/* Go Senpai's page: board left, panel right (decisions, round 5). The board
   and stones are www/stones/stones.css. */

:root {
    color-scheme: dark;
    --table: #2b2723;
    --panel: #1f1c1a;
    --line: #3d3833;
    --text: #e8e2da;
    --quiet: #9c958c;
    --accent: #e0b064;
    --best: #24c0a4;
    --played: #ff5a4e;
    --star: #f0bf3a;
    --mistake: #d8432f;
    --dubious: #d9871a;
    --habit: #8fb8ff;
    --stretch: #a59bd6;
    --winrate: #7fb2e6;
    --tl-rail: #6a6158;
    --loss-0: #3fbf5f;
    --loss-1: #c8d84a;
    --loss-2: #f0a038;
    --loss-3: #ea4c3c;
    --loss-4: #b8263a;
    --loss-5: #7c1c5c;
    --loss-6: #4a1468;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    background: var(--table);
    color: var(--text);
}

a {
    color: var(--accent);
    text-decoration: none;
}

@media (hover: hover) {
    a:hover {
        text-decoration: underline;
    }
}

button {
    font: inherit;
    color: var(--text);
    background: #3a342e;
    border: 1px solid #514940;
    border-radius: 5px;
    padding: 3px 9px;
    cursor: pointer;
}

@media (hover: hover) {
    button:hover:not(:disabled) {
        background: #4a423a;
    }
}

button:disabled {
    opacity: 0.45;
    cursor: default;
}

button.link {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
}

@media (hover: hover) {
    button.link:hover {
        text-decoration: underline;
    }
}

.quiet {
    color: var(--quiet);
}

.small {
    font-size: 12px;
}

.error {
    color: var(--loss-3);
}

code {
    background: #3a342e;
    padding: 1px 4px;
    border-radius: 3px;
}

/* —— the game list —— */

.games {
    max-width: 980px;
    margin: 0 auto;
    padding: 24px 16px;
}

.game-table {
    width: 100%;
    border-collapse: collapse;
}

.game-table th, .game-table td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.game-table th {
    color: var(--quiet);
    font-weight: normal;
}

.game-table tr.lost td:nth-child(4) {
    color: var(--quiet);
}

.level-mark.star { color: var(--star); }
.level-mark.dubious { color: var(--dubious); }
.level-mark.mistake { color: var(--mistake); }

.progress {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.bar {
    display: inline-block;
    width: 120px;
    height: 6px;
    background: #3a342e;
    border-radius: 3px;
    overflow: hidden;
    vertical-align: middle;
}

.bar .fill {
    display: block;
    height: 100%;
    background: var(--accent);
}

/* —— games in: fetched, imported, dropped —— */

.games-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 14px;
}

.games-tools > .quiet {
    margin-right: 4px;
}

