/* Spot the Bug · Th3 SpaceIO
   Green = actions and correct. Red = the vulnerable line and wrong answers only. */

:root {
  --navy: #0A1628;
  --black: #05080D;
  --surface: #0E1D33;
  --surface-2: #122540;
  --surface-3: #18304F;
  --border: #1E3352;
  --border-strong: #2A4469;
  --green: #00CC6A;
  --green-ink: #03140B;
  --green-soft: rgba(0, 204, 106, 0.12);
  --green-line: rgba(0, 204, 106, 0.45);
  --red: #FF3B30;
  --red-text: #FF6B62;   /* Threat Red, lifted for small text on --red-soft (4.5:1) */
  --red-soft: rgba(255, 59, 48, 0.14);
  --red-line: rgba(255, 59, 48, 0.55);
  --gray: #A7B0BC;
  --gray-dim: #808D9F;   /* 4.5:1 or better on every surface (WCAG AA) */
  --white: #FFFFFF;
  --text: #E8EDF3;

  --tok-keyword: #8DB4FF;
  --tok-string: #E3C98F;
  --tok-comment: #808D9F;
  --tok-number: #C5ABFF;
  --tok-fn: #86D3E6;
  --tok-variable: #F1B6D2;
  --tok-tag: #8DB4FF;

  --font-sans: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--navy);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
main { flex: 1; }
[hidden] { display: none !important; }
h1, h2, h3 { color: var(--white); line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1:focus, h2:focus { outline: none; }
p { margin: 0; }
a { color: var(--green); }
button { font: inherit; color: inherit; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 var(--gutter); }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }

.skip {
  position: absolute; left: -999px; top: 8px; z-index: 10;
  background: var(--green); color: var(--green-ink); padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 600;
}
.skip:focus { left: 8px; }

:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- Top bar & footer ---------- */
.topbar { border-bottom: 1px solid var(--border); background: rgba(5, 8, 13, 0.55); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(8px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; color: var(--white); letter-spacing: 0.01em; }
.brand-by { font-size: 11px; color: var(--gray); letter-spacing: 0.14em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.team-badge { font-size: 12px; color: var(--green); border: 1px solid var(--green-line); background: var(--green-soft); padding: 3px 10px; border-radius: 99px; white-space: nowrap; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
.sister-link { font-size: 14px; color: var(--gray); text-decoration: none; white-space: nowrap; }
.sister-link:hover { color: var(--white); }
@media (max-width: 480px) { .sister-link { display: none; } }

.footer { border-top: 1px solid var(--border); margin-top: 56px; background: var(--black); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; padding-top: 20px; padding-bottom: 24px; font-size: 13px; color: var(--gray); }
.footer-brand { color: var(--white); font-weight: 700; letter-spacing: 0.12em; }
.footer-tagline { color: var(--green); font-weight: 600; letter-spacing: 0.16em; }
.footer-meta { color: var(--gray-dim); }

/* ---------- Shared pieces ---------- */
.screen { padding-top: 32px; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.16em; color: var(--green); margin-bottom: 12px; }
.lead { color: var(--gray); font-size: 18px; max-width: 62ch; margin-top: 14px; }
.muted { color: var(--gray); font-size: 14px; }
.section-title { font-size: 22px; margin: 40px 0 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.panel h2 { font-size: 18px; margin-bottom: 14px; }
@media (min-width: 720px) { .panel { padding: 24px; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; }
.btn-primary { background: var(--green); color: var(--green-ink); }
.btn-primary:hover:not(:disabled) { background: #19D97B; }
.btn-primary:disabled { background: var(--surface-3); color: var(--gray-dim); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { border-color: var(--gray); }
.btn-ghost:disabled { color: var(--gray-dim); border-color: var(--border); }
.btn-quiet { background: transparent; color: var(--gray); min-height: 36px; padding: 6px 12px; border-color: var(--border); }
.btn-quiet:hover { color: var(--white); border-color: var(--border-strong); }
.btn-block { width: 100%; }
.btn-sub { font-weight: 500; opacity: 0.75; }

/* ---------- Home ---------- */
.hero { padding: 24px 0 8px; }
.hero h1 { font-size: clamp(32px, 6vw, 52px); max-width: 18ch; font-weight: 700; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 22px 0 0; }
.chips li { font-size: 13px; color: var(--gray); border: 1px solid var(--border); background: var(--surface); padding: 5px 12px; border-radius: 99px; }

.levels { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.level-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.level-card:not(.is-locked):hover { border-color: var(--border-strong); }
.level-card.is-locked { opacity: 0.7; }
.level-head { display: flex; align-items: center; justify-content: space-between; }
.level-head h3 { font-size: 20px; }
.level-mult { font-family: var(--font-mono); font-size: 13px; color: var(--green); background: var(--green-soft); padding: 2px 8px; border-radius: 6px; }
.level-card.is-locked .level-mult { color: var(--gray); background: var(--surface-2); }
.level-blurb { color: var(--gray); font-size: 15px; flex: 1; }
.level-facts { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--gray); }
.level-facts strong { color: var(--white); font-weight: 600; }

.home-grid { display: grid; gap: 16px; margin-top: 16px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .home-grid { grid-template-columns: 1fr 1fr; } }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 10px; color: var(--gray); }
.steps strong { color: var(--white); }
.score-table { margin: 0; display: grid; gap: 2px; }
.score-table div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.score-table div:last-child { border-bottom: 0; }
.score-table dt { color: var(--gray); }
.score-table dd { margin: 0; color: var(--white); text-align: right; font-family: var(--font-mono); font-size: 13px; }

.board { margin-top: 16px; }
.board-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 14px; }
.board-head h2 { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 8px; overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; color: var(--gray); cursor: pointer; font-weight: 500; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--white); border-bottom-color: var(--green); }
.board-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.board-table th { text-align: left; font-weight: 500; color: var(--gray); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; padding: 10px 8px; }
.board-table td { padding: 10px 8px; border-top: 1px solid var(--border); }
.board-table .num { text-align: right; font-family: var(--font-mono); font-size: 13px; }
.board-table .strong { color: var(--white); font-weight: 600; }
.board-table .name { color: var(--white); width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-body { overflow-x: auto; }
.board-table tr.is-you td { background: var(--green-soft); }
.board-table tr.is-you td:first-child { box-shadow: inset 3px 0 0 var(--green); }
@media (max-width: 560px) { .hide-sm { display: none; } }
.empty { color: var(--gray); padding: 18px 0 6px; }
.error { margin-top: 24px; }
.error h1 { font-size: 24px; margin-bottom: 10px; }
.error p { color: var(--gray); }

/* ---------- Round ---------- */
.hud {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px;
}
.hud-stats { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.hud-item { display: flex; flex-direction: column; min-width: 56px; }
.hud-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gray); }
.hud-value { font-family: var(--font-mono); font-weight: 600; color: var(--white); font-size: 16px; }
.timer { flex: 1; min-width: 180px; display: flex; align-items: center; gap: 12px; }
.timer-num { font-family: var(--font-mono); font-weight: 600; font-size: 20px; color: var(--green); min-width: 2.2ch; text-align: right; }
.timer-track { flex: 1; height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.timer-bar { --p: 1; height: 100%; width: 100%; background: var(--green); transform-origin: left center; transform: scaleX(var(--p)); transition: transform 0.1s linear; }
.timer.is-low .timer-num { color: var(--white); }
.timer.is-low .timer-bar { background: var(--white); }
@media (prefers-reduced-motion: no-preference) {
  .timer.is-low .timer-num { animation: pulse 1s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: 0.45; } }
@media (max-width: 640px) {
  .timer { order: 3; flex-basis: 100%; }
  .hud .btn-quiet { margin-left: auto; }
}

.snippet-head { margin: 24px 0 16px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.badge { font-family: var(--font-mono); font-size: 12px; color: var(--white); background: var(--surface-2); border: 1px solid var(--border); padding: 2px 8px; border-radius: 6px; }
.badge-quiet { color: var(--gray); background: transparent; }
.snippet-head h2 { font-size: clamp(22px, 3.4vw, 28px); }
.context { color: var(--gray); margin-top: 6px; max-width: 75ch; }

.round-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .round-grid { grid-template-columns: minmax(0, 1fr) 340px; } }

.code-panel { background: var(--black); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-width: 0; }
.panel-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--gray); font-family: var(--font-mono); }
.panel-bar-hint { margin-left: auto; font-family: var(--font-sans); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.dot-red { background: var(--red); }
.dot-green { background: var(--green); }

.code { font-family: var(--font-mono); font-size: 13.5px; line-height: 1.7; padding: 8px 0; overflow-x: auto; }
@media (max-width: 560px) { .code { font-size: 12.5px; } }
.code .line {
  display: flex; align-items: stretch; width: max-content; min-width: 100%;
  background: transparent; border: 0; margin: 0; padding: 0 14px 0 0; text-align: left;
  color: var(--text); cursor: pointer; position: relative; border-left: 3px solid transparent;
}
.code .ln { flex: 0 0 auto; width: 3.2em; padding-right: 14px; text-align: right; color: var(--gray-dim); user-select: none; }
.code .lc { white-space: pre; flex: 1 0 auto; }
.code button.line:not(:disabled):hover { background: var(--surface-2); }
.code button.line:disabled { cursor: default; }
.code button.line:focus-visible { outline: none; background: var(--surface-2); border-left-color: var(--gray); }
.code .line[aria-pressed="true"] { background: var(--surface-3); border-left-color: var(--white); }
.code .line[aria-pressed="true"] .ln { color: var(--white); }
.line-tag { position: sticky; right: 0; margin-left: 16px; align-self: center; font-family: var(--font-sans); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; white-space: nowrap; }
.line-tag:empty { display: none; }

/* After lock in */
.code .line.is-vuln { background: var(--red-soft); border-left-color: var(--red); }
.code .line.is-vuln .ln { color: var(--red); }
.code .line.is-vuln .line-tag { color: var(--red); background: var(--black); padding: 1px 8px; border-radius: 4px; border: 1px solid var(--red-line); }
.code .line.is-related { background: rgba(255, 59, 48, 0.06); }
.code .line.is-found .line-tag::before { content: '✓ '; color: var(--green); }
.code .line.is-wrong { outline: 1px dashed var(--red-line); outline-offset: -1px; background: transparent; border-left-color: var(--red); }
.code .line.is-wrong .line-tag { color: var(--red); }
.code .line.is-fixed { background: var(--green-soft); border-left-color: var(--green); }
.code .line.is-fixed .ln { color: var(--green); }
.code-static .line { cursor: default; }

.tok-keyword { color: var(--tok-keyword); }
.tok-string { color: var(--tok-string); }
.tok-comment { color: var(--tok-comment); font-style: italic; }
.tok-number { color: var(--tok-number); }
.tok-fn { color: var(--tok-fn); }
.tok-variable { color: var(--tok-variable); }
.tok-tag { color: var(--tok-tag); }
.tok-deco { color: var(--tok-fn); }

.answer-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 18px; scroll-margin-top: 76px; }
@media (min-width: 900px) { .answer-panel { position: sticky; top: 76px; } }
.step h3 { font-size: 15px; display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.step-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong); font-family: var(--font-mono); font-size: 12px; color: var(--gray); }
.line-status { color: var(--gray); font-size: 14px; font-family: var(--font-mono); }
.line-status.is-set { color: var(--white); }
.options { display: grid; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  min-height: 44px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; color: var(--text);
}
.option:hover:not(:disabled) { border-color: var(--border-strong); }
.option[aria-pressed="true"] { border-color: var(--white); background: var(--surface-3); color: var(--white); }
.option:disabled { cursor: default; }
.option .key { font-family: var(--font-mono); font-size: 11px; color: var(--gray); border: 1px solid var(--border-strong); border-radius: 4px; min-width: 20px; text-align: center; }
.option .opt-name { font-size: 14.5px; }
.option.is-correct { border-color: var(--green); background: var(--green-soft); color: var(--white); }
.option.is-correct .key { color: var(--green); border-color: var(--green-line); }
.option.is-wrong { border-color: var(--red); background: var(--red-soft); }
.option.is-wrong .key { color: var(--red); border-color: var(--red-line); }
.keys { font-size: 12px; color: var(--gray); }
@media (hover: none) { .keys, .option .key { display: none; } }

/* Verdict */
.verdict { border-radius: var(--radius-sm); padding: 14px; border: 1px solid var(--border); background: var(--surface-2); }
.verdict-title { font-size: 20px; font-weight: 700; color: var(--white); }
.verdict-note { color: var(--gray); font-size: 14px; margin-top: 2px; }
.verdict-win { border-color: var(--green-line); background: var(--green-soft); }
.verdict-win .verdict-title { color: var(--green); }
.verdict-miss { border-color: var(--red-line); background: var(--red-soft); }
.verdict-miss .verdict-title { color: var(--red); }
.breakdown { margin: 0; display: grid; }
.breakdown div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; color: var(--gray); }
.breakdown div.has { color: var(--text); }
.breakdown div.has dd { color: var(--green); }
.breakdown dd { margin: 0; font-family: var(--font-mono); font-size: 13px; }
.breakdown .total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; color: var(--white); font-weight: 600; }
.breakdown .total dd { color: var(--white); font-size: 15px; }
.cat-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; background: var(--navy); }
.cat-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gray); }
.cat-name { font-size: 17px; font-weight: 600; color: var(--white); margin-top: 4px; }
.cat-meta { font-family: var(--font-mono); font-size: 12px; color: var(--gray); margin-top: 2px; }
.cat-summary { font-size: 14px; color: var(--gray); margin-top: 8px; }

