﻿/* ====== WARCRAFT TOWER DEFENCE — STYLES v3 ====== */

:root {
    --color-bg: #080810;
    --color-panel: rgba(16, 14, 30, 0.92);
    --color-panel-solid: #100e1e;
    --color-panel-border: #c49a3c;
    --color-gold: #ffd700;
    --color-gold-dark: #b8860b;
    --color-gold-dim: rgba(196, 154, 60, 0.35);
    --color-red: #ff4444;
    --color-green: #44ff44;
    --color-blue: #4488ff;
    --color-text: #e8d5b0;
    --color-text-light: #fff8e7;
    --color-text-dim: #9a8d76;
    --color-wood: #3d2b1f;
    --color-wood-light: #5c3d2e;
    --color-stone: #4a4a5a;
    --font-title: 'Cinzel', serif;
    --font-body: 'MedievalSharp', cursive;
    --glow-gold: 0 0 8px rgba(255, 215, 0, 0.3), 0 0 20px rgba(255, 215, 0, 0.12);
    --glow-red: 0 0 10px rgba(255, 68, 68, 0.5);
    --glow-blue: 0 0 10px rgba(68, 136, 255, 0.5);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--color-bg);
    font-family: var(--font-body);
    color: var(--color-text);
}

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* ====== SCREENS ====== */
.screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.screen.active { display: flex; }

/* ====== TITLE SCREEN ====== */
#title-screen {
    background:
        radial-gradient(ellipse at 50% 80%, rgba(180, 80, 0, 0.25) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 20%, rgba(60, 40, 120, 0.2) 0%, transparent 50%),
        linear-gradient(180deg, #060612 0%, #0d0d24 40%, #1a0a05 100%);
}

.title-overlay {
    text-align: center;
    padding: 2rem;
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-title {
    font-family: var(--font-title);
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--color-gold);
    text-shadow:
        0 0 20px rgba(255, 215, 0, 0.5),
        0 0 50px rgba(255, 215, 0, 0.15),
        0 4px 8px rgba(0, 0, 0, 0.8),
        2px 2px 0 #8B6914;
    letter-spacing: 4px;
    line-height: 1.1;
    margin-bottom: 0.5rem;
    animation: titleGlow 4s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.15); }
}

.game-subtitle {
    font-family: var(--font-title);
    font-size: 1.1rem;
    color: #7a6a4a;
    letter-spacing: 10px;
    margin-bottom: 3rem;
    text-transform: uppercase;
}

/* ====== LEVEL SELECT ====== */
#level-select {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    max-width: 420px;
    max-height: 140px;
    overflow-y: auto;
    padding: 4px;
}

.btn-level {
    font-family: var(--font-title);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 10px 18px;
    border: 2px solid rgba(196, 154, 60, 0.3);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--color-text-dim);
    background: rgba(20, 16, 10, 0.7);
    transition: all 0.2s ease;
}

.btn-level:hover {
    border-color: var(--color-gold-dark);
    color: var(--color-text-light);
}

.btn-level.selected {
    border-color: var(--color-gold);
    color: var(--color-gold);
    background: rgba(50, 38, 15, 0.8);
    box-shadow: var(--glow-gold);
}

/* ====== GOLD BUTTON (victory actions) ====== */
.btn-gold {
    background: linear-gradient(180deg, #5a4a20 0%, #3a2a0a 50%, #4a3a15 100%);
    border-color: var(--color-gold);
    color: var(--color-gold);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.2);
}
.btn-gold:hover {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.45);
    color: #fff;
}

/* ====== MEDIEVAL BUTTONS ====== */
.btn-medieval {
    font-family: var(--font-title);
    font-size: 1rem;
    font-weight: 700;
    padding: 13px 36px;
    margin: 6px;
    border: 2px solid var(--color-gold-dark);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--color-text-light);
    background: linear-gradient(180deg, #4a3520 0%, #2a1a0f 50%, #3a2515 100%);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: all 0.15s ease;
    display: block;
    min-width: 200px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.btn-medieval::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.08), transparent);
    transition: left 0.4s ease;
}

.btn-medieval:hover::before { left: 100%; }

.btn-medieval:hover {
    border-color: var(--color-gold);
    box-shadow: var(--glow-gold), 0 4px 16px rgba(0, 0, 0, 0.5);
    transform: translateY(-1px);
}

