/* ════════════════════════════════════════
   TANK BATTLE 3D - Styles
   ════════════════════════════════════════ */

:root {
    --red-team:    #e03030;
    --blue-team:   #2060e0;
    --green-team:  #30a030;
    --yellow-team: #e0b020;
    --bg-dark:     #0d1117;
    --bg-card:     #1a2332;
    --bg-card2:    #1e2d44;
    --accent:      #f5c542;
    --text-light:  #eef3ff;
    --text-muted:  #88a0bb;
    --success:     #2ecc71;
    --danger:      #e74c3c;
    --radius:      16px;
    --shadow:      0 8px 32px rgba(0,0,0,0.45);
}

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

body {
    font-family: 'Outfit', 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text-light);
    overflow: hidden;
    user-select: none;
}

/* ── Screens ── */
.screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.screen.hidden { display: none !important; }

/* ── Overlay (pause/gameover) ── */
.overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(10, 14, 22, 0.88);
    display: flex; align-items: center; justify-content: center;
}

/* ════════════════════════════════════════
   START SCREEN
   ════════════════════════════════════════ */
#startScreen {
    background: radial-gradient(ellipse at 50% 0%, #1a3058 0%, #0d1117 70%);
    overflow-y: auto;
    padding: 20px;
}

.start-panel {
    width: 100%;
    max-width: 680px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 10px 0;
}

.game-logo {
    text-align: center;
    padding: 10px 0 0;
}

.game-logo h1 {
    font-size: clamp(2rem, 6vw, 3.2rem);
    font-weight: 900;
    letter-spacing: -1px;
    line-height: 1.1;
    background: linear-gradient(135deg, #f5c542 0%, #ff6b35 50%, #e03030 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 2px 8px rgba(240,100,30,0.4));
}

.game-logo p { color: var(--text-muted); font-size: 1rem; margin-top: 6px; }

/* ── Section cards ── */
.section-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px 22px;
    border: 1px solid rgba(255,255,255,0.07);
    box-shadow: var(--shadow);
}

.section-card h3 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent);
    margin-bottom: 14px;
}

/* ── Mode cards ── */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.mode-card {
    background: var(--bg-card2);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.mode-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.mode-card.selected { border-color: var(--accent); background: rgba(245, 197, 66, 0.1); }

.mode-card .mode-emoji { font-size: 1.8rem; display: block; margin-bottom: 4px; }
.mode-card .mode-name { font-size: 0.95rem; font-weight: 700; color: var(--text-light); }
.mode-card .mode-desc { font-size: 0.78rem; color: var(--text-muted); margin-top: 3px; }

/* ── Map selector ── */
.map-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.map-card {
    background: var(--bg-card2);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 12px 10px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}
.map-card:hover { border-color: #88b4dd; transform: translateY(-2px); }
.map-card.selected { border-color: var(--accent); background: rgba(245,197,66,0.08); }
.map-card .map-thumb {
    width: 100%; height: 60px; border-radius: 8px;
    margin-bottom: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
}
.map-card .map-name { font-size: 0.85rem; font-weight: 600; }

/* ── Color selector ── */
.color-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 44px; height: 44px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.15s ease;
    position: relative;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: #fff; transform: scale(1.15); }
.color-swatch.selected::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

/* ── Difficulty buttons ── */
.diff-row {
    display: flex;
    gap: 10px;
}

.diff-btn {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: 2px solid transparent;
    background: var(--bg-card2);
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.diff-btn:hover { border-color: var(--text-muted); }
.diff-btn.selected.easy   { border-color: #2ecc71; background: rgba(46,204,113,0.12); color: #2ecc71; }
.diff-btn.selected.medium { border-color: #f39c12; background: rgba(243,156,18,0.12); color: #f39c12; }
.diff-btn.selected.hard   { border-color: #e74c3c; background: rgba(231,76,60,0.12);  color: #e74c3c; }

/* ── Player name & start ── */
.name-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.name-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-card2);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    color: var(--text-light);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}
.name-input:focus { outline: none; border-color: var(--accent); }
.name-input::placeholder { color: var(--text-muted); }

.btn-start {
    background: linear-gradient(135deg, #f5c542, #ff6b35);
    color: #0d1117;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 900;
    padding: 13px 32px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.5px;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(245,197,66,0.35);
}
.btn-start:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(245,197,66,0.5); }
.btn-start:active { transform: translateY(0); }

/* ════════════════════════════════════════
   GAME SCREEN
   ════════════════════════════════════════ */
#gameScreen {
    position: fixed; inset: 0;
    background: #000;
    display: flex;
    padding: 0;
}

#canvasContainer {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
}

#canvasContainer canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ── HUD ── */
#hud {
    position: absolute; inset: 0;
    pointer-events: none;
    z-index: 10;
}

/* Player health */
#playerHud {
    position: absolute;
    top: 72px; left: 16px;
    background: rgba(10,14,22,0.75);
    border-radius: 14px;
    padding: 10px 14px;
    min-width: 180px;
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(8px);
}

