* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0a1428; color: #fff; font-family: 'Segoe UI', system-ui, sans-serif; user-select: none; }
canvas { position: absolute; inset: 0; display: block; cursor: crosshair; }

#backBtn {
    position: fixed; top: 12px; left: 12px; z-index: 50;
    color: #aaa; text-decoration: none; font-size: 13px; font-weight: 700;
    padding: 6px 12px; border-radius: 6px; background: rgba(0,0,0,0.4);
}
#backBtn:hover { color: #fff; background: rgba(0,0,0,0.6); }

.hidden { display: none !important; }

#hud {
    position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
    background: rgba(15, 25, 45, 0.85); backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.08); border-radius: 10px;
    padding: 10px 14px; display: flex; gap: 18px; align-items: center;
    z-index: 30; font-size: 14px; font-weight: 700;
}
.hud-stat { display: flex; flex-direction: column; align-items: center; min-width: 50px; }
.hud-stat .lbl { font-size: 9px; opacity: 0.55; letter-spacing: 1.5px; font-weight: 600; }
.hud-stat span:last-child { font-size: 18px; }
#hud button {
    background: #2a8844; border: none; color: #fff;
    padding: 8px 14px; border-radius: 6px; cursor: pointer;
    font-weight: 700; font-size: 13px; letter-spacing: 0.5px;
}
#hud button:hover { background: #34a554; }
#hud button:disabled { background: #444; cursor: not-allowed; opacity: 0.6; }
#speedBtn { background: #4466aa !important; }
#speedBtn:hover { background: #5577cc !important; }
#startWaveBtn.skip { background: #cc7733 !important; }
#startWaveBtn.skip:hover { background: #dd8844 !important; }
#nextWaveBox { min-width: 70px; }
#nextWaveEl { color: #ffcc44; font-size: 14px !important; letter-spacing: 0.5px; }

#abilityBar {
    position: fixed; left: 12px; bottom: 12px;
    background: rgba(15, 25, 45, 0.85); backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.08); border-radius: 10px;
    padding: 8px; display: flex; gap: 8px; z-index: 30;
}
.ability-btn {
    background: rgba(60, 40, 30, 0.7); border: 1px solid rgba(255,170,80,0.4);
    color: #ffcc88; padding: 8px 14px; border-radius: 6px; cursor: pointer;
    font-weight: 700; font-size: 11px; letter-spacing: 1px;
    display: flex; flex-direction: column; align-items: center; min-width: 70px;
    position: relative; overflow: hidden;
}
.ability-btn:hover:not(:disabled) { background: rgba(80, 55, 40, 0.85); border-color: rgba(255,200,100,0.7); }
.ability-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.ability-btn .ab-name { font-size: 13px; color: #ffcc44; }
.ability-btn .ab-cost { font-size: 10px; opacity: 0.7; margin-top: 2px; }
.ability-btn .ab-cd {
    position: absolute; left: 0; right: 0; bottom: 0;
    height: 3px; background: #ffcc44; transform-origin: left; transform: scaleX(0);
    transition: transform 0.1s linear;
}
#nukeBtn { border-color: rgba(255,80,80,0.4); }
#nukeBtn .ab-name { color: #ff6666; }
#freezeBtn { border-color: rgba(120,200,255,0.4); }
#freezeBtn .ab-name { color: #88ccff; }

#towerPanel {
    position: fixed; right: 12px; top: 50%; transform: translateY(-50%);
    background: rgba(15, 25, 45, 0.9); backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.08); border-radius: 10px;
    padding: 10px; display: flex; flex-direction: column; gap: 8px; z-index: 30;
    min-width: 140px;
}
.panel-title { font-size: 11px; opacity: 0.5; letter-spacing: 2px; text-align: center; margin-bottom: 4px; }
.tower-btn {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px; padding: 8px 10px; color: #fff; cursor: pointer;
    text-align: left; transition: all .15s;
}
.tower-btn:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.25); }
.tower-btn.active { background: rgba(80,160,255,0.25); border-color: #5599ff; }
.tower-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tw-name { font-weight: 800; font-size: 14px; }
.tw-cost { font-size: 12px; color: #ffcc44; font-weight: 700; }
.tw-desc { font-size: 10px; opacity: 0.6; margin-top: 2px; }

#upgradePanel {
    position: fixed; left: 12px; top: 50%; transform: translateY(-50%);
    background: rgba(15, 25, 45, 0.9); backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.08); border-radius: 10px;
    padding: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 30;
    min-width: 170px;
}
#upgradeName { font-size: 16px; font-weight: 800; text-align: center; }
#upgradeStats { font-size: 11px; opacity: 0.7; text-align: center; margin-bottom: 4px; line-height: 1.5; }
#upgradePanel button {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px; padding: 7px; color: #fff; cursor: pointer;
    font-weight: 700; font-size: 12px; transition: all .15s;
}
#upgradePanel button:hover:not(:disabled) { background: rgba(255,255,255,0.15); }
#upgradePanel button:disabled { opacity: 0.4; cursor: not-allowed; }
#sellBtn { background: rgba(255,80,80,0.15) !important; border-color: rgba(255,80,80,0.3) !important; margin-top: 4px; }
#sellBtn:hover { background: rgba(255,80,80,0.3) !important; }
.ghost { background: transparent !important; opacity: 0.6; font-size: 11px !important; padding: 4px !important; }

/* Overlay screens */
#overlay, #gameOverOverlay {
    position: fixed; inset: 0; z-index: 100;
    background: linear-gradient(180deg, rgba(10,20,40,0.96), rgba(10,20,40,0.99));
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 20px;
}
#overlay.visible, #gameOverOverlay.visible { display: flex; }
#overlay.hidden, #gameOverOverlay.hidden { display: none; }

#overlay h1, #gameOverOverlay h1 {
    font-size: 88px; font-weight: 900; letter-spacing: 4px;
    background: linear-gradient(135deg, #ff66bb, #ffcc44, #44ddff);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    margin-bottom: 8px;
}
#gameOverOverlay h1 { font-size: 64px; }
.tagline { font-size: 18px; opacity: 0.85; margin-bottom: 6px; }
.controls { font-size: 13px; opacity: 0.55; margin-bottom: 28px; }

#menuButtons button, #gameOverOverlay button {
    background: linear-gradient(135deg, #ff66bb, #ff4488);
    border: none; color: #fff; padding: 14px 36px; font-size: 18px;
    font-weight: 800; letter-spacing: 2px; border-radius: 10px;
    cursor: pointer; transition: transform .15s, box-shadow .15s;
    box-shadow: 0 6px 20px rgba(255,80,160,0.35); margin: 6px;
}
#menuButtons button:hover, #gameOverOverlay button:not(.ghost):hover {
    transform: translateY(-2px); box-shadow: 0 10px 28px rgba(255,80,160,0.5);
}
#gameOverOverlay button.ghost { background: transparent !important; box-shadow: none; font-size: 13px; padding: 6px 16px; opacity: 0.6; }
#gameOverOverlay button.ghost:hover { opacity: 1; }

#hsBox {
    margin-top: 32px; padding: 16px 28px;
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
}
.hs-label { font-size: 10px; letter-spacing: 2px; opacity: 0.5; }
#hsValue { font-size: 36px; font-weight: 900; color: #ffcc44; }
#bestRound { font-size: 22px; font-weight: 800; color: #44ddff; }

#goRound { font-size: 22px; margin-top: 8px; }
#goScore { font-size: 18px; opacity: 0.85; margin-top: 4px; }
#goNew { color: #ffcc44; font-weight: 800; margin-top: 8px; min-height: 22px; }
