/* ==========================================================================
   Working Together - Style & Responsive Glassmorphic Theme (v2.0)
   ========================================================================== */

:root {
    --bg-dark: #070a13;
    --card-bg: rgba(15, 23, 42, 0.88);
    --hud-bg: rgba(11, 19, 38, 0.82);
    --border-glass: rgba(255, 255, 255, 0.14);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-gold: #fbbf24;
    --accent-cyan: #38bdf8;
    --accent-green: #4ade80;
    --accent-rose: #fb7185;
    --accent-purple: #c084fc;
    --accent-glow: 0 0 24px rgba(56, 189, 248, 0.4);
}

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

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-main);
    touch-action: none;
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #090e1a;
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* ==========================================================================
   Top HUD
   ========================================================================== */
#topHud {
    position: absolute;
    top: env(safe-area-inset-top, 12px);
    left: env(safe-area-inset-left, 12px);
    right: env(safe-area-inset-right, 12px);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 50;
}

.hud-left, .hud-right {
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}

.hud-btn {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--hud-bg);
    border: 1px solid var(--border-glass);
    color: #fff;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.hud-btn:hover {
    transform: scale(1.06);
    border-color: var(--accent-cyan);
    background: rgba(30, 41, 59, 0.9);
}

.hud-btn:active {
    transform: scale(0.95);
}

.hud-badge-panel {
    background: var(--hud-bg);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: 16px;
    padding: 6px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

.level-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--accent-cyan);
}

.level-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.flock-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 700;
}

.flock-counter strong {
    color: var(--accent-gold);
    font-size: 1.05rem;
}

.bird-avatars {
    display: flex;
    gap: 4px;
    align-items: center;
    max-width: 220px;
    flex-wrap: wrap;
}

.bird-avatar-tag {
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.32;
    filter: grayscale(0.85);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bird-avatar-tag.rescued {
    opacity: 1;
    filter: grayscale(0);
    transform: scale(1.15);
    animation: popBounce 0.5s ease-out;
}

@keyframes popBounce {
    0% { transform: scale(0.5); }
    70% { transform: scale(1.35); }
    100% { transform: scale(1.15); }
}

/* ==========================================================================
   Radar Display
   ========================================================================== */
#radarContainer {
    position: relative;
    width: 96px;
    height: 96px;
    background: rgba(10, 15, 29, 0.88);
    border: 1.5px solid rgba(56, 189, 248, 0.35);
    border-radius: 50%;
    box-shadow: 0 0 16px rgba(0, 0, 0, 0.6), inset 0 0 12px rgba(56, 189, 248, 0.2);
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#radarCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.radar-label {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--accent-cyan);
    opacity: 0.8;
}

/* ==========================================================================
   Objectives & Notification Banners
   ========================================================================== */
#objectiveBanner {
    position: absolute;
    top: 78px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
    pointer-events: none;
    z-index: 45;
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
    max-width: 90vw;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.obj-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-gold);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-gold);
    animation: pulseGlow 1.5s infinite alternate;
}

@keyframes pulseGlow {
    0% { transform: scale(0.9); opacity: 0.7; }
    100% { transform: scale(1.3); opacity: 1; }
}

#gameToast {
    position: absolute;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
    border: 1px solid var(--accent-cyan);
    border-radius: 14px;
    padding: 8px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 15px rgba(56, 189, 248, 0.25);
    z-index: 60;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast-hidden {
    opacity: 0;
    transform: translate(-50%, -20px) scale(0.9) !important;
    pointer-events: none;
}

#helicopterWarning {
    position: absolute;
    top: 162px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(225, 29, 72, 0.9);
    border: 1px solid #fda4af;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 800;
    padding: 6px 18px;
    border-radius: 20px;
    z-index: 55;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(225, 29, 72, 0.6);
    animation: flashAlert 0.7s infinite alternate;
}

@keyframes flashAlert {
    0% { opacity: 0.7; transform: translateX(-50%) scale(0.98); }
    100% { opacity: 1; transform: translateX(-50%) scale(1.02); }
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   Mobile Touch Controls Overlay
   ========================================================================== */
#touchControlsOverlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    pointer-events: none;
    z-index: 40;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 24px 28px 24px;
}

#joystickZone {
    width: 50%;
    height: 100%;
    position: relative;
    pointer-events: auto;
}

#joystickBase {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.15) 0%, rgba(15, 23, 42, 0.5) 80%);
    border: 2px solid rgba(56, 189, 248, 0.35);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.2s ease;
    opacity: 0.7;
}

#joystickHandle {
    width: 50px;
    height: 50px;
    background: radial-gradient(circle, #38bdf8 0%, #0284c7 100%);
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(56, 189, 248, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.6);
    transform: translate(0, 0);
    will-change: transform;
}

