/* ============================================
   BATTLESHIP — NAVAL COMMAND UI
   ============================================ */

   :root {
    --bg-deep: #0a0e17;
    --bg-surface: #111827;
    --bg-card: #1a2234;
    --bg-elevated: #202b40;
    --border: #2a3650;
    --border-light: #354362;
    --text-primary: #e8edf5;
    --text-secondary: #8899b4;
    --text-muted: #556380;
    --accent: #f0a500;
    --accent-dim: #c48800;
    --accent-glow: rgba(240, 165, 0, 0.15);
    --hit: #ef4444;
    --miss: #3b82f6;
    --ocean: #1a3a4a;
    --ocean-light: #1f4a5c;
    --ocean-border: #25576b;
    --ship: #4b5c78;
    --ship-border: #64789a;
    --success: #22c55e;
    --success-dim: #15803d;
    --font-display: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }

body {
    font-family: var(--font-display);
    background: var(--bg-deep);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    color: var(--text-primary);
    overflow-x: hidden;
}

.scanline-overlay {
    position: fixed; inset: 0;
    pointer-events: none; z-index: 9999;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px);
}

/* ======================== LAYOUT ======================== */

.container {
    width: 100%; max-width: 1200px;
    padding: 30px 24px 50px;
    text-align: center;
}

/* ======================== HEADER ======================== */

.game-header { margin-bottom: 28px; }

.logo {
    display: flex; flex-direction: column;
    align-items: center; gap: 2px;
}
.logo-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 0 12px rgba(240,165,0,0.4));
}
.logo h1 {
    font-family: var(--font-mono);
    font-size: 2.4rem; font-weight: 700;
    letter-spacing: 0.35em;
    text-shadow: 0 0 30px rgba(240,165,0,0.15);
}
.logo-subtitle {
    font-family: var(--font-mono);
    font-size: 0.7rem; font-weight: 500;
    letter-spacing: 0.5em;
    color: var(--accent); text-transform: uppercase;
}

/* ======================== GAME INFO BAR ======================== */

