@charset "utf-8";
/* Number Sorter — falling-number classification game (2026-06 redesign) */

:root {
  --bg-0: #0b1020;
  --bg-1: #131a31;
  --card: #1a2238;
  --card-2: #212c47;
  --line: #2d3a5c;
  --ink: #eef2ff;
  --muted: #9aa6c7;
  --primary: #38bdf8;
  --primary-ink: #06283b;
  --go: #34d399;
  --bad: #fb7185;
  --left: #a78bfa;    /* violet — the LEFT bin */
  --right: #2dd4bf;   /* teal   — the RIGHT bin */
  --r: 18px;
  --shadow: 0 20px 50px -20px rgba(0,0,0,.65);
  --font: ui-rounded, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink);
  background:
    radial-gradient(1100px 700px at 50% -8%, #1c2748 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%) fixed;
  min-height: 100%; -webkit-text-size-adjust: 100%;
}

/* ---------- top bar ---------- */
.ns-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px clamp(14px, 4vw, 28px);
  border-bottom: 1px solid var(--line); background: rgba(11,16,32,.72);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.ns-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; }
.ns-brand img { display: block; }
.ns-brand span { font-size: clamp(15px, 2.4vw, 18px); }
.ns-nav-links { display: flex; align-items: center; gap: 8px; }
.ns-nav-links a, #btn-info {
  color: var(--muted); text-decoration: none; font-family: var(--font); font-weight: 600; font-size: 14px;
  background: none; border: 1px solid transparent; border-radius: 999px; padding: 8px 12px; cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.ns-nav-links a:hover, #btn-info:hover { color: var(--ink); background: var(--card-2); }
#btn-info { border-color: var(--line); }

