:root {
    --bg-dark: #F8F9FA;
    --panel-bg: #FFFFFF;
    --text-main: #1A1D29;
    --neon-green: #44CC88;
    --neon-cyan: #0088FF;
    --neon-yellow: #FBBF24;
    --neon-purple: #8B00FF;
    --neon-red: #FF0055;
    --font-main: 'Outfit', sans-serif;
}

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

body {
    background-color: #E9ECEF;
    color: var(--text-main);
    font-family: var(--font-main);
    margin: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

#app-container {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 600px;
    background: #FFFFFF;
    border: 2px solid #E2E8F0;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08), 0 0 20px rgba(0, 136, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header HUD */
#hud-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: #F8F9FA;
    border-bottom: 2px solid #E2E8F0;
    gap: 0;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    text-align: center;
}

.wave-box  { width: 72px; }
.gold-box  { width: 50px; }
.enemy-box { width: 76px; }

.hud-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #6C728E;
    margin-bottom: 2px;
    text-align: center;
}

.hud-value {
    font-size: 18px;
    font-weight: 900;
    text-align: center;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.hud-value.hud-pop { transform: scale(1.5); }
.neon-cyan { color: var(--neon-cyan); text-shadow: 0 0 8px rgba(0, 136, 255, 0.5); }
.neon-yellow { color: var(--neon-yellow); text-shadow: 0 0 8px rgba(251, 191, 36, 0.6); }
.neon-green { color: var(--neon-green); text-shadow: 0 0 8px rgba(68, 204, 136, 0.6); }
.neon-red { color: var(--neon-red); text-shadow: 0 0 8px rgba(255, 0, 85, 0.6); }

.btn-group { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.speed-toggle-btn {
    background: #FFFFFF; border: 2px solid var(--neon-cyan); border-radius: 8px;
    color: var(--neon-cyan); font-family: var(--font-main); font-size: 15px;
    font-weight: 900; padding: 6px 12px; cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 136, 255, 0.2); transition: all 0.15s ease;
}
.speed-toggle-btn:hover { transform: scale(1.05); box-shadow: 0 0 12px rgba(0, 136, 255, 0.4); }
.skill-guide-btn {
    background: #FFFFFF; border: 2px solid #CBD5E1; border-radius: 8px;
    color: #475569; font-family: var(--font-main); font-size: 18px;
    font-weight: 900; padding: 6px 12px; cursor: pointer; transition: all 0.15s ease;
}
.skill-guide-btn:hover { transform: scale(1.05); background: #F1F5F9; }

/* Game Viewport */
#game-viewport {
    position: relative;
    overflow: hidden;
    width: 600px;
    height: 750px;
}

#speed-btn {
    position: absolute;
    bottom: 14px;
    right: 14px;
    z-index: 10;
}

#game-canvas {
    background-color: var(--bg-dark);
    touch-action: none;
    width: 100%;
    height: 100%;
}

/* Screen Dimmer & MYTHIC Banner */
#screen-dimmer {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}
#screen-dimmer.dimmer-active { opacity: 1; }
.dimmer-hidden { opacity: 0; }

#mythic-banner {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    font-size: 32px;
    font-weight: 900;
    color: var(--neon-yellow);
    text-shadow: 0 0 20px var(--neon-yellow), 0 0 40px var(--neon-green);
    letter-spacing: 3px;
    pointer-events: none;
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#mythic-banner.mythic-show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}
.mythic-hidden { opacity: 0; }

/* Footer Controls */
#hud-footer {
    padding: 12px 16px;
    background: #F8F9FA;
    border-top: 2px solid #E2E8F0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    flex-shrink: 0;
    position: relative;
}

#tower-info-panel {
    position: absolute;
    bottom: 80px;
    left: 16px;
    right: 16px;
    width: calc(100% - 32px);
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 10px;
    padding: 10px 14px;
    display: grid;
    grid-template-columns: 100px 48px 1fr 1fr 1fr;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    z-index: 20;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    opacity: 1;
    transform: translateY(0);
}
#tower-info-panel.info-panel-hidden {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    display: flex !important;
    visibility: hidden;
}

