/* ================================================================
   Imposter — risograph party-poster theme
   Printed-ink palette, halftone grain, taped-down cards.
   Built to feel screen-printed and hand-assembled, not generated.
   ================================================================ */

:root {
  /* ---- palette: Poster (the default riso look) ---- */
  --paper:  #f1e8d5;   /* warm oat paper                 */
  --paper2: #eaddc2;   /* slightly deeper paper          */
  --ink:    #201d18;   /* near-black warm ink            */
  --poppy:  #e8482d;   /* riso red-orange                */
  --sun:    #f4b52a;   /* riso yellow                    */
  --teal:   #146b64;   /* deep riso teal                 */
  --mint:   #2fae6b;   /* the "I'm in" green             */
  --mut:    #6b6355;   /* muted brown-grey text          */

  /* ---- surfaces + text-on-accent (semantic, swapped per theme) ---- */
  --card:      #fffdf6;  /* card / input / ticket surface        */
  --card-alt:  #fff8ec;  /* a flipped reveal card                */
  --tint-imp:  #fdece7;  /* the imposter's tinted card / row     */
  --tint-warm: #fff5e0;  /* "around the table" mode card         */
  --tint-cool: #e6f2f0;  /* "on a call" mode card                */
  --on-accent: #fffdf6;  /* light text on poppy/teal/mint        */
  --on-sun:    #201d18;  /* dark text on the yellow accent        */

  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --radius: 14px;

  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "DM Sans", system-ui, sans-serif;
  --hand: "Shantell Sans", "Comic Sans MS", cursive;
  --mono: "Space Mono", ui-monospace, monospace;
}

/* =================== THEMES ===================
   Each theme just re-points the palette variables; because every rule below
   uses var(--...), the whole UI (borders and offset-shadows included, since
   those resolve var(--ink) lazily) re-skins itself. Poster is the :root above. */
[data-theme="bubblegum"] {
  --paper: #fbe9f0; --paper2: #f6d7e6;
  --poppy: #e5407e; --sun: #ffbf4d; --teal: #8a5cc4; --mint: #34b877;
  --mut: #86657a;
}
[data-theme="matcha"] {
  --paper: #eef0dc; --paper2: #e2e6c8;
  --poppy: #d1622b; --sun: #e8b93a; --teal: #4a7c3f; --mint: #5aa84a;
  --mut: #6f7256;
}
[data-theme="grape"] {
  --paper: #efe9f5; --paper2: #e2d8ee;
  --poppy: #7c4dff; --sun: #f0a93a; --teal: #3f8f8a; --mint: #34b877;
  --mut: #6f6580;
}
[data-theme="sunset"] {
  --paper: #fdeadf; --paper2: #f8d8c6;
  --poppy: #ef5a3c; --sun: #ffb02e; --teal: #b5507a; --mint: #45b58a;
  --mut: #7d6558;
}
[data-theme="ocean"] {
  --paper: #e6eff2; --paper2: #d3e5ea;
  --poppy: #ef6a4d; --sun: #f2b53a; --teal: #1f6f8b; --mint: #2fae9b;
  --mut: #5f6d72;
}
[data-theme="midnight"] {
  --paper: #16151c; --paper2: #201e28;
  --ink: #ece4d6;
  --poppy: #ff6a4d; --sun: #ffcb47; --teal: #35b3a3; --mint: #4fd08a;
  --mut: #9a9384;
  --card: #232029; --card-alt: #2b2732;
  --tint-imp: #3a231f; --tint-warm: #2c2820; --tint-cool: #1f2b2a;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--body);
  color: var(--ink);
  background-color: var(--paper);
  /* faint halftone dots baked into the paper */
  background-image: radial-gradient(var(--paper2) 1.1px, transparent 1.2px);
  background-size: 11px 11px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* speckled print grain floating over everything */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 9;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.stage {
  position: relative; z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 20px 64px;
  min-height: 100vh;
}

/* -------- screen switching -------- */
.screen { display: none; }
.screen.active { display: block; animation: pop 0.28s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* -------- masthead / wordmark -------- */
.masthead { text-align: center; margin: 12px 0 26px; }
.wordmark {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(3.2rem, 15vw, 5.4rem);
  letter-spacing: -0.03em;
  line-height: 0.9;
  margin: 0;
  color: var(--ink);
  text-shadow: 3px 3px 0 var(--sun), 6px 6px 0 var(--poppy);
  position: relative;
  display: inline-block;
}
.scribble { display: block; width: 78%; height: 16px; margin: -2px auto 0; }
.kicker {
  font-family: var(--hand);
  font-size: 1.15rem;
  color: var(--teal);
  margin: 14px 0 0;
  transform: rotate(-1.5deg);
}

/* -------- cards -------- */
.card {
  position: relative;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow);
  margin: 0 0 22px;
}
.center { text-align: center; }
.tilt-l { transform: rotate(-1.1deg); }
.tilt-r { transform: rotate(1.1deg); }

/* strip of "tape" across the top corner */
.card--tape::before {
  content: "";
  position: absolute; top: -12px; left: 50%;
  width: 96px; height: 26px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(244, 181, 42, 0.55);
  border: 1px dashed rgba(32, 29, 24, 0.35);
}

.card-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.55rem;
  margin: 6px 0 8px;
  letter-spacing: -0.02em;
}
.muted { color: var(--mut); margin: 0 0 16px; line-height: 1.45; }
.tiny { font-size: 0.85rem; }
.hint { font-size: 0.85rem; color: var(--mut); margin: 10px 0 0; }
.hint--err { color: var(--poppy); font-weight: 700; }

