@import url("https://fonts.googleapis.com/css2?family=Lilita+One&family=Nunito:wght@700;800;900&display=swap");

:root {
  --ink: #140810;
  --cream: #fff6ea;
  --maroon: #4a1024;
  --pitch: #1f7a3a;
  --gold: #ffc14d;
  --bad: #ffb3c4;
  --filler: #efe4d4;
  color: var(--ink);
  font-family: Nunito, "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #140810;
}

button { font: inherit; touch-action: manipulation; }

button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

::selection { background: var(--gold); color: var(--ink); }

.app {
  width: min(100vw, 440px);
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--maroon);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}

.screen { min-height: 0; }

#game {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

#game[hidden],
#gate[hidden] { display: none !important; }

.gate {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
  background:
    radial-gradient(ellipse 80% 42% at 50% 14%, rgba(255, 193, 77, 0.42), transparent 60%),
    linear-gradient(180deg, #6e2038 0%, #4a1024 52%, #140810 100%);
}

.gate-art {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 140px;
}

.gate-art svg { width: min(230px, 68vw); height: auto; }

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

h1, h2, .minute, .scorebug strong, .score-num, .tally {
  font-family: "Lilita One", "Arial Black", sans-serif;
  font-weight: 400;
  letter-spacing: 0.01em;
  margin: 0;
}

.gate h1 {
  font-size: clamp(2.5rem, 13vw, 3.5rem);
  line-height: 0.88;
  text-transform: uppercase;
  color: var(--cream);
  text-shadow: 4px 4px 0 var(--ink);
}

.gate h1 span,
.top h1 span { color: var(--gold); }

.lede {
  margin: 12px 0 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.35;
  max-width: 28ch;
}

.fine {
  margin: 8px 0 0;
  color: rgba(255, 246, 234, 0.78);
  font-weight: 700;
  line-height: 1.35;
}

.gate-actions,
.stack,
.answers {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gate-actions { margin-top: 16px; }

.btn,
.choice {
  width: 100%;
  border: 3px solid var(--ink);
  background: var(--cream);
  color: var(--ink);
  border-radius: 16px;
  min-height: 52px;
  padding: 12px 14px;
  font-weight: 900;
  line-height: 1.25;
  box-shadow: 4px 4px 0 var(--ink);
  cursor: pointer;
  text-align: left;
}

.btn { text-align: center; }

.btn:active:not(:disabled),
.choice:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

.btn.primary { background: var(--gold); color: var(--ink); }

.btn.ghost {
  background: transparent;
  color: var(--cream);
  box-shadow: none;
  border-color: rgba(255, 246, 234, 0.45);
}

.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.choice .line { display: block; }

.choice .tag {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--gold);
  border-radius: 999px;
  padding: 2px 8px;
}

.choice.is-patter,
.choice.is-right { background: var(--gold); }

.choice.is-filler { background: var(--filler); }

.choice.is-offair,
.choice.is-wrong { background: var(--bad); }

.choice.is-filler .tag,
.choice.is-offair .tag { color: var(--cream); }

.choice:disabled { cursor: default; opacity: 1; }

.choice.is-picked {
  outline: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--pitch);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 0;
}

.top h1 {
  font-size: clamp(1rem, 4.8vw, 1.28rem);
  text-transform: uppercase;
  color: var(--cream);
  line-height: 0.95;
}

.icon-btn {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--cream);
  color: var(--ink);
  font-weight: 900;
  font-size: 1.15rem;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 0;
  font-weight: 900;
  font-size: 0.82rem;
}

.pill {
  background: var(--gold);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 8px;
}

.pill.pop { animation: pop 0.35s ease; }

.minute {
  margin-left: auto;
  font-size: 1.2rem;
  color: var(--gold);
}

.scorebug {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  align-items: center;
  padding: 2px 12px 6px;
  font-weight: 900;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.scorebug .team:first-child { text-align: left; }
.scorebug .team:last-child { text-align: right; }

.scorebug strong {
  font-size: 1.35rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--gold);
  text-align: center;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 168px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 48% at 38% 18%, rgba(255, 193, 77, 0.22), transparent 62%),
    linear-gradient(180deg, #6a1a34 0%, #4a1024 72%, #2a0c16 100%);
}

.shug-slot {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.shug-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
}

#shug-rig {
  transition: transform 0.7s cubic-bezier(.18, .8, .2, 1);
}