.game-info {
    display: flex; justify-content: space-between; align-items: center;
    max-width: 640px; margin: 0 auto 20px;
    padding: 14px 22px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.score { display: flex; gap: 24px; }
.stat-block { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-label {
    font-family: var(--font-mono); font-size: 0.6rem;
    font-weight: 500; letter-spacing: 0.15em;
    color: var(--text-muted); text-transform: uppercase;
}
.stat-value {
    font-family: var(--font-mono); font-size: 1.5rem;
    font-weight: 600; color: var(--accent);
}
.stat-value.hit-color { color: var(--hit); }
.stat-value.miss-color { color: var(--miss); }

.game-controls { display: flex; gap: 8px; }

.btn-new-game {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 18px;
    font-family: var(--font-display); font-size: 0.85rem; font-weight: 600;
    background: var(--bg-elevated); color: var(--text-secondary);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    cursor: pointer; transition: all 0.2s;
}
.btn-new-game:hover { background: var(--hit); color: white; border-color: var(--hit); }
.btn-icon { font-size: 1.1rem; }

.btn-debug {
    padding: 10px 12px;
    font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600;
    background: var(--bg-elevated); color: var(--text-muted);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    cursor: pointer; transition: all 0.2s;
}
.btn-debug:hover { color: var(--text-secondary); border-color: var(--border-light); }

/* ======================== LEADERBOARD ======================== */

.leaderboard { max-width: 480px; margin: 0 auto 28px; }

.leaderboard-inner {
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 14px 20px;
}
.lb-side { display: flex; align-items: center; gap: 12px; flex: 1; }
.lb-player { justify-content: flex-end; }
.lb-ai { justify-content: flex-start; }
.lb-label {
    font-family: var(--font-mono); font-size: 0.7rem;
    font-weight: 600; letter-spacing: 0.15em;
    color: var(--text-muted); text-transform: uppercase;
}
.lb-score {
    font-family: var(--font-mono); font-size: 2rem;
    font-weight: 700; min-width: 36px; text-align: center;
}
.lb-player .lb-score { color: var(--success); }
.lb-ai .lb-score { color: var(--hit); }
.lb-center {
    display: flex; flex-direction: column; align-items: center;
    padding: 0 20px; flex-shrink: 0;
}
.lb-title {
    font-family: var(--font-mono); font-size: 0.55rem;
    font-weight: 600; letter-spacing: 0.25em;
    color: var(--text-muted); text-transform: uppercase;
}
.lb-divider { font-size: 0.8rem; color: var(--border-light); line-height: 1; }

.lb-reset-btn {
    display: flex; align-items: center; gap: 4px;
    padding: 6px 14px; margin-left: 16px; flex-shrink: 0;
    font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600;
    background: var(--bg-elevated); color: var(--text-muted);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; transition: all 0.2s;
}
.lb-reset-btn:hover {
    color: var(--hit); border-color: var(--hit);
    background: rgba(239,68,68,0.1);
}

.reset-confirm-content { max-width: 380px; }
.reset-confirm-content h2 { font-size: 1.4rem; margin-bottom: 10px; }
.reset-confirm-content > p { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 24px; }
.reset-confirm-buttons { display: flex; gap: 12px; justify-content: center; }
.reset-confirm-buttons .btn { min-width: 110px; padding: 10px 24px; }

.btn-danger {
    background: var(--hit); color: white; border-color: #dc2626;
}
.btn-danger:hover:not(:disabled) {
    background: #dc2626; box-shadow: 0 0 16px rgba(239,68,68,0.3);
}

/* ======================== MODE SELECTION ======================== */

.mode-screen { max-width: 680px; margin: 0 auto; }

.mode-card {
    padding: 60px 50px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
}
.mode-card h2 {
    font-family: var(--font-mono); font-size: 2.2rem; font-weight: 700;
    letter-spacing: 0.2em; margin-bottom: 10px;
}
.mode-desc { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 32px; }

.name-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 32px;
}
.name-input-group label {
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}
.name-input-group input {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    padding: 10px 18px;
    border-radius: 8px;
    text-align: center;
    width: 260px;
    outline: none;
    transition: border-color 0.2s;
}
.name-input-group input:focus { border-color: var(--accent); }
.name-input-group input::placeholder { color: var(--text-muted); opacity: 0.6; }

.mode-buttons { display: flex; gap: 24px; justify-content: center; }

.btn-mode {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    width: 240px; padding: 36px 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    color: var(--text-primary); cursor: pointer; transition: all 0.25s;
}
.btn-mode:hover {
    border-color: var(--accent); background: var(--accent-glow);
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.4), 0 0 20px var(--accent-glow);
}
.mode-icon { font-size: 2.8rem; margin-bottom: 4px; }
.mode-label { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; }
.mode-detail { font-size: 0.85rem; color: var(--text-muted); }

/* ======================== SHIP PLACEMENT ======================== */

.placement-screen { max-width: 800px; margin: 0 auto; }

.placement-header { margin-bottom: 24px; }
.placement-header h2 {
    font-family: var(--font-mono); font-size: 1.5rem;
    font-weight: 600; letter-spacing: 0.12em; margin-bottom: 8px;
}
.placement-header p { font-size: 0.9rem; color: var(--text-secondary); }
.placement-header kbd {
    display: inline-block; padding: 2px 8px;
    font-family: var(--font-mono); font-size: 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light); border-radius: 4px;
    color: var(--accent);
}

.ship-selection {
    display: flex; gap: 10px; justify-content: center;
    margin-bottom: 28px; flex-wrap: wrap;
}