.touch-hint {
    position: absolute;
    bottom: 0px;
    left: 28px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    opacity: 0.7;
}

#actionZone {
    pointer-events: auto;
    margin-bottom: 10px;
}

.action-touch-btn {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #f59e0b 0%, #d97706 100%);
    border: 3px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 24px rgba(217, 119, 6, 0.5), inset 0 2px 6px rgba(255, 255, 255, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    touch-action: none;
}

.action-touch-btn:active {
    transform: scale(0.92);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.7);
    background: radial-gradient(circle at 35% 35%, #fbbf24 0%, #b45309 100%);
}

.action-touch-btn .btn-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.action-touch-btn .btn-text {
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 1px;
    margin-top: 2px;
}

/* ==========================================================================
   Modals & Overlays
   ========================================================================= */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 7, 18, 0.84);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--card-bg);
    border: 1px solid var(--border-glass);
    border-radius: 28px;
    padding: 32px 28px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), var(--accent-glow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-height: 92vh;
    overflow-y: auto;
}

.modal-header-art {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.art-bird {
    font-size: 3.8rem;
    filter: drop-shadow(0 4px 12px rgba(56, 189, 248, 0.4));
    animation: gentleHover 2s infinite ease-in-out;
}

.art-friends {
    font-size: 1.6rem;
    letter-spacing: 4px;
    opacity: 0.9;
}

@keyframes gentleHover {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.modal-card h1 {
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #38bdf8 0%, #fbbf24 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-card h2 {
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
}

.subtitle {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-gold);
    margin-top: -8px;
}

.story-box {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px 18px;
    font-size: 0.92rem;
    line-height: 1.5;
    color: #cbd5e1;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.controls-guide {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    text-align: left;
}

.guide-col {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 10px 12px;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #cbd5e1;
}

.guide-device {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--accent-cyan);
    display: block;
    margin-bottom: 4px;
}

.primary-btn {
    width: 100%;
    padding: 14px 24px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #fff;
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.4);
    transition: all 0.2s ease;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 26px rgba(2, 132, 199, 0.6);
    background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
}

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

.secondary-btn {
    display: inline-block;
    padding: 10px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    transition: color 0.2s;
}

.secondary-btn:hover {
    color: #fff;
}

/* ==========================================================================
   Caged / Rescue Modal
   ========================================================================== */
.caged-card {
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 35px rgba(239, 68, 68, 0.35);
}

.caged-art {
    font-size: 3.5rem;
    animation: shakeSlow 1s infinite ease-in-out;
}

@keyframes shakeSlow {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-6deg); }
    75% { transform: rotate(6deg); }
}

.lock-progress-container {
    width: 100%;
    height: 16px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

.lock-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #4ade80);
    border-radius: 20px;
    transition: width 0.15s ease-out;
    box-shadow: 0 0 12px #4ade80;
}

.lock-hint {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-gold);
}

.struggle-btn {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: 2px solid #fbbf24;
    background: radial-gradient(circle, #f59e0b 0%, #b45309 100%);
    color: #fff;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.4);
    transition: transform 0.08s ease;
}

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

/* ==========================================================================
   Victory / Level Complete Modals
   ========================================================================== */
.victory-card {
    border-color: rgba(251, 191, 36, 0.5);
    box-shadow: 0 0 45px rgba(251, 191, 36, 0.35);
}

.victory-art {
    font-size: 4rem;
    animation: victorySpin 3s infinite ease-in-out;
}

@keyframes victorySpin {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.15) rotate(5deg); }
}

.victory-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    margin: 8px 0;
}

.stat-box {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-num {
    font-size: 1.35rem;
    font-weight: 900;
    color: var(--accent-cyan);
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.victory-msg {
    font-size: 0.95rem;
    color: #e2e8f0;
    line-height: 1.5;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 600px) {
    #topHud {
        top: 8px;
        left: 8px;
        right: 8px;
    }

    .hud-badge-panel {
        padding: 4px 10px;
    }

    .flock-counter {
        font-size: 0.85rem;
    }

    .bird-avatars {
        max-width: 140px;
    }

    .bird-avatar-tag {
        font-size: 0.95rem;
    }

    #radarContainer {
        width: 78px;
        height: 78px;
    }

    #objectiveBanner {
        top: 70px;
        font-size: 0.75rem;
        padding: 4px 12px;
    }

    #gameToast {
        top: 105px;
        font-size: 0.8rem;
        padding: 6px 14px;
    }

    .modal-card {
        padding: 24px 18px;
    }

    .modal-card h1 {
        font-size: 1.8rem;
    }

    .controls-guide {
        grid-template-columns: 1fr;
    }
}
