/* ============================================================
   Knight's Gauntlet — National Chess Day 2026
   Design system + components
   ============================================================ */

:root {
  --bg: #0c1322;
  --bg-2: #090e1a;
  --surface: #141d33;
  --surface-2: #1b2743;
  --border: #2a3a5c;
  --text: #e9eefb;
  --muted: #9dabca;
  --gold: #f2c14e;
  --gold-2: #ffd97a;
  --teal: #46d3b4;
  --coral: #ff7a6b;
  --sq-light: #e7cfa6;
  --sq-dark: #8f6a45;
  --sq-visit-light: #d9bd8c;
  --sq-visit-dark: #7c5a39;
  --sq-text: #2a2010;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1080px;
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5efe3;
  --bg-2: #ece2cf;
  --surface: #fffdf8;
  --surface-2: #f7efe0;
  --border: #ddcfb6;
  --text: #1f2536;
  --muted: #5f6a82;
  --gold: #a9760f;
  --gold-2: #c98f18;
  --teal: #0f7d6c;
  --coral: #c9483a;
  --sq-light: #f0d9b5;
  --sq-dark: #b58863;
  --sq-visit-light: #e3c69b;
  --sq-visit-dark: #966c47;
  --sq-text: #2a2010;
  --shadow: 0 18px 45px rgba(80, 60, 20, 0.18);
  --shadow-sm: 0 6px 16px rgba(80, 60, 20, 0.14);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(70, 211, 180, 0.10), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(242, 193, 78, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img, svg { max-width: 100%; }

a { color: var(--gold); text-underline-offset: 3px; }
a:hover { color: var(--gold-2); }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 0.5em; }
h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.5rem, 3.6vw, 2.2rem); font-weight: 800; }
h3 { font-size: 1.2rem; font-weight: 600; }

p { margin: 0 0 1em; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }
.narrow { max-width: 760px; }

.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.6rem;
}

.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--gold);
  color: #1a1300;
  padding: 10px 16px;
  z-index: 100;
  border-radius: 0 0 10px 0;
  font-weight: 700;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand .mark { width: 34px; height: 34px; flex: none; }
.brand small { display: block; font-family: var(--font-body); font-weight: 600; font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }

