/* ------------------------------------------------------------------
   Imposter Kerala
   Palette grounded in Kerala's visual world:
   - backwater green (deep teal) as the ground
   - kasavu gold (the golden saree/lamp border) as the signature metal
   - theyyam vermilion for the imposter / danger beat
   - coconut cream for the cards you hold up to your face
------------------------------------------------------------------ */

:root {
  --bg:        #0E3B32;   /* backwater green */
  --bg-deep:   #0A2C25;   /* shadow under the water */
  --panel:     #12463B;   /* raised panel */
  --panel-2:   #16513f;   /* panel hover */
  --line:      #235448;   /* hairline on dark */

  --cream:     #F5EFE1;   /* coconut / the card */
  --cream-2:   #EDE4CF;
  --ink:       #1C2620;   /* text on cream */
  --ink-soft:  #5B6B62;

  --gold:      #E0B34A;   /* kasavu gold */
  --gold-deep: #B6871F;
  --gold-glow: rgba(224,179,74,0.35);

  --red:       #D24A31;   /* theyyam vermilion */
  --red-deep:  #A5361F;

  --muted:     #A6C5B8;   /* soft green text on dark */
  --muted-dim: #7BA192;

  --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%, #14544344 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__mark {
  width: 78px; height: 78px;
  margin: 0 auto 16px;
  border-radius: 22px;
  background: linear-gradient(160deg, var(--panel-2), var(--bg-deep));
  border: 1.5px solid var(--gold-deep);
  box-shadow: var(--shadow), inset 0 0 0 3px rgba(224,179,74,0.10);
  display: grid; place-items: center;
  position: relative;
}
/* a small kathakali-ish painted mask, drawn in CSS */
.masthead__mask {
  width: 34px; height: 44px;
  background:
    radial-gradient(circle at 30% 40%, var(--cream) 0 4px, transparent 5px),
    radial-gradient(circle at 70% 40%, var(--cream) 0 4px, transparent 5px);
  border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
  position: relative;
  background-color: var(--red);
  box-shadow: inset 0 -6px 0 -2px var(--red-deep);
}
.masthead__mask::before {
  content: ""; position: absolute; left: 50%; top: -9px; transform: translateX(-50%);
  width: 46px; height: 20px;
  background: var(--gold); border-radius: 24px 24px 0 0;
  box-shadow: 0 0 0 2px var(--gold-deep);
}
.masthead__mask::after {
  content: ""; position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  width: 16px; height: 6px; background: var(--cream); border-radius: 0 0 8px 8px;
}

.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: #1c5c48; }
.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, #1b5a45, #123f33);
  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: #17553f; 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%; }

.reveal__card {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--r-lg);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 26px;
  cursor: pointer;
  border: none;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    repeating-linear-gradient(135deg, rgba(0,0,0,0.015) 0 10px, transparent 10px 20px),
    linear-gradient(180deg, var(--cream), #E7DCC3);
  box-shadow: var(--shadow), inset 0 0 0 2px var(--cream), inset 0 0 0 8px var(--gold), inset 0 0 0 10px var(--gold-deep);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  transition: transform .12s ease, box-shadow .2s ease;
}
.reveal__card:active { transform: scale(0.99); }

.reveal__cover, .reveal__face {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.reveal__face { opacity: 0; transition: opacity .12s ease; }
.reveal__card.is-revealed .reveal__cover { display: none; }
.reveal__card:not(.is-revealed) .reveal__face { display: none; }
.reveal__card.is-revealed .reveal__face { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .reveal__face { transition: none; } }

/* imposter state paints the same card red */
.reveal__card.is-imposter {
  box-shadow: var(--shadow), inset 0 0 0 2px var(--cream), inset 0 0 0 8px var(--red), inset 0 0 0 10px var(--red-deep);
}
.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); }

.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(--gold-deep); font-weight: 600;
  border: 1px solid var(--gold); 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(--gold-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; }
