/* ==========================================================================
   Cannon Clash (巨炮大决战) - Real-Time Simultaneous Tactical Arcade Theme
   ========================================================================== */

:root {
    --bg-page: #0a0e17;
    --bg-surface: #111726;
    --bg-card: rgba(18, 25, 41, 0.88);
    --border-color: rgba(0, 229, 255, 0.25);
    --border-glow: rgba(0, 229, 255, 0.5);

    --p1-color: #00e5ff;
    --p1-glow: rgba(0, 229, 255, 0.45);
    --p2-color: #ff1744;
    --p2-glow: rgba(255, 23, 68, 0.45);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --btn-fire: #ff3d00;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-page);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-primary);
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #141c2e 0%, #080c14 100%);
    overflow: hidden;
}

canvas#gameCanvas {
    display: block;
    max-width: 100vw;
    max-height: 100vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.85);
    background-color: #050811;
}

/* ================= Real-time HUD Layer ================= */
#hudContainer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 14px;
    z-index: 10;
}

#hudContainer.hidden {
    display: none !important;
}

/* Top Status Bar */
.hud-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    pointer-events: auto;
}

.player-status-card {
    background: rgba(14, 20, 34, 0.88);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 6px 14px;
    min-width: 165px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.player-status-card.p1 {
    border-left: 4px solid var(--p1-color);
}

.player-status-card.p2 {
    border-right: 4px solid var(--p2-color);
    text-align: right;
}

.player-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 4px;
}

.player-status-card.p2 .player-badge {
    justify-content: flex-end;
}

.hp-bar-bg {
    width: 100%;
    height: 11px;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.hp-bar-fill {
    height: 100%;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.player-status-card.p1 .hp-bar-fill {
    background: linear-gradient(90deg, #0091ea, #00e5ff);
}

.player-status-card.p2 .hp-bar-fill {
    background: linear-gradient(90deg, #ff5252, #ff1744);
}

.bar-sub-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.reload-track {
    flex: 1;
    height: 5px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.reload-fill {
    height: 100%;
    background: #00e676;
    width: 100%;
    transition: width 0.1s linear, background 0.2s ease;
}

.hp-num {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-secondary);
}

.shield-val {
    color: #00e5ff;
    font-weight: 800;
}

/* Center Environmental HUD */
.center-hud-cluster {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.match-banner {
    background: rgba(14, 20, 34, 0.92);
    border: 2px solid var(--p1-color);
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 800;
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.35);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
    letter-spacing: 0.5px;
}

.env-indicators {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(14, 20, 34, 0.8);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 3px 12px;
}

.wind-meter {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
}

.wind-arrow {
    font-size: 16px;
    display: inline-block;
    transition: transform 0.3s ease;
}

.wind-gauge-bar {
    width: 60px;
    height: 6px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 3px;
    overflow: hidden;
}

.wind-bar-fill {
    height: 100%;
    background: #00e5ff;
    width: 0%;
    transition: width 0.3s ease;
}

.top-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: rgba(14, 20, 34, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: var(--border-glow);
}

/* ================= Bottom Tactical Dual Pods ================= */
.hud-bottom-dual-zone {
    pointer-events: auto;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
}

.player-pod {
    flex: 1;
    background: rgba(14, 20, 34, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
    max-width: 560px;
}

.player-pod.p1 {
    border-left: 3px solid var(--p1-color);
}

.player-pod.p2 {
    border-right: 3px solid var(--p2-color);
}

.player-pod.hidden {
    display: none !important;
}

.pod-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pod-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.player-pod.p1 .pod-title { color: var(--p1-color); }
.player-pod.p2 .pod-title { color: var(--p2-color); }

.fuel-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 700;
}

.fuel-track {
    width: 50px;
    height: 5px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    overflow: hidden;
}

.fuel-fill {
    height: 100%;
    background: #00e676;
    width: 100%;
    transition: width 0.1s ease;
}

/* Weapon Selection Chips */
.weapon-chips-scroll {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding: 3px 0;
    scrollbar-width: none;
}

.weapon-chips-scroll::-webkit-scrollbar {
    display: none;
}

.weapon-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 3px 7px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.weapon-chip:hover {
    background: rgba(255, 255, 255, 0.12);
}

.weapon-chip.active {
    background: rgba(0, 229, 255, 0.25);
    border-color: #00e5ff;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}

.player-pod.p2 .weapon-chip.active {
    background: rgba(255, 23, 68, 0.25);
    border-color: #ff1744;
    box-shadow: 0 0 10px rgba(255, 23, 68, 0.4);
}

.weapon-chip.empty {
    opacity: 0.35;
    cursor: not-allowed;
}

.w-ammo {
    color: #ffc107;
    font-weight: 800;
}

/* Control Inputs: Drive Buttons, Sliders, Fire */
.pod-control-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}

.move-btns-pair {
    display: flex;
    gap: 4px;
}

.move-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    padding: 6px 9px;
    border-radius: 7px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.move-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sliders-pair {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 100px;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.slider-row .lbl {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 58px;
}

.slider-row .lbl b {
    color: #fff;
}

.slider-row input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 5px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #00e5ff;
    cursor: pointer;
    box-shadow: 0 0 6px #00e5ff;
}

.player-pod.p2 .slider-row input[type="range"]::-webkit-slider-thumb {
    background: #ff1744;
    box-shadow: 0 0 6px #ff1744;
}

/* Fire Button */
.fire-btn {
    border: none;
    color: #fff;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0.5px;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 80px;
    justify-content: center;
}

.fire-btn.p1 {
    background: linear-gradient(135deg, #00b0ff, #0091ea);
    box-shadow: 0 3px 14px rgba(0, 176, 255, 0.4);
}

.fire-btn.p2 {
    background: linear-gradient(135deg, #ff3d00, #d50000);
    box-shadow: 0 3px 14px rgba(255, 61, 0, 0.45);
}

.fire-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.fire-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.5);
    box-shadow: none;
}

/* ================= Modals ================= */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 8, 17, 0.88);
    backdrop-filter: blur(14px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.3s ease;
}

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

.menu-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: 20px;
    padding: 34px 38px;
    max-width: 520px;
    width: 90%;
    text-align: center;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 229, 255, 0.15);
}

.game-title {
    font-size: 38px;
    font-weight: 900;
    background: linear-gradient(135deg, #ffffff 20%, #00e5ff 60%, #ff1744 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.game-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 26px;
    line-height: 1.5;
}

.menu-actions-stack {
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.menu-primary-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 229, 255, 0.35);
    color: #fff;
    padding: 13px 18px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.menu-primary-btn:hover {
    background: rgba(0, 229, 255, 0.2);
    border-color: #00e5ff;
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.35);
    transform: translateY(-2px);
}

.menu-primary-btn.pvp:hover {
    border-color: #ff1744;
    box-shadow: 0 0 20px rgba(255, 23, 68, 0.35);
    background: rgba(255, 23, 68, 0.18);
}

/* Campaign Modal */
.campaign-modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: 20px;
    padding: 24px 30px;
    max-width: 860px;
    width: 94%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.campaign-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.stages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    overflow-y: auto;
    padding: 6px 4px;
    flex: 1;
}