.btn-medieval:active {
    transform: translateY(1px);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
}

.btn-secondary {
    background: linear-gradient(180deg, #35354a 0%, #1a1a28 50%, #28283a 100%);
    border-color: #55556a;
}
.btn-secondary:hover {
    border-color: #8888a0;
    box-shadow: 0 0 12px rgba(100, 100, 150, 0.25);
}

.btn-danger {
    background: linear-gradient(180deg, #5a2020 0%, #3a1010 50%, #4a1515 100%);
    border-color: #aa4444;
}

.btn-small {
    font-size: 0.8rem;
    padding: 8px 16px;
    min-width: auto;
}

.btn-wave {
    font-size: 0.85rem;
    padding: 10px 16px;
    min-width: auto;
}

.btn-mini {
    font-size: 0.8rem;
    min-width: 52px;
    padding: 8px 10px;
}

.btn-medieval.disabled {
    opacity: 0.35;
    pointer-events: none;
    filter: grayscale(0.4);
}

.btn-medieval.selected {
    border-color: var(--color-gold) !important;
    box-shadow: var(--glow-gold) !important;
}

/* ====== HOW TO PLAY ====== */
.howto-panel {
    background: linear-gradient(180deg, #16162a 0%, #0c0c1a 100%);
    border: 2px solid var(--color-gold-dark);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), var(--glow-gold);
    animation: fadeInUp 0.4s ease-out;
}

.howto-panel h2 {
    font-family: var(--font-title);
    color: var(--color-gold);
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
}

.howto-content { margin-bottom: 1.5rem; }

.howto-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.025);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-gold-dim);
    transition: background 0.15s;
}
.howto-item:hover { background: rgba(255, 255, 255, 0.05); }

.howto-icon { font-size: 1.4rem; flex-shrink: 0; }

.howto-item p {
    font-size: 0.9rem;
    line-height: 1.4;
}

/* ====== GAME SCREEN ====== */
#game-screen {
    flex-direction: column;
    justify-content: flex-start;
    background: var(--color-bg);
    overflow: hidden;
}

/* ====== HUD TOP ====== */
#hud-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 5px 10px;
    background: linear-gradient(180deg, rgba(18, 14, 32, 0.95) 0%, rgba(12, 10, 24, 0.9) 100%);
    border-bottom: 1px solid var(--color-gold-dim);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    z-index: 100;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-title);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--color-text-light);
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 20px;
    border: 1px solid rgba(196, 154, 60, 0.15);
    min-width: 60px;
    justify-content: center;
}

.hud-icon { font-size: 0.95rem; }

#hud-gold { color: var(--color-gold); border-color: rgba(255, 215, 0, 0.2); }
#hud-lives { color: #ff6666; border-color: rgba(255, 100, 100, 0.15); }
#hud-wave { color: #66aaff; border-color: rgba(100, 170, 255, 0.15); }
#hud-score { color: #aaffaa; border-color: rgba(170, 255, 170, 0.15); }

/* ====== CANVAS ====== */
#game-canvas {
    display: block;
    image-rendering: pixelated;
    cursor: pointer;
    margin: 0 auto;
}

/* ====== HUD BOTTOM ====== */
#hud-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 6px 10px;
    background: linear-gradient(0deg, rgba(18, 14, 32, 0.96) 0%, rgba(12, 10, 24, 0.92) 100%);
    border-top: 1px solid var(--color-gold-dim);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.5);
    z-index: 100;
    flex-shrink: 0;
    gap: 6px;
    position: fixed;
    bottom: 0; left: 0;
    flex-wrap: nowrap;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* ====== TOWER BUTTONS ====== */
#tower-panel {
    display: flex;
    gap: 5px;
    flex: 1;
}

.tower-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 60px;
    height: 60px;
    border: 2px solid rgba(196, 154, 60, 0.4);
    border-radius: var(--radius-md);
    cursor: pointer;
    background: linear-gradient(180deg, rgba(50, 36, 20, 0.9) 0%, rgba(22, 14, 6, 0.95) 100%);
    color: var(--color-text-light);
    transition: all 0.15s ease;
    position: relative;
    overflow: hidden;
}

.tower-btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(circle at 50% 30%, rgba(255, 215, 0, 0.06) 0%, transparent 70%);
    pointer-events: none;
}

