/* ===== RESET & BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    background: #000;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}
canvas { display: block; }

/* ===== HUD ===== */
#hud {
    position: fixed; top: 0; left: 0; right: 0;
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 20px;
    z-index: 100;
    pointer-events: none;
}
.score-panel {
    display: flex; flex-direction: column; align-items: center;
    background: rgba(0,0,0,0.55);
    border-radius: 14px;
    padding: 8px 22px;
    min-width: 80px;
    backdrop-filter: blur(6px);
}
.score-panel .label {
    font-size: 11px; font-weight: 700; letter-spacing: 2px;
    text-transform: uppercase;
}
.score-panel.enemy .label { color: #ff6b6b; }
.score-panel.player .label { color: #74b9ff; }
.score-panel .ball-count {
    font-size: 36px; font-weight: 900; color: #fff;
    line-height: 1.1;
}
#timer-display {
    font-size: 42px; font-weight: 900; color: #fff;
    text-shadow: 0 2px 12px rgba(0,0,0,0.7);
    letter-spacing: 2px;
}
#timer-display.warning { color: #fdcb6e; animation: pulse 0.5s infinite alternate; }
#timer-display.danger  { color: #ff6b6b; animation: pulse 0.3s infinite alternate; }

@keyframes pulse { to { transform: scale(1.12); } }

/* ===== NPC STATS PANELS ===== */
.stats-panel {
    position: fixed; top: 80px;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    border-radius: 12px;
    padding: 10px 14px;
    z-index: 100;
    pointer-events: none;
    min-width: 130px;
}
.player-side { left: 16px; }
.cpu-side { right: 16px; }
.stat-title {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.5px;
    margin-bottom: 6px;
}
.cat-title { color: #74b9ff; }
.bear-title { color: #ff6b6b; }
.stat-row {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 4px;
}
.stat-row span {
    font-size: 10px; color: #dfe6e9; min-width: 38px;
}
.stat-bar {
    flex: 1; height: 6px; background: rgba(255,255,255,0.15);
    border-radius: 3px; overflow: hidden;
}
.stat-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.15s ease;
}
.blue-fill { background: linear-gradient(90deg, #74b9ff, #0984e3); }
.red-fill { background: linear-gradient(90deg, #fd79a8, #e17055); }
.stamina-fill { background: linear-gradient(90deg, #00b894, #55efc4); }
.stamina-bar { background: rgba(255,255,255,0.1); }

/* ===== SKILL BUTTONS ===== */
.skill-player-side {
    position: fixed; bottom: 24px; right: 24px;
    z-index: 100;
}
.skill-cpu-side {
    position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
    z-index: 100;
    pointer-events: none;
}
.cpu-skill-badge {
    position: relative;
    width: 50px; height: 50px;
    border-radius: 50%;
    border: 2px solid #ff6b6b;
    background: linear-gradient(135deg, #e17055, #d63031);
    color: #fff;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(214,48,49,0.4);
}
.cpu-skill-badge .skill-icon { font-size: 18px; line-height: 1; }
.cpu-skill-badge .skill-label { font-size: 7px; font-weight: 700; letter-spacing: 0.5px; }
.cpu-skill-badge .cooldown-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.6);
    height: 0%; transition: height 0.1s linear;
}
.cpu-skill-badge .cooldown-text {
    position: absolute; font-size: 16px; font-weight: 900; color: #fdcb6e;
}
#skill-btn {
    position: relative;
    width: 80px; height: 80px;
    border-radius: 50%;
    border: 3px solid #fdcb6e;
    background: linear-gradient(135deg, #e17055, #d63031);
    color: #fff;
    cursor: pointer;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 20px rgba(214,48,49,0.5);
}
#skill-btn:not(:disabled):hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(214,48,49,0.7);
}
#skill-btn:disabled {
    opacity: 0.6; cursor: default;
    border-color: #636e72;
}
.skill-icon { font-size: 26px; line-height: 1; }
.skill-label { font-size: 8px; font-weight: 700; letter-spacing: 1px; margin-top: 2px; }
.cooldown-overlay {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.6);
    height: 0%; transition: height 0.1s linear;
    pointer-events: none;
}
.cooldown-text {
    position: absolute; font-size: 22px; font-weight: 900; color: #fdcb6e;
    pointer-events: none;
}

/* ===== COUNTDOWN ===== */
#countdown-overlay {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    z-index: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
#countdown-overlay.active { opacity: 1; }
#countdown-text {
    font-size: 140px; font-weight: 900; color: #fff;
    text-shadow: 0 0 60px rgba(255,255,255,0.6), 0 0 120px rgba(116,185,255,0.4);
    animation: countPop 0.6s ease-out;
}
@keyframes countPop {
    0%   { transform: scale(2.5); opacity: 0; }
    50%  { transform: scale(0.9); opacity: 1; }
    100% { transform: scale(1);   opacity: 1; }
}

/* ===== RESULT SCREEN ===== */
#result-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex; align-items: center; justify-content: center;
    z-index: 600;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.4s;
}
#result-overlay.hidden { display: none; }
#result-box {
    text-align: center;
    padding: 40px 50px;
    border-radius: 24px;
    background: rgba(30,30,40,0.9);
    border: 2px solid rgba(255,255,255,0.1);
}
#result-title {
    font-size: 64px; font-weight: 900; margin-bottom: 10px;
}
#result-title.win  { color: #00cec9; text-shadow: 0 0 40px rgba(0,206,201,0.5); }
#result-title.lose { color: #ff6b6b; text-shadow: 0 0 40px rgba(255,107,107,0.5); }
#result-title.draw { color: #fdcb6e; text-shadow: 0 0 40px rgba(253,203,110,0.5); }
#result-detail {
    font-size: 18px; color: #dfe6e9; margin-bottom: 30px;
}
#replay-btn {
    padding: 14px 44px;
    font-size: 18px; font-weight: 700;
    border: none; border-radius: 40px;
    background: linear-gradient(135deg, #00cec9, #0984e3);
    color: #fff;
    cursor: pointer;
    letter-spacing: 2px;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 20px rgba(9,132,227,0.4);
}
#replay-btn:hover {
    transform: scale(1.07);
    box-shadow: 0 6px 30px rgba(9,132,227,0.6);
}

