/* Self-hosted Font Definitions */
@font-face {font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2');}
@font-face {font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/inter-v20-latin-600.woff2') format('woff2');}
@font-face {font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/inter-v20-latin-700.woff2') format('woff2');}
@font-face {font-family: 'Orbitron'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/orbitron-v35-latin-400.woff2') format('woff2');}
@font-face {font-family: 'Orbitron'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/orbitron-v35-latin-700.woff2') format('woff2');}

:root { 
    --menu-width: 200px; 
    --accent-color: #00C9FF; 
    --bg-main: #1a202c; 
    --bg-card: #2d3748; 
    --border-color: #4a5568; 
    --text-color: #e2e8f0; 
    --text-muted: #a8b5c7; 
    --key-bg: #4a5568; 
    --correct-bg: #48bb78; 
    --present-bg: #ecc94b; 
    --absent-bg: #3a4454; 
}

html, body { height: 100%; width: 100%; overflow-x: hidden; margin: 0; padding: 0; }
body { 
    font-family: 'Inter', sans-serif; 
    background-color: var(--bg-main); 
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10"><rect width="10" height="10" fill="%231a202c"/><path d="M0 0L10 10M10 0L0 10" stroke="%232d3748" stroke-width="0.2"/></svg>'); 
    color: var(--text-color); 
    display: flex; flex-direction: row; 
}

/* Sidebar Menu */
.left-menu { width: var(--menu-width); min-width: var(--menu-width); height: 100vh; position: fixed; top: 0; left: 0; background: rgba(10, 10, 10, 0.9); box-shadow: 2px 0 5px rgba(0, 0, 0, 0.3); padding: 0 20px; box-sizing: border-box; z-index: 1001; font-family: 'Orbitron', sans-serif; font-weight: 600; display: flex; flex-direction: column; justify-content: center; overflow-y: auto; }
.left-menu ul { list-style: none; padding: 0; margin: 0; } 
.left-menu li { margin-bottom: 20px; }
.left-menu a { font-size: 24px; font-weight: normal; color: var(--accent-color); text-shadow: 0 0 2px var(--accent-color), 0 0 3px rgba(0, 201, 255, 0.6); text-decoration: none; display: block; padding: 8px 0; transition: color 0.3s ease, text-shadow 0.3s ease, background-color 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; }

/* Main Area */
.mobile-header, .menu-overlay { display: none; }
.main-content-wrapper { flex-grow: 1; padding-left: calc(var(--menu-width) + 20px); padding-right: 20px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; box-sizing: border-box; width: calc(100% - var(--menu-width)); }

.header-bar { width: 100%; max-width: 500px; display: flex; justify-content: space-between; align-items: center; margin: 1rem 0; }
.header-bar h1 { color: var(--accent-color); font-family: 'Orbitron', sans-serif; text-shadow: 0 0 5px var(--accent-color); font-size: 2.2em; margin: 0; flex-grow: 1; text-align: center; }

.icon-btn { background-color: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-muted); border-radius: 50%; width: 44px; height: 44px; cursor: pointer; transition: all 0.2s; display: flex; justify-content: center; align-items: center; }
.icon-btn.placeholder { visibility: hidden; } /* CSP Compliant replacement for inline styles */
.icon-btn svg { width: 1.5em; height: 1.5em; fill: currentColor; }
.icon-btn:hover { color: var(--accent-color); border-color: var(--accent-color); background-color: var(--border-color); }

/* Game Grid */
.game-wrapper { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 500px; margin: auto 0; }
.game-grid { display: grid; grid-template-rows: repeat(6, 1fr); gap: 5px; width: 100%; max-width: 320px; height: 380px; margin-bottom: 1rem; }
.grid-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.grid-tile { width: 100%; height: 100%; border: 2px solid var(--border-color); color: var(--text-color); font-size: 2rem; font-weight: bold; text-transform: uppercase; display: flex; justify-content: center; align-items: center; transition: transform 0.6s, background-color 0.6s, border-color 0.6s; }
.grid-tile.filled { border-color: #6b7280; animation: pop 0.2s; } 

/* CSP-Compliant Text Colors */
.color-correct { color: var(--correct-bg); }
.color-present { color: var(--present-bg); }
.color-absent { color: var(--absent-bg); }

@keyframes pop { 50% { transform: scale(1.1); } }
.grid-tile.correct, .key.correct { background-color: var(--correct-bg); border-color: var(--correct-bg); color: white; }
.grid-tile.present, .key.present { background-color: var(--present-bg); border-color: var(--present-bg); color: white;}
.grid-tile.absent, .key.absent { background-color: var(--absent-bg); color: var(--text-color); }
.tile-flip { animation: flip 0.5s ease-in-out forwards; } 
@keyframes flip { 
    0% { transform: scaleY(1); } 
    50% { transform: scaleY(0); } 
    100% { transform: scaleY(1); } 
}
.row-shake { animation: shake 0.5s; } 
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }

/* Keyboard */
.keyboard { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.keyboard-row { display: flex; justify-content: center; gap: 6px; }
.key { font-family: 'Inter', sans-serif; height: 58px; flex-grow: 1; border: none; border-radius: 4px; background-color: var(--key-bg); color: var(--text-color); font-size: 1.1rem; font-weight: bold; cursor: pointer; transition: background-color 0.2s; -webkit-tap-highlight-color: transparent; display: flex; justify-content: center; align-items: center; touch-action: manipulation; }
.key.large { flex: 1.5; font-size: 0.9rem; }
.key svg { width: 1.5em; height: 1.5em; fill: currentColor; pointer-events: none;}
.key[data-key="ENTER"].valid { background-color: var(--accent-color); color: var(--bg-main); }

/* Messages & Modals (Replaced Inline Styles with strict CSP classes) */
.hidden { display: none !important; }
.toast-container { display: none; position: fixed; top: 10vh; left: 50%; transform: translateX(-50%); background-color: rgba(255, 255, 255, 0.9); color: black; padding: 10px 20px; border-radius: 5px; z-index: 1005; font-weight: bold; }
.toast-container.show { display: block; animation: fade-in-out 3s; }
@keyframes fade-in-out { 0%, 100% { opacity: 0; transform: translate(-50%, -20px); } 10%, 90% { opacity: 1; transform: translate(-50%, 0); } }

.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.show { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content { background-color: var(--bg-card); margin: 15% auto; padding: 2rem; border: 1px solid var(--border-color); width: 90%; max-width: 450px; border-radius: 1rem; text-align: center; }
.modal h2, .modal h3 { margin-top: 0; font-family: 'Orbitron', sans-serif; color: var(--accent-color); }
.close-btn { float: right; cursor: pointer; font-size: 1.5rem; line-height: 1; color: var(--text-muted); padding: 5px; }

/* Buttons & Stats */
.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; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; touch-action: manipulation;}
#shareBtn { background-color: var(--correct-bg); color: white; }
#playAgainBtn { background-color: var(--accent-color); color: var(--bg-main); }
.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; font-weight: bold;}
.dist-bar { background-color: var(--key-bg); text-align: right; padding: 2px 8px; border-radius: 3px; color: white; font-weight: bold; min-width: 20px; box-sizing: border-box; transition: width 0.5s ease-out;}
.dist-bar.highlight { background-color: var(--correct-bg); }

#resetStatsBtn { background: none; border: 1px solid var(--border-color); color: var(--text-muted); padding: 0.5rem 1rem; border-radius: 5px; cursor: pointer; margin-top: 2rem; transition: background 0.2s; }
#resetStatsBtn:hover { background-color: #f43f5e; color: #fff; border-color: #f43f5e; }

.social-icons { display: flex; justify-content: center; gap: 1rem; margin: 1.5rem 0; }
.social-icon { color: var(--text-color); transition: transform 0.2s, color 0.2s; }
.social-icon svg { width: 2.5rem; height: 2.5rem; }
.social-icon:hover { transform: scale(1.1); }
.social-icon[aria-label*="Twitter"]:hover { color: #1DA1F2; } 
.social-icon[aria-label*="Facebook"]:hover { color: #1877F2; } 
.social-icon[aria-label*="Reddit"]:hover { color: #FF4500; }
#copyResultsBtn { font-size: 1rem; width: 100%; }

.content-section { margin-top: 2rem; padding: 1.5rem; background-color: var(--bg-card); border-radius: 1rem; max-width: 500px; width: 100%; line-height: 1.6; }
.content-section h2 { font-family: 'Orbitron'; color: var(--accent-color); }

/* Mobile View Adjustments */
@media (max-width: 992px) {
    :root { --menu-width: 250px; } 
    body { flex-direction: column; padding: 0; } 
    body.menu-open { overflow: hidden; }
    .main-content-wrapper { padding: 80px 15px 40px 15px; width: 100%; box-sizing: border-box; }
    
    .mobile-header { display: flex; align-items: center; justify-content: space-between; padding: 0 20px; height: 60px; background-color: #1a202c; border-bottom: 1px solid #4a5568; position: fixed; top: 0; left: 0; width: 100%; z-index: 1000; box-sizing: border-box; }
    .hamburger-btn { background: none; border: none; padding: 10px; cursor: pointer; z-index: 1002; }
    .hamburger-btn .line { display: block; width: 24px; height: 3px; background-color: #e2e8f0; margin: 5px 0; transition: transform 0.3s ease, opacity 0.3s ease; }
    .mobile-title { font-family: 'Orbitron', sans-serif; font-size: 1.4rem; color: var(--accent-color); font-weight: bold;}
    
    .left-menu { transform: translateX(-100%); transition: transform 0.3s ease-in-out; height: 100vh; width: var(--menu-width); min-width: var(--menu-width); }
    .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; }
    
    .header-bar h1 { font-size: 1.8em; } 
    .game-grid { width: 100%; max-width: 320px; height: auto; aspect-ratio: 5/6; } 
    .key { height: 50px; font-size: 0.9rem; } 
    .modal-content { margin-top: 20%; padding: 1.5rem;}
}