:root {
    --bg: #f5f7fa;
    --fg: #0b1426;
    --muted: #5b6470;
    --accent: #d23e3e;
    --frame: #0b1426;
    --frame-shadow: rgba(0, 0, 0, 0.18);
    --overlay-bg: rgba(255, 255, 255, 0.78);
    --kbd-bg: #e7ecf2;
    --kbd-border: #c5cdd6;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1426;
        --fg: #e8eef7;
        --muted: #8a96a8;
        --accent: #ff6b6b;
        --frame: #e8eef7;
        --frame-shadow: rgba(0, 0, 0, 0.6);
        --overlay-bg: rgba(11, 20, 38, 0.78);
        --kbd-bg: #1f2a44;
        --kbd-border: #2c3a58;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overscroll-behavior: none;
    touch-action: manipulation;
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.stage {
    width: 100%;
    max-width: 820px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hud {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 0 4px;
}

.title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.scores {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-variant-numeric: tabular-nums;
}

.score {
    font-size: 20px;
    font-weight: 600;
}

.score-sep, .hi-label {
    color: var(--muted);
    font-size: 14px;
}

.hi-label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.game-frame {
    position: relative;
    border: 2px solid var(--frame);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px var(--frame-shadow);
    line-height: 0;
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--overlay-bg);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    line-height: 1.4;
}

.overlay.show { display: flex; }

.overlay-card {
    text-align: center;
    padding: 20px 28px;
}

.overlay-title {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 700;
}

.overlay-hint {
    margin: 0 0 4px;
    font-size: 15px;
}

.overlay-sub {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

kbd {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid var(--kbd-border);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--kbd-bg);
    font: inherit;
    font-size: 12px;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 13px;
    padding: 0 4px;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-treat { background: #c08457; }
.dot-carrot { background: #ff8c3a; }
.dot-rabbit { background: #d8d8d8; border: 1px solid var(--muted); }

@media (max-width: 480px) {
    .title { font-size: 18px; }
    .score { font-size: 17px; }
    .legend { font-size: 12px; gap: 12px; }
    .overlay-title { font-size: 18px; }
}
