/* ============================================
   수학 성 수호자 V2 - Dark Cyber Theme
   ============================================ */

/* === CSS Variables === */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-glass: rgba(15, 23, 42, 0.75);
    --border-glass: rgba(100, 200, 255, 0.15);
    --accent-cyan: #00e5ff;
    --accent-magenta: #ff00e5;
    --accent-gold: #ffd700;
    --accent-green: #00ff88;
    --accent-red: #ff3366;
    --accent-orange: #ff8c00;
    --accent-purple: #a855f7;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-dim: #475569;
    --glow-cyan: 0 0 20px rgba(0, 229, 255, 0.3);
    --glow-gold: 0 0 20px rgba(255, 215, 0, 0.3);
    --glow-magenta: 0 0 20px rgba(255, 0, 229, 0.3);
    --glow-green: 0 0 20px rgba(0, 255, 136, 0.3);
    --font-display: 'Orbitron', monospace;
    --font-body: 'Noto Sans KR', 'Do Hyeon', sans-serif;
    --font-game: 'Do Hyeon', sans-serif;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
}

/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    user-select: none;
    color: var(--text-primary);
}

#game-content {
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    position: relative;
}

/* === Main Menu === */
#difficultyModal {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(0, 229, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(255, 0, 229, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(168, 85, 247, 0.05) 0%, transparent 60%),
        linear-gradient(160deg, #050816 0%, #0a0e1a 30%, #0d1525 60%, #06091a 100%);
    position: relative;
    overflow: hidden;
}

#difficultyModal::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(2px 2px at 20% 30%, rgba(0, 229, 255, 0.15), transparent),
        radial-gradient(2px 2px at 40% 70%, rgba(255, 0, 229, 0.12), transparent),
        radial-gradient(1px 1px at 60% 20%, rgba(255, 255, 255, 0.1), transparent),
        radial-gradient(1px 1px at 80% 60%, rgba(255, 215, 0, 0.08), transparent);
    background-size: 250px 250px, 300px 300px, 200px 200px, 350px 350px;
    animation: starfield 120s linear infinite;
    z-index: 0;
}

@keyframes starfield {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#menuParticleCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.menu-container {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 48px 40px;
    max-width: 560px;
    width: 92%;
    background: rgba(8, 12, 28, 0.55);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(100, 200, 255, 0.08);
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.6),
        0 0 80px rgba(0, 229, 255, 0.03),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    animation: menuFadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes menuFadeIn {
    from { opacity: 0; transform: translateY(30px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.menu-logo {
    margin-bottom: 44px;
    position: relative;
}

.logo-castle {
    font-size: 80px;
    display: block;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 0 40px rgba(255, 215, 0, 0.6)) drop-shadow(0 10px 30px rgba(0, 0, 0, 0.4));
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.brand-title {
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 10px;
    color: var(--accent-cyan);
    text-transform: uppercase;
    margin-bottom: 10px;
    text-shadow: var(--glow-cyan);
    opacity: 0.9;
}

.main-title {
    font-family: var(--font-game);
    font-size: 48px;
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 40%, #ffe066 60%, #ffd700 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: goldShimmer 3s ease-in-out infinite;
    margin-bottom: 6px;
    line-height: 1.2;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

@keyframes goldShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.main-subtitle {
    font-family: var(--font-display);
    font-size: 10px;
    letter-spacing: 8px;
    color: var(--text-dim);
    text-transform: uppercase;
    opacity: 0.7;
}

.version-badge {
    display: inline-block;
    margin-top: 16px;
    padding: 4px 18px;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
    border-radius: 20px;
    font-family: var(--font-display);
    font-size: 10px;
    font-weight: 700;
    color: white;
    letter-spacing: 3px;
    box-shadow: 0 4px 20px rgba(0, 229, 255, 0.25), 0 4px 20px rgba(255, 0, 229, 0.25);
}

.difficulty-section {
    margin-bottom: 36px;
}

.section-label {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-weight: 400;
    letter-spacing: 1px;
}

.difficulty-options {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

.difficulty-btn {
    width: 88px;
    height: 92px;
    border: 1.5px solid rgba(100, 200, 255, 0.12);
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.8), rgba(20, 30, 55, 0.6));
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
    overflow: hidden;
}

.difficulty-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.15), rgba(255, 0, 229, 0.15));
    opacity: 0;
    transition: opacity 0.35s ease;
}

.difficulty-btn:hover::before, .difficulty-btn:active::before {
    opacity: 1;
}

.difficulty-btn:hover, .difficulty-btn:active {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 25px rgba(0, 229, 255, 0.2), 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 0 30px rgba(0, 229, 255, 0.03);
    transform: translateY(-5px) scale(1.04);
}

.diff-grade {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 900;
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.3));
    position: relative;
    z-index: 1;
}

.diff-label {
    font-size: 12px;
    color: var(--text-secondary);
    position: relative;
    z-index: 1;
    letter-spacing: 1px;
}