.games-tools-end {
    margin-left: auto;
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.games-filter {
    font: inherit;
    color: var(--text);
    background: #24201d;
    border: 1px solid #514940;
    border-radius: 5px;
    padding: 3px 8px;
    width: 160px;
}

.games-tools button.on {
    border-color: var(--accent);
}

.games .notice {
    margin: -4px 0 12px;
    white-space: normal;
}

/* A game just fetched, imported, moved or restored. */
.game-table tr.fresh td:first-child {
    box-shadow: inset 3px 0 0 var(--accent);
}

/* New: not opened since it came in. */
.game-table .date {
    position: relative;
    padding-left: 18px;
}

.new-dot {
    position: absolute;
    left: 5px;
    top: calc(50% - 3.5px);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

/* A click anywhere on a game's row opens it (in select mode, ticks it). */
.game-table tr.clickable {
    cursor: pointer;
}

@media (hover: hover) {
    .game-table tr.clickable:hover td {
        background: rgb(255 255 255 / 0.03);
    }
}

.game-table tr.picked td {
    background: rgb(224 176 100 / 0.08);
}

/* A column's heading sorts by it. */
.game-table th button.sort {
    color: var(--quiet);
    font-weight: normal;
}

.game-table th button.sort.current {
    color: var(--text);
}

.game-table th.pick, .game-table td.pick {
    width: 1px;
    padding-right: 0;
}

/* The sections: my games, practice, other games, the trash. */
.games-section {
    font-size: 15px;
    font-weight: 600;
    margin: 18px 0 6px;
    display: inline-block;
}

.games-fold {
    margin-top: 22px;
}

.games-fold > summary {
    cursor: pointer;
    list-style-position: outside;
}

.games-fold > summary::marker {
    color: var(--quiet);
}

.games-fold .empty-trash {
    margin-left: 6px;
    color: var(--quiet);
}

.game-table td.actions {
    text-align: right;
}

/* A row's ⋯: always there (no hover on a touch screen). */
.game-table .row-menu-button {
    margin-left: 6px;
    padding: 0 6px;
    font-size: 16px;
    line-height: 1;
    color: var(--quiet);
}

.game-table .row-menu-button[aria-expanded="true"] {
    color: var(--text);
}

.row-menu {
    position: fixed;
    z-index: 900;
    display: flex;
    flex-direction: column;
    min-width: 170px;
    padding: 4px;
    background: var(--panel);
    border: 1px solid #514940;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgb(0 0 0 / 0.45);
}

.row-menu button {
    text-align: left;
    background: none;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
}

.row-menu button:focus-visible {
    background: #3a342e;
    outline: none;
}
@media (hover: hover) {
    .row-menu button:hover {
        background: #3a342e;
        outline: none;
    }
}

.row-menu button.danger, .select-bar button.danger:not(:disabled) {
    color: var(--played);
}

/* Select mode: what can be done to the games ticked. */
.select-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    padding: 8px 10px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.select-bar > span {
    margin-right: 6px;
}

/* A rank to choose, on a game's page. */
.rank-select {
    font: inherit;
    color: var(--text);
    background: #3a342e;
    border: 1px solid #514940;
    border-radius: 5px;
    padding: 1px 4px;
}

/* "Did you play this game?" / "Which side did you play?" */
.claim {
    margin-top: 2px;
}

.claim button + button {
    margin-left: 4px;
}

.claim button {
    white-space: nowrap;
}

.drop-shade {
    position: fixed;
    inset: 12px;
    z-index: 1000;
    display: none;
    place-items: center;
    border: 2px dashed var(--accent);
    border-radius: 12px;
    background: rgb(20 18 16 / 0.82);
    pointer-events: none;
}

.drop-shade.shown {
    display: grid;
}

.drop-shade p {
    font-size: 20px;
    color: var(--accent);
}

/* —— the review page —— */

.review {
    display: grid;
    /* The panel's width as dragged at its edge (panelWidth, settings.js), at most half the window. */
    grid-template-columns: minmax(0, 1fr) min(var(--panel-width, 360px), max(360px, 50vw));
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
}

/* The bar over the board and the panel: back to the game list, Review |
   Play in the middle, the page's buttons at the right. */
.top-bar {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.top-bar .page-tools {
    float: none;
    justify-self: end;
}

a.back-button {
    display: inline-block;
    color: var(--text);
    background: #3a342e;
    border: 1px solid #514940;
    border-radius: 7px;
    padding: 6px 12px;
    white-space: nowrap;
}

@media (hover: hover) {
    a.back-button:hover {
        background: #4a423a;
        text-decoration: none;
    }
}

.board-column {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 12px 12px 8px 16px;
    gap: 6px;
}

/* A finger held on the board is a long press for the page (its menu), not iOS's callout or a selection. */
#goban, #goban * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.board-area {
    flex: 1;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Stones coming down from high up start out beyond the board, as in
       go-clock, whose board fills the screen: kept to the board's own area,
       not drawn over the graph and the panel. */
    overflow: hidden;
}

.graph-area {
    /* The score, and the losses strip under it, apart (graph.js), the label between. */
    height: 130px;
    flex: none;
    position: relative;
}

/* The timeline (timeline.js): the game's moves on a rail, the line the
   board is on branching off below, scrolled to keep the board's move in the
   middle, and faded out at either end. A move is a dot by its loss. */
.timeline-area {
    height: 25px; /* a row's; timeline.js sets it for the rows there are */
    flex: none;
    position: relative;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
    mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
}

.timeline-track {
    position: absolute;
    inset: 0;
}

.tl-rail {
    position: absolute;
    height: 2px;
    border-radius: 1px;
    background: var(--tl-rail);
    transition: left 220ms ease-out, width 220ms ease-out, top 220ms ease-out;
}

.tl-link {
    position: absolute;
    height: 2px;
    border-radius: 1px;
    background: var(--tl-rail);
    transform-origin: 0 50%;
    transition: left 220ms ease-out, width 220ms ease-out, top 220ms ease-out, transform 220ms ease-out;
}

/* The current move's column, behind both rows. */
.tl-column {
    position: absolute;
    top: 1px;
    bottom: 1px;
    border-radius: 5px;
    background: rgb(224 176 100 / 0.16);
    box-shadow: inset 0 0 0 1px rgb(224 176 100 / 0.28);
    transition: left 220ms ease-out, width 220ms ease-out;
}

.tl-node {
    position: absolute;
    z-index: 1;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    transition: left 220ms ease-out, width 220ms ease-out, top 220ms ease-out;
    -webkit-touch-callout: none;
    user-select: none;
}

/* Scrolled by a wheel or a trackpad: it follows at once. */
.timeline-track.scrolling .tl-node,
.timeline-track.scrolling .tl-rail,
.timeline-track.scrolling .tl-link,
.timeline-track.scrolling .tl-column {
    transition: none;
}

.tl-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    box-sizing: border-box;
    border-radius: 50%;
    width: 10px;
    height: 10px;
}

/* One size for every move: the colour says what it lost. */
.tl-dot.plain { background: #7a7168; }
.tl-dot.loss-0 { background: var(--loss-0); }
.tl-dot.loss-1 { background: var(--loss-1); }
.tl-dot.loss-2 { background: var(--loss-2); }
.tl-dot.loss-3 { background: var(--loss-3); }
.tl-dot svg { display: block; width: 100%; height: 100%; }
.tl-dot .sign-mistake,
.tl-dot .sign-dubious { fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; }
.tl-dot.star { width: 15px; height: 15px; border-radius: 0; }

/* A pass, a dashed ring. */
.tl-node.pass .tl-dot {
    background: var(--panel);
    border: 1.3px dashed var(--quiet);
}

/* The ring on the dot itself, wherever it's lifted to (Black's above, White's below). */
.tl-node.current .tl-dot::after,
.tl-node:hover .tl-dot::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 19px;
    height: 19px;
    transform: translate(-50%, -50%);
    border: 2px solid var(--accent);
    border-radius: 50%;
    box-sizing: border-box;
    pointer-events: none;
}

.tl-node:hover:not(.current) .tl-dot::after {
    width: 17px;
    height: 17px;
    border: 1px solid var(--quiet);
}

@media (hover: none) {
    .tl-node:hover:not(.current) .tl-dot::after { content: none; }
}

/* The move under the pointer in the score graph: my lead after it, and what it changed. */
.graph-tip {
    position: absolute;
    top: 2px;
    transform: translateX(6px);
    padding: 1px 6px;
    background: rgb(24 21 19 / 0.85);
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    pointer-events: none;
}

.graph-tip.left { transform: translateX(calc(-100% - 6px)); }
.graph-tip[hidden] { display: none; }
/* In the gap between the score and the losses strip (graph.js sets where). */
.graph-tip.in-gap {
    transform: none;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    padding: 0 6px;
    font-size: 11px;
    line-height: 1;
}
.graph-tip .ahead { color: var(--accent); }
.graph-tip .behind { color: var(--played); }

.score-graph {
    display: block;
    cursor: pointer;
    touch-action: none;
    /* The area between the lead and no lead, Black's and White's. */
    --lead-black: #0c0b0a;
    --lead-white: #ece6dc;
}

.score-graph .graph-panel { fill: rgb(0 0 0 / 0.42); }
.score-graph .axis { stroke: #5b544c; stroke-width: 1; }
.score-graph .leader.black { fill: var(--lead-black); }
.score-graph .leader.white { fill: var(--lead-white); }
.score-graph .bar-top { fill: var(--accent); }
.score-graph .halo { fill: none; stroke: rgb(0 0 0 / 0.75); stroke-width: 3.5; stroke-linejoin: round; }
.score-graph .halo.winrate-halo { stroke-width: 2.5; stroke: rgb(0 0 0 / 0.35); }
.score-graph .graph-label.on-shade { paint-order: stroke; stroke: rgb(0 0 0 / 0.75); stroke-width: 2.5px; }
.score-graph .grid { stroke: var(--quiet); stroke-width: 1; stroke-dasharray: 1 3; opacity: 0.35; }
.score-graph .lead { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.score-graph .lead-dot { fill: var(--accent); }
/* An analysis filling in: the positions known so far, joined. */
.score-graph .lead.sketch { stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.55; }
.score-graph .winrate.sketch { stroke-dasharray: 2 3; opacity: 0.4; }
.score-graph .cursor { stroke: var(--text); stroke-width: 1; opacity: 0.8; }
.score-graph .hover-line { stroke: var(--quiet); stroke-width: 1; stroke-dasharray: 2 2; pointer-events: none; }
.score-graph .mistake { fill: var(--played); stroke: #000; stroke-width: 0.5; }
.score-graph .mistake.none { fill: var(--quiet); }
.score-graph .mistake.star { fill: var(--star); }
.score-graph .mistake.dubious { fill: var(--dubious); }
.score-graph .mistake.mistake-mark { fill: var(--mistake); }
.score-graph .mistake.both { fill: var(--star); stroke: var(--mistake); stroke-width: 1.5; }
.score-graph .graph-label { fill: var(--quiet); font-size: 10px; }
.score-graph .ranged { stroke: var(--text); stroke-width: 1.5; opacity: 0.85; }
.score-graph .ranged.later { opacity: 0.3; }
.score-graph .winrate { fill: none; stroke: var(--winrate); stroke-width: 1; opacity: 0.75; }
.score-graph .lead-label { fill: var(--accent); opacity: 0.8; }
.score-graph .strip-axis { opacity: 0.6; }
.score-graph .loss-bar.loss-0 { fill: var(--loss-0); }
.score-graph .loss-bar.loss-1 { fill: var(--loss-1); }
.score-graph .loss-bar.loss-2 { fill: var(--loss-2); }
.score-graph .loss-bar.loss-3 { fill: var(--loss-3); }
.score-graph .loss-bar.later { opacity: 0.5; }
.score-graph .loss-bar.rough { opacity: 0.45; }
.score-graph .faint { opacity: 0.2; }
.score-graph .lens { fill: rgb(255 255 255 / 0.05); }
.score-graph .winrate-label { fill: var(--winrate); text-anchor: end; opacity: 0.8; }

/* Review | Play, in the top bar: the page's two modes. */
.mode-switch {
    display: flex;
    gap: 0;
}

.mode-switch > button {
    flex: 1;
    min-width: 96px;
    padding: 6px 14px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: 0;
}

.mode-switch > button:first-child { border-radius: 7px 0 0 7px; }
.mode-switch > button:last-child { border-radius: 0 7px 7px 0; border-left: none; }

.mode-switch > button.on {
    background: var(--accent);
    color: #1b1610;
    border-color: var(--accent);
    cursor: default;
}

/* Play's part of the panel (www/play.js): who plays each side, the live
   analysis, the lines played. */
.play-box {
    /* Under the move's controls, the board's switches after it (the panel scrolls). */
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.play-box[hidden] {
    display: none;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    margin: 0 -6px;
    border-radius: 6px;
    min-height: 34px;
}

.player-row.to-move {
    background: rgb(224 176 100 / 0.1);
}

.player-stone {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex: none;
}

.player-stone.black { background: #111; box-shadow: inset 0 0 0 1px #5b544c; }
.player-stone.white { background: #ece6dc; }

.player-side {
    width: 92px;
    flex: none;
}

.rank-select {
    font: inherit;
    font-size: 13px;
    color: var(--text);
    background: #3a342e;
    border: 1px solid #514940;
    border-radius: 5px;
    padding: 2px 4px;
}

.play-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.play-status {
    color: var(--quiet);
    margin: 6px 0 0;
}

.play-status.ended {
    color: var(--accent);
}

.analysis-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.analysis-head h3 {
    margin: 0;
}

.analysis-summary {
    font-variant-numeric: tabular-nums;
}

.analysis-moves {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    font-variant-numeric: tabular-nums;
}

.analysis-move {
    display: grid;
    grid-template-columns: 48px 52px 1fr;
    gap: 6px;
    padding: 2px 4px;
    border-radius: 4px;
    cursor: pointer;
}

.analysis-move.chosen {
    background: rgb(255 255 255 / 0.06);
}
@media (hover: hover) {
    .analysis-move:hover {
        background: rgb(255 255 255 / 0.06);
    }
}

.analysis-point {
    font-weight: 600;
}

/* The move section: the score and captures (the controls are under the board). */
.move-box {
    flex: none;
}

/* The move's controls in the middle, the way back from a variation at the
   left taking the room it needs. */
.move-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 4px;
}

.move-row > .controls {
    grid-column: 2;
    justify-self: center;
}

.move-row > .branch-back {
    grid-column: 1;
}

.move-row .move-title {
    flex: none;
    min-width: 5.5em;
}

.move-row .controls > button {
    padding: 3px 5px;
}

/* Min, Review's or Play's: no timeline. */
.view-min .timeline-area {
    display: none;
}

/* The loss bars' slider, under them: Points … %. */
.loss-mix-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

/* Play: no score graph or losses strip (its scores still give the score line and the timeline's losses); Min and Zen no timeline either, so no section for them. */
.playing .graph-area,
.playing .loss-mix-row {
    display: none;
}

.play-min .line-box {
    display: none;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-button[hidden] {
    display: none;
}

.icon {
    display: inline-flex;
}

.icon svg {
    width: 18px;
    height: 18px;
}

.controls {
    display: flex;
    align-items: center;
    gap: 3px;
    flex: none;
}

.controls > button {
    padding: 3px 6px;
}

.move-title {
    flex: 1;
    min-width: 0;
    text-align: center;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.move-name {
    font-weight: 600;
    font-size: 15px;
}

.captures {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.captured-by {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.captures .player-stone {
    width: 11px;
    height: 11px;
}

/* The board's score under the captures: B+3.5 58%; its line kept while it's not known. */
.move-score {
    min-height: 1.4em;
    margin-top: 1px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.move-score .lead { color: var(--accent); }

.move-played {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The board's switches: each one's name, and its control. */
.board-tools {
    flex: none;
}

.display-switches {
    display: grid;
    grid-template-columns: max-content max-content;
    align-items: center;
    gap: 4px 12px;
    margin: 4px 0 8px;
    font-size: 12px;
}

.display-name {
    color: var(--quiet);
}

.display-switches .display-control {
    display: inline-flex;
    gap: 6px;
}

/* The rows drawn again, laid out in the switches' grid. */
.display-switches .switch-rows {
    display: contents;
}

.display-switches .switch-rows[hidden] {
    display: none;
}

.loss-mix {
    width: 96px;
    margin: 0;
    accent-color: var(--accent);
}

.display-switches .icon-toggles {
    gap: 4px;
}

.icon-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 4px;
    min-width: 0;
}

/* Review's switches in the live analysis's section: this move or the next, KataGo's move. */
.analysis-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.analysis-tools > button {
    padding: 1px 8px;
    font-size: 12px;
}

.toggle-group {
    display: inline-flex;
    gap: 4px;
}

.toggle {
    min-width: 28px;
}

.toggle.on {
    background: var(--accent);
    color: #1b1610;
    border-color: var(--accent);
}

.variation-bar {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
    font-size: 12px;
    margin-top: 4px;
}

.variation-bar:empty {
    display: none;
}

.flash {
    color: var(--loss-2);
}

.panel {
    background: var(--panel);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* The timeline and the graph are here too (2026-11-29): in a short window it scrolls. */
    overflow-x: hidden;
    overflow-y: auto;
}

/* A section the mode leaves out (Play has no histogram), whatever its display. */
.panel > [hidden] {
    display: none !important;
}

.panel > section, .panel > header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
}

.panel h2 {
    font-size: 17px;
    margin: 0 0 4px;
}

.panel h3 {
    font-size: 14px;
    margin: 0 0 6px;
}

.panel p {
    margin: 4px 0;
}

/* The losses: the histogram, then the move's detail, which scrolls. */
.losses {
    flex: none;
    display: flex;
    flex-direction: column;
}

.losses-chart {
    flex: none;
}

.losses-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.losses-head h3 {
    margin: 0 auto 0 0;
}

.segmented {
    display: inline-flex;
}

.segmented .toggle {
    border-radius: 0;
    padding: 1px 7px;
    font-size: 12px;
}

.segmented .toggle:first-child { border-radius: 5px 0 0 5px; }
.segmented .toggle:last-child { border-radius: 0 5px 5px 0; border-left: none; }

/* The game's title in Review: who played Black, who White. */
.players {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 16px;
    row-gap: 2px;
}

.players .player {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.players .player-stone { width: 13px; height: 13px; }
.players .player-rank { font-size: 13px; font-weight: normal; }
.game-table .player-stone { display: inline-block; width: 11px; height: 11px; margin-right: 5px; vertical-align: -1px; }

/* Losses for Black | White | Both. */
.losses-for {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.histogram-area {
    width: 100%;
}

.loss-histogram {
    display: block;
    cursor: pointer;
    touch-action: none;
    user-select: none;
}

.loss-histogram .bin { opacity: 0.75; }
.loss-histogram .bin.loss-0 { --bin: var(--loss-0); }
.loss-histogram .bin.loss-1 { --bin: var(--loss-1); }
.loss-histogram .bin.loss-2 { --bin: var(--loss-2); }
.loss-histogram .bin.loss-3 { --bin: var(--loss-3); }
.loss-histogram .bin[class*="loss-"] { fill: var(--bin); }
/* Black's: its outline, faintly filled; White's: solid, with a white edge. */
.loss-histogram .bin.black { stroke: var(--bin); stroke-width: 1.2; fill-opacity: 0.15; }
.loss-histogram .bin.white { stroke: #ece6dc; stroke-width: 1; }
.loss-histogram .bin.in { opacity: 1; }
/* The rest of the whole game's, over the moves so far. */
.loss-histogram .bin.whole { fill: #ece6dc; opacity: 0.4; }
.loss-histogram .bin.whole.in { opacity: 0.55; }
.loss-histogram .slot-hit { fill: transparent; }
.loss-histogram .selection { fill: rgb(255 255 255 / 0.07); }
.loss-histogram .axis { stroke: #5b544c; stroke-width: 1; }
.loss-histogram text { fill: var(--quiet); font-size: 10px; text-anchor: middle; }
.loss-histogram text.count { text-anchor: end; }
.loss-histogram .grid { stroke: #5b544c; stroke-width: 1; opacity: 0.4; }

.loss-note {
    min-height: 2.6em;
}

.loss-note button.link {
    font-variant-numeric: tabular-nums;
}

.mistakes {
    max-height: 38vh;
    min-height: 64px;
    flex: 0 4 auto;
    overflow-y: auto;
}

/* Analyse, for a game not analysed. */
.mistakes .analyse-now {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 8px 0 4px;
}

.best {
    color: var(--best);
}

/* —— overlays on the board (board-view.js) —— */

.board-overlay {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 40000; /* over every stone, moving ones too (stones.css) */
    pointer-events: none;
    overflow: visible;
}

.board-overlay text {
    text-anchor: middle;
    font-family: system-ui, sans-serif;
    font-weight: 600;
}

.own-black { fill: #000; }
.own-white { fill: #fff; }

/* The move to come, in the "next move" view: a ghost of its stone. */
.next-stone.black { fill: rgb(0 0 0 / 0.45); stroke: rgb(0 0 0 / 0.7); }
.next-stone.white { fill: rgb(255 255 255 / 0.5); stroke: rgb(0 0 0 / 0.45); }

/* A line KataGo suggests (Line, or a candidate under the pointer in Play):
   numbered ghosts of its stones; the tokens make way while it shows. */
.line-stone.black { fill: rgb(0 0 0 / 0.62); stroke: rgb(0 0 0 / 0.8); }
.line-stone.white { fill: rgb(255 255 255 / 0.68); stroke: rgb(0 0 0 / 0.5); }
.line-number.on-black { fill: #fff; }
.line-number.on-white { fill: #111; }
.token-layer { transition: opacity 0.1s; }
.token-layer.under-line { opacity: 0; }

/* The stones as things (board-hand.js, board-magic.js, go-clock's): loose
   under the hand, lying on the table (drawn smaller, further from the eye),
   ridden up onto another, in the air, or the magic's in flight, over the
   rest. A stone turning over in the air wears its tumble sheet, with no
   blur or gleam of the flat stone over it. */
.loose-stone.on-table > .stone,
.loose-stone.on-table > .stone-shadow,
.loose-stone.on-table > .stone-gleam {
    scale: 0.92;
}

.loose-stone.riding { z-index: 25000; }
.loose-stone.in-air,
.magic-stone { z-index: 30000; }

.flying > .stone-focus,
.flying > .stone ~ .stone-gleam {
    display: none;
}

/* The flash of a blast (blastAt). */
.blast-flash {
    position: absolute;
    z-index: 30001;
    border-radius: 50%;
    background: radial-gradient(circle, rgb(255 236 180 / 0.95), rgb(255 160 60 / 0.55) 40%, rgb(255 120 40 / 0) 70%);
    pointer-events: none;
}

/* The stones' pictures are never dragged as images (the stone that can be
   picked up takes pointer events: board-view.js markLiftable). */
#goban img {
    -webkit-user-drag: none;
    user-select: none;
}

/* A stone that can be picked up and moved (the live analysis's: the move
   just played, a play-out's): a soft light-blue glow round it, and a hand to take it.
   Over the shadows, under the stones (stones.css, .resting). */
.board_pos.liftable {
    cursor: grab;
}

.board_pos.liftable::before {
    content: '';
    position: absolute;
    z-index: 2;
    inset: -22%;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(closest-side, transparent 64%, rgba(160, 212, 255, 0.85) 72%, rgba(130, 190, 255, 0.35) 84%, transparent 100%);
}

.board_pos.carried {
    cursor: grabbing;
}

.board_pos.carried::before {
    display: none;
}

/* The bomb, for trying the physics: picked up with a click and dropped on the board with another, it goes off there a second later. */
.board-column {
    position: relative;
}

/* The panel's edge, dragged to widen it (up to twice its least width); a double click puts it back. */
.panel-resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    right: -3px;
    width: 7px;
    z-index: 6;
    cursor: col-resize;
    touch-action: none;
}

.zen .panel-resizer {
    display: none;
}

.bomb {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 5;
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
    border-radius: 50%;
}

.hand-switch {
    position: absolute;
    top: 10px;
    right: 58px;
    z-index: 5;
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    border-radius: 50%;
}

.hand-switch.on,
.bomb.on {
    box-shadow: 0 0 0 2px var(--accent);
}

/* The bomb or the hand carried: it's under the pointer, not on its button. */
.hand-switch.on,
.bomb.on {
    color: transparent;
    text-shadow: 0 0 0 rgb(255 255 255 / 0.25);
}

/* The board turned over (board-flip.js), beside the hand. */
.flip-switch {
    position: absolute;
    top: 10px;
    right: 104px;
    z-index: 5;
    width: 38px;
    height: 38px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    border-radius: 50%;
}

.flip-switch.on {
    box-shadow: 0 0 0 2px var(--accent);
}

.bomb-drag {
    position: fixed;
    z-index: 100000;
    font-size: 26px;
    line-height: 1;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

/* Dropped on the board, its fuse burning: it twitches, faster and faster. */
.hand-drag {
    font-size: 30px;
}

.bomb-drag.lit {
    animation: bomb-fuse 1s ease-in forwards;
}

@keyframes bomb-fuse {
    0% { transform: translate(-50%, -50%) scale(1); }
    20% { transform: translate(-50%, -50%) scale(1.08) rotate(-6deg); }
    40% { transform: translate(-50%, -50%) scale(1) rotate(5deg); }
    55% { transform: translate(-50%, -50%) scale(1.12) rotate(-7deg); }
    70% { transform: translate(-50%, -50%) scale(1.04) rotate(7deg); }
    80% { transform: translate(-50%, -50%) scale(1.18) rotate(-8deg); }
    90% { transform: translate(-50%, -50%) scale(1.1) rotate(8deg); }
    100% { transform: translate(-50%, -50%) scale(1.3); }
}

/* The score tokens (board-view.js): solid discs lying on the board, each
   with its shadow (stone-dom.js, a thinner disc's than the computer's
   stones). The face's lettering grows with it when it is lifted. */
.token-layer {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 40001; /* over the overlay */
    pointer-events: none;
}

.token {
    position: absolute;
    pointer-events: none;
    container-type: size;
}

.token-face {
    position: absolute;
    z-index: 1;
    inset: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111;
    font: 700 53cqw/1 system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
    box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.28);
}

.token-face svg {
    width: 100%;
    height: 100%;
}

.token-face .tick { stroke: #111; }

.token.loss-0 > .token-face { background: var(--loss-0); }
.token.loss-1 > .token-face { background: var(--loss-1); }
.token.loss-2 > .token-face { background: var(--loss-2); }
.token.loss-3 > .token-face { background: var(--loss-3); }
.token.loss-4 > .token-face { background: var(--loss-4); color: #f4eee6; }
.token.loss-5 > .token-face { background: var(--loss-5); color: #f4eee6; }
.token.loss-6 > .token-face { background: var(--loss-6); color: #f4eee6; }
.token.level-star > .token-face { background: #2a2520; }
.token.level-dubious > .token-face,
.token.level-mistake > .token-face { background: #f4efe6; }

.sign-star { fill: var(--star); }
.token-badge {
    position: absolute;
    right: -72%;
    top: -72%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgb(0 0 0 / 0.35);
}

.token-badge.level-star { background: #2a2520; }
.token-badge.level-dubious,
.token-badge.level-mistake { background: #f4efe6; }

.sign-dubious { fill: none; stroke: var(--dubious); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.sign-mistake { fill: none; stroke: var(--mistake); stroke-width: 3; stroke-linecap: round; }

.tick {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.highlight {
    fill: none;
    stroke: var(--accent);
    stroke-width: 3;
}

@media (max-width: 860px) {
    .review {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto;
        height: auto;
    }
    .panel-resizer {
        display: none;
    }
    /* The bar stays at the top of the window as the page scrolls. */
    .top-bar {
        position: sticky;
        top: 0;
        z-index: 50000;
    }
    /* In a column of no fixed height, flex: 1 would make it none tall (an iPad upright: 834 px wide).
       Room left under it for the graph and the move's controls. */
    .board-area {
        flex: none;
        height: min(92vw*857/800, 64vh);
    }
}

/* A phone: the bar's three parts closer together, Review | Play beside the way back. */
@media (max-width: 520px) {
    .top-bar {
        grid-template-columns: auto auto minmax(0, 1fr);
        gap: 6px;
        padding: 6px 8px;
    }
    a.back-button {
        padding: 6px 9px;
    }
    .mode-switch > button {
        min-width: 0;
        padding: 6px 11px;
    }
    .top-bar button.link.page-tool {
        width: 26px;
    }
    /* In a column of no fixed height, flex: 1 would make it none tall. */
    .board-area {
        flex: none;
        height: min(92vw*857/800, 80vh);
    }
    /* The game list as Date, Opponent, Result, Mistakes and ⋯ (Me, Moves, the rows' own buttons and the words left out,
       games.js), a long name cut short. */
    .game-table .phone-hidden {
        display: none;
    }
    .games {
        padding: 16px 8px;
    }
    .game-table th, .game-table td {
        padding: 6px 4px;
    }
    .game-table td.name {
        max-width: 26vw;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    /* The bomb, the hand and the flip in a strip above the board, not on it (it's the window's width). */
    .board-column {
        padding-top: 42px;
    }
    .bomb, .hand-switch, .flip-switch {
        top: 6px;
        width: 32px;
        height: 32px;
        font-size: 17px;
    }
    .bomb { right: 8px; }
    .hand-switch { right: 46px; }
    .flip-switch { right: 84px; }
    /* The move's controls moved under the board (review.js): the panel's look kept. */
    .move-box.under-board {
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 6px 8px;
    }
}

/* Play's views (www/play.js): Min has no score graph; Zen is the board
   alone, the window to itself, with × to come back and a word over the
   board for what has no stone to show (a pass, the end). */
.zen-exit, .zen-note {
    display: none;
}

.play-min .graph-area {
    display: none;
}

.review.zen {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    height: 100vh;
}

.zen > .panel,
.zen > .top-bar,
.zen .timeline-area,
.zen .bomb,
.zen .hand-switch,
.zen .flip-switch {
    display: none;
}

.zen .board-area {
    flex: 1;
    height: auto;
}

.zen .zen-exit {
    display: block;
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 5;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    color: var(--quiet);
    background: rgb(58 52 46 / 0.6);
    opacity: 0.55;
    transition: opacity 0.2s;
}

.zen .zen-exit:focus-visible {
    opacity: 1;
    color: var(--text);
}
@media (hover: hover) {
    .zen .zen-exit:hover {
        opacity: 1;
        color: var(--text);
    }
}

.zen .zen-note:not([hidden]) {
    display: block;
    position: absolute;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    z-index: 5;
    padding: 6px 14px;
    border-radius: 16px;
    background: rgb(31 28 26 / 0.85);
    color: var(--text);
    pointer-events: none;
}

/* —— marks the MCP's tools put on the board (mark_points) —— */

.annotation {
    fill: none;
    stroke: var(--accent);
    stroke-linecap: round;
    stroke-linejoin: round;
}

.annotation-plate {
    fill: rgb(224 176 100 / 0.9);
}

.annotation-label {
    font-weight: 700;
}

/* —— coordinates round the board, and points named in text —— */

.board-labels {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    user-select: none;
}

.board-labels text {
    fill: var(--quiet);
    text-anchor: middle;
    font-family: system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
}

/* Blue on a white halo, to stand out on the yellow wood and on either colour of stone. */
.hover-ring {
    fill: none;
    stroke: #1f6fff;
}

.hover-halo {
    fill: none;
    stroke: #fff;
    opacity: 0.9;
}

.hover-glow {
    fill: none;
    stroke: #1f6fff;
    opacity: 0.22;
}

.coord {
    color: var(--accent);
    border-bottom: 1px dotted var(--accent);
    cursor: default;
}

/* Review's live evaluation: a row is a point, its point named as any is. */
.analysis-move.coord {
    color: inherit;
    border-bottom: none;
}

@media (hover: hover) {
    .coord:hover {
        background: rgb(224 176 100 / 0.18);
    }
}

/* —— the study page —— */

.study h2 {
    margin-top: 28px;
}

.rank-graph {
    display: block;
    width: 100%;
    max-width: 900px;
    height: auto;
}
.rank-graph .graph-panel { fill: rgb(0 0 0 / 0.42); }
.rank-graph .grid { stroke: #3a3530; stroke-width: 1; }
.rank-graph .graph-label { fill: var(--quiet); font-size: 10px; }
.rank-graph .rank-band { fill: rgb(224 176 100 / 0.16); }
.rank-graph .rank-line { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linejoin: round; }
.rank-graph .rank-dot { fill: var(--accent); }
@media (hover: hover) {
    .rank-graph .rank-dot:hover { r: 5; }
}
.rank-graph .rank-game { fill: var(--quiet); opacity: 0.3; cursor: pointer; }
@media (hover: hover) {
    .rank-graph .rank-game:hover { opacity: 1; r: 3.5; }
}
.rank-graph .rank-stated { fill: none; stroke-width: 1.4; stroke-dasharray: 4 3; }
.rank-graph .rank-stated.kgs { stroke: var(--habit); }
.rank-graph .rank-stated.ogs { stroke: var(--best); }
.rank-graph .rank-stated.goquest { stroke: var(--stretch); }
.rank-graph .rank-stated-label.kgs { fill: var(--habit); }
.rank-graph .rank-stated-label.ogs { fill: var(--best); }
.rank-graph .rank-stated-label.goquest { fill: var(--stretch); }

.study-table td {
    white-space: normal;
    vertical-align: top;
}

.study-table td:first-child {
    white-space: nowrap;
}

.study-table .bar {
    width: 70px;
}

.study-table .examples {
    font-size: 12px;
    line-height: 1.6;
}

h1 a.small {
    font-size: 14px;
    font-weight: normal;
    margin-left: 10px;
}


/* —— the table the board lies on (the settings; go-clock's pictures) —— */

.table {
    background-color: var(--table);
    background-position: center;
}

[data-table="wood"] .table {
    background-image: url("images/walnut.jpg");
    background-size: 280px auto;
}

[data-table="felt"] .table {
    background-image: url("images/felt.jpg");
    background-size: 640px auto;
}

/* Ice under a pale veil, as go-clock has it: the picture alone is busy. */
[data-table="ice"] .table {
    background-image: linear-gradient(rgb(178 196 200 / 0.55), rgb(178 196 200 / 0.55)), url("images/ice.jpg");
    background-size: auto, 780px auto;
}

[data-table="space"] .table {
    background-image: url("images/space.jpg");
    background-size: cover;
}

/* The board tilted (board-view.js setTilt): the table's picture lies in
   perspective with it, on a plane drawn as the board is (.table-plane, in
   a box clipping it to the table), but for space, which is seen from
   nowhere in particular. */
.table.tilted-table {
    isolation: isolate;
}

:is([data-table="wood"], [data-table="felt"], [data-table="ice"]) .table.tilted-table {
    background-image: none;
}

.table-plane-clip {
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    border-radius: inherit;
}

:root:not(:is([data-table="wood"], [data-table="felt"], [data-table="ice"])) .table-plane-clip {
    display: none;
}

.table-plane {
    position: absolute;
}

[data-table="wood"] .table-plane {
    background-image: url("images/walnut.jpg");
    background-size: 280px auto;
}

[data-table="felt"] .table-plane {
    background-image: url("images/felt.jpg");
    background-size: 640px auto;
}

[data-table="ice"] .table-plane {
    background-image: linear-gradient(rgb(178 196 200 / 0.55), rgb(178 196 200 / 0.55)), url("images/ice.jpg");
    background-size: auto, 780px auto;
}

/* On a picture, the graph under the board on a dark pane of its own, to be
   read. */
:root:not([data-table="plain"]) .board-column > :not(.board-area, .graph-area, .table-plane-clip) {
    background: rgb(24 21 19 / 0.8);
    border-radius: 6px;
}

/* The graph's two panels are its panes there, the table itself showing
   between them. */
:root:not([data-table="plain"]) .score-graph .graph-panel { fill: rgb(24 21 19 / 0.8); }

/* A base colour chosen (settings.js): the panel's and the score graph's,
   in place of the grey; the graph's a little see-through on a picture, as
   the grey is. Not the top bar's. */
:root[data-base] .panel, :root[data-base] .move-box.under-board { background: var(--base); }
:root[data-base] .score-graph .graph-panel { fill: var(--base); }
:root[data-base]:not([data-table="plain"]) .score-graph .graph-panel { fill: color-mix(in srgb, var(--base) 80%, transparent); }


/* The coordinates read against the table: a halo the table's way, dark
   letters on ice. */
:root:not([data-table="plain"]) .board-labels text {
    fill: #e8e2da;
    stroke: rgb(0 0 0 / 0.6);
    stroke-width: 2.5px;
    paint-order: stroke;
}

:root[data-ink="dark"] .board-labels text {
    fill: #23292b;
    stroke: rgb(255 255 255 / 0.55);
}

/* —— the settings: a dialog over the page, in tabs —— */

/* ? and ⚙: the keys and the settings, at the right of the review's top
   bar, and by the game list's title. */
.page-tools {
    float: right;
    display: inline-flex;
    gap: 4px;
}

button.link.page-tool {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 20px;
    line-height: 1;
    font-weight: normal;
    color: var(--quiet);
    vertical-align: middle;
}

@media (hover: hover) {
    button.link.page-tool:hover {
        color: var(--text);
        background: #3a342e;
        text-decoration: none;
    }
}

/* The gear draws small beside the ?, at the same size. */
button.link.page-tool.gear {
    font-size: 24px;
}

h1 button.link.page-tool {
    margin-left: 8px;
}

.settings-dialog {
    width: min(1120px, 100vw - 32px);
    height: min(800px, 100dvh - 48px);
    max-width: none;
    max-height: none;
    padding: 0;
    color: var(--text);
    background: var(--table);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 18px 60px rgb(0 0 0 / 0.6);
    overflow: hidden;
}

.settings-dialog::backdrop {
    background: rgb(0 0 0 / 0.55);
    backdrop-filter: blur(2px);
}

.settings {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 0 10px 0 20px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.settings-header h1 {
    margin: 0;
    font-size: 17px;
}

.settings-tabs {
    display: flex;
    align-self: stretch;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.settings-tabs [role="tab"] {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 14px 12px 12px;
    color: var(--quiet);
}

@media (hover: hover) {
    .settings-tabs [role="tab"]:hover:not(:disabled) {
        background: none;
        color: var(--text);
    }
}

.settings-tabs [role="tab"].on {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.settings-tabs [role="tab"]:focus-visible,
.settings-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -4px;
}

.settings-close {
    flex: none;
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
    color: var(--quiet);
    background: none;
    border: none;
    border-radius: 6px;
}

@media (hover: hover) {
    .settings-close:hover:not(:disabled) {
        color: var(--text);
        background: #3a342e;
    }
}

.settings-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0 20px;
}

.settings-panel {
    padding-top: 18px;
}

.settings-panel[hidden] {
    display: none;
}

.settings-panel > p.quiet:first-child {
    margin: 0;
}

.settings h2 {
    font-size: 15px;
    margin: 0 0 6px;
}

.settings-display {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 470px);
    gap: 24px;
    align-items: start;
    padding-bottom: 20px;
}

.settings-preview {
    display: flex;
    height: 500px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    position: sticky;
    top: 12px;
}

/* The preview's board fills its pane, at any width (the review page's
   narrow-screen rule for .board-area is for a column of no fixed height). */
.settings-preview > .board-area {
    flex: 1;
    width: 100%;
    height: auto;
    align-self: stretch;
}

.settings-row {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 12px;
    align-items: baseline;
    padding: 7px 0;
}

.settings-label {
    color: var(--quiet);
}

.settings-value {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    min-width: 0;
}

.settings-value .settings-help {
    flex-basis: 100%;
    line-height: 1.35;
}

.settings-value .effect {
    color: var(--habit);
}

.segmented {
    display: inline-flex;
}

.segmented button {
    border-radius: 0;
    margin-left: -1px;
}

.segmented button:first-child {
    border-radius: 5px 0 0 5px;
    margin-left: 0;
}

.segmented button:last-child {
    border-radius: 0 5px 5px 0;
}

.segmented button.on {
    background: var(--accent);
    color: #1b1610;
    border-color: var(--accent);
    position: relative;
}

.swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 4px 3px;
    width: 66px;
    font-size: 12px;
}

.swatch.on {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.swatch-picture {
    display: block;
    width: 56px;
    height: 36px;
    border-radius: 3px;
    background: var(--table) center / cover;
    border: 1px solid rgb(0 0 0 / 0.4);
}

[data-swatch="wood"] { background-image: url("images/walnut.jpg"); }
[data-swatch="felt"] { background-image: url("images/felt.jpg"); }
[data-swatch="ice"] { background-image: linear-gradient(rgb(178 196 200 / 0.55), rgb(178 196 200 / 0.55)), url("images/ice.jpg"); }
[data-swatch="space"] { background-image: url("images/space.jpg"); }

/* The base colours: a chip each, and the picker for any other. */
.base-swatches {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.base-swatch {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid #514940;
}

.base-swatch.on {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.base-picker {
    width: 34px;
    height: 28px;
    padding: 0 2px;
    background: none;
    border: 1px solid #514940;
    border-radius: 6px;
    cursor: pointer;
}

.base-picker.on {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.light-picker {
    flex: none;
    cursor: crosshair;
    touch-action: none;
    border-radius: 50%;
}

.light-picker:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.light-sun {
    filter: drop-shadow(0 0 4px rgb(255 200 90 / 0.8));
    cursor: grab;
}

/* The sun's whole round, rays and the gaps between them, picks it up. */
.light-sun-target {
    fill: transparent;
}

.light-sun-disc {
    fill: #ffd36b;
    stroke: #fff6d8;
    stroke-width: 1.2;
}

.light-sun-ray {
    stroke: #ffd36b;
    stroke-width: 2;
    stroke-linecap: round;
}

.settings-form input,
.settings-form select {
    font: inherit;
    color: var(--text);
    background: #2a2622;
    border: 1px solid #514940;
    border-radius: 5px;
    padding: 4px 7px;
    min-width: 0;
}

.settings-form input:focus-visible,
.settings-form select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 0;
}

.settings-form input.wide {
    width: min(100%, 560px);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

.settings-form input.narrow {
    width: 110px;
}

.settings-form input.medium {
    width: min(100%, 320px);
}

.settings-row.centred {
    align-items: center;
}

.settings-row.invalid input,
.settings-row.invalid select {
    border-color: var(--loss-3);
}

.settings-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 16px 10px;
    margin: 18px 0 0;
}

.settings-group legend {
    padding: 0 6px;
    font-weight: 600;
}

.settings-group > p {
    margin: 2px 0 6px;
}

.settings-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-top: 18px;
    padding: 12px 0;
    background: var(--table);
    border-top: 1px solid var(--line);
}

button.primary {
    background: var(--accent);
    color: #1b1610;
    border-color: var(--accent);
    font-weight: 600;
}

@media (hover: hover) {
    button.primary:hover:not(:disabled) {
        background: #ecc27c;
    }
}

.settings-status.ok { color: var(--loss-0); }
.settings-status.error { color: var(--loss-3); }

/* —— the keys —— */

.keys-dialog {
    width: min(560px, 100vw - 32px);
    max-height: min(760px, 100dvh - 48px);
    padding: 0;
    color: var(--text);
    background: var(--table);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 18px 60px rgb(0 0 0 / 0.6);
}

.keys-dialog::backdrop {
    background: rgb(0 0 0 / 0.45);
}

.keys-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px 8px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.keys-header h1 {
    margin: 0;
    font-size: 17px;
}

.keys-body {
    padding: 6px 20px 18px;
}

.keys-body h2 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--quiet);
    margin: 16px 0 6px;
}

.keys-body dl {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 6px 16px;
    margin: 0;
}

.keys-body section:last-child dl {
    margin-top: 16px;
}

.keys-body dt {
    text-align: right;
    white-space: nowrap;
}

.keys-body dd {
    margin: 0;
}

kbd {
    display: inline-block;
    min-width: 22px;
    padding: 1px 6px;
    font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
    text-align: center;
    color: var(--text);
    background: #3a342e;
    border: 1px solid #514940;
    border-bottom-width: 2px;
    border-radius: 4px;
}

/* —— About —— */

.about {
    max-width: 760px;
    padding-bottom: 24px;
    line-height: 1.5;
}

.about p {
    margin: 4px 0;
}

.about-app h2 {
    font-size: 22px;
    margin: 0 0 4px;
}

.about-copyright {
    color: var(--quiet);
}

.about-credits {
    font-size: 17px;
    margin: 0;
}

.about-credits + .about-block {
    margin-top: 12px;
}

.about-block {
    margin-top: 22px;
}

.about h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--quiet);
    margin: 0 0 8px;
}

.about-notices,
.about-thanks {
    list-style: none;
    margin: 0;
    padding: 0;
}

.about-notices > li {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 10px;
}

.about-thanks > li {
    margin-bottom: 6px;
}

.about-name {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-weight: 600;
}

.about-name .quiet {
    font-weight: normal;
}

.about details summary {
    cursor: pointer;
    color: var(--accent);
    margin-top: 4px;
}

.about-licence {
    white-space: pre-wrap;
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--quiet);
    background: var(--panel);
    border-radius: 6px;
    padding: 10px 12px;
    margin: 6px 0 0;
}

@media (max-width: 640px) {
    .settings-dialog {
        width: 100vw;
        height: 100dvh;
        border: none;
        border-radius: 0;
    }
    .settings-header {
        gap: 10px;
        padding-left: 14px;
    }
    .settings-tabs [role="tab"] {
        padding-inline: 8px;
    }
    .settings-body {
        padding: 0 14px;
    }
}

@media (max-width: 860px) {
    .settings-display {
        grid-template-columns: 1fr;
    }
    .settings-preview {
        position: static;
        height: min(92vw*857/800, 70vh);
        order: -1;
    }
    /* Tilted, its table's picture is clipped to it. */
    .settings-preview.tilted-table {
        position: relative;
    }
    .settings-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* The thread sweep, in the KataGo group of the settings. */
.tune-value { flex-direction: column; align-items: flex-start; min-width: 0; }
.tune-value > * { max-width: 100%; }
.tune-lines { margin: 0; max-height: 11em; overflow: auto; white-space: pre-wrap; color: var(--quiet); }
.tune-lines:empty { display: none; }
.tune-hints { margin: 0; padding-left: 1.2em; }
.tune-file { user-select: all; word-break: break-all; }
.tune-value .ok { color: var(--loss-0); }


/* The board turned over (board-flip.js; go-clock's my-clock.css at 8a1eb98,
   without the water's and space's): while it is, and while it turns, a board
   in three dimensions over the one on the page, which is hidden, and its
   stones with it; seen from two board widths above, the board and the stones
   in the one space. Fixed over the window, so that the board rises over the
   panel as it turns; it takes no clicks but on the board (the catcher).
   Nothing on it that groups what it draws (a background, a rounded corner):
   WebKit clips a rounded overflow through a mask, and draws the board flat. */
.board-flip {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    overflow: hidden;
    pointer-events: none;
    background: none;
    border-radius: 0;
}

.board-flip-shadow {
    position: absolute;
    pointer-events: none;
}

.board-flip-world,
.board-flip-box {
    position: absolute;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
}

.board-flip-world {
    inset: 0;
}

.board-flip-face {
    position: absolute;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.board-flip-wood,
.board-flip-grid,
.board-flip-stone-shadows,
.board-flip-shade {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* The computer board's edges and underside, or a picture that could not be
   read: its colour, plain. */
.board-flip-wood.plain {
    background: #dcb35c;
}

/* The glass board's: its colour, the table's round it, on every face
   (board-flip.js lights and shades it half as much as wood). */
[data-board="glass"] .board-flip-top .board-flip-wood,
[data-board="glass"] .board-flip-wood.plain {
    background: var(--glass-base, rgb(66 60 54));
}



/* Each face's light: black over it, as dark as the face is turned from the
   light. */
.board-flip-shade {
    background: black;
    opacity: 0;
}

.board-flip-catcher {
    position: absolute;
    pointer-events: auto;
    cursor: pointer;
}

.board-flip-stone {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    background-repeat: no-repeat;
    /* A tumbling stone wears a frame of its tumble sheet (stones/tumble.js). */
    background-size: 600% 300%;
}

/* What is written on the underside of the board (about.js): in ink soaking
   into the grain, the right way up for the board turned over end over end,
   and sized to the board (its font size a 27th of the board's width, set by
   board-flip.js). */
.underside {
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
    padding: 0 11%;
    color: rgb(38 24 12);
    mix-blend-mode: multiply;
    font-family: "Iowan Old Style", "Palatino", "Georgia", serif;
    line-height: 1.45;
    text-align: center;
    user-select: text;
}

/* On a glass board, dark under the stones: light, to be read against it. */
[data-board="glass"] .underside {
    color: rgb(222 222 228);
    mix-blend-mode: normal;
}

.underside h1 {
    margin: 0 0 0.5em;
    font-size: 3.2em;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.01em;
}

.underside p {
    margin: 0 0 0.9em;
}

.underside-tip {
    font-style: italic;
}

/* A maker's seal, in red, as a board maker stamps the underside: 先輩, senpai. */
.underside-seal {
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 2.6em;
    height: 2.6em;
    margin-top: 0.7em;
    border: 0.14em solid rgb(170 30 20 / 0.85);
    border-radius: 0.2em;
    color: rgb(170 30 20 / 0.85);
    font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
    font-size: 1.1em;
    line-height: 1;
    transform: rotate(-3deg);
}

.underside-seal span {
    font-size: 0.95em;
}

.underside-meta {
    margin-top: 1.4em !important;
    font-size: 0.8em;
    opacity: 0.85;
}

/* A Position (docs/plan.md, M9): one board, no moves. No graph, timeline,
   moves to step through, captures (not known) or mistakes; its settings
   under its title. */
.review.position .graph-area,
.review.position .timeline-area,
.review.position .move-row,
.review.position .move-box .captures,
.review.position .mistakes,
.review.position .loss-mix-row,
.review.position .view-box {
    display: none;
}

.position-settings p {
    margin: 4px 0;
}

.position-settings .segmented .player-stone {
    display: inline-block;
    width: 13px;
    height: 13px;
    margin: 0;
    vertical-align: -2px;
}

/* A Position's picture over its board (www/picture-view.js): what was read, drawn over it. */
.board-area {
    position: relative;
}

.picture-view {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: var(--table, #2a2622);
}

.picture-view[hidden] {
    display: none;
}

.picture-image, .picture-marks {
    position: absolute;
}

.picture-marks .picture-line {
    stroke: rgba(255, 70, 70, 0.75);
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
}

.picture-marks .picture-black {
    fill: rgba(0, 0, 0, 0.7);
    stroke: #fff;
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
}

.picture-marks .picture-white {
    fill: rgba(255, 255, 255, 0.8);
    stroke: #000;
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
}

.picture-marks text {
    text-anchor: middle;
    dominant-baseline: central;
    font-weight: 700;
    paint-order: stroke;
    stroke: #000;
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
}

.picture-marks .picture-unsure {
    fill: #ffd400;
}

.picture-marks .picture-removed {
    fill: #ff4d4d;
}

/* —— the camera page (www/camera.js): the video with what's read over it, the board flat beside it —— */

.camera-page {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
}

/* The camera's view and the flat board the same shape, sized by www/camera.js's layout to fit with no scrolling:
   one over the other on a window taller than wide (.stacked), side by side on a wide one. */
.camera-body {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
    padding: 12px 16px;
}

.camera-body.stacked {
    flex-direction: column;
    gap: 8px;
    padding: 8px;
}

.camera-scan, .camera-flat, .camera-scan > *, .camera-flat > * {
    flex: none;
}

.camera-scan, .camera-flat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* How sure of the board: fills as its points become sure, green when it locks. */
.camera-sure {
    height: 6px;
    border-radius: 3px;
    background: var(--line);
    overflow: hidden;
}

.camera-sure-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 0.15s linear;
}

.camera-sure.full .camera-sure-fill {
    background: #4caf50;
}

/* Once locked: the side to move, the score, KataGo's best moves, Again. Their room is kept before, so nothing moves. */
.camera-tools {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    visibility: hidden;
}

.camera-tools.shown {
    visibility: visible;
}

.camera-tools > button.on {
    background: var(--accent);
    color: #1b1610;
    border-color: var(--accent);
}

.camera-tools > button, .camera-tools .mode-switch > button {
    min-width: 0;
    white-space: nowrap;
}

/* The side to move a row of its own when the tools are narrow (a phone). */
.camera-body.stacked .camera-tools .mode-switch {
    flex-basis: 100%;
    justify-content: center;
}

.camera-body.stacked .camera-tools .mode-switch > button {
    flex: 0 1 auto;
}

.camera-view {
    position: relative;
    min-height: 0;
    overflow: hidden;
    background: #000;
    border-radius: 6px;
    /* The lock: a ring round the view while every point is sure. */
    outline: 3px solid transparent;
    outline-offset: -3px;
    transition: outline-color 0.3s;
}

.camera-view.locked {
    outline-color: #4caf50;
}

/* Saved: the view flashes. */
.camera-view.saved {
    animation: camera-saved 0.8s ease-out;
}

@keyframes camera-saved {
    from { box-shadow: inset 0 0 0 9999px rgba(76, 175, 80, 0.35); }
    to { box-shadow: inset 0 0 0 9999px rgba(76, 175, 80, 0); }
}

.camera-video, .camera-marks {
    position: absolute;
}

.camera-marks {
    pointer-events: none;
}

.camera-marks .picture-line {
    stroke: rgba(255, 70, 70, 0.45);
    stroke-width: 1px;
    vector-effect: non-scaling-stroke;
}

.camera-marks .picture-black {
    fill: rgba(0, 0, 0, 0.7);
    stroke: #fff;
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
}

.camera-marks .picture-white {
    fill: rgba(255, 255, 255, 0.8);
    stroke: #000;
    stroke-width: 1.5px;
    vector-effect: non-scaling-stroke;
}

.camera-marks text {
    text-anchor: middle;
    dominant-baseline: central;
    font-weight: 700;
    paint-order: stroke;
    stroke: #000;
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
    fill: #ffd400;
}

.camera-message {
    position: absolute;
    inset: auto 0 45% 0;
    text-align: center;
    color: var(--text);
}

.camera-board {
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.camera-picker {
    font: inherit;
    max-width: 320px;
}

/* What's only for the keys (the keys' list, "(Esc)", "n / p"): not shown with no keyboard and mouse or trackpad (an iPad by touch). */
@media not (any-pointer: fine) {
    .key-hint {
        display: none !important;
    }
}
