/* Fantasy Empires – base styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0b1020;
    --card: #131a2b;
    --line: #27335b;
    --ink: #eaf0ff;
    --mute: #9bb0ff;
    --accent: #78d7ff;
    --gold: #f5c842;
    --danger: #e74c3c;
}

html, body { height: 100%; overflow: hidden; }
body {
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ── Screens ── */
.screen { display: none; width: 100%; height: 100%; position: absolute; top: 0; left: 0; overflow: hidden; }
.screen.active { display: flex; }

/* ── Splash background ── */
.splash-bg {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: cover; object-position: top center;
    z-index: 0; pointer-events: none;
}

/* ── Lobby ── */
.lobby-container, .waiting-container, .gameover-container {
    margin: auto;
    text-align: center;
    padding: 32px;
    position: relative; z-index: 1;
    background: rgba(11, 16, 32, .64);
    border: 1px solid rgba(234, 240, 255, .24);
    border-radius: 22px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 255, 255, .08);
    backdrop-filter: blur(5px);
    text-shadow: 0 2px 8px rgba(0, 0, 0, .75);
}
.lobby-container {
    width: min(92vw, 680px);
}
.waiting-container, .gameover-container {
    width: min(92vw, 620px);
}
.lobby-container h1 { font-size: 2.4rem; font-weight: 800; margin-bottom: 8px; color: #fff; }
.subtitle { color: #cbd6ff; margin-bottom: 24px; }
.name-form { margin-bottom: 18px; }
.name-form input {
    background: var(--card); border: 1px solid var(--line); border-radius: 8px;
    color: var(--ink); padding: 10px 14px; font-size: 1rem; width: 220px; text-align: center;
}
.lobby-buttons { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.create-form { display: flex; align-items: center; gap: 8px; }
.select-label { color: #d9e1ff; font-size: .9rem; }
.select-input {
    background: var(--card); border: 1px solid var(--line); border-radius: 8px;
    color: var(--ink); padding: 8px 10px; font-size: 1rem;
}
.divider { color: #d9e1ff; font-size: .9rem; }
.join-form { display: flex; gap: 8px; }
.join-form input {
    background: var(--card); border: 1px solid var(--line); border-radius: 8px;
    color: var(--ink); padding: 10px 14px; font-size: 1rem; text-transform: uppercase;
    width: 140px; text-align: center; letter-spacing: 2px;
}
.error-message { color: var(--danger); margin-top: 12px; }
.hidden { display: none !important; }

/* ── Buttons ── */
.btn {
    border: none; border-radius: 8px; padding: 10px 20px; font-size: 1rem;
    cursor: pointer; font-weight: 600; transition: background .15s;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: #1a2340; }
.btn-small { font-size: .85rem; padding: 6px 12px; }
.btn-leave { margin-top: 16px; }
.btn-quit { color: var(--mute); font-size: .8rem; border: 1px solid var(--line); margin-top: 4px; }
.btn-quit:hover { color: var(--danger); border-color: var(--danger); }
.btn-active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* ── Waiting ── */
.game-code-display {
    display: inline-flex; align-items: center; gap: 10px;
    background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 20px; font-size: 1.8rem; font-weight: 700; letter-spacing: 4px;
    margin: 12px 0;
}
.player-list { margin: 16px 0; text-align: left; display: inline-block; }
.player-list .player-entry {
    padding: 6px 0; display: flex; align-items: center; gap: 8px;
}
.player-list .player-dot {
    width: 12px; height: 12px; border-radius: 50%; display: inline-block;
}

/* ── Game layout ── */
#screen-game { display: none; }
#screen-game.active { display: flex; }
#game-canvas { flex: 1; display: block; min-width: 0; }
.sidebar {
    width: 240px; background: var(--card); border-left: 1px solid var(--line);
    padding: 16px; display: flex; flex-direction: column; gap: 12px;
    overflow-y: auto;
}
.sidebar h3 { font-size: 1.1rem; }
.sidebar h4 { font-size: .95rem; color: var(--mute); }
.sidebar-section { border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.sidebar-actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
#action-list { list-style: none; font-size: .85rem; color: var(--mute); }
#action-list li { padding: 3px 0; }

/* ── Game over ── */
.gameover-container h2 { font-size: 2rem; margin-bottom: 12px; }

/* ── Action list ── */
.btn-undo {
    background: none; border: none; color: var(--danger); cursor: pointer;
    font-size: .85rem; margin-left: 6px; padding: 0 4px;
}
.btn-undo:hover { color: #ff6b6b; }

/* ── Game toast (in-game error messages) ── */
.game-toast {
    position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
    background: rgba(231,76,60,.92); color: #fff; padding: 10px 22px;
    border-radius: 10px; font-weight: 600; font-size: .95rem;
    pointer-events: none; z-index: 10; transition: opacity .3s;
}
.game-toast.hidden { opacity: 0; pointer-events: none; }

/* ── Player status list ── */
.player-status {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 0; font-size: .9rem;
}
.player-status .player-dot {
    width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.player-status .status-icon { margin-left: auto; font-size: .8rem; }
.player-status.eliminated { opacity: .4; text-decoration: line-through; }

/* ── Hint text ── */
.hint-text { color: var(--mute); font-size: .8rem; font-style: italic; margin-top: 4px; }

/* ── Selected info ── */
#selected-info p { font-size: .9rem; }

/* ── End turn submitted state ── */
.btn-submitted {
    background: #1a5c2a !important; color: #8aff8a !important;
    cursor: default;
}

/* ── AI badge ── */
.ai-badge { font-size: .75rem; vertical-align: middle; }

/* ── Waiting screen actions ── */
.waiting-actions { display: flex; gap: 10px; justify-content: center; margin: 14px 0; }

/* ── Turn log ── */
.turn-log {
    max-height: 150px;
    overflow-y: auto;
    font-size: .8rem;
    line-height: 1.5;
}
.log-entry {
    padding: 2px 0;
    border-bottom: 1px solid rgba(255,255,255,.05);
}
.log-combat { color: var(--danger); }
.log-supply { color: #f39c12; }
.log-capture { color: var(--gold); }
.log-income { color: #2ecc71; }
.log-recruit { color: var(--accent); }
.log-move { color: var(--mute); }
.log-info { color: var(--mute); }