/* Reveal */
.reveal { display: grid; gap: 16px; margin-top: 16px; }
.reveal:empty { display: none; }
.explain { display: grid; gap: 18px; }
@media (min-width: 860px) { .explain { grid-template-columns: 3fr 2fr; gap: 32px; } }
.explain h3 { font-size: 15px; margin-bottom: 6px; }
.explain p { color: var(--text); }
.explain-side .fix-part p { color: var(--gray); }
.compare { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .compare { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.compare .code { font-size: 12.5px; }

/* ---------- Results ---------- */
.results-hero { padding: 16px 0 8px; }
.results-hero h1 { font-size: clamp(30px, 5vw, 44px); }
.big-score { color: var(--green); font-family: var(--font-mono); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 24px 0 16px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.stat-value { font-family: var(--font-mono); font-size: 24px; font-weight: 600; color: var(--white); }
.stat-label { font-size: 13px; color: var(--gray); }
.results-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .results-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.focus-list { list-style: none; padding: 0; margin: 0; }
.focus-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.focus-list li:first-child { border-top: 0; }
.focus-name { color: var(--white); font-weight: 500; }
.focus-meta { font-family: var(--font-mono); font-size: 12px; color: var(--gray); }
.focus-count { font-size: 13px; color: var(--gray); white-space: nowrap; }
.save-form label { display: block; font-size: 14px; color: var(--gray); margin-bottom: 6px; }
.save-row { display: flex; gap: 8px; }
.save-row input {
  flex: 1; min-width: 0; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--navy); border: 1px solid var(--border-strong); color: var(--white); font: inherit;
}
.save-row input:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: transparent; }
.save-msg { font-size: 14px; color: var(--green); min-height: 1.5em; margin: 8px 0 4px; }
.review { margin-top: 16px; }
.review-list { list-style: none; padding: 0; margin: 0; }
.review-list li { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.review-list li:first-child { border-top: 0; }
.review-title { color: var(--white); }
.review-cat { grid-column: 2; font-size: 13px; color: var(--gray); }
.review-pts { grid-column: 3; grid-row: 1 / span 2; font-family: var(--font-mono); color: var(--white); }
.pill { grid-row: 1 / span 2; font-size: 12px; font-weight: 600; text-align: center; padding: 3px 8px; border-radius: 99px; border: 1px solid var(--border-strong); color: var(--gray); }
.pill-win { color: var(--green); border-color: var(--green-line); background: var(--green-soft); }
.pill-miss { color: var(--red-text); border-color: var(--red-line); background: var(--red-soft); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

/* Phones: wrap long code lines so the whole flaw is visible without sideways scrolling */
@media (max-width: 560px) {
  .code .line { width: 100%; }
  .code .lc { white-space: pre-wrap; overflow-wrap: anywhere; flex: 1 1 auto; min-width: 0; }
  /* A wrapped line continues under its own indentation, two spaces further in (matters for Python) */
  .code .lc { padding-left: calc((var(--ind, 0) + 2) * 1ch); text-indent: calc((var(--ind, 0) + 2) * -1ch); }
  .code, .compare .code { font-size: 11.5px; }
  .code .line { padding-right: 8px; }
  .code .ln { width: 2.4em; padding-right: 8px; }
  .line-tag { display: none !important; }
  .hud-stats { gap: 8px 18px; }
}

/* Game Night: shown on days other than Friday (assets/js/gamenight.js) */
.gamenight-closed { margin: 8px 0 28px; padding: 20px 22px; border: 1px solid var(--green-line); border-radius: 14px; background: var(--green-soft); }
.gamenight-closed h2 { margin: 0 0 8px; font-size: 1.15rem; }
.gamenight-closed p { margin: 0 0 10px; }
.gamenight-closed .btn { margin-top: 6px; }
@media (max-width: 560px) { .gamenight-closed .btn { width: 100%; } }

/* ---------- Online scoreboard and team links ---------- */
.notice { border: 1px solid var(--border-strong); border-left: 3px solid var(--gray); background: var(--surface); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 8px; }
.notice p { color: var(--gray); font-size: 14px; }
.notice .notice-title { color: var(--white); font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.board-note { font-size: 13px; color: var(--gray); border-left: 2px solid var(--border-strong); padding: 4px 10px; margin: 4px 0 10px; }
.save-hint { font-size: 12.5px; color: var(--gray-dim); margin-top: 8px; }
.save-msg.is-pending { color: var(--gray); }
.save-msg.is-warning { color: var(--white); }
.board-table .num { white-space: nowrap; }

/* =====================================================================
   v0.6: menu, motion, slides, scoreboard, account, privacy, big screen.
   Motion follows LureLens: words reveal one by one, cards rise in, buttons
   squeeze on press, cards glow under the pointer. All still for people
   who ask for reduced motion.
   ===================================================================== */

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 32px; height: 32px; }
.icon-green { color: var(--green); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

/* ---------- Menu ---------- */
.topbar-inner { gap: 16px; }
.nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.nav-link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--gray); text-decoration: none; font-weight: 500; font-size: 15px; white-space: nowrap;
  transition: color 0.15s, background-color 0.15s;
}
.nav-link:hover { color: var(--white); background: var(--surface-2); }
.nav-link[aria-current="page"] { color: var(--white); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--green); }
.nav-link.is-signed-in .nav-icon { color: var(--green); }
.nav-short { display: none; }
.nav-label { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; }
.team-badge { order: 3; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 14px; min-width: 0; max-width: 100%; }
.footer-links a { color: var(--gray); text-decoration: none; }
.footer-links a:hover { color: var(--white); text-decoration: underline; }

/* Phones and small tablets: a tab bar along the bottom, out of the way during a round. */
@media (max-width: 760px) {
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0; gap: 0;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    background: rgba(5, 8, 13, 0.94); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .nav-link { flex-direction: column; gap: 2px; min-height: 52px; padding: 6px 2px; font-size: 11.5px; justify-content: center; border-radius: 10px; }
  .nav-link[aria-current="page"] { box-shadow: none; color: var(--green); background: transparent; }
  .nav-label { display: none; }
  .nav-link[data-view="about"] { display: none; }   /* About and Privacy stay in the footer */
  .nav-short { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .nav-icon { width: 20px; height: 20px; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body[data-view="round"] .nav, body[data-view="exam"] .nav, body[data-view="live"] .nav { display: none; }
  body[data-view="round"], body[data-view="exam"] { padding-bottom: 0; }
  .topbar-inner { height: 56px; }
  .team-badge { max-width: 46vw; }
}

/* ---------- Motion ---------- */
@keyframes rise-in { from { opacity: 0; transform: perspective(900px) translate3d(0, 14px, -30px) rotateX(9deg); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes screen-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes word-in { from { opacity: 0; transform: translateY(0.45em); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes hero-progress { from { width: 0; } to { width: 100%; } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes live-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(0, 204, 106, 0.55); } 70% { box-shadow: 0 0 0 7px rgba(0, 204, 106, 0); } }

.word-in { display: inline-block; white-space: pre; }
.hud-value { display: inline-block; }

@media (prefers-reduced-motion: no-preference) {
  .screen-in { animation: screen-in 0.38s cubic-bezier(0.22, 1, 0.36, 1) backwards; }   /* not "both": a kept transform would trap position: fixed children (the pause cover) */
  .word-in { animation: word-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) backwards; animation-delay: calc(var(--d, 0ms) + var(--w, 0) * 55ms); }
  .text-in { animation: rise-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards; animation-delay: var(--d, 0ms); }
  .rise-in { animation: rise-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) backwards; animation-delay: calc(min(var(--i, 0), 8) * 50ms); }
  .fade-in-row { animation: fade-in 0.4s ease-out backwards; animation-delay: calc(min(var(--i, 0), 10) * 30ms); }
  .stagger-children > :not(:first-child) { animation: rise-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards; animation-delay: calc(250ms + var(--k, 8) * 60ms); }
  .stagger-children > :nth-child(2) { --k: 0; } .stagger-children > :nth-child(3) { --k: 1; } .stagger-children > :nth-child(4) { --k: 2; }
  .stagger-children > :nth-child(5) { --k: 3; } .stagger-children > :nth-child(6) { --k: 4; } .stagger-children > :nth-child(7) { --k: 5; }
  .stagger-children > :nth-child(8) { --k: 6; } .stagger-children > :nth-child(9) { --k: 7; }
  .pop { animation: pop 0.35s cubic-bezier(0.22, 1, 0.36, 1); }
  .lift { transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.2s, box-shadow 0.25s; }
  .lift:hover { transform: translateY(-3px); }
  /* Every button answers a press with a quick, small squeeze. */
  button:not(:disabled):not([data-no-press]), .btn:not([aria-disabled="true"]) { transition: color 0.15s, background-color 0.15s, border-color 0.15s, box-shadow 0.15s, scale 0.15s cubic-bezier(0.22, 1, 0.36, 1); }
  button:not(:disabled):not([data-no-press]):active, a.btn:active { scale: 0.96; }
  .btn:active:not(:disabled) { transform: none; }
}
/* Cards and panels take a soft green edge under the pointer; only the innermost one. Mouse and trackpad only. */
@media (hover: hover) {
  .card { transition: box-shadow 0.25s ease, border-color 0.25s ease; }
  .card:hover:not(:has(.card:hover)) { border-color: var(--border-strong); box-shadow: 0 0 0 1px rgba(0, 204, 106, 0.22), 0 18px 40px -26px rgba(0, 204, 106, 0.45); }
  .btn-primary:hover:not(:disabled) { box-shadow: 0 8px 24px -10px rgba(0, 204, 106, 0.75); }
  .btn-ghost:hover:not(:disabled) { border-color: var(--green-line); color: var(--white); background: var(--green-soft); }
}

/* ---------- Page heads ---------- */
.screen { padding-top: 28px; }
.page-head { margin-bottom: 22px; }
.page-title { font-size: clamp(28px, 5vw, 44px); font-weight: 700; letter-spacing: -0.025em; }
h2.page-title { font-size: clamp(22px, 3.4vw, 30px); }
.page-head .lead { margin-top: 10px; }
.notice-team { border-left-color: var(--green); margin-bottom: 14px; }
.notice-team .notice-title { display: flex; align-items: center; gap: 6px; }
.notice .btn { margin-top: 10px; }
.empty-state { display: grid; place-items: center; gap: 10px; text-align: center; color: var(--gray); padding: 32px 12px; }
.empty-state .icon { color: var(--border-strong); }
.link-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; background: none; border: 0; padding: 0; color: var(--green); font-weight: 500; cursor: pointer; text-decoration: none; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.fine-print { margin-top: 18px; font-size: 13px; color: var(--gray-dim); text-align: center; }
.fine-print a { color: var(--gray); }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 10px; }
.panel-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }

/* ---------- Hero slides ---------- */
.hero-slides { position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 22px; background: linear-gradient(160deg, rgba(14, 29, 51, 0.9), rgba(10, 22, 40, 0.6)); padding: 18px; margin-top: 4px; }
.hero-slides::before, .hero-slides::after { content: ''; position: absolute; width: 300px; height: 300px; border-radius: 50%; filter: blur(60px); pointer-events: none; }
.hero-slides::before { right: -120px; top: -140px; background: rgba(0, 204, 106, 0.09); }
.hero-slides::after { left: -100px; bottom: -160px; background: rgba(77, 124, 255, 0.08); }
@media (min-width: 720px) { .hero-slides { padding: 32px; } }
.slides-stage { position: relative; display: grid; }
.slide { grid-area: 1 / 1; display: grid; gap: 20px; align-items: center; visibility: hidden; }
.slide.is-active { visibility: visible; }
@media (min-width: 860px) { .slide { grid-template-columns: 1.5fr 1fr; gap: 40px; } }
.slide-text { display: grid; gap: 12px; }
.slide-tag { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.16em; color: var(--green); }
.slide-title { font-size: clamp(26px, 5.4vw, 48px); font-weight: 700; line-height: 1.08; letter-spacing: -0.025em; color: var(--white); }
.slide-word { display: inline-block; white-space: pre; }
.slide-sub { color: var(--gray); font-size: clamp(15px, 2vw, 18px); max-width: 52ch; }
.slide-visual { display: flex; justify-content: center; }
@media (min-width: 860px) { .slide-visual { justify-content: flex-end; } }
@media (prefers-reduced-motion: no-preference) {
  .slide .slide-tag, .slide .slide-sub, .slide .slide-word, .slide .slide-visual { transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), filter 0.45s ease; }
  .slide:not(.is-active) .slide-tag { opacity: 0; transform: translateY(-8px); }
  .slide:not(.is-active) .slide-word { opacity: 0; transform: translateY(18px); filter: blur(6px); }
  .slide:not(.is-active) .slide-sub { opacity: 0; transform: translateY(10px); }
  .slide:not(.is-active) .slide-visual { opacity: 0; transform: translateY(24px) rotate(2deg) scale(0.96); }
  .slide.is-active .slide-word { transition-delay: calc(80ms + var(--w) * 45ms); }
  .slide.is-active .slide-sub { transition-delay: 350ms; }
  .slide.is-active .slide-visual { transition-delay: 200ms; }
}
.slides-bar { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; }
.slides-cta { display: flex; gap: 10px; flex: 1 1 auto; }
.slides-nav { display: flex; align-items: center; gap: 2px; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--gray); cursor: pointer; }
.icon-btn:hover { color: var(--white); background: var(--surface-2); }
.slide-dots { display: flex; align-items: center; }
.slide-dot { display: grid; place-items: center; width: 28px; height: 44px; border: 0; background: none; cursor: pointer; border-radius: 99px; }
.slide-dot-track { position: relative; display: block; width: 6px; height: 6px; border-radius: 99px; background: rgba(167, 176, 188, 0.5); overflow: hidden; transition: width 0.3s, background-color 0.3s; }
.slide-dot:hover .slide-dot-track { background: var(--white); }
.slide-dot.is-active .slide-dot-track { width: 24px; background: rgba(0, 204, 106, 0.3); }
.slide-dot-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--green); border-radius: 99px; }
.slide-dot.is-active .slide-dot-fill { width: 100%; }
.slide-dot.is-active .slide-dot-fill.is-running { width: 0; animation: hero-progress 6s linear forwards; }
@media (max-width: 560px) {
  .slides-cta { width: 100%; }
  .slides-cta .btn { flex: 1; }
  .slides-nav { width: 100%; justify-content: space-between; }
}

