/* Mystery Dinner — App Theme */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0b0e;
  --surface:   #1a1520;
  --surface2:  #221d2b;
  --border:    #332b3f;
  --text:      #e8ddf5;
  --muted:     #7a6a8a;
  --accent:    #c49a3f;
  --accent2:   #8b5cf6;
  --danger:    #ef4444;
  --success:   #22c55e;
  --radius:    8px;
  --font:      'Georgia', serif;
  --font-ui:   'system-ui', sans-serif;
}

body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.app-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem; height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.app-nav .logo { font-size: 1.2rem; color: var(--accent); letter-spacing: .05em; }
.app-nav .nav-links { display: flex; gap: 1.5rem; font-family: var(--font-ui); font-size: .9rem; }
.app-nav .nav-links a { color: var(--muted); }
.app-nav .nav-links a:hover { color: var(--text); text-decoration: none; }

.app-main { flex: 1; padding: 2rem; max-width: 1100px; margin: 0 auto; width: 100%; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
}
.card + .card { margin-top: 1rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem 1.25rem; border-radius: var(--radius);
  font-family: var(--font-ui); font-size: .9rem; font-weight: 500;
  cursor: pointer; border: none; transition: opacity .15s;
  text-decoration: none;
}
.btn:hover { opacity: .85; text-decoration: none; }
.btn-primary { background: var(--accent); color: #000; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .8rem 1.75rem; font-size: 1rem; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: .4rem; font-family: var(--font-ui); font-size: .85rem; color: var(--muted); }
.form-control {
  width: 100%; padding: .65rem .9rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font-ui); font-size: .95rem;
}
.form-control:focus { outline: none; border-color: var(--accent2); }
select.form-control option { background: var(--surface2); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Auth pages */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; }
.auth-box { width: 100%; max-width: 420px; }
.auth-logo { text-align: center; margin-bottom: 2rem; font-size: 1.5rem; color: var(--accent); }
.auth-logo span { display: block; font-family: var(--font-ui); font-size: .85rem; color: var(--muted); margin-top: .25rem; }

/* Alerts */
.alert { padding: .75rem 1rem; border-radius: var(--radius); font-family: var(--font-ui); font-size: .9rem; margin-bottom: 1rem; }
.alert-error { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.15); border: 1px solid rgba(34,197,94,.3); color: #86efac; }

/* Dashboard game grid */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.game-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; display: flex; flex-direction: column; gap: .5rem;
  transition: border-color .15s;
}
.game-card:hover { border-color: var(--accent2); }
.game-card .gc-title { font-size: 1.05rem; font-weight: 600; }
.game-card .gc-meta { font-family: var(--font-ui); font-size: .8rem; color: var(--muted); }
.game-card .gc-actions { display: flex; gap: .5rem; margin-top: auto; padding-top: .75rem; }
.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 4px;
  font-family: var(--font-ui); font-size: .75rem; font-weight: 600;
}
.badge-draft    { background: rgba(122,106,138,.2); color: var(--muted); }
.badge-building { background: rgba(139,92,246,.2); color: #a78bfa; }
.badge-complete { background: rgba(34,197,94,.2); color: #86efac; }
.badge-published{ background: rgba(196,154,63,.2); color: var(--accent); }

/* Builder chat */
.builder-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; height: calc(100vh - 100px); }
.chat-panel { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.chat-msg { max-width: 85%; }
.chat-msg.user { align-self: flex-end; }
.chat-msg.assistant { align-self: flex-start; }
.chat-msg .bubble {
  padding: .75rem 1rem; border-radius: var(--radius);
  font-size: .9rem; line-height: 1.6; white-space: pre-wrap;
}
.chat-msg.user .bubble { background: var(--accent2); color: #fff; }
.chat-msg.assistant .bubble { background: var(--surface2); border: 1px solid var(--border); }
.chat-input-row { display: flex; gap: .75rem; padding: 1rem; border-top: 1px solid var(--border); }
.chat-input-row textarea { flex: 1; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: .65rem .9rem; resize: none; font-family: var(--font-ui); font-size: .9rem; }
.chat-input-row textarea:focus { outline: none; border-color: var(--accent2); }

/* Stage sidebar */
.stage-panel { display: flex; flex-direction: column; gap: 1rem; overflow-y: auto; }
.stage-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.stage-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .9rem; border-radius: var(--radius); font-family: var(--font-ui); font-size: .85rem; }
.stage-item.done { color: var(--success); }
.stage-item.active { background: var(--surface2); color: var(--text); }
.stage-item.pending { color: var(--muted); }

/* Host packet */
.packet-section { margin-bottom: 2rem; }
.packet-section h2 { font-size: 1.1rem; border-bottom: 1px solid var(--border); padding-bottom: .5rem; margin-bottom: 1rem; }
.char-sheet { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.char-sheet h3 { color: var(--accent); margin-bottom: .75rem; }
.char-field { margin-bottom: .5rem; font-size: .9rem; }
.char-field strong { color: var(--muted); font-weight: 600; }

/* Print styles for host packet */
@media print {
  .app-nav, .no-print { display: none; }
  body { background: #fff; color: #000; }
  .card, .char-sheet { border: 1px solid #ccc; }
  .char-sheet h3 { color: #8b4513; }
}

/* Responsive */
@media (max-width: 768px) {
  .builder-layout { grid-template-columns: 1fr; height: auto; }
  .stage-panel { display: none; }
  .app-main { padding: 1rem; }
}
