@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-latin.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

@font-face {
    font-family: "JetBrains Mono";
    src: url("../fonts/jetbrains-mono-latin.woff2") format("woff2");
    font-weight: 100 800;
    font-display: swap;
}

/* The token sets of the Penpot file: mode/light, mode/dark and core. */
:root {
    --color-bg: #f2f3ef;
    --color-surface: #ffffff;
    --color-sunken: #e9ebe5;
    --color-text: #14161a;
    --color-muted: #5e636b;
    --color-line: #daddd5;
    --color-line-strong: #b9bdb3;
    --color-accent: #3b3fd8;
    --color-accent-hover: #2f32b8;
    --color-accent-text: #ffffff;
    --color-accent-soft: #e7e8fc;
    --color-mark: #d7f36b;
    --color-mark-text: #1e2600;
    --color-ok: #16794a;
    --color-ok-soft: #dff2e7;
    --color-danger: #c1352a;
    --color-danger-soft: #fae5e2;
    --color-warn: #7a5300;
    --color-warn-soft: #fdf0c8;

    /* Core, so the same in either mode: a dark piece stays dark. */
    --color-piece-dark: #14161a;
    --color-piece-dark-ring: #43464e;
    --color-piece-light: #fbfbf8;
    --color-piece-light-ring: #b9bdb3;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-pill: 999px;

    --font-ui: "Inter", system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

    --shadow-pinned: 0 6px 12px -6px rgb(20 22 26 / 0.18);
    /* The slices of a pie, in this order and never another: told apart with colour vision of any kind (checked with the data-viz palette validator). */
    --color-series-1: #2a78d6;
    --color-series-2: #eb6834;
    --color-series-3: #1baf7a;
    --color-series-4: #eda100;
    --color-series-5: #e87ba4;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #111214;
        --color-surface: #1a1b1f;
        --color-sunken: #232429;
        --color-text: #ecedef;
        --color-muted: #9a9ea6;
        --color-line: #2d2f35;
        --color-line-strong: #43464e;
        --color-accent: #8f92ff;
        --color-accent-hover: #a9abff;
        --color-accent-text: #0d0e1f;
        --color-accent-soft: #25264a;
        --color-mark: #c6e85a;
        --color-mark-text: #1a2100;
        --color-ok: #55c98f;
        --color-ok-soft: #163325;
        --color-danger: #ff8174;
        --color-danger-soft: #3d1c19;
        --color-warn: #f1c75b;
        --color-warn-soft: #3a2f12;
        --shadow-pinned: 0 6px 12px -6px rgb(0 0 0 / 0.6);
        --color-series-1: #3987e5;
        --color-series-2: #d95926;
        --color-series-3: #199e70;
        --color-series-4: #c98500;
        --color-series-5: #d55181;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.45;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--color-muted); }
.icon { flex: none; display: block; }

/* ── Top bar ─────────────────────────────────────────────── */

.bar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 28px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-line);
    /* Stays in view, so who made the screen is never scrolled away. */
    position: sticky;
    top: 0;
    z-index: 3;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--color-text); font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; }
.crumb { color: var(--color-muted); font-family: var(--font-mono); font-size: 14px; }
.crumb::before { content: "/"; margin-right: 10px; color: var(--color-line-strong); font-family: var(--font-ui); font-size: 16px; }
.spacer { flex: 1; }

/* ── Who made the screen ─────────────────────────────────── */

.provenance { position: relative; min-width: 0; }
.provenance-button {
    gap: 6px;
    padding: 5px 10px 5px 12px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--color-warn-soft);
    color: var(--color-warn);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
}
.provenance-button:hover { box-shadow: inset 0 0 0 1px var(--color-warn); }
.provenance-button.open { box-shadow: inset 0 0 0 1.5px var(--color-warn); }
.provenance-button .short { display: none; flex-direction: column; }
.provenance-button .short > span { white-space: nowrap; }

