/* ------------------------------------------------------------------
   Who's The Imposter?
   Palette matched to the crowned-masks app icon:
   - deep plum/magenta as the ground
   - pink accents (the mask tile)
   - crown gold as the signature metal / primary button
   - collar red for the imposter / danger beat
   - cream for the cards you hold up to your face
------------------------------------------------------------------ */

:root {
  --bg:        #5A1050;   /* plum */
  --bg-deep:   #3C0A36;   /* deep plum shadow */
  --panel:     #63145A;   /* raised panel */
  --panel-2:   #711966;   /* panel hover */
  --line:      #833578;   /* hairline on dark */

  --cream:     #F5EFE1;   /* the card */
  --cream-2:   #EDE4CF;
  --ink:       #23202A;   /* text on cream */
  --ink-soft:  #6B6470;

  --gold:      #F2C63D;   /* crown gold */
  --gold-deep: #C9971C;
  --gold-glow: rgba(242,198,61,0.38);

  --red:       #E8557A;   /* collar coral-red */
  --red-deep:  #C23459;

  --muted:     #E6B8DE;   /* soft pink text on dark */
  --muted-dim: #C088B6;

  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;

  --shadow: 0 18px 40px -18px rgba(0,0,0,0.65);
  --font-display: "Baloo 2", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--cream);
  background:
    radial-gradient(120% 80% at 50% -10%, #9c2a8e55 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.frame {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 22px) 20px calc(env(safe-area-inset-bottom) + 22px);
  display: flex;
  flex-direction: column;
}

/* ---------- screens ---------- */
.screen { display: none; flex-direction: column; flex: 1; animation: rise .32s ease both; }
.screen.is-active { display: flex; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .screen, .screen.is-active { animation: none; }
}

/* ---------- masthead ---------- */
.masthead { text-align: center; margin: 8px 0 22px; }

.masthead__icon {
  width: 96px; height: 96px;
  margin: 0 auto 16px;
  display: block;
  border-radius: 22px;
  box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,0.06);
}

.masthead__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(34px, 10vw, 44px);
  line-height: 1;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--cream);
}
.masthead__title em {
  font-style: normal;
  color: var(--gold);
  text-shadow: 0 1px 0 var(--gold-deep);
}
.masthead__kicker {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}
.masthead__kicker span { color: var(--gold); font-weight: 600; }

/* ---------- panels ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-deep));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.panel--rows { display: flex; flex-direction: column; gap: 4px; padding: 8px 18px; }
.panel__head { margin-bottom: 14px; }

/* ---------- stepper ---------- */
.stepper { display: flex; align-items: center; justify-content: space-between; }
.stepper + .stepper { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.stepper__head { display: flex; flex-direction: column; gap: 3px; }
.stepper__label { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--cream); }
.stepper__hint { font-size: 13px; color: var(--muted-dim); }

.stepper__controls { display: flex; align-items: center; gap: 6px; }
.stepper__value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  min-width: 44px;
  text-align: center;
  color: var(--gold);
}

