﻿/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: #0a0a0a;
  color: #f0f0f0;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; background: none; }
input  { font-family: inherit; outline: none; }

/* ─── Design Tokens ───────────────────────────────────────────────────────── */
:root {
  --bg:            #0a0a0a;
  --surf:          #111111;
  --surf2:         #181818;
  --surf3:         #222222;
  --border:        rgba(255,255,255,.09);
  --border-strong: rgba(255,255,255,.16);
  --text:          #f0f0f0;
  --muted:         #777;
  --accent:        #e07b39;
  --accent2:       #c4622a;
  --success:       #4ade80;
  --error:         #f05050;
  --radius:        4px;
  --radius-sm:     3px;
  --shadow:        0 8px 40px rgba(0,0,0,.8);
  --transition:    .18s cubic-bezier(.4,0,.2,1);
}

/* ─── Screens ─────────────────────────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0; overflow-y: auto; overscroll-behavior: none;
  opacity: 0; pointer-events: none;
  transform: translateY(10px);
  transition: opacity .28s ease, transform .28s ease;
  background: var(--bg); z-index: 1;
}
.screen.active { opacity: 1; pointer-events: all; transform: translateY(0); z-index: 2; }
.screen-inner { width: 100%; max-width: 480px; margin: 0 auto; padding: 24px 20px 120px; min-height: 100dvh; }
.center-col { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100dvh; text-align: center; gap: 14px; }

/* ─── Typography ──────────────────────────────────────────────────────────── */
h1 { font-size: 2.4rem; font-weight: 700; letter-spacing: -.04em; line-height: 1; }
h2 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.025em; line-height: 1.2; }
h3 { font-size: 1.05rem; font-weight: 600; }
p  { font-size: .95rem; line-height: 1.55; }
.muted      { color: var(--muted); }
.small      { font-size: .8rem; }
.label      { font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.text-bright{ color: var(--text); font-weight: 600; }
.word-accent{ color: var(--accent); font-weight: 700; font-size: 1.1rem; }
.mt-16      { margin-top: 16px; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 24px; border-radius: var(--radius);
  font-size: .93rem; font-weight: 700; letter-spacing: .01em;
  transition: var(--transition); white-space: nowrap;
}
.btn svg    { width: 17px; height: 17px; flex-shrink: 0; }
.btn-lg     { padding: 16px 32px; font-size: 1rem; width: 100%; max-width: 320px; }
.btn-full   { width: 100%; }

.btn-primary {
  background: var(--accent); color: #fff; border: 2px solid var(--accent);
}
.btn-primary:hover  { background: transparent; color: var(--accent); }
.btn-primary:active { background: var(--accent2); color: #fff; border-color: var(--accent2); }

.btn-ghost {
  background: transparent; color: var(--text); border: 2px solid var(--border-strong);
}
.btn-ghost:hover  { border-color: var(--text); }
.btn-ghost:active { background: var(--surf2); }

.btn-back {
  position: absolute; top: 20px; left: 16px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); border: 2px solid var(--border-strong);
  background: transparent; color: var(--text); transition: var(--transition);
}
.btn-back svg   { width: 18px; height: 18px; }
.btn-back:hover { border-color: var(--text); background: var(--surf2); }

/* ─── Inputs ──────────────────────────────────────────────────────────────── */
.inp {
  width: 100%; background: transparent;
  border: 0; border-bottom: 2px solid var(--border-strong);
  color: var(--text); padding: 12px 4px;
  border-radius: 0; font-size: 1rem; transition: border-color .2s;
}
.inp:focus        { border-bottom-color: var(--accent); }
.inp::placeholder { color: var(--muted); }
.inp-code {
  text-transform: uppercase; letter-spacing: .3em;
  font-size: 1.6rem; font-weight: 700; text-align: center;
  padding: 16px 4px; border-bottom-width: 3px;
}
.inp-xl {
  font-size: 1.6rem; font-weight: 700; text-align: center;
  padding: 20px 4px; border-bottom-width: 3px;
}
.inp-sm     { padding: 8px 4px; font-size: .9rem; }
.form-group { width: 100%; }
.error-msg  { color: var(--error); font-size: .83rem; margin-top: 8px; text-align: left; }
.error-msg.hidden { display: none; }

/* ─── HOME ────────────────────────────────────────────────────────────────── */
.hero-bg { position: fixed; inset: 0; z-index: 0; }
.hero-bg img { width: 100%; height: 100%; object-fit: cover; filter: brightness(.18) saturate(.4); }
.hero-overlay { position: absolute; inset: 0; background: linear-gradient(155deg, rgba(10,10,10,.3) 0%, #0a0a0a 72%); }
#screen-home .screen-inner { position: relative; z-index: 1; }

.app-title { font-size: 2.8rem; letter-spacing: -.05em; line-height: .95; }
.title-rule { display: block; width: 40px; height: 3px; background: var(--accent); margin: 10px auto 0; }
.app-sub    { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.home-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; margin-top: 12px; }

/* ─── Lobby Screens ───────────────────────────────────────────────────────── */
#screen-name .screen-inner { position: relative; }
.screen-header { text-align: center; }
.screen-header h2 { margin-bottom: 6px; }
#screen-host-lobby   .screen-inner,
#screen-player-lobby .screen-inner { padding-top: 68px; }
#screen-host-lobby   .screen-inner { padding-bottom: 40px; }

.lobby-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; margin-top: 8px; }
.room-code-display { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.room-code-display span { font-size: 2rem; font-weight: 700; letter-spacing: .2em; color: var(--accent); }
.btn-copy {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius); border: 1.5px solid var(--border-strong);
  background: transparent; color: var(--muted); transition: var(--transition);
}
.btn-copy svg   { width: 14px; height: 14px; }
.btn-copy:hover { color: var(--text); border-color: var(--text); }
.player-count-badge {
  display: flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius); padding: 6px 12px;
  font-size: .85rem; font-weight: 700; color: var(--muted); letter-spacing: .04em;
}
.player-count-badge svg { width: 14px; height: 14px; }

/* ─── Player List ─────────────────────────────────────────────────────────── */
.player-list {
  display: flex; flex-direction: column; gap: 0;
  margin-bottom: 20px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.player-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surf2);
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  animation: slideIn .2s ease;
}
.player-item:last-child { border-bottom: none; }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.player-avatar {
  width: 32px; height: 32px; border-radius: var(--radius);
  background: var(--surf3);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; flex-shrink: 0;
  color: var(--accent); border: 1.5px solid rgba(224,123,57,.25);
}
.player-name { font-weight: 600; flex: 1; font-size: .93rem; }
.host-badge {
  font-size: .68rem; font-weight: 700;
  background: rgba(224,123,57,.15); color: var(--accent);
  padding: 2px 7px; border-radius: var(--radius-sm);
  letter-spacing: .06em; text-transform: uppercase;
}
.you-badge  { font-size: .7rem; color: var(--muted); font-style: italic; }
.player-list.compact .player-item { padding: 10px 12px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ─── Game Card ───────────────────────────────────────────────────────────── */
.game-card-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.game-card {
  border-radius: var(--radius); overflow: hidden;
  background: var(--surf2); border: 2px solid var(--border);
  cursor: pointer; transition: border-color var(--transition);
}
.game-card.selected { border-color: var(--accent); }
.game-card-img { position: relative; aspect-ratio: 16/7; overflow: hidden; }
.game-card-img img { width: 100%; height: 100%; object-fit: cover; filter: brightness(.55); transition: filter .3s; }
.game-card:hover .game-card-img img { filter: brightness(.7); }
.game-card-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(224,123,57,.2); opacity: 0; transition: opacity .2s;
}
.game-card.selected .game-card-overlay { opacity: 1; }
.check-icon { width: 34px; height: 34px; color: #fff; filter: drop-shadow(0 2px 8px rgba(0,0,0,.6)); }
.game-card-body { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; }
.game-card-name { font-weight: 700; font-size: .93rem; }
.game-card-tag  {
  font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: var(--surf3); color: var(--muted); padding: 3px 8px; border-radius: var(--radius-sm);
}

/* ─── Settings ────────────────────────────────────────────────────────────── */
.settings-list      { display: flex; flex-direction: column; gap: 18px; }
.setting-row        { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setting-label      { font-weight: 600; font-size: .93rem; }
.setting-desc       { font-size: .76rem; color: var(--muted); margin-top: 3px; }
.custom-time-row    { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: -6px; }
.custom-time-inp    { width: 110px; text-align: center; }
.segmented          { display: flex; border: 1.5px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; flex-shrink: 0; }
.seg-btn {
  padding: 7px 14px; font-size: .8rem; font-weight: 700;
  letter-spacing: .04em; color: var(--muted); transition: var(--transition);
  border-right: 1px solid var(--border); text-transform: uppercase;
}
.seg-btn:last-child            { border-right: none; }
.seg-btn.active                { background: var(--accent); color: #fff; }
.seg-btn:hover:not(.active)    { color: var(--text); background: var(--surf3); }

/* Category picker */
.category-search-wrap          { position: relative; margin-bottom: 12px; }
.category-search-wrap svg      { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.category-search-wrap .inp     { padding-left: 26px; }
.category-grid                 { display: grid; grid-template-columns: repeat(2,1fr); gap: 6px; max-height: 260px; overflow-y: auto; padding-right: 4px; }
.category-grid::-webkit-scrollbar { width: 3px; }
.category-grid::-webkit-scrollbar-thumb { background: var(--surf3); }
.cat-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; background: var(--surf2);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .8rem; font-weight: 600; color: var(--muted);
  transition: var(--transition); overflow: hidden; text-align: left;
}
.cat-btn img { width: 26px; height: 26px; border-radius: 2px; object-fit: cover; flex-shrink: 0; filter: brightness(.65); }
.cat-btn.selected, .cat-btn:hover { border-color: var(--accent); color: var(--text); }
.cat-btn.selected  { background: rgba(224,123,57,.1); }
.cat-btn.selected img, .cat-btn:hover img { filter: brightness(.85); }
.cat-btn span      { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Sticky Bottom ───────────────────────────────────────────────────────── */
.sticky-bottom {
  width: 100%; padding: 24px 0 16px;
  display: flex; flex-direction: column; gap: 8px;
}

/* ─── Waiting ─────────────────────────────────────────────────────────────── */
.waiting-art { position: relative; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.pulse-ring  {
  position: absolute; width: 72px; height: 72px;
  border: 2px solid var(--accent); opacity: .25;
  animation: pulse 2.2s ease infinite; transform: rotate(45deg);
}
.pulse-ring-2 { animation-delay: .7s; }
@keyframes pulse {
  0%   { transform: rotate(45deg) scale(.85); opacity: .25; }
  50%  { transform: rotate(45deg) scale(1.35); opacity: .05; }
  100% { transform: rotate(45deg) scale(.85); opacity: .25; }
}
.waiting-icon    { width: 44px; height: 44px; color: var(--accent); }
.room-code-chip  {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius); padding: 8px 16px;
  font-weight: 700; letter-spacing: .18em; font-size: .95rem;
  color: var(--accent); margin: 4px 0; text-transform: uppercase;
}
.room-code-chip svg { width: 15px; height: 15px; }

/* ─── Phase Chip ──────────────────────────────────────────────────────────── */
.phase-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius); padding: 5px 12px;
  font-size: .72rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
  align-self: flex-start;
}
.phase-chip svg        { width: 13px; height: 13px; }
.center-col .phase-chip{ align-self: center; }

/* ─── Category Reveal ─────────────────────────────────────────────────────── */
.category-reveal-card {
  width: 100%; max-width: 360px;
  border-radius: var(--radius); overflow: hidden; position: relative;
  aspect-ratio: 16/9; background: var(--surf2);
  border: 1.5px solid var(--border); margin: 8px 0;
}
.category-reveal-card img { width: 100%; height: 100%; object-fit: cover; filter: brightness(.4); }
.category-reveal-overlay  { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.category-reveal-overlay .label { margin: 0; }
.category-reveal-overlay h2     { font-size: 1.9rem; }

/* ─── Role Box ────────────────────────────────────────────────────────────── */
.role-box {
  display: flex; align-items: center; gap: 14px;
  width: 100%; max-width: 360px;
  padding: 16px 18px; border-radius: var(--radius);
  border-left: 4px solid var(--border-strong);
  border-top: 1.5px solid var(--border);
  border-right: 1.5px solid var(--border);
  border-bottom: 1.5px solid var(--border);
  background: var(--surf2); text-align: left;
  animation: scaleIn .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes scaleIn {
  from { transform: scale(.94); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.role-box svg  { width: 26px; height: 26px; flex-shrink: 0; }
.shadow-box    { border-left-color: var(--error); background: rgba(240,80,80,.06); }
.shadow-box svg{ color: var(--error); }
.word-box      { border-left-color: var(--accent); background: rgba(224,123,57,.06); }
.word-box svg  { color: var(--accent); }
.role-title    { font-size: .88rem; color: var(--muted); }
.role-title strong { color: var(--text); }
.word-big      { font-size: 2rem; font-weight: 700; color: var(--accent); letter-spacing: -.03em; margin-top: 2px; }

/* ─── Clue Input ──────────────────────────────────────────────────────────── */
.clue-category-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid rgba(224,123,57,.35);
  border-radius: var(--radius); padding: 5px 12px;
  font-size: .8rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 4px;
}
.clue-category-chip svg     { width: 13px; height: 13px; }
#clue-input-area            { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.clue-progress-wrap         { width: 100%; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.clue-progress-bar          { width: 100%; height: 3px; background: var(--surf3); overflow: hidden; }
.clue-progress-fill         { height: 100%; background: var(--accent); transition: width .4s ease; }
.submitted-msg              { display: flex; align-items: center; gap: 8px; color: var(--success); font-size: .9rem; font-weight: 600; }
.submitted-msg svg          { width: 17px; height: 17px; }
.screen-section-title       { margin-bottom: 4px; }

/* ─── Clues Review ────────────────────────────────────────────────────────── */
.clues-review-list {
  display: flex; flex-direction: column; gap: 0; width: 100%; margin: 12px 0;
  border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.clue-review-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surf2); border-bottom: 1px solid var(--border); padding: 11px 14px;
}
.clue-review-item:last-child          { border-bottom: none; }
.clue-review-item .player-avatar      { width: 28px; height: 28px; font-size: .75rem; }
.clue-review-name                     { font-size: .8rem; color: var(--muted); flex: 1; }
.clue-review-word                     { font-weight: 700; font-size: .98rem; color: var(--text); }
.clue-review-item.is-shadow           { border-left: 3px solid var(--error); background: rgba(240,80,80,.05); }
.clue-review-item.is-shadow .clue-review-word { color: var(--error); }

/* ─── Voting ──────────────────────────────────────────────────────────────── */
.vote-player-list {
  display: flex; flex-direction: column; gap: 0; width: 100%; margin: 8px 0;
  border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.vote-player-btn {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px 16px;
  background: var(--surf2); border-bottom: 1px solid var(--border);
  color: var(--text); text-align: left;
  transition: var(--transition); font-size: .93rem; font-weight: 600;
}
.vote-player-btn:last-child             { border-bottom: none; }
.vote-player-btn:hover:not(:disabled)   { background: var(--surf3); }
.vote-player-btn:disabled               { opacity: .35; cursor: not-allowed; }
.vote-player-btn.selected-vote          { background: rgba(240,80,80,.08); border-left: 3px solid var(--error); }
.vote-player-btn.selected-vote .player-avatar { border-color: var(--error); color: var(--error); }
.vote-progress-wrap                     { margin-top: 8px; }

/* ─── Results ─────────────────────────────────────────────────────────────── */
.results-hero { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 0 16px; text-align: center; }
.results-outcome-icon {
  width: 60px; height: 60px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; margin-bottom: 4px;
}
.results-outcome-icon svg { width: 28px; height: 28px; }
.outcome-caught  { background: rgba(74,222,128,.1);  border: 2px solid rgba(74,222,128,.35); color: var(--success); }
.outcome-escaped { background: rgba(240,80,80,.1);   border: 2px solid rgba(240,80,80,.35);  color: var(--error); }
.outcome-verbal  { background: rgba(224,123,57,.1);  border: 2px solid rgba(224,123,57,.35); color: var(--accent); }

.result-detail-card  { width: 100%; background: var(--surf2); border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.result-stat-row     { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.result-stat-row:last-child { border-bottom: none; }

.vote-tally       { width: 100%; background: var(--surf2); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; }
.vote-tally-title { font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.vote-tally-row   { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.vote-tally-name  { font-size: .88rem; font-weight: 600; flex: 1; }
.vote-tally-bar-wrap { flex: 2; height: 4px; background: var(--surf3); overflow: hidden; }
.vote-tally-bar   { height: 100%; background: var(--accent); }
.vote-tally-count { font-size: .82rem; color: var(--muted); width: 20px; text-align: right; }

/* ─── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surf3); border: 1.5px solid var(--border-strong);
  color: var(--text); padding: 10px 20px;
  border-radius: var(--radius); font-size: .86rem; font-weight: 600;
  z-index: 999; transition: transform .28s cubic-bezier(.34,1.56,.64,1), opacity .28s;
  opacity: 0; white-space: nowrap; box-shadow: var(--shadow);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ─── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surf3); }

/* ─── Safe area ───────────────────────────────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sticky-bottom { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* ─── Player Lobby (non-center-col) ──────────────────────────────────────── */
.player-lobby-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 0 20px;
  gap: 12px;
}

/* ─── Pre-game Panel ──────────────────────────────────────────────────────── */
#pregame-panel {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 4px;
  margin-bottom: 80px;
}
.pregame-toggle {
  width: 100%;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surf2);
  border-bottom: 1.5px solid var(--border);
  transition: var(--transition);
  text-align: left;
}
.pregame-toggle svg { transition: transform .25s ease; flex-shrink: 0; }
.pregame-toggle:hover { color: var(--text); }
.pregame-body { padding: 14px; display: none; background: var(--surf); }
.pregame-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.pregame-tab-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pgame-tab {
  padding: 5px 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-strong);
  font-size: .78rem; font-weight: 700;
  color: var(--muted);
  background: transparent;
  transition: var(--transition);
}
.pgame-tab.active  { background: var(--accent); color: #fff; border-color: var(--accent); }
.pgame-tab:hover:not(.active) { color: var(--text); }
.switch-vote-chip  { font-size: .76rem; color: var(--muted); padding: 2px 0; }

/* ─── Memory Match ────────────────────────────────────────────────────────── */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  perspective: 600px;
}
.mem-card {
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surf3);
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .38s ease, border-color .2s;
}
.mem-card:hover:not(.matched) { border-color: var(--accent); }
.mem-card.matched { border-color: var(--accent); opacity: .55; cursor: default; }
.mem-card.flipped { transform: rotateY(180deg); }
.mem-front,
.mem-back {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: inherit;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.mem-back {
  background: var(--surf3);
}
.mem-back-mark {
  font-size: 1.3rem; font-weight: 900;
  color: var(--border);
  letter-spacing: -.02em;
  user-select: none;
}
.mem-front {
  transform: rotateY(180deg);
  background: var(--surf2);
}
.mem-word {
  font-size: .78rem; font-weight: 800;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
  user-select: none;
}
.memory-scores-row {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px;
}
.mem-score-item {
  display: flex; align-items: center; gap: 5px;
  font-size: .8rem; font-weight: 600;
}
.mem-score-val { color: var(--accent); font-weight: 700; }

/* ─── Drawing Canvas ──────────────────────────────────────────────────────── */
.draw-toolbar {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.color-palette { display: flex; gap: 6px; align-items: center; }
.color-dot {
  width: 22px; height: 22px;
  border-radius: 3px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.color-dot.active  { border-color: var(--text); transform: scale(1.15); }
.color-dot:hover:not(.active) { transform: scale(1.1); }
.draw-canvas {
  display: block; width: 100%; height: 220px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surf3);
  cursor: crosshair;
  touch-action: none;
}

/* ─── Chadlib Writing Screen ──────────────────────────────────────────────── */
.chadlib-phase-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.chadlib-timer-bar {
  width: 100%; height: 4px;
  background: var(--surf3);
  margin-bottom: 18px;
  overflow: hidden;
}
.chadlib-timer-fill {
  height: 100%;
  background: var(--accent);
  transition: width .25s linear;
}
.chadlib-prev-segments { margin-bottom: 16px; }
.chadlib-prev-seg {
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.chadlib-prev-seg:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.chadlib-prev-author {
  display: block;
  font-size: .68rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 4px;
}
.chadlib-prev-text {
  font-size: .93rem; line-height: 1.65;
  color: var(--text); opacity: .65;
}
.chadlib-write-area { margin-bottom: 8px; }
.chadlib-textarea {
  width: 100%;
  background: var(--surf2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 14px 16px;
  font-size: .95rem; font-family: inherit;
  line-height: 1.65; resize: none;
  min-height: 150px;
  transition: border-color .2s;
}
.chadlib-textarea:focus { border-color: var(--accent); outline: none; }
.chadlib-write-footer {
  display: flex; justify-content: flex-end;
  margin-top: 6px;
}

/* ─── Chadlib Gallery Screen ──────────────────────────────────────────────── */
.chadlib-story-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 100px; }
.chadlib-story-card {
  background: var(--surf2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.chadlib-story-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surf3);
}
.chadlib-story-body { padding: 14px; display: flex; flex-direction: column; gap: 0; }
.chadlib-seg { display: flex; flex-direction: column; gap: 3px; margin-bottom: 12px; }
.chadlib-seg:last-child { margin-bottom: 0; }
.chadlib-seg-author {
  font-size: .68rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent);
}
.chadlib-seg-text { font-size: .93rem; line-height: 1.65; }
.chadlib-seg-divider {
  font-size: .72rem; text-align: center;
  color: var(--muted); padding: 8px 0;
  letter-spacing: .06em;
}

/* ═══════════════════════════════════════════════════════════
   Shadow Word — Word List, Hide Toggle, Word Reminder
   ═══════════════════════════════════════════════════════════ */

/* Shadow "role box" header row */
.role-box-header {
  display: flex; align-items: flex-start; gap: 12px; width: 100%;
}
.role-box-header > svg { flex-shrink: 0; width: 22px; height: 22px; margin-top: 2px; }
.role-box-header > div { flex: 1; }
.word-reveal-main { flex: 1; }

/* Hide/show eye toggle button */
.hide-toggle {
  flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  padding: 4px;
  color: var(--muted);
  transition: color .15s;
  margin-left: auto;
}
.hide-toggle:hover { color: var(--text); }
.hide-toggle svg { width: 18px; height: 18px; display: block; }

/* Shadow cheat-sheet word list */
.shadow-wordlist {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 12px;
  transition: opacity .25s;
}

/* Word pills */
.word-pill {
  background: var(--surf2, #2a2a2a);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 12px;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: .01em;
}
.word-pill-sm {
  padding: 3px 8px;
  font-size: .78rem;
}

/* Word reminder bar (on clue + voting screens) */
.word-reminder-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surf2, #1e1e1e);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 14px;
  width: 100%;
  box-sizing: border-box;
}
.word-reminder-content { flex: 1; min-width: 0; }
.wr-label {
  font-size: .65rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  display: block; margin-bottom: 4px;
}
.wr-word {
  font-size: 1.05rem; font-weight: 700;
  color: var(--accent);
  letter-spacing: .02em;
}
.wr-pills {
  display: flex; flex-wrap: wrap; gap: 5px;
  transition: opacity .25s;
}

/* Live clue feed */
.live-clue-feed {
  width: 100%;
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 12px;
}
.live-clue-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--surf2, #1e1e1e);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: fadeIn .25s ease;
}
.live-clue-item.mine { border-color: var(--accent); }
.live-clue-name {
  flex: 1; font-size: .82rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.live-clue-word {
  font-size: .95rem; font-weight: 700;
  color: var(--text); letter-spacing: .02em;
}
.live-clue-roundlabel {
  font-size: .68rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  margin: 6px 0 2px; padding: 0;
}

/* More-clue vote panel */
.more-clue-vote-panel {
  width: 100%; margin-top: 16px;
  background: var(--surf, #161616);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
}
.more-clue-q {
  font-size: 1rem; font-weight: 600;
  margin: 0 0 16px; color: var(--text);
}
.more-clue-btns {
  display: flex; gap: 10px; justify-content: center;
  margin-bottom: 12px;
}
.more-clue-btns .btn { min-width: 110px; }

/* Round label in clue review lists */
.clue-round-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  margin: 10px 0 4px; padding: 0;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--surf1); border: 1.5px solid var(--border-strong);
  border-radius: calc(var(--radius) * 2);
  padding: 28px 24px 24px;
  width: 100%; max-width: 380px;
  text-align: center;
}
.modal-badge {
  display: inline-block; font-size: 1.1rem; font-weight: 800;
  background: var(--accent); color: #0a0a0a;
  border-radius: var(--radius); padding: 3px 12px;
  margin-bottom: 14px; letter-spacing: .05em;
}
.modal-box h3 { margin: 0 0 6px; font-size: 1.2rem; }
.tos-rules {
  text-align: left; margin-bottom: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.tos-rule {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: .82rem; color: var(--muted); line-height: 1.5;
}
.tos-rule svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; color: var(--accent); }
.tos-check-row {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: .83rem; color: var(--text);
  background: var(--surf2); border-radius: var(--radius);
  padding: 12px; margin-bottom: 20px;
  text-align: left; cursor: pointer; line-height: 1.5;
}
.tos-check-row input[type=checkbox] { flex-shrink: 0; accent-color: var(--accent); width: 15px; height: 15px; margin-top: 1px; }
.modal-btns { display: flex; gap: 10px; }
.modal-btns .btn { flex: 1; }
/* ─── Terms Agreement Checkbox ────────────────────────────────────────────── */
.terms-agree {
  width: 100%;
  margin-top: 6px;
  margin-bottom: 4px;
  text-align: left;
}
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.5;
  cursor: pointer;
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.checkbox-label .checkmark {
  flex-shrink: 0;
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong);
  border-radius: 3px;
  margin-top: 1px;
  transition: background var(--transition), border-color var(--transition);
  position: relative;
}
.checkbox-label .checkmark::after {
  content: '';
  position: absolute;
  left: 5px; top: 1px;
  width: 5px; height: 10px;
  border: solid #0a0a0a;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  opacity: 0;
  transition: opacity var(--transition);
}
.checkbox-label input[type="checkbox"]:checked ~ .checkmark {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox-label input[type="checkbox"]:checked ~ .checkmark::after {
  opacity: 1;
}
.checkbox-label a {
  color: var(--accent);
  text-decoration: none;
}
.checkbox-label a:hover {
  text-decoration: underline;
}

/* ─── Home Footer Links ───────────────────────────────────────────────────── */
.home-footer {
  margin-top: 20px;
  font-size: .78rem;
  color: var(--muted);
}
.home-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color var(--transition);
}
.home-footer a:hover {
  color: var(--accent);
}
.footer-dot {
  margin: 0 6px;
}