/* Slide illustrations */
.mini-card { width: 100%; max-width: 380px; background: var(--black); border: 1px solid var(--border); border-radius: 16px; padding: 14px; box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.7); font-size: 13px; }
.mini-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: var(--font-mono); font-size: 11.5px; color: var(--gray); letter-spacing: 0.04em; margin-bottom: 10px; }
.mini-top .dot { width: 8px; height: 8px; }
.mini-time { color: var(--green); }
.mini-track { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-bottom: 12px; }
.mini-bar { height: 100%; width: 35%; border-radius: 99px; background: var(--green); }
@media (prefers-reduced-motion: no-preference) {
  .mini-bar { animation: mini-drain 6s linear both; }
  .mini-row, .mini-option { animation: rise-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) backwards; animation-delay: calc(300ms + var(--i, 0) * 300ms); }
}
@keyframes mini-drain { from { width: 100%; } to { width: 35%; } }
.mini-code { font-family: var(--font-mono); font-size: 11.5px; line-height: 1.75; overflow: hidden; }
.mini-line { display: flex; gap: 10px; white-space: pre; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid transparent; padding-right: 4px; }
.mini-ln { color: var(--gray-dim); width: 2ch; text-align: right; flex: 0 0 auto; }
.mini-line.is-vuln { background: var(--red-soft); border-left-color: var(--red); }
.mini-line.is-vuln .mini-ln { color: var(--red); }
.mini-line.is-fixed { background: var(--green-soft); border-left-color: var(--green); }
.mini-compare { display: grid; gap: 10px; width: 100%; max-width: 380px; }
.mini-options { display: grid; gap: 8px; }
.mini-option { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.mini-option.is-right { border-color: var(--green); background: var(--green-soft); color: var(--white); }
.mini-option .icon { color: var(--green); }
.mini-key { font-family: var(--font-mono); font-size: 10.5px; color: var(--gray); border: 1px solid var(--border-strong); border-radius: 4px; min-width: 18px; text-align: center; }
.mini-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 8px; background: var(--surface); margin-top: 6px; color: var(--white); }
.mini-rank { font-family: var(--font-mono); color: var(--gray); margin-right: 10px; }
.mini-score { font-family: var(--font-mono); font-weight: 600; }
.mini-live { display: inline-flex; align-items: center; gap: 6px; color: var(--green); }

