/* 声波矿工 — 暗色霓虹主题 */
:root {
    --bg: #0a0e1a;
    --bg2: #050810;
    --cyan: #00d4ff;
    --purple: #b347ff;
    --gold: #ffd700;
    --mint: #7fffd4;
    --text: #e8f4ff;
    --text-dim: #8aa0c0;
    --panel: rgba(12, 18, 34, 0.85);
    --border: rgba(0, 212, 255, 0.25);
    --danger: #ff5577;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#game-canvas {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    right: 290px; /* 右侧任务面板宽度 */
    width: calc(100% - 290px);
    height: 100%;
    display: block;
    touch-action: none;
}

/* HUD 通用条(在任务面板左侧的区域内居中) */
.hud-bar {
    position: fixed;
    left: calc(50% - 145px);
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 18px;
    background: var(--panel);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 0 24px rgba(0, 212, 255, 0.12), inset 0 0 12px rgba(0, 212, 255, 0.05);
    z-index: 10;
}

#hud-top {
    top: 12px;
    max-width: calc(96vw - 290px);
}

#build-bar {
    bottom: 12px;
    max-width: calc(96vw - 290px);
}

/* 顶部统计 */
.stat {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-right: 1px solid rgba(138, 160, 192, 0.2);
}
.stat:last-of-type { border-right: none; }
.stat-icon {
    font-size: 18px;
    text-shadow: 0 0 8px currentColor;
}
.stat-label {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 1px;
}
.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    min-width: 28px;
    text-align: right;
    transition: transform 0.12s ease, color 0.12s ease;
}
.stat-value.bump {
    transform: scale(1.25);
    color: var(--cyan);
}

/* HUD 按钮 */
.hud-btn {
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid var(--border);
    color: var(--cyan);
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 600;
}
.hud-btn:hover { background: rgba(0, 212, 255, 0.2); box-shadow: 0 0 12px rgba(0, 212, 255, 0.4); }
.hud-btn.danger { color: var(--danger); border-color: rgba(255, 85, 119, 0.4); background: rgba(255, 85, 119, 0.08); }
.hud-btn.danger:hover { background: rgba(255, 85, 119, 0.18); box-shadow: 0 0 12px rgba(255, 85, 119, 0.4); }

/* 底部建造按钮 */
.build-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: linear-gradient(180deg, rgba(0, 212, 255, 0.14), rgba(0, 212, 255, 0.04));
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 18px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 110px;
}
.build-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, rgba(0, 212, 255, 0.28), rgba(0, 212, 255, 0.08));
    box-shadow: 0 0 18px rgba(0, 212, 255, 0.45);
    transform: translateY(-2px);
}
.build-btn:active:not(:disabled) { transform: translateY(0); }
.build-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.5);
}
/* 建塔模式激活态 */
.build-btn.active {
    background: linear-gradient(180deg, rgba(255, 215, 0, 0.32), rgba(255, 215, 0, 0.12));
    border-color: var(--gold);
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.55), inset 0 0 12px rgba(255, 215, 0, 0.2);
    animation: build-pulse 1.2s ease-in-out infinite;
}
@keyframes build-pulse {
    0%, 100% { box-shadow: 0 0 14px rgba(255, 215, 0, 0.4), inset 0 0 10px rgba(255, 215, 0, 0.15); }
    50% { box-shadow: 0 0 22px rgba(255, 215, 0, 0.7), inset 0 0 14px rgba(255, 215, 0, 0.25); }
}
.btn-title { font-size: 13px; font-weight: 700; color: var(--cyan); }
.btn-cost { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.btn-cost.afford { color: var(--gold); }

.hint {
    font-size: 12px;
    color: var(--text-dim);
    padding-left: 8px;
    border-left: 1px solid rgba(138, 160, 192, 0.2);
    max-width: 240px;
}

/* 升级面板 */
#upgrade-panel {
    position: fixed;
    z-index: 15;
    background: var(--panel);
    backdrop-filter: blur(12px);
    border: 1px solid var(--cyan);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.4), inset 0 0 12px rgba(0, 212, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 180px;
    transform: translate(-50%, -110%);
    transition: opacity 0.15s ease;
}
#upgrade-panel.hidden { display: none; }
.panel-title {
    font-size: 13px;
    color: var(--cyan);
    font-weight: 700;
    text-align: center;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    letter-spacing: 1px;
}
.panel-levels { font-size: 11px; color: var(--text-dim); font-weight: 400; }
.up-btn {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0 8px;
    background: rgba(0, 212, 255, 0.08);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.12s ease;
    text-align: left;
}
.up-btn:hover:not(:disabled) { background: rgba(0, 212, 255, 0.2); box-shadow: 0 0 10px rgba(0, 212, 255, 0.3); }
.up-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.up-name { font-size: 13px; font-weight: 600; }
.up-val { font-size: 11px; color: var(--mint); text-align: right; }
.up-cost { grid-column: 1 / -1; font-size: 11px; color: var(--gold); border-top: 1px dashed rgba(255, 215, 0, 0.2); padding-top: 4px; margin-top: 2px; }
.up-cost.poor { color: var(--danger); }
.up-close {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.up-close:hover { color: var(--danger); }

/* 浮动提示(toast) */
.toast {
    position: fixed;
    left: 50%;
    bottom: 110px;
    transform: translateX(-50%);
    padding: 10px 18px;
    border-radius: 10px;
    background: rgba(20, 26, 42, 0.92);
    border: 1px solid var(--danger);
    color: var(--danger);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5), 0 0 12px rgba(255, 85, 119, 0.3);
    z-index: 300;
    pointer-events: none;
    animation: toast-in 0.18s ease-out;
}
.toast.info {
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5), 0 0 12px rgba(0, 212, 255, 0.3);
}
.toast.hidden { display: none; }
@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* 升级面板 - 维护费 + 拆除按钮 */
.panel-maint {
    font-size: 11px;
    color: var(--gold);
    text-align: center;
    padding: 2px 0;
    letter-spacing: 0.5px;
}
.up-demolish {
    background: rgba(255, 85, 119, 0.1);
    border: 1px solid rgba(255, 85, 119, 0.4);
    color: var(--danger);
    padding: 7px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.12s ease;
}
.up-demolish:hover:not(:disabled) {
    background: rgba(255, 85, 119, 0.22);
    box-shadow: 0 0 10px rgba(255, 85, 119, 0.4);
}
.up-demolish:disabled { opacity: 0.4; cursor: not-allowed; }

