:root {
    --bg: #0b0f14;
    --ink: #f2f5f7;
    --muted: #9aa7b2;
    --win: #4ade80;
    --lose: #f87171;
    --draw: #fbbf24;
    --accent: #61dafb;
    --panel: rgba(17, 23, 31, 0.72);
    --edge: rgba(255, 255, 255, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--ink);
    font-family: "Space Grotesk", system-ui, sans-serif;
}

#stage {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: manipulation;
}

.hud-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 14px 16px 0;
    text-align: center;
    pointer-events: none;
}

h1 {
    margin: 0;
    font-size: clamp(14px, 1.8vw, 18px);
    color: var(--muted);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

h1 span {
    color: var(--accent);
}

.status {
    margin: 4px 0 0;
    min-height: 1.4em;
    font-size: clamp(18px, 2.8vw, 28px);
    font-weight: 700;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.8);
    transition: color 0.25s;
}

.status.win { color: var(--win); }
.status.lose { color: var(--lose); }
.status.draw { color: var(--draw); }

.status.pop {
    animation: pop 0.45s ease-out;
}

@keyframes pop {
    0% { transform: scale(0.7); opacity: 0; }
    60% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); }
}

/* The 3D board carries the score; this line is for screen readers and the no-WebGL case. */
.score-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.no-webgl .score-text {
    position: static;
    width: auto;
    height: auto;
    clip: auto;
    margin: 18px 0 0;
    font-size: 28px;
}

.draws {
    margin-left: 12px;
    color: var(--muted);
    font-size: 0.7em;
}

.hud-bottom {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 8px;
    max-width: calc(100% - 32px);
    background: var(--panel);
    border: 1px solid var(--edge);
    border-radius: 14px;
    backdrop-filter: blur(10px);
}

.hud-bottom button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--edge);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    font: inherit;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s, border-color 0.15s;
}

.hud-bottom button:hover:not(:disabled),
.hud-bottom button:focus-visible {
    background: rgba(97, 218, 251, 0.18);
    border-color: var(--accent);
    outline: none;
}

.hud-bottom button:active:not(:disabled) {
    transform: translateY(1px);
}

.hud-bottom button:disabled {
    opacity: 0.45;
    cursor: default;
}

.hud-bottom .reset {
    margin-left: 6px;
    color: var(--muted);
}

kbd {
    padding: 1px 6px;
    border: 1px solid var(--edge);
    border-radius: 5px;
    color: var(--muted);
    font-family: inherit;
    font-size: 12px;
}

.webgl-error {
    position: fixed;
    top: 50%;
    left: 16px;
    right: 16px;
    transform: translateY(-50%);
    text-align: center;
    color: var(--muted);
}

@media (max-width: 560px) {
    .hud-bottom {
        bottom: 12px;
        gap: 6px;
        padding: 6px;
    }

    .hud-bottom button {
        flex-direction: column;
        justify-content: center;
        gap: 2px;
        padding: 8px 10px;
        font-size: 14px;
    }

    kbd {
        display: none;
    }
}
