/* Apollo's Time — 4X Strategy Game Styles */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-dark: #1a1a2e;
  --bg-panel: #16213e;
  --bg-card: #0f3460;
  --accent: #e94560;
  --accent2: #53a8b6;
  --text: #eee;
  --text-dim: #8899aa;
  --gold: #f0c040;
  --green: #4caf50;
  --red: #e94560;
  --blue: #2196f3;
  --purple: #9c27b0;
  --border: #2a3a5e;
  /* Affordance additions */
  --btn-shadow: 0 2px 4px rgba(0,0,0,0.4);
  --panel-glow: 0 4px 24px rgba(0,0,0,0.5), 0 0 1px rgba(255,255,255,0.05);
  --bevel-light: rgba(255,255,255,0.08);
  --bevel-dark: rgba(0,0,0,0.3);
  --inset-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

html, body { height: 100%; overflow: hidden; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg-dark); color: var(--text); font-size: clamp(13px, 0.9vw, 16px); }
#app { width: 100%; height: 100%; position: relative; }

/* Screens */
.screen { display: none; width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: 1; }
#save-load-screen.overlay-mode { z-index: 200; background: rgba(0,0,0,0.7); }
.screen.active { display: flex; justify-content: center; align-items: center; }

/* Loading Overlay */
#loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, #0a0a1a 0%, #1a0f08 50%, #0a0a1a 100%);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
#loading-content { text-align: center; }
#loading-title {
  font-size: 36px;
  color: #c9a84c;
  font-family: Georgia, 'Times New Roman', serif;
  letter-spacing: 3px;
  margin-bottom: 30px;
  text-shadow: 0 0 20px rgba(201,168,76,0.4);
}
#loading-spinner {
  width: 50px; height: 50px;
  border: 3px solid #2a1810;
  border-top: 3px solid #c9a84c;
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-status {
  font-size: 14px;
  color: #8a7a6a;
  letter-spacing: 1px;
}
#game-screen.active { justify-content: flex-start; align-items: stretch; }