/* rotated sticker badges */
.sticker {
  position: absolute; top: -14px; right: 14px;
  font-family: var(--hand); font-weight: 700; font-size: 0.9rem;
  color: var(--on-accent); padding: 3px 12px;
  border: 2px solid var(--ink); border-radius: 20px;
  transform: rotate(4deg);
  box-shadow: var(--shadow-sm);
}
.sticker--sun  { background: var(--sun);  color: var(--on-sun); }
.sticker--poppy{ background: var(--poppy); }
.sticker--teal { background: var(--teal); }

/* -------- buttons -------- */
.btn {
  font-family: var(--display); font-weight: 700; font-size: 1.1rem;
  color: var(--on-sun);
  background: var(--sun);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 14px 20px;
  width: 100%;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.06s ease, box-shadow 0.06s ease, background 0.15s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 7px 7px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 2px 2px 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: var(--shadow-sm); }
.btn--go { background: var(--poppy); color: var(--on-accent); }
.btn--tiny { width: auto; font-size: 0.85rem; padding: 10px 14px; box-shadow: var(--shadow-sm); }

/* the star of the show: Play Again */
.btn--again {
  background: var(--sun);
  font-size: 1.25rem;
  padding: 16px;
  margin-top: 4px;
}
.btn--again.is-in {          /* clicked = I'm in */
  background: var(--mint);
  color: var(--on-accent);
}

/* small text links */
.linky {
  display: block; margin: 14px auto 0;
  background: none; border: none;
  font-family: var(--hand); font-size: 1rem;
  color: var(--teal); text-decoration: underline wavy;
  cursor: pointer;
}
.back {
  background: none; border: none;
  font-family: var(--hand); font-size: 1.05rem; color: var(--mut);
  cursor: pointer; margin-bottom: 14px; padding: 4px 0;
}

/* -------- inputs -------- */
.label { display: block; font-weight: 700; margin-bottom: 8px; }
.text-input {
  width: 100%;
  font-family: var(--body); font-size: 1.05rem;
  padding: 12px 14px;
  border: 3px solid var(--ink); border-radius: 10px;
  background: var(--card); color: var(--ink);
}
.text-input:focus { outline: 3px solid var(--sun); outline-offset: 1px; }
.code-input {
  font-family: var(--mono); font-size: 1.6rem; text-align: center;
  text-transform: uppercase; letter-spacing: 0.3em;
}
.name-row { padding: 18px 20px; }

/* -------- interest grid -------- */
.interest-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin: 4px 0 18px;
}
.interest {
  text-align: left;
  background: var(--paper);
  border: 2.5px solid var(--ink); border-radius: 12px;
  padding: 11px 12px; cursor: pointer;
  transition: transform 0.08s ease, background 0.12s ease;
}
.interest:hover { transform: translateY(-2px); }
.interest.on { background: var(--teal); color: var(--on-accent); box-shadow: var(--shadow-sm); }
.interest .i-emoji { font-size: 1.3rem; display: block; }
.interest .i-label { font-weight: 700; display: block; margin-top: 3px; }
.interest .i-blurb { font-size: 0.75rem; opacity: 0.85; display: block; }

/* -------- mode picker -------- */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 4px 0 8px; }
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius);
  padding: 22px 14px; cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.mode-card:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--ink); }