/* ---------- Home ---------- */
.levels-section { margin-top: 36px; }
.gamenight-closed { margin-top: 20px; }
.top-players .board-table td, .top-players .board-table th { padding: 8px 6px; }
.top-body { min-height: 60px; }

/* ---------- Live indicator ---------- */
.live-status { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--gray); font-family: var(--font-mono); letter-spacing: 0.03em; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray-dim); flex: 0 0 auto; }
.live-status[data-status="live"] { color: var(--green); }
.live-status[data-status="live"] .live-dot, .mini-live .live-dot { background: var(--green); }
@media (prefers-reduced-motion: no-preference) {
  .live-status[data-status="live"] .live-dot, .mini-live .live-dot { animation: live-pulse 2s infinite; }
}

/* ---------- Scoreboard ---------- */
.board-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.board-controls { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--black); border: 1px solid var(--border); border-radius: 10px; }
.seg { min-height: 38px; padding: 6px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--gray); cursor: pointer; font-weight: 500; font-size: 14px; white-space: nowrap; }
.seg:hover { color: var(--white); background: var(--surface-2); }
.seg[aria-pressed="true"] { background: var(--surface-3); color: var(--white); box-shadow: inset 0 0 0 1px var(--green-line); }
.table-scroll { overflow-x: auto; }
.table-scroll:focus-visible { outline-offset: 4px; }
.board-table .rank { font-family: var(--font-mono); color: var(--gray); width: 3ch; }
.board-table .name span:first-child { overflow: hidden; text-overflow: ellipsis; }
.board-table tr.is-you td { background: var(--green-soft); }
.you-tag { margin-left: 8px; font-size: 11px; font-family: var(--font-mono); color: var(--green); border: 1px solid var(--green-line); border-radius: 99px; padding: 0 6px; vertical-align: 1px; }
.muted-cell { color: var(--gray); font-size: 13px; }
.board-foot { margin-top: 12px; text-align: center; }
.podium { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; }
.podium-step { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 16px 8px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.podium-1 { padding-top: 26px; background: linear-gradient(180deg, rgba(0, 204, 106, 0.16), var(--surface-2)); border-color: var(--green-line); }
.podium-2 { padding-top: 18px; }
.podium-medal { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-family: var(--font-mono); font-weight: 700; color: var(--green-ink); background: var(--gray); }
.podium-1 .podium-medal { background: var(--green); width: 40px; height: 40px; font-size: 18px; }
.podium-2 .podium-medal { background: #D7DEE8; }
.podium-3 .podium-medal { background: #8E99A8; }
.podium-name { color: var(--white); font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-score { font-family: var(--font-mono); font-weight: 700; color: var(--green); font-size: 18px; }
.podium-meta { font-size: 12px; color: var(--gray); }
.podium-step.is-you { box-shadow: inset 0 0 0 2px var(--green); }
@media (max-width: 420px) { .podium-step { padding-left: 4px; padding-right: 4px; } .podium-score { font-size: 15px; } }

/* ---------- Round ---------- */
.hud-value.is-hot { color: var(--green); }

/* ---------- Results ---------- */
.big-score-unit { color: var(--white); }
.post-panel .btn-row { margin-top: 12px; }
.post-panel .board-body { margin-top: 12px; }
.save-hint { margin-top: 10px; }

/* ---------- Account ---------- */
.account-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .account-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.account-stack { display: grid; gap: 16px; max-width: 760px; }
.account-grid .panel h2, .account-stack .panel h2 { display: flex; align-items: center; gap: 8px; }
.form { display: grid; gap: 10px; margin-top: 12px; }
.form label { font-size: 14px; color: var(--gray); }
.field { display: grid; gap: 6px; }
.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--navy); border: 1px solid var(--border-strong); color: var(--white); font: inherit;
}
.input:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: transparent; }
.input-code { font-family: var(--font-mono); font-size: 22px; letter-spacing: 0.35em; max-width: 220px; }
.form-inline { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.form-inline .input { flex: 1 1 220px; width: auto; }
.hint { font-size: 12.5px; color: var(--gray-dim); }
.form-error { color: var(--white); font-size: 14px; min-height: 0; }
.form-error:not(:empty) { border-left: 3px solid var(--gray); padding: 6px 10px; background: var(--surface-2); border-radius: 6px; }
.profile-list { margin: 0; display: grid; gap: 0; }
.profile-list div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.profile-list div:last-child { border-bottom: 0; }
.profile-list dt { color: var(--gray); font-size: 14px; }
.profile-list dd { margin: 0; color: var(--white); text-align: right; overflow-wrap: anywhere; }
.panel-accent { border-color: var(--green-line); }
.panel-quiet { background: transparent; }
.danger-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.panel-danger { border-color: var(--white); }
.panel-danger p { color: var(--gray); margin: 8px 0; }
.btn-danger { background: var(--white); color: var(--navy); }
.btn-danger:disabled { background: var(--surface-3); color: var(--gray-dim); }

/* ---------- Prose (privacy) and About ---------- */
.prose { max-width: 760px; }
.prose p, .prose li { color: var(--text); }
.prose > .stagger-children > p { margin-bottom: 18px; color: var(--gray); font-size: 17px; }
.prose-section { padding: 18px 0; border-top: 1px solid var(--border); }
.prose-section h2 { font-size: 19px; margin-bottom: 10px; }
.prose-section ul { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 8px; }
.prose-section p + p { margin-top: 10px; }
.prose strong { color: var(--white); }
.about-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .about-grid { grid-template-columns: 1fr 1fr; } }
.about-grid p + p { margin-top: 10px; }
.about-levels { margin: 12px 0 0; padding-left: 18px; display: grid; gap: 8px; color: var(--gray); font-size: 15px; }
.about-levels strong { color: var(--white); }
.chip-list { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 13px; color: var(--text); border: 1px solid var(--border-strong); background: var(--surface-2); padding: 5px 11px; border-radius: 99px; }
.link-list { display: grid; gap: 2px; margin-top: 12px; }

/* ---------- Big screen (?live) ---------- */
body[data-view="live"] .topbar, body[data-view="live"] .footer { display: none; }
body[data-view="live"] #app { max-width: none; padding: 0; }
body[data-view="live"] .screen { padding-top: 0; }
.live-screen { min-height: 100vh; padding: clamp(16px, 3vw, 48px); display: grid; grid-template-rows: auto 1fr; gap: clamp(16px, 2.5vw, 36px); background: radial-gradient(1200px 600px at 85% -10%, rgba(0, 204, 106, 0.08), transparent), var(--navy); }
.live-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.live-title { font-size: clamp(32px, 5vw, 72px); font-weight: 700; letter-spacing: -0.03em; }
.live-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.live-body { display: grid; gap: clamp(16px, 2.5vw, 36px); grid-template-columns: 1fr; align-items: start; }
@media (min-width: 1000px) { .live-body { grid-template-columns: 1fr minmax(260px, 340px); } }
.live-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.live-row { display: grid; grid-template-columns: 3ch 1fr auto auto; align-items: center; gap: 18px; padding: clamp(10px, 1.4vw, 18px) clamp(14px, 2vw, 26px); border-radius: 16px; background: var(--surface); border: 1px solid var(--border); font-size: clamp(18px, 2.2vw, 30px); }
.live-rank { font-family: var(--font-mono); color: var(--gray); }
.live-name { color: var(--white); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-level { color: var(--gray); font-size: 0.6em; }
.live-score { font-family: var(--font-mono); font-weight: 700; color: var(--white); }
.live-1 { border-color: var(--green); background: linear-gradient(90deg, rgba(0, 204, 106, 0.18), var(--surface)); }
.live-1 .live-score, .live-1 .live-rank { color: var(--green); }
.live-top .live-rank { color: var(--white); }
.live-empty { color: var(--gray); font-size: clamp(18px, 2vw, 26px); padding: 30px 0; }
.live-join { padding: 20px; display: grid; gap: 8px; justify-items: center; text-align: center; }
.live-qr { width: min(260px, 70vw); }
.live-qr .qr { display: block; width: 100%; height: auto; border-radius: 10px; }
.live-join-title { font-size: 22px; font-weight: 700; color: var(--white); }
.live-join-url { font-family: var(--font-mono); color: var(--green); font-size: 14px; overflow-wrap: anywhere; }
.live-exit { color: var(--gray); font-size: 13px; }
@media (max-width: 640px) { .live-row { grid-template-columns: 3ch 1fr auto; gap: 10px; } .live-level { display: none; } }

/* ---------- Narrow phones (320px) ---------- */
@media (max-width: 380px) {
  .wrap { padding: 0 12px; }
  .brand-by { display: none; }
  .hud { padding: 10px 12px; }
  .hud-stats { gap: 6px 14px; }
  .seg { padding: 6px 9px; font-size: 13px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 20px; }
}
/* Screens slide in from the side; never let that cause a sideways scrollbar. */
#app { overflow-x: clip; }
/* Slides never grow wider than the screen: long code lines in the
   illustrations are clipped inside their card instead. */
.slides-stage, .slide { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .slide { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); } }
.slide-text, .slide-visual, .mini-card, .mini-compare, .mini-code { min-width: 0; }
.slide-title { overflow-wrap: break-word; }
.btn { white-space: nowrap; }
@media (max-width: 420px) {
  .level-card .btn-sub { display: none; }
  .slides-cta .btn { padding-left: 12px; padding-right: 12px; }
}
/* The header's blur would trap the fixed tab bar inside it (a filter makes a
   new containing block), so on phones the header is solid instead. */
@media (max-width: 760px) {
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(5, 8, 13, 0.97); }
}

