:root {
  --bg: #0c0a12;
  --bg-2: #141019;
  --panel: #1a1622;
  --panel-line: #2c2436;
  --ink: #f4ecff;
  --ink-dim: #9a8fb0;
  --ember: #ff8a3d;
  --ember-bright: #ffb347;
  --flame: #ff5b2e;
  --acid: #7CFFB2;
  --hot-pink: #ff4d8d;
  --paper: #f6efe3;
  --paper-ink: #2a2118;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #221733 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.025) 0px,
    rgba(255,255,255,0.025) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 18px 64px;
}

/* ---- masthead ---- */
.masthead { text-align: center; margin-bottom: 22px; }
.logo {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(20px, 5.5vw, 34px);
  letter-spacing: 1px;
  margin: 0;
  line-height: 1.25;
  color: var(--ember-bright);
  text-shadow: 0 0 12px rgba(255,138,61,0.55), 0 0 28px rgba(255,91,46,0.35);
}
.logo span { color: var(--hot-pink); text-shadow: 0 0 12px rgba(255,77,141,0.55); }
.tagline { color: var(--ink-dim); font-size: 13px; margin: 12px 0 0; letter-spacing: 0.5px; }

/* ---- stage / canvas ---- */
.stage {
  position: relative;
  /* painted boiler room (Codex, 2026-10); the gradient shows until it loads */
  background: url('../img/backdrop-1600.webp?v=1') 70% 100% / cover no-repeat,
    linear-gradient(180deg, #0f0b16 0%, #07050b 100%);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,138,61,0.05);
}
#scene { display: block; width: 100%; height: 300px; }

.meters {
  position: absolute;
  top: 14px; left: 14px;
  display: flex;
  gap: 10px;
}
.meter {
  background: rgba(8,6,12,0.66);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 7px 12px;
  min-width: 130px;
  backdrop-filter: blur(2px);
}
.meter-label {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ink-dim);
}
.meter-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--ember-bright);
  text-shadow: 0 0 10px rgba(255,138,61,0.5);
  font-variant-numeric: tabular-nums;
}
.meter-value.cost { color: var(--acid); text-shadow: 0 0 10px rgba(124,255,178,0.4); }

/* ---- console ---- */
.console { margin-top: 20px; }
.paste-label {
  display: block;
  font-size: 12px;
  color: var(--ink-dim);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
#codeInput {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#codeInput::placeholder { color: #5d5470; }
#codeInput:focus {
  border-color: var(--ember);
  box-shadow: 0 0 0 3px rgba(255,138,61,0.12);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  border: 1px solid var(--panel-line);
  background: transparent;
  color: var(--ink);
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
  letter-spacing: 0.5px;
}
.btn:hover { border-color: var(--ember); }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, var(--ember-bright), var(--flame));
  color: #2a1405;
  border-color: transparent;
  text-shadow: none;
  box-shadow: 0 0 18px rgba(255,91,46,0.4);
}
.btn-primary:hover { box-shadow: 0 0 26px rgba(255,91,46,0.6); border-color: transparent; }
.btn-ghost { color: var(--ink-dim); }
.btn.sample { font-weight: 400; font-size: 12px; padding: 9px 13px; }
.privacy {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.5px;
}
.privacy .lock { color: var(--acid); }