.mode-card--inperson { background: var(--tint-warm); }
.mode-card--online { background: var(--tint-cool); }
.mode-emoji { font-size: 2.4rem; }
.mode-name { font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
.mode-sub { font-size: 0.8rem; color: var(--mut); text-align: center; }

/* -------- theme picker (home screen) -------- */
.theme-row { margin: 20px 0 2px; }
.theme-label {
  display: block; text-align: center;
  font-family: var(--hand); color: var(--teal); font-size: 1.05rem;
  margin-bottom: 10px;
}
.theme-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.theme-swatch {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); color: var(--ink);
  border: 2.5px solid var(--ink); border-radius: 30px;
  padding: 6px 14px 6px 7px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  font-family: var(--display); font-weight: 700; font-size: 0.9rem;
  transition: transform 0.08s ease;
}
.theme-swatch:hover { transform: translate(-1px, -2px); }
.theme-swatch.on { box-shadow: var(--shadow); transform: translate(-1px, -2px); }
.theme-swatch.on .theme-tick { opacity: 1; }
.theme-chip {
  display: inline-flex; width: 24px; height: 24px; flex: none;
  border: 2px solid var(--ink); border-radius: 50%; overflow: hidden;
}
.theme-chip i { display: block; width: 33.34%; height: 100%; }
.theme-tick { opacity: 0; font-size: 0.8rem; margin-left: 2px; }

/* -------- counter -------- */
.counter { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 8px 0 14px; }
.step {
  width: 54px; height: 54px; font-size: 1.8rem; font-family: var(--display);
  color: var(--on-sun);
  background: var(--sun); border: 3px solid var(--ink); border-radius: 50%;
  cursor: pointer; box-shadow: var(--shadow-sm);
}
.step:active { transform: translate(2px, 2px); box-shadow: none; }
.count-num { font-family: var(--display); font-weight: 800; font-size: 3rem; min-width: 60px; text-align: center; }

/* -------- names list -------- */
.names-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.names-list .text-input { padding: 9px 12px; font-size: 0.95rem; }

/* -------- reveal card (the flip) -------- */
.pass-wrap { text-align: center; padding-top: 6px; }
.pass-name {
  font-family: var(--hand); font-weight: 700; font-size: 1.5rem;
  color: var(--teal); margin: 4px 0 16px;
}
.reveal-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  width: 100%; min-height: 300px;
  background: var(--card);
  border: 3px solid var(--ink); border-radius: 20px;
  box-shadow: var(--shadow);
  cursor: pointer; padding: 30px 22px;
  position: relative;
  transition: transform 0.1s ease, background 0.2s ease;
}
.reveal-card::after {         /* halftone corner on the card */
  content: ""; position: absolute; right: 0; bottom: 0; width: 90px; height: 90px;
  border-bottom-right-radius: 20px;
  background-image: radial-gradient(var(--poppy) 1.5px, transparent 1.6px);
  background-size: 9px 9px; opacity: 0.5;
}
.reveal-card:active { transform: scale(0.99); }
.reveal-card.flipped { background: var(--card-alt); }
.reveal-card.imposter { background: var(--tint-imp); }
.reveal-tap { font-family: var(--display); font-weight: 800; font-size: 1.8rem; }
.reveal-sub { font-family: var(--hand); color: var(--mut); font-size: 1.05rem; }
.reveal-role { font-family: var(--hand); font-size: 1.15rem; color: var(--teal); }
.reveal-word {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(2.2rem, 10vw, 3.4rem); letter-spacing: -0.02em;
  line-height: 1; text-align: center;
}
.reveal-cat { font-family: var(--mono); font-size: 0.85rem; color: var(--mut); text-transform: uppercase; letter-spacing: 0.1em; }
.imposter .reveal-word { color: var(--poppy); }
#ip-next, #round-card + .rematch { margin-top: 18px; }

