:root {
    --bg: #f6f3ec;
    --ink: #22243a;
    --muted: #5f6275;
    --panel: #ffffff;
    --rule: #e2ddd1;
    --accent: #3d6fb6;
    --board: #24357a;
    --board-2: #1b2760;
    --box: #a8743a;
    --red: #e8323c;
    --orange: #ff8a1c;
    --yellow: #fdd23c;
    --green: #4cbf3c;
    --blue: #2f8de4;
    --purple: #a24bd8;
    --bad: #b3261e;
    --selected: #eaf1fb;
}

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

* { 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: 4px; }
.drop__dots i:nth-child(1) { background: var(--red); }
.drop__dots i:nth-child(2) { background: var(--orange); }
.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); }

/* ---- 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--none { background: var(--bg); }
.cell.in-move .piece { box-shadow: 0 0 0 3px #fff; }

.piece {
    display: grid;
    place-items: center;
    width: 82%;
    aspect-ratio: 1;
    border-radius: 18%;
    font-size: clamp(.75rem, 3.4vw, 1.25rem);
    line-height: 1;
    color: #fff;
    transition: box-shadow .15s;
}
.piece--cube { box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .22); }
.cell.in-move .piece--cube { box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .22), 0 0 0 3px #fff; }
.piece--box { background: var(--box); border: 3px solid #6b4320; border-radius: 8%; }
.piece--balloon { width: 60%; border-radius: 50% 50% 46% 46%; background: #f2f2f2; }
.piece--duck { background: transparent; font-size: clamp(1rem, 5vw, 1.8rem); }
.piece--rocket, .piece--bomb { background: #3a3f5c; font-weight: 700; }
.piece--disco { border-radius: 50%; width: 70%; background: #e9eefc; color: #3a3f5c; border: 4px solid; }
.piece--none { display: none; }
.piece--empty { border: 2px dotted rgba(255, 255, 255, .4); }
.piece--unknown { background: rgba(255, 255, 255, .2); font-weight: 700; }

.tap-ring { fill: rgba(255, 255, 255, .92); stroke: #1d1d2b; stroke-width: .05; }
.tap-label { font: 800 .2px system-ui, sans-serif; text-anchor: middle; fill: #1d1d2b; }

.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: .75rem; }
.swatch .piece--balloon { border: 1px solid var(--muted); }
.swatch .piece--disco { border-width: 3px; }
.swatch .piece--none { display: block; border-radius: 4px; 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: .65rem; }
.goal .piece--balloon { border: 1px solid var(--muted); }

/* ---- 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__icon { flex: none; width: 20px; font-size: .7rem; }
.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); }
