/* Terminal theme: black and white, sharp edges. Neon green is used only for interaction
   (hover, focus, selection, legal-move hints), never for static content. */
:root {
    --bg: #000000;
    --fg: #f2f2f2;
    --muted: #8a8a8a;
    --line: #3a3a3a;
    --line-strong: #f2f2f2;
    --panel: #0a0a0a;
    --neon: #39ff14;
    --neon-dim: rgba(57, 255, 20, 0.35);
    --neon-faint: rgba(57, 255, 20, 0.14);
    --sq-light: #d9d9d9;
    --sq-dark: #7d7d7d;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
    color-scheme: dark;
}

* { box-sizing: border-box; border-radius: 0 !important; }

::selection { background: var(--neon); color: #000; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 14px/1.5 var(--mono);
}

a { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
a:hover, a:focus-visible { color: var(--neon); outline: none; }

:focus-visible { outline: 1px solid var(--neon); outline-offset: 2px; }

header {
    max-width: 1080px;
    margin: 0 auto;
    padding: 20px 16px 10px;
}

header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0;
}

header p { margin: 2px 0 0; color: var(--muted); }

main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 8px 16px 32px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    align-items: start;
}

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

.board-area { min-width: 0; }

.board-row { display: flex; gap: 8px; }

.board-wrap {
    position: relative;
    flex: 1;
    max-width: 640px;
    aspect-ratio: 1;
    outline: 1px solid var(--line-strong);
}

#board { width: 100%; height: 100%; }

/* ---- Board ---------------------------------------------------------------------------- */

cg-board {
    background-color: var(--sq-light);
    /* 8x8 checkerboard, a8 light */
    background-image: repeating-conic-gradient(var(--sq-dark) 0 25%, var(--sq-light) 0 50%);
    background-size: 25% 25%;
}

cg-board square.last-move { background-color: rgba(0, 0, 0, 0.22); }
cg-board square.check { box-shadow: inset 0 0 0 4px #000, inset 0 0 0 6px #fff; }

/* interaction: neon */
cg-board square.selected { background-color: var(--neon-faint); box-shadow: inset 0 0 0 3px var(--neon); }
cg-board square.move-dest {
    background: radial-gradient(var(--neon) 16%, rgba(0, 0, 0, 0.55) 17%, transparent 21%);
}
cg-board square.oc.move-dest { background: none; box-shadow: inset 0 0 0 3px var(--neon); }
cg-board square.move-dest:hover { background: var(--neon-faint); box-shadow: inset 0 0 0 3px var(--neon); }
.cg-wrap piece.dragging { filter: drop-shadow(0 0 6px var(--neon)); }
cg-board piece.ghost { opacity: 0.35; }

.cg-wrap coords { font-family: var(--mono); font-weight: 600; }
.cg-wrap coords coord { color: rgba(0, 0, 0, 0.55) !important; }
.cg-wrap coords.files { left: 0; bottom: 0; text-transform: lowercase; }
.cg-wrap coords.files coord { text-align: right; padding-right: 3px; }

/* ---- Eval bar ------------------------------------------------------------------------- */

.evalbar {
    position: relative;
    width: 22px;
    flex: none;
    background: #000;
    outline: 1px solid var(--line-strong);
    overflow: hidden;
}

.evalbar-fill {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 50%;
    background: var(--fg);
    transition: height 0.4s steps(12);
}

.evalbar.flipped .evalbar-fill { top: 0; bottom: auto; }

#evalbar-label {
    position: absolute;
    left: 0; right: 0; bottom: 4px;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    mix-blend-mode: difference;
}

/* ---- Text blocks ---------------------------------------------------------------------- */

.player {
    font-weight: 700;
    padding: 6px 0 6px 30px;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

/* ---- Controls ------------------------------------------------------------------------- */

.buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }

button, select, input {
    font: inherit;
    color: var(--fg);
}

button {
    background: #000;
    border: 1px solid var(--line-strong);
    padding: 8px 10px;
    cursor: pointer;
}

button:hover, button:focus-visible {
    border-color: var(--neon);
    color: var(--neon);
    outline: none;
}

button:active { background: var(--neon); color: #000; border-color: var(--neon); }
button:disabled { opacity: 0.4; cursor: default; }

#new-white, #new-black { background: var(--fg); color: #000; border-color: var(--fg); font-weight: 700; }
#new-white:hover, #new-black:hover,
#new-white:focus-visible, #new-black:focus-visible { background: var(--neon); border-color: var(--neon); color: #000; }

button.link {
    background: none;
    border: none;
    padding: 0;
    color: var(--muted);
    font-size: 12px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

button.link:hover, button.link:focus-visible { color: var(--neon); }
button.link:active { background: none; color: var(--neon); }

.settings {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
}

.settings label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

select, input {
    background: #000;
    border: 1px solid var(--line);
    padding: 6px 8px;
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
}

select { cursor: pointer; width: 100%; min-width: 0; }
select:hover, input:hover { border-color: var(--fg); }
select:focus, input:focus { border-color: var(--neon); outline: none; }
select option:checked { background: var(--neon); color: #000; }

/* ---- Panels --------------------------------------------------------------------------- */

.engine, .moves-box {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 10px 12px;
}

.engine-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--line);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 12px;
}

.muted { color: var(--muted); font-weight: 400; font-size: 11px; text-transform: none; letter-spacing: 0; }

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    margin: 0;
}

.stats dt { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; }

.pv {
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
    min-height: 3em;
    overflow-wrap: anywhere;
}

.moves {
    margin: 0;
    padding: 0 0 0 3em;
    max-height: 220px;
    overflow-y: auto;
    font-variant-numeric: tabular-nums;
}

.moves li { padding: 1px 0; }
.moves li::marker { color: var(--muted); }
.moves span { display: inline-block; min-width: 5.5em; }

.fen { display: flex; gap: 6px; }
.fen input { flex: 1; min-width: 0; font-size: 12px; }

* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* ---- Promotion picker ----------------------------------------------------------------- */

.promotion {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    z-index: 10;
}

.promotion[hidden] { display: none; }

.promotion button {
    width: 18%;
    aspect-ratio: 1;
    background: #000;
    color: var(--fg);
    line-height: 1;
}
