/* ===== ClickHouse brand palette =====
   Yellow is the brand primary; near-black neutral.900 is the canvas.
   Ref: https://clickhouse.design/brand/color  */
:root {
  --ch-yellow: #faff69;        /* brand primary */
  --ch-yellow-dim: #d7dc4e;
  --bg: #08080a;
  --panel: #0e0e12;
  --stroke: #26262e;
  --text: #f5f5f4;
  --muted: #9b9ba4;
  --faint: #5c5c66;
  --up: #7cffb2;
  --down: #ff8a8a;
  --coffee: #6f4e37;
  --coffee-light: #a9764f;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

/* Everything lives in one viewport — no scrolling, ever. */
body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Reactive backdrop =====
   Everything here brightens and speeds up while the wheels are turning
   (body.spinning), then eases back down. */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-aurora {
  position: absolute;
  inset: -25%;
  background:
    radial-gradient(36% 40% at 20% 16%, rgba(250, 255, 105, 0.16), transparent 62%),
    radial-gradient(32% 36% at 82% 24%, rgba(120, 190, 255, 0.08), transparent 62%),
    radial-gradient(48% 46% at 50% 100%, rgba(250, 255, 105, 0.13), transparent 64%);
  filter: blur(26px);
  animation: drift 24s ease-in-out infinite alternate;
  transition: filter 0.7s ease;
}
@keyframes drift {
  0%   { transform: translate3d(-2%, -1%, 0) scale(1); }
  50%  { transform: translate3d(3%, 2%, 0) scale(1.08); }
  100% { transform: translate3d(-1%, 3%, 0) scale(1.03); }
}
body.spinning .bg-aurora {
  filter: blur(22px) brightness(2.1) saturate(1.2);
  animation-duration: 5s;
}

.bg-grid {
  position: absolute;
  inset: -10%;
  background-image:
    linear-gradient(rgba(250, 255, 105, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(250, 255, 105, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(70% 62% at 50% 46%, #000 10%, transparent 78%);
  mask-image: radial-gradient(70% 62% at 50% 46%, #000 10%, transparent 78%);
  animation: gridpan 26s linear infinite;
  transition: filter 0.7s ease;
}
@keyframes gridpan { to { background-position: 0 56px, 56px 0; } }
body.spinning .bg-grid { animation-duration: 3s; filter: brightness(2.6); }

/* CRT scanlines — the cheapest way to make pixels feel geeky. */
.bg-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 3px,
    rgba(0, 0, 0, 0.22) 3px 4px
  );
  opacity: 0.5;
}

.bg-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 95% at 50% 42%, transparent 38%, rgba(0, 0, 0, 0.82) 100%);
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

#flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0;
  background: radial-gradient(60% 50% at 50% 45%, rgba(250, 255, 105, 0.55), transparent 70%);
}
#flash.fire { animation: flash 0.7s ease-out; }
@keyframes flash {
  0%   { opacity: 0; }
  8%   { opacity: 1; }
  100% { opacity: 0; }
}

.stage.impact { animation: impact 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes impact {
  0%, 100% { transform: translate3d(0, 0, 0); }
  15% { transform: translate3d(-7px, 4px, 0); }
  35% { transform: translate3d(6px, -3px, 0); }
  55% { transform: translate3d(-4px, 2px, 0); }
  80% { transform: translate3d(2px, -1px, 0); }
}

/* ===== Topbar ===== */
.topbar {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(10px, 1.8vh, 18px) clamp(18px, 4vw, 44px);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo {
  display: block;
  height: clamp(26px, 4.6vh, 42px);
  width: auto;
  filter: drop-shadow(0 0 18px rgba(250, 255, 105, 0.18));
}
.live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 92, 92, 0.35);
  background: rgba(255, 92, 92, 0.10);
  color: #ff8a8a;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.live i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #ff5c5c;
  box-shadow: 0 0 10px #ff5c5c;
  animation: blink 1.6s infinite;
}

.topbar-right { display: flex; align-items: center; gap: 14px; }
.brand-sub {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.icon-btn:hover {
  color: var(--ch-yellow);
  border-color: rgba(250, 255, 105, 0.45);
  background: rgba(250, 255, 105, 0.08);
}

/* ===== Stage ===== */
.stage {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 clamp(16px, 4vw, 44px);
  gap: clamp(6px, 1.4vh, 14px);
}

/* SQL comment, because of course it is. */
.kicker {
  color: var(--faint);
  font-weight: 600;
  font-style: italic;
  font-size: clamp(0.66rem, min(1.7vw, 1.9vh), 0.85rem);
  letter-spacing: 0.1em;
  text-transform: lowercase;
}
.kicker::before { content: "-- "; color: var(--ch-yellow-dim); }

.question {
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-size: clamp(1.2rem, min(3.4vw, 4.6vh), 2.4rem);
  max-width: 26ch;
  background: linear-gradient(180deg, #fff 30%, #b9b9b2 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ===== The terminal ===== */
.term {
  position: relative;
  width: fit-content;
  max-width: min(94vw, 1100px);
  margin-top: clamp(4px, 1.2vh, 12px);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.01)),
    rgba(8, 8, 11, 0.82);
  border: 1px solid rgba(250, 255, 105, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 30px 90px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(0, 0, 0, 0.6);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}
body.spinning .term {
  border-color: rgba(250, 255, 105, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 30px 90px rgba(0, 0, 0, 0.65),
    0 0 60px rgba(250, 255, 105, 0.18);
}
body.landed .term {
  border-color: rgba(250, 255, 105, 0.6);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 30px 110px rgba(0, 0, 0, 0.7),
    0 0 110px rgba(250, 255, 105, 0.28);
}

/* Title bar with traffic lights */
.term-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: clamp(7px, 1.2vh, 11px) 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px 14px 0 0;
  background: rgba(255, 255, 255, 0.025);
}
.term-dots { display: inline-flex; gap: 7px; }
.term-dots i {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #3a3a42;
}
.term-dots i:nth-child(1) { background: #ff5f57; }
.term-dots i:nth-child(2) { background: #febc2e; }
.term-dots i:nth-child(3) { background: #28c840; }
.term-title {
  flex: 1;
  text-align: center;
  color: var(--faint);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.term-step {
  color: var(--ch-yellow-dim);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid rgba(250, 255, 105, 0.25);
  border-radius: 4px;
  padding: 2px 8px;
  background: rgba(250, 255, 105, 0.06);
  min-width: 9ch;
  text-align: center;
}

.term-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.4vh, 14px);
  padding: clamp(12px, 2.4vh, 26px) clamp(20px, 3.6vw, 48px) clamp(14px, 2.6vh, 26px);
  overflow: hidden;
  border-radius: 0 0 14px 14px;
}

/* The query being "run" — clickhouse-client's actual :) prompt. */
.term-query {
  align-self: flex-start;
  color: var(--muted);
  font-size: clamp(0.62rem, min(1.7vw, 1.8vh), 0.85rem);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.tq-prompt { color: var(--ch-yellow); font-weight: 700; }
.caret {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 3px;
  vertical-align: text-bottom;
  background: var(--ch-yellow);
  animation: blink 1.1s steps(1) infinite;
}

/* Speed lines behind the wheels, only while they turn. */
.panel-streaks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.panel-streaks::before {
  content: "";
  position: absolute;
  inset: -60%;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 7px,
    rgba(250, 255, 105, 0.14) 7px 9px
  );
  opacity: 0;
  transition: opacity 0.35s ease;
}
body.spinning .panel-streaks::before {
  opacity: 1;
  animation: streak 0.32s linear infinite;
}
@keyframes streak { to { transform: translateY(16px); } }

/* Expanding ring when the number lands. */
.shock {
  position: absolute;
  left: 50%; top: 50%;
  width: 46px; height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  border: 8px solid var(--ch-yellow);
  opacity: 0;
  pointer-events: none;
}
.shock.fire { animation: shock 0.95s cubic-bezier(0.1, 0.72, 0.2, 1); }
@keyframes shock {
  0%   { transform: scale(1);  opacity: 0.85; border-width: 8px; }
  100% { transform: scale(30); opacity: 0;    border-width: 1px; }
}

/* ===== Binary coffee cup — the caffeine is made of bits ===== */
.cup-ascii {
  --cup-size: clamp(96px, min(11vw, 17vh), 160px);
  position: absolute;
  right: calc(100% + clamp(12px, 2.4vw, 30px));
  bottom: 4px;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 0 16px rgba(250, 255, 105, 0.14));
  transition: filter 0.5s ease;
}
/* A mug-shaped window onto an endless stream of bits. */
.cup-shape {
  position: relative;
  width: var(--cup-size);
  aspect-ratio: 1;
  overflow: hidden;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='8' y='20' width='56' height='58' rx='10' fill='white'/%3E%3Cpath d='M64 34h6a13 13 0 0 1 0 26h-6' fill='none' stroke='white' stroke-width='9'/%3E%3Cellipse cx='40' cy='85' rx='36' ry='6' fill='white'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect x='8' y='20' width='56' height='58' rx='10' fill='white'/%3E%3Cpath d='M64 34h6a13 13 0 0 1 0 26h-6' fill='none' stroke='white' stroke-width='9'/%3E%3Cellipse cx='40' cy='85' rx='36' ry='6' fill='white'/%3E%3C/svg%3E") center / contain no-repeat;
}
.cup-glass {
  position: absolute;
  inset: 0;
  background: rgba(250, 255, 105, 0.13);
}
.cup-bits {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  margin: 0;
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(7px, min(0.85vw, 1.3vh), 12px);
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-align: center;
  white-space: pre;
  color: var(--ch-yellow-dim);
  opacity: 0.9;
  animation: bits-scroll 9s linear infinite;
}
@keyframes bits-scroll { to { transform: translateY(-50%); } }
/* Foam sheen at the rim, coffee darkening toward the base. */
.cup-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.22) 21%,
    rgba(255, 255, 255, 0) 30%,
    rgba(111, 78, 55, 0) 55%,
    rgba(111, 78, 55, 0.7) 100%
  );
}
body.landed .cup-ascii {
  filter: drop-shadow(0 0 26px rgba(250, 255, 105, 0.5));
}
body.spinning .cup-bits { animation-duration: 2.5s; }  /* the brew races with the wheels */

/* Steam: stray bits evaporating off the top of the cup */
.steam-bits {
  position: relative;
  z-index: 1;
  height: 3em;
  margin-left: calc(var(--cup-size) * 0.14);
  /* The mask's rim sits ~20% into the box, so tuck the steam down to meet it. */
  margin-bottom: calc(var(--cup-size) * -0.17);
  font-size: clamp(9px, min(1.4vw, 2vh), 15px);
}
.steam-bits span {
  position: absolute;
  bottom: 0;
  color: rgba(245, 245, 244, 0.75);
  text-shadow: 0 0 6px rgba(245, 245, 244, 0.5);
  opacity: 0;
  animation: bit-rise 2.8s ease-in-out infinite;
}
.steam-bits span:nth-child(1) { left: 1ch;  animation-delay: 0s; }
.steam-bits span:nth-child(2) { left: 4ch;  animation-delay: 0.7s; }
.steam-bits span:nth-child(3) { left: 7ch;  animation-delay: 1.3s; }
.steam-bits span:nth-child(4) { left: 10ch; animation-delay: 1.9s; }
.steam-bits span:nth-child(5) { left: 5.5ch; animation-delay: 2.4s; }
@keyframes bit-rise {
  0%   { transform: translateY(0) scale(1); opacity: 0; }
  20%  { opacity: 0.85; }
  100% { transform: translateY(-2.6em) scale(1.6); opacity: 0; }
}

/* The cup rattles while the wheels are turning. */
body.spinning .cup-ascii { animation: cup-jitter 0.3s steps(2) infinite; }
@keyframes cup-jitter {
  0%, 100% { transform: translate(0, 0); }
  50%      { transform: translate(1px, -1px); }
}

/* ===== Odometer (one spinning wheel per digit) ===== */
.odo {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 800;
  font-size: clamp(3rem, min(12vw, 21vh), 10rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  /* Glow lives on the root as a drop-shadow: a per-column text-shadow would get
     sliced up by each wheel's overflow clip. */
  filter: drop-shadow(0 0 34px rgba(250, 255, 105, 0.12));
  transition: color 0.45s ease, filter 0.45s ease;
}

.odo-col {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
}
.odo-sep { overflow: visible; }          /* the comma's tail lives below the line */

.odo-ghost { display: block; visibility: hidden; }

.odo-strip {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  will-change: transform, filter;
}
.odo-strip > span {
  display: block;
  height: var(--odo-step, 1em);
  line-height: var(--odo-step, 1em);
  text-align: center;
}

/* Motion blur, in em so it tracks the font size on any screen. */
.odo-strip.b1 { filter: blur(0.010em); }
.odo-strip.b2 { filter: blur(0.026em); }
.odo-strip.b3 { filter: blur(0.050em); }
.odo-strip.b4 { filter: blur(0.085em); }

/* While the wheels turn, fade the window edges so digits roll out of view. */
.odo.spinning .odo-digit {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 16%, #000 84%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 16%, #000 84%, transparent 100%);
}
/* No root glow while the wheels turn — it would re-rasterise every frame. */
.odo.spinning { filter: none; transition: none; }

.odo.final {
  color: var(--ch-yellow);
  filter:
    drop-shadow(0 0 18px rgba(250, 255, 105, 0.45))
    drop-shadow(0 0 60px rgba(250, 255, 105, 0.35));
}

.odo.slam { animation: odo-slam 0.55s cubic-bezier(0.16, 0.9, 0.3, 1); }
@keyframes odo-slam {
  0%   { transform: scale(1.13); }
  45%  { transform: scale(0.975); }
  100% { transform: scale(1); }
}

.odo-probe {
  position: absolute;
  visibility: hidden;
  pointer-events: none;
  width: auto !important;
  opacity: 1 !important;
}

.unit {
  color: var(--muted);
  font-weight: 700;
  font-size: clamp(0.72rem, min(1.9vw, 2.2vh), 1.05rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* Status line + tension meter inside the terminal */
.term-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-weight: 700;
  font-size: clamp(0.7rem, min(1.8vw, 2vh), 0.92rem);
  letter-spacing: 0.02em;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
  animation: blink 1.4s infinite;
}
.status.up    { color: var(--up);   border-color: rgba(124, 255, 178, 0.35); background: rgba(124, 255, 178, 0.08); }
.status.down  { color: var(--down); border-color: rgba(255, 138, 138, 0.35); background: rgba(255, 138, 138, 0.08); }
.status.final { color: var(--ch-yellow); border-color: rgba(250, 255, 105, 0.45); background: rgba(250, 255, 105, 0.10); }

/* Tension meter — fills as the guesses march toward the reveal. */
.charge {
  width: min(34vw, 240px);
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.charge i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ch-yellow-dim), var(--ch-yellow));
  box-shadow: 0 0 16px rgba(250, 255, 105, 0.8);
  transition: width 0.7s cubic-bezier(0.3, 0.9, 0.3, 1);
}

/* ===== The spacebar keycap — the emcee's steering wheel ===== */
.drive {
  margin-top: clamp(8px, 1.8vh, 20px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3vw, 40px);
  flex-wrap: wrap;
}

/* The winner button only exists once the number is out.
   (.cta.winner-btn so the generic .cta display rule can't override it) */
.cta.winner-btn { display: none; }
body.landed .cta.winner-btn { display: inline-flex; }
.key-w {
  padding-left: clamp(16px, 3vw, 28px);
  padding-right: clamp(16px, 3vw, 28px);
  letter-spacing: 0.12em;
  text-indent: 0.12em;
}
body.landed .winner-btn .key-space { animation: keypulse 2.2s ease-in-out infinite; }
.cta {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: none;
  border: none;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.25s ease;
}
.cta:disabled { opacity: 0.35; cursor: default; }
.cta:not(:disabled):hover { transform: translateY(-1px); }
.cta:not(:disabled):active .key-space { transform: translateY(2px); box-shadow: 0 1px 0 #101014, 0 4px 20px rgba(250, 255, 105, 0.18); }

.key-space {
  display: inline-block;
  padding: clamp(8px, 1.6vh, 13px) clamp(34px, 7vw, 72px);
  border-radius: 9px;
  border: 1px solid rgba(250, 255, 105, 0.5);
  background: linear-gradient(180deg, #1b1b21, #101014);
  color: var(--ch-yellow);
  font-weight: 800;
  font-size: clamp(0.78rem, min(2vw, 2.2vh), 1rem);
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  box-shadow:
    0 4px 0 #101014,
    0 6px 24px rgba(250, 255, 105, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  animation: keypulse 2.2s ease-in-out infinite;
}
@keyframes keypulse {
  0%, 100% { box-shadow: 0 4px 0 #101014, 0 6px 24px rgba(250, 255, 105, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.09); }
  50%      { box-shadow: 0 4px 0 #101014, 0 6px 34px rgba(250, 255, 105, 0.4),  inset 0 1px 0 rgba(255, 255, 255, 0.09); }
}
body.spinning .key-space, .cta:disabled .key-space { animation: none; }

.cta-label {
  font-weight: 700;
  font-size: clamp(0.72rem, min(1.8vw, 2vh), 0.9rem);
  letter-spacing: 0.06em;
}
.cta-label::before { content: "→ "; color: var(--ch-yellow-dim); }

/* Reserve the tagline's line even before it shows, so nothing jumps. */
.tagline {
  max-width: 52ch;
  min-height: 1.5em;
  color: var(--text);
  font-weight: 600;
  font-size: clamp(0.78rem, min(2vw, 2.2vh), 1.05rem);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.tagline[hidden] { display: block; visibility: hidden; }
.tagline.show { opacity: 1; transform: translateY(0); }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ===== QR chip — phones scan this to submit a guess ===== */
.guess-qr {
  position: fixed;
  right: clamp(14px, 2.4vw, 30px);
  bottom: clamp(40px, 7vh, 60px);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(250, 255, 105, 0.22);
  background: rgba(14, 14, 18, 0.85);
  text-decoration: none;
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.guess-qr img {
  display: block;
  width: clamp(72px, 9vh, 104px);
  height: clamp(72px, 9vh, 104px);
  border-radius: 6px;
}
.guess-qr span {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.5;
}
/* Once the show starts, guessing is over — the QR bows out. */
body.showtime .guess-qr {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

/* ===== Winner board (W after the reveal) ===== */
.winner[hidden] { display: none; }  /* author display would otherwise beat [hidden] */
.winner {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 4, 6, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.winner-card {
  width: min(680px, 94vw);
  border-radius: 14px;
  border: 1px solid rgba(250, 255, 105, 0.35);
  background: rgba(10, 10, 14, 0.97);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.8), 0 0 90px rgba(250, 255, 105, 0.16);
  overflow: hidden;
}
.winner-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.025);
}
.winner-title {
  color: var(--faint);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.winner-query {
  padding: 14px 20px 0;
  color: var(--muted);
  font-size: clamp(0.6rem, 1.6vw, 0.78rem);
  overflow-wrap: anywhere;
}
.winner-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 20px;
  color: var(--muted);
  font-size: clamp(0.78rem, 2vw, 0.95rem);
  max-height: min(58vh, 560px);   /* ten rows shouldn't push the card off screen */
  overflow-y: auto;
}
.winner-row {
  display: grid;
  grid-template-columns: 2.6ch 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
}
.winner-row.first {
  border-color: rgba(250, 255, 105, 0.5);
  background: rgba(250, 255, 105, 0.08);
  box-shadow: 0 0 30px rgba(250, 255, 105, 0.12);
}
.winner-row.first .w-name { color: var(--ch-yellow); font-size: 1.15em; }
.w-rank { text-align: center; }
.w-name {
  color: var(--text);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.w-who { color: var(--faint); font-weight: 400; font-size: 0.82em; }
.winner-row.first .w-who { font-size: 0.72em; }
.w-guess { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.w-delta { color: var(--faint); font-size: 0.85em; }
.winner-row.first .w-delta { color: var(--up); }
.winner-total { color: var(--faint); font-size: 0.72rem; text-align: right; }
.winner-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 20px 16px;
}
.winner-close {
  color: var(--faint);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.winner-reset {
  font-family: inherit;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--down);
  background: rgba(255, 138, 138, 0.07);
  border: 1px solid rgba(255, 138, 138, 0.3);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.winner-reset:hover {
  background: rgba(255, 138, 138, 0.16);
  border-color: rgba(255, 138, 138, 0.55);
}

/* ===== Emcee access gate ===== */
.lock[hidden] { display: none; }
.lock {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  /* Near-opaque: nothing behind is readable until the code checks out. */
  background:
    radial-gradient(60% 40% at 50% 0%, rgba(250, 255, 105, 0.05), transparent 70%),
    rgba(5, 5, 7, 0.985);
}
.lock-card {
  width: min(480px, 94vw);
  border-radius: 14px;
  border: 1px solid rgba(250, 255, 105, 0.3);
  background: rgba(10, 10, 14, 0.97);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.8), 0 0 70px rgba(250, 255, 105, 0.12);
  overflow: hidden;
}
.lock-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.025);
}
.lock-title {
  color: var(--faint);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.lock-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}
.lock-query { color: var(--muted); font-size: 0.74rem; overflow-wrap: anywhere; }
.lock-text { color: var(--muted); font-size: 0.8rem; line-height: 1.6; }
.lock-text a { color: var(--ch-yellow); }
.lock form { display: flex; gap: 10px; }
.lock input {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  border-radius: 9px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.lock input:focus {
  border-color: rgba(250, 255, 105, 0.55);
  box-shadow: 0 0 0 3px rgba(250, 255, 105, 0.12);
}
.lock button {
  font-family: inherit;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: #000;
  background: linear-gradient(180deg, #ffffb0, var(--ch-yellow) 45%, var(--ch-yellow-dim));
  border: none;
  border-radius: 9px;
  padding: 12px 20px;
  cursor: pointer;
}
.lock button:active { transform: translateY(1px); }
.lock-msg { min-height: 1.3em; color: var(--down); font-size: 0.78rem; }

/* ===== Footer ===== */
.footer {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  text-align: center;
  padding: clamp(6px, 1.2vh, 12px) 20px;
  color: #6b6b74;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
}
.footer strong { color: var(--muted); }

@media (max-width: 1000px) {
  .cup-ascii { display: none; }   /* no room to perch beside the terminal */
}

@media (max-width: 720px) {
  .brand-sub { display: none; }
  .term-title { display: none; }
  .term-query { align-self: center; white-space: normal; }
  .footer { font-size: 0.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .live i, .status-dot, .caret, .key-space, .steam-bits span, .cup-ascii, .cup-bits,
  .bg-aurora, .bg-grid, .panel-streaks::before { animation: none !important; }
  .odo.slam, .stage.impact, #flash.fire, .shock.fire { animation: none !important; }
  .odo-strip { filter: none !important; }
}