.menu-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.menu-btn {
    padding: 11px 22px;
    border: 1px solid rgba(100, 200, 255, 0.1);
    border-radius: var(--radius-md);
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.7), rgba(20, 30, 55, 0.5));
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.menu-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.08), rgba(255, 0, 229, 0.08));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.menu-btn:hover:not(:disabled)::after {
    opacity: 1;
}

.menu-btn:hover:not(:disabled) {
    border-color: rgba(0, 229, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3), 0 0 15px rgba(0, 229, 255, 0.1);
}

.menu-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 16px;
    position: relative;
    z-index: 1;
}

/* === Game Canvas === */
#gameCanvas {
    width: 100%;
    height: 100%;
    position: relative;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(0, 229, 255, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(255, 0, 229, 0.03) 0%, transparent 50%),
        linear-gradient(180deg, #0d1117 0%, #111827 50%, #0f172a 100%);
    display: none;
    overflow: hidden;
    contain: layout style paint;
}

#gameCanvas::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        radial-gradient(rgba(100, 200, 255, 0.04) 1px, transparent 1px);
    background-size: 30px 30px;
    pointer-events: none;
    z-index: 0;
}

#dynamicLayerCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 12;
}

#gameUI {
    display: none;
}

/* === Path & Tiles === */
.path {
    position: absolute;
    background: linear-gradient(180deg, rgba(30, 60, 100, 0.6), rgba(20, 40, 80, 0.8));
    border: 1px solid rgba(100, 200, 255, 0.15);
    box-shadow: inset 0 0 20px rgba(0, 100, 200, 0.2);
    z-index: 1;
    border-radius: 8px;
}

.placement-tile {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 1px dashed rgba(100, 200, 255, 0.2);
    border-radius: var(--radius-sm);
    pointer-events: auto;
    cursor: pointer;
    z-index: 2;
    transition: all 0.2s ease;
    background: rgba(0, 229, 255, 0.02);
}

.placement-tile:hover {
    background-color: rgba(0, 229, 255, 0.08);
    border-color: rgba(0, 229, 255, 0.4);
    box-shadow: inset 0 0 15px rgba(0, 229, 255, 0.1);
}

#rangeIndicator {
    position: absolute;
    border-radius: 50%;
    background-color: rgba(0, 229, 255, 0.06);
    border: 1px dashed rgba(0, 229, 255, 0.3);
    pointer-events: none;
    display: none;
    z-index: 99;
    transform: translate(-50%, -50%);
}

/* === Castle (Canvas 렌더링 - 히트박스만 유지) === */
.castle {
    position: absolute;
    width: 120px;
    height: 140px;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    /* 비주얼은 Canvas에서 그림, DOM은 히트박스 + 체력바만 */
}

.castle-body {
    position: absolute;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
}

/* 포탑 - Canvas에서 그리므로 숨김 */
.castle-body::before,
.castle-body::after {
    display: none;
}

/* 깃발 - Canvas에서 그리므로 숨김 */
.castle::before {
    display: none;
}

/* 창문 - Canvas에서 그리므로 숨김 */
.castle::after {
    display: none;
}

.castle-health {
    position: absolute;
    bottom: -32px;
    width: 100px;
    background: linear-gradient(145deg, rgba(10, 14, 26, 0.9), rgba(20, 25, 45, 0.85));
    backdrop-filter: blur(10px);
    color: var(--accent-gold);
    padding: 5px 10px;
    border-radius: 20px;
    font-weight: bold;
    border: 1px solid rgba(255, 215, 0, 0.25);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.4);
    text-align: center;
    font-family: var(--font-display);
    font-size: 14px;
    z-index: 3;
}

/* === Wizard (Canvas sprite - 히트박스만 유지) === */
.wizard {
    position: absolute;
    width: 48px;
    height: 56px;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
    box-shadow: none;
    animation: none;
    /* 히트박스만 유지, 실제 렌더링은 dynamicLayerCanvas에서 */
}

.wizard::before { content: ''; }

.wizard.on-cooldown::after {
    content: '';
    position: absolute;
    top: -8px; right: -8px; bottom: -8px; left: -8px;
    border-radius: 50%;
    border: 2px solid var(--accent-cyan);
    animation: wizardCooldownSparkle 1.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes wizardCooldownSparkle {
    0% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.15); opacity: 0.3; }
    100% { transform: scale(1); opacity: 0.7; }
}

/* === Info Bar (Top HUD) === */
#info-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: linear-gradient(180deg, rgba(10, 14, 26, 0.95) 0%, rgba(10, 14, 26, 0.7) 100%);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    z-index: 100;
    gap: 8px;
}

.info-left, .info-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 13px;
}

.info-icon { font-size: 14px; }
.info-label { color: var(--text-dim); font-size: 11px; display: none; }
.info-value { font-family: var(--font-display); font-weight: 700; font-size: 14px; }