/* ---- results ---- */
.results {
  margin-top: 26px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
  align-items: start;
  animation: rise 0.4s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.receipt {
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 4px;
  padding: 18px 18px 14px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  position: relative;
}
.receipt::before, .receipt::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  height: 8px;
  background: radial-gradient(circle at 6px -2px, transparent 6px, var(--paper) 6px) repeat-x;
  background-size: 14px 8px;
}
.receipt::before { top: -7px; transform: rotate(180deg); }
.receipt::after { bottom: -7px; }
.receipt-head { text-align: center; border-bottom: 2px dashed #c9bca5; padding-bottom: 10px; margin-bottom: 10px; }
.receipt-title { display: block; font-weight: 700; letter-spacing: 3px; font-size: 15px; }
.receipt-sub { display: block; font-size: 10px; color: #7a6f5c; margin-top: 4px; letter-spacing: 0.5px; }
.receipt-rows { display: flex; flex-direction: column; gap: 6px; }
.r-row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.r-row .r-label { color: #5e5444; }
.r-row .r-amt { font-weight: 700; white-space: nowrap; }
.r-row.spicy .r-amt { color: #c0381a; }
.r-row .r-quip { display: block; font-size: 10px; color: #8a7d66; margin-top: 1px; max-width: 230px; }
.receipt-total {
  display: flex; justify-content: space-between;
  border-top: 2px dashed #c9bca5;
  margin-top: 12px; padding-top: 10px;
  font-weight: 700; font-size: 15px;
}
.receipt-foot { text-align: center; font-size: 10px; color: #9a8d75; margin-top: 12px; letter-spacing: 0.5px; }

.verdict-col { display: flex; flex-direction: column; gap: 14px; }
.verdict-card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  padding: 16px;
}
.verdict-label { font-size: 10px; text-transform: uppercase; letter-spacing: 2px; color: var(--ink-dim); }
.verdict-head { display: flex; align-items: center; gap: 10px; }
.verdict-face {
  flex: none; width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
  background: radial-gradient(circle at 50% 38%, #4a3020 0%, #1b1220 72%);
  border: 2px solid rgba(255,138,61,0.55);
  box-shadow: 0 0 14px rgba(255,138,61,0.22);
}
.verdict-face[hidden] { display: none; }
.verdict-grade-row { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.verdict-grade {
  font-family: 'Press Start 2P', monospace;
  font-size: 38px;
  line-height: 1;
  color: var(--ember-bright);
  text-shadow: 0 0 16px rgba(255,138,61,0.55);
}
.verdict-quote { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink); }
.verdict-actions { display: flex; gap: 10px; }
.verdict-actions .btn { flex: 1; }
.verdict-note { font-size: 11px; color: var(--ink-dim); margin: 0; line-height: 1.5; }
.verdict-note code { color: var(--ember); background: rgba(255,138,61,0.1); padding: 1px 5px; border-radius: 4px; }

/* ---- toast ---- */
.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel);
  border: 1px solid var(--ember);
  color: var(--ink);
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
  box-shadow: 0 0 24px rgba(255,91,46,0.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- toolbar ---- */
.masthead { position: relative; }
/* in flow above the logo at every width: pinned top-right it covered the logo once
   the All Games link joined it (2026-10). Back link left, game buttons right. */
.toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}
.toolbar > a.icon-btn:first-child { margin-right: auto; }
.icon-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: rgba(8,6,12,0.6);
  color: var(--ink-dim);
  border: 1px solid var(--panel-line);
  border-radius: 9px;
  padding: 7px 10px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.icon-btn:hover { border-color: var(--ember); color: var(--ink); }

/* ---- incident banner ---- */
.incident {
  margin-top: 14px;
  background: rgba(255,91,46,0.12);
  border: 1px solid var(--flame);
  color: #ffd9c9;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  animation: rise 0.3s ease both;
}
.incident strong { color: var(--ember-bright); letter-spacing: 0.5px; }

/* ---- verdict extras ---- */
.btn-sm { font-size: 11px; padding: 7px 12px; }
.verdict-grade[data-grade="S"], .verdict-grade[data-grade="A"] { color: var(--acid); text-shadow: 0 0 16px rgba(124,255,178,0.5); }
.verdict-lang {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-dim);
  font-style: italic;
  line-height: 1.5;
  border-top: 1px dashed var(--panel-line);
  padding-top: 12px;
}
.verdict-aside {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-dim);
  font-style: italic;
  min-height: 1.5em;
  transition: opacity 0.2s;
}
.defend { margin-top: 12px; }

/* ---- comments the intern read ---- */
.comments-card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  padding: 14px 16px;
}
.comments-title {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--ember-bright);
  margin-bottom: 10px;
}
.comments-list { display: flex; flex-direction: column; gap: 12px; }
.cmt { border-left: 2px solid var(--panel-line); padding-left: 10px; }
.cmt-q {
  display: block;
  font-size: 12.5px;
  color: var(--ink);
  word-break: break-word;
}
.cmt-b {
  display: block;
  font-size: 11.5px;
  color: var(--ink-dim);
  margin-top: 3px;
  line-height: 1.45;
}
.comeback {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ember-bright);
  border-left: 2px solid var(--ember);
  padding-left: 10px;
}

