*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    /* 星空体系配色变量 */
    --space-0: #03041a;
    --space-1: #070a26;
    --space-2: #0d1236;
    --space-3: #161e4a;
    --nebula-cyan: #4cf0ff;
    --nebula-teal: #38e5d0;
    --nebula-violet: #a060ff;
    --nebula-pink: #ff6b9d;
    --nebula-gold: #ffcc44;
    --nebula-green: #7dffb0;
    --text-hi: #f2f6ff;
    --text-mid: #b6c3e8;
    --text-lo: #7d8cbd;
    --text-dim: #586aa0;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--space-0);
    color: var(--text-hi);
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Heiti SC", Arial, sans-serif;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#app {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#game {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

/* ===== HUD ===== */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    z-index: 10;
    pointer-events: none;
    font-size: 13px;
    flex-wrap: wrap;
}

.hud-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.hud-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(8, 14, 38, 0.78);
    border: 1px solid rgba(90, 140, 240, 0.38);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.hud-chip .icon {
    font-size: 14px;
    opacity: 0.95;
}

.hud-chip .label {
    color: var(--text-lo);
    font-size: 11px;
    letter-spacing: 0.5px;
}

.hud-chip .value {
    color: var(--text-hi);
    font-weight: 700;
    font-family: "Menlo", "Consolas", monospace;
    font-size: 14px;
    text-shadow: 0 0 10px rgba(120, 180, 255, 0.35);
}

.hud-chip.danger {
    border-color: rgba(255, 90, 120, 0.7);
    background: rgba(48, 10, 26, 0.82);
    box-shadow: 0 0 16px rgba(255, 80, 110, 0.4);
}

.hud-chip.danger .value {
    color: #ff7d9d;
}

.hud-chip.combo-active {
    border-color: rgba(255, 190, 70, 0.72);
    background: rgba(48, 32, 6, 0.82);
    box-shadow: 0 0 16px rgba(255, 190, 70, 0.45);
}

.hud-chip.combo-active .value {
    color: #ffd76b;
}

/* ===== Bottom Hint ===== */
.bottom-hint {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 11.5px;
    color: rgba(140, 165, 220, 0.72);
    z-index: 10;
    pointer-events: none;
    padding: 0 16px;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.bottom-hint kbd {
    display: inline-block;
    padding: 1px 6px;
    background: rgba(30, 50, 110, 0.72);
    border: 1px solid rgba(100, 150, 240, 0.55);
    border-radius: 4px;
    font-family: "Menlo", monospace;
    font-size: 10.5px;
    color: #b6c9f0;
    margin: 0 2px;
}

/* ===== Overlays ===== */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: radial-gradient(ellipse at center, rgba(10, 14, 44, 0.82), rgba(3, 4, 22, 0.9));
    animation: fadeIn 0.22s ease;
}

.overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===== Panel ===== */
.panel {
    width: min(92vw, 500px);
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px 32px;
    background: radial-gradient(circle at 20% 0%, rgba(90, 140, 255, 0.16), transparent 55%),
    radial-gradient(circle at 85% 100%, rgba(160, 96, 255, 0.14), transparent 55%),
    linear-gradient(160deg, rgba(16, 22, 54, 0.98), rgba(7, 10, 30, 0.99));
    border: 1px solid rgba(96, 148, 250, 0.42);
    border-radius: 20px;
    box-shadow: 0 0 0 1px rgba(120, 170, 255, 0.1),
    0 28px 70px rgba(0, 0, 0, 0.72),
    0 0 100px rgba(76, 140, 255, 0.18);
    animation: panelIn 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes panelIn {
    from {
        transform: translateY(18px) scale(0.96);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.panel h1,
.panel h2 {
    margin: 0 0 6px;
    font-size: 23px;
    font-weight: 700;
    letter-spacing: 3px;
    text-align: center;
    background: linear-gradient(135deg, #6ef2ff 0%, #7aa6ff 45%, #b478ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 16px rgba(96, 180, 255, 0.35));
}

.panel .subtitle {
    text-align: center;
    color: var(--text-lo);
    font-size: 12px;
    letter-spacing: 4px;
    margin-bottom: 22px;
    text-transform: uppercase;
}

/* ===== Form ===== */
.field {
    margin-bottom: 14px;
}

.field label {
    display: block;
    font-size: 12px;
    color: var(--text-mid);
    margin-bottom: 6px;
    letter-spacing: 0.6px;
    font-weight: 500;
}

.field select {
    width: 100%;
    padding: 11px 14px;
    background: rgba(6, 10, 30, 0.92);
    border: 1px solid rgba(90, 130, 220, 0.42);
    border-radius: 10px;
    color: var(--text-hi);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%23a8b8e0' d='M6 8L2 4h8z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.field select:focus {
    border-color: var(--nebula-cyan);
    background: rgba(10, 20, 50, 0.95);
    box-shadow: 0 0 0 3px rgba(76, 240, 255, 0.14);
}

.field select option {
    background: #0a0e28;
    color: var(--text-hi);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 1px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.22s, filter 0.22s, background 0.22s;
    outline: none;
    text-decoration: none;
    box-sizing: border-box;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #3573f0 0%, #6a5cff 55%, #a04df5 100%);
    color: #ffffff;
    box-shadow: 0 6px 22px rgba(90, 120, 255, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:hover {
    box-shadow: 0 10px 32px rgba(90, 120, 255, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(30, 42, 92, 0.72);
    color: #c8d6f8;
    border: 1px solid rgba(100, 140, 225, 0.42);
}

.btn-secondary:hover {
    background: rgba(44, 60, 130, 0.82);
    border-color: rgba(130, 170, 255, 0.68);
}

.btn-ghost {
    margin-top: 10px;
    background: rgba(22, 32, 72, 0.6);
    color: #a8beff;
    border: 1px dashed rgba(110, 150, 240, 0.55);
    font-size: 14px;
}

.btn-ghost:hover {
    background: rgba(38, 56, 118, 0.78);
    color: #dce8ff;
    border-color: rgba(150, 190, 255, 0.85);
}

.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.btn-row .btn {
    flex: 1;
}

/* ===== 更多游戏导航 ===== */
.more-games-nav {
    margin-top: 16px;
    text-align: center;
    font-size: 12.5px;
}

.more-games-nav a {
    color: #8fa6e0;
    text-decoration: none;
    border-bottom: 1px dashed rgba(120, 160, 240, 0.55);
    padding-bottom: 1px;
    transition: color 0.2s, border-color 0.2s;
}

.more-games-nav a:hover {
    color: var(--nebula-cyan);
    border-color: var(--nebula-cyan);
}

/* ===== Description ===== */
.desc {
    background: rgba(6, 12, 34, 0.7);
    border: 1px solid rgba(70, 100, 170, 0.32);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 12.5px;
    line-height: 1.8;
    color: #a8b8dd;
    margin-bottom: 20px;
}

.desc strong {
    color: var(--nebula-cyan);
    font-weight: 600;
}

.desc em {
    color: var(--nebula-gold);
    font-style: normal;
    font-weight: 600;
}

/* ===== Game Over ===== */
.game-over-title {
    text-align: center;
    font-size: 27px;
    font-weight: 700;
    letter-spacing: 5px;
    margin: 0 0 4px;
    background: linear-gradient(135deg, #ff6b8a 0%, #ffb060 55%, #ffd45e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 18px rgba(255, 120, 150, 0.4));
}

.final-score {
    text-align: center;
    margin: 16px 0 22px;
}

.final-score .label {
    font-size: 11px;
    color: var(--text-lo);
    letter-spacing: 3px;
    text-transform: uppercase;
}

.final-score .value {
    font-size: 54px;
    font-weight: 800;
    font-family: "Menlo", "Consolas", monospace;
    background: linear-gradient(135deg, #6ef2ff 0%, #7aa6ff 50%, #b478ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-top: 6px;
    filter: drop-shadow(0 0 24px rgba(96, 200, 255, 0.5));
}

.final-score .high {
    font-size: 12px;
    color: var(--text-lo);
    margin-top: 10px;
}

.final-score .high em {
    color: var(--nebula-gold);
    font-style: normal;
    font-weight: 700;
    font-family: "Menlo", monospace;
    text-shadow: 0 0 12px rgba(255, 204, 68, 0.55);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 22px;
}

.stat-box {
    background: rgba(7, 13, 36, 0.78);
    border: 1px solid rgba(70, 105, 180, 0.3);
    border-radius: 11px;
    padding: 12px 14px;
    transition: border-color 0.2s, background 0.2s;
}

.stat-box:hover {
    border-color: rgba(110, 170, 255, 0.6);
    background: rgba(12, 22, 52, 0.85);
}

.stat-box .label {
    font-size: 11px;
    color: var(--text-lo);
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.stat-box .value {
    font-size: 20px;
    font-weight: 700;
    font-family: "Menlo", "Consolas", monospace;
    color: var(--text-hi);
    line-height: 1;
}

.stat-box .value.good {
    color: var(--nebula-green);
    text-shadow: 0 0 12px rgba(125, 255, 176, 0.4);
}

.stat-box .value.bad {
    color: #ff7d9d;
    text-shadow: 0 0 12px rgba(255, 107, 141, 0.4);
}

.stat-box .value.accent {
    color: var(--nebula-cyan);
    text-shadow: 0 0 12px rgba(76, 240, 255, 0.4);
}

.stat-box .value.gold {
    color: var(--nebula-gold);
    text-shadow: 0 0 12px rgba(255, 204, 68, 0.4);
}

/* ===== Pause ===== */
#pauseOverlay .pause-panel {
    text-align: center;
    padding: 40px 60px;
    background: radial-gradient(circle at 50% 0%, rgba(90, 140, 255, 0.16), transparent 60%),
    rgba(8, 12, 34, 0.94);
    border: 1px solid rgba(96, 148, 250, 0.48);
    border-radius: 18px;
    box-shadow: 0 0 80px rgba(80, 130, 255, 0.3);
}

#pauseOverlay .pause-title {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 10px;
    background: linear-gradient(135deg, #6ef2ff, #b478ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 14px;
    filter: drop-shadow(0 0 20px rgba(96, 200, 255, 0.4));
}

#pauseOverlay .pause-hint {
    font-size: 13px;
    color: var(--text-mid);
    letter-spacing: 1px;
}

#pauseOverlay .pause-hint kbd {
    display: inline-block;
    padding: 2px 10px;
    background: rgba(30, 50, 110, 0.72);
    border: 1px solid rgba(100, 150, 240, 0.55);
    border-radius: 5px;
    font-family: "Menlo", monospace;
    font-size: 12px;
    color: #b6c9f0;
    margin: 0 3px;
}

/* ===== Responsive ===== */
@media (max-width: 560px) {
    .hud {
        padding: 8px 10px;
        font-size: 11px;
        gap: 6px;
    }

    .hud-chip {
        padding: 4px 9px;
        font-size: 11px;
    }

    .hud-chip .label {
        display: none;
    }

    .hud-chip .value {
        font-size: 12px;
    }

    .panel {
        padding: 22px 20px;
    }

    .final-score .value {
        font-size: 40px;
    }

    .stat-box .value {
        font-size: 17px;
    }

    .bottom-hint {
        font-size: 10px;
    }
}

.panel::-webkit-scrollbar {
    width: 6px;
}

.panel::-webkit-scrollbar-track {
    background: transparent;
}

.panel::-webkit-scrollbar-thumb {
    background: rgba(110, 150, 240, 0.35);
    border-radius: 3px;
}

.panel::-webkit-scrollbar-thumb:hover {
    background: rgba(130, 180, 255, 0.5);
}