.gold-info .info-value { color: var(--accent-gold); }
.score-info .info-value { color: var(--accent-cyan); }
.wave-info .info-value { color: var(--accent-magenta); }

.wizard-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-display);
    font-size: 13px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    border-color: var(--accent-cyan);
    background: rgba(0, 229, 255, 0.1);
}

.icon-btn.upgrade-btn {
    border-color: rgba(0, 255, 136, 0.3);
}

.icon-btn.upgrade-btn:hover {
    border-color: var(--accent-green);
    background: rgba(0, 255, 136, 0.1);
    box-shadow: var(--glow-green);
}

/* === Combo Display === */
.combo-display {
    position: fixed;
    top: 55px;
    right: 16px;
    z-index: 100;
    text-align: center;
    animation: comboEntry 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.combo-display.hidden { display: none; }

.combo-count {
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 900;
    color: var(--accent-gold);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    line-height: 1;
}

.combo-label {
    font-family: var(--font-display);
    font-size: 12px;
    letter-spacing: 4px;
    color: var(--accent-cyan);
    text-shadow: var(--glow-cyan);
}

.combo-multiplier {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-magenta);
    text-shadow: var(--glow-magenta);
}

@keyframes comboEntry {
    from { transform: scale(0.5) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes comboPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* === Control Bar (Bottom) === */
#control-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: linear-gradient(0deg, rgba(10, 14, 26, 0.95) 0%, rgba(10, 14, 26, 0.7) 100%);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-glass);
    z-index: 100;
}

.control-left, .control-right {
    display: flex;
    gap: 8px;
}

.ctrl-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ctrl-btn:hover {
    border-color: var(--accent-cyan);
    background: rgba(0, 229, 255, 0.1);
}

.ctrl-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ctrl-btn.primary {
    border-color: var(--accent-green);
    background: rgba(0, 255, 136, 0.1);
    color: var(--accent-green);
    font-weight: 700;
}

.ctrl-btn.primary:hover {
    background: rgba(0, 255, 136, 0.2);
    box-shadow: var(--glow-green);
}

/* === Tower Base (3D 입체감 업그레이드) === */
/* [V3] 타워 DOM은 투명 히트박스 (캔버스 렌더링) */
.tower {
    position: absolute;
    width: 40px;
    height: 40px;
    background: transparent !important;
    border: none !important;
    cursor: pointer;
    z-index: 5;
    clip-path: none !important;
    box-shadow: none !important;
}

.tower.disabled {
    filter: grayscale(100%) brightness(0.4);
    pointer-events: none;
}

.tower.disabled::after {
    content: '🚫';
    position: absolute;
    font-size: 24px;
    color: red;
    text-shadow: 0 0 5px white;
    z-index: 6;
}

.tower.time-warped {
    filter: hue-rotate(180deg) brightness(0.7);
}

.tower:hover {
    /* Canvas 렌더링이므로 hover는 미니멀하게 */
}

/* [V3] 타워 아이콘/이모지 숨김 (캔버스 렌더링) */
.tower::before {
    display: none !important;
}

/* Individual tower styles */
.tower-plus { border-color: rgba(76, 175, 80, 0.5); }
.tower-plus::before { content: '+'; color: #4CAF50; text-shadow: 0 0 10px rgba(76, 175, 80, 0.5); }
.tower-minus { border-color: rgba(255, 152, 0, 0.5); }
.tower-minus::before { content: '−'; color: #ff9800; text-shadow: 0 0 10px rgba(255, 152, 0, 0.5); }
.tower-multiply { border-color: rgba(156, 39, 176, 0.5); }
.tower-multiply::before { content: '×'; color: #9c27b0; text-shadow: 0 0 10px rgba(156, 39, 176, 0.5); }
.tower-divide { border-color: rgba(244, 67, 54, 0.5); }
.tower-divide::before { content: '÷'; color: #f44336; text-shadow: 0 0 10px rgba(244, 67, 54, 0.5); }
.tower-cannon::before { content: '💣'; }
.tower-skyDestroyer::before { content: '🚀'; }
.tower-ice { border-color: rgba(0, 229, 255, 0.5); }
.tower-ice::before { content: '❄️'; }
.tower-meteor::before { content: '☄️'; }
.tower-poison { border-color: rgba(139, 195, 74, 0.5); }
.tower-poison::before { content: '☠️'; }
.tower-stun { border-color: rgba(255, 235, 59, 0.5); }
.tower-stun::before { content: '⚡'; }
.tower-net::before { content: '🕸️'; }
.tower-laser::before { content: '⚡'; font-size: 24px; color: #f39c12; animation: laser-pulse 1s infinite; }
@keyframes laser-pulse { 50% { filter: drop-shadow(0 0 12px #f39c12); } }
.tower-multi-shot::before { content: '🎯'; font-size: 24px; color: #3498db; }
.tower-goldMine { border-color: rgba(255, 215, 0, 0.5); }
.tower-goldMine::before { content: '💰'; }
.tower-shredder::before { content: '💥'; }
.tower-repairStation { border-color: rgba(0, 255, 136, 0.5); }
.tower-repairStation::before { content: '🛠️'; }

/* Random box towers */
.tower-random_cheap { border-color: rgba(255, 255, 255, 0.3); animation: randomBoxPulse 2s infinite; }
.tower-random_cheap::before { content: '❓'; }
.tower-random_medium { border-color: rgba(168, 85, 247, 0.5); animation: randomBoxPulse 1.5s infinite; }
.tower-random_medium::before { content: '❔'; }
.tower-random_expensive { border-color: rgba(255, 0, 229, 0.5); animation: randomBoxPulse 1s infinite; }
.tower-random_expensive::before { content: '❗'; }
@keyframes randomBoxPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(168, 85, 247, 0.3); }
    50% { box-shadow: 0 0 25px rgba(168, 85, 247, 0.6); }
}

/* [V3] 특수 타워도 투명 히트박스 (캔버스 렌더링) */
.tower-ultimate { animation: none !important; }
.tower-ultimate::before { display: none !important; }
.tower-ultimate::after { display: none !important; }
@keyframes ultimate-rainbow { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(360deg); } }
@keyframes ultimate-pulse {
    from { box-shadow: 0 0 15px var(--accent-magenta), 0 0 30px var(--accent-cyan); }
    to { box-shadow: 0 0 25px var(--accent-magenta), 0 0 50px var(--accent-cyan), 0 0 70px var(--accent-gold); }
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.tower-transcendent { animation: none !important; }
.tower-transcendent::before { display: none !important; }
.tower-transcendent::after { display: none !important; }
@keyframes transcendent-bg { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes transcendent-pulse {
    from { box-shadow: 0 0 20px var(--accent-magenta), 0 0 40px var(--accent-cyan); transform: scale(1); }
    to { box-shadow: 0 0 40px var(--accent-magenta), 0 0 80px var(--accent-cyan), 0 0 120px var(--accent-gold); transform: scale(1.05); }
}
@keyframes transcendent-float {
    from { transform: translateY(-2px) scale(1); }
    to { transform: translateY(2px) scale(1.1); }
}

.tower-golden { animation: none !important; }
.tower-golden::before { display: none !important; }
@keyframes goldenGlow {
    from { box-shadow: 0 0 15px #ffc500, 0 0 30px #ff8c00; }
    to { box-shadow: 0 0 25px #ffc500, 0 0 50px #ff8c00; }
}

.tower-silver { animation: none !important; }
.tower-silver::before { display: none !important; }
@keyframes silverGlow {
    from { box-shadow: 0 0 10px #fff, 0 0 20px #c0c0c0; }
    to { box-shadow: 0 0 20px #fff, 0 0 35px #c0c0c0; }
}

.tower-copper { animation: none !important; }
.tower-copper::before { display: none !important; }
@keyframes copperGlow {
    from { box-shadow: 0 0 10px #cd853f, 0 0 15px #b87333; }
    to { box-shadow: 0 0 15px #cd853f, 0 0 25px #b87333; }
}

/* [V3] 타워 레벨 표시 숨김 (캔버스에서 레벨 링으로 표시) */
.tower-level {
    display: none !important;
}

/* === Monsters (Canvas 렌더링 - 히트박스만 유지) === */
.monster {
    position: absolute;
    width: 30px; height: 30px;
    border: none;
    border-radius: 50%;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform;
    top: 0; left: 0;
    background: transparent;
    /* 비주얼은 Canvas에서 그림 */
}

/* 이모지 숨김 - Canvas에서 그림 */
.monster::before { display: none; }
.monster::after { display: none; }

/* 상태이펙트도 Canvas에서 처리하므로 DOM 이펙트 최소화 */
.monster.slowed, .monster.frozen { }
.monster.poisoned { }
.monster.stunned { }
.monster.stealthed { opacity: 0.15; }
.monster.shielded { }
.monster.shredded { }

/* Individual monsters - 모두 투명 히트박스 */
.monster-normal { background: transparent; }
.monster-normal::before { display: none; }

/* Canvas에서 그리므로 모든 몬스터 비주얼 투명 처리, 크기만 유지 */
.monster-tank { width: 45px; height: 45px; background: transparent; border: none; }
.monster-healer { background: transparent; border: none; }
.monster-speed { background: transparent; border: none; }
.monster-boss { width: 60px; height: 60px; background: transparent; border: none; }
.monster-finalBoss { width: 80px; height: 80px; background: transparent; border: none; }
.monster-archfiend { width: 65px; height: 65px; background: transparent; border: none; }
.monster-bat { background: transparent; border: none; z-index: 9; }
.monster-dragon { width: 50px; height: 50px; background: transparent; border: none; z-index: 9; }
.monster-shielder { background: transparent; border: none; }
.monster-teleporter { background: transparent; border: none; }
.monster-splitter { background: transparent; border: none; }
.monster-mini-splitter { width: 20px; height: 20px; background: transparent; border: none; }
.monster-ghost { background: transparent; border: none; }
.monster-mimic { background: transparent; border: none; }
.monster-summoner { background: transparent; border: none; }
.monster-general { width: 40px; height: 40px; background: transparent; border: none; }
.monster-plaguebearer { background: transparent; border: none; }
.monster-assassin { background: transparent; border: none; }
.monster-disruptor { background: transparent; border: none; }
.monster-chronomancer { background: transparent; border: none; }
.monster-golem { width: 48px; height: 48px; background: transparent; border: none; }
.monster-mirage { background: transparent; border: none; }
.monster-leech { background: transparent; border: none; z-index: 9; }
.monster-collector { background: transparent; border: none; }
.monster-ancientDragon { width: 70px; height: 70px; background: transparent; border: none; z-index: 9; }
.monster-voidLord { width: 65px; height: 65px; background: transparent; border: none; }
.monster-titanGolem { width: 75px; height: 75px; background: transparent; border: none; }

/* Monster health - DOM 체력바는 Canvas에서 그리므로 숨김 */
.monster-health { display: none; }
.monster-health-bar { display: none; }

/* === Laser Beam === */
/* [V3] 레이저 빔 DOM 숨김 (캔버스 렌더링) */
.laser-beam {
    display: none !important;
}

/* === Effects === */
/* [V3] 스펠 이펙트 DOM 숨김 (캔버스 렌더링) */
.magic-attack, .frost-nova, .chain-lightning, .teleport-effect, .black-hole, .plague-pool, .splash-damage-effect, .time-warp-effect, .damage-reflect-effect, .soul-drain-effect {
    position: absolute;
    pointer-events: none;
    z-index: 20;
    opacity: 0 !important;
}

.splash-damage-effect {
    width: 1px; height: 1px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: splash-animation 0.8s ease-out forwards;
}
.splash-damage-effect::before {
    content: ''; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); width: 100%; height: 100%; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,82,82,0) 0%, rgba(255,50,50,0.6) 50%, transparent 70%);
    animation: splash-wave 0.8s ease-out forwards;
}
@keyframes splash-animation { from { width: 1px; height: 1px; } to { width: var(--effect-size, 120px); height: var(--effect-size, 120px); opacity: 0; } }
@keyframes splash-wave { 0% { transform: translate(-50%,-50%) scale(0.1); opacity: 1; } 100% { transform: translate(-50%,-50%) scale(1); opacity: 0; } }

.ultimate-splash-effect {
    width: 1px; height: 1px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: ultimate-splash 1.2s ease-out forwards;
    position: absolute; pointer-events: none; z-index: 25;
}
.ultimate-splash-effect::before {
    content: ''; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); width: 100%; height: 100%;
    background: conic-gradient(from 0deg, rgba(255,0,255,0.6), rgba(0,255,255,0.6), rgba(255,255,0,0.6), rgba(255,0,0,0.6), rgba(255,0,255,0.6));
    border-radius: 50%;
    animation: splash-wave 1.2s ease-out forwards;
}
@keyframes ultimate-splash { from { width: 1px; height: 1px; } to { width: var(--effect-size, 200px); height: var(--effect-size, 200px); opacity: 0; } }

.magic-attack { border-radius: 50%; background: radial-gradient(circle, rgba(255,100,0,0.8), transparent 70%); animation: magicBurst 0.5s ease-out forwards; }
.frost-nova { border-radius: 50%; background: radial-gradient(circle, rgba(0,229,255,0.6), transparent 70%); animation: magicBurst 0.5s ease-out forwards; }
@keyframes magicBurst { 0% { transform: translate(-50%,-50%) scale(0.3); opacity: 1; } 100% { transform: translate(-50%,-50%) scale(1); opacity: 0; } }

.chain-lightning { height: 3px; background: linear-gradient(90deg, transparent, var(--accent-cyan), #fff, var(--accent-cyan), transparent); box-shadow: 0 0 10px var(--accent-cyan); transform-origin: left center; }

.teleport-effect { border-radius: 50%; background: radial-gradient(circle, rgba(168,85,247,0.6), transparent 70%); animation: magicBurst 0.3s ease-out forwards; }
.black-hole { border-radius: 50%; background: radial-gradient(circle, #000 30%, rgba(100,0,200,0.5) 60%, transparent 80%); box-shadow: 0 0 30px rgba(100,0,200,0.5); animation: blackHoleSpin 1s linear infinite; }
@keyframes blackHoleSpin { from { transform: translate(-50%,-50%) rotate(0deg); } to { transform: translate(-50%,-50%) rotate(360deg); } }

.plague-pool { border-radius: 50%; background: radial-gradient(circle, rgba(76,175,80,0.5), transparent 70%); animation: plaguePoolPulse 1s ease-in-out infinite; }
@keyframes plaguePoolPulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.8; } }

.time-warp-effect { border-radius: 50%; background: radial-gradient(circle, rgba(124,77,255,0.4), transparent 70%); animation: magicBurst 1s ease-out forwards; }
.damage-reflect-effect { border-radius: 50%; background: radial-gradient(circle, rgba(255,0,0,0.5), transparent 70%); animation: magicBurst 0.3s ease-out forwards; }
.soul-drain-effect { border-radius: 50%; background: radial-gradient(circle, rgba(100,0,100,0.5), transparent 70%); animation: magicBurst 1.5s ease-out forwards; }

/* === Tower Selector === */
.tower-selector {
    position: fixed;
    z-index: 200;
    display: none;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.tower-selector.show { display: block; }

.tower-options-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 8px;
    max-width: 400px;
    max-height: 250px;
    overflow-y: auto;
}

.tower-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.03);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 56px;
}

.tower-option:hover {
    border-color: var(--accent-cyan);
    background: rgba(0, 229, 255, 0.08);
    transform: translateY(-2px);
}

.tower-option-symbol { font-size: 22px; margin-bottom: 2px; }
.tower-option-cost { font-size: 11px; color: var(--accent-gold); font-family: var(--font-display); }
.tower-option-air-label { font-size: 10px; color: var(--accent-cyan); }

.cancel-build-btn {
    width: 100%;
    margin-top: 8px;
    padding: 6px;
    border: 1px solid var(--accent-red);
    border-radius: var(--radius-sm);
    background: rgba(255, 51, 102, 0.1);
    color: var(--accent-red);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.cancel-build-btn:hover {
    background: rgba(255, 51, 102, 0.2);
}

/* === Tower Upgrade Panel === */
.tower-upgrade-selector {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    text-align: center;
    min-width: 280px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    display: none;
}

.tower-upgrade-selector.show { display: block; }

.panel-title {
    color: var(--accent-gold);
    font-family: var(--font-game);
    font-size: 18px;
    margin-bottom: 12px;
}

.tower-detail-info {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.tower-detail-info b { color: var(--accent-gold); }

.upgrade-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.action-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-body);
}

.action-btn.upgrade { border-color: var(--accent-green); color: var(--accent-green); }
.action-btn.upgrade:hover { background: rgba(0,255,136,0.1); }
.action-btn.upgrade:disabled { opacity: 0.4; cursor: not-allowed; }
.action-btn.sell { border-color: var(--accent-orange); color: var(--accent-orange); }
.action-btn.sell:hover { background: rgba(255,140,0,0.1); }
.action-btn.close { border-color: var(--text-dim); color: var(--text-dim); }
.action-btn.close:hover { border-color: var(--text-secondary); color: var(--text-secondary); }

/* === Tooltip === */
#tower-info-tooltip {
    position: fixed;
    display: none;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    z-index: 300;
    max-width: 220px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

#tower-info-tooltip b { color: var(--accent-gold); }

/* === Spell Selector === */
#spellSelector {
    position: fixed;
    z-index: 200;
    display: none;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

#spellSelector.show { display: block; }

.spell-options-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.spell-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.03);
    cursor: pointer;
    transition: all 0.2s;
}

.spell-option:hover { border-color: var(--accent-purple); background: rgba(168,85,247,0.1); }
.spell-option.active { border-color: var(--accent-purple); background: rgba(168,85,247,0.15); box-shadow: var(--glow-magenta); }
.spell-option-symbol { font-size: 24px; }
.spell-option-cost { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

/* === Modals === */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.modal.show { display: flex; }

.modal-content {
    background: linear-gradient(160deg, rgba(17, 24, 39, 0.97), rgba(10, 14, 26, 0.98));
    border: 1px solid rgba(100, 200, 255, 0.1);
    border-radius: var(--radius-xl);
    padding: 36px;
    max-width: 520px;
    width: 92%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.6),
        0 0 60px rgba(0, 229, 255, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    animation: modalEntry 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEntry {
    from { transform: scale(0.92) translateY(24px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-title {
    text-align: center;
    font-family: var(--font-game);
    font-size: 24px;
    color: var(--accent-gold);
    margin-bottom: 20px;
}

.modal-btn {
    display: inline-block;
    padding: 12px 28px;
    border: 1px solid rgba(100, 200, 255, 0.12);
    border-radius: var(--radius-md);
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.8), rgba(20, 30, 55, 0.6));
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    margin: 4px;
    font-family: var(--font-body);
    letter-spacing: 0.5px;
}

.modal-btn:hover {
    border-color: rgba(0, 229, 255, 0.3);
    background: rgba(0, 229, 255, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.modal-btn.primary {
    border-color: rgba(0, 255, 136, 0.3);
    color: var(--accent-green);
    font-weight: 700;
    background: linear-gradient(145deg, rgba(0, 255, 136, 0.08), rgba(0, 255, 136, 0.03));
}
.modal-btn.primary:hover {
    background: rgba(0, 255, 136, 0.15);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.15), 0 6px 24px rgba(0, 0, 0, 0.3);
}

/* Math Modal */
.math-modal { text-align: center; }
.math-modal .modal-header { margin-bottom: 20px; }
.math-modal .modal-header h2 { color: var(--accent-gold); font-family: var(--font-game); font-size: 22px; }

.combo-badge {
    display: inline-block;
    padding: 4px 14px;
    font-family: var(--font-display);
    font-size: 12px;
    border-radius: 20px;
    margin-top: 8px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 140, 0, 0.15));
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: var(--accent-gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    animation: comboBadgePulse 1.5s ease-in-out infinite;
}

@keyframes comboBadgePulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 215, 0, 0.2); }
    50% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.4); }
}

.math-question {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 24px;
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.4), rgba(10, 15, 30, 0.5));
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    border: 1px solid rgba(100, 200, 255, 0.08);
    box-shadow: inset 0 0 40px rgba(0, 229, 255, 0.02);
}

.math-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.math-option {
    padding: 16px;
    border: 2px solid rgba(100, 200, 255, 0.1);
    border-radius: var(--radius-md);
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.7), rgba(20, 30, 55, 0.5));
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-family: var(--font-body);
    position: relative;
    overflow: hidden;
}

.math-option::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.1), rgba(255, 0, 229, 0.1));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.math-option:hover::before { opacity: 1; }
.math-option:hover { border-color: var(--accent-cyan); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 15px rgba(0, 229, 255, 0.1); }
.math-option.correct { border-color: var(--accent-green); background: rgba(0, 255, 136, 0.12); color: var(--accent-green); box-shadow: 0 0 25px rgba(0, 255, 136, 0.2), inset 0 0 20px rgba(0, 255, 136, 0.05); }
.math-option.incorrect { border-color: var(--accent-red); background: rgba(255, 51, 102, 0.12); color: var(--accent-red); box-shadow: 0 0 20px rgba(255, 51, 102, 0.15); }
.math-option.faded { opacity: 0.25; }
.math-option:disabled { cursor: not-allowed; }

.math-result {
    font-size: 16px;
    font-weight: 700;
    padding: 8px;
    min-height: 30px;
}

/* Game Over Modal */
.gameover-modal { text-align: center; }
.gameover-icon { font-size: 64px; margin-bottom: 8px; animation: float 2s ease-in-out infinite; }
.gameover-title { font-family: var(--font-game); font-size: 28px; color: var(--accent-red); margin-bottom: 20px; text-shadow: 0 0 30px rgba(255,51,102,0.4); }

.gameover-stats {
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.4), rgba(10, 15, 30, 0.5));
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 51, 102, 0.1);
    box-shadow: inset 0 0 30px rgba(255, 51, 102, 0.02);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--text-secondary); }