/* -------- ticket (join code) -------- */
.ticket {
  display: flex; align-items: stretch;
  background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden;
}
.ticket-stub {
  background: var(--teal); color: var(--on-accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px 18px; border-right: 3px dashed rgba(255,253,246,0.6);
}
.ticket-label { font-family: var(--hand); font-size: 0.85rem; }
.ticket-code { font-family: var(--mono); font-size: 2.2rem; letter-spacing: 0.15em; }
.ticket-body { padding: 14px 16px; flex: 1; }
.share-row { display: flex; gap: 8px; margin-top: 6px; }
.tiny-input { font-size: 0.8rem; padding: 8px 10px; }

/* -------- player lists -------- */
.player-list { list-style: none; padding: 0; margin: 4px 0 16px; }
.player-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 8px;
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 10px;
  font-weight: 700;
}
.player-list li .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--mut); flex: none; }
.player-list li.ready .dot { background: var(--mint); }
.player-list li .crown { margin-left: auto; font-size: 0.8rem; color: var(--teal); font-family: var(--hand); }
.count-badge {
  font-family: var(--mono); font-size: 0.9rem; background: var(--sun); color: var(--on-sun);
  border: 2px solid var(--ink); border-radius: 20px; padding: 2px 10px; margin-left: 6px;
}

.mini-players { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.mini-players li {
  font-size: 0.82rem; font-weight: 700;
  padding: 5px 11px; border: 2px solid var(--ink); border-radius: 20px;
  background: var(--paper);
}
.mini-players li.ready { background: var(--mint); color: var(--on-accent); }

/* -------- rematch timer -------- */
.rematch-timer { text-align: center; margin: 14px 0 0; }
.timer-num {
  font-family: var(--display); font-weight: 800; font-size: 3.4rem;
  color: var(--poppy); display: block; line-height: 1;
}
.timer-num.snap { animation: snap 0.4s ease; }
@keyframes snap { 0% { transform: scale(1.5); color: var(--mint); } 100% { transform: scale(1); } }
.timer-cap { font-family: var(--hand); color: var(--mut); }

.two-up { display: grid; gap: 18px; }

/* -------- small headings -------- */
.wordmark.small { font-size: clamp(2rem, 9vw, 3rem); text-shadow: 2px 2px 0 var(--sun), 4px 4px 0 var(--poppy); }
.card-title.small { font-size: 1.2rem; }

/* -------- voting -------- */
.vote-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 14px; }
.vote-choice {
  font-family: var(--display); font-weight: 700; font-size: 1.05rem;
  color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); border-radius: 12px;
  padding: 16px 12px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, background 0.12s ease;
}
.vote-choice:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 6px 6px 0 var(--ink); }
.vote-choice.picked { background: var(--poppy); color: var(--on-accent); }
.vote-choice:disabled:not(.picked) { opacity: 0.5; cursor: default; }
.vote-progress {
  font-family: var(--hand); font-size: 1.1rem; color: var(--teal);
  text-align: center; margin: 4px 0 0;
}
#vote-host { text-align: center; }

/* -------- verdict + tally -------- */
.verdict-facts { margin-top: 8px; }
.fact { margin: 6px 0; font-size: 0.95rem; }
.fact-key { font-family: var(--hand); color: var(--mut); }
.fact-val { font-family: var(--display); font-weight: 800; font-size: 1.15rem; margin-left: 4px; }
#verdict-word { color: var(--teal); }
#verdict-imposter { color: var(--poppy); }

.tally-list { list-style: none; padding: 0; margin: 8px 0 0; }
.tally-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; margin-bottom: 8px;
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 10px;
  font-weight: 700;
}
.tally-list li.was-imposter { background: var(--tint-imp); border-color: var(--poppy); }
.tally-name { display: flex; align-items: center; gap: 8px; }
.imp-tag {
  font-family: var(--hand); font-size: 0.75rem; font-weight: 700;
  background: var(--poppy); color: var(--on-accent);
  padding: 1px 8px; border-radius: 20px; border: 2px solid var(--ink);
}
.tally-count { font-family: var(--mono); font-size: 0.9rem; color: var(--mut); }

/* -------- toast -------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  font-weight: 700; padding: 12px 20px; border-radius: 30px;
  box-shadow: var(--shadow-sm); z-index: 20; max-width: 90%;
  font-family: var(--hand); font-size: 1.05rem;
}

/* -------- responsive -------- */
@media (max-width: 480px) {
  .mode-grid, .interest-grid, .vote-grid { grid-template-columns: 1fr; }
  .wordmark { text-shadow: 2px 2px 0 var(--sun), 4px 4px 0 var(--poppy); }
  .ticket { flex-direction: column; }
  .ticket-stub { border-right: none; border-bottom: 3px dashed rgba(255,253,246,0.6); }
}

@media (prefers-reduced-motion: reduce) {
  .screen.active, .timer-num.snap { animation: none; }
  .btn, .mode-card, .reveal-card { transition: none; }
}