.nav { display: flex; align-items: center; gap: 4px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 8px 11px;
  border-radius: 999px;
}
.nav a:hover { background: var(--surface-2); color: var(--gold-2); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--gold); }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.05rem;
  flex: none;
  transition: transform 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { background: var(--surface-2); transform: translateY(-1px); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 11px 20px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
  background: var(--surface-2);
  color: var(--text);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #241a02; box-shadow: var(--shadow-sm); }
.btn-primary:hover { color: #241a02; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 8px 14px; font-size: 0.84rem; }
.btn:focus-visible, .icon-btn:focus-visible, a:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ---------- Hero ---------- */
.hero { padding: 44px 0 8px; position: relative; }
.hero-grid { display: grid; gap: 26px; align-items: center; }
.hero h1 { margin-bottom: 0.3em; }
.hero h1 .accent { color: var(--gold); }
.lede { font-size: clamp(1.02rem, 2.3vw, 1.2rem); color: var(--muted); max-width: 46ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 6px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 999px;
}
.badge strong { color: var(--text); }

.hero-art {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}
.hero-art svg { width: 78%; height: 78%; }
.hero-art .float { animation: float 6s ease-in-out infinite; transform-origin: center; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------- Cards / sections ---------- */
.section { padding: 40px 0; }
.section-head { margin-bottom: 22px; }
.section-head p { color: var(--muted); max-width: 62ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr; }
.grid.cols-3 { grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .hero-grid { grid-template-columns: 1.15fr 0.85fr; }
}

.stat-row { display: flex; flex-wrap: wrap; gap: 10px; }
.stat {
  flex: 1 1 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.stat .k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; }
.stat .v { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; color: var(--gold); }

/* ---------- Game ---------- */
.game-wrap { display: grid; gap: 22px; }
@media (min-width: 860px) { .game-wrap { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } }

.game-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
@media (min-width: 860px) { .game-panel { position: sticky; top: 78px; } }

.mode-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.mode-tabs button {
  flex: 1 1 auto;
  min-width: 70px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 12px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.14s ease;
}
.mode-tabs button:hover { color: var(--text); }
.mode-tabs button[aria-selected="true"] { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #241a02; border-color: transparent; }

.board-shell { position: relative; }
.board {
  --n: 8;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  touch-action: manipulation;
  user-select: none;
}
.sq {
  position: relative;
  border: 0;
  padding: 0;
  margin: 0;
  font-family: var(--font-body);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: clamp(0.55rem, 2.4vw, 0.95rem);
  font-weight: 700;
  color: var(--sq-text);
  background: var(--sq-dark);
  transition: background 0.12s ease;
}
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.visited.light { background: var(--sq-visit-light); }
.sq.visited.dark { background: var(--sq-visit-dark); }
.sq:focus-visible { outline: 3px solid var(--teal); outline-offset: -3px; z-index: 3; }
.sq .num {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 0.62em;
  opacity: 0.72;
  font-weight: 700;
}
.sq.goal::before {
  content: "★";
  font-size: 0.9em;
  color: color-mix(in srgb, var(--teal) 80%, #000);
  opacity: 0.85;
}
.sq.legal::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26%;
  height: 26%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: color-mix(in srgb, var(--teal) 85%, #000 5%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 30%, transparent);
  opacity: 0.9;
}
.sq.dead::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg, rgba(255, 122, 107, 0.28) 0 6px, transparent 6px 12px);
}
.sq.blocked { background: repeating-linear-gradient(45deg, var(--surface-2) 0 6px, var(--border) 6px 12px); cursor: not-allowed; }
.sq.obstacle::before {
  content: "✖";
  color: var(--muted);
  font-size: 0.8em;
}
.piece {
  font-size: 1.7em;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
  animation: hop 0.22s ease;
}
@keyframes hop { from { transform: scale(0.6) translateY(-6px); opacity: 0.3; } to { transform: none; opacity: 1; } }
.piece.black { color: #1b1b1b; }
.piece.white { color: #fdfdfd; text-shadow: 0 0 2px #000; }

.board-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(3px);
  text-align: center;
  padding: 20px;
}
.board-overlay .card { max-width: 320px; }
.board-overlay h3 { margin-bottom: 6px; }

.game-status { margin-top: 12px; min-height: 46px; }
.status-line { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.status-line .big { font-family: var(--font-display); font-size: 1.4rem; color: var(--gold); }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 6px; border: 1px solid var(--border); }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width 0.2s ease; }
.hint-msg { font-size: 0.88rem; color: var(--muted); margin-top: 6px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.controls .btn { flex: 1 1 auto; }
.opt-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; font-size: 0.85rem; color: var(--muted); }
.opt-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
select, input[type="checkbox"] { accent-color: var(--gold); }
select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-family: var(--font-body);
  font-size: 0.85rem;
}

.side-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.side-card + .side-card { margin-top: 16px; }
.side-card h3 { margin-bottom: 8px; }
.best-list { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.best-list li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.best-list li:last-child { border-bottom: 0; }
.best-list .v { font-weight: 700; color: var(--gold); }

.level-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.level-list li { margin-bottom: 6px; }
.level-btn {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 11px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  font-family: var(--font-body);
}
.level-btn:hover { border-color: var(--gold); }
.level-btn .stars { color: var(--gold); letter-spacing: 1px; font-size: 0.8rem; }
.level-btn .meta { font-size: 0.72rem; color: var(--muted); }
.level-btn[aria-current="true"] { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 14%, var(--surface-2)); }

/* ---------- Quiz ---------- */
.quiz-shell { max-width: 720px; margin: 0 auto; }
.q-progress { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.q-dot { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-size: 0.6rem; color: var(--muted); display: grid; place-items: center; font-weight: 700; }
.q-dot.ok { background: var(--teal); color: #04231d; border-color: transparent; }
.q-dot.bad { background: var(--coral); color: #2a0703; border-color: transparent; }
.q-dot.now { outline: 3px solid var(--gold); outline-offset: 1px; }
.opt {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.98rem;
  transition: all 0.14s ease;
}
.opt:hover { border-color: var(--gold); transform: translateX(2px); }
.opt.correct { border-color: var(--teal); background: color-mix(in srgb, var(--teal) 16%, var(--surface)); }
.opt.wrong { border-color: var(--coral); background: color-mix(in srgb, var(--coral) 16%, var(--surface)); }
.opt[disabled] { cursor: default; transform: none; }

/* ---------- Timeline ---------- */
.timeline { position: relative; margin: 0; padding: 0 0 0 26px; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--gold), var(--teal)); }
.timeline li { position: relative; margin-bottom: 20px; }
.timeline li::before { content: ""; position: absolute; left: -24px; top: 8px; width: 12px; height: 12px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px var(--bg); }
.timeline .year { font-family: var(--font-display); font-weight: 800; color: var(--gold); font-size: 1.05rem; }
.timeline h3 { margin: 2px 0 4px; font-size: 1.05rem; }
.tag { display: inline-block; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--teal); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; margin-left: 6px; vertical-align: middle; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
tbody tr:hover { background: var(--surface-2); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }

.chip-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 640px) { .chip-grid { grid-template-columns: repeat(3, 1fr); } }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 10px; font-size: 0.86rem; }
.chip b { color: var(--gold); }

/* ---------- Share / result ---------- */
.result-card {
  border: 2px solid var(--gold);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.result-card .big { font-family: var(--font-display); font-size: 2rem; color: var(--gold); }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.banner {
  border: 1px solid var(--teal);
  background: color-mix(in srgb, var(--teal) 12%, var(--surface));
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.banner .grow { flex: 1 1 200px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 50px; padding: 30px 0; color: var(--muted); font-size: 0.88rem; }
.site-footer .cols { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .site-footer .cols { grid-template-columns: 2fr 1fr 1fr; } }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--gold); }
.site-footer h4 { color: var(--text); font-family: var(--font-body); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.fact-list { list-style: none; margin: 0; padding: 0; }
.fact-list li { padding: 8px 0 8px 28px; position: relative; border-bottom: 1px dashed var(--border); }
.fact-list li::before { content: "♞"; position: absolute; left: 0; top: 8px; color: var(--gold); }
.fact-list li:last-child { border-bottom: 0; }

kbd {
  font-family: ui-monospace, monospace;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.82em;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .float { animation: none !important; }
}

@media (max-width: 640px) {
  .site-header .container { flex-wrap: wrap; }
  .brand { font-size: 1rem; }
  .nav { margin-left: 0; width: 100%; justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
  .nav a { padding: 7px 9px; font-size: 0.86rem; }
  h1 { font-size: clamp(1.9rem, 9vw, 2.6rem); }
  .mode-tabs button { min-width: 0; }
}