.round {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--gold-deep);
  background: var(--panel-2);
  color: var(--gold);
  font-size: 24px; font-weight: 700; line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform .12s ease, background .12s ease;
}
.round:hover { background: #7a1f6f; }
.round:active { transform: scale(0.9); }
.round:disabled { opacity: .3; cursor: not-allowed; }

/* ---------- chips (word packs) ---------- */
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chip {
  position: relative;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--cream);
  border-radius: var(--r-md);
  padding: 13px 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color .14s ease, background .14s ease, transform .1s ease;
}
.chip:active { transform: scale(0.98); }
.chip__name { display: block; font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.chip[aria-checked="true"] {
  border-color: var(--gold);
  background: linear-gradient(180deg, #7d1f72, #4c0e44);
  box-shadow: inset 0 0 0 1px var(--gold-glow);
}
.chip[aria-checked="true"] 
/* ---------- toggle ---------- */
.toggle {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 12px 0; cursor: pointer;
}
.toggle__text { display: flex; flex-direction: column; gap: 3px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle__track {
  flex: none;
  width: 52px; height: 30px; border-radius: 20px;
  background: var(--bg-deep); border: 1px solid var(--line);
  position: relative; transition: background .16s ease;
}
.toggle__thumb {
  position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--muted); transition: transform .16s ease, background .16s ease;
}
.toggle input:checked + .toggle__track { background: #7d1f72; border-color: var(--gold-deep); }
.toggle input:checked + .toggle__track .toggle__thumb { transform: translateX(22px); background: var(--gold); }
.toggle input:focus-visible + .toggle__track { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- rowlink ---------- */
.rowlink {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 14px 0;
  background: none; border: none; border-top: 1px solid var(--line);
  color: var(--cream); font-family: var(--font-body); font-size: 16px;
  cursor: pointer;
}
.rowlink .stepper__label { font-size: 16px; }
.rowlink__meta { color: var(--muted-dim); font-size: 14px; }
.rowlink--center { justify-content: center; gap: 8px; color: var(--muted); border: none; }

/* ---------- primary buttons ---------- */
.cta {
  margin-top: auto;
  width: 100%;
  border: none;
  border-radius: var(--r-md);
  padding: 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  cursor: pointer;
  color: #2a1c00;
  background: linear-gradient(180deg, #F0C766, var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 12px 24px -10px var(--gold-glow), inset 0 1px 0 rgba(255,255,255,0.4);
  transition: transform .12s ease, filter .12s ease;
}
.cta:active { transform: translateY(1px) scale(0.995); filter: brightness(1.04); }
.cta + .cta { margin-top: 12px; }
.cta--ghost {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  border: 1px solid var(--line);
  font-weight: 600;
}
.cta--ghost:active { background: var(--panel); }

.fineprint {
  text-align: center; color: var(--muted-dim);
  font-size: 13px; line-height: 1.5; margin: 14px 4px 0;
}

/* ---------- subheads ---------- */
.subhead { display: flex; align-items: center; gap: 12px; margin: 6px 0 6px; }
.subhead--center { justify-content: center; }
.subhead h2 { font-family: var(--font-display); font-weight: 700; font-size: 24px; margin: 0; }
.subhead__note { color: var(--muted-dim); font-size: 14px; margin: 0 0 16px; }
.back {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--cream); font-size: 20px; cursor: pointer;
}

/* ---------- names ---------- */
.namelist { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.namelist input {
  width: 100%; padding: 15px 16px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-md); color: var(--cream);
  font-family: var(--font-body); font-size: 16px;
}
.namelist input::placeholder { color: var(--muted-dim); }
.namelist input:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }

/* ---------- pass / reveal ---------- */
.screen--pass { justify-content: center; align-items: center; gap: 22px; }
.pass__count {
  font-family: var(--font-display); font-weight: 600;
  color: var(--muted); font-size: 16px; margin-top: 4px;
}

.reveal { width: 100%; perspective: 1400px; }

.reveal__card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--r-lg);
  padding: 0;
  cursor: pointer;
  border: none;
  background: none;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform .18s ease;               /* quick flip back on release */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; touch-action: manipulation;
  /* per-player colour, set inline from JS (falls back to kasavu gold) */
  --pc: var(--gold);
  --pc-deep: var(--gold-deep);
  --pc-wash1: var(--cream);
  --pc-wash2: #E7DCC3;
}
/* fallback for browsers with aspect-ratio issues */
@supports not (aspect-ratio: 1 / 1) {
  .reveal__card { height: 0; padding-bottom: 133.33%; }
}
.reveal__card.is-revealed {
  transform: rotateY(180deg);
  transition: transform .5s cubic-bezier(.2,.75,.2,1);   /* satisfying reveal flip */
}

/* the two faces are stacked on top of each other; each hides its own back */
.reveal__cover, .reveal__face {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 30px;
  overflow: hidden;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  color: var(--ink);
  background:
    repeating-linear-gradient(135deg, rgba(0,0,0,0.02) 0 11px, transparent 11px 22px),
    linear-gradient(180deg, var(--pc-wash1), var(--pc-wash2));
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(255,255,255,.65), inset 0 0 0 8px var(--pc), inset 0 0 0 10px var(--pc-deep);
}
.reveal__face { transform: rotateY(180deg); }

/* text sits above the emblem + filigree */
.reveal__content { position: relative; z-index: 3; display: flex; flex-direction: column; align-items: center; }

/* faint category artwork behind the word */
.reveal__emblem {
  position: absolute; inset: 0; z-index: 1;
  display: grid; place-items: center;
  color: var(--pc); opacity: .10; pointer-events: none;
}
.reveal__emblem svg { width: 62%; height: 62%; }

/* casino-style corner filigree + inner frame */
.reveal__deco { position: absolute; inset: 0; z-index: 2; color: var(--pc); pointer-events: none; }
.reveal__deco::before {
  content: ""; position: absolute; inset: 14px;
  border: 1px solid currentColor; border-radius: 16px; opacity: .30;
}
.corner { position: absolute; width: 30px; height: 30px; }
.corner svg { width: 100%; height: 100%; display: block; }
.corner--tl { top: 12px; left: 12px; }
.corner--tr { top: 12px; right: 12px; transform: rotate(90deg); }
.corner--br { bottom: 12px; right: 12px; transform: rotate(180deg); }
.corner--bl { bottom: 12px; left: 12px; transform: rotate(270deg); }

/* imposter overrides everything red so it stays unmistakable */
.reveal__card.is-imposter .reveal__face {
  background:
    repeating-linear-gradient(135deg, rgba(0,0,0,0.02) 0 11px, transparent 11px 22px),
    linear-gradient(180deg, #F3E4DC, #EBD3C7);
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(255,255,255,.65), inset 0 0 0 8px var(--red), inset 0 0 0 10px var(--red-deep);
}
.reveal__card.is-imposter .reveal__face .reveal__deco { color: var(--red); }
.reveal__card.is-imposter .reveal__face .reveal__emblem { display: none; }
.reveal__card.is-imposter .reveal__word { color: var(--red-deep); }
.reveal__card.is-imposter .reveal__role { color: var(--red); }
.reveal__card.is-imposter .reveal__cat  { color: var(--red-deep); }

@media (prefers-reduced-motion: reduce) {
  .reveal__card, .reveal__card.is-revealed { transition: none; }
}

.reveal__pass { font-size: 15px; letter-spacing: .04em; color: var(--ink-soft); }
.reveal__who {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(30px, 9vw, 40px); color: var(--ink); margin: 6px 0 18px;
}
.reveal__tap {
  font-size: 14px; color: var(--pc-deep); font-weight: 600;
  border: 1px solid var(--pc); border-radius: 999px; padding: 8px 16px;
}

.reveal__role {
  font-size: 14px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 600;
}
.reveal__word {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(30px, 9vw, 42px); line-height: 1.05;
  color: var(--ink); margin: 14px 12px; word-break: break-word;
}
.reveal__cat { font-size: 15px; color: var(--pc-deep); font-weight: 600; }

.pass__note {
  text-align: center; color: var(--muted-dim);
  font-size: 13px; line-height: 1.5; margin: 16px 8px 0;
}

/* ---------- discuss ---------- */
.starter {
  text-align: center;
  background: linear-gradient(180deg, var(--panel), var(--bg-deep));
  border: 1px solid var(--gold-deep);
  border-radius: var(--r-lg);
  padding: 20px; margin: 6px 0 18px;
  box-shadow: var(--shadow);
}
.starter__label { display: block; color: var(--muted); font-size: 14px; }
.starter__name {
  display: block; font-family: var(--font-display); font-weight: 800;
  font-size: clamp(28px, 8vw, 36px); color: var(--gold); margin-top: 4px;
}

.rules {
  list-style: none; counter-reset: r;
  margin: 0 0 18px; padding: 0;
  display: flex; flex-direction: column; gap: 12px;
}
.rules li {
  counter-increment: r;
  position: relative; padding-left: 44px;
  color: var(--muted); font-size: 15px; line-height: 1.45;
}
.rules li::before {
  content: counter(r);
  position: absolute; left: 0; top: -2px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--gold-deep);
  color: var(--gold); font-family: var(--font-display); font-weight: 700;
  display: grid; place-items: center; font-size: 15px;
}
.rules strong { color: var(--cream); }

.timer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 16px; margin-bottom: 14px;
}
.timer__clock { font-family: var(--font-display); font-weight: 700; font-size: 30px; color: var(--gold); }
.timer__btn {
  border: 1px solid var(--gold-deep); background: var(--panel-2);
  color: var(--gold); border-radius: 999px; padding: 9px 18px;
  font-weight: 600; cursor: pointer; font-family: var(--font-body);
}

/* ---------- result ---------- */
.screen--result { justify-content: center; text-align: center; gap: 4px; }
.result__badge {
  color: var(--muted); font-size: 16px; letter-spacing: .04em; margin-bottom: 4px;
}
.result__names {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(32px, 10vw, 46px); color: var(--red);
  text-shadow: 0 1px 0 var(--red-deep); line-height: 1.05;
}
.result__word {
  margin: 30px auto 0; max-width: 320px;
  background: linear-gradient(180deg, var(--cream), #E7DCC3);
  color: var(--ink);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--shadow), inset 0 0 0 6px var(--gold), inset 0 0 0 8px var(--gold-deep);
}
.result__word-label { display: block; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); font-weight: 600; }
.result__word-value { display: block; font-family: var(--font-display); font-weight: 800; font-size: clamp(26px, 8vw, 36px); color: var(--ink); margin: 8px 0 4px; }
.result__word-cat { display: block; font-size: 14px; color: var(--gold-deep); font-weight: 600; }

.screen--result .cta:first-of-type { margin-top: 34px; }

/* ---------- focus ---------- */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
button, input { font: inherit; }
