/* Fair Play — chess.samgod.world
   Same quiet look as samgod.world: the nebula, soft dark panels, emerald only where it means something. */
@font-face { font-family: "Michroma"; src: url("/assets/fonts/michroma.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Titillium Web"; src: url("/assets/fonts/titillium-300.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Titillium Web"; src: url("/assets/fonts/titillium-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Titillium Web"; src: url("/assets/fonts/titillium-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Titillium Web"; src: url("/assets/fonts/titillium-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --void: #070A09; --panel: rgba(16, 20, 19, 0.92); --solid: #101413; --raised: #171D1B; --pill: #1F2825;
  --line: #232B28; --line-hi: #2F3A36;
  --text: #E4E9E7; --soft: #CBD6D2; --muted: #93A39D; --faint: #66746F;
  --emerald: #21D18B; --mint: #9BF7D2; --ink: #06130D;
  --display: "Michroma", "Titillium Web", system-ui, sans-serif;
  --body: "Titillium Web", system-ui, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --sf19: #F2B544; --sf18: #4FB3F6; --sf171: #C58BF2;
  --t-human: #21D18B; --t-sharp: #7FD8C6; --t-suspicious: #F2C744; --t-potential: #FF8A3D; --t-engine: #FF4D5E;
  --m-brilliant: #26C2BD; --m-great: #5B9BD5; --m-best: #7CC25A; --m-excellent: #7CC25A; --m-good: #8FA89B;
  --m-book: #B89776; --m-forced: #8FA89B; --m-inaccuracy: #F2C744; --m-mistake: #F0932B; --m-miss: #F06A5D; --m-blunder: #E0354B;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--void); }
body { margin: 0; min-height: 100svh; display: flex; flex-direction: column; color: var(--text); font: 400 17px/1.5 var(--body); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3, p, ol { margin: 0; }
ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#nebula { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; opacity: 0.5; background: radial-gradient(120% 90% at 85% 20%, #0b2a20 0, #06110d 45%, var(--void) 75%); }
main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 56px; }
section { animation: rise 0.6s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

/* ---------- top ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px clamp(16px, 4vw, 40px); }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 400 12.500px/1 var(--display); }
.brand img { border-radius: 50%; }
.top-right { display: flex; align-items: center; gap: 16px; }
.top-link { font-size: 15.500px; color: var(--muted); transition: color 0.2s; }
.top-link:hover { color: var(--text); }
.tune { display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--solid); transition: border-color 0.2s, transform 0.3s var(--ease); }
.tune:hover { border-color: var(--emerald); transform: translateY(-1px); }
.tune-text { display: grid; line-height: 1.15; text-align: left; }
.tune-text b { font-weight: 600; font-size: 14.500px; }
.tune-text small { font-size: 13px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 16px; }
.bars i { width: 3px; height: 100%; border-radius: 2px; background: var(--emerald); transform-origin: 50% 100%; transform: scaleY(0.3); }
.tune[aria-pressed="true"] .bars i { animation: bars 0.9s ease-in-out infinite; }
.bars i:nth-child(2) { animation-delay: -0.3s !important; }
.bars i:nth-child(3) { animation-delay: -0.6s !important; }
@keyframes bars { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }

/* ---------- buttons, switch ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 22px; border: 1px solid var(--emerald); border-radius: 10px; background: var(--emerald); color: var(--ink); font-weight: 600; transition: transform 0.25s var(--ease), border-color 0.2s; }
.button:hover { transform: translateY(-2px); }
.button:active { transform: scale(0.97); }
.button.quiet { background: var(--solid); border-color: var(--line-hi); color: var(--text); font-weight: 400; }
.button.quiet:hover { border-color: var(--emerald); }
.link { color: var(--emerald); transition: color 0.2s; }
.link:hover { color: var(--mint); }
.switch { position: relative; display: inline-flex; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--void); }
.switch button { position: relative; z-index: 1; padding: 6px 14px; border-radius: 7px; font-size: 16px; color: var(--muted); transition: color 0.2s; }
.switch button[aria-pressed="true"] { color: #F2FFF9; }
.glide { position: absolute; left: 0; top: 4px; bottom: 4px; width: var(--w, 0); transform: translateX(var(--x, 0)); border-radius: 7px; background: var(--pill); transition: transform 0.34s var(--ease), width 0.34s var(--ease); }

/* ---------- home ---------- */
#view-queue { display: grid; gap: 18px; max-width: 820px; margin: 0 auto; padding-top: clamp(20px, 8vh, 96px); }
.intro h1 { font: 300 clamp(28px, 4.4vw, 48px)/1.12 var(--body); letter-spacing: -0.01em; }
.intro p { margin-top: 10px; max-width: 52ch; color: var(--muted); font-size: clamp(17px, 1.6vw, 19px); }
.ask { display: grid; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); transition: border-color 0.25s; }
.ask:focus-within { border-color: var(--line-hi); }
#entry { width: 100%; min-height: 52px; max-height: 240px; padding: 12px 6px 4px; border: 0; background: none; resize: none; font-size: 18px; line-height: 1.45; color: var(--text); }
#entry:focus { outline: 0; }
#entry::placeholder { color: var(--faint); }
.ask-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.hint { color: var(--muted); font-size: 15.500px; }
.ask-row .button { margin-left: auto; }
.under { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; font-size: 16px; }
.options summary, .more summary { cursor: pointer; color: var(--muted); transition: color 0.2s; }
.options summary:hover, .more summary:hover { color: var(--text); }
.options-body { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 10px; color: var(--muted); }
select { padding: 7px 10px; border: 1px solid var(--line-hi); border-radius: 8px; background: var(--solid); }
.status { flex-basis: 100%; min-height: 1.5em; color: var(--muted); }
.status.bad { color: #FF9C9C; }

.block h2 { margin-bottom: 10px; font: 600 18px/1.2 var(--body); }
.block h2 span { margin-left: 8px; font-weight: 400; font-size: 15.500px; color: var(--muted); }
.cards { display: grid; gap: 8px; }
.cards li { animation: rise 0.45s var(--ease) both; }
.game-card, .player-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; width: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); text-align: left; transition: border-color 0.2s, transform 0.3s var(--ease); }
button.game-card:hover { border-color: var(--emerald); transform: translateX(4px); }
.game-names { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.game-names > i { font-style: normal; color: var(--faint); }
.game-facts { margin-top: 2px; font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }
.game-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.who b { font-weight: 600; overflow-wrap: anywhere; }
.who small { color: var(--muted); font-size: 15px; }
.dot { width: 11px; height: 11px; flex: none; border-radius: 50%; border: 1px solid var(--line-hi); }
.dot.w { background: #F2F4F3; }
.dot.b { background: #1B211F; }
.tier { --tier: var(--t-human); display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; background: color-mix(in srgb, var(--tier) 14%, transparent); color: var(--tier); font-size: 15px; white-space: nowrap; }
.tier b { font-weight: 700; font-variant-numeric: tabular-nums; }
[data-tier="sharp"] { --tier: var(--t-sharp); }
[data-tier="suspicious"] { --tier: var(--t-suspicious); }
[data-tier="potential"] { --tier: var(--t-potential); }
[data-tier="engine"] { --tier: var(--t-engine); }
.state { color: var(--muted); font-size: 15.500px; }
.state.running { color: var(--emerald); }
.state.failed { color: #FF9C9C; }
.bar { display: inline-block; width: 120px; height: 6px; border-radius: 3px; background: var(--pill); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--fill, 0%); border-radius: 3px; background: linear-gradient(90deg, var(--emerald), var(--mint)); transition: width 0.3s linear; }
.player-card { display: grid; gap: 4px; }
.player-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; }
.player-head b { font-size: 18px; font-weight: 600; }
.player-card p { color: var(--muted); font-size: 15.500px; }
.player-card .habits { color: var(--soft); }

/* ---------- game ---------- */
.game-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 8px 0 16px; }
.game-head h1 { font: 600 clamp(20px, 2.4vw, 26px)/1.2 var(--body); overflow-wrap: anywhere; }
.game-head p { color: var(--muted); font-size: 15.500px; }

.verdicts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.verdict { --tier: var(--t-human); min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.verdict-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.verdict-head strong { flex-basis: 100%; order: 3; margin-top: 4px; font: 600 clamp(19px, 1.8vw, 23px)/1.2 var(--body); color: var(--tier); }
.verdict-head .score { margin-left: auto; font-size: 26px; font-weight: 700; color: var(--tier); font-variant-numeric: tabular-nums; }
.verdict-head .score small { font-size: 14px; font-weight: 400; color: var(--muted); }
.scale { position: relative; height: 6px; margin: 14px 0 10px; border-radius: 3px; background: linear-gradient(90deg, var(--t-human) 0 25%, var(--t-sharp) 25% 48%, var(--t-suspicious) 48% 70%, var(--t-potential) 70% 88%, var(--t-engine) 88% 100%); }
.scale i { position: absolute; top: -6px; left: var(--at, 0%); width: 18px; height: 18px; margin-left: -9px; border-radius: 50%; background: #fff; border: 4px solid var(--solid); box-shadow: 0 0 0 1px var(--line-hi); transition: left 1s var(--ease); }
.verdict-note { color: var(--soft); font-size: 16px; }
.verdict details { margin-top: 10px; }
.verdict summary { cursor: pointer; color: var(--muted); font-size: 15.500px; transition: color 0.2s; }
.verdict summary:hover { color: var(--text); }
.evidence { margin-top: 8px; table-layout: fixed; font-size: 15px; }
.evidence th { padding: 4px 8px 6px 0; text-align: left; font-weight: 400; color: var(--faint); }
.evidence td { padding: 6px 8px 6px 0; vertical-align: middle; color: var(--muted); }
.evidence th:nth-child(1) { width: 42%; }
.evidence th:nth-child(2), .evidence th:nth-child(3) { width: 15%; }
.evidence tr.hit td:first-child { color: var(--text); }
.evidence .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--soft); }
.zbar { position: relative; display: block; width: 100%; height: 8px; border-radius: 4px; background: linear-gradient(90deg, transparent calc(37.5% - 1px), var(--line-hi) calc(37.5% - 1px) calc(37.5% + 1px), transparent calc(37.5% + 1px)), var(--void); }
.zbar i { position: absolute; top: 0; bottom: 0; left: var(--from, 37.5%); width: var(--size, 0%); border-radius: 4px; background: var(--fill, var(--faint)); transition: width 0.9s var(--ease); }

.bench { display: grid; grid-template-columns: minmax(0, min(48%, 74svh)) minmax(0, 1fr); gap: 16px; align-items: start; }
.bench-board { display: grid; gap: 8px; position: sticky; top: 12px; }
.strip { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.strip .clock { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.board-wrap { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; }
.evalbar { position: relative; border-radius: 8px; background: #1B211F; border: 1px solid var(--line); overflow: hidden; }
.evalbar i { position: absolute; left: 0; right: 0; bottom: 0; height: var(--white, 50%); background: #F2F4F3; transition: height 0.45s var(--ease); }
.evalbar span { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 11px; font-weight: 700; color: #101413; }
.evalbar span.for-black { bottom: auto; top: 4px; color: var(--text); }
.board { position: relative; aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line-hi); overflow: hidden; user-select: none; }
.board-squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.board-squares i { position: relative; }
.board-squares .light { background: #C4D1CA; }
.board-squares .dark { background: #3F6253; }
.board-squares .last.light { background: #D3D68F; }
.board-squares .last.dark { background: #7C8C4B; }
.board-squares i::before, .board-squares i::after { position: absolute; font: 700 11px/1 var(--body); opacity: 0.75; }
.board-squares i[data-rank]::before { content: attr(data-rank); left: 4px; top: 4px; }
.board-squares i[data-file]::after { content: attr(data-file); right: 4px; bottom: 3px; }
.board-squares .light::before, .board-squares .light::after { color: #3F6253; }
.board-squares .dark::before, .board-squares .dark::after { color: #C4D1CA; }
.board-pieces, .board-arrows { position: absolute; inset: 0; pointer-events: none; }
.board-arrows { width: 100%; height: 100%; }
.piece { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; transition: transform 0.2s var(--ease); will-change: transform; }
.arrow-line { stroke: var(--engine); stroke-width: 0.085; opacity: 0.9; animation: fade 0.3s ease both; }
.arrow-head { fill: var(--engine); opacity: 0.95; animation: fade 0.3s ease both; }
@keyframes fade { from { opacity: 0; } }
[data-engine="sf19"] { --engine: var(--sf19); }
[data-engine="sf18"] { --engine: var(--sf18); }
[data-engine="sf171"] { --engine: var(--sf171); }
.board-badge { position: absolute; left: 0; top: 0; z-index: 2; width: 12.5%; height: 12.5%; pointer-events: none; transition: transform 0.2s var(--ease); }
.board-badge::after { content: attr(data-sign); position: absolute; right: 3%; top: 3%; display: grid; place-items: center; width: 40%; aspect-ratio: 1; border-radius: 50%; background: var(--mark); color: var(--ink); font: 700 clamp(9px, 1.1vw, 14px)/1 var(--body); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.55); }
.controls { display: grid; grid-template-columns: 1fr 1fr 1.7fr 1fr 1fr 1fr; gap: 6px; }
.controls button { height: 46px; border: 1px solid var(--line); border-radius: 10px; background: var(--solid); font-size: 16px; transition: border-color 0.2s, transform 0.2s; }
.controls button:hover { border-color: var(--emerald); }
.controls button:active { transform: scale(0.95); }
.controls .primary { background: var(--emerald); border-color: var(--emerald); color: var(--ink); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 14.500px; }
.panel .legend { margin-top: 8px; }
.swatch { display: inline-block; width: 16px; height: 4px; margin-right: 8px; border-radius: 2px; vertical-align: middle; background: var(--engine, var(--muted)); }

.bench-data { display: grid; gap: 12px; min-width: 0; }
.panel { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.panel h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; font: 600 16px/1.2 var(--body); }
.panel h3 span { font-weight: 400; font-size: 14.500px; color: var(--muted); }
#move-panel { display: grid; grid-template-columns: minmax(0, 1.5fr) repeat(4, minmax(0, 1fr)); gap: 4px 14px; }
.cell { min-width: 0; }
.cell small { display: block; color: var(--muted); font-size: 14px; white-space: nowrap; }
.cell b { display: block; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.cell.move b { display: flex; align-items: center; gap: 9px; font-size: 22px; }
.cell .flag { color: var(--emerald); }
.mark-chip { display: inline-grid; place-items: center; flex: none; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 7px; font: 700 13px/1 var(--body); font-style: normal; color: var(--ink); background: var(--mark, var(--m-good)); }
[data-mark="brilliant"] { --mark: var(--m-brilliant); }
[data-mark="great"] { --mark: var(--m-great); }
[data-mark="best"] { --mark: var(--m-best); }
[data-mark="excellent"] { --mark: var(--m-excellent); }
[data-mark="good"] { --mark: var(--m-good); }
[data-mark="book"] { --mark: var(--m-book); }
[data-mark="forced"] { --mark: var(--m-forced); }
[data-mark="inaccuracy"] { --mark: var(--m-inaccuracy); }
[data-mark="mistake"] { --mark: var(--m-mistake); }
[data-mark="miss"] { --mark: var(--m-miss); }
[data-mark="blunder"] { --mark: var(--m-blunder); }

.table-wrap { overflow-x: auto; }
.data { font-size: 15.500px; }
.data th { padding: 4px 10px 6px 0; text-align: left; font-weight: 400; color: var(--faint); white-space: nowrap; }
.data td { padding: 7px 10px 7px 0; white-space: nowrap; vertical-align: middle; }
.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.data small { margin-left: 6px; color: var(--muted); font-size: 14px; }
.lines td.first { color: var(--engine); font-weight: 600; }
.lines td.played { text-decoration: underline; text-decoration-color: var(--text); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.chart { display: block; width: 100%; height: 170px; border-radius: 10px; background: var(--void); cursor: pointer; }
.chart .area { fill: rgba(242, 244, 243, 0.14); }
.chart .curve { fill: none; stroke: #F2F4F3; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.chart .axis { stroke: var(--line-hi); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .tw { fill: #C9D2CE; }
.chart .tb { fill: #5A6862; }
.chart .hot { fill: var(--emerald); }
.chart .tick { stroke: var(--mark); stroke-width: 3; vector-effect: non-scaling-stroke; }
.chart .cursor { stroke: var(--emerald); stroke-width: 2; vector-effect: non-scaling-stroke; }
.moves { max-height: 300px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line-hi) transparent; position: relative; }
.move-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1fr); gap: 4px; align-items: center; }
.move-row > span { color: var(--faint); font-size: 15px; text-align: right; padding-right: 6px; }
.move { display: flex; align-items: center; gap: 9px; min-height: 38px; padding: 5px 10px; border-radius: 9px; text-align: left; transition: background 0.2s; }
button.move:hover { background: var(--raised); }
.move.current { background: var(--pill); }
.move b { font-weight: 600; }
.move small { margin-left: auto; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.more { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.more .table-wrap { margin-top: 10px; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px; padding: 18px clamp(16px, 4vw, 40px) 24px; border-top: 1px solid var(--line); color: var(--faint); font-size: 14.500px; }

@media (max-width: 940px) {
  .bench { grid-template-columns: minmax(0, 1fr); }
  .bench-board { position: static; }
  #move-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cell.move { grid-column: 1 / -1; }
  .tune-text small { display: none; }
}
@media (max-width: 560px) {
  .top-link { display: none; }
  .ask-row .button { width: 100%; margin-left: 0; }
  .game-card { padding: 12px; }
}

@media (max-width: 620px) { .verdicts { grid-template-columns: minmax(0, 1fr); } }
