.clash-overlay {
    position: fixed;
    inset: 0;
    background: #111;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: white;
    user-select: none;
    overflow: hidden;
    touch-action: none;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.clash-overlay.rotated {
    transform: rotate(-90deg);
    transform-origin: center center;
    width: 100vh;
    height: 100vw;
    left: calc((100vw - 100vh) / 2);
    top: calc((100vh - 100vw) / 2);
}

.clash-header {
    height: 40px;
    min-height: 40px;
    background: linear-gradient(to bottom, #4a4a4a, #2a2a2a);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    font-size: 16px;
    border-bottom: 2px solid #222;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    z-index: 10;
}
.clash-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.clash-rotate-btn {
    background: linear-gradient(to bottom, #555, #333);
    color: white;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}
.clash-rotate-btn:active { background: #444; }

.clash-timer {
    font-size: 24px;
    font-weight: bold;
    color: #f1c40f;
    text-shadow: 1px 1px 2px #000;
}
.clash-timer.overtime {
    color: #e74c3c;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

.clash-close-btn {
    background: linear-gradient(to bottom, #e74c3c, #c0392b);
    color: white;
    border: 1px solid #7f8c8d;
    border-radius: 5px;
    padding: 5px 15px;
    cursor: pointer;
    font-weight: bold;
    text-shadow: 1px 1px 1px #000;
}
.clash-close-btn:active {
    background: #c0392b;
}

/* === SETTINGS GEAR + OVERLAY === */
.clash-settings-btn {
    background: linear-gradient(to bottom, #555, #333);
    color: #ccc;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: color 0.15s;
}
.clash-settings-btn:active { background: #444; color: #f1c40f; }

.clash-settings-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.75);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.clash-settings-panel {
    background: linear-gradient(135deg, #2c3e50, #1a252f);
    border: 2px solid #f1c40f;
    border-radius: 14px;
    padding: 24px 28px;
    width: 280px;
    max-width: 85vw;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.08);
}

.clash-settings-title {
    text-align: center;
    color: #f1c40f;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 3px;
    margin: 0 0 18px 0;
    text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.clash-settings-group {
    margin-bottom: 14px;
}

.clash-settings-label {
    display: block;
    color: #bdc3c7;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.clash-settings-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #444;
    outline: none;
}
.clash-settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(to bottom, #f1c40f, #d4ac0d);
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.clash-settings-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(to bottom, #f1c40f, #d4ac0d);
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.clash-settings-speed-row {
    display: flex;
    gap: 8px;
}
.clash-settings-speed-opt {
    flex: 1;
    padding: 8px;
    border: 2px solid #555;
    border-radius: 8px;
    background: #333;
    color: #aaa;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}
.clash-settings-speed-opt.active {
    border-color: #f1c40f;
    color: #f1c40f;
    background: rgba(241,196,15,0.12);
}
.clash-settings-speed-opt:active { background: #444; }

.clash-settings-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.clash-settings-resume {
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(to bottom, #27ae60, #1e8449);
    color: white;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 1px;
    cursor: pointer;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
    box-shadow: 0 3px 10px rgba(39,174,96,0.3);
}
.clash-settings-resume:active { background: #1e8449; }

.clash-settings-exit {
    padding: 10px;
    border: 2px solid #e74c3c;
    border-radius: 8px;
    background: transparent;
    color: #e74c3c;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}
.clash-settings-exit:active {
    background: rgba(231,76,60,0.15);
}

.clash-board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #1a1a1a;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.clash-board {
    position: relative;
    width: 360px;
    height: 640px;
    background-image: url('../assets/tiles/grass_1.png');
    background-size: 64px 64px;
    image-rendering: pixelated;
    border: 4px solid #3e6b22;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8), inset 0 0 40px rgba(0,0,0,0.3);
    transform-origin: center center;
    overflow: hidden;
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.clash-board.shake {
    animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
.clash-board::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.1);
    pointer-events: none;
}

.clash-path {
    position: absolute;
    width: 60px;
    height: 100%;
    background: rgba(139, 69, 19, 0.4);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
    pointer-events: none;
    z-index: 1;
}
.clash-path.left { left: 40px; }
.clash-path.right { right: 40px; }
.clash-path::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0; left: 0; right: 0;
    border-left: 2px dashed rgba(0,0,0,0.2);
    border-right: 2px dashed rgba(0,0,0,0.2);
}

.clash-river {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 44px;
    background-image: url('../assets/tiles/water_1.png?v=2');
    background-size: 64px 64px;
    image-rendering: pixelated;
    transform: translateY(-50%);
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.4), inset 0 -2px 5px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
}
/* River flow */
.clash-river::after {
    content: '';
    width: 100%;
    height: 100%;
    background-image: url('../assets/tiles/water_2.png?v=2');
    background-size: 64px 64px;
    opacity: 0.5;
    animation: flow 4s linear infinite;
    image-rendering: pixelated;
}
@keyframes flow {
    from { background-position: 0 0; }
    to { background-position: -128px 0; }
}

.clash-bridge {
    position: absolute;
    top: 50%;
    width: 60px;
    height: 50px;
    background-image: url('../assets/tiles/bridge.png?v=2');
    background-size: 100% 100%;
    image-rendering: pixelated;
    transform: translateY(-50%);
    box-shadow: 0 5px 10px rgba(0,0,0,0.4);
    z-index: 5;
}
.clash-bridge.left { left: 40px; }
.clash-bridge.right { right: 40px; }

.clash-tower {
    position: absolute;
    width: 64px;
    height: 72px;
    background-image: url('../assets/sprites/tower_princess_blue.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translate(-50%, -50%);
    z-index: 10;
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.5));
}

.clash-tower.enemy {
    background-image: url('../assets/sprites/tower_princess_red.png');
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.5));
}

.clash-tower-hero {
    display: none;
}

.clash-tower.king {
    width: 80px;
    height: 100px;
    background-image: url('../assets/sprites/tower_king_blue.png');
}
.clash-tower.king.enemy {
    background-image: url('../assets/sprites/tower_king_red.png');
}

@keyframes towerHit {
    0% { transform: translate(-50%, -50%) rotate(0) scale(1); filter: brightness(2) drop-shadow(0 10px 10px rgba(0,0,0,0.5)); }
    25% { transform: translate(-52%, -50%) rotate(-2deg) scale(1.02); filter: brightness(1.5) drop-shadow(0 10px 10px rgba(0,0,0,0.5)); }
    50% { transform: translate(-48%, -50%) rotate(2deg) scale(0.98); filter: brightness(1) drop-shadow(0 10px 10px rgba(0,0,0,0.5)); }
    75% { transform: translate(-51%, -50%) rotate(-1deg) scale(1.01); }
    100% { transform: translate(-50%, -50%) rotate(0) scale(1); filter: drop-shadow(0 10px 10px rgba(0,0,0,0.5)); }
}
.clash-tower.hit {
    animation: towerHit 0.3s ease-out;
}

.clash-tower-hp-container {
    position: absolute;
    bottom: -22px;
    width: 44px;
    height: 8px;
    background: #333;
    border: 1px solid black;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    z-index: 15;
}
.clash-tower.player.king .clash-tower-hp-container {
    bottom: auto;
    top: -22px;
}

.clash-tower-hp-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #2ecc71;
    transition: width 0.1s;
    z-index: 1;
}
.clash-tower.enemy .clash-tower-hp-fill {
    background: #e74c3c;
}

.clash-tower-hp-text {
    position: relative;
    z-index: 2;
    color: white;
    font-size: 8px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

.clash-unit {
    position: absolute;
    left: -12px;
    top: -12px;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    z-index: 15;
    will-change: transform;
}

.clash-unit::after {
    content: '';
    position: absolute;
    bottom: -6px;
    width: 20px;
    height: 10px;
    background: rgba(0,0,0,0.4);
    border-radius: 50%;
    z-index: -1;
    pointer-events: none;
    filter: blur(1px);
}
.clash-unit.ogre::after, .clash-unit.demonlord::after { width: 36px; height: 16px; bottom: -8px; }
.clash-unit.flying::after { transform: translateY(20px) scale(0.8); opacity: 0.5; }

.clash-unit-icon {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    image-rendering: pixelated;
    transition: transform 0.1s;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
    animation: unitBob 0.6s infinite ease-in-out;
}

@keyframes unitBob {
    0% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
    100% { transform: translateY(0); }
}
@keyframes unitBobFlipped {
    0% { transform: scaleX(-1) translateY(0); }
    50% { transform: scaleX(-1) translateY(-2px); }
    100% { transform: scaleX(-1) translateY(0); }
}
.clash-unit-icon.face-left {
    animation: unitBobFlipped 0.6s infinite ease-in-out;
}

@keyframes unitHit {
    0% { filter: brightness(3); transform: scale(1.1); }
    100% { filter: brightness(1); transform: scale(1); }
}
.clash-unit.hit .clash-unit-icon {
    animation: unitHit 0.2s ease-out;
}
.clash-unit.enemy .clash-unit-icon {
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
}
.clash-unit.player .clash-unit-icon {
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
}

/* Base unit size adjustments */
.clash-unit.demonlord .clash-unit-icon { width: 68px; height: 68px; margin-top: -22px; margin-left: -22px; image-rendering: auto; background-size: contain; }

/* Animated giant (ogre) */
.clash-unit.ogre .clash-unit-icon {
    width: 64px; height: 64px; margin-top: -20px; margin-left: -20px;
    background-size: 400% 100%;
    animation: spriteWalk 0.6s steps(3) infinite;
}
.clash-unit.ogre.winding-up .clash-unit-icon,
.clash-unit.ogre.attacking .clash-unit-icon {
    animation: spriteAttack 0.5s steps(3) infinite;
}

.clash-unit.ogre .clash-unit-icon.face-left {
    transform: scaleX(-1);
    animation: spriteWalk 0.6s steps(3) infinite;
}
.clash-unit.ogre.winding-up .clash-unit-icon.face-left,
.clash-unit.ogre.attacking .clash-unit-icon.face-left {
    animation: spriteAttack 0.5s steps(3) infinite;
}
.clash-unit.mega_giant .clash-unit-icon.face-left {
    transform: scaleX(-1);
    animation: spriteWalk 0.8s steps(3) infinite;
}
.clash-unit.mega_giant.winding-up .clash-unit-icon.face-left,
.clash-unit.mega_giant.attacking .clash-unit-icon.face-left {
    animation: spriteAttack 0.6s steps(3) infinite;
    filter: drop-shadow(0 0 12px rgba(255,50,0,0.9)) drop-shadow(0 4px 6px rgba(0,0,0,0.6));
}

@keyframes spriteWalk {
    from { background-position: 0% 0%; }
    to { background-position: 100% 0%; }
}
@keyframes spriteAttack {
    from { background-position: 0% 0%; }
    to { background-position: 100% 0%; }
}
.clash-unit.mega_pekka .clash-unit-icon { width: 96px; height: 96px; margin-top: -36px; margin-left: -36px; filter: drop-shadow(0 0 8px rgba(180,0,255,0.8)) drop-shadow(0 4px 6px rgba(0,0,0,0.6)); }
.clash-unit.boss_golem_king .clash-unit-icon { width: 110px; height: 110px; margin-top: -43px; margin-left: -43px; image-rendering: auto; filter: drop-shadow(0 0 10px rgba(255,160,0,0.7)) drop-shadow(0 4px 8px rgba(0,0,0,0.6)); }
.clash-unit.boss_golem_king::after { width: 50px; height: 20px; bottom: -10px; }
.clash-unit.boss_dragon_lord .clash-unit-icon { width: 120px; height: 110px; margin-top: -43px; margin-left: -48px; image-rendering: auto; filter: drop-shadow(0 0 12px rgba(255,60,0,0.8)) drop-shadow(0 4px 8px rgba(0,0,0,0.6)); }
.clash-unit.boss_dragon_lord::after { width: 50px; height: 18px; bottom: -10px; transform: translateY(24px) scale(0.7); opacity: 0.4; }
.clash-unit.boss_skeleton_king .clash-unit-icon { width: 100px; height: 100px; margin-top: -38px; margin-left: -38px; image-rendering: auto; filter: drop-shadow(0 0 10px rgba(0,255,160,0.6)) drop-shadow(0 4px 8px rgba(0,0,0,0.6)); }
.clash-unit.boss_skeleton_king::after { width: 44px; height: 18px; bottom: -9px; }
.clash-unit.boss_lightning_mage .clash-unit-icon { width: 90px; height: 90px; margin-top: -33px; margin-left: -33px; image-rendering: auto; filter: drop-shadow(0 0 8px rgba(80,160,255,0.7)) drop-shadow(0 4px 6px rgba(0,0,0,0.6)); }
.clash-unit.boss_lightning_mage::after { width: 40px; height: 16px; bottom: -8px; }
.clash-unit.boss_shadow_assassin .clash-unit-icon { width: 88px; height: 88px; margin-top: -32px; margin-left: -32px; image-rendering: auto; filter: drop-shadow(0 0 10px rgba(120,0,200,0.7)) drop-shadow(0 4px 6px rgba(0,0,0,0.6)); }
.clash-unit.boss_shadow_assassin::after { width: 36px; height: 14px; bottom: -7px; opacity: 0.3; }
.clash-unit.boss_siege_engine .clash-unit-icon { width: 100px; height: 90px; margin-top: -33px; margin-left: -38px; image-rendering: auto; filter: drop-shadow(0 0 8px rgba(255,80,0,0.6)) drop-shadow(0 4px 8px rgba(0,0,0,0.6)); }
.clash-unit.boss_siege_engine::after { width: 48px; height: 18px; bottom: -9px; }
.clash-unit.mega_giant .clash-unit-icon {
    width: 100px; height: 100px; margin-top: -38px; margin-left: -38px;
    filter: drop-shadow(0 0 8px rgba(255,120,0,0.8)) drop-shadow(0 4px 6px rgba(0,0,0,0.6));
    background-size: 400% 100%;
    animation: spriteWalk 0.8s steps(3) infinite;
}
.clash-unit.mega_giant.winding-up .clash-unit-icon,
.clash-unit.mega_giant.attacking .clash-unit-icon {
    animation: spriteAttack 0.6s steps(3) infinite;
    filter: drop-shadow(0 0 12px rgba(255,50,0,0.9)) drop-shadow(0 4px 6px rgba(0,0,0,0.6));
}
.clash-unit.skeleton .clash-unit-icon, .clash-unit.goblin .clash-unit-icon, .clash-unit.paladin .clash-unit-icon {
    width: 40px; height: 40px; margin-top: -8px; margin-left: -8px;
}
.clash-unit.wizard .clash-unit-icon {
    width: 44px; height: 44px; margin-top: -10px; margin-left: -10px;
    image-rendering: auto; background-size: contain;
}
.clash-unit.rogue .clash-unit-icon {
    width: 44px; height: 44px; margin-top: -10px; margin-left: -10px;
    image-rendering: auto; background-size: contain;
}
.clash-unit.imp .clash-unit-icon {
    width: 42px; height: 42px; margin-top: -9px; margin-left: -9px;
    image-rendering: auto; background-size: contain;
}
.clash-unit.ice_wizard .clash-unit-icon, .clash-unit.bomber .clash-unit-icon {
    width: 40px; height: 40px; margin-top: -8px; margin-left: -8px;
}
.clash-unit.musketeer .clash-unit-icon {
    width: 42px; height: 42px; margin-top: -9px; margin-left: -9px; image-rendering: auto;
}
.clash-unit.witch_unit .clash-unit-icon {
    width: 44px; height: 44px; margin-top: -10px; margin-left: -10px; image-rendering: auto;
}
.clash-unit.lumberjack .clash-unit-icon {
    width: 42px; height: 42px; margin-top: -9px; margin-left: -9px; image-rendering: auto;
}
.clash-unit.hogrider .clash-unit-icon {
    width: 46px; height: 46px; margin-top: -11px; margin-left: -11px; image-rendering: auto;
}
.clash-unit.cannon_building .clash-unit-icon {
    width: 40px; height: 40px; margin-top: -4px; margin-left: -4px;
}
.clash-unit.inferno_tower .clash-unit-icon {
    width: 46px; height: 50px; margin-top: -10px; margin-left: -9px; image-rendering: auto;
}
.clash-unit.tombstone_building .clash-unit-icon {
    width: 36px; height: 36px; margin-top: -2px; margin-left: -2px;
}

/* Animated knight */
.clash-unit.knight .clash-unit-icon {
    width: 40px; height: 40px; margin-top: -8px; margin-left: -8px;
    background-size: 400% 100%;
    animation: spriteWalk 0.5s steps(3) infinite;
}
.clash-unit.knight.winding-up .clash-unit-icon,
.clash-unit.knight.attacking .clash-unit-icon {
    animation: spriteAttack 0.45s steps(3) infinite;
}
.clash-unit.knight .clash-unit-icon.face-left {
    transform: scaleX(-1);
    animation: spriteWalk 0.5s steps(3) infinite;
}
.clash-unit.knight.winding-up .clash-unit-icon.face-left,
.clash-unit.knight.attacking .clash-unit-icon.face-left {
    animation: spriteAttack 0.45s steps(3) infinite;
}

/* Animated archer */
.clash-unit.archer .clash-unit-icon {
    width: 40px; height: 40px; margin-top: -8px; margin-left: -8px;
    background-size: 400% 100%;
    animation: spriteWalk 0.5s steps(3) infinite;
}
.clash-unit.archer.winding-up .clash-unit-icon,
.clash-unit.archer.attacking .clash-unit-icon {
    animation: spriteAttack 0.45s steps(3) infinite;
}
.clash-unit.archer .clash-unit-icon.face-left {
    transform: scaleX(-1);
    animation: spriteWalk 0.5s steps(3) infinite;
}
.clash-unit.archer.winding-up .clash-unit-icon.face-left,
.clash-unit.archer.attacking .clash-unit-icon.face-left {
    animation: spriteAttack 0.45s steps(3) infinite;
}
.clash-unit.dragon .clash-unit-icon { width: 52px; height: 52px; margin-top: -14px; margin-left: -14px; image-rendering: auto; background-size: contain; }
.clash-unit.bat .clash-unit-icon { width: 44px; height: 28px; margin-top: -4px; margin-left: -10px; background-size: 120% auto; background-position: center 25%; }

/* New units */
.clash-unit.prince .clash-unit-icon { width: 48px; height: 48px; margin-top: -12px; margin-left: -12px; image-rendering: auto; }
.clash-unit.prince::after { width: 32px; height: 14px; bottom: -7px; }
.clash-unit.electro_wizard .clash-unit-icon { width: 40px; height: 40px; margin-top: -8px; margin-left: -8px; image-rendering: auto; }
.clash-unit.balloon_unit .clash-unit-icon { width: 52px; height: 52px; margin-top: -14px; margin-left: -14px; image-rendering: auto; }
.clash-unit.balloon_unit::after { transform: translateY(24px) scale(0.7); opacity: 0.4; }
.clash-unit.mega_minion .clash-unit-icon { width: 44px; height: 44px; margin-top: -10px; margin-left: -10px; image-rendering: auto; }
.clash-unit.mega_minion::after { transform: translateY(20px) scale(0.8); opacity: 0.5; }
.clash-unit.princess .clash-unit-icon { width: 36px; height: 40px; margin-top: -8px; margin-left: -6px; image-rendering: auto; }
.clash-unit.royal_giant .clash-unit-icon { width: 60px; height: 60px; margin-top: -18px; margin-left: -18px; image-rendering: auto; }
.clash-unit.royal_giant::after { width: 36px; height: 16px; bottom: -8px; }
.clash-unit.tesla_building .clash-unit-icon { width: 44px; height: 44px; margin-top: -6px; margin-left: -6px; image-rendering: auto; }
.clash-unit.sparky .clash-unit-icon { width: 52px; height: 52px; margin-top: -14px; margin-left: -14px; image-rendering: auto; }
.clash-unit.sparky::after { width: 36px; height: 14px; bottom: -7px; }
.clash-unit.dark_prince .clash-unit-icon { width: 48px; height: 48px; margin-top: -12px; margin-left: -12px; image-rendering: auto; }
.clash-unit.dark_prince::after { width: 32px; height: 14px; bottom: -7px; }
.clash-unit.bandit .clash-unit-icon { width: 40px; height: 40px; margin-top: -8px; margin-left: -8px; image-rendering: auto; }
.clash-unit.inferno_dragon .clash-unit-icon { width: 52px; height: 48px; margin-top: -12px; margin-left: -14px; image-rendering: auto; }
.clash-unit.inferno_dragon::after { transform: translateY(20px) scale(0.8); opacity: 0.5; }
.clash-unit.executioner .clash-unit-icon { width: 48px; height: 48px; margin-top: -12px; margin-left: -12px; image-rendering: auto; }
.clash-unit.night_witch .clash-unit-icon { width: 44px; height: 44px; margin-top: -10px; margin-left: -10px; image-rendering: auto; }

/* Deploying animation */
.clash-unit.deploying {
    opacity: 0.8;
}

.clash-deploy-timer {
    position: absolute;
    top: -24px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: conic-gradient(rgba(255,255,255,0.9) var(--progress, 0%), rgba(0,0,0,0.6) 0);
    border: 2px solid #222;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.clash-unit.player { /* no borders */ }
.clash-unit.enemy { /* no borders */ }

.clash-unit.ogre { width: 34px; height: 34px; font-size: 20px; }
.clash-unit.demonlord { width: 34px; height: 34px; font-size: 20px; }

.clash-unit.building-unit {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 22px;
}

.clash-unit-hp-bar {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 5px;
    background: #333;
    border: 1px solid black;
    border-radius: 2px;
    overflow: hidden;
}
.clash-unit-hp-fill {
    height: 100%;
    background: #2ecc71;
}
.clash-unit.enemy .clash-unit-hp-fill { background: #e74c3c; }

/* Level indicator */
.clash-unit-level {
    position: absolute;
    bottom: -8px;
    right: -8px;
    background: #f1c40f;
    color: black;
    font-size: 9px;
    font-weight: bold;
    width: 14px;
    height: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    border: 1px solid #000;
}

.clash-unit.flying {
    z-index: 25;
}

.clash-unit.jumping {
    transform: translate(-50%, -50%) scale(1.3) translateY(-10px);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 30;
}

.clash-unit-icon {
    font-size: inherit;
}

@keyframes unitAttack {
    0% { transform: scale(1) translateX(0); }
    25% { transform: scale(1.15) translateX(3px); }
    50% { transform: scale(1.2) translateX(6px); }
    100% { transform: scale(1) translateX(0); }
}
@keyframes unitAttackFlipped {
    0% { transform: scaleX(-1) scale(1) translateX(0); }
    25% { transform: scaleX(-1) scale(1.15) translateX(3px); }
    50% { transform: scaleX(-1) scale(1.2) translateX(6px); }
    100% { transform: scaleX(-1) scale(1) translateX(0); }
}

.clash-unit.winding-up .clash-unit-icon {
    animation: unitAttack 0.45s ease-out forwards;
}
.clash-unit.winding-up .clash-unit-icon.face-left {
    animation: unitAttackFlipped 0.45s ease-out forwards;
}
.clash-unit.attacking .clash-unit-icon {
    animation: unitAttack 0.45s ease-out forwards;
}
.clash-unit.attacking .clash-unit-icon.face-left {
    animation: unitAttackFlipped 0.45s ease-out forwards;
}

@keyframes deathShake {
    0% { transform: translate(-50%, -50%) scale(1); filter: brightness(3); }
    20% { transform: translate(-55%, -45%) scale(1.05); }
    40% { transform: translate(-45%, -55%) scale(0.95); }
    60% { transform: translate(-55%, -55%) scale(1.1); }
    80% { transform: translate(-45%, -45%) scale(0.9); }
    100% { transform: translate(-50%, -50%) scale(1); filter: drop-shadow(0 5px 5px rgba(0,0,0,0.5)); }
}

.clash-tower.destroyed {
    background-image: url('../assets/sprites/tower_destroyed.png') !important;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: none !important;
    font-size: 24px;
    filter: drop-shadow(0 5px 5px rgba(0,0,0,0.5));
    animation: deathShake 0.5s ease-out;
}
.clash-tower.king.destroyed {
    background-image: url('../assets/sprites/tower_destroyed_2.png') !important;
}
.clash-tower.destroyed .clash-tower-hero {
    display: none;
}
.clash-tower.destroyed::after, .clash-tower.destroyed::before { 
    display: none !important; 
}
.clash-tower.destroyed .clash-tower-hp {
    display: none;
}

.clash-damage-text {
    position: absolute;
    color: #ff3333;
    font-weight: bold;
    font-size: 16px;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
    pointer-events: none;
    z-index: 100;
    animation: floatUp 0.8s ease-out forwards;
}

@keyframes floatUp {
    0% { transform: translate(-50%, 0) scale(1); opacity: 1; }
    50% { transform: translate(-50%, -20px) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -40px) scale(1); opacity: 0; }
}

.clash-projectile {
    position: absolute;
    left: -12px;
    top: -12px;
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    border-radius: 0;
    will-change: transform;
    z-index: 20;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.clash-projectile.fireball {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 0 8px #e74c3c);
}
.clash-projectile.fireball::after {
    display: none;
}

.clash-projectile.dragon-fire {
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, #f1c40f, #e67e22);
    filter: drop-shadow(0 0 5px #e67e22);
    border-radius: 50%;
}

.clash-projectile.knives {
    width: 40px;
    height: 40px;
}

.clash-projectile.barrel {
    width: 30px;
    height: 30px;
    animation: spin 0.5s linear infinite;
}

.clash-projectile.lightning {
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 0 10px #5dade2);
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.clash-stat-popup {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    font-weight: bold;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
    animation: floatUpFade 2s forwards;
}

@keyframes floatUpFade {
    0% { transform: translate(-50%, 0); opacity: 1; }
    100% { transform: translate(-50%, -30px); opacity: 0; }
}

.clash-bottom-area {
    min-height: 140px;
    background: linear-gradient(to bottom, #2c3e50, #1a252f);
    display: flex;
    flex-direction: column;
    padding: 6px 5px 8px 5px;
    box-sizing: border-box;
    border-top: 3px solid #f1c40f;
}

/* === ENEMY ELIXIR BAR === */
.clash-enemy-elixir-wrapper {
    position: absolute;
    top: 42px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 11;
    display: flex;
    align-items: center;
    gap: 6px;
    width: 55%;
    max-width: 260px;
}
.clash-enemy-elixir-label {
    font-size: 9px;
    font-weight: bold;
    color: #e74c3c;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 1px 1px 2px #000;
    white-space: nowrap;
    flex-shrink: 0;
}
.clash-enemy-elixir-bar {
    position: relative;
    flex: 1;
    height: 14px;
    background: #111;
    border: 1.5px solid #922;
    border-radius: 7px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.8), 0 1px 3px rgba(0,0,0,0.5);
}
.clash-enemy-elixir-fill {
    height: 100%;
    background: linear-gradient(to bottom, #ff6b6b, #c0392b);
    width: 0%;
    transition: none;
    border-right: 1.5px solid rgba(255,255,255,0.6);
    position: relative;
    box-shadow: 0 0 6px rgba(231,76,60,0.6);
}
.clash-enemy-elixir-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: linear-gradient(
        -45deg,
        rgba(255, 255, 255, 0.15) 25%,
        transparent 25%,
        transparent 50%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.15) 75%,
        transparent 75%,
        transparent
    );
    background-size: 14px 14px;
    animation: moveStripes 1s linear infinite;
}
.clash-enemy-elixir-text {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    font-size: 10px;
    text-shadow: 1px 1px 2px #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}
.clash-enemy-elixir-bar.full {
    animation: enemyElixirPulse 0.8s ease-in-out infinite;
    border-color: #ff4444;
}
.clash-enemy-elixir-bar.full .clash-enemy-elixir-text {
    animation: pulse 0.8s ease-in-out infinite;
    color: #ff4444;
}
@keyframes enemyElixirPulse {
    0% { box-shadow: inset 0 1px 3px rgba(0,0,0,0.8), 0 0 3px #e74c3c; }
    50% { box-shadow: inset 0 1px 3px rgba(0,0,0,0.8), 0 0 8px #ff4444, 0 0 16px rgba(231,76,60,0.4); }
    100% { box-shadow: inset 0 1px 3px rgba(0,0,0,0.8), 0 0 3px #e74c3c; }
}

/* === PLAYER ELIXIR BAR === */
.clash-elixir-bar {
    position: relative;
    width: 90%;
    max-width: 400px;
    height: 20px;
    background: #111;
    border: 2px solid #6c3483;
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto 6px auto;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.8), 0 2px 5px rgba(0,0,0,0.5);
}

.clash-elixir-fill {
    height: 100%;
    background: linear-gradient(to bottom, #f39c12, #e74c3c); /* fallback */
    background: linear-gradient(to bottom, #f194ff, #8e44ad);
    width: 0%;
    transition: none;
    border-right: 2px solid rgba(255,255,255,0.8);
    position: relative;
    box-shadow: 0 0 10px #d252ff;
}
.clash-elixir-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: linear-gradient(
        -45deg, 
        rgba(255, 255, 255, 0.2) 25%, 
        transparent 25%, 
        transparent 50%, 
        rgba(255, 255, 255, 0.2) 50%, 
        rgba(255, 255, 255, 0.2) 75%, 
        transparent 75%, 
        transparent
    );
    background-size: 20px 20px;
    animation: moveStripes 1s linear infinite;
}

@keyframes moveStripes {
    0% { background-position: 0 0; }
    100% { background-position: 20px 20px; }
}

.clash-elixir-text {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    font-size: 13px;
    text-shadow: 1px 1px 2px #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

/* Elixir tick marks */
.clash-elixir-ticks {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 10%; /* offset to align with 10 units */
}
.clash-elixir-tick {
    width: 1px;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.clash-controls-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.clash-next-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 44px;
}
.clash-next-label {
    font-size: 9px;
    color: #bdc3c7;
    margin-bottom: 3px;
    font-weight: bold;
}
.clash-next-slot {
    width: 44px;
    height: 56px;
    background: rgba(0,0,0,0.3);
    border: 2px dashed #7f8c8d;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.clash-next-slot .icon {
    font-size: 24px;
    opacity: 0.7;
}

.clash-cards {
    display: flex;
    gap: 6px;
}

.clash-card {
    width: 64px;
    height: 82px;
    background: linear-gradient(to bottom, #d5e8f5, #95a5a6);
    border-radius: 7px;
    border: 2px solid #2980b9;
    color: black;
    display: flex;
    flex-direction: column;
    position: relative;
    cursor: grab;
    box-shadow: 0 4px 10px rgba(0,0,0,0.8), inset 0 2px 4px rgba(255,255,255,0.8);
    overflow: hidden;
    transition: transform 0.1s;
}
.clash-card.disabled {
    filter: grayscale(100%) brightness(0.6);
    cursor: not-allowed;
}
.clash-card:active:not(.disabled) {
    cursor: grabbing;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.9), inset 0 2px 5px rgba(255,255,255,0.8);
}

.clash-card-bg {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, rgba(255,255,255,0.3) 0%, transparent 70%);
}

.clash-card .cost {
    position: absolute;
    top: -4px;
    left: -4px;
    background: #9b59b6;
    background: radial-gradient(circle at 30% 30%, #d252ff, #8e44ad);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid #333;
    z-index: 2;
    text-shadow: 1px 1px 1px #000;
}

.clash-card .icon {
    font-size: 40px;
    z-index: 1;
    margin-top: 10px;
    text-align: center;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.3));
}

.clash-card .name {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: rgba(0,0,0,0.8);
    color: white;
    font-size: 8px;
    font-weight: bold;
    text-align: center;
    padding: 2px 0;
    z-index: 2;
}

.clash-drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    transform: translate(-50%, -50%);
    font-size: 40px;
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.5));
}

.clash-grid-highlight {
    position: absolute;
    pointer-events: none;
    border: 2px solid rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.3);
    z-index: 50;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.clash-range-ring {
    position: absolute;
    border: 2px dashed rgba(255,255,255,0.6);
    border-radius: 50%;
    pointer-events: none;
    background: rgba(255,255,255,0.05);
}

.clash-spell-highlight {
    position: absolute;
    pointer-events: none;
    border: 3px solid rgba(231, 76, 60, 0.8);
    background: rgba(231, 76, 60, 0.2);
    border-radius: 50%;
    z-index: 50;
    transform: translate(-50%, -50%);
}

.clash-spell-effect {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(231,76,60,0.8) 50%, transparent 100%);
    transform: translate(-50%, -50%);
    z-index: 40;
    pointer-events: none;
    animation: explode 0.3s ease-out forwards;
}

@keyframes explode {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

.clash-explosion-particle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #e74c3c;
    border-radius: 50%;
    z-index: 50;
    pointer-events: none;
    animation: particleFly 0.6s ease-out forwards;
    box-shadow: 0 0 10px #f1c40f;
}

@keyframes particleFly {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0); opacity: 0; }
}

.clash-flying-crown {
    position: absolute;
    font-size: 32px;
    z-index: 200;
    pointer-events: none;
    animation: crownFly 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.8));
}

@keyframes crownFly {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    20% { transform: translate(-50%, -100%) scale(1.5); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0.5); opacity: 0; }
}

.clash-crowns {
    position: absolute;
    top: 52px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 10;
}

.clash-crown-score {
    background: rgba(0,0,0,0.7);
    border: 2px solid #f1c40f;
    border-radius: 12px;
    padding: 3px 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 16px;
    font-weight: bold;
    color: white;
}
.clash-crown-score.player { border-color: #3498db; }
.clash-crown-score.enemy { border-color: #e74c3c; }

.clash-end-screen {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.clash-end-title {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 20px;
    text-transform: uppercase;
    text-shadow: 0 4px 10px rgba(0,0,0,0.8);
}
.clash-end-title.victory { color: #f1c40f; }
.clash-end-title.defeat { color: #e74c3c; }
.clash-end-title.tie { color: #bdc3c7; }

.clash-end-crowns {
    display: flex;
    gap: 20px;
    margin-bottom: 40px;
    font-size: 60px;
}
.clash-end-crown {
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.5));
}
.clash-end-crown.empty {
    filter: grayscale(100%) opacity(0.3);
}

.clash-end-btn {
    background: #3498db;
    color: white;
    border: 2px solid #2980b9;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0 #2980b9;
}
.clash-end-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #2980b9;
}

.clash-quiz-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 500;
}

.clash-quiz-box {
    background: #2c3e50;
    border: 4px solid #f1c40f;
    border-radius: 15px;
    padding: 30px;
    width: 400px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.clash-quiz-prompt {
    font-size: 24px;
    margin-bottom: 20px;
    color: white;
}

.clash-quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.clash-quiz-btn {
    background: #34495e;
    color: white;
    border: 2px solid #7f8c8d;
    padding: 12px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
}

.clash-quiz-btn:hover {
    background: #2c3e50;
    border-color: #f1c40f;
}

.clash-quiz-timer-bar {
    height: 10px;
    background: #3498db;
    border-radius: 5px;
    margin-bottom: 20px;
    width: 100%;
    transition: width 0.1s linear;
}

.clash-unit.overleveled {
    filter: drop-shadow(0 0 8px #f1c40f) brightness(1.2);
}

.clash-unit.underleveled {
    filter: grayscale(80%) drop-shadow(0 0 5px #7f8c8d);
}

/* === DEATH ANIMATION === */
@keyframes unitDie {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    30% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; filter: brightness(2); }
    100% { transform: translate(-50%, -60%) scale(0); opacity: 0; }
}
.clash-unit.dying {
    animation: unitDie 0.4s ease-out forwards !important;
    pointer-events: none;
}
.clash-unit.dying .clash-unit-hp-bar,
.clash-unit.dying .clash-unit-level,
.clash-unit.dying .clash-deploy-timer {
    display: none;
}

.clash-death-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    z-index: 50;
    pointer-events: none;
    animation: deathParticleFly 0.5s ease-out forwards;
    box-shadow: 0 0 4px currentColor;
}
@keyframes deathParticleFly {
    0% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0); opacity: 0; }
}

/* === ELIXIR LEAK WARNING === */
@keyframes elixirPulse {
    0% { box-shadow: inset 0 2px 5px rgba(0,0,0,0.8), 0 0 4px #d252ff, 0 0 8px #d252ff; }
    50% { box-shadow: inset 0 2px 5px rgba(0,0,0,0.8), 0 0 12px #ff52ff, 0 0 24px #d252ff; }
    100% { box-shadow: inset 0 2px 5px rgba(0,0,0,0.8), 0 0 4px #d252ff, 0 0 8px #d252ff; }
}
.clash-elixir-bar.full {
    animation: elixirPulse 0.8s ease-in-out infinite;
    border-color: #ff52ff;
}
.clash-elixir-bar.full .clash-elixir-text {
    animation: pulse 0.8s ease-in-out infinite;
    color: #ff52ff;
}

/* === KNOCKBACK EFFECT === */
@keyframes knockbackFlash {
    0% { filter: brightness(2) saturate(1.5); transform: translate(-50%, -50%) scale(1.1); }
    100% { filter: brightness(1) saturate(1); transform: translate(-50%, -50%) scale(1); }
}
.clash-unit.knocked-back {
    animation: knockbackFlash 0.3s ease-out forwards !important;
    transition: left 0.2s ease-out, top 0.2s ease-out;
}

/* === BATTLE START COUNTDOWN === */
.clash-countdown {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    background: rgba(0,0,0,0.5);
    pointer-events: none;
}
.clash-countdown-number {
    font-size: 120px;
    font-weight: 900;
    color: #f1c40f;
    text-shadow: 0 0 20px rgba(241,196,15,0.8), 0 4px 8px rgba(0,0,0,0.6);
    opacity: 0;
    transform: scale(2);
    font-family: 'Impact', 'Arial Black', sans-serif;
}
.clash-countdown-number.pop {
    animation: countdownPop 0.9s ease-out forwards;
}
.clash-countdown-number.fight {
    color: #e74c3c;
    text-shadow: 0 0 30px rgba(231,76,60,0.9), 0 4px 8px rgba(0,0,0,0.6);
    font-size: 80px;
}
@keyframes countdownPop {
    0% { opacity: 0; transform: scale(2.5); }
    20% { opacity: 1; transform: scale(0.9); }
    40% { transform: scale(1.05); }
    60% { transform: scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: scale(0.8); }
}

/* === ANNOUNCEMENT OVERLAY === */
.clash-announcement {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    pointer-events: none;
}
.clash-announcement-text {
    font-size: 36px;
    font-weight: 900;
    font-family: 'Impact', 'Arial Black', sans-serif;
    letter-spacing: 3px;
    text-transform: uppercase;
    animation: announcementSlide 2s ease-out forwards;
    padding: 12px 40px;
    border-radius: 4px;
}
.clash-announcement-text.double-elixir {
    color: #d252ff;
    text-shadow: 0 0 20px rgba(210,82,255,0.8);
    background: rgba(0,0,0,0.6);
}
.clash-announcement-text.overtime {
    color: #e74c3c;
    text-shadow: 0 0 20px rgba(231,76,60,0.8);
    background: rgba(0,0,0,0.7);
    font-size: 42px;
}
.clash-announcement-text.king-activate {
    color: #f1c40f;
    text-shadow: 0 0 20px rgba(241,196,15,0.8);
    background: rgba(0,0,0,0.6);
    font-size: 28px;
}
@keyframes announcementSlide {
    0% { opacity: 0; transform: scale(0.5) translateY(20px); }
    15% { opacity: 1; transform: scale(1.1) translateY(0); }
    25% { transform: scale(1) translateY(0); }
    75% { opacity: 1; transform: scale(1) translateY(0); }
    100% { opacity: 0; transform: scale(0.9) translateY(-10px); }
}

/* === TIMER WARNING === */
.clash-timer.warning {
    animation: timerWarning 0.5s ease-in-out infinite alternate;
    color: #e74c3c !important;
}
@keyframes timerWarning {
    0% { transform: scale(1); text-shadow: 1px 1px 2px #000; }
    100% { transform: scale(1.15); text-shadow: 0 0 8px rgba(231,76,60,0.8), 1px 1px 2px #000; }
}

/* === KING TOWER ACTIVATION === */
@keyframes kingActivate {
    0% { filter: brightness(1); box-shadow: none; }
    20% { filter: brightness(2.5); box-shadow: 0 0 30px rgba(241,196,15,0.9); }
    60% { filter: brightness(1.5); box-shadow: 0 0 15px rgba(241,196,15,0.5); }
    100% { filter: brightness(1); box-shadow: none; }
}
.clash-tower.activating {
    animation: kingActivate 1.5s ease-out forwards;
    z-index: 100 !important;
}
.clash-king-spark {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f1c40f;
    z-index: 101;
    pointer-events: none;
    box-shadow: 0 0 6px #f1c40f, 0 0 12px #e67e22;
    animation: sparkFly 0.7s ease-out forwards;
}
@keyframes sparkFly {
    0% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0); opacity: 0; }
}

/* === DEPLOYMENT ZONE === */
.clash-deploy-zone {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

/* === SPAWN SHADOW === */
@keyframes spawnShadowPulse {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    30% { opacity: 0.7; }
    100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; }
}
.clash-spawn-shadow {
    position: absolute;
    width: 30px;
    height: 14px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 5;
    animation: spawnShadowPulse 1s ease-out forwards;
}
.clash-spawn-shadow.player {
    background: radial-gradient(ellipse, rgba(93,173,226,0.6) 0%, rgba(93,173,226,0) 70%);
    box-shadow: 0 0 10px rgba(93,173,226,0.4);
}
.clash-spawn-shadow.enemy {
    background: radial-gradient(ellipse, rgba(231,76,60,0.6) 0%, rgba(231,76,60,0) 70%);
    box-shadow: 0 0 10px rgba(231,76,60,0.4);
}

/* Death explosion for Mega Giant */
.clash-death-explosion {
    position: absolute;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 50;
    background: radial-gradient(circle, rgba(255,200,50,0.9) 0%, rgba(255,100,0,0.6) 40%, rgba(255,50,0,0) 70%);
    animation: deathExplosion 0.7s ease-out forwards;
}
@keyframes deathExplosion {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.3); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

/* Boss unit ground shake on deploy */
.clash-unit.mega_pekka.deploying .clash-unit-icon,
.clash-unit.mega_giant.deploying .clash-unit-icon {
    animation: bossLand 0.8s ease-out;
}
@keyframes bossLand {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.15); opacity: 1; }
    70% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* === END GAME STATS === */
.clash-end-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 15px 0;
    width: 100%;
    max-width: 250px;
}
.clash-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 12px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    font-size: 14px;
}
.clash-stat-row span:first-child {
    color: #bbb;
}
.clash-stat-row span:last-child {
    color: #f1c40f;
    font-weight: bold;
}

/* === LANGUAGE QUIZ CONTAINER === */
.clash-quiz-container {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9000;
}
.clash-quiz-container .quiz-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 8px 0;
    overflow-y: auto;
}
.clash-quiz-container .quiz-modal {
    width: 94%;
    max-width: 420px;
    max-height: none;
    overflow-y: visible;
    margin: auto 0;
    padding: 12px 16px;
}
.clash-quiz-container .memory-tip-modal {
    max-height: none;
    overflow-y: visible;
    width: 94%;
    max-width: 420px;
    margin: auto 0;
}
.clash-quiz-container .btn-continue {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 14px 16px;
    background: linear-gradient(145deg, #2a5a4a, #1a4a3a);
    border: 1px solid #4a7a6a;
    border-radius: 8px;
    color: #e0e0e0;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, box-shadow 0.15s;
    touch-action: manipulation;
}
.clash-quiz-container .btn-continue:hover {
    background: linear-gradient(145deg, #3a6a5a, #2a5a4a);
    box-shadow: 0 0 12px rgba(93, 222, 93, 0.3);
}
.clash-quiz-container .self-assessment-buttons {
    display: flex;
    gap: 6px;
}
.clash-quiz-container .btn-self-assess {
    flex: 1;
    padding: 12px 6px;
    touch-action: manipulation;
    min-height: 50px;
}
.clash-quiz-container .btn-option {
    padding: 12px 14px;
    touch-action: manipulation;
    min-height: 44px;
}

/* === POWER-UP POPUP === */
.clash-powerup-popup {
    position: absolute;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 200;
    white-space: nowrap;
    text-shadow: 0 0 8px currentColor, 1px 1px 0 #000, -1px -1px 0 #000;
    animation: powerUpPop 1.2s ease-out forwards;
}
@keyframes powerUpPop {
    0% { transform: translate(-50%, 0) scale(0.5); opacity: 0; }
    15% { transform: translate(-50%, -8px) scale(1.3); opacity: 1; }
    30% { transform: translate(-50%, -12px) scale(1); }
    70% { opacity: 1; transform: translate(-50%, -20px) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -35px) scale(0.8); }
}

/* === POWER-UP HUD BAR === */
.clash-powerup-hud {
    position: absolute;
    top: 44px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    z-index: 12;
}
.clash-powerup-hud-icon {
    width: 22px;
    height: 22px;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
    pointer-events: auto;
}
.clash-pu-tooltip {
    position: absolute;
    z-index: 100;
    background: rgba(0,0,0,0.92);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    padding: 8px 12px;
    max-width: 200px;
    transform: translateX(-50%);
    pointer-events: auto;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}
.clash-pu-tt-name {
    font-size: 12px;
    font-weight: 700;
    color: #f1c40f;
    margin-bottom: 3px;
}
.clash-pu-tt-desc {
    font-size: 10px;
    color: #ccc;
    line-height: 1.4;
}
.clash-powerup-hud-icon.triggered {
    animation: hudIconPulse 0.6s ease-out;
    border-color: #f1c40f;
    box-shadow: 0 0 8px rgba(241,196,15,0.7);
}
@keyframes hudIconPulse {
    0% { transform: scale(1); }
    30% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

/* === SPEED TOGGLE === */
.clash-speed-btn {
    background: linear-gradient(to bottom, #555, #333);
    color: #f1c40f;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
    line-height: 1;
}
.clash-speed-btn:active { background: #444; }
.clash-speed-btn.fast {
    background: linear-gradient(to bottom, #e67e22, #d35400);
    border-color: #f39c12;
    color: white;
}

/* === DECK VIEWER === */
.clash-deck-btn {
    background: linear-gradient(to bottom, #555, #333);
    color: white;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.clash-deck-btn:active { background: #444; }

.clash-deck-viewer {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.88);
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}
.clash-deck-viewer-title {
    font-size: 18px;
    font-weight: bold;
    color: #f1c40f;
    margin-bottom: 12px;
}
.clash-deck-viewer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    width: 100%;
    max-width: 360px;
}
.clash-deck-viewer-card {
    background: linear-gradient(135deg, #1e2d3d, #152238);
    border: 2px solid #3a5a7a;
    border-radius: 6px;
    padding: 6px;
    text-align: center;
    font-size: 10px;
}
.clash-deck-viewer-card.in-hand {
    border-color: #f1c40f;
    box-shadow: 0 0 6px rgba(241,196,15,0.4);
}
.clash-deck-viewer-card.is-next {
    border-color: #2ecc71;
}
.clash-deck-viewer-card .dvr-name {
    font-weight: bold;
    color: #ecf0f1;
    margin-bottom: 2px;
}
.clash-deck-viewer-card .dvr-stats {
    color: #888;
    font-size: 9px;
    line-height: 1.3;
}
.clash-deck-viewer-card .dvr-cost {
    display: inline-block;
    background: radial-gradient(circle, #d252ff, #8e44ad);
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    line-height: 16px;
    font-size: 10px;
    font-weight: bold;
    margin-bottom: 2px;
}
.clash-deck-viewer-hint {
    font-size: 11px;
    color: #666;
    margin-top: 12px;
}

/* === CARD TOOLTIP (long press) === */
.clash-card-tooltip {
    position: fixed;
    background: rgba(20,30,50,0.95);
    border: 2px solid #f1c40f;
    border-radius: 8px;
    padding: 8px 12px;
    z-index: 2000;
    pointer-events: none;
    min-width: 120px;
    text-align: center;
}
.clash-card-tooltip .ctt-name {
    font-size: 13px;
    font-weight: bold;
    color: #f1c40f;
    margin-bottom: 4px;
}
.clash-card-tooltip .ctt-type {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.clash-card-tooltip .ctt-stats {
    font-size: 11px;
    color: #ddd;
    line-height: 1.4;
}
.clash-card-tooltip .ctt-stats span {
    color: #5dade2;
    font-weight: bold;
}

/* === DEPLOY CARD FLY ANIMATION === */
@keyframes clashDeployFly {
    0% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.9; }
    60% { transform: translate(-50%, -50%) scale(0.3); opacity: 0.6; }
    100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
}
.clash-deploy-fly {
    position: absolute;
    width: 40px;
    height: 40px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    pointer-events: none;
    z-index: 50;
    filter: brightness(1.5) drop-shadow(0 0 8px rgba(241,196,15,0.8));
    animation: clashDeployFly 0.45s ease-in forwards;
}

/* === FLOATING GOLD TEXT IN BATTLE === */
@keyframes clashGoldFloat {
    0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
    20% { opacity: 1; transform: translate(-50%, -10px) scale(1.15); }
    70% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -35px) scale(0.9); }
}
.clash-float-gold {
    position: absolute;
    font-size: 16px;
    font-weight: 900;
    pointer-events: none;
    z-index: 200;
    white-space: nowrap;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
    animation: clashGoldFloat 1.2s ease-out forwards;
}
.clash-float-gold.gain { color: #2ecc71; }
.clash-float-gold.loss { color: #e74c3c; }

/* === LEVELED-UP UNIT GLOW === */
@keyframes clashLevelGlow {
    0%, 100% { box-shadow: 0 0 6px 2px rgba(241,196,15,0.4); }
    50% { box-shadow: 0 0 12px 4px rgba(241,196,15,0.7); }
}
.clash-unit.leveled-up .clash-unit-icon {
    filter: drop-shadow(0 0 5px rgba(241,196,15,0.6));
}
.clash-unit.leveled-up::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 1.5px solid rgba(241,196,15,0.5);
    animation: clashLevelGlow 2s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
}
.clash-unit.leveled-max .clash-unit-icon {
    filter: drop-shadow(0 0 7px rgba(231,76,60,0.7));
}
.clash-unit.leveled-max::before {
    border-color: rgba(231,76,60,0.6);
    animation: clashLevelGlowMax 2s ease-in-out infinite;
}
@keyframes clashLevelGlowMax {
    0%, 100% { box-shadow: 0 0 6px 2px rgba(231,76,60,0.4); }
    50% { box-shadow: 0 0 14px 5px rgba(231,76,60,0.7); }
}