/* Main Menu */
#main-menu { justify-content: center; align-items: center; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
.menu-container { text-align: center; }
.game-title { font-size: clamp(36px, 8vw, 72px); font-weight: 900; letter-spacing: clamp(4px, 1.5vw, 12px); color: var(--gold); text-shadow: 0 0 40px rgba(240,192,64,0.3), 0 2px 0 #b8860b; margin-bottom: 8px; }
.game-subtitle { font-size: 18px; color: var(--text-dim); letter-spacing: 4px; margin-bottom: 48px; }
.menu-buttons { display: flex; flex-direction: column; gap: 16px; align-items: center; }

/* Buttons */
.btn {
  padding: 12px 32px; font-size: 16px; border: none; border-radius: 6px;
  cursor: pointer; font-weight: 600; transition: all 0.2s; min-width: 200px;
  border-bottom: 3px solid rgba(0,0,0,0.3);
  box-shadow: var(--btn-shadow), inset 0 1px 0 var(--bevel-light);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.btn:active {
  transform: translateY(1px);
  border-bottom-width: 1px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}
.btn-primary {
  background: linear-gradient(to bottom, #f0576e 0%, var(--accent) 100%);
  color: white;
}
.btn-primary:hover { background: linear-gradient(to bottom, #ff6b82 0%, #f0576e 100%); transform: translateY(-1px); }
.btn-primary:active { background: linear-gradient(to bottom, var(--accent) 0%, #c9374d 100%); }
.btn-secondary {
  background: linear-gradient(to bottom, #153a6e 0%, var(--bg-card) 100%);
  color: var(--text); border: 1px solid var(--border);
}
.btn-secondary:hover { background: linear-gradient(to bottom, #1a4a80 0%, #153a6e 100%); }
.btn-secondary:active { background: linear-gradient(to bottom, var(--bg-card) 0%, #0a2540 100%); }
.btn-danger {
  background: linear-gradient(to bottom, #e04a3a 0%, #c0392b 100%);
  color: white;
}
.btn-danger:hover { background: linear-gradient(to bottom, #f05a4a 0%, #e04a3a 100%); }
.btn-sm {
  padding: 6px 12px; font-size: 18px; border: none; background: transparent;
  color: var(--text); cursor: pointer; border-radius: 4px;
  transition: all 0.15s;
}
.btn-sm:hover { background: rgba(255,255,255,0.1); box-shadow: 0 0 8px rgba(255,255,255,0.05); }
.city-jump-dropdown {
  background: var(--bg-panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 4px 8px; font-size: 13px; cursor: pointer; max-width: 150px;
  box-shadow: var(--inset-shadow);
}
.city-jump-dropdown:hover { border-color: var(--accent); }
.btn-end-turn {
  padding: 10px 28px; font-size: 16px; font-weight: 700;
  background: linear-gradient(to bottom, #5cbf60 0%, var(--green) 100%);
  color: white; border: none; border-radius: 6px; cursor: pointer; letter-spacing: 1px;
  border-bottom: 3px solid #388e3c;
  box-shadow: var(--btn-shadow), inset 0 1px 0 rgba(255,255,255,0.15);
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.btn-end-turn:hover { background: linear-gradient(to bottom, #72cc76 0%, #5cbf60 100%); transform: translateY(-1px); }
.btn-end-turn:active { background: linear-gradient(to bottom, var(--green) 0%, #388e3c 100%); transform: translateY(1px); border-bottom-width: 1px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.4); }
.btn-close {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.03) 100%);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 50%;
  color: var(--text-dim); font-size: 20px; cursor: pointer; padding: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: all 0.15s; line-height: 1;
}
.btn-close:hover { color: #fff; background: linear-gradient(to bottom, rgba(233,69,96,0.4) 0%, rgba(233,69,96,0.2) 100%); border-color: var(--accent); box-shadow: 0 0 8px rgba(233,69,96,0.3); }
.btn-close:active { box-shadow: inset 0 2px 4px rgba(0,0,0,0.5); transform: scale(0.95); }

/* Setup Panel */
.setup-panel { max-width: 400px; width: 90vw; margin: auto; padding: 32px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.form-group input, .form-group select {
  width: 100%; padding: 10px; background: var(--bg-dark); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px; font-size: 15px;
  box-shadow: var(--inset-shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--accent2);
  box-shadow: var(--inset-shadow), 0 0 0 3px rgba(83,168,182,0.25);
}
.form-group select option { background: var(--bg-dark); }
.form-buttons { display: flex; gap: 12px; margin-top: 24px; }
.form-buttons .btn { flex: 1; }

/* Panels */
.panel {
  background: linear-gradient(170deg, rgba(30,45,80,0.95) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border); border-radius: 8px; padding: 16px;
  border-top-color: rgba(255,255,255,0.1); border-left-color: rgba(255,255,255,0.06);
  border-bottom-color: rgba(0,0,0,0.3); border-right-color: rgba(0,0,0,0.2);
  box-shadow: var(--panel-glow);
}
.panel h2 { margin-bottom: 16px; color: var(--gold); font-size: clamp(18px, 1.4vw, 22px); font-weight: 700; }
.panel h3 { font-size: clamp(15px, 1.1vw, 18px); color: var(--gold); }
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, rgba(255,255,255,0.03) 0%, transparent 100%);
  margin: -16px -16px 12px -16px; padding: 12px 16px 10px;
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid var(--border);
}

/* Save/Load */
.save-panel { max-width: 500px; width: 90vw; margin: auto; max-height: 80vh; overflow-y: auto; }
.save-slot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px; margin-bottom: 8px;
  background: linear-gradient(to bottom, rgba(26,26,46,0.9) 0%, var(--bg-dark) 100%);
  border: 1px solid var(--border); border-left: 3px solid var(--accent2);
  border-radius: 6px; cursor: pointer; transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.save-slot:hover { border-color: var(--accent2); background: var(--bg-card); transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,0.3); }
.save-slot .slot-info { flex: 1; }
.save-slot .slot-name { font-weight: 600; color: var(--text); }
.save-slot .slot-detail { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.save-slot .slot-empty { color: var(--text-dim); font-style: italic; }
.save-slot .slot-actions { display: flex; gap: 8px; }
.save-slot .slot-actions button { padding: 6px 14px; font-size: 13px; }

/* Game Screen */
#game-screen { flex-direction: column; }
#top-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px; background: linear-gradient(to bottom, #1e2d50 0%, var(--bg-panel) 100%); border-bottom: 1px solid var(--border); z-index: 10; min-height: 42px; flex-wrap: wrap; }
.resource-bar { display: flex; gap: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.resource-bar::-webkit-scrollbar { display: none; }
.res { font-size: 14px; white-space: nowrap; }
.res b { color: var(--gold); }
.turn-info { display: flex; gap: 16px; font-weight: 600; }
#era-display { color: var(--accent2); }
.top-buttons { display: flex; gap: 4px; }

/* Map Container */
#map-container { flex: 1; position: relative; overflow: hidden; cursor: grab; }
#map-container:active { cursor: grabbing; }
#map-container canvas { display: block; }

/* Minimap */
#minimap-container { position: absolute; bottom: 52px; left: 8px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 6px; padding: 4px; z-index: 20; box-shadow: var(--panel-glow); }
#minimap { display: block; border-radius: 4px; cursor: pointer; width: 200px; height: 130px; }
#minimap-toggle { display: none; position: absolute; bottom: 54px; left: 8px; z-index: 20; width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(to bottom, #1e2d50 0%, var(--bg-panel) 100%); border: 1px solid var(--border); color: var(--text); font-size: 18px; cursor: pointer; box-shadow: var(--btn-shadow); }

/* Side Panel */
.side-panel { position: absolute; top: 50px; right: 8px; width: 260px; max-height: calc(100vh - 110px); overflow-y: auto; z-index: 20; font-size: 13px; }
.side-panel .hint { color: var(--text-dim); text-align: center; padding: 20px 0; }

/* Overlay Panels */
.overlay-panel {
  position: absolute; z-index: 100;
  background: linear-gradient(170deg, rgba(30,45,80,0.97) 0%, var(--bg-panel) 100%);
  border: 1px solid var(--border); border-radius: 8px; padding: 16px;
  border-top-color: rgba(255,255,255,0.1); border-left-color: rgba(255,255,255,0.06);
  border-bottom-color: rgba(0,0,0,0.3); border-right-color: rgba(0,0,0,0.2);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 1px rgba(255,255,255,0.05), 0 0 60px rgba(15,52,96,0.3);
}
.overlay-panel.hidden { display: none; }
#city-panel { top: 50px; left: 50%; transform: translateX(-50%); width: 600px; max-width: 95vw; max-height: calc(100vh - 110px); overflow-y: auto; }
#tech-panel { top: 50px; left: 50%; transform: translateX(-50%); width: 700px; max-width: 95vw; max-height: calc(100vh - 110px); overflow-y: auto; }
#game-menu { top: 50%; left: 50%; transform: translate(-50%, -50%); width: 280px; max-width: 90vw; }
.vertical { flex-direction: column; }

/* Bottom Bar */
#bottom-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px; background: linear-gradient(to top, #1e2d50 0%, var(--bg-panel) 100%); border-top: 1px solid var(--border); z-index: 10; min-height: 48px; }
#action-buttons { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
#action-buttons::-webkit-scrollbar { display: none; }
#action-buttons button {
  padding: 6px 14px;
  background: linear-gradient(to bottom, #153a6e 0%, var(--bg-card) 100%);
  color: var(--text); border: 1px solid var(--border); border-radius: 4px;
  cursor: pointer; font-size: 13px; white-space: nowrap;
  border-bottom: 2px solid rgba(0,0,0,0.3);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), inset 0 1px 0 var(--bevel-light);
  transition: all 0.15s;
}
#action-buttons button:hover { background: linear-gradient(to bottom, #1a4a80 0%, #153a6e 100%); transform: translateY(-1px); }
#action-buttons button:active { transform: translateY(1px); box-shadow: inset 0 2px 3px rgba(0,0,0,0.4); border-bottom-width: 1px; }
#action-buttons button:disabled { opacity: 0.4; cursor: default; transform: none; box-shadow: none; }
#unit-info-bar { font-size: 13px; color: var(--text-dim); }

/* Notifications */
#notifications { position: absolute; top: 50px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.notification { padding: 10px 20px; background: var(--bg-card); border: 1px solid var(--accent2); border-radius: 6px; color: var(--text); font-size: 14px; animation: notifIn 0.3s ease, notifOut 0.5s ease 2.5s forwards; pointer-events: auto; }
@keyframes notifIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes notifOut { to { opacity: 0; transform: translateY(-10px); } }

/* Tech Tree */
.tech-era { margin-bottom: 16px; }
.tech-era h4 { color: var(--accent2); margin-bottom: 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; }
.tech-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.tech-item {
  padding: 8px 12px; background: linear-gradient(to bottom, rgba(26,26,46,0.9) 0%, var(--bg-dark) 100%);
  border: 1px solid var(--border); border-radius: 4px; font-size: 12px;
  cursor: pointer; transition: all 0.15s; min-width: 120px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2), inset 0 1px 0 var(--bevel-light);
}
.tech-item.researched { border-color: var(--green); background: linear-gradient(to bottom, rgba(76,175,80,0.2) 0%, rgba(76,175,80,0.1) 100%); }
.tech-item.available { border-color: var(--accent2); cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.3), inset 0 1px 0 rgba(83,168,182,0.15); }
.tech-item.available:hover { background: rgba(83,168,182,0.2); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.tech-item.current { border-color: var(--gold); background: rgba(240,192,64,0.15); animation: pulse 1.5s infinite; }
.tech-item.locked { opacity: 0.4; cursor: default; }
.tech-item .tech-name { font-weight: 600; }
.tech-item .tech-cost { font-size: 11px; color: var(--text-dim); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(240,192,64,0.3); } 50% { box-shadow: 0 0 8px 2px rgba(240,192,64,0.3); } }

/* Civics & Government Panel */
#civics-panel { top: 50px; left: 50%; transform: translateX(-50%); width: 700px; max-width: 95vw; max-height: calc(100vh - 110px); overflow-y: auto; }
.gov-section { margin-bottom: 16px; padding: 10px; background: var(--bg-dark); border-radius: 6px; border: 1px solid var(--border); }
.gov-current { font-size: 13px; margin-bottom: 8px; }
.gov-current b { color: var(--purple); }
.gov-anarchy { color: var(--red); font-weight: 600; }
.gov-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.gov-card { flex: 1 1 180px; padding: 8px; background: linear-gradient(to bottom, rgba(156,39,176,0.15) 0%, var(--bg-dark) 100%); border: 1px solid var(--purple); border-radius: 6px; font-size: 12px; }
.gov-card:hover { background: rgba(156,39,176,0.25); }
.gov-name { font-weight: 600; color: var(--purple); margin-bottom: 2px; }
.gov-era { font-size: 10px; color: var(--text-dim); margin-bottom: 4px; }
.gov-desc { color: var(--text-dim); margin-bottom: 6px; }
.civic-btn-adopt { padding: 3px 10px; background: var(--purple); color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 11px; }
.civic-btn-adopt:hover { filter: brightness(1.2); }
.civic-era { margin-bottom: 16px; }
.civic-era h4 { color: var(--purple); margin-bottom: 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; }
.civic-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.civic-item {
  flex: 0 0 calc(50% - 3px); padding: 8px; background: linear-gradient(to bottom, rgba(26,26,46,0.9) 0%, var(--bg-dark) 100%);
  border: 1px solid var(--border); border-radius: 6px; font-size: 12px; transition: all 0.15s;
}
.civic-item.researched { border-color: var(--green); background: linear-gradient(to bottom, rgba(76,175,80,0.2) 0%, rgba(76,175,80,0.1) 100%); }
.civic-item.available { border-color: var(--purple); cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.3), inset 0 1px 0 rgba(156,39,176,0.15); }
.civic-item.available:hover { background: rgba(156,39,176,0.2); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.civic-item.current { border-color: var(--gold); background: rgba(240,192,64,0.15); animation: pulse 1.5s infinite; }
.civic-item.locked { opacity: 0.4; cursor: default; }
.civic-item .civic-name { font-weight: 600; }
.civic-item .civic-cost { font-size: 11px; color: var(--text-dim); }
.civic-item .civic-unlocks { font-size: 10px; color: var(--purple); margin-top: 2px; }
.civic-buttons { display: flex; gap: 4px; margin-top: 4px; }
.civic-btn-research { padding: 2px 8px; background: var(--purple); color: #fff; border: none; border-radius: 3px; cursor: pointer; font-size: 11px; }
.civic-btn-research:hover { filter: brightness(1.2); }
.civic-btn-cancel { padding: 2px 8px; background: var(--red); color: #fff; border: none; border-radius: 3px; cursor: pointer; font-size: 11px; }

/* City Panel Detail */
.city-yields { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.city-yield { font-size: 13px; }
.city-yield b { color: var(--gold); }
.build-queue { margin: 10px 0; }
.build-item { padding: 6px 10px; background: linear-gradient(to right, rgba(26,26,46,0.9), var(--bg-dark)); border-left: 3px solid var(--accent2); border-radius: 4px; margin-bottom: 4px; font-size: 13px; display: flex; justify-content: space-between; }
.build-item .progress-bar { width: 80px; height: 8px; background: var(--bg-panel); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.build-item .progress-fill { height: 100%; background: var(--accent2); border-radius: 4px; }
.build-options { max-height: 200px; overflow-y: auto; }
.build-option { padding: 6px 10px; background: linear-gradient(to bottom, rgba(26,26,46,0.8) 0%, var(--bg-dark) 100%); border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: 4px; margin-bottom: 3px; cursor: pointer; font-size: 12px; display: flex; justify-content: space-between; transition: all 0.15s; }
.build-option:hover { border-color: var(--accent2); border-left-color: var(--accent2); transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
.build-option.disabled { opacity: 0.35; cursor: default; }
.artifact-badge { display:inline-block; padding:2px 6px; background:linear-gradient(135deg, rgba(218,165,32,0.15), rgba(218,165,32,0.05)); border:1px solid rgba(218,165,32,0.4); border-radius:3px; font-size:10px; color:var(--gold); cursor:help; white-space:nowrap; }

/* Tile Info in Side Panel */
.tile-info { padding: 4px 0; }
.tile-info h4 { color: var(--accent2); margin-bottom: 6px; }
.tile-info .yields { color: var(--text-dim); font-size: 12px; margin-bottom: 4px; }
.tile-info .resource-info { color: var(--gold); font-size: 13px; }
.unit-card { padding: 8px; background: linear-gradient(to bottom, rgba(26,26,46,0.9) 0%, var(--bg-dark) 100%); border-left: 3px solid var(--gold); border-radius: 6px; margin-top: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.unit-card h4 { margin-bottom: 4px; }
.unit-card .stats { font-size: 12px; color: var(--text-dim); }
.hp-bar { width: 100%; height: 6px; background: #333; border-radius: 3px; margin-top: 4px; }
.hp-fill { height: 100%; border-radius: 3px; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: linear-gradient(to bottom, #3a4a6e, var(--border)); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: linear-gradient(to bottom, var(--accent2), #3a7a8a); }

/* Encyclopedia Panel */
#encyclopedia-panel.hidden { display: none !important; }
#encyclopedia-panel {
  position: absolute;
  top: 40px; bottom: 40px; left: 40px; right: 40px;
  z-index: 200;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  width: auto; max-height: none;
  transform: none; left: 40px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 60px rgba(15,52,96,0.3);
}
#encyclopedia-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}
#ency-sidebar {
  width: 140px;
  min-width: 140px;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 4px;
  overflow-y: auto;
}
#ency-sidebar button {
  text-align: left;
  padding: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: #ccc;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
}
#ency-sidebar button.active, #ency-sidebar button:hover {
  background: rgba(255,255,255,0.1);
  border-color: #555;
  color: #fff;
}
#ency-list {
  width: 220px;
  min-width: 220px;
  border-right: 1px solid #333;
  overflow-y: auto;
  padding: 8px;
}
#ency-list .ency-item {
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 4px;
  margin-bottom: 2px;
  font-size: 13px;
  color: #ccc;
}
#ency-list .ency-item:hover, #ency-list .ency-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
#ency-detail {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
#ency-detail h2 { margin-top: 0; color: var(--gold); }
#ency-detail .stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
#ency-detail .stat-box {
  background: rgba(255,255,255,0.05);
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #333;
}
#ency-detail .stat-label { color: #888; font-size: 11px; text-transform: uppercase; }
#ency-detail .stat-value { color: #fff; font-size: 16px; font-weight: bold; }
#ency-detail .flavor { color: #aaa; font-style: italic; margin: 12px 0; padding: 10px; border-left: 3px solid var(--gold); }
#ency-detail .effects-list { margin: 12px 0; }
#ency-detail .effects-list li { margin: 4px 0; color: #8f8; }
#ency-detail .upgrade-chain { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
#ency-detail .upgrade-chain span { padding: 4px 8px; background: rgba(255,255,255,0.05); border-radius: 4px; font-size: 12px; }
#ency-detail .upgrade-chain .current { background: rgba(240,192,64,0.2); border: 1px solid var(--gold); }
#ency-detail .ency-link { color: var(--accent2); cursor: pointer; text-decoration: underline; }
#ency-detail .ency-link:hover { color: #fff; }
#ency-detail .section-title { color: var(--accent2); font-size: 14px; text-transform: uppercase; letter-spacing: 1px; margin: 16px 0 8px; border-bottom: 1px solid #333; padding-bottom: 4px; }
#ency-detail .badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 11px; margin-right: 4px; }
#ency-detail .badge-era { background: rgba(83,168,182,0.2); border: 1px solid var(--accent2); color: var(--accent2); }
#ency-detail .badge-type { background: rgba(240,192,64,0.2); border: 1px solid var(--gold); color: var(--gold); }
#ency-detail .badge-domain { background: rgba(76,175,80,0.2); border: 1px solid var(--green); color: var(--green); }
.ency-ref { cursor: pointer; color: var(--accent2); font-size: 11px; vertical-align: super; margin-left: 2px; }
.ency-ref:hover { color: #fff; }

/* Golden Age Badge */
.golden-age-badge { color: var(--gold); font-weight: 700; animation: pulse 1.5s infinite; }



/* Promotion Popup */
#promotion-popup { top: 50%; left: 50%; transform: translate(-50%, -50%); width: 320px; max-height: 400px; overflow-y: auto; z-index: 150; }
.promo-option { padding: 10px; margin: 4px 0; background: var(--bg-dark); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; transition: all 0.15s; }
.promo-option:hover { border-color: var(--gold); background: rgba(240,192,64,0.1); }
.btn-promote { display: block; width: 100%; margin-top: 8px; padding: 6px; background: var(--gold); color: #000; border: none; border-radius: 4px; font-weight: 700; cursor: pointer; font-size: 13px; }
.btn-promote:hover { background: #ffd060; }

/* Diplomacy Panel */
#diplomacy-panel { top: 50px; left: 50%; transform: translateX(-50%); width: 550px; max-width: 95vw; max-height: calc(100vh - 110px); overflow-y: auto; }

/* City-State Panel */
#citystate-panel { top: 50px; left: 50%; transform: translateX(-50%); width: 450px; max-width: 95vw; max-height: calc(100vh - 110px); overflow-y: auto; }
.cs-influence-bar { height: 12px; background: #333; border-radius: 6px; overflow: hidden; margin: 8px 0; }
.cs-influence-fill { height: 100%; border-radius: 6px; transition: width 0.3s; }
.cs-status-neutral { color: #888; }
.cs-status-friend { color: #4caf50; }
.cs-status-ally { color: #ffc107; }
.diplo-row { display: flex; align-items: center; gap: 10px; padding: 10px; margin-bottom: 4px; background: linear-gradient(to bottom, rgba(26,26,46,0.9), var(--bg-dark)); border: 1px solid var(--border); border-left: 3px solid var(--accent2); border-radius: 4px; font-size: 13px; transition: all 0.15s; }
.diplo-row:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
.diplo-color-swatch { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(255,255,255,0.2); }
.diplo-name { font-weight: 600; flex: 1; }
.diplo-score { font-weight: 700; min-width: 40px; text-align: right; }
.diplo-status { min-width: 70px; text-align: center; font-size: 12px; }
.diplo-actions { display: flex; gap: 4px; }
.diplo-btn-war { background: rgba(233,69,96,0.2) !important; color: var(--red) !important; border: 1px solid var(--red) !important; font-size: 11px !important; padding: 4px 8px !important; }
.diplo-btn-war:hover { background: rgba(233,69,96,0.4) !important; }
.diplo-btn-peace { background: rgba(76,175,80,0.2) !important; color: var(--green) !important; border: 1px solid var(--green) !important; font-size: 11px !important; padding: 4px 8px !important; }
.diplo-btn-peace:hover { background: rgba(76,175,80,0.4) !important; }

/* City Specialization Badge */
.city-spec-badge { display: inline-block; padding: 3px 10px; margin-bottom: 8px; background: rgba(83,168,182,0.15); border: 1px solid var(--accent2); border-radius: 4px; font-size: 12px; color: var(--accent2); font-weight: 600; cursor: help; }

/* Trade Route Items */
.trade-route-item { padding: 4px 8px; margin: 3px 0; background: var(--bg-dark); border-radius: 4px; font-size: 12px; }
.trade-route-select { width: 100%; margin-top: 4px; padding: 6px; background: var(--bg-dark); color: var(--text); border: 1px solid var(--border); border-radius: 4px; font-size: 12px; cursor: pointer; }
.trade-route-select:hover { border-color: var(--accent2); }

/* Tech Tree Buttons */
.tech-buttons { display: flex; gap: 4px; margin-top: 4px; }
.tech-btn-research { padding: 2px 8px; font-size: 11px; font-weight: 600; background: var(--green); color: #fff; border: none; border-radius: 3px; cursor: pointer; }
.tech-btn-research:hover { background: #66bb6a; }
.tech-btn-cancel { padding: 2px 8px; font-size: 11px; font-weight: 600; background: #e07020; color: #fff; border: none; border-radius: 3px; cursor: pointer; }
.tech-btn-cancel:hover { background: #f08030; }
.tech-btn-ency { padding: 2px 6px; font-size: 11px; background: rgba(255,255,255,0.1); color: var(--text-dim); border: 1px solid var(--border); border-radius: 3px; cursor: pointer; }
.tech-btn-ency:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* Resource Tooltip */
.resource-tooltip { position: fixed; z-index: 300; background: var(--bg-dark); border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; min-width: 180px; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,0.6); pointer-events: none; }
.resource-tooltip.hidden { display: none; }
.rt-header { font-size: 14px; margin-bottom: 2px; }
.rt-header b { color: var(--gold); }
.rt-sep { border-top: 1px solid var(--border); margin: 6px 0; }
.rt-row { display: flex; justify-content: space-between; gap: 16px; padding: 1px 0; }
.rt-row span:last-child { color: var(--gold); font-weight: 600; }
.rt-net { margin-top: 2px; font-weight: 700; }

/* ========== DIALOGUE SYSTEM ========== */
#dialogue-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  animation: dlg-fade-in 0.3s ease;
}
#dialogue-overlay.hidden { display: none; }
@keyframes dlg-fade-in { from { opacity: 0; } to { opacity: 1; } }

#dialogue-box {
  position: relative;
  display: flex;
  width: min(720px, 90vw);
  min-height: 220px;
  background: linear-gradient(135deg, #0f1a30 0%, #1a1a2e 100%);
  border: 2px solid var(--gold);
  border-radius: 10px;
  box-shadow: 0 0 40px rgba(240,192,64,0.25), 0 8px 32px rgba(0,0,0,0.6);
  overflow: hidden;
  animation: dlg-slide-up 0.35s ease;
}
@keyframes dlg-slide-up { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

#dialogue-portrait {
  width: 140px; min-height: 200px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 64px; font-weight: 700; color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  border-right: 1px solid var(--border);
}

#dialogue-content {
  flex: 1; padding: 20px 24px; display: flex; flex-direction: column; gap: 12px;
}

#dialogue-name {
  font-size: 20px; font-weight: 700; color: var(--gold);
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

#dialogue-text {
  flex: 1;
  font-size: 15px; line-height: 1.6; color: var(--text);
  max-height: 200px; overflow-y: auto;
  padding-right: 8px;
}
#dialogue-text::-webkit-scrollbar { width: 4px; }
#dialogue-text::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 2px; }

#dialogue-text .dlg-loading {
  color: var(--text-dim); font-style: italic;
}
@keyframes dlg-dots { 0%,20% { content: '.'; } 40% { content: '..'; } 60%,100% { content: '...'; } }
#dialogue-text .dlg-loading::after { content: '...'; animation: dlg-dots 1.5s steps(1) infinite; }

#dialogue-actions {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto;
}
#dialogue-actions button {
  padding: 6px 16px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--gold); border-radius: 4px;
  background: rgba(240,192,64,0.1); color: var(--gold);
  cursor: pointer; transition: all 0.2s;
}
#dialogue-actions button:hover {
  background: var(--gold); color: #000;
}
#dialogue-actions button.dlg-btn-danger {
  border-color: var(--red); color: var(--red); background: rgba(233,69,96,0.1);
}
#dialogue-actions button.dlg-btn-danger:hover {
  background: var(--red); color: #fff;
}

#dialogue-close {
  position: absolute; top: 8px; right: 10px;
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: linear-gradient(to bottom, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.03) 100%);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 50%;
  color: var(--text-dim); font-size: 20px; cursor: pointer; line-height: 1;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: all 0.15s;
}
#dialogue-close:hover { color: #fff; background: linear-gradient(to bottom, rgba(233,69,96,0.4) 0%, rgba(233,69,96,0.2) 100%); border-color: var(--accent); box-shadow: 0 0 8px rgba(233,69,96,0.3); }
#dialogue-close:active { box-shadow: inset 0 2px 4px rgba(0,0,0,0.5); transform: scale(0.95); }

/* Voice chat in dialogue */
#dialogue-voice {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
#dialogue-mic {
  background: linear-gradient(to bottom, #2a1810, #1a0f08);
  border: 1px solid #c9a84c;
  color: #c9a84c;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 20px;
  transition: all 0.2s;
}
#dialogue-mic:hover { background: linear-gradient(to bottom, #3d2517, #2a1810); box-shadow: 0 0 10px rgba(201,168,76,0.3); }
#dialogue-mic.listening {
  background: linear-gradient(to bottom, #4a1010, #2a0808);
  border-color: #e94560;
  color: #e94560;
  animation: mic-pulse 1s ease-in-out infinite;
}
@keyframes mic-pulse { 0%,100% { box-shadow: 0 0 5px rgba(233,69,96,0.3); } 50% { box-shadow: 0 0 20px rgba(233,69,96,0.6); } }
#dialogue-mic.processing {
  opacity: 0.6;
  cursor: wait;
}
#dialogue-speech-status {
  font-size: 12px;
  color: #8a7a6a;
  font-style: italic;
}
#dialogue-player-speech {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(201,168,76,0.1);
  border-left: 3px solid #c9a84c;
  font-size: 13px;
  color: #e8d5b0;
  font-style: italic;
  border-radius: 0 4px 4px 0;
}

/* Narration notification (styled differently from normal notifications) */
.notification.narration-notif {
  border-left: 3px solid var(--gold);
  background: linear-gradient(90deg, rgba(240,192,64,0.1), var(--bg-panel));
  font-style: italic;
  max-width: 400px;
}

/* ========== NARRATIVE OVERLAY ========== */

#narrative-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  animation: narrativeFadeIn 1.5s ease-out;
}
#narrative-overlay.hidden { display: none; }

@keyframes narrativeFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes narrativeTextFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

#narrative-content {
  max-width: 680px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 48px 40px;
  text-align: center;
  animation: narrativeTextFadeIn 2s ease-out 0.5s both;
}

#narrative-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 42px;
  color: #D4A843;
  margin: 0 0 8px 0;
  letter-spacing: 2px;
  text-shadow: 0 0 30px rgba(212, 168, 67, 0.3);
}

#narrative-subtitle {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  color: #a08838;
  margin: 0 0 36px 0;
  font-style: italic;
  letter-spacing: 1px;
}

#narrative-text {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 17px;
  color: #d4c9a8;
  line-height: 1.85;
  margin: 0 0 40px 0;
  text-align: left;
  white-space: pre-line;
}

#narrative-dismiss {
  background: linear-gradient(to bottom, rgba(212,168,67,0.15) 0%, transparent 100%);
  border: 2px solid #D4A843;
  color: #D4A843;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  padding: 12px 40px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.3s ease;
  border-bottom: 3px solid rgba(160,120,30,0.6);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(212,168,67,0.2);
}
#narrative-dismiss:hover {
  background: #D4A843;
  color: #1a1a2e;
}
#narrative-dismiss:active {
  transform: translateY(1px);
  border-bottom-width: 1px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}

/* Era intro variant */
#narrative-overlay.era-intro #narrative-title {
  font-size: 56px;
  margin-bottom: 16px;
}
#narrative-overlay.era-intro #narrative-text {
  text-align: center;
  font-size: 19px;
}

/* Event notification variant */
.notification.narrative-event {
  border-left: 3px solid #D4A843;
  background: linear-gradient(90deg, rgba(212,168,67,0.12), var(--bg-panel));
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  max-width: 440px;
  line-height: 1.6;
  color: #d4c9a8;
}

/* Music toggle button */
#music-toggle {
  background: none;
  border: 1px solid var(--text-dim);
  color: var(--text);
  font-size: 16px;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}
#music-toggle:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* Video Overlay */
#video-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
#video-overlay.hidden { display: none; }
#game-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
#video-skip {
  position: absolute;
  bottom: 30px;
  right: 30px;
  background: rgba(0,0,0,0.7);
  border: 1px solid #c9a84c;
  color: #c9a84c;
  padding: 8px 20px;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
}
#video-skip:hover { background: rgba(201,168,76,0.3); }

/* Narration Book Overlay */
#narration-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.5s ease;
}
#narration-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes bookOpen { from { transform: scale(0.8) rotateY(-10deg); opacity: 0; } to { transform: scale(1) rotateY(0); opacity: 1; } }
#narration-book {
  background: linear-gradient(135deg, #2a1810 0%, #3d2517 30%, #2a1810 100%);
  border: 3px solid #c9a84c;
  border-radius: 8px;
  padding: 40px 50px;
  max-width: 600px;
  width: 90%;
  text-align: center;
  box-shadow: 0 0 60px rgba(201,168,76,0.3), inset 0 0 30px rgba(0,0,0,0.5);
  animation: bookOpen 0.6s ease;
  position: relative;
}
#narration-book::before, #narration-book::after {
  content: '❧';
  position: absolute;
  color: #c9a84c;
  font-size: 24px;
  opacity: 0.5;
}
#narration-book::before { top: 10px; left: 20px; }
#narration-book::after { bottom: 10px; right: 20px; transform: rotate(180deg); }
#narration-icon {
  font-size: 48px;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 10px rgba(201,168,76,0.5));
}
#narration-quote {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 18px;
  line-height: 1.7;
  color: #e8d5b0;
  font-style: italic;
  margin-bottom: 20px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
