/* =========================================================================
   OMSR CHESS — design system
   Midnight & Gold. Premium and restrained: the gamified skeleton (path, XP,
   streak, hearts) is kept, but the chunky cartoon styling is toned down —
   thinner borders, softer presses, tighter type, real shadows.
   ========================================================================= */

/* ------------------------------------------------------------------ reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

/* ----------------------------------------------------------------- tokens */
:root {
  --gold:        #F0B429;
  --gold-dark:   #C88A06;
  --gold-deep:   #A06E05;
  --gold-soft:   rgba(240, 180, 41, .14);

  --blue:        #3B82F6;
  --blue-dark:   #2563EB;
  --blue-soft:   rgba(59, 130, 246, .14);

  --green:       #16A34A;
  --green-dark:  #12813B;
  --green-soft:  rgba(22, 163, 74, .14);

  --red:         #DC2626;
  --red-dark:    #B91C1C;
  --red-soft:    rgba(220, 38, 38, .14);

  --violet:      #8B5CF6;
  --violet-dark: #6D3EE0;
  --teal:        #0D9488;
  --teal-dark:   #0B7D73;
  --orange:      #EA7C1B;
  --orange-dark: #C2620C;

  /* dark is the default identity for this brand */
  --bg:          #0F172A;
  --bg-alt:      #16213A;
  --bg-sunken:   #0A1120;
  --card:        #1B2942;
  --card-2:      #22334F;
  --ink:         #D9E2F0;
  --ink-strong:  #FFFFFF;
  --ink-mute:    #8FA3BF;
  --line:        #2A3B57;
  --line-strong: #3A4E70;

  --sq-light:    #EADBC0;
  --sq-dark:     #7C5C3E;
  --sq-sel:      rgba(240, 180, 41, .55);
  --sq-last:     rgba(240, 180, 41, .34);
  --sq-check:    #E5484D;

  --pc-white-fill: #FAF4E6;
  --pc-white-line: #2B2317;
  --pc-black-fill: #2A2E3F;
  --pc-black-line: #0E1119;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 4px 14px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 44px rgba(0,0,0,.45);

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
  --font: 'Segoe UI Variable Display', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Cascadia Mono', 'SF Mono', Consolas, monospace;
  --sidebar: 236px;
  --rail: 176px;
}

