@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;500;700&display=swap');

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

:root {
    --mars-green: #00C851;
    --mars-green-light: #00ff6a;
    --mars-green-dark: #008a35;
    --neon-purple: #9d00ff;
    --neon-pink: #ff00d4;
    --dark-bg: #f5f5f5;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(0, 200, 81, 0.5);
}

body {
    font-family: 'Rajdhani', sans-serif;
    background: var(--dark-bg);
    overflow: hidden;
    touch-action: none;
    color: #333;
}

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

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

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 100;
}

#score-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#score-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: var(--mars-green);
    letter-spacing: 4px;
    text-shadow: 0 0 10px var(--mars-green);
}

#score-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 48px;
    font-weight: 900;
    color: #fff;
    text-shadow: 
        0 0 10px var(--mars-green),
        0 0 20px var(--mars-green),
        0 0 40px var(--mars-green);
    line-height: 1;
}

#high-score {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 2px;
}

#high-score-value {
    color: var(--neon-purple);
    text-shadow: 0 0 10px var(--neon-purple);
}

/* Pause Button */
.pause-btn {
    position: absolute;
    top: 20px;
    right: 50%;
    transform: translateX(50%);
    width: 50px;
    height: 50px;
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    background: rgba(0, 200, 81, 0.1);
    backdrop-filter: blur(10px);
    color: var(--mars-green);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pause-btn:hover {
    background: rgba(0, 200, 81, 0.3);
    box-shadow: 0 0 20px var(--mars-green);
    transform: translateX(50%) scale(1.1);
}

.pause-btn:active {
    transform: translateX(50%) scale(0.95);
}

/* Touch Hint for Mobile */
.touch-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    color: var(--mars-green);
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
    font-weight: 500;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    letter-spacing: 1px;
}

.touch-hint.visible {
    opacity: 1;
}

.swipe-icon {
    font-size: 18px;
    animation: swipeHint 1.5s ease-in-out infinite;
}

@keyframes swipeHint {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(5px); }
}

/* Show touch hint only on touch devices when playing */
@media (hover: none) and (pointer: coarse) {
    .touch-hint.visible {
        opacity: 0.8;
    }
}

/* Overlays */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

.menu-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 50px 60px;
    text-align: center;
    box-shadow: 
        0 10px 60px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.overlay.active .menu-panel {
    transform: scale(1);
}

.game-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 72px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--mars-green), var(--neon-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    letter-spacing: 8px;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 20px rgba(0, 200, 81, 0.5));
}

.subtitle {
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;
    color: rgba(0, 0, 0, 0.6);
    letter-spacing: 6px;
    margin-bottom: 40px;
    text-transform: uppercase;
}

.menu-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 42px;
    font-weight: 700;
    color: #ff4757;
    letter-spacing: 6px;
    margin-bottom: 30px;
    text-shadow: 
        0 0 10px #ff4757,
        0 0 20px #ff4757;
}

.menu-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 3px;
    padding: 18px 50px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.menu-btn.primary {
    background: linear-gradient(135deg, var(--mars-green), var(--neon-purple));
    color: #000;
    box-shadow: 
        0 4px 30px rgba(0, 200, 81, 0.4),
        0 0 60px rgba(0, 200, 81, 0.2);
}

.menu-btn.primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 6px 40px rgba(0, 200, 81, 0.6),
        0 0 80px rgba(0, 200, 81, 0.3);
}

.menu-btn.primary:active {
    transform: translateY(0) scale(0.98);
}

.menu-btn.secondary {
    background: transparent;
    border: 2px solid var(--mars-green);
    color: var(--mars-green);
    margin-top: 15px;
}

.menu-btn.secondary:hover {
    background: rgba(0, 200, 81, 0.2);
    box-shadow: 0 0 30px rgba(0, 200, 81, 0.3);
}

.menu-btn.tertiary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    padding: 12px 30px;
    margin-top: 15px;
}

.menu-btn.tertiary:hover {
    border-color: rgba(255, 255, 255, 0.6);
    color: #fff;
}

/* Mode Selector */
.mode-selector {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mode-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: var(--mars-green);
    letter-spacing: 3px;
    margin-bottom: 5px;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 30px;
    gap: 5px;
}

.mode-icon {
    font-size: 28px;
    margin-bottom: 5px;
}

.mode-text {
    font-size: 18px;
    font-weight: 700;
}

.mode-desc {
    font-size: 11px;
    color: rgba(0, 0, 0, 0.5);
    font-weight: 400;
    letter-spacing: 1px;
}

.pov-btn {
    background: linear-gradient(135deg, #ff6b35, #ff4757);
    box-shadow: 
        0 4px 30px rgba(255, 107, 53, 0.4),
        0 0 60px rgba(255, 71, 87, 0.2);
}

.pov-btn:hover {
    box-shadow: 
        0 6px 40px rgba(255, 107, 53, 0.6),
        0 0 80px rgba(255, 71, 87, 0.3);
}

/* Safety Game Over Panel */
.safety-panel {
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
}

.incident-badge {
    background: linear-gradient(135deg, #ff4757, #ff6b35);
    color: white;
    padding: 10px 25px;
    border-radius: 30px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 2px;
    display: inline-block;
    margin-bottom: 15px;
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 71, 87, 0.5); }
    50% { transform: scale(1.05); box-shadow: 0 0 30px rgba(255, 71, 87, 0.8); }
}

.safety-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    color: #ff4757;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(255, 71, 87, 0.5);
}

.safety-content {
    text-align: left;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.safety-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: 15px;
}

.safety-section {
    margin-bottom: 15px;
}