/* 维护费警示色 */
.stat-value.warn { color: var(--danger); }
#stat-maint.warn { color: var(--danger); animation: pulse-warn 0.6s ease-in-out infinite alternate; }
@keyframes pulse-warn { from { opacity: 0.6; } to { opacity: 1; } }

/* 右侧常驻任务面板 */
.quest-sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 290px;
    background: rgba(8, 12, 22, 0.92);
    border-left: 1px solid var(--border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 90;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
}
.quest-sidebar-head {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.game-title.tiny { font-size: 15px; margin: 0 0 8px; letter-spacing: 1px; }
.quest-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: 10px;
    color: var(--text-dim);
}
.quest-summary b { color: var(--mint); font-weight: 600; }
.quests-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    overflow-y: auto;
    flex: 1;
}
.quests-list::-webkit-scrollbar { width: 6px; }
.quests-list::-webkit-scrollbar-thumb { background: rgba(0, 212, 255, 0.2); border-radius: 3px; }
.quest-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 10px;
    align-items: start;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(0, 212, 255, 0.04);
    transition: all 0.15s ease;
}
.quest-item.ready { border-color: var(--mint); background: rgba(127, 255, 212, 0.06); box-shadow: 0 0 12px rgba(127, 255, 212, 0.15); }
.quest-item.done { border-color: rgba(255, 215, 0, 0.4); background: rgba(255, 215, 0, 0.05); opacity: 0.65; }
.quest-item.current { border-color: var(--cyan); box-shadow: 0 0 10px rgba(0, 212, 255, 0.2); }
.quest-num {
    width: 26px; height: 26px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 12px;
    background: rgba(0, 212, 255, 0.15);
    color: var(--cyan);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.quest-item.done .quest-num { background: rgba(255, 215, 0, 0.15); color: var(--gold); border-color: rgba(255, 215, 0, 0.4); }
.quest-item.ready .quest-num { background: rgba(127, 255, 212, 0.15); color: var(--mint); border-color: var(--mint); }
.quest-body { min-width: 0; }
.quest-name { font-size: 13px; font-weight: 700; color: var(--text); }
.quest-goal { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.quest-bar { height: 3px; background: rgba(138, 160, 192, 0.15); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.quest-bar-fill { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--mint)); transition: width 0.3s ease; }
.quest-item.ready .quest-bar-fill { background: linear-gradient(90deg, var(--mint), var(--gold)); }
.quest-reward { font-size: 10px; color: var(--mint); margin-top: 4px; letter-spacing: 0.5px; }
.quest-action {
    background: rgba(0, 212, 255, 0.12);
    border: 1px solid var(--border);
    color: var(--cyan);
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
    width: 100%;
    margin-top: 4px;
    transition: all 0.12s ease;
}
.quest-action:hover:not(:disabled) { background: rgba(0, 212, 255, 0.25); box-shadow: 0 0 10px rgba(0, 212, 255, 0.4); }
.quest-action:disabled { opacity: 0.4; cursor: not-allowed; }
.quest-action.affordable { color: var(--gold); border-color: rgba(255, 215, 0, 0.5); }
.quest-status-tag { font-size: 10px; color: var(--text-dim); font-weight: 600; padding: 4px 8px; white-space: nowrap; text-align: center; display: block; }
.quest-status-tag.done { color: var(--gold); }
.quest-status-tag.ready { color: var(--mint); }

/* 新手引导 */
.tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    transition: box-shadow 0.2s ease;
}
.tutorial-overlay.hidden { display: none; }
.tutorial-box {
    position: fixed;
    z-index: 201;
    width: 300px;
    padding: 16px 18px 14px;
    background: rgba(12, 18, 34, 0.96);
    border: 1px solid var(--cyan);
    border-radius: 12px;
    box-shadow: 0 0 28px rgba(0, 212, 255, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: left 0.25s ease, top 0.25s ease, opacity 0.2s ease;
}
.tutorial-box.hidden { display: none; }
.tutorial-step {
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.tutorial-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--cyan);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}
.tutorial-text {
    font-size: 12px;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 12px;
}
.tutorial-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.tutorial-skip {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.12s ease;
}
.tutorial-skip:hover { color: var(--text); border-color: var(--text-dim); }
.tutorial-next {
    background: linear-gradient(180deg, rgba(0, 212, 255, 0.3), rgba(0, 212, 255, 0.12));
    border: 1px solid var(--cyan);
    color: var(--cyan);
    padding: 6px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    transition: all 0.12s ease;
}
.tutorial-next:hover { box-shadow: 0 0 12px rgba(0, 212, 255, 0.5); }
.tutorial-next.waiting {
    opacity: 0.5;
    pointer-events: none;
}
.tutorial-next.waiting::after {
    content: '…';
    animation: dots 1s steps(4) infinite;
}
@keyframes dots { 0%{content:'·'} 33%{content:'··'} 66%{content:'···'} }