[data-theme="light"] {
  --bg:          #FBF9F4;
  --bg-alt:      #F3EFE6;
  --bg-sunken:   #EBE6DA;
  --card:        #FFFFFF;
  --card-2:      #F7F4ED;
  --ink:         #33405A;
  --ink-strong:  #131C2E;
  --ink-mute:    #6B7A93;
  --line:        #E2DACA;
  --line-strong: #CDC2AC;
  --gold-soft:   rgba(240, 180, 41, .18);
  --shadow-sm: 0 1px 2px rgba(30,25,10,.10);
  --shadow-md: 0 4px 14px rgba(30,25,10,.10);
  --shadow-lg: 0 16px 44px rgba(30,25,10,.16);
  --pc-black-fill: #3A3020;
  --pc-black-line: #16110A;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  color: var(--ink-strong); margin: 0 0 .4em; line-height: 1.18;
  letter-spacing: -.021em; font-weight: 700;
}
h1 { font-size: clamp(1.55rem, 3.2vw, 2.15rem); letter-spacing: -.03em; }
h2 { font-size: clamp(1.18rem, 2.2vw, 1.45rem); }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .85em; }
strong { color: var(--ink-strong); font-weight: 650; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.eyebrow {
  font-size: .68rem; font-weight: 700; letter-spacing: .13em;
  text-transform: uppercase; color: var(--ink-mute);
}

/* --------------------------------------------------------------- buttons */
.btn {
  --b: var(--gold); --bd: var(--gold-dark); --fg: #26200C;
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  background: var(--b); color: var(--fg);
  font-weight: 650; font-size: .9rem; letter-spacing: .005em;
  padding: .66em 1.15em; border-radius: var(--r-md);
  box-shadow: 0 2px 0 var(--bd), var(--shadow-sm);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--bd); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.blue   { --b: var(--blue);   --bd: var(--blue-dark);   --fg: #fff; }
.btn.green  { --b: var(--green);  --bd: var(--green-dark);  --fg: #fff; }
.btn.red    { --b: var(--red);    --bd: var(--red-dark);    --fg: #fff; }
.btn.violet { --b: var(--violet); --bd: var(--violet-dark); --fg: #fff; }
.btn.teal   { --b: var(--teal);   --bd: var(--teal-dark);   --fg: #fff; }
.btn.orange { --b: var(--orange); --bd: var(--orange-dark); --fg: #fff; }
.btn.ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-strong); box-shadow: none;
}
.btn.ghost:hover { background: var(--card-2); border-color: var(--gold); color: var(--ink-strong); }
.btn.ghost:active { transform: translateY(1px); }
.btn.sm { padding: .42em .8em; font-size: .8rem; border-radius: var(--r-sm); }
.btn.lg { padding: .85em 1.7em; font-size: 1rem; }
.btn.wide { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: .3em;
  padding: .2em .58em; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line);
  font-size: .7rem; font-weight: 650; letter-spacing: .03em;
  color: var(--ink-mute); white-space: nowrap;
}
.chip.g { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.chip.b { background: var(--blue-soft);  border-color: var(--blue);  color: var(--blue); }
.chip.r { background: var(--red-soft);   border-color: var(--red);   color: var(--red); }
.chip.y { background: var(--gold-soft);  border-color: var(--gold);  color: var(--gold); }
.chip.p { background: rgba(139,92,246,.14); border-color: var(--violet); color: var(--violet); }
[data-theme="light"] .chip.y { color: var(--gold-deep); }
[data-theme="light"] .chip.g { color: var(--green-dark); }

/* ----------------------------------------------------------------- layout */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 1rem .65rem; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: .12rem;
  background: var(--bg-alt); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: .3rem .45rem 1.1rem; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 auto; display: block; }
.brand-mark .logo-mark { width: 100%; height: 100%; display: block; border-radius: 10px; box-shadow: var(--shadow-sm); }
.brand:hover .brand-mark .logo-mark { filter: brightness(1.08); }
.brand-name { font-weight: 750; font-size: 1.05rem; letter-spacing: -.02em; color: var(--ink-strong); line-height: 1.1; }
.brand-name small {
  display: block; font-size: .58rem; font-weight: 650; letter-spacing: .16em;
  color: var(--gold); text-transform: uppercase; margin-top: 1px;
}

.nav-item {
  display: flex; align-items: center; gap: .65rem; width: 100%;
  padding: .5rem .6rem; border-radius: var(--r-sm);
  font-weight: 550; font-size: .875rem; letter-spacing: .002em;
  color: var(--ink-mute); border: 1px solid transparent; text-align: left;
  transition: background .13s, color .13s;
}
.nav-item .ic { font-size: 1.02rem; width: 1.3em; text-align: center; opacity: .95; }
.nav-item:hover { background: var(--card-2); color: var(--ink); }
.nav-item.active {
  background: var(--gold-soft); border-color: rgba(240,180,41,.32);
  color: var(--ink-strong); font-weight: 650;
}
.nav-item.active .ic { filter: none; }
.nav-sep { height: 1px; background: var(--line); margin: .55rem .5rem; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  padding: .6rem 1.1rem; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(15,23,42,.86); z-index: 30;
  backdrop-filter: blur(10px);
}
[data-theme="light"] .topbar { background: rgba(251,249,244,.88); }
.topbar .spacer { flex: 1; }
.stat {
  display: inline-flex; align-items: center; gap: .3rem;
  font-weight: 700; font-size: .86rem; color: var(--ink-strong);
  padding: .22rem .5rem; border-radius: var(--r-sm);
}
.stat .ic { font-size: .95rem; }
.stat.fire  { color: var(--orange); }
.stat.gem   { color: var(--blue); }
.stat.heart { color: var(--red); }
.stat.xp    { color: var(--gold); }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { background: var(--card-2); }

.view { padding: 1.3rem clamp(.9rem, 2.6vw, 2rem) 4.5rem; max-width: 1180px; width: 100%; margin: 0 auto; }
.view.narrow { max-width: 820px; }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 1rem 1.1rem; box-shadow: var(--shadow-sm);
}
.card.tight { padding: .75rem .85rem; }
.card.gold { border-color: rgba(240,180,41,.4); background: linear-gradient(180deg, var(--gold-soft), transparent 60%), var(--card); }
.card-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); }
.row { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }
.row.tight { gap: .3rem; }
.stack { display: flex; flex-direction: column; gap: .85rem; }
.muted { color: var(--ink-mute); }
.center { text-align: center; }
.hidden { display: none !important; }

.section-head { display: flex; align-items: flex-end; gap: .7rem; flex-wrap: wrap; margin: 1.5rem 0 .8rem; }
.section-head h2 { margin: 0; }
.section-head p { margin: 0; font-size: .9rem; }

.bar { height: 8px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--gold); transition: width .45s cubic-bezier(.2,.9,.3,1); }
.bar.blue > i  { background: var(--blue); }
.bar.green > i { background: var(--green); }
.bar.thin { height: 5px; }

.ring { --p: 0; width: 58px; height: 58px; flex: 0 0 auto; position: relative; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring .track { stroke: var(--bg-sunken); }
.ring .fill { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.2,.9,.3,1); }
.ring .label { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 1.15rem; color: var(--ink-strong); }

/* --------------------------------------------------------------- the path */
.path { position: relative; padding: .5rem 0 2rem; overflow-x: clip; }
.path-unit { margin-bottom: 1.9rem; }
.unit-head {
  display: flex; align-items: center; gap: .8rem; justify-content: space-between;
  background: linear-gradient(135deg, var(--card-2), var(--card));
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--gold);
  color: var(--ink-strong); padding: .7rem .95rem;
  border-radius: var(--r-md); margin-bottom: 1.4rem; box-shadow: var(--shadow-sm);
}
.unit-head.blue   { border-left-color: var(--blue); }
.unit-head.violet { border-left-color: var(--violet); }
.unit-head.orange { border-left-color: var(--orange); }
.unit-head.teal   { border-left-color: var(--teal); }
.unit-head.green  { border-left-color: var(--green); }
.unit-head h3 { margin: 0 0 .1rem; font-size: .98rem; }
.unit-head small { color: var(--ink-mute); font-weight: 450; font-size: .82rem; }
.unit-pct { font-weight: 700; white-space: nowrap; color: var(--gold); font-size: .95rem; }