/* ---- ledger panel ---- */
.ledger {
  margin-top: 26px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  padding: 20px;
  animation: rise 0.3s ease both;
}
.ledger-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.ledger-head h2 { margin: 0; font-size: 16px; color: var(--ember-bright); letter-spacing: 0.5px; }
.ledger-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.lstat {
  background: var(--bg-2);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.lstat-v { display: block; font-size: 22px; font-weight: 700; color: var(--ember-bright); font-variant-numeric: tabular-nums; }
.lstat-l { display: block; font-size: 10px; color: var(--ink-dim); margin-top: 4px; letter-spacing: 0.5px; text-transform: uppercase; }

.achv-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-dim); margin: 22px 0 12px; }
.achv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.achv {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 10px 12px;
}
.achv.locked { opacity: 0.5; }
.achv.got { border-color: rgba(255,179,71,0.4); }
.achv-i { font-size: 18px; color: var(--ember-bright); }
.achv.locked .achv-i { color: var(--ink-dim); }
.achv-n { display: block; font-size: 12px; font-weight: 700; color: var(--ink); }
.achv-d { display: block; font-size: 10.5px; color: var(--ink-dim); margin-top: 2px; line-height: 1.35; }

/* ---- achievement popup ---- */
.achv-pop {
  position: fixed;
  left: 50%; top: 24px;
  transform: translateX(-50%) translateY(-24px);
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--ember);
  border-radius: 12px;
  padding: 12px 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 70;
  box-shadow: 0 0 30px rgba(255,91,46,0.35);
  max-width: 360px;
}
.achv-pop.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- install nudge ---- */
.install-nudge {
  position: fixed;
  left: 50%; bottom: 22px;
  transform: translateX(-50%) translateY(24px);
  display: flex; align-items: center; gap: 14px;
  background: var(--panel);
  border: 1px solid var(--ember);
  border-radius: 12px;
  padding: 12px 14px 12px 18px;
  font-size: 13px;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 65;
  box-shadow: 0 0 26px rgba(255,91,46,0.3);
  max-width: 92vw;
}
.install-nudge.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.in-actions { display: flex; gap: 8px; align-items: center; }
.in-yes {
  font-family: inherit; font-size: 12px; font-weight: 700;
  background: linear-gradient(180deg, var(--ember-bright), var(--flame));
  color: #2a1405; border: none; border-radius: 8px; padding: 7px 12px; cursor: pointer;
}
.in-no {
  font-family: inherit; font-size: 13px;
  background: transparent; color: var(--ink-dim); border: 1px solid var(--panel-line);
  border-radius: 8px; padding: 6px 9px; cursor: pointer;
}
.ap-burst { font-size: 26px; color: var(--ember-bright); text-shadow: 0 0 12px rgba(255,179,71,0.6); }
.ap-title { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: 2px; color: var(--acid); }
.ap-name { display: block; font-size: 14px; font-weight: 700; color: var(--ink); margin-top: 2px; }
.ap-desc { display: block; font-size: 11px; color: var(--ink-dim); margin-top: 2px; line-height: 1.4; }

/* ---- live token preview under the textarea ---- */
.precount {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.3px;
}
.precount #preTokens, .precount #preBill { color: var(--ember-bright); font-weight: 700; font-variant-numeric: tabular-nums; }
.precount .pre-fire { filter: grayscale(0.2); }