.ship-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 18px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer; transition: all 0.2s;
    min-width: 130px;
}
.ship-item:hover:not(.placed) { border-color: var(--accent-dim); background: var(--accent-glow); }
.ship-item.selected {
    border-color: var(--accent); background: var(--accent-glow);
    box-shadow: 0 0 16px rgba(240,165,0,0.15);
}
.ship-item.placed { opacity: 0.35; cursor: not-allowed; }

.ship-emoji { font-size: 1.3rem; }
.ship-name {
    font-family: var(--font-display); font-size: 0.85rem;
    font-weight: 600; color: var(--text-primary);
}
.ship-size {
    font-family: var(--font-mono); font-size: 0.75rem;
    color: var(--accent); font-weight: 600; margin-left: auto;
}

.placement-board-container { margin: 20px 0; }
.placement-board-container h3 {
    font-family: var(--font-mono); font-size: 0.85rem;
    font-weight: 500; letter-spacing: 0.15em;
    color: var(--text-muted); text-transform: uppercase;
    margin-bottom: 12px;
}

.placement-controls {
    display: flex; gap: 14px; justify-content: center; margin-top: 24px;
}

/* ======================== BUTTONS ======================== */

.btn {
    padding: 12px 28px; font-family: var(--font-display);
    font-size: 0.95rem; font-weight: 600;
    border: 1px solid var(--border); border-radius: var(--radius-md);
    cursor: pointer; transition: all 0.2s;
}
.btn-secondary { background: var(--bg-elevated); color: var(--text-secondary); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-light); }
.btn-primary { background: var(--success-dim); color: white; border-color: var(--success); }
.btn-primary:hover:not(:disabled) { background: var(--success); box-shadow: 0 0 20px rgba(34,197,94,0.25); }
.btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ======================== GAME SCREEN ======================== */

.game-screen { max-width: 100%; }

.boards-container {
    display: flex; gap: 24px;
    justify-content: center; align-items: flex-start;
    flex-wrap: nowrap;
}

.board-column {
    display: flex; flex-direction: column;
    align-items: center; gap: 12px;
}

.board-section { text-align: center; }

.board-label-bar {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; margin-bottom: 14px;
}
.board-dot { width: 8px; height: 8px; border-radius: 50%; }
.board-dot.friendly { background: var(--success); box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.board-dot.hostile { background: var(--hit); box-shadow: 0 0 8px rgba(239,68,68,0.5); }
.board-label-bar h3 {
    font-family: var(--font-mono); font-size: 0.85rem;
    font-weight: 500; letter-spacing: 0.15em;
    color: var(--text-secondary); text-transform: uppercase;
}

.board-divider {
    display: flex; align-items: center; justify-content: center;
    align-self: center; padding-top: 30px;
}
.vs-badge {
    font-family: var(--font-mono); font-size: 0.75rem;
    font-weight: 700; letter-spacing: 0.15em;
    color: var(--text-muted); background: var(--bg-card);
    border: 1px solid var(--border); padding: 8px 12px;
    border-radius: var(--radius-sm);
}

/* ======================== SHIP TRACKER ======================== */

.ship-tracker {
    width: 100%; max-width: 440px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 12px 16px;
}
.tracker-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 10px;
}
.tracker-title {
    font-family: var(--font-mono); font-size: 0.65rem;
    font-weight: 600; letter-spacing: 0.15em;
    color: var(--text-muted); text-transform: uppercase;
}
.tracker-count {
    font-family: var(--font-mono); font-size: 0.7rem;
    font-weight: 600; color: var(--accent);
}
.tracker-list { display: flex; flex-wrap: wrap; gap: 6px; }