.info-element {
    font-size: 16px;
    font-weight: 900;
    padding: 2px 10px;
    border-radius: 6px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.info-badge {
    background: #0088FF;
    color: #FFFFFF;
    font-size: 12px;
    font-weight: 900;
    padding: 3px 6px;
    border-radius: 6px;
    text-align: center;
    justify-self: center;
}
.info-atk {
    font-size: 13px;
    font-weight: 800;
    color: #FF5500;
    justify-self: center;
}
.info-spd {
    font-size: 13px;
    font-weight: 800;
    color: #0088FF;
    justify-self: center;
}
.info-desc {
    font-size: 12px;
    color: #475569;
    font-weight: 600;
    line-height: 1.3;
    justify-self: end;
    max-width: 140px;
    text-align: right;
}

.neon-btn {
    width: 100%;
    height: 54px;
    background: linear-gradient(135deg, #FF6B00, #FF0055);
    border: 2px solid #FFF;
    border-radius: 12px;
    color: #FFFFFF;
    font-family: var(--font-main);
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(255, 107, 0, 0.6), 0 0 10px rgba(255, 0, 85, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
}
.neon-btn:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 0 30px rgba(255, 107, 0, 0.9);
}
.neon-btn:active {
    transform: translateY(1px);
}
.neon-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
    filter: grayscale(0.5);
    pointer-events: none;
}

/* Modals */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(248, 249, 250, 0.45);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}
.modal-hidden { display: none !important; }

#defeat-modal.modal-overlay {
    background: transparent;
    backdrop-filter: none;
}
#defeat-modal::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(30, 41, 59, 0.35) 0%, rgba(15, 23, 42, 0.7) 100%);
    pointer-events: none;
    z-index: 0;
}
#defeat-modal .modal-card {
    position: relative;
    z-index: 1;
    width: 85%;
    background: linear-gradient(135deg, #FFFFFF 0%, #FFF7ED 100%);
    border: 2px solid #FDBA74;
    border-radius: 24px;
    padding: 32px 24px;
    text-align: center;
    box-shadow: 0 8px 40px rgba(249, 115, 22, 0.25), 0 0 80px rgba(249, 115, 22, 0.1);
    animation: defeatPopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes defeatPopIn {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

#defeat-modal .modal-title {
    font-size: 28px;
    font-weight: 900;
    margin-bottom: 8px;
    color: #EA580C;
}
#defeat-modal .modal-desc {
    font-size: 14px;
    color: #78716C;
    margin-bottom: 12px;
    line-height: 1.5;
}
#defeat-modal .modal-hint {
    font-size: 14px;
    color: #7C3AED;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.06), rgba(249, 115, 22, 0.04));
    border-radius: 12px;
    border: 1px solid rgba(124, 58, 237, 0.15);
    line-height: 1.6;
    font-weight: 600;
}
#defeat-modal .modal-actions { display: flex; flex-direction: column; gap: 12px; }

#restart-btn {
    background: linear-gradient(135deg, #F97316, #EF4444);
    border: none;
    color: #FFFFFF;
    padding: 14px 24px;
    border-radius: 14px;
    font-family: var(--font-main);
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.4);
    animation: restartPulse 2s ease-in-out infinite;
}
#restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(249, 115, 22, 0.55);
}
@keyframes restartPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(249, 115, 22, 0.4); }
    50% { box-shadow: 0 4px 32px rgba(249, 115, 22, 0.7), 0 0 40px rgba(239, 68, 68, 0.3); }
}

