/* ==========================================================================
   SMASH CITY 3D - Modern Arcade & Glassmorphism Design System
   ========================================================================== */

:root {
    --bg-dark: #090d16;
    --card-bg: rgba(18, 26, 43, 0.75);
    --card-border: rgba(255, 255, 255, 0.12);
    --card-glow: rgba(56, 189, 248, 0.15);

    --primary-cyan: #00f5ff;
    --primary-blue: #2563eb;
    --accent-gold: #fbbf24;
    --accent-red: #f43f5e;
    --accent-green: #22c55e;
    --accent-purple: #a855f7;

    --text-white: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Rajdhani', monospace, sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: var(--font-heading);
    color: var(--text-white);
    touch-action: none;
}

/* 3D Canvas */
#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#game-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Screen Flash for heavy destruction */
#screen-flash {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.35) 0%, transparent 80%);
    pointer-events: none;
    z-index: 8;
    opacity: 0;
    transition: opacity 0.15s ease-out;
}

/* Floating Numbers & Text */
#floating-text-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    overflow: hidden;
}

.floating-text {
    position: absolute;
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 1.35rem;
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation: floatDamage 0.85s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 0 12px currentColor;
}

.floating-damage {
    color: #ff4d4d;
}

.floating-gold {
    color: #ffd700;
    font-size: 1.5rem;
}

@keyframes floatDamage {
    0% {
        opacity: 0;
        transform: translate(-50%, -20%) scale(0.6);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -60%) scale(1.25);
    }
    70% {
        opacity: 1;
        transform: translate(-50%, -120%) scale(1.0);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -160%) scale(0.8);
    }
}

/* Glassmorphic Styles */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6), 0 0 30px var(--card-glow);
    border-radius: 24px;
}

.glass-card {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border-radius: 16px;
}

/* ==========================================================================
   IN-GAME HUD
   ========================================================================== */
#ingame-hud {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    transition: opacity 0.3s ease;
}

#ingame-hud > * {
    pointer-events: auto;
}

.hidden {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

.hud-top-left {
    align-self: flex-start;
    padding: 10px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gold-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.coin-icon {
    font-size: 1.4rem;
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.6));
}

.gold-amount {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 800;
    color: #fef08a;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.dps-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-weight: 700;
}

.badge-dot {
    color: rgba(255, 255, 255, 0.2);
}

.hud-top-right {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    display: flex;
    align-items: center;
    gap: 10px;
}

.glass-icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.glass-icon-btn:hover {
    background: rgba(30, 41, 59, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.glass-btn {
    padding: 10px 18px;
    border-radius: 9999px;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.btn-danger-pill {
    background: rgba(225, 29, 72, 0.25);
    border-color: rgba(244, 63, 94, 0.4);
    color: #fecdd3;
    backdrop-filter: blur(10px);
}

.btn-danger-pill:hover {
    background: rgba(225, 29, 72, 0.5);
    border-color: rgba(244, 63, 94, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 0 16px rgba(244, 63, 94, 0.4);
}

/* Bottom Cooldown Bar */
.hud-bottom-center {
    align-self: center;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}

.cooldown-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: rgba(10, 15, 26, 0.7);
    padding: 6px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.cooldown-bar-bg {
    width: 160px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.cooldown-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #00f5ff, #3b82f6);
    box-shadow: 0 0 10px #00f5ff;
    border-radius: 999px;
    transition: width 0.05s linear;
}

.cooldown-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

/* ==========================================================================
   MOBILE CONTROLS OVERLAY
   ========================================================================== */
#mobile-controls {
    position: absolute;
    inset: 0;
    pointer-events: none !important;
    z-index: 25;
}

#joystick-zone {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.12) 0%, rgba(15, 23, 42, 0.35) 70%);
    border: 2px dashed rgba(56, 189, 248, 0.35);
    pointer-events: auto !important;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

#joystick-knob {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, #00f5ff 0%, #2563eb 100%);
    box-shadow: 0 0 16px rgba(0, 245, 255, 0.7);
    border: 2px solid white;
    position: absolute;
    pointer-events: none;
    transform: translate(0px, 0px);
}

.joystick-guide-hint {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(148, 163, 184, 0.6);
    pointer-events: none;
}

#action-zone {
    position: absolute;
    bottom: 30px;
    right: 25px;
    pointer-events: auto !important;
}

.touch-hammer-btn {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #00f5ff);
    border: 3px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 24px rgba(0, 245, 255, 0.4), inset 0 2px 6px rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    position: relative;
    outline: none;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.touch-hammer-btn:active {
    transform: scale(0.92);
    box-shadow: 0 2px 10px rgba(0, 245, 255, 0.6);
}

.touch-hammer-btn .hammer-emoji {
    font-size: 2.2rem;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

.touch-hammer-btn .btn-text {
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 1px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    margin-top: -2px;
}

.hammer-glow-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(0, 245, 255, 0.4);
    animation: pulseRing 2s infinite ease-out;
}

@keyframes pulseRing {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.25); opacity: 0; }
}

/* ==========================================================================
   LOBBY OVERLAY (Translucent & Visible surrounding buildings)
   ========================================================================== */
.overlay-screen {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.25s ease-out;
}

