:root {
  --bg: #0a0e13;
  --panel: #111821;
  --panel-2: #17202b;
  --line: #233040;
  --text: #e6edf3;
  --dim: #8b9aab;
  --accent: #4ef0a0;
  --accent-ink: #04170d;
  --amber: #f5c451;
  --red: #ff6b6b;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(78, 240, 160, 0.08), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}

.mono { font-family: var(--mono); }
.dim { color: var(--dim); }
a { color: var(--accent); }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  /* Full-width solid bar that also fills the area behind the iPhone status bar */
  padding: calc(14px + env(safe-area-inset-top)) max(18px, calc((100% - 560px) / 2 + 18px)) 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.logo { color: var(--accent); font-size: 22px; line-height: 1; transform: translateY(2px); }
.name { font-weight: 700; font-size: 20px; letter-spacing: -0.02em; }
.actions { display: flex; align-items: center; gap: 8px; }
.pill { font-size: 13px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--dim); }
.icon {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  font: 600 16px var(--sans); cursor: pointer;
}
.icon:active { transform: scale(0.96); }

main { max-width: 560px; margin: 0 auto; padding: 18px 18px 8px; }

/* Progress */
.progress { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0; margin: 0 0 14px; }
.step {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--dim); font-size: 13px;
}
.step.active { border-color: var(--accent); color: var(--text); }
.step.green { border-color: rgba(78, 240, 160, 0.5); }
.step.amber { border-color: rgba(245, 196, 81, 0.5); }
.step.red { border-color: rgba(255, 107, 107, 0.5); }

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  animation: rise 0.25s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.eyebrow { margin: 0 0 10px; font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.clue { font-size: 19px; line-height: 1.45; margin: 0 0 12px; font-weight: 500; }
.question { font-weight: 600; margin: 16px 0 10px; }
.meta { color: var(--dim); font-size: 14px; margin: 8px 0 0; }
.meta strong { color: var(--text); }
.center { text-align: center; }

.payload {
  margin: 0 0 4px; padding: 14px;
  background: #070a0e; border: 1px solid var(--line); border-radius: 10px;
  color: var(--accent); font-size: 15px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-all;
}

/* Inputs */
.row { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.row.between { justify-content: space-between; }
.row .meta { margin: 0; }
.field {
  flex: 1; min-width: 0;
  padding: 12px 14px; font-size: 17px; /* ≥16px stops iOS zooming */
  color: var(--text); background: #070a0e;
  border: 1px solid var(--line); border-radius: 10px; outline: none;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(78, 240, 160, 0.15); }
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }

.btn {
  padding: 12px 18px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  font: 700 16px var(--sans);
}
.btn:active { transform: scale(0.98); }
.btn.full { width: 100%; margin-top: 14px; }
.link {
  background: none; border: 0; padding: 8px 0; cursor: pointer;
  color: var(--dim); font: 500 14px var(--sans); text-decoration: underline; text-underline-offset: 3px;
}
.link:disabled { opacity: 0.3; cursor: default; }
.center-block { display: block; margin: 14px auto 0; }

/* Guess list */
.guesses { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.guesses li {
  display: flex; justify-content: space-between;
  padding: 8px 12px; border-radius: 8px; background: var(--panel-2); color: var(--dim); font-size: 14px;
}
.guesses li .mono { color: var(--text); }
.guesses li.ok { background: rgba(78, 240, 160, 0.12); color: var(--accent); }

/* Exhibit (email / code / logs / command) */
.exhibit {
  background: #070a0e; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 0; font-size: 13px; overflow-x: auto;
}
.exhibit .line { display: flex; padding: 1px 14px; white-space: pre; }
.exhibit .ln { width: 22px; flex: none; color: #4b5a6b; font-family: var(--mono); user-select: none; }
.exhibit.phishing { font-size: 14px; }
.exhibit.phishing .line { white-space: pre-wrap; }
.exhibit.phishing .line .mono { font-family: var(--sans); }
.exhibit.phishing .line:nth-child(-n+3) .mono { color: var(--dim); font-family: var(--mono); font-size: 12.5px; }

.options { display: grid; gap: 8px; }
.option {
  text-align: left; padding: 12px 14px; cursor: pointer;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; font: 15px/1.4 var(--sans);
}
.option:not(:disabled):hover { border-color: var(--accent); }
.option:disabled { cursor: default; opacity: 0.55; }
.option.right { opacity: 1; border-color: var(--accent); background: rgba(78, 240, 160, 0.12); }
.option.wrong { opacity: 1; border-color: var(--red); background: rgba(255, 107, 107, 0.12); }

/* Outcome */
.outcome { margin-top: 16px; padding: 14px; border-radius: 10px; border: 1px solid; }
.outcome p { margin: 0; }
.outcome.green { border-color: rgba(78, 240, 160, 0.4); background: rgba(78, 240, 160, 0.07); }
.outcome.amber { border-color: rgba(245, 196, 81, 0.4); background: rgba(245, 196, 81, 0.07); }
.outcome.red { border-color: rgba(255, 107, 107, 0.4); background: rgba(255, 107, 107, 0.07); }
.explain { margin-top: 8px !important; color: var(--dim); font-size: 14px; }

/* Results */
.results { text-align: center; }
.big { font: 800 64px/1 var(--mono); margin: 6px 0; letter-spacing: -0.04em; }
.verdict { color: var(--dim); margin: 0 0 16px; }
.squares { display: flex; justify-content: center; gap: 12px; }
.sq { display: grid; gap: 2px; font-size: 26px; }
.sq .lbl { font-size: 11px; color: var(--dim); font-family: var(--mono); }
.countdown { color: var(--text); }

.stats { margin-top: 22px; text-align: left; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.stat { display: grid; text-align: center; padding: 10px 4px; background: var(--panel-2); border-radius: 10px; }
.stat .num { font: 700 24px var(--mono); }
.stat .lbl { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.dist { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: center; font-size: 13px; }
.bar-track { background: var(--panel-2); border-radius: 6px; }
.bar { background: var(--accent); color: var(--accent-ink); font: 700 12px var(--mono); padding: 3px 8px; border-radius: 6px; text-align: right; min-width: 24px; }

/* Modals */
dialog {
  border: 1px solid var(--line); border-radius: 18px; padding: 0;
  background: var(--panel); color: var(--text);
  width: min(92vw, 480px); max-height: 80dvh; overflow: auto;
  margin: max(56px, 10vh) auto auto; /* sit near the top, not dead centre */
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px); }
.modal { padding: 22px; position: relative; }
.modal h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: -0.02em; }
.close { position: absolute; top: 14px; right: 14px; }
.how { padding-left: 20px; display: grid; gap: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 14px; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14px;
  padding: 10px 16px; border-radius: 999px; transition: 0.2s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { max-width: 560px; margin: 0 auto; padding: 18px; text-align: center; color: var(--dim); font-size: 13px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Archive */
.banner {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-bottom: 12px; padding: 10px 14px; border-radius: 10px;
  background: rgba(245, 196, 81, 0.08); border: 1px solid rgba(245, 196, 81, 0.35);
  color: var(--amber); font-size: 14px;
}
.banner a { color: var(--amber); font-weight: 600; }
.arch-list { display: grid; gap: 6px; margin-top: 8px; }
.arch-row {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px; text-decoration: none;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}
.arch-row:hover, .arch-row.current { border-color: var(--accent); }
.arch-num { color: var(--accent); font-weight: 700; }
.arch-date { font-size: 15px; }
.arch-score { font-size: 14px; white-space: nowrap; }
.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); text-decoration: none; font-size: 15px; text-align: center; flex: 1; }
.center-row { justify-content: center; margin-top: 14px; }

/* Bigger on desktop: scale the layout up rather than stretching it.
   Content and dialogs are zoomed separately so dialogs always fit the window. */
@media (min-width: 900px) {
  .top, main, .foot, #toast { zoom: 1.3; }
  dialog { zoom: 1.2; max-height: calc(84dvh / 1.2); margin-top: calc(8vh / 1.2); }
}
@media (min-width: 1600px) and (min-height: 900px) {
  .top, main, .foot, #toast { zoom: 1.5; }
  dialog { zoom: 1.35; max-height: calc(84dvh / 1.35); margin-top: calc(8vh / 1.35); }
}

/* Difficulty */
.daybar { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 10px; font-size: 14px; color: var(--dim); }
.level { font-weight: 600; }
.level .pips { letter-spacing: 2px; font-size: 11px; }
.l1 { color: var(--accent); }
.l2 { color: var(--amber); }
.l3 { color: var(--red); }
.arch-date { display: flex; flex-direction: column; line-height: 1.25; }
.arch-level { font-size: 12px; font-weight: 600; }

/* Learn more */
.learn { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 14px; }
.learn a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.learn a:hover { text-decoration-color: var(--accent); }

/* Breach round */
.clues { margin: 12px 0 0; padding-left: 22px; display: grid; gap: 8px; }
.clues li { font-size: 16px; line-height: 1.45; }
.clues li::marker { color: var(--accent); font-family: var(--mono); font-weight: 700; }
.clues li.new { animation: rise 0.3s ease-out; }
@media (max-width: 400px) { .progress .step .lbl { display: none; } .progress .step { font-size: 16px; } }

/* Installed app (Add to Home Screen): iOS blurs a strip just below the status bar,
   so give the header extra room there. */
@media (display-mode: standalone) {
  .top { padding-top: calc(env(safe-area-inset-top) + 30px); }
}
html.standalone .top { padding-top: calc(env(safe-area-inset-top) + 30px); }