.nodes { display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.node-row { display: flex; justify-content: center; width: 100%; }
.node {
  --c: var(--card-2); --cd: var(--line-strong); --fg: var(--ink);
  position: relative; width: 62px; height: 62px; border-radius: 18px;
  background: var(--c); border: 1px solid var(--cd);
  box-shadow: 0 3px 0 var(--cd), var(--shadow-sm);
  display: grid; place-items: center; font-size: 1.5rem; color: var(--fg);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.node.open {
  --c: linear-gradient(160deg, var(--card-2), var(--card));
  --cd: var(--line-strong); border-color: var(--gold); color: var(--gold);
}
.node:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--cd), var(--shadow-md); }
.node:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--cd); }
.node.locked { opacity: .45; color: var(--ink-mute); border-color: var(--line); }
.node.done {
  background: linear-gradient(160deg, var(--gold), var(--gold-deep));
  border-color: var(--gold); color: #241B06;
  box-shadow: 0 3px 0 var(--gold-deep), 0 0 22px rgba(240,180,41,.22);
}
.node-label {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: .45rem; font-size: .68rem; font-weight: 600;
  letter-spacing: .01em; color: var(--ink-mute); white-space: nowrap;
  max-width: 140px; overflow: hidden; text-overflow: ellipsis;
}
.node-crown { position: absolute; top: -7px; right: -5px; font-size: .8rem; }
.node-wrap { display: flex; flex-direction: column; align-items: center; margin-bottom: 1.35rem; }

/* ------------------------------------------------------------------ board */
.board-layout {
  display: grid; gap: 1rem;
  grid-template-columns: minmax(280px, 1fr) minmax(270px, 355px);
  align-items: start;
}
@media (max-width: 900px) { .board-layout { grid-template-columns: 1fr; } }

.board-frame { display: flex; gap: .5rem; align-items: stretch; }

.board {
  position: relative; width: 100%; aspect-ratio: 1;
  border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--line-strong); user-select: none; touch-action: none;
  background: var(--sq-light); box-shadow: var(--shadow-md);
}
.squares { position: absolute; inset: 0; display: grid; grid-template: repeat(8, 1fr) / repeat(8, 1fr); }
.sq { position: relative; }
.sq.light { background: var(--sq-light); }
.sq.dark  { background: var(--sq-dark); }
.sq.last::after     { content: ''; position: absolute; inset: 0; background: var(--sq-last); }
.sq.selected::after { content: ''; position: absolute; inset: 0; background: var(--sq-sel); }
.sq.in-check::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, var(--sq-check) 14%, transparent 70%); }
.sq.hover { box-shadow: inset 0 0 0 3px rgba(255,255,255,.8); }
.sq.mark-good::after { content: ''; position: absolute; inset: 0; background: var(--green); opacity: .45; }
.sq.mark-bad::after  { content: ''; position: absolute; inset: 0; background: var(--red); opacity: .45; }
.sq.mark-hint::after { content: ''; position: absolute; inset: 0; background: var(--gold); opacity: .45; }
.sq.shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-5px)} 40%{transform:translateX(5px)} 60%{transform:translateX(-3px)} 80%{transform:translateX(3px)} }

.pieces, .hints { position: absolute; inset: 0; pointer-events: none; }
.pc {
  position: absolute; width: 12.5%; height: 12.5%; top: 0; left: 0;
  transition: transform .16s cubic-bezier(.2,.9,.3,1); will-change: transform;
  display: grid; place-items: center;
}
.pc.dragging { z-index: 20; transition: none; filter: drop-shadow(0 6px 9px rgba(0,0,0,.45)); }
.piece-svg { width: 94%; height: 94%; display: block; overflow: visible; }