.provenance-details {
    position: absolute;
    top: calc(100% + 14px);
    left: calc(100% - 52px);
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 400px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    padding: 18px;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: 0 12px 32px -8px rgb(20 22 26 / 0.22);
    color: var(--color-text);
}
.provenance-details .grabber { display: none; }
.provenance-scrim { display: none; }
.details-head { display: flex; align-items: center; gap: 8px; }
.details-head .badge { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-md); background: var(--color-warn-soft); color: var(--color-warn); }
.details-head h2 { font-size: 15px; font-weight: 600; }
.details-section { display: flex; flex-direction: column; gap: 4px; }
.details-section h3 { font-size: 12px; font-weight: 600; }
.details-section p { font-size: 13px; color: var(--color-muted); }
.details-section.watch { padding: 12px; border-radius: var(--radius-md); background: var(--color-danger-soft); }
.details-section.watch h3 { color: var(--color-danger); }
.details-section.watch p { color: var(--color-text); }
.details-author { font-size: 13px; color: var(--color-muted); }
.details-document { display: flex; flex-direction: column; gap: 4px; }
.details-document h3 { font-size: 12px; font-weight: 600; }
.details-document pre {
    margin: 0;
    max-height: 240px;
    overflow: auto;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--color-sunken);
    font: 12px/1.5 var(--font-mono);
}
.details-actions { display: flex; gap: 8px; }

/* Where the whole sentence would meet the links on the right, it is set on two shorter lines. */
@media (max-width: 1080px) {
    .provenance-button { align-items: center; padding: 5px 8px; border-radius: var(--radius-md); font-size: 11px; line-height: 1.25; }
    .provenance-button .long { display: none; }
    .provenance-button .short { display: flex; }
    .provenance-button .icon { width: 13px; height: 13px; }
}
.bar-links { display: flex; gap: 4px; }

main { max-width: 1072px; margin: 0 auto; padding: 32px 16px 48px; }

/* ── Buttons and chips ───────────────────────────────────── */

button, .button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: 500 14px/1.3 var(--font-ui);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-line-strong);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
}
button:hover, .button:hover { border-color: var(--color-muted); text-decoration: none; }
button:focus-visible, .button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}
.primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-text); }
.primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.ghost { background: transparent; border-color: transparent; }
.ghost:hover { background: var(--color-sunken); border-color: transparent; }
.small { padding: 5px 10px; font-size: 13px; }
.move { font-family: var(--font-mono); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--color-sunken);
    color: var(--color-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}
.chip.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.accent { background: var(--color-accent-soft); color: var(--color-accent); }
.chip.ok { background: var(--color-ok-soft); color: var(--color-ok); }
.chip.danger { background: var(--color-danger-soft); color: var(--color-danger); }
.chip.warn { background: var(--color-warn-soft); color: var(--color-warn); }
.chip.mark { background: var(--color-mark); color: var(--color-mark-text); }

/* ── Cards ───────────────────────────────────────────────── */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-lg);
    min-width: 0;
}
.card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-line);
}
.card-head h2 { font-size: 14px; font-weight: 600; }
.card-head .meta { margin-left: auto; font-size: 12px; color: var(--color-muted); }
.card-body { padding: 16px 18px 18px; }

/* ── Values ──────────────────────────────────────────────── */

.rows { margin: 0; padding: 4px 0; }
.rows > div {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 16px;
    align-items: baseline;
    padding: 11px 18px;
}
.rows > div + div { border-top: 1px solid var(--color-line); }
.rows dt, .record dt { font: 13px var(--font-mono); color: var(--color-muted); overflow-wrap: anywhere; }
.rows dd, .record dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.rows.single > div { grid-template-columns: minmax(0, 1fr); }