.hud-name {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 6px;
}

.health-bar-wrap {
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 5px;
}

.health-bar-fill {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, #2ecc71, #27ae60);
    transition: width 0.2s ease, background 0.3s;
}

.health-bar-fill.medium { background: linear-gradient(90deg, #f1c40f, #e67e22); }
.health-bar-fill.low    { background: linear-gradient(90deg, #e74c3c, #c0392b); }

.hud-hp-text { font-size: 0.75rem; color: var(--text-muted); }

#armorBar { margin-top: 4px; }

/* Power-up active */
#powerupHud {
    position: absolute;
    top: 72px; left: 210px;
    background: rgba(10,14,22,0.75);
    border-radius: 14px;
    padding: 10px 14px;
    min-width: 130px;
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(8px);
    display: none;
}

#powerupHud.visible { display: block; }
#powerupIcon { font-size: 1.6rem; }
#powerupName { font-size: 0.8rem; font-weight: 700; color: var(--accent); }
#powerupTimer { font-size: 0.75rem; color: var(--text-muted); }

/* Timer */
#timerHud {
    position: absolute;
    top: 72px; left: 50%; transform: translateX(-50%);
    background: rgba(10,14,22,0.75);
    border-radius: 14px;
    padding: 10px 20px;
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(8px);
    text-align: center;
}

#timerHud .timer-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }
#timerText { font-size: 1.6rem; font-weight: 900; color: var(--text-light); }
#timerText.urgent { color: #e74c3c; animation: pulse-urgent 0.5s ease infinite; }

@keyframes pulse-urgent {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* Kills & score */
#scoreHud {
    position: absolute;
    top: 72px; right: 16px;
    background: rgba(10,14,22,0.75);
    border-radius: 14px;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(8px);
    text-align: right;
    min-width: 120px;
}

.score-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.score-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.score-val { font-size: 1.1rem; font-weight: 900; color: var(--accent); }

/* Kill feed */
#killFeed {
    position: absolute;
    top: 168px; right: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 260px;
}

.kill-entry {
    background: rgba(10,14,22,0.82);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.8rem;
    border-left: 3px solid var(--accent);
    animation: slide-in-right 0.3s ease, fade-out 0.5s ease 3.5s forwards;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kill-entry .killer { color: #fff; font-weight: 700; }
.kill-entry .killed { color: var(--danger); font-weight: 700; }

@keyframes slide-in-right {
    from { transform: translateX(60px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}
@keyframes fade-out {
    to { opacity: 0; }
}

/* Mode info banner */
#modeHud {
    position: absolute;
    bottom: 90px; left: 50%; transform: translateX(-50%);
    background: rgba(10,14,22,0.75);
    border-radius: 10px;
    padding: 6px 16px;
    font-size: 0.85rem;
    border: 1px solid rgba(255,255,255,0.08);
    text-align: center;
    pointer-events: none;
    display: none;
}

/* Team scoreboard */
#teamHud {
    position: absolute;
    top: 50%; right: 16px;
    transform: translateY(-50%);
    background: rgba(10,14,22,0.8);
    border-radius: 14px;
    padding: 12px 16px;
    border: 1px solid rgba(255,255,255,0.08);
    min-width: 160px;
    display: none;
}

#teamHud.visible { display: block; }
.team-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.team-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.team-name { font-size: 0.82rem; font-weight: 700; flex: 1; }
.team-alive { font-size: 0.82rem; color: var(--text-muted); }

/* Pause btn */
#pauseBtn {
    position: absolute;
    top: 16px; right: 16px; /* fallback, will be offset when scoreHud is visible */
    width: 38px; height: 38px;
    background: rgba(10,14,22,0.75);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    cursor: pointer;
    pointer-events: all;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    z-index: 20;
    color: var(--text-light);
    transition: background 0.15s;
    /* position it below scoreHud */
    top: auto; bottom: 80px; right: 16px;
}

#pauseBtn:hover { background: rgba(255,255,255,0.1); }

/* Push start screen content below fixed header */
#startScreen { padding-top: 72px; }

/* Announcement banner */
#announcement {
    position: absolute;
    top: 40%; left: 50%; transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 30;
}

.announce-text {
    font-size: clamp(1.8rem, 5vw, 3.5rem);
    font-weight: 900;
    text-shadow: 0 0 30px rgba(245,197,66,0.7), 0 3px 10px rgba(0,0,0,0.6);
    animation: announce-pop 0.4s cubic-bezier(0.34,1.56,0.64,1) forwards, announce-fade 0.4s ease 1.8s forwards;
}

@keyframes announce-pop {
    from { transform: scale(0.4); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}
@keyframes announce-fade {
    to { opacity: 0; transform: scale(1.1); }
}

/* ════════════════════════════════════════
   FLOATING HEALTH BARS (above tanks)
   ════════════════════════════════════════ */
.tank-hpbar {
    position: absolute;
    pointer-events: none;
    z-index: 15;
    transform: translate(-50%, -50%);
    white-space: nowrap;
}

.tank-hpbar-track {
    width: 52px; height: 7px;
    background: rgba(0,0,0,0.5);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.15);
}

.tank-hpbar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.15s;
}