/* contact shadow on the square */
.pc-drop { fill: url(#omsrShadow); opacity: .55; }
[data-theme="light"] .pc-drop { opacity: .42; }

/* body: gradient fill, crisp outline, rounded joins */
.pc-art .pc-body { stroke-linejoin: round; stroke-linecap: round; }
.pc-white .pc-art .pc-body { fill: url(#omsrW); stroke: var(--pc-white-line); stroke-width: 3; }
.pc-black .pc-art .pc-body { fill: url(#omsrB); stroke: var(--pc-black-line); stroke-width: 3; }

/* rim highlight — reads as polished, turned material */
.pc-art .pc-gloss { fill: none; stroke-linecap: round; stroke-width: 2.6; }
.pc-white .pc-art .pc-gloss { stroke: #FFFFFF; opacity: .8; }
.pc-black .pc-art .pc-gloss { stroke: #9A94BE; opacity: .5; }

/* occlusion where one form meets the next */
.pc-art .pc-shade { stroke: none; }
.pc-white .pc-art .pc-shade { fill: #A98F63; opacity: .35; }
.pc-black .pc-art .pc-shade { fill: #000000; opacity: .38; }

/* knight details */
.pc-art .pc-mane { fill: none; stroke-width: 3; stroke-linecap: round; }
.pc-white .pc-art .pc-mane { stroke: var(--pc-white-line); opacity: .4; }
.pc-black .pc-art .pc-mane { stroke: #9A94BE; opacity: .45; }
.pc-art .pc-ear { stroke-linejoin: round; stroke-width: 2.4; }
.pc-white .pc-art .pc-ear { fill: #DCC9A4; stroke: var(--pc-white-line); }
.pc-black .pc-art .pc-ear { fill: #14121C; stroke: var(--pc-black-line); }
.pc-art .pc-eye { stroke: none; }
.pc-white .pc-art .pc-eye { fill: #3A2E19; }
.pc-black .pc-art .pc-eye { fill: #CFC6EA; }

/* bishop mitre slit */
.pc-art .pc-slit { fill: none; stroke-width: 3.4; stroke-linecap: round; }
.pc-white .pc-art .pc-slit { stroke: var(--pc-white-line); opacity: .55; }
.pc-black .pc-art .pc-slit { stroke: #0D0B13; opacity: .8; }

.hint { position: absolute; width: 12.5%; height: 12.5%; display: grid; place-items: center; }
.hint.dot::before { content: ''; width: 26%; height: 26%; border-radius: 50%; background: rgba(30,20,10,.33); }
.hint.cap::before { content: ''; width: 84%; height: 84%; border-radius: 50%; border: 5px solid rgba(30,20,10,.3); box-sizing: border-box; }
.arrows { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.arrows .arrow { stroke-width: .16; fill: none; opacity: .85; stroke-linecap: round; }
.arrows .arrow.good { stroke: var(--green); }
.arrows .arrow.best { stroke: var(--gold); }
.arrows .arrow.bad  { stroke: var(--red); }
.arrows .arrow.alt  { stroke: var(--blue); }

.board.flash-good { animation: fg .5s; }
.board.flash-bad  { animation: fb .5s; }
@keyframes fg { 0%,100%{box-shadow:var(--shadow-md)} 35%{box-shadow: inset 0 0 0 5px var(--green), var(--shadow-md)} }
@keyframes fb { 0%,100%{box-shadow:var(--shadow-md)} 35%{box-shadow: inset 0 0 0 5px var(--red), var(--shadow-md)} }

/* Coordinates sit OUTSIDE the board in their own gutters, so they are always
   legible and never overlap a piece. */
.board-grid {
  display: grid;
  grid-template-columns: var(--coord-w, 1.25rem) 1fr;
  grid-template-rows: 1fr var(--coord-w, 1.25rem);
  width: 100%;
}
.board-grid > .board { grid-column: 2; grid-row: 1; }
.coords-rank { grid-column: 1; grid-row: 1; display: grid; grid-template-rows: repeat(8, 1fr); }
.coords-corner { grid-column: 1; grid-row: 2; }
.coords-file { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: repeat(8, 1fr); }
.coords-rank span, .coords-file span {
  display: grid; place-items: center;
  font-size: clamp(.6rem, 1.5vw, .78rem); font-weight: 650;
  color: var(--ink-mute); font-variant-numeric: tabular-nums; user-select: none;
}
.board-grid.no-coords { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.board-grid.no-coords > .board { grid-column: 1; grid-row: 1; }
.board-grid.no-coords .coords-rank,
.board-grid.no-coords .coords-file,
.board-grid.no-coords .coords-corner { display: none; }

.promo-pick {
  position: absolute; z-index: 40; left: calc(var(--x) * 12.5%); top: calc(var(--y) * 12.5%);
  width: 12.5%; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--gold); border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.promo-btn { aspect-ratio: 1; display: grid; place-items: center; padding: 4%; }
.promo-btn:hover { background: var(--gold-soft); }
.promo-btn.cancel { aspect-ratio: auto; padding: .25rem; font-weight: 700; color: var(--ink-mute); background: var(--card-2); }

.evalbar {
  width: 16px; flex: 0 0 16px; border-radius: 999px; overflow: hidden;
  background: var(--pc-black-fill); border: 1px solid var(--line-strong);
  position: relative; display: flex; flex-direction: column-reverse;
}
.evalbar > i { display: block; background: var(--pc-white-fill); transition: height .35s ease; height: 50%; }
.evalbar .mid { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--gold); opacity: .65; }
.eval-num { font-weight: 700; text-align: center; font-size: .76rem; font-family: var(--mono); }

/* --------------------------------------------------------------- move list */
.moves {
  display: grid; grid-template-columns: 2.1rem 1fr 1fr; gap: 1px 5px;
  font-size: .86rem; max-height: 236px; overflow-y: auto; align-content: start;
  font-family: var(--mono);
}
.moves .no { color: var(--ink-mute); text-align: right; }
.moves .mv { padding: .08rem .32rem; border-radius: 5px; font-weight: 600; cursor: pointer; text-align: left; }
.moves .mv:hover { background: var(--card-2); }
.moves .mv.current { background: var(--gold-soft); color: var(--gold); }
.moves .mv .tag { font-size: .78em; margin-left: .18em; }
.tag-best, .tag-excellent { color: var(--green); }
.tag-good { color: var(--teal); }
.tag-inaccuracy { color: var(--gold); }
.tag-mistake { color: var(--orange); }
.tag-blunder { color: var(--red); }

.captured { display: flex; flex-wrap: wrap; gap: 1px; min-height: 1.1em; font-size: 1.05rem; line-height: 1; }
.captured .adv { font-size: .74rem; font-weight: 700; color: var(--ink-mute); margin-left: .3em; align-self: center; }

/* ------------------------------------------------------------ feedback bar */
.feedback {
  position: sticky; bottom: 0; z-index: 40; margin-top: 1rem;
  border-top: 1px solid var(--line); background: var(--card);
  padding: .85rem clamp(.9rem, 2.6vw, 1.7rem);
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
  border-radius: var(--r-md) var(--r-md) 0 0; box-shadow: var(--shadow-lg);
}
.feedback.good { background: linear-gradient(180deg, var(--green-soft), var(--card)); border-color: var(--green); }
.feedback.bad  { background: linear-gradient(180deg, var(--red-soft), var(--card)); border-color: var(--red); }
.feedback .fb-title { font-weight: 700; font-size: 1rem; color: var(--ink-strong); }
.feedback.good .fb-title { color: var(--green); }
.feedback.bad  .fb-title { color: var(--red); }
.feedback .fb-body { flex: 1; min-width: 190px; font-size: .89rem; }
.mascot { width: 50px; height: 50px; flex: 0 0 auto; }
.mascot .m-body { fill: var(--gold); stroke: var(--gold-deep); stroke-width: 3.5; stroke-linejoin: round; }
.mascot .m-ear { fill: var(--gold-deep); }
.mascot .m-face circle { fill: #2A1F06; }
.mascot .m-face path { fill: none; stroke: #2A1F06; stroke-width: 3.5; stroke-linecap: round; }
.mascot .m-mane { fill: none; stroke: var(--gold-deep); stroke-width: 4; stroke-linecap: round; }
.mascot .m-shadow { fill: rgba(0,0,0,.16); }
.mascot-sad .m-body { fill: var(--red); stroke: var(--red-dark); }
.mascot-sad .m-ear, .mascot-sad .m-mane { stroke: var(--red-dark); fill: var(--red-dark); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confetti i { position: absolute; top: -14px; width: 8px; height: 12px; border-radius: 1px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .15; } }

/* --------------------------------------------------------------- variation */
.var-list { display: flex; flex-direction: column; gap: .3rem; }
.var-item {
  display: flex; gap: .55rem; align-items: flex-start; text-align: left; width: 100%;
  padding: .5rem .65rem; border-radius: var(--r-sm); border: 1px solid var(--line); background: transparent;
  transition: border-color .12s, background .12s;
}
.var-item:hover, .var-item.active { border-color: var(--gold); background: var(--gold-soft); }
.var-item .vn { font-weight: 650; color: var(--ink-strong); font-size: .88rem; }
.var-item .vm { font-family: var(--mono); font-size: .76rem; color: var(--ink-mute); }
.var-item .vnote { font-size: .8rem; color: var(--ink-mute); }

.idea-list { margin: 0; padding-left: 1.05rem; }
.idea-list li { margin-bottom: .4rem; }

.pill-row { display: flex; gap: .3rem; flex-wrap: wrap; }
.filter-btn {
  padding: .34rem .72rem; border-radius: 999px; border: 1px solid var(--line);
  font-weight: 600; font-size: .76rem; color: var(--ink-mute); background: transparent;
  transition: all .12s;
}
.filter-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.filter-btn.on { background: var(--gold); border-color: var(--gold); color: #241B06; }

.search {
  width: 100%; padding: .68rem .9rem; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 500;
}
.search:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px var(--gold-soft); }
.search::placeholder { color: var(--ink-mute); }

.op-card {
  display: flex; flex-direction: column; gap: .45rem; text-align: left; cursor: pointer;
  transition: transform .13s, border-color .13s, box-shadow .13s;
}
.op-card:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.op-card .oc-top { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.op-card h3 { margin: 0; font-size: .96rem; }
.op-card .oc-moves { font-family: var(--mono); font-size: .78rem; color: var(--gold); font-weight: 600; }
.op-card .oc-tag { font-size: .83rem; color: var(--ink-mute); margin: 0; }
.dots { display: flex; gap: 2px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.dots i.on { background: var(--gold); }

/* ---------------------------------------------------------------- overlay */
.modal-back {
  position: fixed; inset: 0; background: rgba(6,11,22,.72); z-index: 300;
  display: grid; place-items: center; padding: 1rem; backdrop-filter: blur(4px);
}
.modal {
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--r-xl);
  padding: 1.5rem; max-width: 440px; width: 100%; text-align: center;
  box-shadow: var(--shadow-lg);
}
.modal.wide { max-width: 620px; }
.modal h2 { margin-bottom: .3rem; }

/* -------------------------------------------------------------- utilities */
.kv { display: grid; grid-template-columns: auto 1fr; gap: .25rem .9rem; font-size: .88rem; }
.kv dt { color: var(--ink-mute); }
.kv dd { margin: 0; font-weight: 650; color: var(--ink-strong); text-align: right; }

.big-num { font-size: 1.75rem; font-weight: 750; color: var(--ink-strong); line-height: 1; }
.stat-tile { display: flex; flex-direction: column; gap: .18rem; align-items: center; text-align: center; }
.stat-tile small { font-size: .66rem; letter-spacing: .09em; text-transform: uppercase; font-weight: 650; color: var(--ink-mute); }

/* ======================================================== ADS & MONETISING
   Deliberately restrained: rails only appear when there is genuinely spare
   width, nothing ever covers the board, and no interstitials. */
.ad-rail {
  width: var(--rail); flex: 0 0 var(--rail);
  padding: 1rem .5rem; position: sticky; top: 0; align-self: flex-start;
  height: 100vh; display: none; flex-direction: column; gap: .8rem;
  border-left: 1px solid var(--line);
}
/* only show the rail when the window is wide enough that it costs nothing */
@media (min-width: 1400px) { .ad-rail.on { display: flex; } }

.ad-slot {
  position: relative; background: var(--card); border: 1px dashed var(--line-strong);
  border-radius: var(--r-md); display: grid; place-items: center; overflow: hidden;
  min-height: 90px; color: var(--ink-mute);
}
.ad-slot.rail { min-height: 600px; }
.ad-slot.leaderboard { min-height: 90px; width: 100%; margin: .9rem 0; }
.ad-slot.inline { min-height: 110px; width: 100%; margin: .9rem 0; }
.ad-label {
  position: absolute; top: 5px; left: 7px; font-size: .55rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-mute); opacity: .75; font-weight: 650;
}
.ad-house { padding: 1rem .8rem; text-align: center; }
.ad-house h4 { margin: 0 0 .3rem; font-size: .88rem; color: var(--ink-strong); }
.ad-house p { margin: 0 0 .7rem; font-size: .76rem; color: var(--ink-mute); line-height: 1.45; }

.ad-anchor {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: var(--card); border-top: 1px solid var(--line);
  padding: .35rem .6rem; display: none; align-items: center; gap: .5rem;
  box-shadow: 0 -4px 14px rgba(0,0,0,.25);
}
.ad-anchor.on { display: flex; }
.ad-anchor .ad-slot { min-height: 50px; flex: 1; border: 0; background: transparent; }
.ad-anchor .close { color: var(--ink-mute); font-size: 1rem; padding: .2rem .4rem; }

.pro-badge {
  display: inline-flex; align-items: center; gap: .25rem; padding: .12rem .45rem;
  border-radius: 999px; font-size: .62rem; font-weight: 750; letter-spacing: .08em;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep)); color: #241B06;
}

.price-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.price-card { display: flex; flex-direction: column; gap: .6rem; position: relative; }
.price-card.featured { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), var(--shadow-md); }
.price-card .amount { font-size: 2rem; font-weight: 750; color: var(--ink-strong); line-height: 1; }
.price-card .amount small { font-size: .82rem; font-weight: 500; color: var(--ink-mute); }
.price-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; font-size: .87rem; }
.price-card li::before { content: '✓'; color: var(--green); font-weight: 700; margin-right: .45rem; }
.price-card li.off { color: var(--ink-mute); }
.price-card li.off::before { content: '—'; color: var(--ink-mute); }
.ribbon {
  position: absolute; top: -1px; right: 14px; background: var(--gold); color: #241B06;
  font-size: .6rem; font-weight: 750; letter-spacing: .09em; padding: .18rem .5rem;
  border-radius: 0 0 6px 6px;
}

.heart-row { display: flex; gap: .25rem; align-items: center; justify-content: center; font-size: 1.5rem; }
.heart-row .h { filter: grayscale(1) opacity(.32); }
.heart-row .h.on { filter: none; }

.reward-timer {
  width: 100%; height: 6px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; margin: .8rem 0;
}
.reward-timer > i { display: block; height: 100%; background: var(--gold); width: 0%; }

.donate-tile { display: flex; align-items: center; gap: .7rem; text-decoration: none; }
.donate-tile .ic { font-size: 1.5rem; }

/* ==================================================== LANDING / HOME PAGE */
.landing { padding: 0 0 4rem; max-width: none; }
.landing section { padding: 0 clamp(1rem, 5vw, 3rem); }
.landing .wrap { max-width: 1080px; margin: 0 auto; }

.hero {
  position: relative; min-height: min(88vh, 760px);
  display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; gap: 2rem;
  padding-top: 2rem; padding-bottom: 2rem; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: -20% -10% auto -10%; height: 70%;
  background: radial-gradient(ellipse at 30% 30%, var(--gold-soft), transparent 62%);
  pointer-events: none;
}
.hero-copy { position: relative; z-index: 2; }
.hero h1 {
  font-size: clamp(2.1rem, 6vw, 3.9rem); line-height: 1.03; letter-spacing: -.035em; margin: .5rem 0 .7rem;
}
.hero h1 .grad {
  background: linear-gradient(103deg, var(--gold) 8%, #FFE9A8 46%, var(--gold-dark) 92%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { font-size: clamp(1rem, 1.7vw, 1.2rem); color: var(--ink-mute); max-width: 46ch; margin-bottom: 1.5rem; }
.hero-cta { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }
.hero-note { font-size: .8rem; color: var(--ink-mute); margin-top: 1.1rem; }

.hero-stage {
  position: relative; z-index: 1; display: grid; place-items: center;
  min-height: 420px; perspective: 1100px;
}

/* Layered extrusion: many copies of the silhouette pushed back in Z build a
   solid-looking form that genuinely turns as you scroll. */
.hero-piece { width: min(400px, 74vw); aspect-ratio: 1 / 1.04; transform-style: preserve-3d; }
.hero-stack {
  position: relative; width: 100%; height: 100%; transform-style: preserve-3d;
  transform: rotateX(var(--rx, 8deg)) rotateY(var(--ry, -22deg));
  transition: transform .12s linear;
  animation: heroFloat 6s ease-in-out infinite;
}
@keyframes heroFloat { 0%,100% { translate: 0 0; } 50% { translate: 0 -14px; } }
.hero-layer { position: absolute; inset: 0; transform: translateZ(calc((var(--i) - 1) * 0.9px)); }
.hero-layer svg { width: 100%; height: 100%; display: block; }
.hero-layer .pc-body {
  fill: color-mix(in srgb, var(--gold-deep) calc(100% - var(--d) * 62%), #2B2110);
  stroke: none;
}
.hero-layer .pc-gloss, .hero-layer .pc-shade, .hero-layer .pc-slit,
.hero-layer .pc-mane, .hero-layer .pc-ear, .hero-layer .pc-eye, .hero-layer .pc-drop { display: none; }
.hero-face .pc-body {
  fill: url(#omsrHero); stroke: #6B4A05; stroke-width: 1.4; stroke-linejoin: round;
}
.hero-face .pc-mane { fill: none; stroke: #6B4A05; stroke-width: 2.2; opacity: .5; }
.hero-face .pc-ear { fill: #C88A06; stroke: #6B4A05; stroke-width: 1.8; }
.hero-face .pc-eye { fill: #2B2110; }
.hero-face .pc-gloss { fill: none; stroke: #FFF3D0; stroke-width: 2.2; opacity: .75; stroke-linecap: round; }
.hero-face .pc-shade { fill: #6B4A05; opacity: .3; }
.hero-face .pc-slit { fill: none; stroke: #6B4A05; stroke-width: 2.6; }
.hero-glow {
  position: absolute; width: 66%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, var(--gold-soft), transparent 68%);
  filter: blur(22px); z-index: -1;
}

.scroll-cue {
  position: absolute; bottom: 1.1rem; left: 50%; translate: -50% 0;
  font-size: .7rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-mute); display: flex; flex-direction: column; align-items: center; gap: .35rem;
}
.scroll-cue i { width: 1px; height: 26px; background: linear-gradient(var(--gold), transparent); animation: cue 1.9s ease-in-out infinite; }
@keyframes cue { 0%,100% { opacity: .25; height: 16px; } 50% { opacity: 1; height: 28px; } }

.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem;
  margin: 1rem 0 2.5rem;
}
.stat-strip .card { text-align: center; padding: 1rem .7rem; }
.stat-strip .n {
  font-size: clamp(1.5rem, 3.4vw, 2.2rem); font-weight: 750; line-height: 1;
  background: linear-gradient(120deg, var(--gold), #FFE9A8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-strip .l { font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-mute); margin-top: .3rem; font-weight: 650; }

.reveal { opacity: 0; translate: 0 26px; transition: opacity .7s ease, translate .7s cubic-bezier(.2,.9,.3,1); }
.reveal.in { opacity: 1; translate: 0 0; }

.feature-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; align-items: center;
  padding: 2.4rem 0; border-top: 1px solid var(--line);
}
.feature-row:nth-child(even) .feature-art { order: -1; }
.feature-row h3 { font-size: clamp(1.25rem, 2.6vw, 1.75rem); letter-spacing: -.025em; }
.feature-row p { color: var(--ink-mute); }
.feature-art {
  display: grid; place-items: center; min-height: 210px; border-radius: var(--r-lg);
  background: linear-gradient(150deg, var(--card-2), var(--card)); border: 1px solid var(--line);
  font-size: 4.4rem; position: relative; overflow: hidden;
}
.feature-art::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 25%, var(--gold-soft), transparent 60%);
}
.feature-list { list-style: none; padding: 0; margin: .8rem 0 0; display: flex; flex-direction: column; gap: .45rem; font-size: .92rem; }
.feature-list li::before { content: '♦'; color: var(--gold); margin-right: .55rem; font-size: .8em; }

.support-card {
  background: linear-gradient(150deg, var(--gold-soft), transparent 62%), var(--card);
  border: 1px solid rgba(240,180,41,.34); border-radius: var(--r-xl);
  padding: clamp(1.3rem, 3vw, 2.2rem); text-align: center;
}
.support-card .pig { font-size: 2.6rem; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; text-align: center; min-height: auto; padding-top: 1rem; }
  .hero-copy { order: 2; }
  .hero-stage { order: 1; min-height: 300px; }
  .hero-sub { margin-inline: auto; }
  .hero-cta { justify-content: center; }
  .hero-piece { width: min(280px, 62vw); }
  .feature-row { grid-template-columns: 1fr; gap: 1.1rem; padding: 1.8rem 0; }
  .feature-row:nth-child(even) .feature-art { order: 0; }
  .feature-art { min-height: 150px; font-size: 3.2rem; }
  .scroll-cue { display: none; }
}

/* ------------------------------------------------------------- responsive */
.mobile-nav { display: none; }

@media (max-width: 780px) {
  #app { flex-direction: column; }
  .sidebar { display: none; }
  .ad-rail { display: none !important; }
  main { padding-bottom: calc(4.4rem + env(safe-area-inset-bottom, 0px)); }

  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg-alt) 92%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: .3rem .15rem calc(.3rem + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
  }
  .mobile-nav .nav-item {
    flex-direction: column; gap: .12rem; padding: .38rem .2rem; font-size: .58rem;
    border-radius: var(--r-sm); text-align: center; letter-spacing: .01em;
    min-height: 46px; justify-content: center;          /* comfortable tap target */
  }
  .mobile-nav .nav-item .ic { font-size: 1.2rem; width: auto; }
  .mobile-nav .nav-item.active { background: transparent; border-color: transparent; color: var(--gold); }

  .view { padding: .8rem .7rem 2rem; }

  /* the board is the hero on a phone: give it the full width */
  .board-layout { gap: .7rem; }
  .board-frame { gap: .28rem; }
  .evalbar { width: 11px; flex-basis: 11px; }
  .board-grid { --coord-w: 1rem; }
  .board { border-radius: 10px; }

  /* stack the panel below the board, and keep controls thumb-reachable */
  .board-layout > .stack { gap: .6rem; }
  .moves { max-height: 168px; font-size: .82rem; }

  /* headers and cards get tighter */
  .topbar { padding: .5rem .7rem; gap: .3rem; position: sticky; }
  .topbar h2 { font-size: .9rem; }
  .stat { padding: .18rem .35rem; font-size: .8rem; }
  .stat .ic { font-size: .88rem; }
  .card { padding: .85rem .9rem; border-radius: var(--r-md); }
  .card-grid { grid-template-columns: 1fr; gap: .7rem; }
  .section-head { margin: 1.1rem 0 .6rem; }
  h1 { font-size: 1.45rem; }
  h2 { font-size: 1.12rem; }

  /* filter pills scroll sideways instead of wrapping into a wall */
  .pill-row {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch; padding-bottom: .2rem;
  }
  .pill-row::-webkit-scrollbar { display: none; }
  .filter-btn { flex: 0 0 auto; padding: .42rem .8rem; }

  /* every button comfortably tappable */
  .btn { padding: .72em 1.1em; }
  .btn.sm { padding: .52em .85em; font-size: .8rem; }
  .var-item { padding: .62rem .7rem; }

  /* the path gets narrower so nodes never clip off-screen */
  .node { width: 58px; height: 58px; font-size: 1.35rem; }
  .node-label { font-size: .62rem; max-width: 104px; }
  .node-wrap { margin-bottom: 1.2rem; }
  .nodes { gap: .8rem; }
  .unit-head { padding: .6rem .75rem; }

  .feedback { padding: .75rem .8rem calc(.75rem + env(safe-area-inset-bottom, 0px)); gap: .6rem; }
  .mascot { width: 40px; height: 40px; }
  .feedback .fb-title { font-size: .94rem; }
  .feedback .fb-body { min-width: 140px; font-size: .84rem; }

  .modal { padding: 1.15rem; border-radius: var(--r-lg); }
  .price-grid { grid-template-columns: 1fr; }

  body.has-anchor main { padding-bottom: calc(7.6rem + env(safe-area-inset-bottom, 0px)); }
  body.has-anchor .mobile-nav { bottom: 56px; }
}

/* very small phones */
@media (max-width: 380px) {
  .view { padding: .65rem .5rem 2rem; }
  .board-grid { --coord-w: .85rem; }
  .node { width: 52px; height: 52px; font-size: 1.2rem; }
  .mobile-nav .nav-item { font-size: .53rem; }
  .stat.gem, .stat.fire { display: none; }     /* keep the topbar from wrapping */
}

/* landscape phone: board beside the panel again */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
  .board-layout { grid-template-columns: minmax(0,1fr) minmax(210px, 300px); }
  .topbar { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print { .sidebar, .topbar, .mobile-nav, .ad-rail, .ad-anchor, .feedback { display: none !important; } }