.rv-btn {
    position: relative;
    padding: 14px 16px;
    border-radius: 10px;
    border: none;
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.rv-badge {
    background: #F3F4F6;
    color: #B45309;
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 4px;
    font-weight: 900;
}
.neon-btn-gold { background: linear-gradient(135deg, #FFE600, #FF6B00); color: #000; }
.neon-btn-cyan { background: linear-gradient(135deg, #00F0FF, #0072FF); color: #FFF; }

/* AD STUFF HIDDEN FOR ITCH.IO */
.rv-btn, .card-reroll-btn, .rv-badge { display: none !important; }
.btn-secondary {
    background: transparent;
    border: 1px solid #D1D5DB;
    color: #6B7280;
    padding: 12px;
    border-radius: 10px;
    font-family: var(--font-main);
    font-weight: 600;
    cursor: pointer;
}

/* Card Inventory Panel */
#cards-panel {
    position: absolute;
    top: 68px;
    right: 8px;
    width: 240px;
    max-height: 340px;
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: all 0.25s ease;
    overflow: hidden;
}
#cards-panel.cards-panel-hidden {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
    visibility: hidden;
}
.cards-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #FEF3C7;
    border-bottom: 1px solid #FDE68A;
    gap: 8px;
}
.cards-panel-title {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #92400E;
    flex: 1;
}
.cards-count-badge {
    background: #F59E0B;
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 20px;
    min-width: 20px;
    text-align: center;
}
.cards-panel-body {
    padding: 10px 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cards-panel-body::-webkit-scrollbar { width: 5px; }
.cards-panel-body::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }
.cards-empty {
    text-align: center;
    color: #9CA3AF;
    font-size: 12px;
    font-weight: 600;
    padding: 16px 0;
}
.cards-owned-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
}
.cards-owned-item .c-name { color: #374151; }
.cards-owned-item .c-count { color: #6B7280; font-size: 11px; }
.cards-owned-item .c-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
}
.cards-owned-item .c-info { flex: 1; min-width: 0; }
.cards-owned-item .c-top { display: flex; justify-content: space-between; gap: 6px; }
.cards-owned-item .c-desc {
    font-size: 10px;
    font-weight: 500;
    color: #6B7280;
    margin-top: 2px;
    line-height: 1.3;
}

/* Skill Guide Panel */
#skill-guide-panel {
    position: absolute;
    top: 60px;
    right: 10px;
    width: 440px;
    max-height: 90vh;
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    z-index: 50;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.25s ease;
}
#skill-guide-panel.skill-guide-hidden {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
    visibility: hidden;
}

.skill-guide-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #F8F9FA;
    border-bottom: 1px solid #E2E8F0;
}
.skill-guide-title {
    font-size: 15px;
    font-weight: 900;
    color: var(--text-main);
    letter-spacing: 0.5px;
}
.guide-close-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #94A3B8;
    padding: 4px 8px;
    border-radius: 4px;
}
.guide-close-btn:hover { color: #475569; background: #E2E8F0; }

.skill-guide-content {
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.skill-guide-content::-webkit-scrollbar {
    display: none;
}

.guide-element-section {
    margin-bottom: 12px;
    border-radius: 8px;
    overflow: hidden;
}
.guide-element-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    font-size: 15px;
    font-weight: 800;
    color: #FFFFFF;
    cursor: pointer;
}
.guide-skills {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 6px;
    background: #F8F9FA;
}

.guide-skill-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 4px;
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    font-size: 13px;
}
.guide-skill-sum {
    font-size: 12px;
    color: #94A3B8;
}
.guide-skill-desc {
    font-size: 12px;
    color: #64748B;
    line-height: 1.3;
}


.guide-skill-row.active {
    background: #FFF9DB;
    border-color: #F59E0B;
    box-shadow: 0 0 8px rgba(245,158,11,0.25), inset 0 0 6px rgba(245,158,11,0.08);
}
.guide-skill-row.active .guide-skill-sum {
    color: #B45309;
    font-weight: 700;
}

/* Screen Dimmer */
.screen-dimmer {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: 70;
}
.screen-dimmer.dimmer-active {
    opacity: 1;
    pointer-events: auto;
}

