:root {
    --bg: #0a1018;
    --bg-2: #0f1722;
    --panel: #131e2b;
    --panel-2: #182534;
    --line: #22344a;
    --line-2: #2d4560;
    --text: #e4ecf3;
    --muted: #8a9bb0;
    --dim: #5e6f84;
    --accent: #22b8a8;
    --accent-2: #1a8f83;
    --accent-ink: #061b19;
    --ember: #ff8a2a;
    --ember-2: #c8631a;
    --ok: #3dd68c;
    --bad: #f0596a;
    --accent-text: var(--accent);   /* legible accent for text/borders on dark grounds (a dark accent sets this lighter) */
    --vault: var(--ember);          /* vault-code digit color */
    --display: "Chakra Petch", "Trebuchet MS", sans-serif;
    --body: "IBM Plex Sans", "Segoe UI", Helvetica, Arial, sans-serif;
    --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
    color-scheme: dark;
  }
  * { box-sizing: border-box; }
  html { background: var(--bg); }
  body {
    margin: 0; background: var(--bg); color: var(--text);
    font-family: var(--body); font-size: 15px; line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    background-image:
      radial-gradient(1200px 500px at 50% -200px, color-mix(in srgb, var(--accent-text) 12%, transparent), transparent 60%),
      radial-gradient(800px 400px at 100% 100%, rgba(255,138,42,0.06), transparent 60%);
    min-height: 100vh;
  }
  a { color: var(--accent-text); }
  button { font-family: inherit; font-size: inherit; cursor: pointer; }
  button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
  h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.1; text-wrap: balance; }
  .mono, pre.mono, code { font-family: var(--mono); }
  pre.mono {
    background: var(--bg); border: 1px solid var(--line); border-left: 3px solid var(--accent);
    padding: 14px 16px; border-radius: 4px; overflow-x: auto; font-size: 13.5px; line-height: 1.6;
    margin: 0 0 18px; color: #c9e6e2; white-space: pre;
  }
  blockquote {
    margin: 0 0 18px; padding: 14px 18px; border-left: 3px solid var(--ember);
    background: rgba(255,138,42,0.06); border-radius: 0 4px 4px 0; font-style: italic; color: #f3dfcb;
  }
  table.data { border-collapse: collapse; width: 100%; margin: 0 0 18px; font-family: var(--mono); font-size: 13px; }
  table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
  table.data th { color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }
  .wrap-x { overflow-x: auto; }

  .eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-text); }
  .label { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

  /* Header */
  header.top {
    border-bottom: 1px solid var(--line);
    padding: 22px clamp(16px, 4vw, 40px) 18px;
    display: grid; grid-template-columns: 1fr auto; gap: 18px 32px; align-items: end;
  }
  header.top h1 { font-size: clamp(30px, 5vw, 48px); font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
  header.top h1 .out { color: var(--ember); }
  .sub { color: var(--muted); margin-top: 6px; max-width: 60ch; }
  .status { display: flex; gap: 26px; flex-wrap: wrap; }
  .stat { display: grid; gap: 2px; }
  .stat .v { font-family: var(--display); font-size: 26px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1; }
  .stat .v.ember { color: var(--ember); }
  .stat .v.accent { color: var(--accent-text); }

  /* Layout */
  main {
    display: grid; grid-template-columns: 250px minmax(0, 1fr) 300px; gap: 20px;
    padding: 22px clamp(16px, 4vw, 40px) 60px; max-width: 1400px; margin: 0 auto;
  }
  @media (max-width: 1080px) { main { grid-template-columns: 220px minmax(0,1fr); } aside.board { grid-column: 1 / -1; } }
  @media (max-width: 720px) { main { grid-template-columns: 1fr; } nav.chapters { order: 0; } section.stage { order: 1; } aside.board { order: 2; } }

  /* Chapter nav */
  nav.chapters { display: grid; gap: 8px; align-content: start; }
  .chap {
    text-align: left; width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--text);
    padding: 12px 14px; border-radius: 4px; display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center;
    transition: border-color .15s, background .15s;
  }
  .chap:hover:not(:disabled) { border-color: var(--line-2); background: var(--panel-2); }
  .chap.active { border-color: var(--accent-text); background: var(--panel-2); box-shadow: inset 3px 0 0 var(--accent-text); }
  .chap:disabled { opacity: .5; cursor: not-allowed; }
  .chap .n { font-family: var(--display); font-size: 20px; font-weight: 700; color: var(--accent-text); }
  .chap.locked .n { color: var(--dim); }
  .chap .t { font-weight: 600; font-size: 14px; }
  .chap .d { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
  .chap .pips { display: flex; gap: 3px; flex-wrap: wrap; max-width: 44px; justify-content: flex-end; }
  .pip { width: 8px; height: 8px; border-radius: 1px; background: var(--line-2); }
  .pip.done { background: var(--ok); }
  .chap.complete { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); box-shadow: inset 3px 0 0 var(--ok); }
  .chap.complete .n { color: var(--ok); }
  .vault {
    margin-top: 10px; background: var(--bg); border: 1px dashed var(--line-2); border-radius: 4px; padding: 12px 14px;
  }
  .vault .code { font-family: var(--mono); font-size: 24px; letter-spacing: .35em; color: var(--vault); margin-top: 4px; }
  .vault .code span.blank { color: var(--dim); }

  /* Stage */
  section.stage { min-width: 0; }
  .card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: clamp(18px, 3vw, 30px); }
  .brief h2 { font-size: clamp(24px, 3.4vw, 34px); margin: 6px 0 10px; }
  .brief p { color: #c7d3df; max-width: 66ch; margin: 0 0 18px; }
  .plist { display: grid; gap: 8px; margin-top: 8px; }
  .prow {
    display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; text-align: left;
    background: var(--bg-2); border: 1px solid var(--line); color: var(--text); padding: 12px 14px; border-radius: 4px;
  }
  .prow:hover { border-color: var(--line-2); }
  .prow .k { font-family: var(--mono); color: var(--muted); font-size: 12px; }
  .prow .pts { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .prow.done .pts { color: var(--ok); }
  .prow.done .k { color: var(--ok); }

  .puzzle .crumb { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
  .puzzle h2 { font-size: clamp(22px, 3vw, 30px); margin: 0 0 14px; }
  .puzzle .prompt { max-width: 66ch; color: #d6dfe8; margin: 0 0 18px; }
  .opts { display: grid; gap: 8px; margin-bottom: 18px; }
  .opt {
    text-align: left; background: var(--bg-2); border: 1px solid var(--line); color: var(--text); padding: 12px 14px 12px 42px;
    border-radius: 4px; position: relative; line-height: 1.5;
  }
  .opt::before {
    content: ""; position: absolute; left: 14px; top: 15px; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid var(--line-2); background: transparent;
  }
  .opt.multi::before { border-radius: 2px; }
  .opt:hover { border-color: var(--line-2); }
  .opt.sel { border-color: var(--accent-text); background: color-mix(in srgb, var(--accent-text) 12%, transparent); }
  .opt.sel::before { background: var(--accent); border-color: var(--accent-text); box-shadow: inset 0 0 0 3px var(--bg-2); }
  .opt.multi.sel::before { box-shadow: none; }
  .opt .ordn { position: absolute; left: 10px; top: 11px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-family: var(--display); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
  .opt.ordered::before { display: none; }
  .opt.email { font-size: 14px; }
  .opt.email b { color: var(--muted); font-weight: 500; }
  .opt.email u { color: var(--ember); }
  .text-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
  input.ans {
    flex: 1 1 260px; background: var(--bg); border: 1px solid var(--line-2); color: var(--text); padding: 11px 14px;
    border-radius: 4px; font-family: var(--mono); font-size: 15px;
  }
  .actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
  .btn {
    background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text); padding: 10px 18px; border-radius: 4px; font-weight: 600;
  }
  .btn:hover { border-color: var(--accent-text); }
  .btn.primary { background: var(--accent); border-color: var(--accent-text); color: var(--accent-ink); }
  .btn.primary:hover { background: #2ed0be; }
  .btn.ghost { background: transparent; }
  .btn:disabled { opacity: .45; cursor: not-allowed; }
  .btn.sm { padding: 6px 12px; font-size: 13px; font-weight: 500; }
  .meta { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .hintbox { margin: 14px 0 0; padding: 12px 16px; background: rgba(255,138,42,0.08); border: 1px solid rgba(255,138,42,0.35); border-radius: 4px; color: #f6dcc3; }
  .fb { margin-top: 14px; padding: 12px 16px; border-radius: 4px; border: 1px solid; }
  .fb.bad { border-color: rgba(240,89,106,0.5); background: rgba(240,89,106,0.08); color: #ffd3d8; }
  .fb.ok { border-color: rgba(61,214,140,0.5); background: rgba(61,214,140,0.08); color: #d3f7e4; }
  .debrief { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 18px; }
  .debrief .label { color: var(--ok); }
  .debrief p { max-width: 66ch; color: #d6dfe8; margin: 8px 0 0; }
  .reward { margin-top: 18px; padding: 18px 20px; border: 1px solid var(--ember-2); background: rgba(255,138,42,0.07); border-radius: 6px; }
  .reward h3 { color: var(--ember); font-size: 18px; margin-bottom: 6px; }
  .reward p { margin: 0; color: #f3dfcb; max-width: 66ch; }
  .lockmsg { color: var(--muted); }

  /* Leaderboard */
  aside.board { display: grid; gap: 14px; align-content: start; min-width: 0; }
  .tabs { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
  .tabs button { flex: 1; background: var(--panel); color: var(--muted); border: 0; padding: 9px; font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
  .tabs button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent-text); }
  .rows { display: grid; gap: 4px; }
  .row {
    display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center;
    padding: 8px 10px; border-radius: 4px; background: var(--panel); border: 1px solid var(--line);
  }
  .row.me { border-color: var(--accent-text); }
  .row .rk { font-family: var(--display); font-weight: 700; color: var(--muted); font-size: 15px; }
  .row:nth-child(1) .rk { color: var(--ember); }
  .row:nth-child(2) .rk, .row:nth-child(3) .rk { color: var(--accent-text); }
  .row .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
  .row .nm small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
  .row .sc { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text); }
  .board .note { font-size: 12.5px; color: var(--muted); }
  .board .empty { color: var(--muted); font-size: 13.5px; padding: 12px; border: 1px dashed var(--line); border-radius: 4px; }
  .me-chip { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
  .me-chip b { display: block; }
  .me-chip small { color: var(--muted); }

  /* Register overlay */
  .overlay { position: fixed; inset: 0; background: rgba(4,8,12,0.82); display: grid; place-items: center; padding: 16px; z-index: 10; }
  .overlay[hidden] { display: none; }
  .modal { width: min(480px, 100%); background: var(--panel); border: 1px solid var(--line-2); border-radius: 6px; padding: 28px; }
  .modal h2 { font-size: 24px; margin: 6px 0 8px; }
  .modal p { color: var(--muted); margin: 0 0 18px; }
  .field { display: grid; gap: 6px; margin-bottom: 14px; }
  .field input, .field select { background: var(--bg); border: 1px solid var(--line-2); color: var(--text); padding: 10px 12px; border-radius: 4px; font-family: inherit; font-size: 15px; }
  .err { color: var(--bad); font-size: 13px; min-height: 18px; }

  footer { text-align: center; color: var(--dim); font-size: 12px; padding: 0 16px 30px; font-family: var(--mono); }
  @media (prefers-reduced-motion: no-preference) {
    .fb, .reward, .hintbox { animation: rise .25s ease-out; }
    @keyframes rise { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }
  }

/* ===== v2 additions ===== */
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 28px; width: auto; }
.topbar-right { display: flex; align-items: flex-end; gap: 22px; flex-wrap: wrap; }
.userchip { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.userchip b { color: var(--text); }
.btn.link { background: none; border: 0; color: var(--accent-text); padding: 0; font-weight: 500; }
.btn.link:hover { text-decoration: underline; }
.btn.danger { border-color: rgba(240,89,106,0.5); color: #ffd3d8; }
.btn.danger:hover { background: rgba(240,89,106,0.12); }

/* login / register */
.modal .devlink { margin-top: 12px; padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: 4px; font-size: 13px; color: var(--muted); }
.modal .devlink a { word-break: break-all; }
.sent { text-align: center; padding: 10px 0; }
.sent .big { font-size: 40px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-family: var(--mono); font-size: 11px; letter-spacing: .04em; border: 1px solid; vertical-align: middle; }
.badge.first { color: var(--ember); border-color: var(--ember-2); background: rgba(255,138,42,0.1); }
.badge.speed { color: var(--accent-text); border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-text) 14%, transparent); }
.badge.done { color: var(--ok); border-color: rgba(61,214,140,0.5); background: rgba(61,214,140,0.08); }
.row .nm .badges { display: inline-flex; gap: 4px; margin-left: 6px; }

/* solve celebration */
.solve-burst { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.solve-burst span { position: absolute; width: 8px; height: 8px; border-radius: 1px; animation: burst 900ms ease-out forwards; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(540deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .solve-burst { display: none; } }

/* finale */
.finale { text-align: left; }
.finale h2 { font-size: clamp(28px, 4vw, 44px); margin: 6px 0 12px; }
.finale h2 .out { color: var(--ember); }
.finale .lede { color: #d6dfe8; max-width: 66ch; margin: 0 0 22px; }
.timeline { display: grid; gap: 0; margin: 18px 0 22px; border-left: 2px solid var(--line-2); }
.tl { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding: 0 0 18px 0; position: relative; }
.tl::before { content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.tl .when { font-family: var(--mono); font-size: 11px; color: var(--muted); grid-column: 2; text-transform: uppercase; letter-spacing: .08em; }
.tl .what { grid-column: 2; color: #d6dfe8; max-width: 66ch; }
.tl .what b { color: var(--text); }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 0 0 18px; }
.stat-tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; }
.stat-tile .v { font-family: var(--display); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-tile .v.ember { color: var(--ember); } .stat-tile .v.accent { color: var(--accent-text); } .stat-tile .v.ok { color: var(--ok); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line-2); color: var(--text); padding: 10px 16px; border-radius: 4px; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,.4); max-width: min(90vw, 520px); }
.toast.bad { border-color: rgba(240,89,106,0.6); }

/* banner (game over / locked / preview) */
.banner { padding: 10px 16px; border-radius: 4px; border: 1px solid var(--line-2); background: var(--panel); color: var(--muted); font-size: 13.5px; margin-bottom: 14px; }
.banner.ember { border-color: var(--ember-2); color: #f3dfcb; background: rgba(255,138,42,0.07); }

/* ===== admin ===== */
.admin main { grid-template-columns: 220px minmax(0, 1fr); }
@media (max-width: 720px) { .admin main { grid-template-columns: 1fr; } }
.admin nav.side { display: grid; gap: 6px; align-content: start; }
.admin nav.side button { text-align: left; background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 10px 14px; border-radius: 4px; font-weight: 500; }
.admin nav.side button.active { border-color: var(--accent-text); background: var(--panel-2); }
.admin .card + .card { margin-top: 16px; }
.admin h2 { font-size: 24px; margin: 0 0 6px; }
.admin .help { color: var(--muted); font-size: 13.5px; max-width: 70ch; margin: 0 0 16px; }
.form { display: grid; gap: 14px; max-width: 720px; }
.form .field input, .form .field select, .form .field textarea { width: 100%; background: var(--bg); border: 1px solid var(--line-2); color: var(--text); padding: 9px 12px; border-radius: 4px; font-family: inherit; font-size: 14px; }
.form .field textarea { min-height: 70px; font-family: var(--mono); font-size: 13px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form .three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .form .two, .form .three { grid-template-columns: 1fr; } }
.form .hint { font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent-text); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th, table.grid td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid th { color: var(--muted); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 500; position: sticky; top: 0; background: var(--panel); }
table.grid td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
table.grid th.num { text-align: right; }
table.grid tr:hover td { background: rgba(255,255,255,0.02); }
table.grid .actions-cell { white-space: nowrap; display: flex; gap: 6px; }
.tbl-wrap { overflow-x: auto; max-height: 70vh; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search] { background: var(--bg); border: 1px solid var(--line-2); color: var(--text); padding: 8px 12px; border-radius: 4px; font-family: inherit; min-width: 220px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.bar { height: 8px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar.warn i { background: var(--ember); }
.bar.bad i { background: var(--bad); }
.meter-row { display: grid; grid-template-columns: 1fr 60px; gap: 10px; align-items: center; font-size: 13px; }
.chart { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; align-items: end; height: 120px; border-bottom: 1px solid var(--line-2); padding-bottom: 2px; }
.chart b { display: block; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; position: relative; }
.chart b[title]:hover { background: var(--ember); }
.chart-x { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; font-family: var(--mono); font-size: 10px; color: var(--dim); margin-top: 4px; }
.chart-x span { text-align: center; overflow: hidden; }
.tmpl { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 14px 16px; margin-bottom: 12px; }
.tmpl pre { white-space: pre-wrap; font-family: var(--body); font-size: 14px; margin: 8px 0 10px; color: #d6dfe8; line-height: 1.55; }
.tmpl .label { display: flex; justify-content: space-between; align-items: center; }
.topic-pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-2); font-family: var(--mono); font-size: 11px; color: var(--muted); }
.report { background: #fff; color: #111; padding: 40px; border-radius: 6px; font-family: Georgia, 'Times New Roman', serif; line-height: 1.55; }
.report h1, .report h2, .report h3 { font-family: var(--body); color: #0b1a24; }
.report h1 { font-size: 28px; margin: 0 0 4px; } .report h2 { font-size: 18px; margin: 26px 0 8px; border-bottom: 2px solid #103649; padding-bottom: 4px; }
.report .sub { color: #555; margin-bottom: 20px; }
.report table { border-collapse: collapse; width: 100%; font-size: 13px; font-family: var(--body); }
.report th, .report td { border-bottom: 1px solid #ddd; padding: 6px 8px; text-align: left; }
.report th { background: #f0f4f7; }
.report .kpi { display: inline-block; margin: 0 22px 12px 0; }
.report .kpi b { display: block; font-size: 26px; color: #103649; font-family: var(--body); }
.report .kpi span { font-size: 12px; color: #666; text-transform: uppercase; letter-spacing: .06em; }
@media print { body { background: #fff; } header.top, nav.side, .no-print, footer { display: none !important; } main { display: block; padding: 0; } .report { padding: 0; } }

/* difficulty pills */
.diff { display: inline-block; padding: 1px 8px; border-radius: 999px; font-family: var(--mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; border: 1px solid; vertical-align: middle; }
.diff.easy { color: var(--ok); border-color: rgba(61,214,140,0.5); }
.diff.medium { color: var(--accent-text); border-color: var(--accent-2); }
.diff.hard { color: var(--ember); border-color: var(--ember-2); }

/* ===== phone layout ===== */
@media (max-width: 720px) {
  header.top { grid-template-columns: 1fr; gap: 12px; padding: 14px 16px 12px; }
  header.top > div { min-width: 0; }
  header.top .eyebrow { font-size: 10px; letter-spacing: .1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  header.top h1 { font-size: 28px; }
  header.top .sub { font-size: 13px; line-height: 1.45; }
  .topbar-right { width: 100%; }
  .status { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; }
  .stat .v { font-size: 20px; }
  main { padding: 12px 12px 40px; gap: 12px; }
  /* chapters become a horizontal strip so the puzzle stays on screen */
  nav.chapters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  nav.chapters .chap { flex: 0 0 auto; width: auto; min-width: 150px; grid-template-columns: 26px 1fr; grid-template-rows: auto auto; padding: 9px 11px; scroll-snap-align: start; }
  nav.chapters .chap .n { font-size: 16px; grid-row: 1 / span 2; }
  nav.chapters .chap .t { font-size: 13px; }
  nav.chapters .chap .d { font-size: 10.5px; }
  nav.chapters .chap .pips { grid-column: 2; }
  .vault { margin: 0; flex: 0 0 auto; padding: 8px 12px; display: flex; align-items: center; gap: 10px; }
  .vault .code { margin: 0; font-size: 18px; letter-spacing: .25em; }
  .card { padding: 16px 14px; }
  pre.mono { font-size: 12px; padding: 10px 12px; line-height: 1.5; }
  table.data { font-size: 12px; }
  .opt { padding: 11px 12px 11px 38px; font-size: 14px; }
  .actions { gap: 8px; }
  .btn { padding: 10px 14px; }
  .meta { flex-basis: 100%; margin-left: 0; }
  .me-chip { flex-direction: column; align-items: stretch; }
  .me-chip .actions { justify-content: flex-start; }
  .status .label { font-size: 10px; }
}

/* email card (rendered from the From/To/Subject convention in content) */
.mail { background: #f6f7f9; color: #1c2430; border-radius: 6px; overflow: visible; border: 1px solid #d8dee6; text-align: left; font-family: var(--body); }
.mail-h { display: flex; gap: 12px; padding: 12px 14px; background: #fff; border-bottom: 1px solid #e6eaef; border-radius: 6px 6px 0 0; }
.mail-av { width: 38px; height: 38px; border-radius: 50%; background: #103649; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; flex: 0 0 auto; }
.mail-meta { min-width: 0; font-size: 13.5px; line-height: 1.4; }
.mail-from b { color: #111; font-weight: 600; }
.mail-addr { color: #5b6773; word-break: break-all; }
.mail-to { color: #5b6773; font-size: 12.5px; }
.mail-subj { color: #111; font-weight: 600; margin-top: 3px; }
.mail-body { padding: 12px 14px 14px; font-size: 14px; line-height: 1.55; color: #26303c; }
.mail-body b { color: #111; }
.mail a.mlink { color: #0b57d0; text-decoration: underline; cursor: pointer; position: relative; }
.mail a.mlink:hover::after { content: attr(title); position: absolute; left: 0; top: 100%; margin-top: 4px; background: #1c2430; color: #fff; font-size: 11px; padding: 4px 8px; border-radius: 3px; white-space: nowrap; z-index: 2; font-family: var(--mono); }
.opt.has-mail { padding: 10px 10px 10px 40px; }
.opt.has-mail::before { top: 22px; }
.opt.has-mail.sel .mail { box-shadow: 0 0 0 2px var(--accent-text); }
.wrap-x .mail { margin-bottom: 18px; }
.fb.confirm { border-color: var(--ember-2); background: rgba(255,138,42,0.08); color: #f3dfcb; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.intel { border: 1px solid var(--ember-2); background: linear-gradient(180deg, rgba(255,138,42,0.10), rgba(255,138,42,0.03)); border-radius: 6px; padding: 14px 18px; margin-bottom: 14px; }
.intel-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.intel .eyebrow { color: var(--ember); }
.intel p { margin: 4px 0 10px; color: #e8dccf; max-width: 66ch; }
.intel .label { color: var(--muted); }

/* achievements + leaderboard neighborhood */
.bdg { font-size: 13px; margin-left: 3px; cursor: default; }
.mybadges { margin-top: 6px; font-size: 15px; letter-spacing: .1em; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 8px 0 22px; }
.badge-tile { background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; display: grid; grid-template-columns: 30px 1fr; gap: 2px 10px; align-items: center; }
.badge-tile .bi { font-size: 22px; grid-row: 1 / span 2; text-align: center; }
.badge-tile b { font-size: 13.5px; } .badge-tile small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.rows .gap { text-align: center; color: var(--dim); font-family: var(--mono); font-size: 11px; letter-spacing: .1em; padding: 4px 0; }
.banner a { color: var(--ember); }

/* ===== interactive modules ===== */
.module-card { border: 1px solid var(--line); border-radius: 6px; padding: 16px; background: var(--bg-2); margin-bottom: 18px; }
.finale-card { border-color: var(--ember-2); background: linear-gradient(180deg, rgba(255,138,42,0.08), rgba(255,138,42,0.02)); }
.finale-card h3 { color: var(--ember); font-size: 18px; margin: 0 0 4px; }
.prow.finale { border-color: var(--ember-2); }
.prow.finale .k { color: var(--ember); }
.scene { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 16px; background: linear-gradient(180deg, #1a2634 0 60%, #3b2f24 60%); border-radius: 6px; border: 1px solid var(--line-2); margin-bottom: 8px; }
.hs { background: rgba(255,255,255,0.06); border: 2px solid transparent; border-radius: 6px; padding: 12px 8px; color: var(--text); display: grid; justify-items: center; gap: 6px; }
.hs:hover { background: rgba(255,255,255,0.1); }
.hs.sel { border-color: var(--ember); background: rgba(255,138,42,0.16); }
.hs-ic { font-size: 34px; line-height: 1; } .hs-lb { font-size: 12px; text-align: center; color: var(--muted); line-height: 1.3; }
.urlbar { font-family: var(--mono); font-size: 15px; background: #fff; color: #222; border-radius: 6px; padding: 12px 14px; overflow-x: auto; white-space: nowrap; margin-bottom: 10px; }
.url-dim { color: #888; } .url-dot { color: #444; }
.url-seg { background: none; border: 0; border-bottom: 2px solid transparent; color: #0b57d0; font: inherit; padding: 2px 1px; cursor: pointer; }
.url-seg:hover { background: #eef3ff; } .url-seg.sel { background: #ffe5cc; border-bottom-color: #ff8a2a; color: #111; }
.lineup { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 8px; }
.browser { background: #fff; color: #222; border: 2px solid transparent; border-radius: 8px; overflow: hidden; text-align: left; padding: 0; cursor: pointer; }
.browser.sel { border-color: var(--accent-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-text) 34%, transparent); }
.browser .bar { background: #e9ecf1; padding: 8px 10px; display: flex; gap: 8px; align-items: center; font-size: 12px; font-family: var(--mono); }
.browser .dots { color: #b0b6bf; letter-spacing: -2px; } .browser .addr { background: #fff; border-radius: 12px; padding: 3px 10px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browser .page { padding: 18px 16px 14px; display: grid; justify-items: center; gap: 8px; }
.pg-logo { color: #103649; font-size: 26px; } .pg-title { font-weight: 600; font-size: 13.5px; text-align: center; }
.pg-field { width: 80%; height: 26px; border: 1px solid #cfd5dd; border-radius: 4px; background: #fafbfc; }
.pg-btn { width: 80%; background: #103649; color: #fff; border-radius: 4px; padding: 6px; text-align: center; font-size: 13px; }
.pg-note { font-size: 11px; color: #777; text-align: center; }
.phone { max-width: 380px; background: #111; border-radius: 22px; padding: 12px; border: 4px solid #2a3441; margin-bottom: 16px; }
.phone.chat { max-width: 520px; border-radius: 8px; border-width: 1px; background: #1e2a38; }
.ph-top { color: #fff; font-weight: 600; padding: 6px 8px 10px; border-bottom: 1px solid #333; font-size: 14px; }
.ph-msgs { display: grid; gap: 8px; padding: 10px 4px; max-height: 320px; overflow-y: auto; }
.msg { display: grid; gap: 2px; max-width: 85%; } .msg.me { justify-self: end; text-align: right; }
.bub { background: #2d3a4a; color: #fff; padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.4; text-align: left; }
.sms .msg.them .bub { background: #3a3a3c; } .sms .msg.me .bub { background: #0a84ff; } .chat .msg.me .bub { background: #1f5f8b; }
.tm { font-size: 10.5px; color: #8a9bb0; }
.push-card { background: #fff; color: #111; border-radius: 10px; padding: 10px 12px; font-size: 13px; display: grid; gap: 2px; animation: rise .25s; }
.push-card.denied { opacity: .45; text-decoration: line-through; } .push-card small { color: #666; }
.push-actions { display: flex; gap: 6px; padding: 8px 4px 2px; flex-wrap: wrap; }
.term { background: #05080c; border: 1px solid var(--line-2); border-radius: 6px; font-family: var(--mono); font-size: 13px; }
.term-out { height: 260px; overflow-y: auto; padding: 12px; color: #cfe6dc; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.term-out .cmd { color: var(--accent-text); } .term-out .dim { color: var(--muted); }
.term-in { display: flex; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line); color: var(--accent-text); }
.term-in input { flex: 1; background: none; border: 0; color: #fff; font: inherit; outline: none; }
.bins-list { display: grid; gap: 8px; margin-bottom: 8px; }
.bin-item { background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.bin-btns { display: flex; gap: 6px; }
@media (max-width: 720px) { .bin-item { grid-template-columns: 1fr; } }
.pwlab { margin-top: 10px; display: grid; gap: 8px; }
.pw-time { font-family: var(--display); font-size: 30px; color: var(--accent-text); } .pw-why { color: var(--muted); font-size: 13.5px; }
.qrwrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
#qrbox { background: #fff; padding: 12px; border-radius: 6px; display: inline-block; }
.qr-poster { color: var(--muted); } .qr-poster b { display: block; color: var(--text); font-size: 18px; }
.qr-fallback { color: #333; font-size: 12px; }
.soc { border: 1px solid var(--line-2); border-radius: 6px; padding: 14px; background: var(--bg); }
.soc-top { display: flex; justify-content: space-between; margin-bottom: 10px; } .soc-clock { font-family: var(--display); font-size: 22px; color: var(--ember); }
.soc-alert { min-height: 58px; padding: 12px 14px; background: var(--panel); border-left: 3px solid var(--ember); border-radius: 4px; margin-bottom: 12px; font-size: 15px; }
.media { background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 14px; margin-bottom: 14px; }
.media-h { font-weight: 600; margin-bottom: 10px; } .media-none { color: var(--muted); font-size: 13px; padding: 8px 0; }
.media details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 8px; }
/* admin library */
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.lib-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 14px; display: grid; gap: 6px; align-content: start; }
.lib-card b { font-size: 15px; } .lib-card small { color: var(--muted); line-height: 1.45; }
.lib-card .actions { margin-top: 4px; }
.preview-box { border: 1px dashed var(--line-2); border-radius: 6px; padding: 16px; margin-top: 12px; background: var(--panel); }
.form textarea.json { min-height: 260px; font-family: var(--mono); font-size: 12.5px; line-height: 1.45; }

/* ===== advanced modules ===== */
.hdrs { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; overflow-x: auto; margin-bottom: 14px; }
.hdr-line { white-space: pre; color: var(--muted); } .hdr-line.hl-a { color: #cfe6dc; background: color-mix(in srgb, var(--accent-text) 12%, transparent); } .hdr-line.hl-b { color: #f3dfcb; background: rgba(255,138,42,0.08); }
table.pcap th { cursor: pointer; white-space: nowrap; } table.pcap tr { cursor: pointer; } table.pcap tr.sel td, table.clickable tr.sel td { background: rgba(255,138,42,0.14); } table.pcap td.info { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.clickable tr { cursor: pointer; } table.clickable tr:hover td { background: rgba(255,255,255,0.04); }
.hc { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; } @media (max-width: 720px) { .hc { grid-template-columns: 1fr; } }
.hc-res { padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; font-size: 13.5px; min-height: 40px; }
.fw-traffic { background: var(--bg); border-left: 3px solid var(--ember); padding: 10px 14px; border-radius: 0 4px 4px 0; margin-bottom: 12px; font-size: 13.5px; }
.fw-n { display: inline-block; width: 22px; color: var(--muted); }
.ar { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } @media (max-width: 900px) { .ar { grid-template-columns: 1fr; } }
.prof { background: #fff; color: #1c2430; border-radius: 8px; padding: 14px; margin-bottom: 8px; }
.prof-h { display: flex; gap: 12px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid #e6eaef; margin-bottom: 10px; } .pf-bio { font-size: 13px; color: #5b6773; }
.posts { display: grid; gap: 8px; } .post { text-align: left; background: #f6f7f9; border: 2px solid transparent; border-radius: 6px; padding: 10px 12px; color: #1c2430; font: inherit; font-size: 14px; cursor: pointer; } .post small { color: #6b7783; display: block; margin-top: 4px; } .post.sel { border-color: var(--ember); background: #fff2e6; }
.cc { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 8px; } @media (max-width: 900px) { .cc { grid-template-columns: 1fr; } }
.toolbox { background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; padding: 12px; display: grid; gap: 8px; }
.toolbox textarea { min-height: 70px; background: var(--panel); border: 1px solid var(--line); color: var(--text); padding: 8px 10px; border-radius: 4px; font-size: 12.5px; resize: vertical; }
.ransom .ph-top { color: var(--ember); }
svg.plan { max-width: 100%; height: auto; background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; margin-bottom: 8px; }
svg.plan .room rect { fill: var(--panel-2); stroke: var(--line-2); stroke-width: 1.5; cursor: pointer; } svg.plan .room:hover rect { fill: #1f3040; } svg.plan .room.sel rect { fill: rgba(255,138,42,0.25); stroke: var(--ember); stroke-width: 2.5; }
.room-lb { font: 11.5px/1.25 var(--body); color: var(--text); pointer-events: none; }
.qb { display: grid; grid-template-columns: 280px 1fr; gap: 16px; } @media (max-width: 900px) { .qb { grid-template-columns: 1fr; } }
.qb-pal { display: grid; gap: 6px; align-content: start; } .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; cursor: grab; user-select: none; } .chip.used { opacity: .35; } .chip.in { background: color-mix(in srgb, var(--accent-text) 16%, transparent); border-color: var(--accent-text); cursor: pointer; } .chip.ghost { opacity: .4; border-style: dashed; cursor: default; }
.qb-q { display: grid; gap: 10px; align-content: start; }
.qb-slot { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: center; background: var(--bg); border: 1px dashed var(--line-2); border-radius: 6px; padding: 8px 12px; min-height: 46px; } .qb-slot.over { border-color: var(--accent-text); background: color-mix(in srgb, var(--accent-text) 9%, transparent); }
.qb-slot .kw { font-family: var(--mono); color: var(--accent-text); font-weight: 600; letter-spacing: .06em; } .qb-slot .drop { display: flex; flex-wrap: wrap; gap: 6px; }
.qb-res { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; font-size: 13.5px; color: #d6dfe8; min-height: 50px; } .qb-res .ok-res { color: var(--ok); margin-bottom: 8px; }
.cc > div, .hc > div, .ar > div, .qb > div { min-width: 0; }
.toolbox .actions { flex-wrap: wrap; }

/* attack tactic tag + pack builder */
.eyebrow .tactic { color: var(--ember); }
.pb-chapters { display: grid; gap: 12px; }
.pb-chapter { border: 1px solid var(--line); border-radius: 6px; background: var(--bg-2); }
.pb-chead { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.pb-chead .tac { font-family: var(--mono); font-size: 11px; color: var(--ember); }
.pb-chead select, .pb-chead input { background: var(--bg); border: 1px solid var(--line-2); color: var(--text); padding: 7px 10px; border-radius: 4px; font-family: inherit; font-size: 13px; }
.pb-puzzles { display: grid; gap: 6px; padding: 10px 12px; }
.pb-pz { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; font-size: 13px; }
.pb-pz .t { font-weight: 500; } .pb-pz small { color: var(--muted); }
.pb-addrow { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 12px 12px; }
.pb-flow { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 14px; }
.pb-flow .step { font-family: var(--mono); font-size: 11px; padding: 3px 9px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--muted); }
.pb-flow .step.on { color: var(--ember); border-color: var(--ember-2); }
.pb-flow .arr { color: var(--dim); align-self: center; }