.tank-hpbar-name {
    font-size: 0.62rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

/* ════════════════════════════════════════
   MOBILE CONTROLS
   ════════════════════════════════════════ */
#mobileControls {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: none;
    z-index: 15;
}

@media (pointer: coarse) {
    #mobileControls { display: block; }
    #pauseBtn { pointer-events: all; }
}

#joystickLeft {
    position: absolute;
    bottom: 40px; left: 40px;
    width: 110px; height: 110px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.15);
    pointer-events: all;
    touch-action: none;
}

#joystickKnobLeft {
    position: absolute;
    width: 46px; height: 46px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255,255,255,0.4);
    pointer-events: none;
}

#fireBtn {
    position: absolute;
    bottom: 60px; right: 50px;
    width: 80px; height: 80px;
    background: radial-gradient(circle, #e03030, #9a0f0f);
    border-radius: 50%;
    pointer-events: all;
    touch-action: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    border: 3px solid rgba(255,100,100,0.4);
    box-shadow: 0 4px 20px rgba(224,48,48,0.4);
    transition: transform 0.1s;
}
#fireBtn:active { transform: scale(0.9); }

#aimJoystick {
    position: absolute;
    bottom: 40px; right: 160px;
    width: 90px; height: 90px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.1);
    pointer-events: all;
    touch-action: none;
}

#aimKnob {
    position: absolute;
    width: 36px; height: 36px;
    background: rgba(100,180,255,0.3);
    border-radius: 50%;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(100,180,255,0.5);
    pointer-events: none;
}

/* ════════════════════════════════════════
   PAUSE SCREEN
   ════════════════════════════════════════ */
#pauseScreen {
    pointer-events: all;
}

.pause-panel {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px 48px;
    text-align: center;
    width: 320px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255,255,255,0.08);
}

.pause-panel h2 {
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 28px;
    color: var(--accent);
}

