:root {
    --bg-dark: #0b0e17;
    --panel-bg: rgba(18, 23, 38, 0.85);
    --panel-border: rgba(255, 255, 255, 0.14);
    --accent: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.5);
    --accent-secondary: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    color: var(--text-main);
}

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100vh;
    cursor: crosshair;
}

/* ================= HUD 顶栏与状态 ================= */
#hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 18px 24px;
}

#hud.hidden {
    display: none;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.hud-card {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 12px 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
}

.hud-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 260px;
}

.level-badge-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.level-tag {
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.level-title-hud {
    font-size: 16px;
    font-weight: 800;
    color: #fff;
}

.progress-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}

.progress-bar-bg {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #10b981, #06b6d4, #8b5cf6);
    border-radius: 999px;
    transition: width 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-star-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.75);
    left: 80%;
}

.claim-win-btn {
    margin-top: 4px;
    background: linear-gradient(135deg, #10b981, #059669);
    border: 1px solid #34d399;
    color: #fff;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);
    transition: transform 0.18s ease;
}

.claim-win-btn:hover {
    transform: scale(1.03);
}

.claim-win-btn.hidden {
    display: none;
}

/* 中央计时器与连击 */
.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.timer-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    border-radius: 999px;
}

.timer-icon {
    font-size: 20px;
}

.timer-value {
    font-size: 26px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
}

.timer-value.urgent {
    color: var(--danger);
    animation: pulseUrgent 0.6s infinite alternate;
}

@keyframes pulseUrgent {
    from { transform: scale(1); }
    to { transform: scale(1.12); }
}

.combo-banner {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    padding: 4px 16px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.45);
    transform: scale(0);
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.combo-banner.active {
    transform: scale(1);
}

/* 右侧黑洞规模与快捷按钮 */
.hud-right {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.size-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 210px;
}

.size-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.size-tier-name {
    font-size: 15px;
    font-weight: 800;
    color: #38bdf8;
}

.size-meters {
    font-size: 18px;
    font-weight: 900;
    color: #fff;
}

.next-tier-bar-bg {
    width: 100%;
    height: 7px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    overflow: hidden;
}

.next-tier-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f59e0b, #ec4899);
    transition: width 0.15s ease-out;
}

.score-sub {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.hud-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.icon-btn:hover {
    background: rgba(139, 92, 246, 0.3);
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* ================= HUD 底栏：技能、提示与雷达 ================= */
.hud-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.skill-panel {
    display: flex;
    align-items: center;
    gap: 14px;
}

.skill-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.28), rgba(6, 182, 212, 0.28));
    border: 1.5px solid rgba(139, 92, 246, 0.6);
    border-radius: 16px;
    padding: 10px 18px;
    color: #fff;
    cursor: pointer;
    pointer-events: auto;
    overflow: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 6px 24px rgba(139, 92, 246, 0.3);
}

.skill-btn:hover:not(.cooldown) {
    transform: translateY(-2px) scale(1.02);
    border-color: #38bdf8;
    box-shadow: 0 8px 28px rgba(56, 189, 248, 0.45);
}

.skill-btn.cooldown {
    opacity: 0.65;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.15);
}

.skill-btn.active-skill {
    border-color: #f59e0b;
    box-shadow: 0 0 25px rgba(245, 158, 11, 0.7);
    animation: skillGlow 0.5s infinite alternate;
}

@keyframes skillGlow {
    from { box-shadow: 0 0 15px rgba(245, 158, 11, 0.5); }
    to { box-shadow: 0 0 30px rgba(245, 158, 11, 0.9); }
}

.skill-icon {
    font-size: 26px;
}

.skill-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.skill-name {
    font-size: 14px;
    font-weight: 800;
}

.skill-key {
    font-size: 11px;
    color: #cbd5e1;
}

.controls-hint {
    font-size: 12px;
    color: var(--text-muted);
    background: rgba(15, 23, 42, 0.7);
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* 右下角小地图雷达 */
.minimap-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px;
}