.record {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 6px 10px;
    align-items: center;
    margin: 0;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--color-sunken);
    font-family: var(--font-mono);
    font-size: 13px;
}
.record dt { font-size: 12px; }
.record .chip { background: var(--color-surface); }
.sequence { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.sequence > li { min-width: 0; }
.sequence.of-records > li { flex: 1 1 170px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chips .chip { font-family: var(--font-mono); }
.chips .chip.named { font-family: var(--font-ui); }
.null { color: var(--color-muted); }
.number { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── Playing ─────────────────────────────────────────────── */

.play { display: flex; flex-direction: column; gap: 20px; }
.view { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.play-head { display: flex; align-items: center; gap: 16px; }
.play-head .titles { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.title-row { display: flex; align-items: center; gap: 10px; }
.play-head h1 { font-size: 28px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.play-head .sub { font: 13px var(--font-mono); color: var(--color-muted); }
.play-head .actions { display: flex; gap: 8px; margin-left: auto; flex: none; }
.play-head .actions button { white-space: nowrap; }

.last-move {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border: 1px solid var(--color-line);
    border-radius: calc(var(--radius-md) + 2px);
    background: var(--color-surface);
    font: 500 13px var(--font-mono);
    min-width: 0;
}
.last-move .chip { font-family: var(--font-ui); }
.last-move .move-text { overflow-wrap: anywhere; }
.last-move .drew { display: inline-flex; align-items: center; gap: 6px; color: var(--color-muted); font-weight: 400; }
.last-move .undo { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; font: 12px var(--font-ui); color: var(--color-muted); white-space: nowrap; }

.moves-body { display: flex; flex-direction: column; gap: 18px; padding: 16px 18px 18px; }
.block { display: flex; flex-direction: column; gap: 12px; }
.actor-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--color-muted); }
.actor-head .chip { font-family: var(--font-mono); }
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-head { font: 600 13px var(--font-mono); }
.input-head .params { margin-left: 4px; font-weight: 400; color: var(--color-muted); }
.buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.buttons:empty { display: none; }
/* An input's choices as one list, and the button that plays the one picked beside it. */
.move-select { display: flex; gap: 6px; }
.move-select select { flex: 1 1 auto; min-width: 0; width: auto; }
.move-select .move { flex: none; }
.moves-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--color-line);
    font-size: 12px;
    color: var(--color-muted);
}
.rejection { display: flex; align-items: center; gap: 6px; color: var(--color-danger); font-size: 12px; }
.rejection code { font-family: var(--font-mono); }

.move-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    padding: 14px;
    border-radius: calc(var(--radius-md) + 2px);
    background: var(--color-sunken);
}
/* The fields of a form side by side while there is room, each at least wide enough to type in. */
.move-form .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field .label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.field small { color: var(--color-muted); font-size: 12px; }
.field.invalid input, .field.invalid select { border-color: var(--color-danger); box-shadow: 0 0 0 0.5px var(--color-danger); }
/* A yes or no ticked beside its name; a slider with its value at the end of the label; a date from the calendar. */
.field.check { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; align-self: start; cursor: pointer; }
.field.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--color-accent); box-shadow: none; }
.field.check .label { font-size: 14px; }
.field input[type="range"] { width: 100%; padding: 0; border: 0; background: none; box-shadow: none; accent-color: var(--color-accent); }
.slider-value { margin-left: auto; font: 500 13px var(--font-mono); }
.field input[type="date"] { font-family: var(--font-mono); max-width: 220px; }

input, textarea, select {
    font: inherit;
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-line-strong);
    background: var(--color-surface);
    color: var(--color-text);
}
input, select { font-family: var(--font-mono); font-size: 14px; }
select { cursor: pointer; }
input::placeholder, textarea::placeholder { color: var(--color-muted); font-family: var(--font-ui); }

.result {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px;
    border: 1px solid var(--color-ok);
    border-radius: var(--radius-lg);
    background: var(--color-ok-soft);
}
.result-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--color-ok); }
.result-value { display: flex; flex-direction: column; gap: 2px; }
.result-value .key { font: 12px var(--font-mono); color: var(--color-ok); }
.result-value .value { font: 600 30px/1.2 var(--font-mono); overflow-wrap: anywhere; }
.result p { font-size: 13px; color: var(--color-muted); }

/* ── A view's layout ─────────────────────────────────────── */