#narration-attribution {
  font-size: 14px;
  color: #c9a84c;
  margin-bottom: 25px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
#narration-dismiss {
  background: linear-gradient(to bottom, #c9a84c, #a07830);
  border: none;
  color: #1a0f08;
  padding: 10px 30px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 4px;
  letter-spacing: 1px;
}
#narration-dismiss:hover { background: linear-gradient(to bottom, #d4b45c, #b08838); }

/* ========== RESPONSIVE: 4K / LARGE SCREENS (min-width: 2560px) ========== */
@media (min-width: 2560px) {
  html, body { font-size: 16px; }
  .panel, .overlay-panel { max-width: 900px; }
  #city-panel { width: 750px; }
  #tech-panel { width: 850px; }
  #civics-panel { width: 850px; }
  #diplomacy-panel { width: 650px; }
  .btn { padding: 14px 36px; font-size: 17px; }
  .btn-end-turn { padding: 12px 32px; font-size: 17px; }
}

/* ========== RESPONSIVE: TABLET (max-width: 1024px) ========== */
@media (max-width: 1024px) {
  /* Panels constrained to viewport */
  .setup-panel { width: 90vw; max-width: 400px; padding: 24px; }
  .save-panel { width: 90vw; max-width: 500px; }
  #city-panel { width: 95vw; max-width: 600px; }
  #tech-panel { width: 95vw; max-width: 700px; }
  #civics-panel { width: 95vw; max-width: 700px; }
  #diplomacy-panel { width: 95vw; max-width: 550px; }
  #game-menu { width: 80vw; max-width: 280px; }
  #promotion-popup { width: 90vw; max-width: 320px; }

  /* Encyclopedia: inset reduced */
  #encyclopedia-panel { top: 20px; bottom: 20px; left: 10px; right: 10px; }
  #ency-sidebar { width: 110px; min-width: 110px; }
  #ency-list { width: 180px; min-width: 180px; }

  /* Minimap smaller */
  #minimap { width: 160px; height: 104px; }

  /* Font sizes slightly smaller */
  .game-title { letter-spacing: 6px; }
  .game-subtitle { font-size: 16px; margin-bottom: 32px; }

  /* Side panel narrower */
  .side-panel { width: 220px; }

  /* Resource bar scroll */
  .resource-bar { gap: 10px; }
}