/* ---- daily challenge banner ---- */
.daily-banner {
  margin-top: 12px;
  background: rgba(124,255,178,0.08);
  border: 1px solid rgba(124,255,178,0.35);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #d7ffe9;
  animation: rise 0.3s ease both;
}
.daily-banner strong { color: var(--acid); }

/* ---- clerk byline under the verdict ---- */
.verdict-byline {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ember-bright);
  letter-spacing: 0.4px;
}
.verdict-byline .by-title { color: var(--ink-dim); font-style: italic; }

/* ---- the optimizer card ---- */
.optimize-card {
  background: var(--panel);
  border: 1px solid rgba(124,255,178,0.3);
  border-radius: 14px;
  padding: 14px 16px;
}
.optimize-title {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--acid);
  margin-bottom: 8px;
}
.optimize-save { margin: 0; font-size: 13px; color: var(--ink); line-height: 1.5; }
.optimize-save b { color: var(--acid); }
.optimize-best { margin: 8px 0 0; font-size: 12px; color: var(--ink-dim); }
.optimize-best b { color: var(--ember-bright); }
.optimize-hint { margin: 8px 0 0; font-size: 12px; color: var(--ink-dim); font-style: italic; line-height: 1.5; }

/* ---- Hall of Shame ---- */
.hall-list { display: flex; flex-direction: column; gap: 10px; }
.hall-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-2);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 10px 12px;
}
.hall-grade {
  font-family: 'Press Start 2P', monospace;
  font-size: 18px; line-height: 1;
  color: var(--flame);
  flex-shrink: 0;
  width: 30px; text-align: center;
}
.hall-grade[data-grade="S"], .hall-grade[data-grade="A"] { color: var(--acid); }
.hall-main { min-width: 0; flex: 1; }
.hall-preview {
  display: block; font-size: 11.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: 'JetBrains Mono', monospace;
}
.hall-meta { display: block; font-size: 10.5px; color: var(--ink-dim); margin-top: 3px; letter-spacing: 0.3px; }
.hall-total { flex-shrink: 0; font-weight: 700; color: var(--ember-bright); font-variant-numeric: tabular-nums; font-size: 13px; }

/* ---- receipt rows print in line-by-line ---- */
.receipt-rows .r-row { animation: printrow 0.26s ease both; }
@keyframes printrow { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---- grade slams down like a rubber stamp ---- */
.verdict-grade.stamp { animation: stampin 0.5s cubic-bezier(0.2, 1.5, 0.35, 1) both; }
@keyframes stampin {
  0%   { transform: scale(2.7) rotate(-13deg); opacity: 0; }
  55%  { transform: scale(0.88) rotate(4deg); opacity: 1; }
  78%  { transform: scale(1.08) rotate(-2deg); }
  100% { transform: scale(1) rotate(0); }
}
/* ink-splatter flash behind the freshly stamped grade */
.verdict-grade-row { position: relative; }
.verdict-grade-row.inkflash::before {
  content: "";
  position: absolute;
  left: -6px; top: 50%;
  width: 64px; height: 64px;
  transform: translateY(-50%) scale(0.2);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,91,46,0.5) 0%, rgba(255,91,46,0) 70%);
  animation: inksplat 0.5s ease-out both;
  pointer-events: none;
}
@keyframes inksplat {
  from { transform: translateY(-50%) scale(0.2); opacity: 0.9; }
  to   { transform: translateY(-50%) scale(1.5); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .receipt-rows .r-row, .verdict-grade.stamp { animation: none; }
  .verdict-grade-row.inkflash::before { display: none; }
}

@media (max-width: 620px) {
  .results { grid-template-columns: 1fr; }
  .meters { position: static; flex-direction: row; padding: 12px 12px 0; }
  .stage { padding-top: 0; }
  #scene { height: 240px; }
  .privacy { margin-left: 0; width: 100%; }
  .ledger-stats { grid-template-columns: repeat(2, 1fr); }
  .achv-grid { grid-template-columns: 1fr; }
}