/* ---------- stage ---------- */
.ns-wrap {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: clamp(14px, 3vw, 32px) 14px 36px; min-height: calc(100vh - 58px);
}
.ns-screen {
  display: none; width: min(600px, 100%);
  background: linear-gradient(180deg, var(--card) 0%, #161d31 100%);
  border: 1px solid var(--line); border-radius: calc(var(--r) + 6px);
  box-shadow: var(--shadow); padding: clamp(18px, 4vw, 30px);
  animation: fade .28s ease both;
}
.ns-wrap[data-screen="start"]  .ns-start  { display: block; }
.ns-wrap[data-screen="game"]   .ns-game   { display: block; }
.ns-wrap[data-screen="result"] .ns-result { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- start ---------- */
.ns-title { margin: 0 0 6px; font-size: clamp(26px, 6vw, 38px); font-weight: 800; letter-spacing: -.5px; color: #bae6fd; }
.ns-ver { font-size: 14px; font-weight: 700; color: var(--muted); letter-spacing: .04em; vertical-align: middle; }
.ns-tag { margin: 0 0 18px; color: var(--muted); font-size: 15px; line-height: 1.55; }

/* ---- start-screen controls: CCSS standard picker ---- */
.ns-field-label { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.ns-ccss { margin: 0 0 18px; padding: 11px 13px; background: var(--bg-0); border: 1px solid var(--line);
  border-radius: 12px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.ns-ccss b { color: #bae6fd; font-weight: 800; }

.ns-modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 10px; }
.ns-mode {
  appearance: none; cursor: pointer; text-align: left;
  background: var(--bg-0); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 14px; color: var(--ink); transition: border-color .15s, background .15s, box-shadow .15s;
}
.ns-mode b { display: block; font-weight: 800; font-size: 15px; }
.ns-mode small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.ns-mode:hover { background: var(--card-2); }
.ns-mode.is-active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(56,189,248,.25); background: var(--card-2); }

.ns-primary {
  appearance: none; border: 0; cursor: pointer; width: 100%; margin-top: 4px;
  padding: 15px 20px; border-radius: 14px; font-family: var(--font); font-weight: 800; font-size: 17px; line-height: 1;
  color: var(--primary-ink); background: linear-gradient(180deg, #7dd3fc, var(--primary));
  box-shadow: 0 10px 24px -10px rgba(56,189,248,.7); transition: transform .08s ease, filter .15s;
}
.ns-primary:hover { filter: brightness(1.05); }
.ns-primary:active { transform: translateY(1px); }
.ns-ghost {
  appearance: none; cursor: pointer; width: 100%; margin-top: 10px; padding: 12px 20px; border-radius: 14px;
  font-family: var(--font); font-weight: 700; font-size: 15px; line-height: 1;
  color: var(--muted); background: transparent; border: 1px solid var(--line); transition: color .15s, background .15s;
}
.ns-ghost:hover { color: var(--ink); background: var(--card-2); }
.ns-best { margin: 16px 0 0; text-align: center; color: var(--muted); font-size: 14px; }
.ns-best strong { color: #fbbf24; font-size: 16px; }

/* ---------- game HUD ---------- */
.ns-hud {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px; font-size: 14px; color: var(--muted);
}
.ns-hud-mode {
  font-weight: 800; font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--ink); background: var(--bg-0); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px;
}
.ns-hud-stat { font-weight: 600; }
.ns-hud-stat strong { color: var(--ink); font-weight: 800; }
.ns-hud-lives { margin-left: auto; font-size: 18px; letter-spacing: 2px; line-height: 1; }
.ns-quit { appearance: none; cursor: pointer; font-family: var(--font); font-weight: 800; font-size: 12px;
  color: var(--muted); background: var(--bg-0); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; transition: color .15s, background .15s, border-color .15s; }
.ns-quit:hover { color: var(--bad); border-color: var(--bad); }

/* ---------- field ---------- */
.ns-field {
  position: relative; overflow: hidden;
  height: clamp(340px, 56vh, 540px);
  border-radius: var(--r); border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,.02), transparent 30%),
    repeating-linear-gradient(180deg, transparent 0 38px, rgba(255,255,255,.015) 38px 39px),
    var(--bg-0);
}
.ns-tile {
  position: absolute; top: 14px; left: 50%; transform: translate(-50%, 0);
  width: clamp(74px, 18vw, 92px); height: clamp(74px, 18vw, 92px);
  display: grid; place-items: center;
  border-radius: 18px; background: linear-gradient(180deg, #fff, #e6edf8);
  color: #0b1020; box-shadow: 0 10px 22px -8px rgba(0,0,0,.6), inset 0 0 0 1px rgba(0,0,0,.05);
  will-change: transform;
}
#tile-num { font-weight: 850; font-size: clamp(34px, 9vw, 46px); font-variant-numeric: tabular-nums; }
.ns-tile.correct { background: linear-gradient(180deg, #bbf7d0, #86efac); }
.ns-tile.wrong { background: linear-gradient(180deg, #fecdd3, #fda4af); }
/* a number coming back for review (missed earlier) gets an amber ring */
.ns-tile.is-review { box-shadow: 0 0 0 3px #fbbf24, 0 0 18px rgba(251,191,36,.55), 0 10px 22px -8px rgba(0,0,0,.6); }

.ns-bins { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; padding: 10px; }
.ns-bin {
  appearance: none; cursor: pointer; flex: 1;
  height: clamp(78px, 16vh, 104px);
  border-radius: 14px; border: 2px dashed var(--line); background: rgba(255,255,255,.02);
  display: grid; place-items: center; padding: 8px; transition: border-color .15s, background .15s, transform .1s;
}
.ns-bin-left { border-color: color-mix(in srgb, var(--left) 55%, var(--line)); }
.ns-bin-right { border-color: color-mix(in srgb, var(--right) 55%, var(--line)); }
.ns-bin:hover { background: rgba(255,255,255,.05); }
.ns-bin:active { transform: scale(.98); }
.ns-bin-label { font-weight: 800; font-size: clamp(15px, 4vw, 19px); text-align: center; line-height: 1.15; }
.ns-bin-left .ns-bin-label { color: var(--left); }
.ns-bin-right .ns-bin-label { color: var(--right); }
.ns-bin.flash-good { border-style: solid; border-color: var(--go); background: rgba(52,211,153,.18); }
.ns-bin.flash-bad  { border-style: solid; border-color: var(--bad); background: rgba(251,113,133,.18); }

.ns-flash {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  font-weight: 850; font-size: clamp(20px, 6vw, 30px); text-align: center; white-space: nowrap;
  opacity: 0; pointer-events: none; text-shadow: 0 2px 16px rgba(0,0,0,.7);
}
.ns-flash.show { animation: flashPop 1s ease both; }
.ns-flash.good { color: #6ee7b7; }
.ns-flash.bad { color: #fda4af; }
@keyframes flashPop {
  0% { opacity: 0; transform: translate(-50%, -35%) scale(.8); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -55%) scale(1); }
}

/* ---------- controls ---------- */
.ns-controls { display: flex; gap: 10px; margin-top: 12px; }
.ns-ctrl {
  appearance: none; cursor: pointer; flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 16px 10px; border-radius: 14px; border: 1px solid var(--line);
  font-family: var(--font); font-weight: 800; font-size: clamp(15px, 4vw, 18px); color: var(--ink);
  background: linear-gradient(180deg, var(--card-2), #1a2138);
  transition: transform .06s ease, background .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent; user-select: none; touch-action: manipulation;
}
.ns-ctrl .ns-arrow { font-size: 20px; line-height: 1; }
.ns-ctrl-left { color: var(--left); border-color: color-mix(in srgb, var(--left) 45%, var(--line)); }
.ns-ctrl-right { color: var(--right); border-color: color-mix(in srgb, var(--right) 45%, var(--line)); }
.ns-ctrl:active { transform: translateY(2px) scale(.99); }
.ns-ctrl:hover { background: linear-gradient(180deg, #2a3759, #212a45); }

/* ---------- result ---------- */
.ns-result { text-align: center; }
.ns-result-emoji { font-size: 50px; line-height: 1; margin-bottom: 6px; }
.ns-result-head { margin: 0 0 4px; font-size: clamp(22px, 5vw, 28px); font-weight: 800; }
.ns-result-sub { margin: 0 0 18px; color: var(--muted); font-size: 15px; line-height: 1.5; }
.ns-result-sub strong { color: var(--ink); }
.ns-scoreline { display: flex; justify-content: center; gap: 14px; margin: 0 0 22px; }
.ns-score { flex: 1; max-width: 170px; background: var(--bg-0); border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px; }
.ns-score-num { display: block; font-weight: 800; font-size: 34px; line-height: 1; color: var(--primary); font-variant-numeric: tabular-nums; }
.ns-score:last-child .ns-score-num { color: #fbbf24; }
.ns-score-lbl { display: block; margin-top: 5px; font-weight: 700; font-size: 11px; line-height: 1; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }

/* ---------- end-of-game debrief ---------- */
.ns-debrief { text-align: left; margin: 0 0 20px; }
.ns-debrief-hd { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: center; margin: 0 0 8px; }
.ns-debrief-list { list-style: none; margin: 0; padding: 0; max-height: 30vh; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg-0); }
.ns-debrief-list li { display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  border-bottom: 1px solid rgba(255,255,255,.05); font-size: 16px; }
.ns-debrief-list li:last-child { border-bottom: none; }
.ns-d-num { font-weight: 850; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.ns-d-arr { color: var(--muted); }
.ns-d-ans { font-weight: 700; color: #6ee7b7; }
.ns-d-cnt { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--bad); white-space: nowrap; }
.ns-debrief-empty { padding: 12px 14px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- info modal ---------- */
.ns-modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 18px;
  background: rgba(5,8,18,.68); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fade .2s ease both;
}
.ns-modal[hidden] { display: none; }
.ns-modal-card { width: min(460px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: clamp(20px, 4vw, 28px); box-shadow: var(--shadow); }
.ns-modal-card h2 { margin: 0 0 12px; font-size: 22px; font-weight: 800; }
.ns-modal-card ol { margin: 0 0 16px; padding-left: 20px; }
.ns-modal-card li { margin: 0 0 10px; line-height: 1.5; }
.ns-modal-card strong { color: #bae6fd; }
.ns-kbd {
  display: inline-block; min-width: 20px; text-align: center; padding: 1px 6px; border-radius: 6px;
  background: var(--bg-0); border: 1px solid var(--line); font-weight: 700; font-size: 12px;
}

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

@media (max-width: 360px) { .ns-modes { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  .ns-screen, .ns-modal, .ns-flash.show { animation: none !important; }
  .ns-flash.show { opacity: 1; }
  .ns-primary, .ns-ctrl, .ns-bin, .ns-mode { transition: none !important; }
}