.tracker-ship {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.3s;
}
.tracker-ship.sunk {
    opacity: 0.35; border-color: var(--hit);
    background: rgba(239,68,68,0.08);
}
.tracker-ship.sunk .tracker-ship-name {
    text-decoration: line-through; color: var(--text-muted);
}
.tracker-ship-icon { font-size: 0.9rem; }
.tracker-ship-name {
    font-family: var(--font-display); font-size: 0.72rem;
    font-weight: 600; color: var(--text-secondary);
}
.tracker-ship-pips { display: flex; gap: 3px; }
.tracker-pip {
    width: 7px; height: 7px;
    background: var(--ocean); border: 1px solid var(--ocean-border);
    border-radius: 2px;
}
.tracker-ship.sunk .tracker-pip { background: var(--hit); border-color: #dc2626; }

/* ======================== GRID ======================== */

.grid-wrapper {
    display: inline-block; background: var(--bg-card);
    padding: 14px; border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}
.grid-header {
    display: grid; grid-template-columns: 30px repeat(10, 38px);
    gap: 2px; margin-bottom: 2px;
}
.corner { width: 30px; height: 26px; }
.col-label {
    width: 38px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-weight: 500;
    font-size: 0.7rem; color: var(--text-muted);
}
.grid {
    display: grid; grid-template-columns: 30px repeat(10, 38px);
    gap: 2px;
}
.row-label {
    width: 30px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-weight: 500;
    font-size: 0.7rem; color: var(--text-muted);
}
.cell {
    width: 38px; height: 38px;
    background: var(--ocean); border: 1px solid var(--ocean-border);
    border-radius: 3px; cursor: pointer; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem; font-weight: bold; position: relative;
}
.cell:hover:not(.hit):not(.miss):not(.disabled) {
    background: var(--ocean-light); border-color: var(--accent-dim);
    box-shadow: 0 0 8px rgba(240,165,0,0.15); z-index: 1;
}
.cell.hit {
    background: var(--hit); border-color: #dc2626;
    cursor: not-allowed; box-shadow: inset 0 0 10px rgba(0,0,0,0.3);
    animation: hitFlash 0.3s ease-out;
}
.cell.hit::after {
    content: '✕'; color: rgba(255,255,255,0.9);
    font-size: 1.1rem; font-weight: 700;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
@keyframes hitFlash {
    0% { transform: scale(1.3); background: #fff; }
    100% { transform: scale(1); }
}
.cell.miss { background: var(--ocean); border-color: var(--ocean-border); cursor: not-allowed; }
.cell.miss::after { content: '•'; color: var(--text-muted); font-size: 1.4rem; }
.cell.disabled { cursor: not-allowed; opacity: 0.5; }
.cell.ship { background: var(--ship); border-color: var(--ship-border); }
.cell.valid-placement { background: rgba(34,197,94,0.35); border-color: rgba(34,197,94,0.6); }
.cell.invalid-placement { background: rgba(239,68,68,0.3); border-color: rgba(239,68,68,0.5); }

/* ======================== MESSAGE BAR ======================== */

.message {
    margin: 28px auto 0; max-width: 640px;
    font-family: var(--font-mono); font-size: 0.9rem; font-weight: 500;
    min-height: 44px; padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
}
.message.win {
    background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.3);
    color: var(--success); animation: pulse 0.5s ease-in-out;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.02); } }

/* ======================== MODALS ======================== */

.modal {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    animation: fadeIn 0.3s ease-in;
}
.modal.show { display: flex; justify-content: center; align-items: center; }

.modal-content {
    background: var(--bg-surface); border: 1px solid var(--border);
    padding: 44px 40px 36px; border-radius: var(--radius-xl);
    text-align: center; max-width: 480px; width: 92%;
    animation: slideIn 0.4s cubic-bezier(0.16,1,0.3,1);
}
.modal-content h2 { font-size: 2rem; margin-bottom: 8px; }
.modal-content > p { font-size: 1rem; margin-bottom: 24px; color: var(--text-secondary); }