.stat-value { color: var(--accent-gold); font-family: var(--font-display); font-weight: 700; }

.name-input {
    width: 100%;
    padding: 14px 18px;
    border: 1.5px solid rgba(100, 200, 255, 0.1);
    border-radius: var(--radius-md);
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.4), rgba(10, 15, 30, 0.5));
    color: var(--text-primary);
    font-size: 16px;
    text-align: center;
    margin-bottom: 20px;
    outline: none;
    font-family: var(--font-body);
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

.name-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.12), inset 0 0 20px rgba(0, 229, 255, 0.03);
}

.name-input::placeholder {
    color: var(--text-dim);
    letter-spacing: 0;
}

.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* Ranking Modal */
.ranking-modal { text-align: center; }

.hall-of-fame-container {
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.4), rgba(20, 15, 5, 0.3));
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: inset 0 0 40px rgba(255, 215, 0, 0.02);
    position: relative;
    overflow: hidden;
}

.hall-of-fame-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg at 50% 50%, transparent, rgba(255, 215, 0, 0.03), transparent, rgba(255, 215, 0, 0.02), transparent);
    animation: hofShine 8s linear infinite;
    pointer-events: none;
}

@keyframes hofShine {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.hof-title { color: var(--accent-gold); font-family: var(--font-game); margin-bottom: 12px; font-size: 16px; }

.hall-of-fame { text-align: left; }
.fame-entry { padding: 6px 0; font-size: 14px; color: var(--text-secondary); border-bottom: 1px solid rgba(255,255,255,0.03); }

.ranking-tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; }