/* ================= v0.7: progress, certificate, share, pause ================= */
.mono { font-family: var(--font-mono); }
.link-btn.inline { min-height: 0; display: inline; }
.btn-small { min-height: 38px; padding: 6px 14px; font-size: 14px; }
.narrow { max-width: 640px; }

/* Progress */
.stats-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 560px) { .stats-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .stats-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.progress-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin-bottom: 16px; }
@media (min-width: 900px) { .progress-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.progress-grid + .panel, .weak, .cert-panel { margin-bottom: 16px; }
.bars { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 14px; }
.bars-compact { gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 48px; grid-template-areas: "label value" "bar bar"; gap: 6px 10px; align-items: end; }
.bar-label { grid-area: label; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; min-width: 0; }
.bar-label strong { color: var(--white); font-weight: 600; }
.bar-label .muted { font-size: 13px; }
.bar { grid-area: bar; height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; width: var(--v); background: var(--green); border-radius: inherit; transform-origin: left center; }
.bar-fill.is-weak { background: var(--gray); }
.bar-value { grid-area: value; font-family: var(--font-mono); font-size: 14px; color: var(--white); text-align: right; }
@media (prefers-reduced-motion: no-preference) {
  .bar-fill { animation: bar-grow 0.8s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 60ms); }
}
@keyframes bar-grow { from { transform: scaleX(0); } }
.weak-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 760px) { .weak-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.weak-list li { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: grid; gap: 4px; }
.weak-list .muted { font-size: 14px; }

/* Certificate */
.cert-panel h2 { display: flex; align-items: center; gap: 8px; }
.cert-levels { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 760px) { .cert-levels { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.cert-level { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.cert-level strong { color: var(--white); }
.cert-level .muted { font-size: 13px; margin-top: 2px; }
.cert-check { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--green-soft); color: var(--green); flex: 0 0 auto; }
.cert-earned { display: flex; align-items: center; gap: 6px; color: var(--white); margin-bottom: 14px; }
.cert-panel .field { max-width: 420px; margin-bottom: 14px; }
.cert-preview { background: var(--black); border: 1px solid var(--border); border-radius: 10px; padding: clamp(8px, 2vw, 16px); }
.cert-image, .share-image { display: block; width: 100%; height: auto; border-radius: 6px; aspect-ratio: 2000 / 1414; background: var(--surface-2); }
.share-image { aspect-ratio: 1200 / 630; }
.cert-online { margin-top: 14px; display: grid; gap: 8px; justify-items: start; }
.cert-online p { color: var(--gray); }
.cert-online a { color: var(--green); overflow-wrap: anywhere; }
.cert-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.cert-form .field { flex: 1 1 220px; }
.cert-form .input { text-transform: uppercase; letter-spacing: 0.08em; }
.cert-result { margin-top: 18px; }
.cert-valid { border: 1px solid var(--green-line); border-radius: 10px; padding: 16px; background: var(--green-soft); }
.cert-valid-head { display: flex; align-items: center; gap: 6px; color: var(--white); margin-bottom: 12px; }
.cert-facts { display: grid; gap: 8px; margin: 0 0 12px; }
.cert-facts div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; }
.cert-facts dt { color: var(--gray); font-size: 14px; }
.cert-facts dd { margin: 0; color: var(--white); overflow-wrap: anywhere; }
@media (max-width: 420px) { .cert-facts div { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.cert-invalid { border: 1px solid var(--border-strong); border-radius: 10px; padding: 16px; display: grid; gap: 6px; }
.cert-invalid p:first-child { display: flex; align-items: center; gap: 6px; color: var(--white); }

/* Share */
.share-panel { display: grid; gap: 16px; align-items: center; margin-top: 16px; }
@media (min-width: 860px) { .share-panel { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); } }
.share-panel h2 { margin-bottom: 6px; }
.share-preview { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }

/* Pause and report */
.hud-actions { display: flex; gap: 8px; }
@media (max-width: 640px) { .hud-actions { margin-left: auto; } .hud .hud-actions .btn-quiet { margin-left: 0; } }
.hud-actions .btn-quiet { gap: 6px; }
#app .screen.is-paused .code-panel, #app .screen.is-paused .options, #app .screen.is-paused .snippet-head .context { filter: blur(10px); user-select: none; pointer-events: none; }
.pause-cover { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(5, 8, 13, 0.82); }
.pause-cover[hidden] { display: none; }
.pause-box { width: min(420px, 100%); padding: 28px 24px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.pause-box h2 { font-size: 28px; }
.pause-box .btn { margin-top: 10px; }
.report { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13.5px; color: var(--gray); border-top: 1px solid var(--border); padding-top: 12px; }
.report a { color: var(--green); }

/* What's new */
.whatsnew { width: min(520px, calc(100% - 32px)); max-height: calc(100dvh - 48px); overflow: auto; padding: 26px 24px; color: var(--text); border: 1px solid var(--border-strong); }
.whatsnew::backdrop { background: rgba(5, 8, 13, 0.75); }
.whatsnew h2 { font-size: 24px; margin-bottom: 14px; }
.whatsnew h3 { font-size: 15px; color: var(--gray); margin: 16px 0 8px; }
.whatsnew-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.whatsnew-list li { display: flex; gap: 10px; align-items: flex-start; }
.whatsnew-list .icon { margin-top: 4px; }
@media (prefers-reduced-motion: no-preference) {
  .whatsnew[open] { animation: pop-in 0.28s cubic-bezier(.2, .7, .2, 1); }
}
@keyframes pop-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.mini-cert-title { font-weight: 700; color: var(--white); font-size: 15px; margin: 10px 0 8px; }
.mini-ref { font-family: var(--font-mono); color: var(--green); }
.mini-cert-levels { display: grid; gap: 4px; }

/* ================= v0.8: classroom, class big screen, moderation ================= */
.field-label { font-size: 14px; font-weight: 500; color: var(--text); }
.small-btn { min-height: 32px; font-size: 13px; }
.class-hub { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .class-hub { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .class-hub > :last-child:nth-child(4) { grid-column: 1 / -1; } }
.class-hub .form { display: grid; gap: 14px; }
.class-hub .input-code { max-width: 200px; text-transform: uppercase; letter-spacing: 0.25em; }
.class-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.class-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.class-list li:last-child { border-bottom: 0; }
.class-list a { display: inline-flex; gap: 10px; align-items: baseline; color: var(--white); text-decoration: none; font-weight: 600; }
.class-list a:hover .class-name { text-decoration: underline; text-underline-offset: 3px; }
.class-code { color: var(--green); letter-spacing: 0.08em; }
.class-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--gray); font-size: 14px; margin: -6px 0 18px; }
.class-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 980px) { .class-grid { grid-template-columns: minmax(0, 1fr) 320px; } .teacher-panel { position: sticky; top: 84px; } }
.class-main { display: grid; gap: 16px; min-width: 0; }
.teacher-panel { display: grid; gap: 10px; justify-items: start; }
.class-code-big { font-size: clamp(34px, 6vw, 46px); font-weight: 600; letter-spacing: 0.16em; color: var(--white); line-height: 1.1; }
.class-qr { width: min(220px, 70vw); }
.class-qr .qr { display: block; width: 100%; height: auto; border-radius: 10px; }
.class-link { font-size: 13px; color: var(--green); overflow-wrap: anywhere; }
.teacher-panel .btn-row { margin-top: 4px; }

.debrief { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.debrief-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; align-content: start; }
.debrief-pick { all: unset; display: grid; gap: 8px; align-content: start; cursor: pointer; width: 100%; }
.debrief-pick:focus-visible { outline: 2px solid var(--green); outline-offset: 8px; border-radius: 6px; }
.debrief-item:has(.debrief-pick):hover { border-color: var(--border-strong); background: var(--surface-2); }
.debrief-head { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.debrief-n { font-family: var(--font-mono); color: var(--green); min-width: 2ch; }
.debrief-title { min-width: 0; }
.debrief-title strong { color: var(--white); }
.debrief-bars { display: grid; gap: 6px; }
.debrief-bars .bar-row { grid-template-columns: minmax(0, 1fr) 48px; }
.debrief-wrong { font-size: 13.5px; color: var(--gray); }
.debrief-wrong strong { color: var(--white); font-weight: 600; }

/* class big screen */
.live-main { min-width: 0; }
.live-code { font-size: clamp(30px, 3.4vw, 46px); font-weight: 600; letter-spacing: 0.16em; color: var(--white); }
.live-count { color: var(--gray); font-size: 16px; }
.live-screen .debrief { grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); }
.live-screen .debrief-title { font-size: 18px; }
.live-snippet { display: grid; gap: 18px; justify-items: stretch; }
.live-snippet > .btn { justify-self: start; }
.live-snippet h2 { font-size: clamp(24px, 2.6vw, 36px); }
.live-snippet .code { font-size: clamp(12px, 0.95vw, 15px); }

/* moderation */
.mod-controls { display: grid; gap: 14px; margin-bottom: 16px; }
.mod-fields { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .mod-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.mod-table td { vertical-align: top; }
.mod-table tr.is-hidden td { opacity: 0.6; }
.mod-table .pill { margin: 2px 4px 2px 0; display: inline-block; }

/* Tablets: six menu items fit with short labels */
@media (min-width: 761px) and (max-width: 1080px) {
  .nav-label { display: none; }
  .nav-short { display: inline; }
  .nav-link { padding: 8px 9px; gap: 6px; font-size: 14px; }
  .nav-link[data-view="about"] { display: none; }
}
.pill-flag { color: var(--white); border-color: var(--gray); }

/* ================= v0.9: opening scene (assets/js/intro.js) ================= */
html.intro-open { overflow: hidden; }
.intro {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; overflow: hidden;
  background: var(--navy); color: var(--text); cursor: default;
  clip-path: inset(0 0 0 0);
}
.intro-backdrop {
  position: absolute; inset: -6%; opacity: 0; transform: scale(1.06);
  background:
    radial-gradient(60% 50% at 78% 12%, rgba(0, 204, 106, 0.16), transparent 70%),
    radial-gradient(50% 45% at 12% 92%, rgba(141, 180, 255, 0.08), transparent 70%),
    linear-gradient(rgba(167, 176, 188, 0.05) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, rgba(167, 176, 188, 0.05) 1px, transparent 1px) 0 0 / 48px 48px;
  -webkit-mask-image: radial-gradient(75% 70% at 50% 50%, #000 40%, transparent 100%);
  mask-image: radial-gradient(75% 70% at 50% 50%, #000 40%, transparent 100%);
  transition: opacity 1.2s ease, transform 6s cubic-bezier(.2, .7, .2, 1);
}
.intro.is-on .intro-backdrop { opacity: 1; transform: scale(1); }
.intro-scene { position: relative; width: 100%; height: 100%; display: grid; place-items: center; padding: 72px 16px; }
.intro-corner {
  position: absolute; top: clamp(16px, 4vw, 32px); margin: 0;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.22em; color: var(--gray-dim);
  opacity: 0; transition: opacity 0.6s ease 0.2s;
}
.intro-label { left: clamp(16px, 4vw, 40px); }
.intro-status { right: clamp(16px, 4vw, 40px); color: var(--gray); text-align: right; }
.intro.is-on .intro-corner { opacity: 1; }
.intro.is-locked .intro-status { color: var(--white); }
.intro.is-resolved .intro-status { color: var(--green); }
@media (max-width: 560px) { .intro-label { display: none; } .intro-status { right: 50%; transform: translateX(50%); white-space: nowrap; } }

.intro-stage { display: grid; width: min(860px, 100%); }
.intro-stage > * { grid-area: 1 / 1; }

/* the code under review */
.intro-code {
  align-self: center; background: var(--black); border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  opacity: 0; transform: translateY(18px) scale(0.98);
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(.2, .8, .2, 1), filter 0.5s ease;
}
.intro.is-on .intro-code { opacity: 1; transform: none; }
.intro.is-resolved .intro-code { opacity: 0; transform: scale(0.9); filter: blur(8px); }
.intro-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 12px; color: var(--gray); }
.intro-dots { display: inline-flex; gap: 6px; }
.intro-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--surface-3); }
.intro-body { position: relative; padding: 12px 0; }
.intro-lines { list-style: none; margin: 0; padding: 0; counter-reset: none; }
.intro-line {
  position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: start;
  padding: 3px 18px 3px 0; font-family: var(--font-mono); font-size: clamp(11.5px, 0.9vw + 6px, 18px); line-height: 1.75;
  opacity: 0; transform: translateX(-10px); transition: opacity 0.35s ease, transform 0.45s cubic-bezier(.2, .8, .2, 1), background-color 0.3s ease;
}
.intro-line.is-in { opacity: 1; transform: none; }
.intro-ln { color: var(--gray-dim); text-align: right; padding-right: 16px; user-select: none; }
.intro-line code { font: inherit; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.intro.is-locked .intro-line:not(.is-flaw) { opacity: 0.38; }
.intro.is-locked .intro-line.is-flaw { background: var(--red-soft); box-shadow: inset 3px 0 0 var(--red); }
.intro.is-locked .intro-line.is-flaw .intro-ln { color: var(--red); }

/* the scan */
.intro-scan { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--green); box-shadow: 0 0 18px 2px rgba(0, 204, 106, 0.55); opacity: 0; pointer-events: none; }
.intro-scan::before { content: ''; position: absolute; left: 0; right: 0; bottom: 2px; height: 56px; background: linear-gradient(to bottom, transparent, rgba(0, 204, 106, 0.14)); }
.intro.is-scanning .intro-scan { animation: intro-scan 0.95s cubic-bezier(.45, 0, .2, 1) forwards; }
@keyframes intro-scan {
  0% { top: 0; opacity: 0; }
  10% { opacity: 1; }
  85% { opacity: 1; }
  100% { top: calc(100% - 2px); opacity: 0; }
}

/* the lock on the vulnerable line */
.intro-lock { position: absolute; inset: -5px 4px; pointer-events: none; }
.intro-lock i { position: absolute; width: 14px; height: 14px; border: 2px solid var(--white); opacity: 0; transform: scale(1.8); transition: opacity 0.25s ease, transform 0.45s cubic-bezier(.2, .9, .2, 1.2); }
.intro-lock i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; transform-origin: 300% 300%; }
.intro-lock i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; transform-origin: -200% 300%; }
.intro-lock i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; transform-origin: 300% -200%; }
.intro-lock i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; transform-origin: -200% -200%; }
.intro.is-locked .intro-lock i { opacity: 1; transform: scale(1); }
.intro.is-locked .intro-line.is-flaw { animation: intro-thud 0.5s ease 0.15s; }
@keyframes intro-thud { 30% { transform: scale(1.012); } 100% { transform: none; } }
.intro-tag {
  display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 16px; border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em; color: var(--white);
  opacity: 0; transform: translateY(6px); transition: opacity 0.3s ease 0.25s, transform 0.4s ease 0.25s;
}
.intro-tag-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.intro.is-locked .intro-tag { opacity: 1; transform: none; }

