/* ==========================================================================
   Panda Paradise CSS Design System
   Modern Dark Bamboo Forest Theme with Glassmorphism
   ========================================================================== */

:root {
    --bg-main: #09131a;
    --bg-card: rgba(15, 23, 42, 0.75);
    --bg-card-hover: rgba(30, 41, 59, 0.85);
    --border-color: rgba(255, 255, 255, 0.12);
    
    --primary: #10b981;
    --primary-hover: #059669;
    --primary-glow: rgba(16, 185, 129, 0.35);
    
    --accent: #f59e0b;
    --accent-glow: rgba(245, 158, 11, 0.35);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --meadow-bg-day: linear-gradient(135deg, #132e22 0%, #0d1f17 100%);
    --meadow-grid-day: rgba(16, 185, 129, 0.08);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

/* Day vs Night Theme Overrides */
body.day-theme {
    --bg-main: #0b1915;
    --bg-card: rgba(18, 38, 30, 0.8);
    --meadow-bg-day: radial-gradient(circle at 50% 30%, #1a3d2e 0%, #0c2118 80%);
}

body.night-theme {
    --bg-main: #050a0f;
    --bg-card: rgba(10, 18, 28, 0.85);
    --meadow-bg-day: radial-gradient(circle at 50% 30%, #0f1d2c 0%, #050a12 80%);
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.app-container {
    width: 95vw;
    max-width: 1400px;
    height: 94vh;
    height: 94dvh;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
}

/* Header Navbar */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    font-size: 2.2rem;
    animation: bounceSlow 3s infinite ease-in-out;
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a7f3d0, #10b981);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge-port {
    font-size: 0.75rem;
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.header-controls {
    display: flex;
    gap: 10px;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.08);
}

.btn-icon.active {
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

/* Stats HUD */
.stats-hud {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.hud-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform 0.2s ease;
}

.hud-card:hover {
    transform: translateY(-2px);
    border-color: rgba(16, 185, 129, 0.4);
}

.hud-icon {
    font-size: 1.8rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px;
    border-radius: var(--radius-sm);
}

.hud-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

.hud-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hud-value {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.hud-subvalue {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: 4px 0 2px 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #34d399, #10b981);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

/* Main Content Grid */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    min-height: 0; /* flex stretch fix */
}

/* Meadow Interactive Playground */
.meadow-section {
    position: relative;
    background: var(--meadow-bg-day);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.5), 0 12px 36px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    cursor: crosshair;
    touch-action: none;
}

/* Grid Pattern Overlay on Meadow */
.meadow-section::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        radial-gradient(circle at 15% 20%, rgba(16, 185, 129, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(52, 211, 153, 0.12) 0%, transparent 40%),
        linear-gradient(var(--meadow-grid-day) 1px, transparent 1px),
        linear-gradient(90deg, var(--meadow-grid-day) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
    pointer-events: none;
}

.meadow-overlay-hint {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 8px 18px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: #a7f3d0;
    pointer-events: none;
    z-index: 10;
}

/* Particle Layer & Bamboo Targets */
.particle-layer, .target-queue {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* Bamboo Target Sprout */
.bamboo-target {
    position: absolute;
    width: 36px;
    height: 48px;
    transform: translate(-50%, -100%);
    animation: sproutPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 6;
}

.bamboo-target .ripple {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    animation: rippleExpand 1s infinite ease-out;
}

.bamboo-stalk {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4));
}

/* Panda Container & Sprite */
.panda-container {
    position: absolute;
    width: 120px;
    height: 120px;
    margin-left: -60px;
    margin-top: -60px;
    z-index: 20;
    transition: transform 0.1s linear;
    will-change: left, top, transform;
}

.panda-sprite {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Panda Animations based on State */
.panda-container.idle .panda-sprite {
    animation: idleBreathe 3s infinite ease-in-out;
}

.panda-container.walking .panda-sprite {
    animation: waddleWalk 0.35s infinite alternate ease-in-out;
}

.panda-container.rolling .panda-sprite {
    animation: rollTumble 0.5s infinite linear;
}

.panda-container.eating .panda-sprite {
    animation: eatChew 0.4s infinite alternate ease-in-out;
}

.panda-container.happy .panda-sprite {
    animation: happyJump 0.5s 2 ease-in-out;
}

/* Facing Right vs Facing Left Flip (Flip sprite & accessories only, keep bubble upright) */
.panda-container.facing-left .panda-sprite,
.panda-container.facing-left .accessory {
    transform: scaleX(-1);
}

.panda-container.facing-right .panda-sprite,
.panda-container.facing-right .accessory {
    transform: scaleX(1);
}

/* Accessories positioning */
.accessory {
    position: absolute;
    pointer-events: none;
    z-index: 25;
    transition: opacity 0.2s ease;
}

.accessory.hidden {
    display: none;
}

.accessory.hat {
    top: -24px;
    left: 25px;
}

.accessory.glasses {
    top: 36px;
    left: 30px;
}

.accessory.cape {
    top: 55px;
    left: -15px;
}

.hero-cape {
    width: 45px;
    height: 65px;
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    border-radius: 4px 20px 20px 20px;
    transform: rotate(-15deg);
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    animation: capeFlutter 0.6s infinite alternate ease-in-out;
}

.accessory.crown {
    top: -18px;
    left: 35px;
}

/* Emotion Bubble */
.panda-bubble {
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
    background: #ffffff;
    color: #0f172a;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    animation: bubblePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 30;
}

.panda-bubble.hidden {
    display: none;
}

.panda-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: #ffffff transparent transparent transparent;
}

/* Floating Heart / Bamboo Particles */
.floating-particle {
    position: absolute;
    font-size: 1.4rem;
    pointer-events: none;
    animation: floatUp 1.2s forwards ease-out;
    z-index: 35;
}

/* Sidebar Control Panel */
.sidebar-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
}

.panel-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel-card h3 {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 600;
}

/* Mode Buttons */
.mode-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.mode-btn.active {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--primary);
    color: #6ee7b7;
    box-shadow: 0 0 10px var(--primary-glow);
}

.mode-icon {
    font-size: 1.2rem;
}

/* Slider Controls */
.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-val {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 700;
}

.custom-slider {
    width: 100%;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Accessories Grid */
.accessories-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.acc-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.acc-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.acc-btn.active {
    background: rgba(245, 158, 11, 0.2);
    border-color: var(--accent);
    color: #fde047;
}

.acc-icon {
    font-size: 1.1rem;
}

/* Facts Card */
.facts-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(15, 23, 42, 0.7));
    border-color: rgba(16, 185, 129, 0.3);
}

.facts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fact-text {
    font-size: 0.85rem;
    color: #e2e8f0;
    line-height: 1.45;
    font-style: italic;
    min-height: 48px;
}

.btn-small {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid var(--primary);
    color: #a7f3d0;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: var(--primary);
    color: #042f2e;
}

/* Actions Card */
.actions-card {
    flex-direction: row;
    gap: 8px;
}

.btn-secondary {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

/* Keyframe Animations */
@keyframes idleBreathe {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-4px) scale(1.02, 0.98); }
}

@keyframes waddleWalk {
    0% { transform: rotate(-6deg) translateY(-4px); }
    100% { transform: rotate(6deg) translateY(0px); }
}

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

@keyframes eatChew {
    0% { transform: scale(1) translateY(0); }
    100% { transform: scale(1.08, 0.92) translateY(3px); }
}

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

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

@keyframes rippleExpand {
    0% { width: 10px; height: 4px; opacity: 1; }
    100% { width: 60px; height: 18px; opacity: 0; }
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(0.8); opacity: 1; }
    100% { transform: translateY(-40px) scale(1.4); opacity: 0; }
}

