:root {
    --bg: #f6f3ec;
    --ink: #22243a;
    --muted: #5f6275;
    --panel: #ffffff;
    --rule: #e2ddd1;
    --accent: #3d6fb6;
    --board: #1d3b48;
    --board-2: #1b2a4a;
    --wall: #142a33;
    --red: #e2324a;
    --yellow: #f7c948;
    --green: #5cb98c;
    --blue: #5b95cb;
    --purple: #9b5fc0;
    --bad: #b3261e;
    --selected: #eaf1fb;
    --note-bg: #fff6dc;
    --note-rule: #f0d98a;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #15161d;
        --ink: #ececf1;
        --muted: #a3a6b6;
        --panel: #1f2029;
        --rule: #34364a;
        --accent: #8db4ee;
        --bad: #ff8a80;
        --selected: #26304a;
        --note-bg: #2e2a1a;
        --note-rule: #5c5226;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.container { max-width: 1000px; margin: 0 auto; padding: 16px; }

header h1 { margin: 8px 0 4px; font-size: 1.9rem; }
header p { margin: 0 0 8px; color: var(--muted); }
header nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0; margin: 0 0 16px; }
header nav a { color: var(--accent); }
header nav a.ko-fi-nav-link { font-weight: 600; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 20px;
    min-width: 0;
}
.panel h2 { margin: 0 0 6px; font-size: 1.25rem; }
.caption { margin: 0 0 12px; color: var(--muted); }

.btn {
    display: inline-block;
    font: 700 1rem/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    padding: 11px 22px;
    border-radius: 999px;
    border: 0;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

.link {
    font: inherit;
    color: var(--accent);
    background: none;
    border: 0;
    padding: 0;
    text-decoration: underline;
    cursor: pointer;
}

/* ---- upload ---- */
.drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 28px 16px;
    text-align: center;
    border: 2px dashed var(--rule);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.drop:hover, .drop.is-over, .drop:focus-within { border-color: var(--accent); background: var(--selected); }
.drop strong { font-size: 1.2rem; }
.drop span { color: var(--muted); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop__dots { display: flex; gap: 8px; margin-bottom: 4px; }
.drop__dots i { width: 16px; height: 16px; border-radius: 50%; }
.drop__dots i:nth-child(1) { background: var(--red); }
.drop__dots i:nth-child(2) { background: var(--yellow); }
.drop__dots i:nth-child(3) { background: var(--green); }
.drop__dots i:nth-child(4) { background: var(--blue); }
.drop__dots i:nth-child(5) { background: var(--purple); }
.or { margin: 12px 0 0; text-align: center; color: var(--muted); }
.status { margin: 8px 0 0; text-align: center; font-weight: 600; }
.status:empty { display: none; }
.status.is-error { color: var(--bad); }
.disclaimer {
    margin: 14px 0 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--note-bg);
    border: 1px solid var(--note-rule);
    font-size: .9rem;
}

/* ---- workspace ---- */
.workspace {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr);
    grid-template-areas: "shot board" "shot moves";
    gap: 0 20px;
    align-items: start;
}
.workspace .shot { grid-area: shot; }
#board-section { grid-area: board; }
#moves-section { grid-area: moves; }
.workspace.no-shot { grid-template-columns: minmax(0, 1fr); grid-template-areas: "board" "moves"; }

@media (max-width: 760px) {
    .workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "moves" "shot" "board"; }
    .workspace.no-shot { grid-template-areas: "board" "moves"; }
}

.shot__frame { border-radius: 10px; overflow: hidden; background: #000; }
#shot { display: block; width: 100%; height: auto; }

/* ---- board ---- */
.board-wrap { position: relative; max-width: 440px; margin: 0 auto 14px; }
.board {
    display: grid;
    gap: 0;
    background: linear-gradient(180deg, var(--board), var(--board-2));
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
}
.board-path { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.cell {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
}
.cell:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }
.cell--wall { background: var(--wall); }
.cell--none { background: var(--bg); }
.cell.in-path .piece { transform: scale(1.12); }

.piece {
    display: grid;
    place-items: center;
    width: 56%;
    aspect-ratio: 1;
    border-radius: 50%;
    font-size: clamp(.7rem, 3vw, 1.1rem);
    line-height: 1;
    transition: transform .15s;
}
.piece--anchor { background: #000; color: #fff; box-shadow: 0 0 0 2px #fff inset; }
.piece--wild { background: conic-gradient(var(--red), var(--yellow), var(--green), var(--blue), var(--purple), var(--red)); }
.piece--piece { border: 3px solid #fff; }
.piece--wall, .piece--none { display: none; }
.piece--empty { border: 2px dotted rgba(255, 255, 255, .4); }
.piece--unknown { background: rgba(255, 255, 255, .2); color: #fff; font-weight: 700; }

.path-line { fill: none; stroke: #fff; stroke-width: .16; stroke-linecap: round; stroke-linejoin: round; opacity: .95; }
.path-step { fill: #fff; stroke: var(--ink); stroke-width: .03; }
.path-num { font: 700 .2px system-ui, sans-serif; text-anchor: middle; fill: #22243a; }

.palette { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.swatch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    font-size: .85rem;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    border: 1px solid var(--rule);
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
}
.swatch .piece { width: 22px; font-size: .7rem; }
.swatch .piece--piece { border-color: var(--ink); border-width: 2px; }
.swatch .piece--wall, .swatch .piece--none { display: block; border-radius: 4px; }
.swatch .piece--wall { background: var(--wall); }
.swatch .piece--none { background: transparent; border: 2px dashed var(--muted); }
.swatch[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

.size { display: flex; gap: 16px; margin-bottom: 12px; }
.size select { font: inherit; margin-left: 4px; }

.goals { border: 1px solid var(--rule); border-radius: 10px; padding: 8px 12px 10px; margin: 0; }
.goals legend { font-weight: 600; padding: 0 4px; }
.goals legend span { font-weight: 400; color: var(--muted); font-size: .9rem; }
#goals { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.goal { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.goal .piece { width: 18px; font-size: .6rem; }

/* ---- moves ---- */
.best { font-size: 1.1rem; font-weight: 600; margin: 0 0 12px; }
.moves { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.move {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    font: inherit;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--rule);
    background: var(--panel);
    color: var(--ink);
    cursor: pointer;
}
.move.is-selected { background: var(--selected); border-color: var(--accent); }
.move__dot { flex: none; width: 16px; height: 16px; border-radius: 50%; }
.move__text { flex: 1; }
.move__text small { display: block; color: var(--muted); }
.move__score { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }

.notes p { margin: 8px 0; }

.footer { padding: 20px; text-align: center; border-top: 1px solid var(--rule); }
.footer h2 { margin: 0 0 4px; font-size: 1.1rem; }
.footer p { margin: 0 0 14px; color: var(--muted); }