.stats-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.stats {
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 20px; border-radius: var(--radius-md);
}
.stats h3 {
    font-family: var(--font-mono); font-size: 0.7rem;
    font-weight: 600; letter-spacing: 0.2em;
    text-transform: uppercase; color: var(--accent); margin-bottom: 16px;
}
.stats-row { display: flex; justify-content: center; gap: 20px; }
.stats-row.streaks {
    margin-top: 12px; padding-top: 12px;
    border-top: 1px solid var(--border);
}
.stat-item {
    display: flex; flex-direction: column;
    align-items: center; gap: 4px; min-width: 60px;
}
.stat-num {
    font-family: var(--font-mono); font-size: 1.6rem;
    font-weight: 700; color: var(--accent);
}
.stat-desc {
    font-size: 0.7rem; font-weight: 500;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.05em;
}
.lifetime-stats { background: var(--bg-elevated); border-color: var(--border-light); }

.btn-play-again {
    padding: 14px 40px;
    font-family: var(--font-display); font-size: 1.05rem; font-weight: 600;
    background: var(--success-dim); color: white;
    border: 1px solid var(--success); border-radius: var(--radius-md);
    cursor: pointer; transition: all 0.2s; margin-top: 4px;
}
.btn-play-again:hover { background: var(--success); box-shadow: 0 0 20px rgba(34,197,94,0.3); }

.handoff-content { max-width: 420px; }
.handoff-content h2 { font-size: 1.6rem; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn {
    from { transform: translateY(-20px) scale(0.97); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ======================== RESPONSIVE ======================== */

@media (max-width: 960px) {
    .boards-container { flex-wrap: wrap; gap: 16px; }
    .board-divider { display: none; }
}

@media (max-width: 768px) {
    html { font-size: 13px; }
    .container { padding: 20px 12px 40px; }
    .logo h1 { font-size: 1.8rem; letter-spacing: 0.25em; }
    .game-info { flex-direction: column; gap: 12px; padding: 12px 16px; }

    .grid-header { grid-template-columns: 26px repeat(10, 32px); }
    .corner { width: 26px; height: 24px; }
    .col-label { width: 32px; height: 24px; font-size: 0.6rem; }
    .grid { grid-template-columns: 26px repeat(10, 32px); }
    .row-label { width: 26px; height: 32px; font-size: 0.6rem; }
    .cell { width: 32px; height: 32px; font-size: 0.9rem; }
    .grid-wrapper { padding: 10px; }

    .ship-selection { flex-direction: column; align-items: center; gap: 8px; }
    .ship-item { min-width: 220px; }

    .mode-buttons { flex-direction: column; align-items: center; }
    .btn-mode { width: 100%; max-width: 280px; }
    .mode-card { padding: 40px 30px; }
    .mode-card h2 { font-size: 1.6rem; }

    .placement-controls { flex-direction: column; align-items: center; }
    .modal-content { padding: 30px 24px 28px; }
    .stats-row { flex-wrap: wrap; gap: 14px; }

    .leaderboard-inner { flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
    .lb-reset-btn { margin-left: 0; }
}

@media (max-width: 420px) {
    .grid-header { grid-template-columns: 22px repeat(10, 28px); }
    .corner { width: 22px; }
    .col-label { width: 28px; font-size: 0.55rem; }
    .grid { grid-template-columns: 22px repeat(10, 28px); }
    .row-label { width: 22px; height: 28px; font-size: 0.55rem; }
    .cell { width: 28px; height: 28px; font-size: 0.8rem; }
}
/* ===================== LOBBY ===================== */

.lobby-layout {
    display: flex;
    gap: 24px;
    max-width: 960px;
    margin: 0 auto;
    align-items: flex-start;
}

.lobby-sidebar {
    flex: 0 0 280px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px 28px;
    text-align: left;
}

.lobby-heading {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    margin-bottom: 6px;
}

.lobby-subheading {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.lobby-create-form {
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lobby-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
}

.lobby-select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}
.lobby-select:focus { border-color: var(--accent); }

.lobby-create-btn { width: 100%; margin-top: 4px; }

.lobby-message {
    min-height: 20px;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--hit);
    margin-top: 10px;
}

.lobby-back-btn { width: 100%; margin-top: 12px; }

.lobby-games-panel {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px 28px;
    min-height: 420px;
}

.lobby-games-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.lobby-games-title {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.lobby-live {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--success);
    letter-spacing: 0.1em;
    animation: pulse 2s ease-in-out infinite;
}

.games-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
}

.games-empty {
    text-align: center;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 60px 20px;
}

.game-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color 0.2s;
}
.game-item:hover { border-color: var(--border-light); }

.game-item-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: left;
}