.tower-btn:hover {
    border-color: var(--color-gold);
    box-shadow: var(--glow-gold);
    transform: translateY(-2px);
}
.tower-btn:hover::after {
    background: radial-gradient(circle at 50% 30%, rgba(255, 215, 0, 0.12) 0%, transparent 70%);
}

.tower-btn:active { transform: translateY(1px); }

.tower-btn.selected {
    border-color: var(--color-gold);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.5), inset 0 0 20px rgba(255, 215, 0, 0.08);
    background: linear-gradient(180deg, rgba(70, 50, 20, 0.95) 0%, rgba(35, 22, 8, 0.95) 100%);
}

.tower-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(0.5);
}

.tower-btn-icon { font-size: 1.5rem; line-height: 1; }

.tower-btn-cost {
    font-family: var(--font-title);
    font-size: 0.6rem;
    color: var(--color-gold);
    font-weight: 700;
    opacity: 0.85;
}

/* ====== SKILL BUTTONS ====== */
#skill-panel {
    display: flex;
    gap: 4px;
    align-items: center;
}

.skill-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 2px solid rgba(100, 140, 200, 0.35);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    background: linear-gradient(180deg, rgba(30, 40, 70, 0.9) 0%, rgba(15, 18, 40, 0.95) 100%);
    color: var(--color-text-light);
    transition: all 0.15s ease;
    font-family: var(--font-body);
    position: relative;
}

.skill-btn:hover {
    border-color: #88bbff;
    box-shadow: var(--glow-blue);
    transform: scale(1.08);
}

.skill-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(0.6);
}

.skill-btn.selected {
    border-color: #ffaa44;
    box-shadow: 0 0 12px rgba(255, 170, 68, 0.5);
    animation: skillPulse 1.2s ease-in-out infinite;
}

.skill-btn .cooldown-text {
    position: absolute;
    bottom: -2px;
    font-size: 0.5rem;
    font-family: var(--font-title);
    font-weight: 700;
    color: #ff8888;
}

@keyframes skillPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 170, 68, 0.4); }
    50% { box-shadow: 0 0 20px rgba(255, 170, 68, 0.7); }
}

/* ====== CONTROL BUTTONS (speed, wave, settings) ====== */
#controls-panel {
    display: flex;
    gap: 5px;
    align-items: center;
}

.ctrl-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--color-gold-dim);
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font-title);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-light);
    background: rgba(30, 24, 16, 0.85);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.ctrl-btn:hover {
    border-color: var(--color-gold);
    background: rgba(50, 38, 20, 0.9);
    box-shadow: var(--glow-gold);
}

.ctrl-btn:active { transform: scale(0.96); }

.ctrl-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.ctrl-btn-icon { font-size: 1rem; }

.ctrl-btn-wave {
    background: linear-gradient(180deg, #4a3520 0%, #2a1a0f 100%);
    border: 2px solid var(--color-gold-dark);
    padding: 0 16px;
    height: 42px;
    font-size: 0.82rem;
    animation: wavePulse 2.5s ease-in-out infinite;
}

.ctrl-btn-wave:hover {
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.4);
}

@keyframes wavePulse {
    0%, 100% { box-shadow: 0 0 6px rgba(255, 215, 0, 0.15); }
    50% { box-shadow: 0 0 18px rgba(255, 215, 0, 0.35); }
}

.ctrl-btn-settings {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    font-size: 1rem;
}

/* ====== TOWER INFO POPUP ====== */
#tower-info {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    animation: fadeInUp 0.15s ease-out;
    pointer-events: auto;
}

