:root {
  --deep: #050a14;
  --navy: #0d1830;
  --panel: rgba(13, 24, 48, .82);
  --panel-2: rgba(18, 35, 61, .9);
  --line: rgba(77, 227, 255, .55);
  --cyan: #4de3ff;
  --pink: #ff5d8f;
  --text: #e8f1ff;
  --dim: #7d93b8;
  --green: #81b64c;
  --green-edge: #45753c;
  --light-sq: #ebecd0;
  --dark-sq: #739552;
  --last: rgba(255, 245, 105, .5);
  --mono: VT323, ui-monospace, Menlo, monospace;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--deep);
  color: var(--text);
  font: 15px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
a { color: var(--cyan); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }

/* ---- backdrop: dusk sky into night, pixel stars, CRT scanlines ---- */
.sky {
  position: fixed; inset: 0; z-index: -1;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 1px, transparent 1px 3px),
    radial-gradient(2px 2px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(2px 2px at 78% 9%, #fff9 50%, transparent 51%),
    radial-gradient(2px 2px at 55% 26%, #fff6 50%, transparent 51%),
    radial-gradient(2px 2px at 30% 40%, #fff5 50%, transparent 51%),
    radial-gradient(2px 2px at 90% 35%, #fff7 50%, transparent 51%),
    radial-gradient(2px 2px at 6% 62%, #fff4 50%, transparent 51%),
    radial-gradient(2px 2px at 67% 70%, #fff3 50%, transparent 51%),
    linear-gradient(180deg, #1c2d52 0%, #10203d 30%, #0a1428 60%, var(--deep) 100%);
}

/* ---- wordmark: CRT split ---- */
.mark { font-family: var(--mono); font-weight: 400; letter-spacing: .12em; text-decoration: none; color: var(--text); margin: 0; line-height: 1; }
.mark span { text-shadow: -3px 0 var(--pink), 3px 0 var(--cyan); }
.mark.big { font-size: clamp(64px, 14vw, 128px); }
.mark.big span { text-shadow: -5px 0 var(--pink), 5px 0 var(--cyan), 0 0 24px rgba(77,227,255,.35); }
.mark.small { font-size: 30px; }
.mark.small span { text-shadow: -2px 0 var(--pink), 2px 0 var(--cyan); }

.label {
  display: inline-block; font-family: var(--mono); font-size: 17px; letter-spacing: .14em;
  color: var(--deep); background: var(--cyan); padding: 0 8px; line-height: 20px;
}
.panel {
  position: relative; background: var(--panel); border: 2px solid var(--line);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 18px rgba(77,227,255,.18), inset 0 0 24px rgba(77,227,255,.05);
  padding: 22px 18px 18px;
}
.panel > .label { position: absolute; top: -11px; left: 14px; }

.go {
  font-family: var(--mono); font-size: 28px; letter-spacing: .14em;
  background: var(--panel); border: 2px solid var(--cyan); color: var(--text);
  box-shadow: 0 0 20px rgba(77,227,255,.35), inset 0 0 18px rgba(77,227,255,.12);
  padding: 12px 28px;
  transition: transform .08s, box-shadow .15s;
}
.go:hover { box-shadow: 0 0 30px rgba(77,227,255,.55), inset 0 0 22px rgba(77,227,255,.2); }
.go:active { transform: translateY(2px); }

/* Chess.com-style chunky green action */
.confirm {
  width: 100%; margin-top: 14px; font-family: var(--mono); font-size: 26px; letter-spacing: .12em;
  background: var(--green); color: #fff; border: 0; border-radius: 8px;
  box-shadow: 0 5px 0 var(--green-edge); padding: 10px 0 8px; text-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.confirm:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--green-edge); }
.confirm:disabled { background: #3b4a3a; box-shadow: 0 5px 0 #263026; color: #8a9a88; }

/* ---- header ---- */
.top {
  display: flex; align-items: center; gap: 18px; padding: 14px 20px; max-width: 1180px; margin: 0 auto;
}
.pips { display: flex; gap: 6px; margin-left: auto; }
.pips i { width: 22px; height: 12px; border: 2px solid var(--line); background: transparent; }
.pips i.on { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.pips i.done { border-color: transparent; }
.dayno { font-family: var(--mono); font-size: 20px; letter-spacing: .12em; color: var(--dim); }

/* ---- intro ---- */
.intro { text-align: center; max-width: 640px; margin: 4vh auto 0; padding: 0 16px; }
.intro .tag { font-family: var(--mono); font-size: 26px; letter-spacing: .5em; color: var(--cyan); margin: 14px 0 4px; }
.intro .sub { font-family: var(--mono); font-size: 21px; letter-spacing: .08em; color: var(--dim); margin: 0 0 30px; }
.intro .how { text-align: left; margin-bottom: 26px; }
.intro .how p { margin: 0; }
.intro .meta { font-family: var(--mono); color: var(--dim); font-size: 18px; letter-spacing: .1em; }
.c-brill { color: var(--cyan); }
.c-great { color: #8f9bff; }

/* ---- game layout ---- */
.game {
  display: grid; grid-template-columns: minmax(0, 1fr) 320px 70px; gap: 22px;
  max-width: 1180px; margin: 0 auto; padding: 8px 20px 20px; align-items: start;
}
.boardwrap { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; width: min(100%, 70vh + 36px); }
.board { position: relative; aspect-ratio: 1; box-shadow: 0 0 0 3px #000, 0 0 0 5px var(--line), 0 0 30px rgba(77,227,255,.2); }
.board svg { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; }

.evalbar { position: relative; background: #3d3a37; border: 2px solid #000; overflow: hidden; }
.evalbar .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: #f1f1f1; transition: height .9s cubic-bezier(.2,.8,.2,1); }
.evalbar.flip .fill { top: 0; bottom: auto; }
.evalbar span {
  position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-family: var(--mono); font-size: 15px; color: #333; z-index: 1;
}
.evalbar.flip span { bottom: auto; top: 4px; }
.evalbar.hide .fill { height: 50% !important; background: repeating-linear-gradient(45deg, #555 0 4px, #444 4px 8px); }
.evalbar.hide span { color: #bbb; top: calc(50% - 9px); bottom: auto; }

.side { display: grid; gap: 22px; }
.tomove { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 28px; letter-spacing: .06em; }
.tomove i { width: 16px; height: 16px; border: 2px solid #000; background: #f3ecd9; }
.tomove i.b { background: #2c2f3e; border-color: #8090b0; }
.timer { position: relative; height: 16px; border: 2px solid var(--line); margin: 10px 0 8px; }
.timer .bar { position: absolute; inset: 0; background: linear-gradient(90deg, var(--cyan), #8f9bff); transform-origin: left; }
.timer .bar.low { background: var(--pink); }
.timer span { position: absolute; right: -2px; top: -26px; font-family: var(--mono); font-size: 20px; color: var(--dim); }
.hint { margin: 0; color: var(--dim); font-size: 13.5px; }

.verdict .vline { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 30px; }
.sym {
  display: inline-grid; place-items: center; min-width: 36px; height: 36px; border-radius: 50%;
  font: 700 17px/1 var(--body); color: #fff; border: 2px solid rgba(0,0,0,.4); box-shadow: 0 2px 0 rgba(0,0,0,.4);
}
.verdict .pts { margin-left: auto; color: var(--cyan); }
.vwhy { margin: 6px 0 12px; color: var(--dim); font-size: 13.5px; }
.goods { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.goods li {
  display: grid; grid-template-columns: 28px minmax(52px, auto) 1fr auto; align-items: center; gap: 8px;
  padding: 5px 8px; background: var(--panel-2); border-left: 4px solid; font-size: 13px; cursor: default;
}
.goods li.mine { outline: 1px solid var(--text); }
.goods li .sym { min-width: 24px; height: 24px; font-size: 12px; }
.goods li b { font-family: var(--mono); font-size: 21px; font-weight: 400; }
.goods li .why { color: var(--dim); font-size: 12px; line-height: 1.25; }
.goods li .p { font-family: var(--mono); font-size: 19px; }
.src { margin: 0 0 14px; font-size: 12px; color: var(--dim); }
.next { width: 100%; font-size: 24px; padding: 10px; }

/* ---- rating climb ---- */
.climb { position: relative; height: min(70vh, 640px); }
.track {
  position: absolute; left: 30px; top: 0; bottom: 0; width: 6px;
  background: repeating-linear-gradient(180deg, var(--line) 0 6px, transparent 6px 10px);
}
.track .mile { position: absolute; left: -26px; bottom: var(--f); width: 58px; transform: translateY(50%); text-align: right; }
.track .mile b { display: block; font-family: var(--mono); font-weight: 400; font-size: 16px; color: var(--dim); }
.track .mile.hit b { color: var(--cyan); }
.track .mile i { position: absolute; left: 24px; bottom: 7px; width: 18px; height: 2px; background: var(--line); }
.track .mile .tip {
  display: none; position: absolute; right: 64px; bottom: 0; white-space: nowrap; background: var(--panel); border: 1px solid var(--line);
  padding: 2px 8px; font-family: var(--mono); font-size: 16px; color: var(--text);
}
.track .mile:hover .tip, .track .mile.just .tip { display: block; }
.rook {
  position: absolute; left: 14px; bottom: var(--f, 0%); width: 38px; height: 38px; transform: translateY(50%);
  transition: bottom 1.2s cubic-bezier(.3,1.4,.4,1);
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' shape-rendering='crispEdges'%3E%3Cpath fill='%234de3ff' d='M2 1h3v2h2V1h2v2h2V1h3v4h-1v6h1v3H2v-3h1V5H2z'/%3E%3Cpath fill='%23050a14' d='M5 6h2v4H5z'/%3E%3C/svg%3E");
  filter: drop-shadow(0 0 6px var(--cyan));
}
.rook span {
  position: absolute; left: -2px; top: -26px; font-family: var(--mono); font-size: 22px; color: var(--cyan); white-space: nowrap;
}

/* ---- summary ---- */
.summary { max-width: 560px; margin: 4vh auto 0; padding: 0 16px; text-align: center; }
.summary .total { font-family: var(--mono); font-size: 110px; line-height: 1; margin-top: 14px; text-shadow: -3px 0 var(--pink), 3px 0 var(--cyan); }
.summary .total small { font-size: 40px; color: var(--dim); text-shadow: none; }
.rating-line { font-family: var(--mono); font-size: 24px; letter-spacing: .06em; margin: 4px 0 22px; color: var(--dim); }
.rating-line b { color: var(--cyan); font-weight: 400; }
.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 18px; }
.cards .c { background: var(--panel); border: 2px solid; padding: 8px 4px; }
.cards .c .sym { margin-bottom: 4px; }
.cards .c b { display: block; font-family: var(--mono); font-size: 22px; font-weight: 400; overflow-wrap: anywhere; }
.cards .c small { color: var(--dim); font-family: var(--mono); font-size: 15px; }
.stats { color: var(--dim); margin: 0 0 18px; }
.countdown { font-family: var(--mono); color: var(--dim); font-size: 19px; letter-spacing: .1em; }

.foot { text-align: center; color: var(--dim); font-size: 12px; padding: 30px 16px 24px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel); border: 2px solid var(--pink);
  padding: 8px 16px; font-family: var(--mono); font-size: 20px; z-index: 10;
}

/* board extras: drawn in SVG */
.ghost { pointer-events: none; }
.arrow { pointer-events: none; }

@media (max-width: 900px) {
  .game { grid-template-columns: 1fr; gap: 16px; padding: 4px 16px 16px; }
  .boardwrap { width: 100%; grid-template-columns: 18px minmax(0, 1fr); gap: 6px; }
  .evalbar span { font-size: 11px; letter-spacing: -.04em; }
  .climb { order: -1; height: 46px; }
  .track { left: 0; right: 0; top: 20px; bottom: auto; height: 6px; width: auto;
    background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 10px); }
  .track .mile { transform: translateX(-50%); bottom: auto; top: 10px; width: auto; left: var(--f); }
  .track .mile b { font-size: 13px; text-align: center; }
  .track .mile i { display: none; }
  .track .mile:not(.key) { display: none; }
  .track .mile .tip { right: auto; left: 50%; transform: translateX(-50%); bottom: auto; top: 18px; }
  .rook { width: 28px; height: 28px; top: 9px; bottom: auto; left: var(--f, 0%); transform: translate(-50%, -50%); transition: left 1.2s cubic-bezier(.3,1.4,.4,1); }
  .rook span { left: 50%; top: -22px; transform: translateX(-50%); font-size: 18px; }
  .top { padding: 10px 16px; gap: 10px; }
  .mark.small { font-size: 24px; }
  .dayno { font-size: 17px; }
  .pips i { width: 14px; }
  .cards .c b { font-size: 18px; }
  .summary .total { font-size: 84px; }
}
