*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #050d16;
    --panel: rgba(12, 24, 40, 0.96);
    --line-real: #2a4a68;
    --text: #eef6ff;
    --muted: #93b2cf;
    --accent: #6fe3ff;
    --gold: #ffd76a;
}

html, body { height: 100%; overscroll-behavior: none; }

body {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Segoe UI', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

.stage { position: relative; width: 100%; height: 100%; }
#game { display: block; width: 100%; height: 100%; touch-action: none; }

.pause-btn {
    position: absolute;
    top: 50%;
    right: max(8px, env(safe-area-inset-right));
    transform: translateY(-50%);
    width: 36px; height: 32px;
    border: 1px solid var(--line-real);
    border-radius: 9px;
    background: rgba(5, 13, 22, 0.8);
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    z-index: 5;
}

.pause-btn:active { transform: translateY(-50%) scale(0.94); }

.overlay {
    position: absolute; inset: 0; display: none;
    align-items: center; justify-content: center; padding: 18px;
    background: rgba(2, 6, 12, 0.9);
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    z-index: 10;
}

.overlay.is-open { display: flex; }

.panel {
    width: 100%; max-width: 340px; max-height: 100%; overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px;
    padding: 22px 18px;
    border: 1px solid var(--line-real); border-radius: 20px;
    background: var(--panel);
    text-align: center;
    animation: pop 0.22s ease;
}

@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }

.title {
    font-size: clamp(1.9rem, 9vw, 2.5rem);
    font-weight: 800;
    letter-spacing: 0.18em;
    background: linear-gradient(135deg, var(--accent), #4c8bff 60%, var(--gold));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}

.panel-title { font-size: 1.5rem; font-weight: 800; letter-spacing: 0.08em; color: var(--gold); }
.subtitle { color: var(--muted); font-size: 0.85rem; line-height: 1.7; }

.modes { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.mode {
    display: flex; align-items: center; justify-content: space-between;
    padding: 13px 16px;
    border: 1px solid var(--line-real); border-radius: 13px;
    background: rgba(255, 255, 255, 0.05); color: var(--text);
    font-family: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.mode small { font-size: 0.68rem; font-weight: 500; color: var(--muted); }
.mode:active { transform: scale(0.98); border-color: var(--accent); }

.btn {
    min-height: 48px; padding: 13px 20px;
    border: 1px solid var(--line-real); border-radius: 14px;
    background: rgba(255, 255, 255, 0.06); color: var(--text);
    font-family: inherit; font-size: 0.94rem; font-weight: 700; letter-spacing: 0.05em;
    text-decoration: none; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: transform 0.12s ease;
}

.btn:active { transform: scale(0.96); }
.btn-primary { border-color: transparent; background: linear-gradient(135deg, var(--accent), #2b8fff); color: #03121c; }
.btn-secondary { border-color: #7a4dd8; background: rgba(122, 77, 216, 0.16); color: #e2d2ff; }

.best-line { font-size: 0.8rem; color: var(--muted); }
.best-line b { color: var(--gold); font-variant-numeric: tabular-nums; }

.toolbar { display: flex; justify-content: center; gap: 8px; margin-top: 2px; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 40px; height: 34px; padding: 0 10px;
    border: 1px solid var(--line-real); border-radius: 10px;
    background: rgba(255, 255, 255, 0.06); color: var(--text);
    font-family: inherit; font-size: 0.9rem; text-decoration: none; cursor: pointer;
}

.icon-btn-text { font-size: 0.76rem; font-weight: 700; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.stat { padding: 9px 6px; border-radius: 11px; background: rgba(255, 255, 255, 0.06); }
.stat b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.64rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) { .panel { animation: none; } }
