*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #000000; --surface: #0A0A0F; --cell: #111118; --cell-hover: #16161F;
    --border: #222230; --accent: #D4AF37; --danger: #EF4444; --success: #10B981;
    --text-primary: #F0F0F4; --text-secondary: #6B6B80; --text-muted: #3A3A4A;
    --x-color: #D4AF37; --o-color: #F0F0F4; /* Adjusted for tictactoe */
    --win-bg: #1A1A0F;
}
body { 
    background: var(--bg); 
    color: var(--text-primary); 
    font-family: 'Geist', sans-serif; 
    min-height: 100vh; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    padding: 24px; 
    overflow-x: hidden;
}
.screen { display: none; width: 100%; max-width: 460px; flex-direction: column; align-items: center; }
.screen.active { display: flex; }

/* Toasts */
.toast-container { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--surface); border: 1px solid var(--border); color: var(--text-primary); padding: 14px 24px; border-radius: 8px; font-size: 13px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,0.6); animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1); transition: opacity 0.3s; white-space: nowrap; }
.toast.success { border-color: var(--success); }
.toast.danger { border-color: var(--danger); }
.toast.warning { border-color: var(--accent); }
.toast.nudge { border-color: var(--accent); }
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Countdown Overlay */
.countdown-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 9999; display: none; align-items: center; justify-content: center; flex-direction: column; }
.countdown-overlay.show { display: flex; }
.countdown-num { font-family: 'Space Grotesk', sans-serif; font-size: 120px; font-weight: 700; color: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }

/* Suspense Overlay */
.suspense-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 9999; display: none; align-items: center; justify-content: center; flex-direction: column; backdrop-filter: blur(5px); }
.suspense-overlay.show { display: flex; animation: fadeIn 0.5s ease; }
.suspense-text { font-family: 'Space Grotesk', sans-serif; font-size: 32px; font-weight: 700; color: var(--text-primary); text-align: center; }
.suspense-text .accent { color: var(--accent); font-size: 48px; display: block; margin-top: 10px; animation: pulse 1s infinite alternate; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Shared Buttons */
.action-btn { width: 100%; padding: 15px; border-radius: 10px; font-family: 'Geist', sans-serif; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text-secondary); transition: all 0.2s; }
.action-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.action-btn.primary { background: var(--accent); border-color: var(--accent); color: #000; }
.action-btn.primary:hover { background: #E5C354; border-color: #E5C354; }
.action-btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.action-btn.danger:hover { color: #fff; background: var(--danger); }
.action-btn.nudge { background: transparent; border-color: var(--accent); color: var(--accent); }

/* Overlays */
.result-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.95); z-index: 10000; align-items: center; justify-content: center; padding: 24px; }
.result-overlay.show { display: flex; }
.result-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px 32px; text-align: center; width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 20px 40px rgba(0,0,0,0.8); }
.result-headline { font-family: 'Space Grotesk', sans-serif; font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 8px; color: var(--accent); text-transform: uppercase; }
.result-sub { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }
.result-actions { display: flex; gap: 10px; width: 100%; margin-top: 8px;}

/* Typography */
.game-title { font-family: 'Space Grotesk', sans-serif; font-size: 42px; font-weight: 700; letter-spacing: -1.5px; margin-bottom: 6px; }
.game-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 32px; }

/* Setup Form */
.setup-form { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.input-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 4px; display: block; }
.player-input-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 8px;}
.player-input-row input { flex: 1; background: transparent; border: none; outline: none; font-family: 'Geist', sans-serif; font-size: 15px; color: var(--text-primary); }
.player-input-row input::placeholder { color: var(--text-muted); }
.player-input-row select { width: 100%; background: transparent; border: none; color: var(--text-primary); font-family: 'Geist', sans-serif; outline: none; }

/* Mode Toggle */
.mode-toggle { display: grid; grid-template-columns: 1fr 1fr 1fr; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; gap: 4px; margin-bottom: 16px; }
.mode-btn { padding: 10px; border: none; border-radius: 7px; background: transparent; color: var(--text-secondary); font-family: 'Geist', sans-serif; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s;}
.mode-btn.active { background: var(--cell-hover); color: var(--text-primary); }

/* Game Grid (for index.html) */
.game-grid { display: grid; grid-template-columns: 1fr; gap: 10px; width: 100%; margin-top: 8px; }
.game-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: border-color 0.2s; }
.game-card:hover { border-color: var(--accent); }
.game-card.disabled { opacity: 0.5; cursor: not-allowed; }
.game-card.disabled:hover { border-color: var(--border); }
.game-name { font-family: 'Space Grotesk', sans-serif; font-size: 16px; font-weight: 600; }
.game-tag { font-size: 11px; padding: 4px 8px; background: var(--cell); border-radius: 4px; color: var(--text-secondary); }

/* Lobby Specific */
.lobby-card { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 20px; margin-bottom: 16px; }
.room-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.room-code-display { font-family: 'Space Grotesk', sans-serif; font-size: 24px; font-weight: 700; color: var(--accent); letter-spacing: 2px; }
.copy-btn { font-size: 12px; font-weight: 500; color: var(--text-secondary); background: none; border: 1px solid var(--border); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.copy-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }
.players-display { display: flex; justify-content: space-between; align-items: center; }
.player-slot { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.player-slot.right { text-align: right; }
.player-name { font-size: 15px; font-weight: 500; }
.player-status { font-size: 12px; color: var(--text-secondary); }
.vs-badge { font-family: 'Space Grotesk', sans-serif; font-size: 13px; font-weight: 700; color: var(--text-muted); padding: 0 16px; }


/* Lock-In Animation */
.option-btn.locked-in {
    background: rgba(212, 175, 55, 0.2) !important;
    border-color: var(--accent) !important;
    color: var(--text-primary) !important;
    animation: pulse-yellow 1s infinite alternate;
}
@keyframes pulse-yellow {
    from { box-shadow: 0 0 5px rgba(212, 175, 55, 0.2); }
    to { box-shadow: 0 0 20px rgba(212, 175, 55, 0.8); }
}



#oceanCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}