@keyframes bubblePop {
    0% { transform: translateX(-50%) scale(0.5); opacity: 0; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes capeFlutter {
    0% { transform: rotate(-12deg); }
    100% { transform: rotate(-22deg); }
}

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

/* Responsive adjustments for Mobile & Tablets */
@media (max-width: 768px) {
    .app-container {
        width: 100vw;
        height: 100dvh;
        padding: 8px;
        gap: 8px;
    }

    .main-header {
        padding: 8px 14px;
    }

    .brand-text h1 {
        font-size: 1.1rem;
    }

    .badge-port {
        font-size: 0.65rem;
        padding: 1px 6px;
    }

    .stats-hud {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .hud-card {
        padding: 8px 10px;
        gap: 8px;
    }

    .hud-icon {
        font-size: 1.3rem;
        padding: 4px;
    }

    .hud-value {
        font-size: 1rem;
    }

    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: 55dvh 1fr;
        gap: 8px;
        overflow-y: auto;
    }

    .meadow-section {
        min-height: 280px;
    }

    .meadow-overlay-hint {
        top: 8px;
        font-size: 0.75rem;
        padding: 6px 12px;
        width: 90%;
        text-align: center;
    }

    .sidebar-panel {
        gap: 8px;
    }

    .panel-card {
        padding: 10px;
    }

    .acc-btn, .mode-btn, .btn-secondary {
        min-height: 44px; /* Touch target friendly for fingers */
    }
}

@media (max-width: 480px) {
    .panda-container {
        width: 90px;
        height: 90px;
        margin-left: -45px;
        margin-top: -45px;
    }

    .panda-container .panda-sprite svg {
        width: 90px;
        height: 90px;
    }
}