/* the brand */
.intro-brand { align-self: center; display: grid; justify-items: center; gap: 14px; text-align: center; pointer-events: none; }
.intro-mark-wrap { position: relative; width: clamp(76px, 15vw, 108px); aspect-ratio: 1; }
.intro-mark { display: block; width: 100%; height: 100%; overflow: visible; }
.intro-mark-box, .intro-brace, .intro-dot { transform-box: fill-box; transform-origin: center; opacity: 0; }
.intro-mark-box { transform: scale(0.6); transition: opacity 0.4s ease, transform 0.6s cubic-bezier(.2, .9, .2, 1.1); }
.intro-brace { transition: opacity 0.4s ease 0.15s, transform 0.7s cubic-bezier(.2, .9, .2, 1) 0.15s; }
.intro-brace-l { transform: translateX(-160%); }
.intro-brace-r { transform: translateX(160%); }
.intro-dot { transform: scale(0); transition: opacity 0.2s ease 0.55s, transform 0.45s cubic-bezier(.3, 1.6, .5, 1) 0.55s; }
.intro.is-resolved .intro-mark-box, .intro.is-resolved .intro-brace, .intro.is-resolved .intro-dot { opacity: 1; transform: none; }
.intro-ring { position: absolute; inset: 0; border-radius: 22%; border: 2px solid var(--green); opacity: 0; }
.intro.is-resolved .intro-ring { animation: intro-ring 1.1s cubic-bezier(.2, .7, .2, 1) 0.6s; }
@keyframes intro-ring { 0% { opacity: 0.85; transform: scale(1); } 100% { opacity: 0; transform: scale(2.1); } }
.intro-title { margin: 6px 0 0; font-weight: 700; font-size: clamp(40px, 10vw, 88px); line-height: 1; letter-spacing: -0.03em; color: var(--white); }
.intro-word { display: inline-block; margin: 0 0.12em; opacity: 0; transform: translateY(28px); filter: blur(8px); transition: opacity 0.5s ease, transform 0.7s cubic-bezier(.2, .8, .2, 1), filter 0.6s ease; transition-delay: calc(var(--i) * 110ms); }
.intro.is-titled .intro-word { opacity: 1; transform: none; filter: none; }
.intro-tagline { margin: 4px 0 0; font-family: var(--font-mono); font-size: clamp(11px, 2.4vw, 14px); letter-spacing: 0.4em; color: var(--green); }
.intro-tword { display: inline-block; margin: 0 0.3em; opacity: 0; transform: translateY(8px); transition: opacity 0.4s ease, transform 0.5s ease; transition-delay: calc(var(--i) * 190ms); }
.intro.is-taglined .intro-tword { opacity: 1; transform: none; }