/* ========== RESPONSIVE: MOBILE (max-width: 640px) ========== */
@media (max-width: 640px) {
  html, body { font-size: 14px; }

  /* Top bar: allow wrapping, scrollable resources */
  #top-bar { padding: 4px 8px; min-height: auto; flex-wrap: wrap; gap: 4px; }
  .resource-bar { gap: 8px; flex: 1 1 100%; order: 2; padding: 2px 0; overflow-x: auto; }
  .turn-info { font-size: 12px; gap: 8px; }
  .top-buttons { gap: 2px; }
  .btn-sm { padding: 6px 8px; font-size: 16px; }

  /* Panels become full-width sheets */
  .setup-panel { width: 95vw; max-width: none; padding: 20px 16px; }
  .save-panel { width: 95vw; max-width: none; }
  #city-panel { width: 100vw; max-width: none; top: 0; left: 0; transform: none; max-height: 100vh; border-radius: 0; }
  #tech-panel { width: 100vw; max-width: none; top: 0; left: 0; transform: none; max-height: 100vh; border-radius: 0; }
  #civics-panel { width: 100vw; max-width: none; top: 0; left: 0; transform: none; max-height: 100vh; border-radius: 0; }
  #diplomacy-panel { width: 100vw; max-width: none; top: 0; left: 0; transform: none; max-height: 100vh; border-radius: 0; }
  #game-menu { width: 90vw; max-width: none; }
  #promotion-popup { width: 95vw; max-width: none; }

  /* Side panel: full width overlay */
  .side-panel { width: 100vw; right: 0; top: 0; max-height: 100vh; border-radius: 0; z-index: 100; }

  /* Encyclopedia: full screen, stacked */
  #encyclopedia-panel { top: 0; bottom: 0; left: 0; right: 0; border-radius: 0; }
  #encyclopedia-content { flex-direction: column; }
  #ency-sidebar { width: 100%; min-width: 0; flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid #333; padding: 4px; overflow-x: auto; overflow-y: visible; max-height: 50px; }
  #ency-sidebar button { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
  #ency-list { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid #333; max-height: 120px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 2px; }
  #ency-list .ency-item { flex: 0 0 auto; }
  #ency-detail { padding: 10px; }

  /* Dialogue: portrait above text */
  #dialogue-box { flex-direction: column; min-height: auto; }
  #dialogue-portrait { width: 100%; min-height: 100px; max-height: 120px; border-right: none; border-bottom: 1px solid var(--border); }
  #dialogue-content { padding: 14px 16px; }
  #dialogue-name { font-size: 18px; }
  #dialogue-text { font-size: 14px; max-height: 150px; }
  #dialogue-close { top: 6px; right: 8px; width: 36px; height: 36px; }

  /* Bottom bar: scrollable actions */
  #bottom-bar { padding: 4px 8px; min-height: 44px; }
  #action-buttons { overflow-x: auto; flex-shrink: 1; }
  #action-buttons button { min-height: 38px; padding: 6px 10px; font-size: 12px; }
  .btn-end-turn { padding: 8px 16px; font-size: 14px; min-height: 44px; flex-shrink: 0; }

  /* Button touch targets */
  .btn { min-height: 44px; padding: 10px 20px; min-width: 120px; }
  .btn-close { width: 36px; height: 36px; font-size: 22px; }

  /* Minimap: hidden by default, toggle-able */
  #minimap-container { display: none; }
  #minimap-container.visible { display: block; }
  #minimap-toggle { display: block; }
  #minimap { width: 160px; height: 104px; }

  /* Narrative: tighter */
  #narrative-content { padding: 24px 20px; max-width: 95vw; }
  #narrative-title { font-size: clamp(24px, 6vw, 42px); }
  #narrative-subtitle { font-size: 14px; margin-bottom: 20px; }
  #narrative-text { font-size: 15px; line-height: 1.7; }
  #narrative-dismiss { padding: 10px 28px; font-size: 15px; }

  /* Era intro smaller */
  #narrative-overlay.era-intro #narrative-title { font-size: clamp(28px, 7vw, 56px); }
  #narrative-overlay.era-intro #narrative-text { font-size: 16px; }

  /* Resource tooltip */
  .resource-tooltip { min-width: 150px; font-size: 12px; }

  /* Notification */
  .notification { font-size: 13px; padding: 8px 14px; max-width: 85vw; }
  .notification.narration-notif { max-width: 85vw; }
  .notification.narrative-event { max-width: 85vw; }

  /* Form tweaks */
  .form-group input, .form-group select { font-size: 16px; padding: 12px; }
  .form-buttons { flex-direction: column; }
  .form-buttons .btn { min-width: 100%; }

  /* Game title on small screens */
  .game-title { letter-spacing: 3px; }
  .game-subtitle { font-size: 14px; letter-spacing: 2px; margin-bottom: 32px; }
  .menu-buttons .btn { min-width: 180px; }
}