/* 遮罩 */
.overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(10, 14, 26, 0.85), rgba(5, 8, 16, 0.97));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}
.overlay.hidden { display: none; }
.overlay-card {
    text-align: center;
    padding: 40px 50px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(12, 18, 34, 0.6);
    box-shadow: 0 0 60px rgba(0, 212, 255, 0.25);
    max-width: 90vw;
}
.game-title {
    font-size: 46px;
    font-weight: 900;
    letter-spacing: 8px;
    color: var(--cyan);
    text-shadow: 0 0 24px rgba(0, 212, 255, 0.7), 0 0 48px rgba(0, 212, 255, 0.3);
    margin-bottom: 4px;
}
.game-title.small { font-size: 32px; letter-spacing: 6px; }
.game-subtitle {
    font-size: 14px;
    letter-spacing: 10px;
    color: var(--purple);
    text-shadow: 0 0 12px rgba(179, 71, 255, 0.6);
    margin-bottom: 20px;
}
.game-desc { font-size: 14px; color: var(--text-dim); margin-bottom: 24px; }
.keymap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 28px;
}
.keymap b { color: var(--mint); }
.start-btn {
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    border: none;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 4px;
    padding: 14px 44px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 24px rgba(0, 212, 255, 0.5);
}
.start-btn:hover { transform: scale(1.05); box-shadow: 0 0 36px rgba(0, 212, 255, 0.8); }

/* 调试信息 */
#debug-info {
    position: fixed;
    left: 8px;
    bottom: 80px;
    font-size: 11px;
    color: var(--mint);
    font-family: monospace;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 8px;
    border-radius: 4px;
    z-index: 8;
    line-height: 1.5;
    pointer-events: none;
}
#debug-info.hidden { display: none; }

.hidden { display: none !important; }

/* 响应式 */
@media (max-width: 720px) {
    .stat-label { display: none; }
    .stat-icon { font-size: 15px; }
    .stat-value { font-size: 15px; }
    .hud-bar { gap: 8px; padding: 8px 12px; }
    .build-btn { min-width: 90px; padding: 6px 12px; }
    .hint { display: none; }
    .game-title { font-size: 34px; letter-spacing: 5px; }
    .keymap { grid-template-columns: 1fr; }
}