.stage-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stage-card.unlocked:hover {
    background: rgba(0, 229, 255, 0.12);
    border-color: #00e5ff;
    transform: translateY(-3px);
}

.stage-card.locked {
    opacity: 0.45;
    cursor: not-allowed;
}

.stage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stage-id {
    font-size: 11px;
    font-weight: 800;
    color: #00e5ff;
    letter-spacing: 1px;
}

.star-icon {
    font-size: 14px;
    color: #455a64;
}

.star-icon.active {
    color: #ffc107;
}

.stage-title {
    font-size: 15px;
    font-weight: 700;
}

.stage-desc {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.stage-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

.stage-enemy {
    font-size: 11px;
    color: #ff8a80;
    font-weight: 600;
}

.stage-play-btn {
    background: #00e5ff;
    border: none;
    color: #000;
    font-size: 11px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.stage-card.locked .stage-play-btn {
    background: #37474f;
    color: #90a4ae;
}

/* Guide Modal */
.guide-content {
    max-height: 60vh;
    overflow-y: auto;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 13px;
    padding: 10px 4px;
}

.guide-item {
    background: rgba(255, 255, 255, 0.04);
    padding: 10px 14px;
    border-radius: 10px;
    border-left: 3px solid #00e5ff;
}

.guide-item-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #00e5ff;
}

.guide-item-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

@media (max-width: 820px) {
    .hud-bottom-dual-zone {
        flex-direction: column;
        gap: 8px;
    }
    .player-pod {
        max-width: 100%;
        padding: 6px 10px;
    }
    .player-status-card {
        min-width: 120px;
        padding: 5px 8px;
    }
}