.lamp {
  position: absolute;
  top: 8px;
  left: 10px;
  z-index: 5;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  background: var(--pitch);
  color: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 8px;
  box-shadow: 2px 2px 0 var(--ink);
}

.lamp.is-off { background: #8c1d38; }

.speech {
  position: absolute;
  z-index: 5;
  top: 36px;
  left: 10px;
  right: 74px;
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 16px 16px 16px 6px;
  box-shadow: 4px 4px 0 var(--ink);
  padding: 8px 10px;
  font-weight: 800;
  font-size: 0.86rem;
  line-height: 1.25;
  max-height: 4.6em;
  overflow: hidden;
}

.speech.is-patter { background: #ffe7a8; }
.speech.is-off { background: #ffd0da; }

.timer {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 56px;
  height: 56px;
  z-index: 5;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 3px 3px 0 var(--ink);
}

.timer svg { width: 100%; height: 100%; display: block; }

.timer span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "Lilita One", "Arial Black", sans-serif;
  font-size: 1.15rem;
  color: var(--ink);
}

.ring-bg,
.ring { fill: none; stroke-width: 4; }

.ring-bg { stroke: rgba(20, 8, 16, 0.15); }

.ring {
  stroke: var(--gold);
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: calc(113.1 * (1 - var(--p, 1)));
  transform: rotate(-90deg);
  transform-origin: 22px 22px;
}

.timer.is-low {
  background: var(--maroon);
  animation: pulse 0.45s ease-in-out infinite;
}

.timer.is-low span { color: var(--gold); }

.pitch {
  position: absolute;
  left: 8px;
  bottom: 8px;
  width: 142px;
  height: 84px;
  z-index: 3;
  border: 3px solid var(--ink);
  border-radius: 10px;
  box-shadow: 3px 3px 0 var(--ink);
  background: var(--pitch);
  overflow: hidden;
}

.halfway {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 246, 234, 0.85);
}

.centre {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 2px solid rgba(255, 246, 234, 0.85);
  border-radius: 50%;
}

.box {
  position: absolute;
  top: 18%;
  height: 64%;
  width: 18%;
  border: 2px solid rgba(255, 246, 234, 0.85);
}

.box-left { left: 0; border-left: 0; }
.box-right { right: 0; border-right: 0; }

.spot {
  display: none;
  position: absolute;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--cream);
  left: 76%;
  top: 50%;
}

.scene-pen .spot,
.scene-gull .spot,
.scene-own .spot,
.scene-winner .spot { display: block; }

.ball {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--cream);
  border: 2px solid var(--ink);
  left: 50%;
  top: 48%;
  z-index: 1;
}

.scene-pen .ball { left: 74%; top: 50%; }
.scene-pies .ball { left: 50%; top: 36%; }
.scene-gull .ball { left: 58%; top: 70%; }
.scene-own .ball { left: 92%; top: 46%; }
.scene-winner .ball { left: 90%; top: 40%; }

.snack {
  display: none;
  position: absolute;
  width: 14px;
  height: 9px;
  border-radius: 7px 7px 4px 4px;
  background: var(--gold);
  border: 2px solid var(--ink);
  z-index: 1;
}

.snack::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: 1px;
  height: 3px;
  border-radius: 3px;
  background: #c47a3a;
}

.scene-kick .snack-a { display: block; left: 16%; top: 68%; }
.scene-pies .snack { display: block; top: 66%; }
.scene-pies .snack-a { left: 8%; }
.scene-pies .snack-b { left: 24%; }
.scene-pies .snack-c { left: 40%; }

.varwalk {
  display: none;
  position: absolute;
  left: 3%;
  bottom: 4%;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--cream);
  background: var(--ink);
  border-radius: 3px;
  padding: 1px 3px;
}

.scene-pen .varwalk { display: block; }

.queue {
  display: none;
  position: absolute;
  left: 8%;
  right: 18%;
  bottom: 8%;
  height: 8px;
}

.scene-winner .queue {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.queue i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cream);
  border: 1px solid var(--ink);
  display: block;
}

.gull {
  display: none;
  position: absolute;
  width: 36px;
  height: 28px;
  left: 66%;
  top: 16%;
  z-index: 2;
}

.show-gull .gull { display: block; }

.panel {
  flex: 0 1 auto;
  max-height: 58dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: #140810;
  border-top: 4px solid var(--gold);
}

