/* CSS RESET & BASE VARIABLES */
:root {
    --primary-color: #ff6b35;
    --primary-hover: #ff8552;
    --secondary-color: #4ecdc4;
    --accent-color: #ffe66d;
    --danger-color: #ff2a6d;
    --bg-dark: rgba(15, 23, 42, 0.85);
    --card-bg: rgba(30, 41, 59, 0.75);
    --glass-border: rgba(255, 255, 255, 0.15);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --radius-lg: 20px;
    --radius-md: 12px;
    --font-heading: 'Fredoka One', cursive, sans-serif;
    --font-body: 'Outfit', sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #0d1b2a;
    font-family: var(--font-body);
    color: var(--text-main);
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* UI OVERLAY LAYER */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    z-index: 10;
}

/* TOP HUD */
#top-hud {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
    gap: 15px;
}

.hud-card {
    background: var(--bg-dark);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 12px 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    pointer-events: auto;
    transition: all 0.3s ease;
}

.player-card {
    display: flex;
    align-items: center;
    gap: 12px;
}

.p1-card {
    border-left: 4px solid #ff9f43;
}

.p2-card {
    border-left: 4px solid #54a0ff;
}

.avatar {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.1);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.player-info {
    display: flex;
    flex-direction: column;
}

.player-name {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.carrot-score {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: var(--accent-color);
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.stamina-bar-container {
    width: 100px;
    height: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
    margin-top: 4px;
}

.stamina-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #10ac84, #1dd1a1);
    border-radius: 6px;
    transition: width 0.1s linear, background-color 0.3s ease;
}

.stamina-bar-fill.low {
    background: linear-gradient(90deg, #ff6b6b, #ee5253);
}

.game-status-card {
    text-align: center;
    min-width: 240px;
}

.status-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--primary-color);
}

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

/* BEAR WARNING BANNER */
#bear-warning-banner {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(238, 82, 83, 0.95), rgba(255, 107, 107, 0.95));
    border: 2px solid #ff6b6b;
    border-radius: var(--radius-lg);
    padding: 16px 32px;
    text-align: center;
    box-shadow: 0 0 30px rgba(238, 82, 83, 0.8);
    animation: pulseWarning 1s infinite alternate;
    pointer-events: none;
    z-index: 20;
}

#bear-warning-banner.hidden {
    display: none;
}

@keyframes pulseWarning {
    0% { transform: translateX(-50%) scale(0.98); box-shadow: 0 0 20px rgba(238, 82, 83, 0.5); }
    100% { transform: translateX(-50%) scale(1.04); box-shadow: 0 0 40px rgba(255, 0, 0, 0.9); }
}

.warning-icon {
    font-size: 1.8rem;
}

.warning-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: #fff;
    letter-spacing: 1px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.7);
}

.warning-text {
    font-weight: 800;
    font-size: 0.9rem;
    color: #ffeaa7;
    margin-top: 4px;
}

/* RADAR MINI-MAP */
#radar-container {
    position: absolute;
    bottom: 25px;
    right: 25px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    padding: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
}

#radar-canvas {
    border-radius: 50%;
    background: radial-gradient(circle, #1e293b 0%, #0f172a 100%);
}

.radar-label {
    position: absolute;
    bottom: -18px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--secondary-color);
    background: rgba(15, 23, 42, 0.9);
    padding: 2px 8px;
    border-radius: 8px;
}

/* CONTROLS HINT */
#controls-hint {
    position: absolute;
    bottom: 25px;
    left: 25px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--bg-dark);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 12px;
}

.hint-item {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.key {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    padding: 2px 6px;
    font-weight: bold;
    color: var(--accent-color);
    font-size: 0.75rem;
    box-shadow: 0 2px 0 rgba(0,0,0,0.3);
}

/* MODAL OVERLAYS & MENUS */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 30, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.4s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-card {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 28px;
    padding: 36px;
    width: 90%;
    max-width: 520px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    text-align: center;
    animation: modalAppear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalAppear {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.game-logo {
    margin-bottom: 24px;
}

.logo-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 8px;
}

.game-logo h1 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    background: linear-gradient(135deg, #ff9f43, #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

.tagline {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.mode-selector {
    margin-bottom: 24px;
}

.mode-selector h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.menu-sections {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mode-buttons.horizontal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mode-buttons.horizontal .btn {
    padding: 12px 12px;
    justify-content: center;
}

.btn {
    border: none;
    border-radius: var(--radius-md);
    padding: 14px 20px;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    outline: none;
}

.btn-primary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 2px solid transparent;
}

.btn-primary:hover, .btn-primary.active {
    background: rgba(255, 107, 53, 0.2);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 2px solid transparent;
}

.btn-secondary:hover, .btn-secondary.active {
    background: rgba(78, 205, 196, 0.2);
    border-color: var(--secondary-color);
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 1.5rem;
}

.btn-title {
    display: block;
    font-size: 1.1rem;
    font-weight: 800;
}

.btn-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

.controls-overview {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 24px;
    display: flex;
    gap: 12px;
    justify-content: space-around;
}

.player-controls-card {
    font-size: 0.8rem;
    text-align: left;
}

.player-controls-card h4 {
    color: var(--accent-color);
    margin-bottom: 6px;
}

.player-controls-card p {
    color: var(--text-muted);
    margin-bottom: 2px;
}

.btn-start {
    width: 100%;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), #ee5253);
    color: white;
    font-family: var(--font-heading);
    font-size: 1.3rem;
    padding: 16px;
    border-radius: 50px;
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.5);
}

.btn-start:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 30px rgba(255, 107, 53, 0.7);
}

/* END GAME MODAL */
.end-icon {
    font-size: 4rem;
    margin-bottom: 12px;
}

.end-card h2 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    color: var(--danger-color);
    margin-bottom: 8px;
}

#end-message {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.stats-summary {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 28px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--accent-color);
    margin-top: 4px;
}

.end-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* AUDIO BUTTON */
.audio-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-dark);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    transition: transform 0.2s ease;
}

.audio-btn:hover {
    transform: scale(1.1);
}

/* MOBILE CONTROLS */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }
    
    #controls-hint {
        display: none;
    }

    #mobile-controls {
        position: absolute;
        bottom: 25px;
        left: 20px;
        right: 20px;
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        pointer-events: auto;
    }

    #joystick-zone {
        width: 120px;
        height: 120px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.1);
        border: 2px solid rgba(255, 255, 255, 0.25);
        position: relative;
        touch-action: none;
    }

    #joystick-knob {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: var(--primary-color);
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    }

    .action-btn {
        background: linear-gradient(135deg, var(--secondary-color), #0abde3);
        color: white;
        border: none;
        padding: 16px 24px;
        border-radius: 30px;
        font-weight: 800;
        font-size: 1rem;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    }
}