/* ===== START SCREEN ===== */
#start-overlay {
    position: fixed; inset: 0;
    background: linear-gradient(135deg, #0c0c1e 0%, #1a1a3e 100%);
    display: flex; align-items: center; justify-content: center;
    z-index: 700;
}
#start-overlay.hidden { display: none; }
#start-box {
    text-align: center;
    padding: 40px 50px;
}
#start-box h1 {
    font-size: 52px; color: #fff; margin-bottom: 16px;
    text-shadow: 0 0 40px rgba(116,185,255,0.5);
}
#start-box p {
    font-size: 16px; color: #b2bec3; margin-bottom: 36px; line-height: 1.7;
}
#start-btn {
    padding: 16px 56px;
    font-size: 20px; font-weight: 700;
    border: none; border-radius: 40px;
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: #fff;
    cursor: pointer;
    letter-spacing: 3px;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 24px rgba(108,92,231,0.5);
}
#start-btn:hover {
    transform: scale(1.07);
    box-shadow: 0 6px 34px rgba(108,92,231,0.7);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    #hud { padding: 8px 10px; }
    .score-panel { padding: 6px 14px; min-width: 60px; }
    .score-panel .ball-count { font-size: 28px; }
    #timer-display { font-size: 32px; }
    #start-box h1 { font-size: 36px; }
    #skill-btn { width: 66px; height: 66px; }
    .skill-icon { font-size: 20px; }
    #cpu-stats { top: 70px; right: 8px; min-width: 110px; }
    #countdown-text { font-size: 100px; }
    #result-title { font-size: 48px; }
}
