/* Fonts (Local CSP) */
@font-face {font-display: swap; font-family: 'Inter'; font-style: normal; font-weight: 400; src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2');}
@font-face {font-display: swap; font-family: 'Inter'; font-style: normal; font-weight: 700; src: url('/fonts/inter-v20-latin-700.woff2') format('woff2');}
@font-face {font-display: swap; font-family: 'Orbitron'; font-style: normal; font-weight: 600; src: url('/fonts/orbitron-v35-latin-600.woff2') format('woff2');}
@font-face {font-display: swap; font-family: 'Orbitron'; font-style: normal; font-weight: 700; src: url('/fonts/orbitron-v35-latin-700.woff2') format('woff2');}

:root {
    --bg-dark: #111827; --bg-panel: #1f2937; --accent-blue: #0ea5e9; --accent-green: #10b981; --accent-red: #ef4444; --text-light: #f3f4f6;
}

html, body { height: 100%; width: 100%; overflow: hidden; margin: 0; padding: 0; background-color: var(--bg-dark); color: var(--text-light); font-family: 'Inter', sans-serif; touch-action: none; user-select: none; }
.hidden { display: none !important; }

/* Menus & Nav */
.left-menu { width: 200px; height: 100vh; position: fixed; top: 0; left: 0; background: rgba(10, 10, 10, 0.9); z-index: 1001; font-family: 'Orbitron', sans-serif; display: flex; flex-direction: column; justify-content: center; padding: 0 20px; box-sizing: border-box; }
.left-menu ul { list-style: none; padding: 0; margin: 0; } .left-menu li { margin-bottom: 20px; }
.left-menu a { font-size: 26px; color: var(--accent-blue); text-decoration: none; display: block; transition: 0.3s; }
.left-menu a:hover { color: #fff; text-shadow: 0 0 8px var(--accent-blue); }
.mobile-header, .menu-overlay { display: none; }

/* Game Area */
.main-content-wrapper { margin-left: 200px; height: 100vh; display: flex; flex-direction: column; position: relative; }
.canvas-container { position: relative; flex-grow: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #000; }
canvas { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 0 20px rgba(0,0,0,0.8); }

/* In-Game HUD */
.game-hud { position: absolute; top: max(15px, env(safe-area-inset-top)); left: 15px; right: 15px; display: flex; justify-content: space-between; z-index: 10; pointer-events: none; }
.hud-box { background: rgba(17, 24, 39, 0.85); border: 2px solid var(--accent-blue); padding: 10px 20px; border-radius: 12px; font-family: 'Orbitron', sans-serif; font-size: 1.5rem; text-shadow: 2px 2px 0 #000; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.timeline-box { display: flex; gap: 5px; align-items: center; padding: 5px 15px; }
.ball-dot { width: 30px; height: 30px; border-radius: 50%; background: #374151; display: flex; align-items: center; justify-content: center; font-size: 1rem; font-weight: bold; }
.ball-dot.b-4 { background: var(--accent-blue); } .ball-dot.b-6 { background: var(--accent-green); } .ball-dot.b-w { background: var(--accent-red); }

/* Comic Text & Feedback Juice */
.comic-text { position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%); font-family: 'Orbitron', sans-serif; font-size: 5rem; font-weight: 900; color: #ffeb3b; -webkit-text-stroke: 3px #000; text-shadow: 4px 4px 0 #ef4444, 8px 8px 0 #000; z-index: 20; pointer-events: none; animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.feedback-text { position: absolute; top: 40%; left: 15%; font-family: 'Orbitron', sans-serif; font-size: 3rem; font-weight: 900; color: #fff; -webkit-text-stroke: 2px #000; text-shadow: 3px 3px 0 #000; z-index: 20; pointer-events: none; animation: floatUp 1s ease-out forwards; }
.feedback-perfect { color: #10b981; } .feedback-early { color: #f59e0b; } .feedback-late { color: #f59e0b; }
@keyframes popIn { 0% { transform: translate(-50%, -50%) scale(0.1) rotate(-15deg); opacity: 0; } 100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; } }
@keyframes floatUp { 0% { transform: translateY(0) scale(0.5); opacity: 0; } 20% { transform: translateY(-20px) scale(1.2); opacity: 1; } 100% { transform: translateY(-60px) scale(1); opacity: 0; } }

/* Controls */
.action-controls { position: absolute; bottom: max(20px, env(safe-area-inset-bottom)); left: 20px; right: 20px; display: flex; justify-content: space-between; align-items: flex-end; z-index: 10; gap: 10px; }
.swing-btn { flex: 1; max-width: 250px; padding: 20px; font-family: 'Orbitron', sans-serif; font-size: 1.5rem; font-weight: bold; background: rgba(255,255,255,0.1); border: 3px solid rgba(255,255,255,0.5); color: #fff; border-radius: 15px; backdrop-filter: blur(5px); cursor: pointer; transition: 0.1s; }
.swing-btn:active { background: rgba(255,255,255,0.3); transform: scale(0.95); }

.run-container { flex: 1; max-width: 300px; display: flex; flex-direction: column; gap: 5px; align-items: center; }
.run-btn { width: 100%; padding: 20px; font-family: 'Orbitron', sans-serif; font-size: 2rem; font-weight: bold; background: var(--accent-green); border: 4px solid #fff; color: #fff; border-radius: 15px; cursor: pointer; text-shadow: 2px 2px 0 #000; box-shadow: 0 8px 0 #047857; transition: 0.1s; animation: pulseRun 1s infinite alternate; }
.run-btn:active { transform: translateY(8px); box-shadow: 0 0 0 #047857; animation: none; }
@keyframes pulseRun { 0% { transform: scale(1); } 100% { transform: scale(1.05); } }
.run-risk-bar { width: 100%; height: 15px; background: #333; border: 2px solid #fff; border-radius: 10px; overflow: hidden; }
.risk-fill { height: 100%; width: 0%; background: var(--accent-red); transition: width 0.1s linear; }

/* Main Menu */
.full-screen-menu { position: absolute; inset: 0; background: rgba(17, 24, 39, 0.95); z-index: 100; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(10px); }
.menu-content { text-align: center; max-width: 500px; width: 90%; }
.menu-content h1 { font-family: 'Orbitron', sans-serif; font-size: 4rem; color: var(--accent-blue); margin: 0; text-shadow: 0 0 15px rgba(14, 165, 233, 0.6); line-height: 1; }
.subtitle { font-size: 1.2rem; color: #9ca3af; margin-bottom: 30px; }
.stats-box { display: flex; justify-content: space-around; background: var(--bg-panel); padding: 15px; border-radius: 10px; margin-bottom: 30px; border: 1px solid #374151; font-family: 'Orbitron', sans-serif; }
.stats-box strong { color: var(--accent-green); font-size: 1.5rem; display: block; }

.menu-buttons { display: flex; flex-direction: column; gap: 15px; }
.main-btn { padding: 15px; font-family: 'Orbitron', sans-serif; font-size: 1.3rem; font-weight: bold; border: none; border-radius: 10px; cursor: pointer; color: #fff; transition: 0.2s; }
.btn-blue { background: var(--accent-blue); box-shadow: 0 5px 0 #0284c7; }
.btn-green { background: var(--accent-green); box-shadow: 0 5px 0 #059669; }
.btn-dark { background: #4b5563; box-shadow: 0 5px 0 #374151; }
.main-btn:active { transform: translateY(5px); box-shadow: 0 0 0 transparent; }

/* Modals & Flash */
.flash-overlay { position: fixed; inset: 0; z-index: 999; pointer-events: none; opacity: 0; transition: opacity 0.2s ease-out; }
.flash-white { background: #fff; opacity: 1; transition: none; }
.flash-red { background: rgba(239, 68, 68, 0.5); opacity: 1; transition: none; }
.camera-shake { animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake { 10%, 90% { transform: translate3d(-5px, 0, 0); } 20%, 80% { transform: translate3d(5px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-10px, 0, 0); } 40%, 60% { transform: translate3d(10px, 0, 0); } }

.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 1002; animation: fadeIn 0.3s; }
.modal-content { background: var(--bg-panel); margin: 15vh auto; padding: 30px; border: 2px solid var(--accent-blue); width: 90%; max-width: 450px; border-radius: 15px; text-align: center; box-shadow: 0 0 30px rgba(14, 165, 233, 0.3); position: relative; }
.final-score-box { font-family: 'Orbitron', sans-serif; font-size: 5rem; font-weight: bold; color: var(--accent-green); text-shadow: 0 0 20px rgba(16, 185, 129, 0.5); line-height: 1; margin: 10px 0; }
.modal-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.modal-btn { padding: 12px 20px; font-family: 'Orbitron', sans-serif; font-weight: bold; border: none; border-radius: 8px; cursor: pointer; color: #fff; font-size: 1.1rem; }
.share-btn { background: var(--accent-blue); } .play-btn { background: #4b5563; }
.close-btn { position: absolute; top: 10px; right: 15px; font-size: 1.5rem; cursor: pointer; color: #9ca3af; }
.help-list { text-align: left; line-height: 1.6; margin-top: 20px; } .help-list li { margin-bottom: 10px; }

#toast { position: fixed; top: 10vh; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.9); color: white; padding: 12px 24px; border-radius: 8px; z-index: 1005; font-weight: bold; display: none; border: 1px solid var(--accent-blue); }

/* Mobile Layout */
@media (max-width: 768px) {
    .left-menu { transform: translateX(-100%); transition: 0.3s; width: 250px; }
    .left-menu.menu-open { transform: translateX(0); }
    .menu-overlay.menu-open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; }
    .mobile-header { display: flex; align-items: center; justify-content: space-between; padding: 0 15px; height: 60px; background: rgba(17, 24, 39, 0.9); border-bottom: 1px solid #374151; position: absolute; top: 0; width: 100%; z-index: 100; box-sizing: border-box; }
    .hamburger-btn { background: none; border: none; color: #fff; font-size: 1.5rem; }
    .mobile-title { font-family: 'Orbitron', sans-serif; font-size: 1.5rem; color: var(--accent-blue); }
    .main-content-wrapper { margin-left: 0; padding-top: 60px; }
    .game-hud { top: max(70px, env(safe-area-inset-top)); }
    .hud-box { padding: 5px 10px; font-size: 1.1rem; }
    .action-controls { gap: 5px; bottom: max(10px, env(safe-area-inset-bottom)); left: 5px; right: 5px;}
    .swing-btn { padding: 15px 5px; font-size: 1.1rem; border-width: 2px; }
    .run-btn { padding: 10px; font-size: 1.5rem; border-width: 2px; box-shadow: 0 5px 0 #047857; }
    .menu-content h1 { font-size: 2.5rem; }
    .feedback-text { left: 50%; transform: translateX(-50%); text-align: center; width: 100%; font-size: 2rem;}
}