/* progress, skip and the exit */
.intro-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(167, 176, 188, 0.08); }
.intro-progress span { display: block; height: 100%; width: 0; background: var(--green); }
.intro.is-on .intro-progress span { animation: intro-progress 5.5s linear forwards; }
@keyframes intro-progress { to { width: 100%; } }
.intro-skip {
  position: absolute; right: clamp(16px, 4vw, 40px); bottom: clamp(18px, 4vw, 34px); display: inline-flex; align-items: center; gap: 10px;
  min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: rgba(14, 29, 51, 0.7);
  color: var(--gray); font: 500 14px var(--font-sans); cursor: pointer; transition: color 0.2s ease, border-color 0.2s ease;
}
.intro-skip:hover, .intro-skip:focus-visible { color: var(--white); border-color: var(--gray); }
.intro-skip:focus-visible { outline: 2px solid var(--green-line); outline-offset: 3px; }
.intro-skip kbd { font: 500 11px var(--font-mono); padding: 2px 6px; border: 1px solid var(--border-strong); border-radius: 4px; color: var(--gray-dim); }
@media (pointer: coarse) { .intro-skip kbd { display: none; } }
.intro.is-leaving { clip-path: inset(0 0 100% 0); transition: clip-path 0.65s cubic-bezier(.7, 0, .2, 1); }
.intro.is-leaving .intro-brand { transform: translateY(-40px); opacity: 0; transition: transform 0.6s cubic-bezier(.7, 0, .2, 1), opacity 0.5s ease; }
.intro.is-skipped { opacity: 0; transition: opacity 0.38s ease; }
.footer-links .footer-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--gray); cursor: pointer; }
.footer-links .footer-btn:hover { color: var(--white); text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .footer-links #replay-intro { display: none; } }

/* ================= v1.0: 3D (assets/js/world.js, assets/js/tilt.js) ================= */
#world {
  position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; pointer-events: none;
  opacity: 0; transition: opacity 1.1s ease;
}
#world.is-ready { opacity: var(--world-opacity, 1); }
#world.is-ready.is-hidden { opacity: 0; transition-duration: 0.4s; }
html.has-world body { background: transparent; }
html.has-world { background: var(--navy); }
html.has-world .topbar, html.has-world main, html.has-world .footer { position: relative; z-index: 1; }
html.has-world .topbar { position: sticky; z-index: 5; }
html.has-world .card, html.has-world .panel, html.has-world .stat, html.has-world .level-card { background: rgba(14, 29, 51, 0.88); }
html.has-world .podium-step { background: rgba(18, 37, 64, 0.86); }
html.has-world .footer { background: rgba(5, 8, 13, 0.82); }
html.has-world .hero-slides { background: linear-gradient(160deg, rgba(14, 29, 51, 0.72), rgba(10, 22, 40, 0.42)); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
html.has-world body[data-view="round"] .card, html.has-world body[data-view="round"] .panel,
html.has-world body[data-view="exam"] .card, html.has-world body[data-view="exam"] .panel { background: var(--surface); }

/* Cards that lean toward the pointer (tilt.js sets --rx, --ry, --gx, --gy). */
.tilt-on, .tilt-on.lift:hover { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0); transform-style: preserve-3d; transition: transform 0.12s ease-out; will-change: transform; }
.tilt-on.tilt-out { transition: transform 0.5s cubic-bezier(.2, .8, .2, 1); }
.tilt-on::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(420px circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, 0.07), transparent 45%);
  opacity: var(--glare, 0); transition: opacity 0.3s ease;
}
.level-card, .stat, .podium-step, .cert-preview, .share-preview, .mini-card { position: relative; }
.level-card.tilt-on > * { transform: translateZ(18px); }

/* The intro in 3D: the code card swings in, flattens to be read, then falls away into depth. */
.intro-stage { perspective: 1400px; }
.intro-code { transform: translateY(30px) rotateX(24deg) rotateY(-16deg) scale(0.94); transform-origin: 50% 60%; }
.intro.is-on .intro-code { transform: rotateX(9deg) rotateY(-7deg); transition: opacity 0.5s ease, transform 1.4s cubic-bezier(.2, .8, .2, 1), filter 0.5s ease; }
.intro.is-locked .intro-code { transform: rotateX(0) rotateY(0) scale(1.02); transition: opacity 0.5s ease, transform 0.6s cubic-bezier(.2, .9, .2, 1), filter 0.5s ease; }
.intro.is-resolved .intro-code { transform: translateZ(-420px) rotateX(28deg); }
.intro-mark-wrap { transform: rotateY(-80deg); transition: transform 0.9s cubic-bezier(.2, .9, .2, 1); transform-style: preserve-3d; }
.intro.is-resolved .intro-mark-wrap { transform: rotateY(0); }
.intro-title { perspective: 800px; }
.intro-word { transform: translateY(28px) rotateX(-70deg); transform-origin: 50% 100%; }

/* Title stage (home): the name and the way in, with the 3D mark beside it. */
.title-stage {
  position: relative; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); align-items: center; gap: 24px;
  min-height: clamp(420px, calc(100svh - 150px), 640px); padding: 16px 0 40px;
}
.stage-title { font-size: clamp(52px, 8.5vw, 108px); font-weight: 700; letter-spacing: -0.035em; line-height: 0.98; max-width: none; }
.stage-copy .lead { max-width: 46ch; }
.stage-copy .btn-row { margin-top: 28px; }
.btn-lg { min-height: 52px; padding: 12px 22px; font-size: 16px; }
.stage-scroll { margin-top: 44px; display: flex; align-items: center; gap: 12px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gray); }
.stage-scroll-line { width: 44px; height: 1px; background: linear-gradient(90deg, var(--green), transparent); transform-origin: left; }
.stage-mark { display: grid; place-items: center; }
.stage-mark img { width: clamp(150px, 22vw, 260px); height: auto; filter: drop-shadow(0 0 60px rgba(0, 204, 106, 0.25)); }
html.has-world .stage-mark { visibility: hidden; }
@media (prefers-reduced-motion: no-preference) {
  .stage-scroll-line { animation: scroll-cue 2.4s ease-in-out infinite; }
  .stage-mark img { animation: mark-float 6s ease-in-out infinite; }
}
@keyframes scroll-cue { 0%, 100% { transform: scaleX(0.3); opacity: 0.4; } 50% { transform: scaleX(1); opacity: 1; } }
@keyframes mark-float { 0%, 100% { transform: perspective(600px) translateY(0) rotateY(-12deg); } 50% { transform: perspective(600px) translateY(-10px) rotateY(12deg); } }
@media (max-width: 760px) {
  .title-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(180px, 1fr) auto; min-height: calc(100svh - 150px); gap: 8px; padding-top: 8px; }
  .stage-mark { order: -1; }
  .stage-scroll { display: none; }
  .stage-copy .btn-row .btn { flex: 1 1 auto; }
}
.stage-copy { position: relative; isolation: isolate; }
html.has-world .stage-copy::before {
  content: ''; position: absolute; z-index: -1; inset: -12% -18% -12% -40%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(10, 22, 40, 0.9), rgba(10, 22, 40, 0.6) 60%, transparent);
}

