* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:root {
    --ink: #eaf0ff;
    --gold: #ffd76a;
    --muted: #94a3c8;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: #0d1230;
    color: var(--ink);
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    overscroll-behavior: none;
}

.wrap { position: relative; width: 100%; height: 100dvh; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---------- hud ---------- */
.hud {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 8px calc(10px + env(safe-area-inset-left));
    pointer-events: none;
}
.hud > * { pointer-events: auto; }
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid rgba(255, 215, 106, 0.28);
    border-radius: 10px;
    background: rgba(6, 10, 30, 0.42);
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    flex: 0 0 auto;
    backdrop-filter: blur(6px);
}
.icon-btn-text { font-size: 13px; }

.hud-mid { flex: 1; text-align: center; pointer-events: none; }
.clock {
    font-size: 27px;
    font-weight: 800;
    color: var(--gold);
    line-height: 1.05;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    font-variant-numeric: tabular-nums;
}
.clock.low { color: #ff8b7a; }
.score-line { font-size: 15px; font-weight: 700; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
.best { margin-left: 8px; font-size: 11px; font-weight: 500; color: var(--muted); }
.best b { color: var(--ink); }

.streak {
    position: absolute;
    top: 22%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    font-size: 26px;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.6);
    letter-spacing: 2px;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
}
.streak.show { animation: pop 0.85s ease forwards; }
@keyframes pop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
    25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
    70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -90%) scale(1); }
}

.toast {
    position: absolute;
    top: 34%;
    left: 50%;
    transform: translateX(-50%);
    padding: 7px 16px;
    border-radius: 10px;
    background: rgba(150, 40, 40, 0.82);
    font-size: 14px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
}
.toast.show { animation: fade 1.2s ease forwards; }
@keyframes fade {
    0% { opacity: 0; } 15% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; }
}

/* ---------- touch controls ---------- */
.stick {
    position: absolute;
    width: 116px;
    height: 116px;
    margin: -58px 0 0 -58px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.22);
    background: rgba(10, 16, 40, 0.28);
    pointer-events: none;
    z-index: 5;
}
.stick-knob {
    position: absolute;
    left: 50%; top: 50%;
    width: 52px; height: 52px;
    margin: -26px 0 0 -26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.jump-btn {
    position: absolute;
    right: calc(24px + env(safe-area-inset-right));
    bottom: calc(30px + env(safe-area-inset-bottom));
    width: 88px; height: 88px;
    border-radius: 50%;
    border: 2px solid rgba(255, 215, 106, 0.5);
    background: rgba(255, 215, 106, 0.16);
    color: var(--gold);
    font-size: 19px;
    font-weight: 800;
    font-family: inherit;
    z-index: 5;
    backdrop-filter: blur(4px);
}
.jump-btn:active { background: rgba(255, 215, 106, 0.36); }

/* ---------- overlays ---------- */
.overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(6, 9, 26, 0.9);
    z-index: 20;
}
.overlay.is-open { display: flex; }
.overlay-card {
    width: 100%;
    max-width: 330px;
    padding: 26px 20px;
    border-radius: 20px;
    background: linear-gradient(180deg, #1d2a5e, #131a3c);
    border: 1px solid rgba(255, 215, 106, 0.25);
    text-align: center;
}
.title { font-size: 31px; letter-spacing: 5px; color: var(--gold); }
.subtitle { margin: 8px 0 18px; font-size: 13px; color: var(--muted); }
.over-title { font-size: 26px; color: var(--gold); letter-spacing: 3px; }
.over-sub { margin: 6px 0 14px; font-size: 13px; color: var(--muted); min-height: 18px; }

.btn {
    min-height: 48px;
    padding: 0 18px;
    border: 1px solid rgba(255, 215, 106, 0.32);
    border-radius: 13px;
    background: rgba(0, 0, 0, 0.26);
    color: var(--ink);
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}
.btn-primary {
    background: linear-gradient(180deg, #ffdd85, #e3ab34);
    border-color: #ffe6a4;
    color: #2c2005;
}
.btn-wide { width: 100%; margin-top: 9px; }

.how { margin-top: 18px; text-align: left; }
.how-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 0;
    font-size: 12px;
    color: var(--muted);
}
.how-key { color: var(--ink); font-weight: 600; flex: 0 0 auto; }
.result-row {
    display: flex;
    justify-content: space-between;
    padding: 7px 4px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
