:root {
    --bg: #0b1220;
    --panel: #16233a;
    --panel-2: #1e3050;
    --line: #2a3f60;
    --text: #e8eefb;
    --dim: #7f93b3;
    --accent: #38bdf8;
    --p1: #38bdf8;
    --p2: #fbbf24;
    --ok: #4ade80;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    background: radial-gradient(120% 90% at 50% 0%, #16233a 0%, var(--bg) 60%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    display: flex;
    justify-content: center;
    padding: 16px 16px 32px;
}

.game {
    width: 100%;
    max-width: 660px;
}

.game__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

h1 {
    font-size: 1.3rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    margin: 0;
}

h1::after {
    content: "";
    display: block;
    width: 42px;
    height: 3px;
    margin-top: 6px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--p1), var(--p2));
}

.btn {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 16px;
    font: inherit;
    font-size: .82rem;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.btn:hover {
    background: #27405f;
    border-color: var(--accent);
}

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #06121f;
    font-weight: 700;
}

.btn--primary:hover {
    background: #7dd3fc;
}

/* ---- scoreboard ---- */
.score {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    margin: 0 0 12px;
    padding: 0;
}

.score li {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 9px 10px;
    text-align: center;
}

.score b {
    display: block;
    font-size: 1.5rem;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.score span {
    display: block;
    font-size: .58rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--dim);
    margin-top: 4px;
}

.score__p1 {
    border-left: 3px solid var(--p1);
}

.score__p1 b {
    color: var(--p1);
}

.score__p2 {
    border-right: 3px solid var(--p2);
}

.score__p2 b {
    color: var(--p2);
}

.score__mid b {
    font-size: 1rem;
    color: var(--dim);
    padding-top: 5px;
}

/* ---- stage ---- */
.stage {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #0e172a;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    touch-action: none;
}

/* [hidden] loses to display:flex on the rule below, so restore it */
.over[hidden] {
    display: none;
}

.over {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    background: rgba(11, 18, 32, .9);
    backdrop-filter: blur(3px);
    padding: 20px;
}

.over h2 {
    margin: 0;
    font-size: 1.45rem;
}

.over p {
    margin: 0 0 6px;
    color: var(--dim);
    font-size: .88rem;
    max-width: 28em;
    line-height: 1.6;
}

/* ---- touch pads ---- */
.touches {
    display: none;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
}

.touch {
    display: grid;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(2, 42px);
    gap: 5px;
}

.touch button {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--text);
    font-size: .9rem;
    cursor: pointer;
    touch-action: manipulation;
}

.touch button:active {
    background: var(--accent);
    color: #06121f;
}

.touch--p1 button:active {
    background: var(--p1);
}

.touch--p2 button:active {
    background: var(--p2);
}

.touch [data-dir="up"] {
    grid-column: 2;
    grid-row: 1;
}

.touch [data-dir="left"] {
    grid-column: 1;
    grid-row: 2;
}

.touch [data-dir="down"] {
    grid-column: 2;
    grid-row: 2;
}

.touch [data-dir="right"] {
    grid-column: 3;
    grid-row: 2;
}

.hintline {
    margin: 12px 2px 0;
    font-size: .76rem;
    color: var(--dim);
    line-height: 1.55;
}

kbd {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0 4px;
    font-size: .66rem;
    color: var(--text);
    margin: 0 1px;
}

@media (pointer: coarse) {
    .touches {
        display: flex;
    }
}

@media (max-width: 480px) {
    .score span kbd {
        display: none;
    }
}