/* ================= v0.11: mobile and config snippets, practice by kind ================= */
.badge-kind { display: inline-flex; align-items: center; gap: 6px; color: var(--green); border-color: var(--green-line); }
.badge-kind .icon { width: 14px; height: 14px; }
.panel-file { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 12.5px; }
.panel-bar { min-width: 0; }
/* Mobile code sits in a phone-style frame: a thicker bezel, rounder corners and a notch. */
.code-panel.kind-mobile { position: relative; border: 6px solid #1A2B44; border-radius: 26px; box-shadow: 0 0 0 1px var(--border-strong), 0 24px 60px -24px rgba(0, 0, 0, 0.6); }
.code-panel.kind-mobile .panel-bar { padding-top: 18px; }
.phone-notch { position: absolute; top: 6px; left: 50%; width: 76px; height: 7px; margin-left: -38px; border-radius: 9px; background: #1A2B44; z-index: 1; }
/* Config files get a dashed file-tab edge. */
.code-panel.kind-config .panel-bar { border-bottom-style: dashed; }
.level-kinds { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; color: var(--gray); margin: 0 0 14px; }
.practice-section { margin: 8px 0 40px; }
.practice-section .segmented { margin: 4px 0 16px; }
.practice-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .practice-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.practice-card { display: grid; gap: 12px; align-content: start; padding: 20px; }
.practice-card .btn { justify-self: start; }
.practice-head { display: flex; align-items: center; gap: 10px; }
.practice-head h3 { margin: 0; font-size: 19px; color: var(--white); }
.bars-subhead { font-size: 15px; color: var(--white); margin: 22px 0 12px; }
@media (max-width: 520px) { .code-panel .panel-bar-hint { display: none; } }

/* v0.12: practise a flaw from focus areas and Progress */
.focus-list li .focus-practise { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.focus-list li > div { flex: 1; }
.focus-actions { margin-top: 14px; }
.weak-list .btn-small { margin-top: 8px; }

/* v0.12 accessibility: code lines are at least 24px tall to tap */
.code .line { min-height: 24px; align-items: baseline; padding-block: max(0px, calc((24px - 1.7em) / 2)); }   /* number beside the first row of a wrapped line */
.code:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }

/* v0.13: practice every day, with the clock on or off */
.practice-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; margin: 4px 0 16px; }
.practice-section .practice-controls .segmented { margin: 0; }
.clock-setting { display: inline-flex; align-items: center; gap: 10px; }
.clock-label { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gray); }
.weak-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-top: 12px; }
.weak-foot .save-hint { margin: 0; flex: 1 1 260px; }
.timer.is-off { display: flex; align-items: center; }
.timer-off { font-family: var(--font-mono); font-size: 13px; color: var(--gray); }

/* v0.13: the certificate exam */
.exam-intro, .exam-result, .exam-wait { max-width: 720px; margin: 24px auto; }
.exam-wait { text-align: center; padding: 40px 24px; }
.exam-rules { list-style: none; padding: 0; margin: 16px 0 22px; display: grid; gap: 10px; }
.exam-rules li { display: flex; gap: 10px; align-items: flex-start; color: var(--text); }
.exam-rules .icon { flex: 0 0 auto; margin-top: 3px; }
.exam-result h1 { display: flex; align-items: center; gap: 10px; }
.exam-result.is-pass { border-color: var(--green); }
.exam-levels { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.exam-level { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.exam-level p { margin: 2px 0 0; }
.exam-level .cert-check { margin-left: auto; }

/* v0.14: why not your answer, and "Which fix works?" */
.why-not { margin: 12px 0 4px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; line-height: 1.55; color: var(--text); }
.why-not p { margin: 6px 0 0; }
.why-not .cat-label { margin: 0; }
.cat-guide { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 14px; }
.fix-question { margin-top: 4px; }
.fix-question h3 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fixq-tag { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gray); border: 1px solid var(--border-strong); border-radius: 99px; padding: 2px 8px; font-weight: 400; }
.fixq-options { display: grid; gap: 8px; margin: 10px 0; }
.fixq-option { display: flex; align-items: flex-start; gap: 10px; text-align: left; width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 14.5px; line-height: 1.5; cursor: pointer; }
.fixq-option:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-3); }
.fixq-option:disabled { cursor: default; opacity: 0.75; }
.fixq-option .key { flex: 0 0 auto; margin-top: 2px; }
.fixq-option.is-right { opacity: 1; border-color: var(--green); background: var(--green-soft); color: var(--white); }
.fixq-option.is-wrong { opacity: 1; border-color: var(--red-line); background: var(--red-soft); }
.fixq-why { margin: 0 0 6px; font-size: 14px; color: var(--text); }
.fixq-why:empty { display: none; }
.fixq-skip { font-size: 13px; }
.fix-question.is-done .fixq-skip { display: none; }

/* v0.14: the guided round's coach */
.coach { margin: 0 0 16px; padding: 14px 16px; border-color: var(--green); background: linear-gradient(0deg, var(--green-soft), var(--green-soft)), var(--surface); display: grid; gap: 6px; }
.coach-step { font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--green); margin: 0; }
.coach-text { margin: 0; color: var(--white); font-size: 15px; line-height: 1.55; }
.coach-extra { margin: 0; color: var(--text); font-size: 14px; }
.coach .btn, .coach .btn-row { justify-self: start; margin-top: 4px; }
.coach-target { outline: 2px solid var(--green); outline-offset: 4px; border-radius: 12px; }
@media (prefers-reduced-motion: no-preference) { .coach-target { animation: coach-pulse 1.6s ease-in-out 2; } }
@keyframes coach-pulse { 50% { outline-color: transparent; } }

/* v0.14: the flaw guide */
.guide-tools { margin: 4px 0 18px; }
/* Every guide column is capped at the screen width (minmax(0, 1fr)), so a long
   code line scrolls inside its own box instead of pushing the whole page wider. */
.guide-list { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.guide-card { padding: 20px; scroll-margin-top: 90px; min-width: 0; }
.guide-card.is-target { border-color: var(--green); }
.guide-card:focus { outline: none; }
.guide-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; align-items: flex-start; }
.guide-head h2 { margin: 0 0 4px; font-size: 21px; }
.guide-kinds { display: flex; gap: 6px; flex-wrap: wrap; }
.guide-summary { color: var(--text); margin: 10px 0 14px; }
.guide-cols { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.guide-cols > * { min-width: 0; }
@media (min-width: 760px) { .guide-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.guide-cols h3 { font-size: 14px; margin: 0 0 6px; color: var(--white); }
.guide-cols ul { margin: 0; padding-left: 18px; color: var(--text); display: grid; gap: 6px; font-size: 14.5px; }
.guide-example { display: grid; gap: 10px; margin: 16px 0 12px; grid-template-columns: minmax(0, 1fr); }
.guide-example > * { min-width: 0; }
@media (min-width: 760px) { .guide-example { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.guide-ex-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray); margin: 0 0 6px; }
.guide-code { border: 1px solid var(--border); border-radius: 10px; background: var(--black); padding: 8px 12px; max-width: 100%; min-width: 0; }
.guide-code .line { min-height: 0; }
.guide-code.is-bad { border-color: var(--red-line); }
.guide-code.is-good { border-color: rgba(0, 204, 106, 0.45); }
.guide-decoys { margin: 8px 0 12px; font-size: 14px; color: var(--text); }
.guide-decoys summary { cursor: pointer; color: var(--white); font-weight: 600; }
.guide-decoys ul { padding-left: 18px; display: grid; gap: 8px; margin-top: 10px; }
/* Practise buttons wrap their label on a phone instead of running past the card. */
.guide-card .btn-row { display: flex; flex-wrap: wrap; }
.guide-card .btn { white-space: normal; max-width: 100%; text-align: left; }
.focus-actions-row { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.focus-guide { font-size: 13px; }
.weak-actions { margin-top: 8px; align-items: center; }

/* v0.16: the "your stack" slide */
.mini-stack { display: flex; flex-wrap: wrap; gap: 8px; align-content: center; }
.mini-stack .badge { font-family: var(--font-mono); animation: fade-in .4s ease both; animation-delay: calc(var(--i, 0) * 60ms); }
@media (prefers-reduced-motion: reduce) { .mini-stack .badge { animation: none; } }

/* v0.17: teams */
.team-pack { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.team-pack p { margin: 0; flex: 1 1 280px; }
.teams-cta { margin: 8px 0 28px; }
.teams-features { display: grid; gap: 14px; grid-template-columns: 1fr; margin-bottom: 20px; }
@media (min-width: 640px) { .teams-features { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 980px) { .teams-features { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.teams-feature { padding: 20px; }
.teams-feature h2 { font-size: 18px; margin: 10px 0 6px; }
.teams-feature p { color: var(--gray); margin: 0; }
.teams-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--green-soft); color: var(--green); }
.teams-steps ol { display: grid; gap: 10px; padding-left: 22px; margin: 0; }
.teams-steps li strong, .teams-steps li span { display: block; }
.teams-steps li span { color: var(--gray); }
.team-tools { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin-bottom: 18px; }
.team-picker { min-width: 220px; }
.team-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px; }
.team-head h2 { margin: 0 0 4px; }
.team-head .btn-row { margin: 0; }
.team-packs { margin: 6px 0 0; color: var(--text); }
.team-link { flex-basis: 100%; padding: 16px; margin-top: 4px; display: grid; gap: 10px; }
.team-link p { margin: 0; }
.team-link-input { width: 100%; font-family: var(--font-mono); font-size: 13px; }
.team-section { margin-top: 28px; }
.team-section h2 { margin-bottom: 4px; }
.team-section > .muted { margin-top: 0; }
.team-table td a { color: var(--text); }
.team-bar-col { min-width: 150px; }
.team-bar { display: grid; grid-template-columns: 1fr 44px; gap: 10px; align-items: center; grid-template-areas: "bar value"; }
.print-only { display: none; }

@media print {
  :root { --text: #111; --white: #000; --gray: #444; --gray-dim: #555; --border: #ccc; --surface: #fff; --surface-2: #fff; --surface-3: #e6e6e6; --green: #008a47; }
  body { background: #fff !important; color: #111; }
  .topbar, .footer, .no-print, .skip-link, #world, .world-3d, .toast { display: none !important; }
  .print-only { display: block; }
  .card, .panel { background: #fff !important; box-shadow: none !important; border: 1px solid #ccc; break-inside: avoid; }
  .team-head .btn-row, .team-head h2, .page-head { display: none; }
  .rise-in, .fade-in-row { animation: none !important; opacity: 1 !important; transform: none !important; }
  .table-scroll { overflow: visible; }
  .board-table th, .board-table td { color: #111; }
  .hide-sm { display: table-cell !important; }
  a { color: #111; text-decoration: none; }
}
