@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #f2f4e9;
  --muted: #a4b0a6;
  --faint: #69766e;
  --bg: #101614;
  --panel: rgba(27, 37, 32, .76);
  --panel-solid: #1b2520;
  --line: rgba(205, 230, 208, .12);
  --accent: #c9f36b;
  --accent-soft: #dffca2;
  --accent-ink: #182116;
  --cream: #f3ecd7;
  --brown: #8a6247;
  --brown-deep: #684734;
  --danger: #f49a86;
  --board-size: min(66vw, 672px);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: 'Manrope', system-ui, sans-serif; min-height: 100vh; overflow-x: hidden; }
button { font: inherit; }
button:focus-visible, [draggable='true']:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ambient { position: fixed; width: 48vw; height: 48vw; border-radius: 50%; filter: blur(80px); opacity: .12; pointer-events: none; z-index: 0; }
.ambient-one { background: #8eb447; top: -24vw; left: -16vw; }
.ambient-two { background: #5a836e; right: -26vw; bottom: -28vw; }
.shell { width: min(1320px, calc(100% - 64px)); margin: 0 auto; position: relative; z-index: 1; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 27px 0 18px; }
.brand { color: var(--ink); text-decoration: none; display: inline-flex; gap: 11px; align-items: center; }
.brand-mark { width: 37px; height: 37px; border-radius: 12px; display: grid; place-items: center; color: var(--accent-ink); background: var(--accent); font: 500 12px 'DM Mono', monospace; letter-spacing: -.08em; box-shadow: 0 0 0 5px rgba(201,243,107,.08); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; letter-spacing: -.02em; }
.brand small { margin-top: 2px; color: var(--faint); font-size: 10px; }
.topbar-note { color: var(--muted); font: 11px 'DM Mono', monospace; text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 8px; }
.live-dot, .turn-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(201,243,107,.1); }
.workspace { padding: 67px 0 76px; }
.intro-row { display: flex; justify-content: space-between; gap: 60px; align-items: end; margin-bottom: 54px; }
.eyebrow, .panel-kicker { color: var(--accent); font: 500 10px 'DM Mono', monospace; letter-spacing: .16em; text-transform: uppercase; margin: 0; }
h1 { font-size: clamp(43px, 5.7vw, 78px); line-height: .98; letter-spacing: -.075em; margin: 13px 0 0; font-weight: 700; }
h1 em { color: var(--accent); font-style: normal; }
.intro-copy { color: var(--muted); max-width: 380px; font-size: 13px; line-height: 1.75; margin: 0 4px 3px 0; }
.studio { display: grid; grid-template-columns: minmax(400px, var(--board-size)) minmax(300px, 390px); align-items: start; justify-content: space-between; gap: clamp(28px, 6vw, 96px); }
.board-column { min-width: 0; }
.board-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 15px; }
.turn-pill { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--ink); }
.position-code { font: 10px 'DM Mono', monospace; color: var(--faint); white-space: nowrap; }
.board-frame { position: relative; padding: 14px 14px 29px 29px; background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 22px 70px rgba(0,0,0,.25); }
.board { display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; overflow: hidden; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); position: relative; }
.square { border: 0; padding: 0; position: relative; display: grid; place-items: center; cursor: pointer; aspect-ratio: 1; transition: filter .18s ease, box-shadow .18s ease; }
.square.light { background: var(--cream); }
.square.dark { background: var(--brown); }
.square:hover { filter: brightness(1.08); }
.square.last-move { box-shadow: inset 0 0 0 999px rgba(201,243,107,.17); }
.square.suggested-from, .square.suggested-to { box-shadow: inset 0 0 0 999px rgba(201,243,107,.40); }
.square.suggested-to::after { content: ''; width: 21%; aspect-ratio: 1; border-radius: 50%; position: absolute; background: rgba(30, 52, 26, .52); }
.square.selected { box-shadow: inset 0 0 0 999px rgba(93, 147, 229, .34); }
.square.legal::after { content: ''; width: 20%; aspect-ratio: 1; border-radius: 50%; background: rgba(28, 48, 31, .38); position: absolute; }
.square.legal.has-piece::after { width: 84%; height: 84%; background: transparent; border: 4px solid rgba(201,243,107,.62); }
.move-arrow { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; overflow: visible; }
.move-arrow line { stroke-width: 1.7; stroke-linecap: round; opacity: .88; filter: drop-shadow(0 1px 1px rgba(0,0,0,.3)); }
.move-arrow.good { color: #baf46b; }
.move-arrow.neutral { color: #f6ce66; }
.move-arrow.bad { color: #f58f7d; }
.move-arrow.suggestion { color: #dffca2; }
.move-arrow.good line { stroke: #baf46b; }
.move-arrow.neutral line { stroke: #f6ce66; }
.move-arrow.bad line { stroke: #f58f7d; }
.move-arrow.suggestion line { stroke: #dffca2; stroke-dasharray: 2.2 1.4; }
.piece { position: relative; z-index: 2; line-height: 1; font-family: 'Arial Unicode MS', 'Noto Sans Symbols 2', serif; font-size: clamp(28px, 5vw, 57px); user-select: none; cursor: grab; transition: transform .18s ease; filter: drop-shadow(0 2px 1px rgba(0,0,0,.28)); }
.piece:active { cursor: grabbing; transform: scale(.92); }
.piece.white-piece { color: #fff9e9; text-shadow: 0 2px 0 #8b6549, 0 3px 5px rgba(0,0,0,.35); }
.piece.black-piece { color: #18201c; text-shadow: 0 1px 0 rgba(255,255,255,.15), 0 3px 4px rgba(0,0,0,.3); }
.rank-labels, .file-labels { position: absolute; color: var(--faint); font: 10px 'DM Mono', monospace; }
.rank-labels { left: 9px; top: 14px; bottom: 29px; display: flex; flex-direction: column; justify-content: space-around; }
.file-labels { left: 29px; right: 14px; bottom: 9px; display: flex; justify-content: space-around; }
.board-footer { display: flex; align-items: center; gap: 18px; color: var(--faint); font: 10px 'DM Mono', monospace; padding: 14px 2px 0; }
.board-footer span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.suggestion-legend { background: var(--accent); }
.selected-legend { background: #5d93e5; }
.text-button { color: var(--muted); border: 0; padding: 0; background: transparent; cursor: pointer; margin-left: auto; font: 10px 'DM Mono', monospace; }
.text-button:hover { color: var(--accent); }
.control-column { display: flex; flex-direction: column; gap: 14px; padding-top: 28px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; backdrop-filter: blur(16px); }
.suggestion-panel { padding: 24px; }
.spark { font-size: 14px; vertical-align: -1px; margin-right: 5px; }
.suggestion-state { margin: 24px 0 5px; color: var(--muted); font-size: 12px; min-height: 18px; }
.suggestion-state.loading { color: var(--accent); }
.suggestion-state.error { color: var(--danger); }
.suggestion-move { color: var(--accent); font: 500 48px/.95 'DM Mono', monospace; letter-spacing: -.1em; min-height: 48px; }
.suggestion-explanation { color: var(--muted); font-size: 12px; line-height: 1.65; min-height: 42px; margin: 14px 0 15px; }
.suggestion-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 21px; }
.tag { display: inline-flex; padding: 5px 8px; border-radius: 5px; background: rgba(201,243,107,.14); color: var(--accent-soft); font: 10px 'DM Mono', monospace; }
.tag-muted { color: var(--faint); background: rgba(255,255,255,.045); }
.move-evaluation { display: flex; align-items: flex-start; gap: 8px; padding: 10px 0 13px; border-top: 1px solid rgba(255,255,255,.07); margin-bottom: 12px; }
.evaluation-badge { flex: 0 0 auto; padding: 5px 7px; border-radius: 4px; font: 500 9px 'DM Mono', monospace; letter-spacing: .04em; }
.evaluation-badge.neutral { color: var(--muted); background: rgba(255,255,255,.07); }
.evaluation-badge.good { color: #dffca2; background: rgba(186,244,107,.15); }
.evaluation-badge.average { color: #f6ce66; background: rgba(246,206,102,.13); }
.evaluation-badge.bad { color: #ffb4a5; background: rgba(245,143,125,.14); }
.move-evaluation > span:last-child { color: var(--muted); font-size: 10px; line-height: 1.45; }
.primary-button, .secondary-button { border: 0; cursor: pointer; transition: transform .15s ease, background .15s ease, color .15s ease; }
.primary-button { width: 100%; padding: 13px 14px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 800; }
.primary-button:hover { background: var(--accent-soft); transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .56; transform: none; }
.primary-button span { margin-right: 5px; }
.always-suggest-control { display: flex; align-items: center; gap: 10px; margin-top: 17px; cursor: pointer; user-select: none; }
.always-suggest-control input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 34px; height: 20px; flex: 0 0 auto; padding: 3px; border-radius: 99px; background: rgba(255,255,255,.12); transition: background .2s ease; }
.toggle-thumb { display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform .2s ease, background .2s ease; }
.always-suggest-control input:checked + .toggle-track { background: rgba(201,243,107,.7); }
.always-suggest-control input:checked + .toggle-track .toggle-thumb { transform: translateX(14px); background: var(--accent-ink); }
.always-suggest-control input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 3px; }
.always-suggest-copy { display: flex; flex-direction: column; gap: 2px; }
.always-suggest-copy strong { color: var(--ink); font-size: 11px; font-weight: 700; }
.always-suggest-copy small { color: var(--faint); font: 9px 'DM Mono', monospace; }
.elo-control { margin-top: 22px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.07); }
.elo-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.elo-heading small { color: var(--faint); font: 9px 'DM Mono', monospace; }
.elo-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.elo-option { min-height: 55px; padding: 8px 5px; border: 1px solid rgba(255,255,255,.09); border-radius: 7px; background: rgba(255,255,255,.035); color: var(--muted); cursor: pointer; text-align: left; transition: border-color .18s ease, background .18s ease, color .18s ease; }
.elo-option:hover { border-color: rgba(201,243,107,.45); color: var(--ink); }
.elo-option.active { border-color: rgba(201,243,107,.7); background: rgba(201,243,107,.12); color: var(--accent-soft); }
.elo-option strong, .elo-option small { display: block; }
.elo-option strong { font: 500 11px 'DM Mono', monospace; }
.elo-option small { margin-top: 5px; color: var(--faint); font-size: 8px; line-height: 1.2; }
.elo-option.active small { color: rgba(223,252,162,.7); }
.history-panel { padding: 20px 23px 17px; }
.panel-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 15px; }
.panel-heading h2 { margin: 6px 0 0; font-size: 17px; letter-spacing: -.045em; }
.move-count { color: var(--faint); font: 10px 'DM Mono', monospace; }
.history-list { max-height: 170px; overflow: auto; padding-right: 2px; }
.history-list::-webkit-scrollbar { width: 3px; }
.history-list::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 4px; }
.history-grid { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 2px 7px; font: 12px 'DM Mono', monospace; }
.history-grid > span { padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.055); }
.history-grid .number { color: var(--faint); }
.history-grid .move { color: var(--ink); }
.history-grid .latest { color: var(--accent); }
.empty-history { color: var(--faint); font-size: 11px; line-height: 1.7; padding: 4px 0 3px; }
.empty-history span { color: var(--muted); }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.secondary-button { padding: 11px 10px; border-radius: 8px; background: rgba(255,255,255,.05); color: var(--muted); border: 1px solid var(--line); font-size: 11px; }
.secondary-button:hover { color: var(--ink); background: rgba(255,255,255,.09); }
.status-line { color: var(--faint); font-size: 11px; line-height: 1.6; margin: 0 4px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(8, 12, 10, .72); backdrop-filter: blur(8px); }
.modal-backdrop[hidden] { display: none; }
.promotion-dialog { width: min(360px, 100%); padding: 27px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 22px 80px rgba(0,0,0,.42); }
.promotion-dialog h2 { font-size: 25px; letter-spacing: -.06em; margin: 11px 0 5px; }
.promotion-dialog p:not(.eyebrow) { color: var(--muted); font-size: 12px; margin: 0 0 19px; }
.promotion-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.promotion-option { padding: 11px 4px 9px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.04); color: var(--ink); cursor: pointer; }
.promotion-option:hover { background: rgba(201,243,107,.13); border-color: rgba(201,243,107,.55); }
.promotion-option .promotion-piece { display: block; font-size: 30px; line-height: 1; }
.promotion-option small { display: block; color: var(--faint); margin-top: 7px; font: 9px 'DM Mono', monospace; }
@media (max-width: 980px) {
  :root { --board-size: min(68vw, 620px); }
  .studio { grid-template-columns: minmax(360px, var(--board-size)) minmax(290px, 350px); gap: 32px; }
  .intro-row { margin-bottom: 40px; }
}
@media (max-width: 760px) {
  .shell { width: min(100% - 32px, 620px); }
  .topbar { padding-top: 18px; }
  .topbar-note { display: none; }
  .workspace { padding-top: 42px; }
  .intro-row { display: block; margin-bottom: 31px; }
  h1 { font-size: clamp(45px, 13vw, 64px); }
  .intro-copy { margin-top: 22px; max-width: 520px; }
  .studio { display: block; }
  .board-column { width: 100%; }
  .control-column { padding-top: 31px; }
  .board-footer { flex-wrap: wrap; }
  .position-code { display: none; }
}
@media (max-width: 430px) {
  .shell { width: calc(100% - 22px); }
  .board-frame { padding: 9px 9px 24px 24px; }
  .rank-labels { top: 9px; bottom: 24px; left: 6px; }
  .file-labels { left: 24px; right: 9px; bottom: 7px; }
  .piece { font-size: clamp(28px, 10.5vw, 43px); }
  .suggestion-panel { padding: 20px; }
}