#minimapCanvas {
    width: 140px;
    height: 140px;
    border-radius: 12px;
    background: rgba(10, 14, 26, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.minimap-legend {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: var(--text-muted);
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 3px;
}

/* 中央升级横幅提示 */
#centerToast {
    position: fixed;
    top: 22%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    pointer-events: none;
    z-index: 25;
    text-align: center;
    opacity: 0;
    transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#centerToast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.toast-title {
    font-size: 32px;
    font-weight: 900;
    background: linear-gradient(135deg, #fde047, #f97316, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.65));
}

.toast-sub {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    margin-top: 4px;
}

/* ================= 模态框与主菜单 ================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.78), rgba(6, 9, 18, 0.94));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none;
}

.menu-container {
    width: 100%;
    max-width: 980px;
    max-height: 92vh;
    overflow-y: auto;
    background: rgba(19, 25, 43, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 30px 34px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.menu-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.game-logo {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 38px;
    font-weight: 900;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #c084fc, #38bdf8, #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-hole-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: radial-gradient(circle, #000 48%, #8b5cf6 64%, #06b6d4 78%, transparent 100%);
    box-shadow: 0 0 22px rgba(139, 92, 246, 0.8);
    display: inline-block;
}

.game-subtitle {
    color: var(--text-muted);
    font-size: 15px;
}

/* 模式与皮肤工具条 */
.settings-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px 20px;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-label {
    font-size: 13px;
    font-weight: 700;
    color: #cbd5e1;
}

.mode-pills, .skin-pills {
    display: flex;
    gap: 8px;
}

.pill-btn {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #e2e8f0;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pill-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}

.pill-btn.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

.skin-dot-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
}

.skin-dot-btn:hover {
    transform: scale(1.15);
}

.skin-dot-btn.active {
    border-color: #fff;
    transform: scale(1.2);
    box-shadow: 0 0 14px rgba(255, 255, 255, 0.6);
}

/* 5大关卡选择网格 */
.levels-section-title {
    font-size: 16px;
    font-weight: 800;
    color: #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(265px, 1fr));
    gap: 16px;
}

.level-card {
    background: rgba(30, 41, 59, 0.65);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 18px;
    cursor: pointer;
    transition: all 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: var(--card-accent, var(--accent));
}

.level-card:hover {
    transform: translateY(-5px);
    border-color: var(--card-accent, var(--accent));
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
    background: rgba(30, 41, 59, 0.92);
}

.level-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.level-icon-large {
    font-size: 34px;
    line-height: 1;
}

.level-stars {
    font-size: 16px;
    letter-spacing: 2px;
}

.level-card-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.level-card-title {
    font-size: 19px;
    font-weight: 800;
    color: #fff;
    margin: 2px 0 6px 0;
}

.level-card-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.45;
}

.level-card-targets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.target-chip {
    font-size: 11px;
    background: rgba(255, 255, 255, 0.08);
    padding: 3px 8px;
    border-radius: 6px;
    color: #cbd5e1;
}

.level-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px;
}

.play-now-badge {
    background: var(--card-accent, var(--accent));
    color: #fff;
    padding: 5px 14px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
}

/* 结算弹窗 */
.result-box {
    width: 100%;
    max-width: 480px;
    background: rgba(19, 25, 43, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 24px;
    padding: 32px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.7);
}

.result-stars {
    font-size: 44px;
    letter-spacing: 6px;
}

.result-title {
    font-size: 30px;
    font-weight: 900;
}

.result-subtitle {
    font-size: 14px;
    color: var(--text-muted);
}

.stats-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 6px 0;
}

.stat-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
}

.stat-val {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    margin-top: 4px;
}

.btn-group {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
    margin-top: 6px;
}

.btn {
    flex: 1;
    padding: 13px 20px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    color: #fff;
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(139, 92, 246, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.18);
}

@media (max-width: 768px) {
    #hud {
        padding: 10px 12px;
    }
    .hud-left, .size-card {
        min-width: 160px;
    }
    .controls-hint {
        display: none;
    }
    #minimapCanvas {
        width: 100px;
        height: 100px;
    }
}