.lobby-backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 35%, rgba(9, 13, 22, 0.1) 0%, rgba(9, 13, 22, 0.35) 85%);
    pointer-events: none;
}

.lobby-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 480px;
    padding: 28px 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 18px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4), 0 0 30px rgba(0, 245, 255, 0.15);
    border-radius: 24px;
}

.game-logo .logo-subtitle {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--primary-cyan);
    margin-bottom: 4px;
}

.game-logo .logo-title {
    font-size: 2.75rem;
    font-weight: 900;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.gradient-text {
    background: linear-gradient(135deg, #00f5ff 0%, #3b82f6 50%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-logo .logo-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.lobby-gold-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 16px;
    padding: 14px 28px;
    width: 100%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.gold-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.gold-value-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
}

.coin-icon-lg {
    font-size: 2rem;
    filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.7));
}

.gold-amount-lg {
    font-family: var(--font-mono);
    font-size: 2.4rem;
    font-weight: 800;
    color: #fef08a;
    text-shadow: 0 0 16px rgba(251, 191, 36, 0.4);
}

.gold-unit {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent-gold);
    align-self: flex-end;
    margin-bottom: 6px;
}

.lobby-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    width: 100%;
}

.cta-button {
    padding: 16px 20px;
    border-radius: 18px;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
}

.cta-button:hover {
    transform: translateY(-3px) scale(1.02);
}

.cta-button:active {
    transform: translateY(1px) scale(0.98);
}

.primary-cta {
    background: linear-gradient(135deg, #00f5ff 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 8px 24px rgba(0, 245, 255, 0.35);
}

.primary-cta:hover {
    box-shadow: 0 12px 30px rgba(0, 245, 255, 0.5);
}

.secondary-cta {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-white);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.secondary-cta:hover {
    background: rgba(51, 65, 85, 0.9);
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: 0 8px 24px rgba(56, 189, 248, 0.25);
}

.cta-icon {
    font-size: 1.7rem;
    margin-bottom: 4px;
}

.cta-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.cta-subtitle {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    opacity: 0.85;
    letter-spacing: 1.5px;
}

.controls-guide-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px 18px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 12px;
}

.guide-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.guide-tag {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--primary-cyan);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.guide-col p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.guide-col strong {
    color: var(--text-white);
}

.guide-divider {
    width: 1px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
}

.lobby-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-top: 6px;
}

.glass-text-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.glass-text-btn:hover {
    color: var(--text-white);
    background: rgba(255, 255, 255, 0.06);
}

.subtle-btn {
    color: var(--text-dim);
}

.subtle-btn:hover {
    color: var(--accent-red);
}

/* ==========================================================================
   UPGRADE MODAL
   ========================================================================== */
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 7, 15, 0.85);
    backdrop-filter: blur(8px);
}

.modal-window {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    padding: 28px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    gap: 20px;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.modal-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-muted);
    font-size: 1.8rem;
    line-height: 1;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: rgba(244, 63, 94, 0.25);
    color: var(--accent-red);
}

.modal-gold-bar {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 12px;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.modal-gold-val {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 800;
    color: #fef08a;
}

.upgrade-cards-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.upgrade-card {
    background: rgba(20, 29, 48, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    transition: all 0.2s ease;
}

.upgrade-card:hover {
    border-color: rgba(56, 189, 248, 0.35);
    background: rgba(30, 41, 68, 0.75);
}

.card-info-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.card-icon {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: left;
}

.card-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-name {
    font-size: 1.05rem;
    font-weight: 700;
}

.card-level-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-cyan);
    background: rgba(0, 245, 255, 0.12);
    border: 1px solid rgba(0, 245, 255, 0.25);
    padding: 2px 6px;
    border-radius: 6px;
}

.card-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.card-stat-transition {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 700;
    color: #cbd5e1;
    margin-top: 2px;
}

.stat-arrow {
    color: var(--primary-cyan);
    margin: 0 4px;
}

.stat-next {
    color: var(--accent-green);
}

.card-buy-btn {
    min-width: 110px;
    padding: 10px 14px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.3);
    transition: all 0.2s ease;
}

.card-buy-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(34, 197, 94, 0.45);
}

.card-buy-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.card-buy-btn:disabled {
    background: rgba(51, 65, 85, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    box-shadow: none;
    cursor: not-allowed;
}

.buy-btn-label {
    font-size: 0.8rem;
    font-weight: 700;
}

.buy-btn-cost {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 800;
    margin-top: 2px;
}

.full-width {
    width: 100%;
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE & TABLET)
   ========================================================================== */
@media (max-width: 640px) {
    .lobby-content {
        padding: 24px 20px;
        gap: 18px;
    }

    .game-logo .logo-title {
        font-size: 2.1rem;
    }

    .lobby-buttons-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .controls-guide-card {
        flex-direction: column;
        gap: 8px;
    }

    .guide-divider {
        width: 80%;
        height: 1px;
    }

    .upgrade-card {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .card-buy-btn {
        width: 100%;
        flex-direction: row;
        gap: 8px;
        padding: 12px;
    }

    #joystick-zone {
        width: 130px;
        height: 130px;
        bottom: 16px;
        left: 16px;
    }

    .touch-hammer-btn {
        width: 84px;
        height: 84px;
        bottom: 16px;
        right: 16px;
    }
}