#intro,
#play,
#classified,
#result {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

#play,
#classified,
#result { overflow: hidden; }

#intro { overflow: auto; }

.scroll {
  overflow: auto;
  min-height: 0;
  flex: 1 1 auto;
}

#next,
#class-next,
#result .stack {
  flex: 0 0 auto;
  margin-top: 8px;
}

.kicker {
  margin: 0 0 6px;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.prompt,
.explain,
#result p {
  margin: 0 0 10px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--cream);
}

.verdict {
  margin: 8px 0;
  font-weight: 900;
  line-height: 1.3;
}

.verdict.is-patter { color: var(--gold); }
.verdict.is-filler { color: var(--cream); }
.verdict.is-offair { color: var(--bad); }

.class-line {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 8px;
}

.read {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-weight: 900;
  font-size: 1.02rem;
}

.blank {
  display: inline-block;
  width: 1.15em;
  height: 0.75em;
  border-bottom: 4px solid var(--gold);
  transition: width linear;
}

.tally {
  color: var(--gold);
  font-size: 1.45rem;
  line-height: 1;
}

.class-note {
  margin: 0 0 8px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--gold);
}

#result h2 {
  font-size: clamp(1.8rem, 9vw, 2.45rem);
  text-transform: uppercase;
  line-height: 0.92;
  margin: 0 0 8px;
  color: var(--gold);
  text-shadow: 3px 3px 0 var(--ink);
}

.score-num {
  font-size: 2.3rem;
  color: var(--cream);
  margin: 0 0 2px;
}

.share-note {
  margin: 0;
  font-weight: 800;
  line-height: 1.35;
  color: var(--gold);
  overflow-wrap: anywhere;
}

.mouth-smile,
.mouth-grin,
.mouth-flat,
.mouth-oh,
.eyes-shut,
.eyes-wide { display: none; }

.face-ready .mouth-smile,
.face-threat .mouth-smile,
.face-patter .mouth-grin,
.face-filler .mouth-flat,
.face-class .mouth-flat,
.face-offair .mouth-oh { display: block; }

.face-filler .eyes-open,
.face-offair .eyes-open { display: none; }

.face-filler .eyes-shut,
.face-offair .eyes-wide { display: block; }

.eyes-open {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 4.8s infinite;
}

.brow { transform-box: fill-box; transform-origin: center; }

.face-patter .brow { transform: translateY(-3px); }
.face-offair .brow { transform: translateY(-6px); }
.face-filler .brow { transform: translateY(3px); }
.face-class .brow { transform: translateY(1px); }
.face-threat .brow-l { transform: translateY(-4px) rotate(-8deg); }
.face-threat .brow-r { transform: translateY(-1px) rotate(8deg); }

.blush { opacity: 0.35; }
.face-patter .blush { opacity: 0.7; }
.face-offair .blush { opacity: 0.85; }

.pupil { transform-box: fill-box; transform-origin: center; }
.face-filler .pupil { transform: translateY(2px); }

.moustache { transform-box: fill-box; transform-origin: center; }

.is-talking:not(.face-offair) .moustache { animation: yap 0.14s steps(2) 6; }

.face-offair .moustache {
  transform: rotate(7deg);
  transform-origin: 18% 50%;
}

.sweat { opacity: 0; }
.is-threatened .sweat,
.face-offair .sweat { opacity: 1; }

.drop { transform-box: fill-box; transform-origin: center; }
.is-threatened .drop,
.face-offair .drop { animation: drip 1.15s ease-in infinite; }
.d2 { animation-delay: 0.35s; }

.hand-pie { opacity: 0; }
.is-pie .hand-pie { opacity: 1; }

.shug-bob { transform-box: fill-box; transform-origin: 50% 80%; }
.is-shoving .shug-bob { animation: shove 0.55s ease; }

@keyframes blink {
  0%, 88%, 100% { transform: scaleY(1); }
  93%, 96% { transform: scaleY(0.08); }
}

@keyframes yap {
  50% { transform: translateY(2px); }
}

@keyframes drip {
  0% { transform: translateY(0); opacity: 1; }
  80% { transform: translateY(14px); opacity: 0; }
  100% { opacity: 0; }
}

@keyframes shove {
  0% { transform: rotate(0deg); }
  35% { transform: rotate(4deg) translateY(-3px); }
  100% { transform: rotate(0deg); }
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