.tower-info-content {
    background: linear-gradient(180deg, rgba(24, 20, 42, 0.97) 0%, rgba(10, 8, 20, 0.98) 100%);
    border: 1px solid var(--color-gold-dim);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    text-align: center;
    min-width: 280px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), var(--glow-gold);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.tower-info-content h3 {
    font-family: var(--font-title);
    color: var(--color-gold);
    margin-bottom: 8px;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.tower-info-content p {
    font-size: 0.8rem;
    margin-bottom: 12px;
    line-height: 1.5;
    color: #b0a890;
}

.tower-info-content p span {
    color: var(--color-text-light);
    font-weight: 700;
}

.tower-info-buttons {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.hidden { display: none !important; }

/* ====== SETTINGS PANEL ====== */
#settings-panel {
    position: absolute;
    right: 10px;
    bottom: 80px;
    z-index: 40;
    width: min(340px, calc(100vw - 20px));
    animation: fadeInUp 0.15s ease-out;
}

.settings-content {
    background: linear-gradient(180deg, rgba(22, 18, 38, 0.97) 0%, rgba(10, 8, 18, 0.98) 100%);
    border: 1px solid var(--color-gold-dim);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: 0 8px 36px rgba(0, 0, 0, 0.6), var(--glow-gold);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.settings-content h3 {
    margin-bottom: 12px;
    color: var(--color-gold);
    font-family: var(--font-title);
    font-size: 0.95rem;
    text-align: center;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    padding: 8px 10px;
    border: 1px solid rgba(196, 154, 60, 0.12);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.15);
    transition: background 0.15s;
}

.settings-row:hover { background: rgba(0, 0, 0, 0.25); }

.settings-row span {
    font-size: 0.82rem;
    color: #c9c0ac;
}

.settings-row select {
    border: 1px solid #5f5a34;
    border-radius: 4px;
    padding: 5px 8px;
    background: #1a1408;
    color: #e8dcc2;
    font-family: var(--font-title);
    font-size: 0.78rem;
    cursor: pointer;
}

.checkbox-row {
    justify-content: flex-start;
    gap: 10px;
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    transform: scale(1.15);
    accent-color: #c9a040;
    cursor: pointer;
}

/* ====== PAUSE OVERLAY ====== */
#pause-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 45;
    background: rgba(6, 6, 14, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.pause-panel {
    min-width: 260px;
    max-width: min(380px, 90vw);
    background: linear-gradient(180deg, rgba(20, 16, 34, 0.98) 0%, rgba(10, 8, 18, 0.99) 100%);
    border: 1px solid var(--color-gold-dim);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6), var(--glow-gold);
}

.pause-panel h2 {
    color: var(--color-gold);
    font-family: var(--font-title);
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.pause-panel p {
    color: #b0a890;
    margin-bottom: 14px;
    font-size: 0.88rem;
}

/* ====== GAME OVER ====== */
.gameover-panel {
    background: linear-gradient(180deg, #1a0808 0%, #0a0510 100%);
    border: 2px solid #cc3333;
    border-radius: var(--radius-lg);
    padding: 2rem 3rem;
    text-align: center;
    box-shadow: 0 0 50px rgba(204, 51, 51, 0.25);
    animation: fadeInUp 0.4s ease-out;
}

.gameover-panel h2 {
    font-family: var(--font-title);
    font-size: 2.2rem;
    color: #ff4444;
    text-shadow: 0 0 20px rgba(255, 50, 50, 0.4);
    margin-bottom: 1rem;
}

.gameover-panel p {
    font-family: var(--font-title);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

#gameover-score span, #gameover-wave span { color: var(--color-gold); }

#gameover-score { margin-bottom: 1.5rem; }

/* ====== RESPONSIVE ====== */
@media (max-width: 420px) {
    .game-title { font-size: 2.6rem; }
    .tower-btn { width: 50px; height: 50px; }
    .tower-btn-icon { font-size: 1.2rem; }
    .hud-item { font-size: 0.72rem; padding: 4px 7px; min-width: 50px; }
    .ctrl-btn { height: 34px; padding: 0 8px; font-size: 0.7rem; }
    .ctrl-btn-wave { height: 36px; padding: 0 12px; }
    .skill-btn { width: 36px; height: 36px; font-size: 0.95rem; }
    #settings-panel { bottom: 68px; right: 6px; }
    #tower-info { bottom: 70px; }
}

@media (min-width: 600px) {
    .game-title { font-size: 5rem; }
    .tower-btn { width: 68px; height: 68px; }
    .tower-btn-icon { font-size: 1.6rem; }
    .ctrl-btn { height: 40px; font-size: 0.8rem; }
    .ctrl-btn-wave { height: 44px; }
    .hud-item { font-size: 0.9rem; padding: 6px 12px; }
}

/* ====== SCROLLBAR ====== */
.howto-panel::-webkit-scrollbar { width: 5px; }
.howto-panel::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 3px; }
.howto-panel::-webkit-scrollbar-thumb { background: var(--color-gold-dark); border-radius: 3px; }

/* ====== DAMAGE FLASH ====== */
@keyframes damageFlash {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(255, 0, 0, 0.12); }
}
.damage-flash { animation: damageFlash 0.3s ease; }
