/* Hex RTS — Dark theme, monospace UI */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #1a1a2e; color: #eee; font-family: 'Courier New', monospace; height: 100vh; overflow: hidden; }

/* --- Screens --- */
.screen { width: 100vw; height: 100vh; }

/* --- Auth --- */
#auth-screen { display: flex; align-items: center; justify-content: center; }
.auth-box { background: #16213e; border: 1px solid #333; padding: 40px; width: 360px; text-align: center; }
.auth-box h1 { font-size: 28px; color: #e94560; margin-bottom: 4px; }
.auth-subtitle { color: #666; font-size: 12px; margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 8px; }
.auth-form input { background: #0d1520; color: #eee; border: 1px solid #333; padding: 10px 12px; font-family: inherit; font-size: 13px; outline: none; }
.auth-form input:focus { border-color: #e94560; }
.auth-switch { font-size: 11px; color: #666; margin-top: 8px; }
.auth-switch a { color: #e94560; text-decoration: none; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: #555; font-size: 11px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; border-top: 1px solid #333; }
.guest-btn { background: #333; color: #aaa; border: none; padding: 10px 16px; cursor: pointer; font-family: inherit; font-size: 13px; width: 100%; }
.guest-btn:hover { background: #444; color: #eee; }
.auth-error { color: #e74c3c; font-size: 11px; margin-top: 12px; min-height: 16px; }

/* --- Top bar --- */
.top-bar { background: #16213e; border-bottom: 1px solid #333; padding: 8px 16px; display: flex; align-items: center; gap: 12px; }
.top-bar h1 { font-size: 16px; color: #e94560; }
.top-bar .status { color: #888; font-size: 12px; }
.elo-badge { background: #0d1520; padding: 2px 8px; border: 1px solid #333; color: #f39c12; font-size: 11px; }

/* --- Lobby --- */
#lobby-screen { display: flex; flex-direction: column; }
.lobby-content { flex: 1; display: flex; flex-direction: column; padding: 20px; overflow-y: auto; }
.lobby-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.lobby-header h2 { color: #e94560; }
.lobby-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.game-list { flex: 1; overflow-y: auto; }
.game-item { background: #16213e; border: 1px solid #333; padding: 12px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.game-item .game-info { display: flex; flex-direction: column; gap: 4px; }
.game-item .game-id { color: #e94560; font-weight: bold; }
.game-item .game-players { color: #888; font-size: 12px; }
.game-item .game-actions { display: flex; gap: 6px; align-items: center; }
.game-item .game-status-tag { color: #666; font-size: 11px; }
.empty-msg { color: #555; padding: 20px; text-align: center; }
.log-panel { white-space: pre-wrap; font-size: 11px; max-height: 100px; overflow-y: auto; border: 1px solid #333; padding: 6px; margin-top: 8px; background: #0d1520; color: #888; }

/* --- Game screen --- */
#game-screen { display: flex; flex-direction: column; }
.resource-bar { display: flex; gap: 16px; padding: 6px 12px; font-size: 12px; background: #0d1520; align-items: center; border-bottom: 1px solid #222; }
.res-gold { color: #f39c12; }
.res-wood { color: #cd853f; }
.res-units { color: #aaa; }
.res-tick { color: #666; }
.match-timer { color: #666; margin-left: auto; }

#production-bar { display: none; background: #0d1520; padding: 4px 12px; font-size: 11px; align-items: center; gap: 8px; border-bottom: 1px solid #222; }
#production-bar.active { display: flex; }
.prod-label { color: #aaa; white-space: nowrap; }
.prod-track { flex: 1; height: 6px; background: #1a1a2e; border-radius: 3px; overflow: hidden; }
.prod-fill { height: 100%; background: #e94560; transition: width 0.2s; width: 0%; }

.game-main { flex: 1; display: flex; overflow: hidden; }
.game-canvas-wrap { flex: 1; position: relative; overflow: hidden; background: #0a0a1a; cursor: grab; }
.game-canvas-wrap:active { cursor: grabbing; }
.game-canvas-wrap canvas { display: block; }
.hex-coords { position: absolute; bottom: 8px; left: 8px; color: #555; font-size: 11px; pointer-events: none; }

.game-sidebar { width: 300px; background: #16213e; border-left: 1px solid #333; display: flex; flex-direction: column; padding: 8px; overflow-y: auto; }
.game-sidebar h3 { margin: 0 0 8px 0; font-size: 13px; color: #e94560; }

/* --- Info panel --- */
.info-panel { font-size: 11px; line-height: 1.6; margin-bottom: 8px; min-height: 20px; color: #aaa; }
.info-panel .info-title { font-weight: bold; font-size: 12px; margin: 4px 0 2px; }
.info-panel .info-row { display: flex; justify-content: space-between; }
.info-panel .info-label { color: #666; }
.info-panel .info-value { color: #ddd; }
.info-panel .info-hp-bar { height: 4px; background: #333; margin: 2px 0 4px; border-radius: 2px; overflow: hidden; }
.info-panel .info-hp-fill { height: 100%; border-radius: 2px; }

/* --- Chat --- */
.chat-panel { margin-top: auto; border-top: 1px solid #333; padding-top: 8px; }
.chat-messages { height: 80px; overflow-y: auto; font-size: 11px; color: #888; margin-bottom: 4px; }
.chat-input-row { display: flex; gap: 4px; }
.chat-input-row input { flex: 1; background: #0d1520; color: #eee; border: 1px solid #333; padding: 4px 8px; font-family: inherit; font-size: 11px; outline: none; }
.chat-input-row input:focus { border-color: #e94560; }

/* --- Rule editor --- */
#rule-editor-container { flex: 1; display: flex; flex-direction: column; min-height: 0; margin-bottom: 8px; }
.rule-ref-toggle { background: #0d1520; color: #8899aa; border: 1px solid #333; padding: 4px 8px; cursor: pointer; font-family: inherit; font-size: 11px; text-align: left; margin-bottom: 4px; }
.rule-reference { display: none; background: #0d1520; border: 1px solid #333; padding: 8px; margin-bottom: 6px; font-size: 11px; line-height: 1.5; max-height: 200px; overflow-y: auto; }
.rule-editor-wrap { position: relative; flex: 1; min-height: 140px; }
.rule-editor-wrap pre { position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: 0; padding: 8px; font-family: inherit; font-size: 12px; line-height: 1.5; color: transparent; background: #0d1520; border: 1px solid #333; overflow: auto; white-space: pre-wrap; word-wrap: break-word; pointer-events: none; }
.rule-editor-wrap textarea { position: absolute; top: 0; left: 0; width: 100%; height: 100%; margin: 0; padding: 8px; font-family: inherit; font-size: 12px; line-height: 1.5; color: #ddd; background: transparent; border: 1px solid #333; resize: none; overflow: auto; white-space: pre-wrap; word-wrap: break-word; caret-color: #e94560; outline: none; }
.rule-errors { max-height: 50px; overflow-y: auto; font-size: 11px; line-height: 1.4; margin-top: 4px; }
.rule-presets { display: flex; gap: 4px; margin-bottom: 4px; }
.rule-presets button { font-size: 10px; padding: 2px 6px; background: #0d1520; color: #888; border: 1px solid #333; cursor: pointer; font-family: inherit; }
.rule-presets button:hover { color: #eee; border-color: #e94560; }

/* --- Status bar --- */
.status-bar { background: #0d1520; border-top: 1px solid #333; padding: 6px 16px; font-size: 11px; color: #888; }

/* --- Overlays --- */
.overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 100; align-items: center; justify-content: center; }
.overlay.visible { display: flex; }
.overlay-box { background: #16213e; border: 1px solid #333; padding: 40px; text-align: center; min-width: 300px; }
.overlay-box .result { font-size: 32px; font-weight: bold; margin-bottom: 8px; }
.overlay-box .result.victory { color: #2ecc71; }
.overlay-box .result.defeat { color: #e74c3c; }
.overlay-box .winner-name { color: #888; font-size: 14px; margin-bottom: 20px; }

/* --- Buttons --- */
button { background: #e94560; color: white; border: none; padding: 8px 16px; cursor: pointer; font-family: inherit; font-size: 12px; }
button:hover { background: #c73e54; }
button.secondary { background: #333; }
button.secondary:hover { background: #444; }
.btn-small { padding: 4px 10px; font-size: 11px; }

/* --- Inputs --- */
input[type="text"], input[type="password"] { background: #16213e; color: #eee; border: 1px solid #333; padding: 8px; font-family: inherit; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0d1520; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* --- Replay Viewer --- */
.replay-loading { display: flex; align-items: center; justify-content: center; height: 100vh; color: #888; font-size: 14px; }
.replay-content { flex-direction: column; height: 100vh; }
.replay-top-bar { background: #16213e; border-bottom: 1px solid #333; padding: 8px 16px; display: flex; align-items: center; gap: 12px; }
.replay-game-id { color: #e94560; font-size: 14px; font-weight: bold; }
.replay-main { flex: 1; display: flex; overflow: hidden; }
.replay-canvas-wrap { flex: 1; position: relative; overflow: hidden; background: #0a0a1a; cursor: grab; }
.replay-canvas-wrap:active { cursor: grabbing; }
.replay-canvas-wrap canvas { display: block; }
.replay-sidebar { width: 260px; background: #16213e; border-left: 1px solid #333; display: flex; flex-direction: column; padding: 8px; overflow-y: auto; }
.replay-sidebar h3 { margin: 0 0 8px 0; font-size: 13px; color: #e94560; }
.replay-sidebar h3:not(:first-child) { margin-top: 12px; }

/* Player cards */
.replay-player { background: #0d1520; border: 1px solid #333; padding: 8px; margin-bottom: 6px; }
.replay-player-header { display: flex; align-items: center; gap: 6px; }
.replay-player-color { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.replay-player-name { color: #eee; font-size: 12px; font-weight: bold; }
.replay-winner-badge { font-size: 12px; margin-left: auto; }
.replay-player-elo { color: #f39c12; font-size: 10px; margin-top: 2px; }
.replay-player-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: 10px; }
.rps-gold { color: #f39c12; }
.rps-wood { color: #cd853f; }
.rps-units { color: #aaa; }
.rps-base { color: #4ecdc4; }
.rps-prod { color: #e94560; }

/* Playback controls */
.replay-controls { background: #0d1520; border-top: 1px solid #333; padding: 8px 16px; display: flex; align-items: center; gap: 8px; }
.replay-ctrl-btn { width: 36px; height: 28px; font-size: 14px; padding: 0; text-align: center; line-height: 28px; }
.replay-speed-btn { background: #16213e; color: #888; border: 1px solid #333; padding: 4px 8px; cursor: pointer; font-family: inherit; font-size: 11px; }
.replay-speed-btn:hover { color: #eee; border-color: #e94560; }
.replay-speed-btn.active { color: #e94560; border-color: #e94560; background: #1a1a2e; }
.replay-slider { flex: 1; height: 6px; -webkit-appearance: none; appearance: none; background: #1a1a2e; border-radius: 3px; outline: none; cursor: pointer; }
.replay-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; background: #e94560; border-radius: 50%; cursor: pointer; }
.replay-slider::-moz-range-thumb { width: 14px; height: 14px; background: #e94560; border-radius: 50%; cursor: pointer; border: none; }
.replay-tick-num { color: #888; font-size: 11px; white-space: nowrap; min-width: 100px; text-align: right; }