.tab-btn {
    padding: 8px 20px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    font-family: var(--font-body);
}

.tab-btn.active { border-color: var(--accent-cyan); color: var(--accent-cyan); background: rgba(0,229,255,0.1); }

.ranking-timer { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; font-family: var(--font-display); }

.ranking-content { display: none; }
.ranking-content.active { display: block; }

.ranking-list {
    list-style: none;
    text-align: left;
    max-height: 250px;
    overflow-y: auto;
}

.ranking-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 13px;
    color: var(--text-secondary);
}

/* Achievement Modal */
.achievement-modal { text-align: center; }

.achievement-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
}

.achievement-item {
    padding: 14px;
    border: 1px solid rgba(100, 200, 255, 0.06);
    border-radius: var(--radius-md);
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.3), rgba(10, 15, 30, 0.4));
    transition: all 0.3s ease;
}

.achievement-item.unlocked {
    border-color: rgba(255, 215, 0, 0.25);
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.06), rgba(255, 215, 0, 0.02));
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.05);
}

.achievement-item.locked { opacity: 0.35; filter: grayscale(0.5); }

.achievement-icon { font-size: 24px; margin-bottom: 4px; }
.achievement-name { font-size: 13px; font-weight: 700; color: var(--accent-gold); }
.achievement-desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* Settings Modal */
.settings-modal { text-align: center; max-width: 380px; }