/* Card System */
.card-modal-card {
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(20px);
    border: 1px solid #E5E7EB;
    border-radius: 20px;
    padding: 32px 24px 28px;
    text-align: center;
    max-width: 560px;
    width: 90%;
    box-shadow: 0 12px 60px rgba(0, 0, 0, 0.15);
    animation: cardModalIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes cardModalIn {
    from { transform: translateY(40px) scale(0.92); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
.card-modal-title {
    font-size: 24px;
    font-weight: 900;
    color: #374151;
    margin-bottom: 24px;
    letter-spacing: 2px;
    transition: color 0.3s;
    text-transform: uppercase;
}
.card-grid {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    perspective: 800px;
}
.card-grid.pop-in .card-slot {
    animation: cardFlipIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
@keyframes cardFlipIn {
    from { transform: translateY(30px) rotateY(25deg) scale(0.85); opacity: 0; }
    to   { transform: translateY(0) rotateY(0) scale(1);     opacity: 1; }
}

.card-slot {
    flex: 1;
    background: #FFFFFF;
    border: 2px solid #E5E7EB;
    border-radius: 14px;
    padding: 20px 12px 18px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-height: 190px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    position: relative;
    overflow: hidden;
    animation-delay: var(--delay, 0s);
    border-color: var(--border, #E5E7EB);
}
.card-slot::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: var(--glow, transparent);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 0;
    pointer-events: none;
}
.card-slot:hover::before { opacity: 1; }
.card-slot > * { position: relative; z-index: 1; }

.card-slot:hover {
    border-color: var(--border, #6366F1);
    box-shadow: 0 8px 30px rgba(99,102,241,0.15);
    transform: translateY(-6px);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

/* build-specific card styles */
.card-build-breeder {
    background: #FFFFFF;
    border-left: 4px solid #4ADE80;
}
.card-build-breeder:hover {
    box-shadow: 0 4px 30px rgba(74,222,128,0.15);
}
.card-build-banker {
    background: #FFFFFF;
    border-left: 4px solid #FBBF24;
}
.card-build-banker:hover {
    box-shadow: 0 4px 30px rgba(251,191,36,0.15);
}
.card-build-elementalist {
    background: #FFFFFF;
    border-left: 4px solid #A78BFA;
}
.card-build-elementalist:hover {
    box-shadow: 0 4px 30px rgba(167,139,250,0.15);
}
.card-build-tactician {
    background: #FFFFFF;
    border-left: 4px solid #F87171;
}
.card-build-tactician:hover {
    box-shadow: 0 4px 30px rgba(248,113,113,0.15);
}

.card-build-tag {
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
.card-name {
    font-size: 17px;
    font-weight: 900;
    line-height: 1.2;
    margin: 2px 0;
}
.card-desc {
    font-size: 13px;
    color: #374151;
    line-height: 1.45;
    font-weight: 600;
    padding: 0 2px;
}
.card-reroll-btn {
    margin: 0 auto;
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid #D1D5DB;
    background: #F3F4F6;
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6B7280;
    transition: all 0.2s;
}
.card-reroll-btn:hover {
    background: #E5E7EB;
    transform: translateY(-1px);
}

/* Options Button */
.options-btn {
    background: #FFFFFF;
    border: 2px solid #CBD5E1;
    border-radius: 8px;
    color: #475569;
    font-family: var(--font-main);
    font-size: 18px;
    font-weight: 900;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.options-btn:hover {
    transform: scale(1.05);
    background: #F1F5F9;
}


/* Options Panel */
#options-panel {
    position: absolute;
    top: 60px;
    right: 10px;
    width: 280px;
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    z-index: 50;
    overflow: hidden;
    transition: all 0.25s ease;
}
.options-panel-hidden {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
    visibility: hidden;
}
.options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #F8F9FA;
    border-bottom: 1px solid #E2E8F0;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #1E293B;
}
.options-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    padding: 4px 0;
}
.option-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #6366F1;
    cursor: pointer;
}