.game-item-id {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--accent);
    font-weight: 600;
}

.game-item-creator {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.game-item-meta {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
}

.game-join-btn { padding: 8px 20px; font-size: 0.85rem; }

/* ===================== TURN INDICATOR ===================== */

.turn-indicator {
    max-width: 700px;
    margin: 0 auto 18px;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.04em;
}

.turn-yours {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: var(--hit);
    animation: pulse 1.8s ease-in-out infinite;
}

.turn-theirs {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

/* ===================== MOVE HISTORY ===================== */

.move-history-panel {
    max-width: 700px;
    margin: 20px auto 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}

.move-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.mh-title {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.mh-count {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--accent);
    font-weight: 600;
}

.move-history-list {
    max-height: 160px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.move-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    border-left: 2px solid transparent;
}

.move-you    { border-left-color: var(--hit); }
.move-opponent { border-left-color: var(--miss); }
.move-icon { font-size: 0.85rem; }

.move-who {
    font-weight: 700;
    min-width: 32px;
    color: var(--text-secondary);
}

.move-coord {
    font-weight: 600;
    color: var(--accent);
    min-width: 28px;
}

.move-result {
    font-weight: 700;
    font-size: 0.62rem;
    padding: 2px 6px;
    border-radius: 3px;
}
.move-result.hit  { background: rgba(239,68,68,0.15); color: var(--hit); }
.move-result.miss { background: rgba(59,130,246,0.15); color: var(--miss); }

.move-time {
    color: var(--text-muted);
    font-size: 0.62rem;
    margin-left: auto;
}

/* ======================== HEADER ACTIONS ======================== */

.game-header {
    position: relative;
    margin-bottom: 28px;
}

.header-actions {
    position: absolute;
    top: 0; right: 0;
    display: flex; align-items: center; gap: 8px;
}

.btn-leaderboard {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    font-family: var(--font-mono); font-size: 0.72rem; font-weight: 600;
    letter-spacing: 0.05em;
    background: var(--bg-card); color: var(--accent);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    text-decoration: none; transition: all 0.2s;
}
.btn-leaderboard:hover { border-color: var(--accent); background: var(--accent-glow); }

.btn-leaderboard-modal {
    display: inline-block; margin-top: 10px;
    padding: 10px 28px;
    font-family: var(--font-mono); font-size: 0.8rem; font-weight: 600;
    color: var(--accent); background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    text-decoration: none; transition: all 0.2s;
}
.btn-leaderboard-modal:hover { border-color: var(--accent); background: var(--accent-glow); }

/* ======================== THEME TOGGLE ======================== */

.btn-theme-toggle {
    position: absolute;
    top: 0; right: 0;
    padding: 8px 12px;
    font-size: 1.1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}
.btn-theme-toggle:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

/* ======================== LIGHT MODE ======================== */

body.light {
    --bg-deep: #eef1f7;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #e4e9f2;
    --border: #c8d0e0;
    --border-light: #a8b8d0;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7fa0;
    --accent-glow: rgba(240, 165, 0, 0.12);
    --ocean: #c5d8e8;
    --ocean-light: #b0cfe0;
    --ocean-border: #90b5cc;
    --ship: #7a8fa8;
    --ship-border: #5a7090;
}

body.light .scanline-overlay { display: none; }
body.light .modal { background-color: rgba(0,0,0,0.45); }