.layout { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.layout-heading { font-size: 18px; font-weight: 600; }
.layout-heading:not(:first-child) { margin-top: 8px; }
.layout-text { font-size: 15px; line-height: 1.6; color: var(--color-muted); white-space: pre-line; }
/* Blocks side by side, top-aligned, each column laid out as the view is; one above the other on a narrow screen. */
.columns { display: grid; gap: 20px; align-items: start; min-width: 0; }
.compact .columns { gap: 12px; }
@media (max-width: 720px) { .columns { grid-template-columns: minmax(0, 1fr) !important; } }

/* A view's labels are words for people, not names from the rules. */
.rows.labelled dt { font: 500 13px var(--font-ui); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; }
.stat-label { font-size: 12px; font-weight: 500; color: var(--color-muted); }
.stat-value { font: 600 30px/1.2 var(--font-mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* A written number breaks only where it has a space, before its unit, never inside its digits. */
.stat-value.number { overflow-wrap: normal; }

.table-scroll { overflow-x: auto; }
/* How far each thing has got: a bar, and the count beside it; a full bar is done. */
.progress-list { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px 18px; }
.progress-item { display: grid; grid-template-columns: minmax(80px, max-content) 1fr auto; align-items: center; gap: 14px; }
.progress-label { font-size: 13px; font-weight: 500; }
.progress-track { height: 8px; border-radius: var(--radius-pill); background: var(--color-sunken); overflow: hidden; }
.progress-fill { display: block; height: 100%; border-radius: inherit; background: var(--color-accent); }
.progress-fill.full { background: var(--color-ok); }
.progress-count { font: 400 13px var(--font-mono); color: var(--color-muted); }
/* The moves at the end of a line, played with what it holds; one asking for more opens a form under it. */
.table td.row-actions { text-align: right; white-space: nowrap; padding-top: 6px; padding-bottom: 6px; }
.row-actions .move { padding: 5px 12px; font-size: 13px; }
.row-actions .move + .move { margin-left: 6px; }
.table tr.row-form td { padding: 0 18px 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { padding: 10px 18px; text-align: left; font-size: 12px; font-weight: 500; color: var(--color-muted); border-bottom: 1px solid var(--color-line); white-space: nowrap; }
.table td { padding: 10px 18px; vertical-align: top; overflow-wrap: anywhere; }
.table tbody tr + tr td { border-top: 1px solid var(--color-line); }
/* A number written to a format reads down its column at the right, digit under digit. */
.table .number { text-align: right; white-space: nowrap; }
.table td.number, .rows .number { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* A chart: a scale down the left, bars stacked from the floor, a label under every few. */
.chart-card .card-head { flex-wrap: wrap; gap: 8px 16px; }
.chart-legend { display: flex; gap: 14px; margin: 0 0 0 auto; padding: 0; list-style: none; font-size: 12px; color: var(--color-muted); }
.chart-legend li { display: flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 2px; }
.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 20px 18px 12px; }
.chart-scale { position: relative; height: 220px; min-width: 40px; font: 11px var(--font-mono); color: var(--color-muted); }
.chart-scale span { position: absolute; right: 0; transform: translateY(50%); white-space: nowrap; }
.chart-plot { position: relative; display: flex; align-items: flex-end; height: 220px; padding-bottom: 0; margin-bottom: 22px; }
.chart-line { position: absolute; left: 0; right: 0; height: 1px; background: var(--color-line); }
.chart-column { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.chart-bar { display: flex; flex-direction: column-reverse; width: 62%; height: 100%; justify-content: flex-start; }
.chart-bar span:last-child { border-radius: 3px 3px 0 0; }
.chart-label { position: absolute; top: 100%; margin-top: 6px; font-size: 11px; color: var(--color-muted); white-space: nowrap; }
.chart .neutral, .chart-legend .neutral { background: var(--color-line-strong); }
.chart .accent, .chart-legend .accent { background: var(--color-accent); }
.chart .ok, .chart-legend .ok { background: var(--color-ok); }
.chart .warn, .chart-legend .warn { background: var(--color-warn); }
.chart .danger, .chart-legend .danger { background: var(--color-danger); }
/* Lines: 2px whatever the plot's stretch, the last record of each marked with a dot ringed in the surface. */
.chart-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.chart-lines polyline { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; background: none; }
.chart-lines .accent { stroke: var(--color-accent); }
.chart-lines .neutral { stroke: var(--color-line-strong); }
.chart-lines .ok { stroke: var(--color-ok); }
.chart-lines .warn { stroke: var(--color-warn); }
.chart-lines .danger { stroke: var(--color-danger); }
.chart-dot { position: absolute; left: 50%; width: 10px; height: 10px; border-radius: 50%; transform: translate(-50%, 50%); box-shadow: 0 0 0 2px var(--color-surface); }
.chart-legend .swatch.line { height: 3px; border-radius: 2px; }
/* A pie: a ring of shares, each named with its share beside it. */
.chart-pie { display: flex; align-items: center; gap: 28px; padding: 20px 18px; flex-wrap: wrap; }
.pie { width: 160px; height: 160px; flex: none; transform: none; }
.pie path { stroke: var(--color-surface); stroke-width: 0.025; }
.pie .series-1, .pie-legend .series-1 { fill: var(--color-series-1); background: var(--color-series-1); }
.pie .series-2, .pie-legend .series-2 { fill: var(--color-series-2); background: var(--color-series-2); }
.pie .series-3, .pie-legend .series-3 { fill: var(--color-series-3); background: var(--color-series-3); }
.pie .series-4, .pie-legend .series-4 { fill: var(--color-series-4); background: var(--color-series-4); }
.pie .series-5, .pie-legend .series-5 { fill: var(--color-series-5); background: var(--color-series-5); }
.pie .other, .pie-legend .other { fill: var(--color-line-strong); background: var(--color-line-strong); }
.pie-legend { flex: 1; min-width: 180px; max-width: 280px; display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.pie-legend li { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 8px; }
.pie-legend .swatch { width: 10px; height: 10px; border-radius: 2px; }
.pie-share { font: 13px var(--font-mono); color: var(--color-muted); }

/* A board keeps its squares square, and as wide as the card lets it up to a comfortable size. */
.board-card { padding: 16px 18px 18px; }
.board-card .card-head { margin: -16px -18px 16px; }
.board {
    display: grid;
    grid-template-columns: auto repeat(var(--files), minmax(0, 1fr));
    gap: 3px;
    max-width: 520px;
    margin: 0 auto;
}
.board-label { display: grid; place-items: center; padding: 0 4px; font: 500 11px var(--font-mono); color: var(--color-muted); }
.square {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--color-sunken);
    container-type: inline-size;
}
.square.playable { cursor: pointer; }
.square.playable:hover { background: var(--color-accent-soft); border-color: transparent; }
/* Where the rules allow a move, a small dot; the move itself is the rules' to name. */
.square.playable:not(:has(*))::after {
    content: ""; width: 22%; height: 22%; border-radius: 50%; background: var(--color-accent); opacity: 0.55;
}
/* A value with no piece grows with its square, so a mark on a small board reads as one. */
.square-text { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 clamp(11px, 55cqi, 44px)/1 var(--font-mono), "Segoe UI Symbol", "Noto Sans Symbols 2", "Apple Symbols", sans-serif; }
.piece { width: 78%; height: 78%; border-radius: 50%; }
.piece.dark { background: var(--color-piece-dark); box-shadow: inset 0 0 0 1px var(--color-piece-dark-ring); }
.piece.light { background: var(--color-piece-light); box-shadow: inset 0 0 0 1px var(--color-piece-light-ring); }
.piece.accent { background: var(--color-accent); }
.piece.ok { background: var(--color-ok); }
.piece.warn { background: var(--color-warn); }
.piece.danger { background: var(--color-danger); }
/* A covered square: the whole of it, so nothing under it shows. */
.piece.tile { width: 100%; height: 100%; border-radius: inherit; background: var(--color-line-strong); }
.board.checkered .square.dark { background: var(--color-line); }
/* Moving from one square to another: the squares a move starts from, the one chosen, and a
   piece that can be taken, ringed where an empty square would get a dot. */
.square.origin { cursor: pointer; }
.square.origin:hover { box-shadow: inset 0 0 0 2px var(--color-accent-soft); }
.square.selected { background: var(--color-accent-soft); box-shadow: inset 0 0 0 2px var(--color-accent); cursor: pointer; }
.square.target { box-shadow: inset 0 0 0 3px var(--color-accent); }
.board-choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
/* A board drawn as keys: a calculator's face, no wider than one, with its readout on top. A key
   the rules do not offer now stays where it is, faded. */
.keys-card { width: 100%; max-width: 440px; margin-inline: auto; }
.key-display {
    display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
    padding: 4px 0 14px; margin-bottom: 16px; border-bottom: 1px solid var(--color-line);
    container-type: inline-size; min-width: 0;
}
.key-display-above { min-height: 1.4em; font: 400 16px/1.4 var(--font-mono); color: var(--color-muted); text-align: right; overflow-wrap: anywhere; }
.key-display-value { font: 600 clamp(22px, 12cqi, 44px)/1.15 var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.board.keys { grid-template-columns: repeat(var(--files), minmax(0, 1fr)); gap: 8px; max-width: none; }
.square.key {
    aspect-ratio: auto; height: 48px; border-radius: 10px; color: var(--color-text);
    font: inherit; cursor: pointer; container-type: normal;
}
.square.key .square-text { font: 500 18px/1 var(--font-mono), "Segoe UI Symbol", "Noto Sans Symbols 2", "Apple Symbols", sans-serif; }
.square.key:not(:disabled):hover { filter: brightness(0.95); }
.square.key:not(:disabled):active { filter: brightness(0.88); }
.square.key:disabled { opacity: 0.4; cursor: default; }
.square.key.empty { background: none; }
.square.key.tone-neutral { background: var(--color-surface); box-shadow: inset 0 0 0 1px var(--color-line); }
.square.key.tone-neutral .square-text { font-size: 15px; }
.square.key.tone-accent { background: var(--color-accent); color: var(--color-accent-text); }
.square.key.tone-ok { background: var(--color-ok-soft); color: var(--color-ok); }
.square.key.tone-warn { background: var(--color-warn-soft); color: var(--color-warn); }
.square.key.tone-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.board-rejection { margin-top: 12px; }

/* A theme's compact density: the same screen with less air in it. */
main.compact { padding-top: 20px; }
.compact .play, .compact .view, .compact .layout { gap: 12px; }
.compact .card-head { padding: 9px 14px; }
.compact .card-body, .compact .moves-body { padding: 12px 14px 14px; gap: 12px; }
.compact .rows { padding: 2px 0; }
.compact .rows > div { padding: 7px 14px; }
.compact .table th, .compact .table td { padding: 7px 14px; }
.compact .stat { padding: 10px 14px; }
.compact .last-move { padding: 6px 12px; }
.compact .board-card { padding: 12px 14px 14px; }
.compact .board-card .card-head { margin: -12px -14px 12px; }
.compact .result { padding: 16px; gap: 10px; }

/*
 * Wide: the pinned block dissolves into the grid. Head and last move span both
 * columns; the moves take the right one and stay on screen, and the view fills the left.
 */
@media (min-width: 721px) {
    .play { display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-auto-flow: row dense; gap: 20px; }
    .pinned { display: contents; }
    .play-head, .last-move { grid-column: 1 / -1; }
    .pinned > .side {
        grid-column: 2;
        position: sticky;
        top: 72px;
        align-self: start;
        display: flex;
        flex-direction: column;
        max-height: calc(100vh - 88px);
    }
    .side .moves-body { overflow-y: auto; }
    .view { grid-column: 1; }

    /* A view places its own moves, so there is no column beside it. */
    .play.laid-out { grid-template-columns: minmax(0, 1fr); }
    .play.laid-out .pinned > .side { grid-column: 1; position: static; max-height: none; }
}

/* ── The start ───────────────────────────────────────────── */

.landing { display: flex; flex-direction: column; gap: 48px; padding-top: 24px; }
.hero { display: flex; align-items: center; gap: 48px; }
.hero-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; flex: 1; }
.hero h1 { font-size: 40px; font-weight: 600; line-height: 1.15; }
.hero-copy > p { font-size: 16px; line-height: 1.6; color: var(--color-muted); max-width: 500px; }

.ask { display: flex; flex-direction: column; gap: 14px; width: 470px; flex: none; padding: 20px; scroll-margin-top: 80px; }
.ask h2 { font-size: 13px; font-weight: 600; }
.ask input { width: 100%; }
.ask .prompt { padding: 10px 12px; border-radius: var(--radius-md); background: var(--color-sunken); font: 13px/1.55 var(--font-mono); color: var(--color-muted); overflow-wrap: anywhere; }
.ask .note { display: flex; align-items: flex-start; gap: 8px; padding-top: 14px; border-top: 1px solid var(--color-line); font-size: 12px; color: var(--color-muted); }
.ask .note .icon { flex: none; margin-top: 2px; }

.section { display: flex; flex-direction: column; gap: 14px; }
.section-head h2 { font-size: 18px; font-weight: 600; }
.section-head p { font-size: 13px; color: var(--color-muted); }

.samples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.sample { display: flex; flex-direction: column; gap: 10px; height: 100%; padding: 18px; color: var(--color-text); }
.sample-head { display: flex; align-items: center; font-size: 15px; font-weight: 600; color: var(--color-text); }
.sample-head:hover { text-decoration: none; color: var(--color-accent); }
.sample .tags button.chip { padding: 2px 8px; border: 0; border-radius: var(--radius-pill); background: var(--color-sunken); font-size: 12px; cursor: pointer; }
.sample .tags button.chip:hover { color: var(--color-accent); }
#make { scroll-margin-top: 80px; }
.sample-head .icon { margin-left: auto; color: var(--color-accent); }
.sample p { font-size: 13px; color: var(--color-muted); }
.sample .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }

.make { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.make textarea {
    min-height: 170px;
    resize: vertical;
    background: var(--color-sunken);
    border-color: var(--color-line);
    font: 12.5px/1.5 var(--font-mono);
}
.make-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.made { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--color-ok); }
.made a { color: var(--color-accent); }
.made .muted { font-size: 13px; font-weight: 400; }
.problem {
    margin: 0;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--color-danger-soft);
    color: var(--color-danger);
    font: 13px/1.5 var(--font-mono);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ── A link that cannot be opened ────────────────────────── */

.failure { max-width: 600px; margin: 64px auto 0; display: flex; flex-direction: column; gap: 16px; padding: 28px; }
.failure-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--color-danger-soft); color: var(--color-danger); }
.failure h1 { font-size: 20px; font-weight: 600; }
.failure > p { font-size: 14px; color: var(--color-muted); margin-top: -10px; }
.failure pre { margin: 0; padding: 12px 14px; border-radius: var(--radius-md); background: var(--color-sunken); font: 13px/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.failure pre strong { display: block; color: var(--color-danger); font-weight: 600; }
.failure .actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Narrow ──────────────────────────────────────────────── */

@media (max-width: 720px) {
    .bar { padding: 0 16px; }
    .crumb, .bar-links { display: none; }

    /* Narrow, the detail rises from the bottom over a dimmed page. */
    .provenance-scrim { display: block; position: fixed; inset: 0; z-index: 4; background: rgb(20 22 26 / 0.4); }
    .provenance-details {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        max-height: 85vh;
        gap: 14px;
        padding: 10px 20px 28px;
        border: 0;
        border-radius: 16px 16px 0 0;
        box-shadow: none;
    }
    .provenance-details .grabber { display: block; align-self: center; width: 36px; height: 4px; border-radius: 2px; background: var(--color-line-strong); }
    .details-head h2 { font-size: 17px; }
    .details-section h3 { font-size: 13px; }
    .details-section p { font-size: 14px; }
    .details-actions button { flex: 1; justify-content: center; }
    main { padding: 0 0 32px; }

    /* What must stay in view is pinned under the bar; the view scrolls beneath it. */
    .play { gap: 0; }
    .pinned {
        position: sticky;
        top: 56px;
        z-index: 1;
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 14px 16px;
        background: var(--color-bg);
        box-shadow: var(--shadow-pinned);
    }
    .side .moves-body { max-height: 40vh; overflow-y: auto; }
    .view { padding: 16px 16px 0; gap: 16px; }

    .play-head { gap: 8px; }
    .play-head h1 { font-size: 20px; }
    .play-head .sub { display: none; }
    .play-head .actions button { padding: 5px 8px; }
    .play-head .actions .label { display: none; }
    .last-move .undo { display: none; }
    .rows > div { grid-template-columns: 90px minmax(0, 1fr); }
    .layout { gap: 16px; }
    .stat-value { font-size: 24px; }
    .stat-value.number { font-size: 20px; }
    .table th, .table td { padding: 9px 14px; }
    /* A narrow table keeps each value on one line and scrolls sideways, rather than breaking a date letter
       by letter; the buttons at the end of a line wrap instead, so none is out of sight. */
    .table th, .table td { white-space: nowrap; }
    .table td.row-actions { white-space: normal; min-width: 96px; }
    .row-actions .move { margin: 2px 0 2px 6px; }
    .row-actions .move + .move { margin-left: 6px; }

    .landing { gap: 36px; padding: 28px 16px 0; }
    .hero { flex-direction: column; align-items: stretch; gap: 24px; }
    .hero h1 { font-size: 30px; }
    .hero-copy > p { font-size: 15px; }
    .ask { width: auto; }
    .samples { grid-template-columns: minmax(0, 1fr); gap: 12px; }

    .failure { margin: 40px 16px 0; }
}

.boot { padding: 16px; font-family: var(--font-ui); color: var(--color-muted); }

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: 8px 16px;
    background: var(--color-warn-soft);
    color: var(--color-text);
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

/* ── How to write one: static, from doc/guide*.md ────────── */

/* Outside the app, so it is there for a reader that does not run the page: one article per
   language, the page's own shown. Laid out as a section of the start page, and only there. */
body:has(main .play) #guide, body:has(main .failure) #guide { display: none; }
/* Nor while the app loads, which would show it alone and then push it down; without scripts it stays. */
@media (scripting: enabled) { body:has(#app > .boot) #guide { display: none; } }
html:not([lang="ja"]) .guide > [lang="ja"], html[lang="ja"] .guide > [lang="en"] { display: none; }
/* What an AI reads, styles unapplied: the page never shows it. */
.guide > .for-ai { display: none; }
.guide { max-width: 1072px; margin: 0 auto; padding: 0 16px 64px; color: var(--color-text); scroll-margin-top: 80px; }
.guide article { display: flex; flex-direction: column; gap: 14px; }
.guide h2 { font-size: 18px; font-weight: 600; }
.guide h2 + p { margin-top: -12px; font-size: 13px; color: var(--color-muted); }
.guide code { font-family: var(--font-mono); }
.guide .card { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.guide pre { margin: 0; padding: 12px 14px; border: 1px solid var(--color-line); border-radius: var(--radius-md); background: var(--color-sunken); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.guide .card p { font-size: 13px; color: var(--color-muted); }
.guide ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; }
.guide li { display: flex; flex-direction: column; gap: 10px; padding: 18px; border: 1px solid var(--color-line); border-radius: var(--radius-lg); background: var(--color-surface); }
.guide li > p { font-size: 13px; color: var(--color-muted); }
.guide li > p:first-child a { display: flex; align-items: center; font-size: 15px; font-weight: 600; color: var(--color-text); }
.guide li > p:first-child a:hover { text-decoration: none; color: var(--color-accent); }
.guide li > p:first-child a::after {
    content: "";
    width: 16px; height: 16px;
    margin-left: auto;
    background: var(--color-accent);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='M13 5l7 7-7 7'/%3E%3C/svg%3E") center / contain no-repeat;
}
.guide li > p:last-child { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.guide li > p:last-child code { padding: 2px 8px; border-radius: var(--radius-pill); background: var(--color-sunken); font-size: 12px; font-weight: 500; line-height: 1.4; }
.guide ul ~ p { font-size: 12px; color: var(--color-muted); }
.guide ul ~ p + p { margin-top: -10px; }

@media (max-width: 720px) {
    .guide { padding: 0 16px 48px; }
    .guide ul { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}