.settings-group { margin-bottom: 24px; }

.setting-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 14px;
}

.volume-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    background: linear-gradient(90deg, rgba(0, 229, 255, 0.2), rgba(255, 0, 229, 0.2));
    border-radius: 3px;
    outline: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-cyan), #0099cc);
    cursor: pointer;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.7), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.volume-value { font-family: var(--font-display); font-size: 12px; color: var(--text-dim); min-width: 36px; text-align: right; }

/* === Wave Announce === */
.wave-announce {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 150;
    text-align: center;
    pointer-events: none;
    animation: waveAnnounce 2s ease-out forwards;
}

.wave-announce.hidden { display: none; }

.wave-number {
    font-family: var(--font-display);
    font-size: 48px;
    font-weight: 900;
    color: var(--accent-gold);
    text-shadow: 0 0 40px rgba(255,215,0,0.5), 0 2px 4px rgba(0,0,0,0.5);
    letter-spacing: 4px;
}

.wave-enemies {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 8px;
}

@keyframes waveAnnounce {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    30% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(0.9); }
}

/* === Achievement Toast === */
#achievement-toast-container {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 400;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.achievement-toast {
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(255,215,0,0.15), rgba(17,24,39,0.95));
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: var(--radius-lg);
    color: var(--accent-gold);
    font-size: 14px;
    font-weight: 700;
    animation: toastEntry 0.4s ease-out, toastExit 0.4s ease-in 2.6s forwards;
    box-shadow: 0 4px 20px rgba(255,215,0,0.2);
    white-space: nowrap;
}

