/* Packet Rush — layered on top of base.css, which supplies the top bar,
   buttons, dialogs and the overlay. The colours are re-declared here as five
   themes (body.rush-<name>) so the page chrome follows the same palette the
   canvas is drawn with in js/main.js. */

body.rush-bright {
  --bg: #1b2534; --panel: #222f42; --panel-2: #2b3a51; --line: #3d5171;
  --text: #eaf1fb; --muted: #b3c4dc;
  --cyan: #45d0e0; --green: #4ade80; --amber: #f5a524; --red: #f87171;
  --glow-1: #2b3c55; --glow-2: #24404f; --bar: rgba(9, 14, 22, .75); --stage: #1a2434;
  --hover: #1b2838; --primary: #12463c; --primary-hover: #15594b; --primary-text: #d9ffe9;
  --overlay: rgba(12, 18, 28, .86); --backdrop: rgba(4, 7, 12, .72); --logo: linear-gradient(140deg, #1b3a4a, #123047);
  color-scheme: dark;
}
body.rush-dark {
  --bg: #070b12; --panel: #101823; --panel-2: #16202e; --line: #24334a;
  --text: #dbe6f3; --muted: #8ea3bd;
  --cyan: #45d0e0; --green: #4ade80; --amber: #f5a524; --red: #f87171;
  --glow-1: #142033; --glow-2: #10202b; --bar: rgba(4, 7, 12, .8); --stage: #0a0f18;
  --hover: #131d2b; --primary: #0f3a31; --primary-hover: #124a3e; --primary-text: #d9ffe9;
  --overlay: rgba(5, 8, 13, .88); --backdrop: rgba(0, 0, 0, .75); --logo: linear-gradient(140deg, #13303d, #0c2233);
  color-scheme: dark;
}
/* soft: pastel lavender, mint and peach on a pale ground */
body.rush-soft {
  --bg: #f3f0fa; --panel: #ffffff; --panel-2: #f1ecf8; --line: #dcd3ec;
  --text: #3b3552; --muted: #756d8f;
  --cyan: #6f8fe0; --green: #3fa37b; --amber: #d2803f; --red: #d0677a;
  --glow-1: #e6ecff; --glow-2: #fde6ee; --bar: rgba(255, 255, 255, .8); --stage: #ffffff;
  --hover: #ebe6fa; --primary: #dcf3e9; --primary-hover: #cbeedf; --primary-text: #1f5a42;
  --overlay: rgba(250, 248, 255, .9); --backdrop: rgba(60, 50, 90, .35); --logo: linear-gradient(140deg, #e3e9ff, #fbe3ee);
  color-scheme: light;
}
/* energy: deep teal with lime and hot orange */
body.rush-energy {
  --bg: #0c1c28; --panel: #122a3a; --panel-2: #183850; --line: #2a5878;
  --text: #f2faff; --muted: #a6c6dc;
  --cyan: #22d3ee; --green: #a3e635; --amber: #ff8f2e; --red: #ff4d6d;
  --glow-1: #10405a; --glow-2: #3b2a10; --bar: rgba(6, 20, 30, .8); --stage: #0f2433;
  --hover: #163247; --primary: #3a2508; --primary-hover: #4d3109; --primary-text: #ffe2c2;
  --overlay: rgba(8, 22, 32, .88); --backdrop: rgba(2, 10, 16, .75); --logo: linear-gradient(140deg, #ff8f2e, #22d3ee);
  color-scheme: dark;
}
/* excited: neon party, magenta and electric yellow on violet */
body.rush-excited {
  --bg: #170a2b; --panel: #221040; --panel-2: #2e1656; --line: #5a2a8e;
  --text: #fff0fb; --muted: #d4b4ea;
  --cyan: #ff4fd8; --green: #3dfcb4; --amber: #ffe14d; --red: #ff5470;
  --glow-1: #4a1570; --glow-2: #6b1450; --bar: rgba(20, 6, 38, .8); --stage: #1d0c36;
  --hover: #3a1a66; --primary: #4a1150; --primary-hover: #5e1666; --primary-text: #ffe0fa;
  --overlay: rgba(22, 8, 42, .88); --backdrop: rgba(10, 2, 22, .75); --logo: linear-gradient(140deg, #ff4fd8, #ffe14d);
  color-scheme: dark;
}

body[class*="rush-"] {
  background:
    radial-gradient(1100px 600px at 20% -10%, var(--glow-1) 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, var(--glow-2) 0%, transparent 55%),
    var(--bg);
  transition: background-color .3s ease, color .3s ease;
}
body[class*="rush-"] .topbar { background: var(--bar); }
body[class*="rush-"] .logo { background: var(--logo); }
body[class*="rush-"] .stage { background: var(--stage); }
body[class*="rush-"] .overlay { background: var(--overlay); }
body[class*="rush-"] .btn:hover { background: var(--hover); }
body[class*="rush-"] .btn-primary { background: var(--primary); color: var(--primary-text); }
body[class*="rush-"] .btn-primary:hover { background: var(--primary-hover); }
body[class*="rush-"] dialog::backdrop { background: var(--backdrop); }
body.rush-soft .stage { box-shadow: 0 18px 50px rgba(90, 70, 140, .18); }
body.rush-excited .logo { color: #170a2b; }

.theme-pick {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.theme-pick:hover, .theme-pick:focus-visible { border-color: var(--cyan); outline: none; }
.theme-pick option { background: var(--panel); color: var(--text); }

.rush {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px 16px;
  display: grid;
  gap: 12px;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
}
.hud-name { font-size: 16px; margin-right: auto; }
.hud-stat { color: var(--muted); white-space: nowrap; }
.hud-stat b { color: var(--text); font-variant-numeric: tabular-nums; margin-left: 4px; }
#hud-in { color: var(--green); }
#hud-lost { color: var(--red); }
#hud-resent { color: #93c5fd; }
#hud-server.down { color: var(--red); }
.hud-stat[hidden] { display: none; }
.pill {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--cyan);
}

.rush-stage { position: relative; padding: 10px; border-radius: var(--radius); }
.viewport { position: relative; }
.viewport .layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 6px;
}
.viewport .fx { pointer-events: none; }
#world3d { cursor: crosshair; touch-action: none; }
#world3d.orbiting { cursor: grabbing; }
body.view-3d #world { visibility: hidden; }
#world {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  border-radius: 6px;
  image-rendering: pixelated;
  cursor: crosshair;
  touch-action: manipulation;
}

.ov-note {
  text-align: left;
  max-width: 560px;
  margin: 0 auto 14px;
  padding: 10px 14px;
  border-left: 3px solid var(--cyan);
  background: color-mix(in srgb, var(--cyan) 10%, transparent);
  border-radius: 4px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}
.ov-note:empty { display: none; }
.ov-note h4 { margin: 0 0 4px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--cyan); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: stretch;
}
.skills { display: flex; flex-wrap: wrap; gap: 8px; }
.skill {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 78px;
  padding: 6px 4px 5px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.skill canvas { width: 30px; height: 30px; image-rendering: pixelated; }
.skill .count {
  position: absolute; top: 3px; right: 6px;
  font-weight: 700; font-size: 13px; color: var(--amber);
  font-variant-numeric: tabular-nums;
}
.skill kbd { position: absolute; top: 3px; left: 5px; font-size: 10px; }
.skill:hover { border-color: var(--cyan); }
.skill.selected { border-color: var(--green); background: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 30%, transparent); }
.skill.empty { opacity: .38; }
.skill.empty .count { color: var(--muted); }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ctl[aria-pressed="true"] { border-color: var(--amber); color: var(--amber); }
.rate-box { display: inline-flex; align-items: center; gap: 4px; }
.rate-box[hidden] { display: none; }
.rate-box .ctl { min-width: 34px; font-size: 16px; font-weight: 700; padding-left: 8px; padding-right: 8px; }
.rate-read { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.1; min-width: 44px; }
.rate-read b { display: block; color: var(--amber); font-size: 14px; font-variant-numeric: tabular-nums; }
.nuke:hover { border-color: var(--red); color: var(--red); }
.nuke.armed { border-color: var(--red); background: color-mix(in srgb, var(--red) 22%, var(--panel)); color: var(--text); }

.skill-note {
  margin: 0;
  min-height: 1.5em;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.skill-note b { color: var(--text); }

.ov-osi { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: -4px auto 14px; max-width: 560px; }
.ov-osi:empty { display: none; }
.osi-chip {
  font: inherit; font-size: 12px; cursor: pointer;
  color: var(--text);
  background: color-mix(in srgb, var(--layer) 22%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--layer) 70%, transparent);
  border-radius: 999px;
  padding: 3px 10px;
}
.osi-chip:hover, .osi-chip:focus-visible { background: color-mix(in srgb, var(--layer) 38%, var(--panel)); outline: none; }
.ov-osi-why { flex-basis: 100%; margin: 4px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

.osi-dialog { max-width: 720px; }
.osi-stack { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 6px; }
.osi-layer {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--layer) 14%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--layer) 45%, transparent);
  border-left: 4px solid var(--layer);
}
.osi-layer.focus { box-shadow: 0 0 0 2px var(--layer); }
.osi-num {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 8px;
  font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums;
  background: var(--layer); color: #0b1020;
}
.osi-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.osi-head strong { font-size: 15px; }
.osi-pdu { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.osi-job { margin: 3px 0 2px; font-size: 13.5px; color: var(--text); line-height: 1.45; }
.osi-eg { font-size: 12px; color: var(--muted); font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }
.osi-levels { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 5px; }
.osi-levels span { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.osi-extra { display: grid; gap: 8px; font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.osi-extra p { margin: 0; }
.osi-extra b { color: var(--text); }
.osi-h3 { margin: 18px 0 8px; font-size: 16px; }
.tcpip-wrap { overflow-x: auto; margin-bottom: 10px; }
.tcpip-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tcpip-table th, .tcpip-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tcpip-table th { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.tcpip-table td:first-child { font-weight: 600; color: var(--text); white-space: nowrap; }
.tcpip-table td { color: var(--muted); }
.tcpip-table .osi-dots { display: flex; gap: 3px; }
.tcpip-table .osi-dots span {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px;
  font-size: 11px; font-weight: 700; color: #0b1020; background: var(--layer);
}
.osi-source { font-size: 13px; margin-top: 14px; color: var(--muted); }
.osi-source ul { margin: 4px 0 0; padding-left: 18px; }
.osi-source a { color: var(--cyan); word-break: break-word; }

.help-skills { display: grid; gap: 8px; margin: 10px 0 16px; }
.help-skill { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; font-size: 13.5px; color: var(--muted); }
.help-skill canvas { width: 30px; height: 30px; image-rendering: pixelated; }
.help-skill b { color: var(--text); }

.level-card .lv-best { font-size: 12px; color: var(--muted); }
.level-card .lv-stars, .ov-stars { color: var(--amber); letter-spacing: 2px; }
.level-card .lv-stars { display: block; font-size: 14px; margin-top: 2px; }
.level-card .lv-stars .off, .ov-stars .off { color: var(--line); }
.overlay-card .ov-stars { font-size: 30px; margin: -4px 0 6px; line-height: 1; color: var(--amber); }
.ov-stars:empty { display: none; }
.ov-stars small { display: block; font-size: 13px; letter-spacing: 0; color: var(--muted); margin-top: 6px; }
.daily {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; align-items: center;
  margin: 12px 0 4px; padding: 12px 14px; border-radius: 10px;
  background: color-mix(in srgb, var(--amber) 12%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--amber) 55%, transparent);
}
.daily:empty { display: none; }
.daily h3 { margin: 0; font-size: 14px; color: var(--amber); }
.daily p { margin: 2px 0 0; font-size: 13px; color: var(--text); }
.daily .streak { font-size: 12px; color: var(--muted); }
.daily.done { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--panel-2)); }
.daily.done h3 { color: var(--green); }
.level-card.locked { opacity: .45; cursor: not-allowed; }

@media (max-width: 640px) {
  .skill { width: 64px; font-size: 11px; }
  .hud { font-size: 13px; gap: 6px 12px; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------ phones -- */
/* Touch: no tap flash, no text selection when tapping fast, bigger targets,
   and no keyboard hints nobody can press. */
.skill, .ctl, .theme-pick, .osi-chip, .viewport { -webkit-tap-highlight-color: transparent; }
.toolbar, .hud, .viewport { -webkit-user-select: none; user-select: none; }
@media (pointer: coarse) {
  kbd { display: none; }
  .skill { min-height: 56px; }
  .ctl, .theme-pick, .topbar .btn { min-height: 40px; }
}

.rotate-hint { display: none; margin: 0; font-size: 13px; color: var(--muted); text-align: center; }
#btn-full[hidden] { display: none; }

/* safe areas on notched phones */
.topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.rush { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }

/* On small screens a level card needs the whole screen, not the board's
   190 px, so the overlay becomes a full-screen sheet. */
@media (max-width: 700px), (max-height: 520px) {
  .overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .overlay-card { max-width: 640px; padding: 16px; }
  .overlay-card h2 { font-size: 21px; }
  .overlay-buttons .btn { min-width: 120px; min-height: 44px; }
}

/* Portrait phone: compact header, skills on a tidy grid, a nudge to rotate. */
@media (max-width: 600px) {
  .topbar { gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .topbar .brand p { display: none; }
  .topbar h1 { font-size: 18px; }
  .logo { width: 34px; height: 34px; font-size: 17px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn, .theme-pick { font-size: 13px; padding: 7px 10px; }
  .rush { gap: 10px; }
  .hud { padding: 8px 12px; gap: 4px 12px; font-size: 12.5px; }
  .hud-name { flex-basis: 100%; order: -1; margin: 0; font-size: 15px; }
  .rush-stage { padding: 6px; }
  .skills { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; gap: 6px; }
  .skill { width: auto; padding: 5px 2px; font-size: 11px; }
  .controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; gap: 6px; }
  .ctl { padding: 8px 6px; font-size: 13px; }
  .skill-note { font-size: 13px; }
  .foot { font-size: 11px; }
}
@media (max-width: 600px) and (orientation: portrait) and (pointer: coarse) {
  .rotate-hint { display: block; }
}

/* Landscape phone and full screen: the screen is short and wide, so the
   board takes the left and the toolbar becomes a column on the right. The
   board is sized from the height left over, --chrome being everything above
   and around it. */
@media (max-height: 520px) and (orientation: landscape) {
  .topbar { padding-top: 4px; padding-bottom: 4px; gap: 8px; }
  .topbar .brand p, .foot, .skill-note, .rotate-hint { display: none; }
  .topbar h1 { font-size: 15px; }
  .logo { width: 28px; height: 28px; font-size: 14px; border-radius: 8px; }
  .topbar-actions { gap: 5px; }
  .topbar-actions .btn, .theme-pick { font-size: 12px; padding: 4px 8px; min-height: 30px; }
  .rush { --chrome: 100px; gap: 6px; padding-top: 6px; }
  .hud { padding: 3px 10px; font-size: 12px; gap: 2px 12px; border-radius: 8px; }
  .hud-name { font-size: 13px; }
  .hud .pill { font-size: 10px; padding: 1px 8px; }
}
@media (orientation: landscape) {
  body.fullscreen .rush { --chrome: 60px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .rush { max-width: none; grid-template-columns: minmax(0, 1fr) clamp(190px, 26vw, 270px); align-items: start; }
}
@media (orientation: landscape) {
  body.fullscreen .rush { max-width: none; grid-template-columns: minmax(0, 1fr) clamp(200px, 22vw, 300px); align-items: start; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .rush > .hud { grid-column: 1 / -1; }
  .rush > .rush-stage { grid-column: 1; grid-row: 2; padding: 4px; }
  .rush > .toolbar { grid-column: 2; grid-row: 2; flex-direction: column; flex-wrap: nowrap; gap: 6px; }
  .rush .skills { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; gap: 4px; }
  .rush .skill { width: auto; min-height: 0; padding: 3px 2px 2px; font-size: 9.5px; }
  .rush .skill canvas { width: 22px; height: 22px; }
  .rush .skill .count { font-size: 11px; top: 1px; right: 4px; }
  .rush .controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 4px; }
  .rush .ctl { padding: 5px 6px; font-size: 12px; min-height: 30px; }
  .viewport, #world { width: min(100%, calc((100dvh - var(--chrome)) * 2)); margin: 0 auto; }
}
@media (orientation: landscape) {
  body.fullscreen .rush > .hud { grid-column: 1 / -1; }
  body.fullscreen .rush > .rush-stage { grid-column: 1; grid-row: 2; }
  body.fullscreen .rush > .toolbar { grid-column: 2; grid-row: 2; flex-direction: column; flex-wrap: nowrap; }
  body.fullscreen .skills { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  body.fullscreen .skill { width: auto; }
  body.fullscreen .controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  body.fullscreen .viewport, body.fullscreen #world { width: min(100%, calc((100dvh - var(--chrome, 60px)) * 2)); margin: 0 auto; }
}

/* Full screen — the browser's own, or on iPhones (which do not let pages go
   full screen) an immersive mode that simply gives the game the whole page.
   The menu bar goes; the Exit button in the toolbar brings it back. */
body.fullscreen { min-height: 100dvh; }
body.fullscreen .topbar, body.fullscreen .foot, body.fullscreen .rotate-hint, body.fullscreen .skill-note { display: none; }
body.fullscreen .rush { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
body.fullscreen #btn-full { border-color: var(--cyan); color: var(--cyan); }
body.fullscreen.pseudo-fs { overflow: hidden; }
body.fullscreen .rush { min-height: 100dvh; align-content: center; }

/* Full-screen toggle at the end of the status bar, always in reach. */
.hud-full {
  display: grid; place-items: center;
  width: 34px; height: 30px; margin: -4px -8px -4px 0; padding: 0;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hud-full:hover, .hud-full:focus-visible { border-color: var(--cyan); color: var(--cyan); outline: none; }
.hud-full svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.hud-full .fs-exit, body.fullscreen .hud-full .fs-enter { display: none; }
body.fullscreen .hud-full .fs-exit { display: inline; }
body.fullscreen .hud-full { border-color: var(--cyan); color: var(--cyan); }
@media (pointer: coarse) { .hud-full { width: 40px; height: 36px; } }

/* Immersive fallback when the browser (or the page hosting the game) refuses
   real full screen: a fixed layer over the whole viewport. */
body.pseudo-fs .rush {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow-y: auto;
  background:
    radial-gradient(1100px 600px at 20% -10%, var(--glow-1) 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, var(--glow-2) 0%, transparent 55%),
    var(--bg);
}

.ov-quiz { max-width: 560px; margin: 0 auto 14px; text-align: left; }
.ov-quiz:empty { display: none; }
.ov-quiz h4 { margin: 0 0 6px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--amber); }
.ov-quiz p { margin: 0 0 8px; color: var(--text); font-size: 14px; }
.quiz-opts { display: grid; gap: 6px; }
.quiz-opts .btn { text-align: left; }
.quiz-opts .btn.right { border-color: var(--green); background: color-mix(in srgb, var(--green) 18%, var(--panel-2)); }
.quiz-opts .btn.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 18%, var(--panel-2)); }
.quiz-verdict { margin-top: 8px; font-size: 13px; color: var(--muted); }
.class-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 12px 0; }
.class-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.class-form input, .result-code {
  font: inherit; font-size: 14px; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.class-form input:focus, .result-code:focus { outline: none; border-color: var(--cyan); }
.class-summary { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.class-summary b { color: var(--text); }
.code-label { font-size: 13px; color: var(--muted); }
.result-code { width: 100%; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 12px; word-break: break-all; resize: vertical; margin-top: 4px; }
.class-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.copy-note { min-height: 1.3em; font-size: 13px; }
.level-tabs { display: flex; gap: 6px; margin: 12px 0 6px; }
.level-tab[aria-selected="true"] { border-color: var(--cyan); color: var(--cyan); }
.level-list.worlds { display: grid; grid-template-columns: 1fr; gap: 12px; }
.world { border-left: 4px solid var(--layer); padding: 6px 0 2px 10px; }
.world-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.world-head .num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px;
  background: var(--layer); color: #0b1020; font-weight: 700; font-size: 13px;
}
.world-head strong { font-size: 15px; }
.world-head .sub { font-size: 12px; color: var(--muted); }
.world-head .wstars { margin-left: auto; font-size: 12px; color: var(--amber); }
.world-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }

/* challenge pack: categories down, difficulties across */
.level-list.challenges { display: grid; grid-template-columns: 1fr; gap: 12px; }
.ch-intro { margin: 0; font-size: 13px; color: var(--muted); }
.ch-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-filter { font: inherit; font-size: 13px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.ch-filter[aria-pressed="true"] { border-color: var(--f, var(--cyan)); color: var(--f, var(--cyan)); background: color-mix(in srgb, var(--f, var(--cyan)) 14%, var(--panel-2)); }
.ch-row.filtered { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ch-cat h3 { margin: 0 0 6px; font-size: 15px; display: flex; gap: 8px; align-items: baseline; }
.ch-cat h3 .wstars { margin-left: auto; font-size: 12px; color: var(--amber); font-weight: 400; }
.ch-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ch-row .level-card { border-top: 3px solid var(--diff); min-height: 96px; }
.ch-row .diff { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--diff); }
@media (max-width: 600px) { .ch-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* level cards: badge, name, best and stars stacked */
.level-card { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 92px; }
.level-card strong { font-size: 14px; line-height: 1.25; }