.safety-section:last-child {
    margin-bottom: 0;
}

.safety-section h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: var(--mars-green);
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.safety-section p {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

.safety-section ul {
    margin: 0;
    padding-left: 20px;
}

.safety-section li {
    font-size: 13px;
    line-height: 1.6;
    color: #444;
    margin-bottom: 5px;
}

.normative-ref {
    font-weight: 700;
    color: #666;
    font-size: 12px !important;
}

.safety-score {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    color: var(--mars-green);
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0, 200, 81, 0.1);
    border-radius: 8px;
}

.safety-score strong {
    font-size: 20px;
}

/* POV Mobile UI */
.pov-indicator {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    z-index: 100;
    pointer-events: none;
}

.direction-arrow {
    font-size: 32px;
    color: var(--mars-green);
    text-shadow: 0 0 10px var(--mars-green);
    transition: transform 0.2s ease;
}

.direction-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 2px;
}

/* POV Radar (mini-map) */
.pov-radar {
    position: absolute;
    top: 80px;
    right: 20px;
    width: 80px;
    height: 80px;
    z-index: 100;
    pointer-events: none;
}

.radar-container {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--mars-green);
    background: rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.radar-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: var(--mars-green);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--mars-green);
}

.radar-fruit {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #ff00d4;
    border-radius: 50%;
    box-shadow: 0 0 8px #ff00d4;
    display: none;
}

.radar-hazard {
    position: absolute;
    width: 5px;
    height: 5px;
    background: #ff4757;
    border-radius: 50%;
    box-shadow: 0 0 6px #ff4757;
}

/* Comfort settings panel */
.comfort-settings {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 25px;
    z-index: 300;
    display: none;
    min-width: 280px;
}

.comfort-settings.active {
    display: block;
}

.comfort-settings h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    color: var(--mars-green);
    margin-bottom: 20px;
    text-align: center;
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item label {
    display: block;
    font-size: 12px;
    margin-bottom: 8px;
    color: #333;
}

.setting-item input[type="range"] {
    width: 100%;
}

.setting-value {
    text-align: right;
    font-size: 11px;
    color: #666;
}

/* Statistics Panel */
.stats-panel {
    max-width: 500px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.stat-item {
    background: rgba(0, 200, 81, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
}

.stat-number {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 32px;
    font-weight: 900;
    color: var(--mars-green);
    text-shadow: 0 0 10px var(--mars-green);
}

.stat-label {
    display: block;
    font-size: 11px;
    color: #666;
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stats-section {
    text-align: left;
    margin: 20px 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
}

.stats-section h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: var(--mars-green);
    margin-bottom: 10px;
}

.stats-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.stats-list li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 13px;
    display: flex;
    justify-content: space-between;
}

.stats-list li:last-child {
    border-bottom: none;
}

.hazard-count {
    font-weight: 700;
    color: #ff4757;
}

.stats-actions {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.stats-actions .menu-btn {
    flex: 1;
    padding: 12px 20px;
    font-size: 12px;
}

/* Pause menu specific */
.pause-score {
    margin-bottom: 30px;
}

#pause-score-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 48px;
    font-weight: 900;
    color: var(--mars-green);
    text-shadow: 
        0 0 10px var(--mars-green),
        0 0 20px var(--mars-green);
}

.controls-hint {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.controls-hint p {
    color: rgba(0, 0, 0, 0.5);
    font-size: 14px;
    margin: 8px 0;
    letter-spacing: 1px;
}

.final-score {
    margin-bottom: 30px;
}

.score-label-final {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 4px;
    margin-bottom: 10px;
}

#final-score-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 64px;
    font-weight: 900;
    color: var(--neon-cyan);
    text-shadow: 
        0 0 10px var(--neon-cyan),
        0 0 20px var(--neon-cyan),
        0 0 40px var(--neon-cyan);
}

/* Animation keyframes */
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 20px var(--mars-green); }
    50% { box-shadow: 0 0 40px var(--mars-green), 0 0 60px var(--neon-purple); }
}

/* Device-specific styles - Mobile */
body.device-mobile #hud {
    padding: 15px 20px;
    /* Supporto safe area per notch/dynamic island */
    padding-top: max(15px, env(safe-area-inset-top));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}

body.device-mobile #score-value {
    font-size: 42px;
}

body.device-mobile #score-label {
    font-size: 10px;
    letter-spacing: 3px;
}

body.device-mobile #high-score {
    font-size: 12px;
}

body.device-mobile .pause-btn {
    width: 60px;
    height: 60px;
    font-size: 24px;
    top: 15px;
    /* Supporto safe area per notch */
    top: max(15px, env(safe-area-inset-top));
}

body.device-mobile .touch-hint {
    font-size: 12px;
    padding: 10px 18px;
    bottom: max(20px, env(safe-area-inset-bottom));
}

/* Device-specific styles - Desktop */
body.device-desktop .pause-btn {
    width: 50px;
    height: 50px;
    font-size: 20px;
}

/* Responsive base */
@media (max-width: 768px) {
    .game-title {
        font-size: 48px;
        letter-spacing: 4px;
    }
    
    .menu-panel {
        padding: 40px 30px;
        margin: 20px;
    }
    
    .menu-btn {
        padding: 16px 40px;
        font-size: 14px;
    }
}

/* Landscape mobile optimization */
@media (max-width: 896px) and (orientation: landscape) {
    body.device-mobile #hud {
        padding: 10px 15px;
    }
    
    body.device-mobile #score-value {
        font-size: 32px;
    }
    
    body.device-mobile .pause-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
}