@keyframes toastEntry {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastExit {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* === Message Popup === */
.message-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 14px 28px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
    z-index: 600;
    animation: msgPop 0.3s ease-out, toastExit 0.4s ease-in 2.6s forwards;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

@keyframes msgPop {
    from { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.upgrade-notification {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: linear-gradient(135deg, rgba(0,255,136,0.15), rgba(17,24,39,0.95));
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0,255,136,0.3);
    border-radius: var(--radius-lg);
    color: var(--accent-green);
    font-size: 14px;
    font-weight: 700;
    z-index: 600;
    animation: toastEntry 0.4s ease-out, toastExit 0.4s ease-in 2.6s forwards;
    box-shadow: 0 4px 20px rgba(0,255,136,0.2);
}

/* === Screen Shake === */
@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5px, -3px); }
    20% { transform: translate(5px, 3px); }
    30% { transform: translate(-3px, 5px); }
    40% { transform: translate(3px, -5px); }
    50% { transform: translate(-5px, 3px); }
    60% { transform: translate(5px, -3px); }
    70% { transform: translate(-3px, -5px); }
    80% { transform: translate(3px, 5px); }
    90% { transform: translate(-5px, -3px); }
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, rgba(0, 229, 255, 0.3), rgba(255, 0, 229, 0.3)); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, rgba(0, 229, 255, 0.5), rgba(255, 0, 229, 0.5)); }

/* === Selection === */
::selection {
    background: rgba(0, 229, 255, 0.2);
    color: var(--accent-cyan);
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
    .main-title { font-size: 36px; }
    .logo-castle { font-size: 64px; }
    .difficulty-btn { width: 74px; height: 78px; }
    .diff-grade { font-size: 26px; }
    .menu-container { padding: 36px 28px; }
    .info-item { padding: 3px 6px; font-size: 12px; }
    .info-value { font-size: 12px; }
    .math-question { font-size: 20px; padding: 18px; }
    .math-option { padding: 14px; font-size: 16px; }
    .wave-number { font-size: 36px; }
    .combo-count { font-size: 36px; }
    .modal-content { padding: 28px; }
}

@media (max-width: 480px) {
    .main-title { font-size: 28px; }
    .logo-castle { font-size: 56px; }
    .menu-container { padding: 28px 20px; }
    .menu-actions { flex-direction: column; align-items: center; }
    .menu-btn { width: 100%; justify-content: center; }
    .difficulty-btn { width: 66px; height: 72px; }
    .diff-grade { font-size: 24px; }
}