.pause-panel .btn-menu {
    display: block;
    width: 100%;
    padding: 13px;
    margin-bottom: 12px;
    border-radius: 12px;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-resume {
    background: linear-gradient(135deg, #f5c542, #ff6b35);
    color: #0d1117;
}
.btn-resume:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(245,197,66,0.3); }

.btn-restart {
    background: var(--bg-card2);
    color: var(--text-light);
    border: 1px solid rgba(255,255,255,0.08) !important;
}
.btn-restart:hover { background: rgba(255,255,255,0.07); }

.btn-quit {
    background: rgba(231,76,60,0.12);
    color: var(--danger);
    border: 1px solid rgba(231,76,60,0.2) !important;
}
.btn-quit:hover { background: rgba(231,76,60,0.2); }

/* ════════════════════════════════════════
   GAME OVER SCREEN
   ════════════════════════════════════════ */
#gameOverScreen {
    background: radial-gradient(ellipse at 50% 0%, #1a1030 0%, #0d1117 80%);
    overflow-y: auto;
    padding: 20px;
}

.gameover-panel {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 36px 40px;
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(255,255,255,0.07);
    text-align: center;
}

.result-banner {
    font-size: clamp(1.6rem, 5vw, 2.8rem);
    font-weight: 900;
    margin-bottom: 6px;
}
.result-banner.win  { color: var(--accent); }
.result-banner.lose { color: var(--danger); }
.result-banner.draw { color: #88b4dd; }

.result-subtitle { font-size: 1rem; color: var(--text-muted); margin-bottom: 24px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-box {
    background: var(--bg-card2);
    border-radius: 12px;
    padding: 14px 10px;
}

.stat-box .stat-val { font-size: 1.8rem; font-weight: 900; color: var(--accent); }
.stat-box .stat-lbl { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

/* Scoreboard */
.scoreboard {
    background: var(--bg-card2);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 24px;
}

.sb-header {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr 1fr;
    padding: 8px 14px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sb-row {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr 1fr;
    padding: 10px 14px;
    font-size: 0.88rem;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.sb-row:last-child { border-bottom: none; }
.sb-row.player-row { background: rgba(245,197,66,0.07); }
.sb-row.winner-row { background: rgba(46,204,113,0.07); }

.sb-rank { font-weight: 900; color: var(--text-muted); }
.sb-name { font-weight: 700; }
.sb-kills { color: var(--success); font-weight: 700; }
.sb-deaths { color: var(--danger); }
.sb-score { color: var(--accent); font-weight: 700; }

.team-badge {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
}

.btn-row { display: flex; gap: 12px; }

.btn-play-again {
    flex: 1;
    padding: 13px;
    background: linear-gradient(135deg, #f5c542, #ff6b35);
    color: #0d1117;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 900;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-play-again:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(245,197,66,0.35); }

.btn-menu-back {
    padding: 13px 20px;
    background: var(--bg-card2);
    color: var(--text-light);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-menu-back:hover { background: rgba(255,255,255,0.07); }

/* ════════════════════════════════════════
   WAVE NOTIFICATION (survival)
   ════════════════════════════════════════ */
#waveNotice {
    position: absolute;
    top: 30%; left: 50%; transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    z-index: 25;
    display: none;
}

#waveNotice.show { display: block; }
.wave-text { font-size: clamp(2rem,6vw,4rem); font-weight: 900; color: var(--danger); text-shadow: 0 0 40px rgba(231,76,60,0.6); }
.wave-sub { font-size: 1rem; color: var(--text-muted); margin-top: 4px; }

/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */
@media (max-width: 520px) {
    .mode-grid { grid-template-columns: 1fr; }
    .map-grid { grid-template-columns: repeat(3,1fr); }
    .stat-grid { grid-template-columns: repeat(3,1fr); }
    .btn-row { flex-direction: column; }
    .start-panel { gap: 16px; }
}

@media (max-width: 380px) {
    .section-card { padding: 14px 16px; }
    .gameover-panel { padding: 24px 20px; }
}
