/* Local Fonts for Strict CSP */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    src: url('/fonts/inter-v20-latin-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    src: url('/fonts/inter-v20-latin-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    src: url('/fonts/inter-v20-latin-700.woff2') format('woff2');
}
@font-face {
    font-family: 'Orbitron';
    font-style: normal;
    font-weight: 400;
    src: url('/fonts/orbitron-v35-latin-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Orbitron';
    font-style: normal;
    font-weight: 700;
    src: url('/fonts/orbitron-v35-latin-700.woff2') format('woff2');
}
/* Ensure emoji icons fit cleanly */
.icon-btn { font-size: 1.5rem; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.modal-btn { display: flex; align-items: center; justify-content: center; gap: 8px; }

:root { 
    --accent-color: #00C9FF; --bg-main: #1a202c; --bg-container: #2d3748; --border-color: #4a5568; 
    --text-color: #e2e8f0; --text-muted: #a0aec0; --correct-bg: #48bb78; --error-bg: #f56565;
    --dist-hot: #ff4d4d; --dist-warm: #ffb84d; --dist-cold: #66ccff;
}
html, body { height: 100%; width: 100%; overflow: hidden; margin: 0; padding: 0; overscroll-behavior: contain; }
body { font-family: 'Inter', sans-serif; background-color: var(--bg-main); color: var(--text-color); }
body.menu-open { overflow: hidden; }

/* Screen Flashes */
.flash-overlay { position: fixed; inset: 0; z-index: 999; pointer-events: none; opacity: 0; transition: opacity 0.2s ease-out; }
.flash-green { background: rgba(72, 187, 120, 0.3); opacity: 1; transition: none; }
.flash-red { background: rgba(245, 101, 101, 0.3); opacity: 1; transition: none; }

/* Menus */
.left-menu { width: 200px; min-width: 200px; height: 100vh; position: fixed; top: 0; left: 0; background: rgba(10, 10, 10, 0.85); box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3); padding: 0 20px; z-index: 1001; font-family: 'Orbitron', sans-serif; font-weight: 600; display: flex; flex-direction: column; justify-content: center; }
.left-menu ul { list-style: none; padding: 0; margin: 0; } .left-menu li { margin-bottom: 20px; }
.left-menu a { font-size: 30px; font-weight: normal; color: #00C9FF; text-shadow: 0 0 2px #00C9FF, 0 0 3px rgba(0, 201, 255, 0.6); text-decoration: none; display: block; padding: 8px 0; transition: all 0.3s ease; }
.left-menu a:hover, .left-menu a:focus  { color: #fff; text-shadow: 0 0 6px #fff, 0 0 8px rgba(255, 255, 255, 0.5); outline: none; }
.left-menu a.active-page-link { color: #fff; text-shadow: 0 0 8px #fff, 0 0 12px rgba(255, 255, 255, 0.7); background-color: rgba(0, 190, 255, 0.1); border-radius: 5px; padding-left: 10px; padding-right: 10px; }

.mobile-header, .menu-overlay { display: none; }

/* Layout */
.main-content-wrapper { margin-left: 200px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; box-sizing: border-box; height: 100%; width: calc(100% - 200px); }
.breadcrumbs { width: 100%; max-width: 600px; margin-bottom: 0rem; padding: 0 1rem; box-sizing: border-box; } 
.breadcrumbs ol { display: flex; list-style: none; padding: 0; margin: 0; font-size: 0.9rem; color: var(--text-muted); } 
.breadcrumbs li:not(:last-child)::after { content: '>'; margin: 0 0.75rem; } 
.breadcrumbs a { color: var(--text-muted); text-decoration: none; } 
.breadcrumbs a:hover { color: var(--accent-color); }

.header-bar { width: 100%; max-width: 600px; display: flex; justify-content: space-between; align-items: center; padding: 1rem; box-sizing: border-box; border-bottom: 1px solid var(--border-color); flex-shrink: 0;}
.header-bar h1 { color: var(--accent-color); font-family: 'Orbitron', sans-serif; text-shadow: 0 0 5px var(--accent-color); font-size: 2em; margin: 0; flex-grow: 1; text-align: center; }
.icon-btn { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; transition: color 0.2s; width: 44px; height: 44px; }
.icon-btn:hover { color: var(--accent-color); }

/* Mode Selector */
.mode-selector { display: flex; background: var(--bg-container); border-radius: 8px; margin: 10px 0; overflow: hidden; border: 1px solid var(--border-color); }
.mode-btn { background: none; border: none; color: var(--text-muted); padding: 8px 15px; font-size: 0.9rem; font-weight: 600; cursor: pointer; font-family: 'Orbitron', sans-serif; transition: 0.2s; }
.mode-btn.active { background: var(--accent-color); color: var(--bg-main); }

/* Time Attack HUD */
#time-attack-hud { display: flex; gap: 20px; font-family: 'Orbitron', sans-serif; font-size: 1.5rem; margin-bottom: 10px; }
.time-box { color: var(--error-bg); font-weight: bold; }
.score-box { color: var(--correct-bg); font-weight: bold; }

.game-container { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 600px; padding: 1rem; box-sizing: border-box; flex-grow: 1; overflow-y: auto; transition: filter 0.3s ease, opacity 0.3s ease; }
.game-container.game-over { filter: blur(2px); opacity: 0.7; pointer-events: none; }

/* Flag Grid */
.flag-container { width: 300px; height: 200px; position: relative; margin-bottom: 1.5rem; box-shadow: 0 5px 15px rgba(0,0,0,0.3); background-color: var(--bg-container); display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); perspective: 1000px; }
.flag-piece { width: 100%; height: 100%; position: relative; transition: transform 0.6s; transform-style: preserve-3d; }
.flag-piece.flipped { transform: rotateY(180deg); }
.flag-piece .front, .flag-piece .back { width: 100%; height: 100%; position: absolute; backface-visibility: hidden; background-size: 300% 200%; }
.flag-piece .front { background: var(--bg-container); }
.flag-piece .back { transform: rotateY(180deg); }

/* Inputs */
.input-container { position: relative; width: 100%; max-width: 400px; margin-bottom: 1.5rem; }
#guess-input { width: 100%; padding: 0.75rem; font-size: 1.1rem; border-radius: 0.5rem; border: 2px solid var(--border-color); background-color: var(--bg-main); color: var(--text-color); box-sizing: border-box; padding-right: 45px; transition: border-color 0.2s ease; }
#guess-input:focus { outline: none; border-color: var(--accent-color); }
#guess-input.invalid { border-color: var(--error-bg); }
#giveUpBtn { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; padding: 5px 10px; }
#giveUpBtn:hover { color: var(--error-bg); }
#playAgainBtn { width: 100%; max-width: 400px; padding: 0.75rem; font-family: 'Orbitron', sans-serif; font-size: 1.2rem; font-weight: 700; background-color: var(--correct-bg); color: white; border: none; border-radius: 0.5rem; cursor: pointer; display: none; margin-top: 10px; }

/* Autocomplete */
#autocomplete-list { position: absolute; width: 100%; background-color: var(--bg-container); border: 1px solid var(--border-color); border-top: none; z-index: 10; max-height: 180px; overflow-y: auto; border-bottom-left-radius: 0.5rem; border-bottom-right-radius: 0.5rem;}
.autocomplete-item { padding: 10px; cursor: pointer; }
.autocomplete-item:hover, .autocomplete-item.active { background-color: var(--border-color); }

/* Animations */
.input-container.shake { animation: shake 0.5s; } 
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

/* Guesses */
.guesses-container { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 0.5rem; }
.guess-row { display: flex; align-items: center; justify-content: space-between; background-color: var(--bg-container); padding: 0.5rem 1rem; border-radius: 0.5rem; animation: slideIn 0.3s ease-out; transition: opacity 0.3s ease; }
.guesses-container .guess-row:not(:last-child) { opacity: 0.6; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.guess-row .name { flex-grow: 1; display: inline-block; font-weight: 600; }
.guess-row .distance { min-width: 100px; text-align: right; margin-right: 1rem; font-weight: bold; }
.guess-row .direction { font-size: 1.5rem; }
.guess-row.win .name span { display: inline-block; animation: wave 0.5s ease-out both; color: var(--correct-bg);}

/* Hot & Cold Colors */
.distance.hot { color: var(--dist-hot); text-shadow: 0 0 5px rgba(255, 77, 77, 0.4); }
.distance.warm { color: var(--dist-warm); }
.distance.cold { color: var(--dist-cold); }

@keyframes wave { 0%, 100% { transform: translateY(0); } 25% { transform: translateY(-8px); } 75% { transform: translateY(5px); } }

/* Modals */
.modal { display: none; position: fixed; z-index: 1002; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.7); animation: fadeIn 0.3s; }
.modal-content { background-color: var(--bg-container); margin: 15% auto; padding: 2rem; border: 1px solid var(--border-color); width: 90%; max-width: 450px; border-radius: 1rem; text-align: center; }
.modal h2 { margin-top: 0; font-family: 'Orbitron', sans-serif; }
.modal h2.win { color: var(--correct-bg); }
.modal h2.loss { color: var(--error-bg); }
.close-btn { float: right; cursor: pointer; font-size: 1.5rem; line-height: 1; color: var(--text-muted); }
.modal-buttons { display: flex; gap: 1rem; justify-content: center; margin-top: 1.5rem; }
.modal-btn { font-family: 'Orbitron', sans-serif; border: none; padding: 0.75rem 1.5rem; border-radius: 0.5rem; cursor: pointer; font-size: 1rem; font-weight: 600; }
#copyResultsBtn { background-color: var(--accent-color); color: var(--bg-main); }
#playAgainModalBtn { background-color: var(--correct-bg); color: white; }
#toast { position: fixed; top: 10vh; left: 50%; transform: translateX(-50%); background-color: rgba(0,0,0,0.8); color: white; padding: 12px 24px; border-radius: 8px; z-index: 1005; font-weight: bold; display: none; animation: fade-in-out 3s; }
@keyframes fade-in-out { 0%, 100% { opacity: 0; } 10%, 90% { opacity: 1; } }
#confetti-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1003; pointer-events: none; }

/* Stats & Help Specific */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin: 1.5rem 0; }
.stat-item { text-align: center; } .stat-item .value { font-size: 2rem; font-weight: bold; } .stat-item .label { color: var(--text-muted); font-size: 0.9rem; }
.distribution-graph { margin-top: 1rem; } 
.dist-row { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; } 
.dist-label { width: 20px; }
.dist-bar { flex-grow: 1; background-color: var(--border-color); text-align: right; padding: 2px 8px; border-radius: 3px; color: white; font-weight: bold; min-width: 20px; }
.dist-bar.highlight { background-color: var(--correct-bg); }
.example-guess-row { display: flex; align-items: center; justify-content: space-between; background-color: var(--bg-main); padding: 0.5rem 1rem; border-radius: 0.5rem; margin-top: 0.5rem; border: 1px solid var(--border-color); }
.help-list { text-align: left; padding-left: 20px; margin-bottom: 10px; }
.help-p { margin-top: 1rem; margin-bottom: 5px; text-align: left;}

/* Mobile */
@media (max-width: 768px) { 
    .left-menu { transform: translateX(-100%); transition: transform 0.3s ease-in-out; width: 250px; min-width: 250px; }
    .left-menu.menu-open { transform: translateX(0); }
    .menu-overlay { display: block; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
    .menu-overlay.menu-open { opacity: 1; pointer-events: auto; }
    .mobile-header { display: flex; align-items: center; justify-content: space-between; padding: 0 1rem; height: 60px; background-color: var(--bg-main); border-bottom: 1px solid var(--border-color); position: fixed; top: 0; left: 0; width: 100%; z-index: 100; box-sizing: border-box; }
    .hamburger-btn { background: none; border: none; padding: 10px; cursor: pointer; color: var(--text-color); font-size: 1.5rem; }
    .mobile-title { font-family: 'Orbitron', sans-serif; font-size: 1.5rem; color: var(--accent-color); }
    .main-content-wrapper { margin-left: 0; width: 100%; padding-top: 60px; height: calc(100% - 60px); }
    .breadcrumbs { display: none; }
    .header-bar { display: none; }
    .game-container { padding: 1rem; justify-content: flex-start; }
    .flag-container { width: 85vw; height: calc(85vw * 2 / 3); max-width: 300px; max-height: 200px;}
}