/* Bomby Deluxe — Styles (premium dark fantasy) */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Cinzel+Decorative:wght@400;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0d0d1a;
  color: #d4c4a8;
  font-family: 'Courier New', Courier, monospace;
  overflow: hidden;
  user-select: none;
}

canvas {
  display: block;
  cursor: crosshair;
}
canvas:active { cursor: grabbing; }

/* ==================== SCREENS ==================== */
.screen {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 100;
  background: radial-gradient(ellipse at 50% 30%, rgba(30, 20, 60, 0.98), rgba(8, 8, 18, 0.99));
  overflow: hidden;
}
.screen::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: conic-gradient(from 0deg at 50% 50%,
    transparent 0deg, rgba(201,168,76,0.03) 60deg,
    transparent 120deg, rgba(123,104,238,0.03) 180deg,
    transparent 240deg, rgba(201,168,76,0.03) 300deg,
    transparent 360deg);
  animation: screenShimmer 20s linear infinite;
  pointer-events: none;
  z-index: -1;
}
@keyframes screenShimmer {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.screen.screen-enter {
  animation: screenFadeIn 0.5s ease-out;
}
@keyframes screenFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#main-menu { display: flex; }
#menu-bg-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: -1;
  opacity: 0.6;
}

/* ==================== TYPOGRAPHY ==================== */
.screen h1 {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-size: 3em;
  font-weight: 700;
  color: #c9a84c;
  text-shadow:
    0 0 20px rgba(200,168,76,0.4),
    0 0 60px rgba(200,168,76,0.15),
    0 2px 4px rgba(0,0,0,0.8);
  margin-bottom: 0.3em;
  letter-spacing: 4px;
  text-transform: uppercase;
  animation: titleGlow 3s ease-in-out infinite;
}
@keyframes titleGlow {
  0%, 100% {
    text-shadow: 0 0 20px rgba(200,168,76,0.3), 0 0 4px rgba(200,168,76,0.1), 0 2px 4px rgba(0,0,0,0.8);
    filter: brightness(1);
  }
  50% {
    text-shadow: 0 0 40px rgba(200,168,76,0.6), 0 0 80px rgba(200,168,76,0.25), 0 0 4px rgba(255,220,120,0.3), 0 2px 4px rgba(0,0,0,0.8);
    filter: brightness(1.05);
  }
}

.screen h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.05em;
  color: #7b68a8;
  margin-bottom: 2em;
  font-weight: 400;
  letter-spacing: 3px;
  text-shadow: 0 0 12px rgba(123,104,168,0.2);
}

/* ==================== MENU BUTTONS ==================== */
.menu-btn {
  display: block;
  padding: 13px 52px;
  margin: 6px;
  font-size: 0.95em;
  font-family: 'Cinzel', serif;
  font-weight: 600;
  background: linear-gradient(135deg, #1a1528 0%, #251e3a 50%, #1a1528 100%);
  color: #c9a84c;
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.25s ease;
  text-transform: uppercase;
  letter-spacing: 2px;
  position: relative;
  overflow: hidden;
}
.menu-btn::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(201,168,76,0.08), transparent);
  transition: left 0.5s ease;
}
.menu-btn:hover::before {
  left: 100%;
}
.menu-btn:hover {
  background: linear-gradient(135deg, #2a2048 0%, #3d3560 50%, #2a2048 100%);
  color: #f0d878;
  border-color: rgba(201,168,76,0.6);
  box-shadow:
    0 0 20px rgba(200,168,76,0.2),
    0 0 40px rgba(200,168,76,0.08),
    inset 0 0 20px rgba(200,168,76,0.05);
  transform: translateY(-2px);
  text-shadow: 0 0 8px rgba(240,216,120,0.3);
}
.menu-btn:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.4);
}

/* ==================== GAME SCREEN ==================== */
#game-screen {
  z-index: 0;
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
}

/* ==================== HUD ==================== */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 7px 16px;
  background: linear-gradient(180deg, rgba(12, 10, 24, 0.95), rgba(8, 8, 18, 0.88));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(61, 53, 96, 0.5);
  box-shadow: 0 2px 16px rgba(0,0,0,0.4), inset 0 -1px 0 rgba(201,168,76,0.08);
  font-size: 0.85em;
  z-index: 10;
}

#hud span { white-space: nowrap; }
#hud-mana { color: #9b88ff; text-shadow: 0 0 8px rgba(123,104,238,0.3); }
#hud-turn { color: #a09888; }
#hud-stats { color: #9a9a78; }

.hud-btn {
  padding: 5px 14px;
  font-size: 0.85em;
  font-family: 'Courier New', Courier, monospace;
  background: rgba(26, 21, 40, 0.7);
  color: #c9a84c;
  border: 1px solid rgba(61, 53, 96, 0.6);
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.15s ease;
}
.hud-btn:hover {
  background: rgba(61, 53, 96, 0.8);
  color: #f0d878;
  border-color: rgba(201,168,76,0.5);
  box-shadow: 0 0 10px rgba(201,168,76,0.15);
}
.hud-btn:active { transform: scale(0.96); }

.hud-btn-end {
  margin-left: auto;
}

/* ==================== INFO PANEL ==================== */
#info-panel {
  position: fixed;
  bottom: 10px;
  left: 10px;
  padding: 10px 14px;
  background: linear-gradient(160deg, rgba(14, 12, 28, 0.92), rgba(8, 8, 18, 0.88));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(61, 53, 96, 0.4);
  border-top: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: 6px;
  font-size: 0.8em;
  line-height: 1.6;
  z-index: 10;
  min-width: 200px;
  max-width: 280px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

/* ==================== TOAST NOTIFICATIONS ==================== */
#toast-container {
  position: fixed;
  top: 48px;
  right: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.toast {
  padding: 8px 16px;
  background: linear-gradient(135deg, rgba(18, 14, 32, 0.94), rgba(10, 10, 22, 0.92));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(61, 53, 96, 0.5);
  border-left: 3px solid #c9a84c;
  border-radius: 6px;
  font-size: 0.8em;
  color: #d4c4a8;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35), 0 0 8px rgba(201,168,76,0.08);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
.toast-out {
  opacity: 0.3;
  transform: translateX(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* ==================== PANEL BACKDROP ==================== */
#panel-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 40;
  animation: backdropIn 0.2s ease-out;
}
@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==================== CITADEL PANEL ==================== */
#citadel-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(170deg, rgba(16, 14, 32, 0.97), rgba(8, 8, 18, 0.98));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(61, 53, 96, 0.5);
  border-top: 2px solid rgba(201, 168, 76, 0.4);
  border-radius: 8px;
  padding: 18px 20px;
  z-index: 50;
  max-width: 650px;
  max-height: 80vh;
  overflow-y: auto;
  min-width: 420px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5), 0 0 1px rgba(201,168,76,0.2);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(61, 53, 96, 0.3);
}
.panel-header h3 {
  color: #c9a84c;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 1.1em;
  text-shadow: 0 0 12px rgba(201,168,76,0.2);
}
.panel-close {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  color: #888;
  font-size: 1em;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.panel-close:hover { background: #cc3333; color: #fff; border-color: #cc3333; }

#citadel-panel h4 {
  color: #9b88ff;
  margin: 14px 0 8px;
  text-transform: uppercase;
  font-size: 0.82em;
  letter-spacing: 2px;
  border-bottom: 1px solid rgba(123,104,238,0.15);
  padding-bottom: 5px;
}

#citadel-panel p {
  font-size: 0.85em;
  margin: 4px 0;
}

.prod-status {
  color: #c9a84c;
  background: rgba(30, 28, 10, 0.6);
  padding: 8px 12px;
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 4px;
}

.cancel-btn, .rush-btn {
  padding: 4px 12px;
  font-size: 0.8em;
  font-family: 'Courier New', Courier, monospace;
  background: rgba(50, 30, 30, 0.6);
  color: #cc6644;
  border: 1px solid rgba(102, 51, 51, 0.5);
  border-radius: 4px;
  cursor: pointer;
  margin-left: 8px;
  transition: all 0.15s ease;
}
.cancel-btn:hover { background: rgba(102, 51, 51, 0.8); color: #fff; }

.rush-btn {
  background: rgba(26, 26, 42, 0.6);
  color: #9b88ff;
  border-color: rgba(61, 53, 96, 0.5);
}
.rush-btn:hover { background: rgba(61, 53, 96, 0.8); color: #fff; box-shadow: 0 0 10px rgba(123,104,238,0.2); }

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.panel-item {
  padding: 10px;
  border-radius: 5px;
  font-size: 0.78em;
  line-height: 1.4;
  border: 1px solid rgba(34, 34, 34, 0.6);
  transition: all 0.15s ease;
}

.unit-desc {
  color: #888;
  font-size: 0.9em;
}

.item-done {
  background: rgba(10, 30, 10, 0.5);
  border-color: rgba(51, 102, 51, 0.5);
  color: #66aa66;
}
.item-avail {
  background: rgba(15, 15, 35, 0.6);
  border-color: rgba(61, 53, 96, 0.5);
  cursor: pointer;
  color: #c0b8a0;
}
.item-avail:hover {
  background: rgba(30, 26, 60, 0.7);
  border-color: rgba(123, 104, 238, 0.6);
  box-shadow: 0 0 12px rgba(123,104,238,0.1);
  transform: translateY(-1px);
}
.item-locked {
  background: rgba(10, 10, 15, 0.4);
  border-color: rgba(26, 26, 34, 0.5);
  color: #444;
}

/* ==================== SETUP SCREEN ==================== */
.setup-content {
  text-align: center;
  min-width: 380px;
}

.setup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0;
  padding: 10px 18px;
  background: linear-gradient(135deg, rgba(15,12,30,0.9), rgba(20,16,38,0.9));
  border: 1px solid rgba(61,53,96,0.4);
  border-radius: 6px;
  transition: border-color 0.2s ease;
}
.setup-row:hover {
  border-color: rgba(201,168,76,0.3);
}
.setup-row label {
  font-family: 'Cinzel', serif;
  color: #c9a84c;
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 0 8px rgba(201,168,76,0.15);
}
.setup-row select {
  background: linear-gradient(135deg, #0a0a18 0%, #12101e 100%);
  color: #d4c4a8;
  border: 1px solid rgba(61,53,96,0.6);
  padding: 8px 14px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85em;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23c9a84c' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.setup-row select:hover {
  border-color: rgba(201,168,76,0.5);
}
.setup-row select:focus {
  outline: none;
  border-color: #7b68ee;
  box-shadow: 0 0 12px rgba(123,104,238,0.2);
}

/* ==================== TRIBE PICKER ==================== */
.tribe-picker {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tribe-card {
  width: 150px;
  background: linear-gradient(170deg, rgba(26,22,48,0.95), rgba(14,12,28,0.98));
  border: 2px solid rgba(60,55,90,0.5);
  border-left: 4px solid #555;
  border-radius: 10px;
  padding: 14px 10px;
  cursor: pointer;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.tribe-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.tribe-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.tribe-card:hover::before { opacity: 1; }
.tribe-card:hover {
  transform: translateY(-4px);
  border-color: rgba(120,110,160,0.7);
}
.tribe-card:hover::after {
  opacity: 1;
  box-shadow: inset 0 0 30px rgba(123,104,238,0.08);
}

/* Per-tribe glow colors on hover */
.tribe-card[data-tribe="IRONGUARD"]:hover {
  border-color: rgba(68,136,255,0.6);
  box-shadow: 0 0 25px rgba(68,136,255,0.15), 0 8px 24px rgba(0,0,0,0.3);
}
.tribe-card[data-tribe="SHADOWFEN"]:hover {
  border-color: rgba(51,170,51,0.6);
  box-shadow: 0 0 25px rgba(51,170,51,0.15), 0 8px 24px rgba(0,0,0,0.3);
}
.tribe-card[data-tribe="FROSTBORN"]:hover {
  border-color: rgba(51,204,204,0.6);
  box-shadow: 0 0 25px rgba(51,204,204,0.15), 0 8px 24px rgba(0,0,0,0.3);
}
.tribe-card[data-tribe="CELESTIALS"]:hover {
  border-color: rgba(255,215,0,0.6);
  box-shadow: 0 0 25px rgba(255,215,0,0.15), 0 8px 24px rgba(0,0,0,0.3);
}

/* Selected state */
.tribe-card.selected {
  border-color: #c9a84c !important;
  box-shadow: 0 0 20px rgba(201,168,76,0.25), 0 0 40px rgba(201,168,76,0.1), 0 6px 20px rgba(0,0,0,0.3);
}
.tribe-card.selected::before { opacity: 1; background: linear-gradient(90deg, transparent, rgba(201,168,76,0.3), transparent); }
.tribe-card.selected::after { opacity: 1; box-shadow: inset 0 0 40px rgba(201,168,76,0.06); }

/* Per-tribe selected glow */
.tribe-card[data-tribe="IRONGUARD"].selected {
  border-color: #4488ff !important;
  box-shadow: 0 0 20px rgba(68,136,255,0.3), 0 0 40px rgba(68,136,255,0.1);
}
.tribe-card[data-tribe="SHADOWFEN"].selected {
  border-color: #33aa33 !important;
  box-shadow: 0 0 20px rgba(51,170,51,0.3), 0 0 40px rgba(51,170,51,0.1);
}
.tribe-card[data-tribe="FROSTBORN"].selected {
  border-color: #33cccc !important;
  box-shadow: 0 0 20px rgba(51,204,204,0.3), 0 0 40px rgba(51,204,204,0.1);
}
.tribe-card[data-tribe="CELESTIALS"].selected {
  border-color: #ffd700 !important;
  box-shadow: 0 0 20px rgba(255,215,0,0.3), 0 0 40px rgba(255,215,0,0.1);
}

/* Locked tribe */
.tribe-card.locked { opacity: 0.65; }
.tribe-card.locked:hover { opacity: 0.85; }
.tribe-card .lock-badge {
  position: absolute;
  top: -1px;
  right: -1px;
  background: linear-gradient(135deg, #c9a84c, #a88630);
  color: #0d0d1a;
  font-size: 0.7em;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 0 8px 0 8px;
  line-height: 1.2;
  text-shadow: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.tribe-card .tribe-name {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  color: #eee;
  font-size: 0.95em;
  margin: 0 0 6px;
  letter-spacing: 1px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}
.tribe-card .tribe-perk {
  font-size: 0.72em;
  color: #9a90b0;
  font-style: italic;
  line-height: 1.4;
}

/* ==================== AI ROSTER ==================== */
.ai-row {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  background: linear-gradient(135deg, rgba(15,12,30,0.9), rgba(20,16,38,0.9));
  border: 1px solid rgba(61,53,96,0.4);
  border-radius: 6px;
  margin-bottom: 6px;
  transition: border-color 0.2s ease;
}
.ai-row:hover { border-color: rgba(201,168,76,0.3); }
.ai-row .ai-label {
  color: #888;
  font-size: 0.78em;
  min-width: 34px;
  text-align: center;
  flex-shrink: 0;
}
.ai-row select {
  flex: 1;
  min-width: 0;
  background: linear-gradient(135deg, #0a0a18 0%, #12101e 100%);
  color: #d4c4a8;
  border: 1px solid rgba(61,53,96,0.6);
  padding: 6px 8px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.78em;
  border-radius: 4px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23c9a84c' stroke-width='1' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 22px;
}
.ai-row select:hover { border-color: rgba(201,168,76,0.5); }
.ai-row select:focus { outline: none; border-color: #7b68ee; }
.ai-remove-btn {
  width: 26px;
  height: 26px;
  background: rgba(50,30,30,0.5);
  color: #cc6644;
  border: 1px solid rgba(102,51,51,0.4);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.ai-remove-btn:hover { background: rgba(102,51,51,0.7); color: #fff; }

.setup-buttons {
  margin-top: 24px;
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* ==================== INSTRUCTIONS ==================== */
.instructions-content {
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 34px;
  text-align: left;
  background: linear-gradient(170deg, rgba(18,14,34,0.5), rgba(10,8,20,0.5));
  border: 1px solid rgba(61,53,96,0.3);
  border-radius: 12px;
}
.instructions-content h1 { text-align: center; }
.instructions-section {
  margin-bottom: 18px;
  padding: 12px 14px;
  background: rgba(15,12,30,0.4);
  border-left: 3px solid rgba(201,168,76,0.3);
  border-radius: 0 6px 6px 0;
}
.instructions-section h3 {
  font-family: 'Cinzel', serif;
  color: #c9a84c;
  margin-bottom: 6px;
  font-size: 0.95em;
  letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(201,168,76,0.15);
}
.instructions-section p {
  color: #a8a090;
  font-size: 0.85em;
  line-height: 1.6;
  margin: 3px 0;
}
#btn-instructions-back {
  display: block;
  margin: 20px auto 0;
}
.instructions-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(20,16,36,0.8);
  border: 1px solid rgba(61,53,96,0.5);
  color: #999;
  font-size: 1.5em;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 110;
  transition: all 0.2s ease;
}
.instructions-close:hover { background: #cc3333; color: #fff; border-color: #cc3333; }

/* ==================== BOTTOM ACTION BUTTONS ==================== */
#bottom-actions {
  position: fixed;
  right: 8px;
  bottom: 160px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 10;
}
.bottom-btn {
  padding: 7px 14px;
  font-size: 0.75em;
  font-family: 'Courier New', Courier, monospace;
  background: linear-gradient(180deg, rgba(30, 25, 48, 0.88), rgba(20, 16, 34, 0.88));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #c9a84c;
  border: 1px solid rgba(61, 53, 96, 0.5);
  border-radius: 5px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all 0.15s ease;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.bottom-btn:hover {
  background: linear-gradient(180deg, rgba(61, 53, 96, 0.95), rgba(45, 38, 80, 0.95));
  color: #f0d878;
  border-color: rgba(201,168,76,0.4);
  box-shadow: 0 2px 12px rgba(201,168,76,0.12);
  transform: translateX(-2px);
}
.bottom-btn:active { transform: translateX(-1px) scale(0.97); }
.bottom-btn-tech {
  background: linear-gradient(180deg, rgba(32, 28, 52, 0.88), rgba(22, 18, 40, 0.88));
  border-color: rgba(90, 61, 128, 0.5);
  color: #9b78ee;
}
.bottom-btn-tech:hover {
  background: linear-gradient(180deg, rgba(90, 61, 128, 0.95), rgba(70, 48, 110, 0.95));
  color: #fff;
  box-shadow: 0 2px 12px rgba(123,104,238,0.2);
}
.bottom-btn-end {
  background: linear-gradient(180deg, rgba(26, 42, 24, 0.88), rgba(18, 32, 16, 0.88));
  border-color: rgba(74, 122, 51, 0.5);
  color: #88cc44;
}
.bottom-btn-end:hover {
  background: linear-gradient(180deg, rgba(74, 122, 51, 0.95), rgba(58, 100, 38, 0.95));
  color: #fff;
  box-shadow: 0 2px 12px rgba(100,180,60,0.2);
}

/* Hotkey legend — hidden */
#hotkey-legend { display: none; }

/* ==================== LIST PANEL ==================== */
#list-panel {
  position: fixed;
  top: 44px;
  left: 10px;
  background: linear-gradient(170deg, rgba(16, 14, 32, 0.97), rgba(8, 8, 18, 0.97));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(61, 53, 96, 0.4);
  border-top: 2px solid rgba(201, 168, 76, 0.3);
  border-radius: 8px;
  padding: 14px;
  z-index: 50;
  max-width: 420px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  min-width: 300px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
#list-panel h4 {
  color: #9b88ff;
  margin: 12px 0 5px;
  text-transform: uppercase;
  font-size: 0.78em;
  letter-spacing: 2px;
  border-bottom: 1px solid rgba(123,104,238,0.15);
  padding-bottom: 4px;
}
.list-items {
  max-height: 250px;
  overflow-y: auto;
}
.list-row {
  padding: 6px 10px;
  font-size: 0.78em;
  color: #c0b8a0;
  border-bottom: 1px solid rgba(26, 26, 40, 0.5);
  cursor: pointer;
  transition: all 0.12s ease;
  border-radius: 3px;
  margin-bottom: 1px;
}
.list-row:hover {
  background: rgba(30, 26, 60, 0.5);
  color: #f0d878;
  border-bottom-color: transparent;
}

/* ==================== TECH PANEL ==================== */
#tech-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at 50% 15%, rgba(22, 18, 44, 0.98), rgba(8, 8, 16, 0.98));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(61, 53, 96, 0.5);
  border-top: 2px solid rgba(123, 104, 238, 0.6);
  border-radius: 8px;
  padding: 18px 22px;
  z-index: 50;
  max-width: 860px;
  max-height: 88vh;
  overflow-y: auto;
  min-width: 540px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5), 0 0 40px rgba(123, 104, 238, 0.08), inset 0 1px 0 rgba(123, 104, 238, 0.1);
}

/* Progress bar */
.tech-progress {
  position: relative;
  background: #080812;
  border: 1px solid #2a2540;
  border-radius: 10px;
  height: 22px;
  margin: 8px 0 14px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}
.tech-progress-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, #3d3560 0%, #7b68ee 60%, #9b88ff 100%);
  border-radius: 10px;
  transition: width 0.4s ease;
  box-shadow: 0 0 8px rgba(123, 104, 238, 0.4);
}
.tech-progress-text {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 0.72em;
  color: #d4c4a8;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

/* Branch labels */
.tech-branch-labels {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
}
.tech-branch-label {
  font-size: 0.7em;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 3px;
  border: 1px solid;
}
.tech-bl-military {
  color: #cc6644;
  border-color: rgba(204,102,68,0.3);
  background: linear-gradient(135deg, rgba(204,102,68,0.12), rgba(204,102,68,0.04));
  text-shadow: 0 0 8px rgba(204,102,68,0.3);
}
.tech-bl-arcane {
  color: #9b78ee;
  border-color: rgba(155,120,238,0.3);
  background: linear-gradient(135deg, rgba(155,120,238,0.12), rgba(155,120,238,0.04));
  text-shadow: 0 0 8px rgba(155,120,238,0.3);
}
.tech-bl-explore {
  color: #44aa88;
  border-color: rgba(68,170,136,0.3);
  background: linear-gradient(135deg, rgba(68,170,136,0.12), rgba(68,170,136,0.04));
  text-shadow: 0 0 8px rgba(68,170,136,0.3);
}

/* Tree container */
.tech-tree-container {
  position: relative;
  min-height: 280px;
}
.tech-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}
.tech-nodes {
  position: relative;
  z-index: 1;
}

/* Tier row */
.tech-tier {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 18px 0;
  flex-wrap: wrap;
}
.tech-tier[data-tier="0"] { padding-bottom: 12px; }

/* Tech node */
.tech-node {
  position: relative;
  width: 80px;
  text-align: center;
  cursor: default;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.tech-node-ring {
  width: 56px; height: 56px;
  margin: 0 auto 4px;
  border-radius: 50%;
  border: 2.5px solid #222;
  background: radial-gradient(circle at 40% 35%, rgba(20,18,35,0.95), rgba(8,8,14,0.98));
  position: relative;
  transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
}
.tech-node .tech-icon {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6em;
  line-height: 1;
  z-index: 2;
  pointer-events: none;
}
.tech-label {
  font-size: 0.65em;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

/* Branch color rings */
.tech-b-root .tech-node-ring { border-color: rgba(201,168,76,0.25); }
.tech-b-military .tech-node-ring { border-color: rgba(204,102,68,0.25); }
.tech-b-arcane .tech-node-ring { border-color: rgba(155,120,238,0.25); }
.tech-b-explore .tech-node-ring { border-color: rgba(68,170,136,0.25); }

/* Branch icon glows */
.tech-b-root .tech-icon { text-shadow: 0 0 8px rgba(201,168,76,0.4); }
.tech-b-military .tech-icon { text-shadow: 0 0 8px rgba(204,102,68,0.4); }
.tech-b-arcane .tech-icon { text-shadow: 0 0 8px rgba(155,120,238,0.4); }
.tech-b-explore .tech-icon { text-shadow: 0 0 8px rgba(68,170,136,0.4); }

/* Badge checkmark */
.tech-badge-done {
  position: absolute;
  top: -2px; right: 6px;
  color: #44cc44;
  font-size: 0.85em;
  font-weight: bold;
  text-shadow: 0 0 6px rgba(68,204,68,0.7);
  z-index: 3;
}

/* Tooltip */
.tech-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10,8,22,0.97);
  border: 1px solid #3d3560;
  border-radius: 6px;
  padding: 10px 14px;
  min-width: 180px;
  max-width: 240px;
  text-align: left;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6), 0 0 30px rgba(123,104,238,0.08);
  font-size: 0.78em;
  line-height: 1.5;
  color: #ccc;
}
.tech-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #3d3560;
}
.tech-node:hover .tech-tooltip { display: block; }
.tech-node.tech-focused .tech-tooltip { display: block; z-index: 20; }
.tech-node.tech-focused .tech-node-ring { box-shadow: 0 0 12px 3px rgba(201,168,76,0.6); }

.tech-confirm-bar {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  background: linear-gradient(180deg, rgba(22,18,44,0.95), rgba(12,10,24,0.98));
  border-top: 1px solid rgba(201,168,76,0.4);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 30;
}
.tech-confirm-bar .tcb-info {
  flex: 1;
  min-width: 0;
}
.tech-confirm-bar .tcb-name {
  color: #f0d878;
  font-weight: 700;
  font-size: 1em;
}
.tech-confirm-bar .tcb-cost {
  color: #9b78ee;
  font-size: 0.85em;
}
.tech-confirm-bar .tcb-desc {
  color: #999;
  font-size: 0.8em;
  margin-top: 2px;
}
.tech-confirm-btn {
  flex-shrink: 0;
  padding: 10px 20px;
  background: linear-gradient(135deg, #c9a84c, #a88a30);
  color: #1a1528;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  font-size: 1em;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tech-confirm-btn:active { background: #a88a30; }
.tech-confirm-cancel {
  flex-shrink: 0;
  padding: 10px 14px;
  background: transparent;
  color: #888;
  border: 1px solid #444;
  border-radius: 6px;
  font-size: 0.85em;
  cursor: pointer;
}
.tech-confirm-cancel:active { background: rgba(255,255,255,0.05); }

.tech-tooltip strong { display: block; color: #f0d878; font-size: 1.15em; margin-bottom: 4px; }
.tech-tooltip .tt-cost { display: block; color: #9b78ee; font-size: 0.95em; margin-bottom: 4px; }
.tech-tooltip .tt-desc { display: block; color: #999; margin-bottom: 4px; }
.tech-tooltip .tt-unlock { display: block; color: #88ccaa; font-size: 0.9em; }
.tech-tooltip .tt-needs { display: block; color: #886644; font-size: 0.9em; margin-top: 4px; }
.tech-tooltip .tt-done { display: block; color: #44cc44; font-weight: 600; margin-top: 4px; }
.tech-tooltip .tt-ready { display: block; color: #c9a84c; font-weight: 600; margin-top: 4px; }
.tech-tooltip .tt-wait { display: block; color: #7b68a8; font-size: 0.9em; margin-top: 4px; }

/* Node states */
.tech-researched .tech-node-ring {
  border-color: #44aa44 !important;
  background: radial-gradient(circle at 40% 35%, rgba(20,60,20,0.7), rgba(10,30,10,0.9));
  box-shadow: 0 0 12px rgba(68,204,68,0.25), inset 0 0 10px rgba(68,204,68,0.08);
}
.tech-researched .tech-icon { opacity: 0.8; }
.tech-researched .tech-label { color: #66aa66; }

.tech-available {
  cursor: pointer;
}
.tech-available .tech-node-ring {
  border-color: #c9a84c !important;
  background: radial-gradient(circle at 40% 35%, rgba(50,42,15,0.8), rgba(20,18,8,0.9));
  animation: nodeGlow 2.5s ease-in-out infinite;
}
.tech-available .tech-icon { text-shadow: 0 0 14px rgba(201,168,76,0.7); opacity: 1; }
.tech-available .tech-label { color: #c9a84c; }
.tech-available:hover {
  transform: scale(1.1);
  filter: brightness(1.2);
}
.tech-available:hover .tech-node-ring {
  border-color: #f0d878 !important;
  box-shadow: 0 0 24px rgba(240,216,120,0.45), inset 0 0 12px rgba(240,216,120,0.1);
  animation: none;
}

.tech-expensive .tech-node-ring {
  border-color: #3d3560 !important;
  box-shadow: inset 0 0 4px rgba(123,104,238,0.05);
}
.tech-expensive .tech-icon { opacity: 0.45; }
.tech-expensive .tech-label { color: #5a4e80; }

.tech-locked .tech-node-ring {
  border-color: #1a1a22 !important;
  background: rgba(8,8,14,0.7);
}
.tech-locked .tech-icon { opacity: 0.15; text-shadow: none; }
.tech-locked .tech-label { color: #2a2a2a; }

@keyframes nodeGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(201,168,76,0.15), inset 0 0 6px rgba(201,168,76,0.05); }
  50% { box-shadow: 0 0 20px rgba(201,168,76,0.4), inset 0 0 10px rgba(201,168,76,0.1); }
}

@keyframes techUnlock {
  0% { transform: scale(1); }
  30% { transform: scale(1.25); filter: brightness(2); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); filter: brightness(1); }
}
.tech-unlock-anim {
  animation: techUnlock 0.4s ease-out forwards !important;
}
.tech-unlock-anim .tech-node-ring {
  border-color: #ffd700 !important;
  box-shadow: 0 0 40px rgba(255,215,0,0.6) !important;
}

@keyframes techPulse {
  0%, 100% { box-shadow: 0 0 4px rgba(201,168,76,0.1); }
  50% { box-shadow: 0 0 16px rgba(201,168,76,0.35); }
}

/* Repeat production active */
.repeat-active {
  background: #1a2a1a !important;
  color: #44cc44 !important;
  border-color: #336633 !important;
}

/* ==================== BACK LINK ==================== */
.back-link {
  display: inline-block;
  margin-top: 22px;
  padding: 8px 20px;
  font-size: 0.8em;
  font-family: 'Cinzel', serif;
  color: #7b68a8;
  border: 1px solid rgba(61,53,96,0.4);
  border-radius: 4px;
  text-decoration: none;
  letter-spacing: 1px;
  transition: all 0.25s ease;
}
.back-link:hover {
  color: #c9a84c;
  border-color: rgba(201,168,76,0.5);
  background: rgba(26,21,40,0.6);
  box-shadow: 0 0 12px rgba(201,168,76,0.1);
}

/* ==================== UNIT ACTION BUTTONS ==================== */
.bottom-btn-unit {
  background: linear-gradient(180deg, rgba(44, 34, 20, 0.88), rgba(32, 24, 14, 0.88));
  border-color: rgba(180, 140, 60, 0.35);
  color: #c9a84c;
}
.bottom-btn-unit:hover {
  background: linear-gradient(180deg, rgba(100, 80, 30, 0.95), rgba(80, 64, 24, 0.95));
  color: #f0d878;
  box-shadow: 0 2px 12px rgba(201,168,76,0.15);
}

/* ==================== TURN BANNER ==================== */
#turn-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  font-size: 3.2em;
  color: #c9a84c;
  text-shadow: 0 0 30px rgba(200,168,76,0.5), 0 0 60px rgba(200,168,76,0.2), 0 2px 4px rgba(0,0,0,0.8);
  letter-spacing: 8px;
  text-transform: uppercase;
  font-family: 'Courier New', Courier, monospace;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  white-space: nowrap;
}
#turn-banner.show {
  animation: turnBannerIn 2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes turnBannerIn {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); letter-spacing: 24px; filter: blur(4px); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1); letter-spacing: 8px; filter: blur(0); }
  18% { transform: translate(-50%, -50%) scale(1.02); }
  65% { opacity: 1; transform: translate(-50%, -50%) scale(1); text-shadow: 0 0 40px rgba(200,168,76,0.6), 0 0 80px rgba(200,168,76,0.3), 0 2px 4px rgba(0,0,0,0.8); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.96); letter-spacing: 12px; }
}

/* Panel animations */
#citadel-panel {
  animation: panelSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
#tech-panel {
  animation: panelSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
#list-panel {
  animation: panelSlideLeft 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes panelSlideIn {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes panelSlideLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==================== VICTORY / DEFEAT ==================== */
#victory-screen {
  background: radial-gradient(ellipse at 50% 40%, rgba(50,40,10,0.4), rgba(8,8,18,0.99));
}
#victory-screen h1 {
  font-size: 3.5em;
  color: #ffd700;
  animation: victoryPulse 2s ease-in-out infinite;
}
#victory-screen h2 {
  color: #c9a84c;
  font-size: 1.2em;
}
@keyframes victoryPulse {
  0%, 100% { text-shadow: 0 0 20px rgba(255,215,0,0.3), 0 2px 4px rgba(0,0,0,0.8); transform: scale(1); }
  50% { text-shadow: 0 0 60px rgba(255,215,0,0.6), 0 0 120px rgba(255,215,0,0.2), 0 0 4px rgba(255,220,120,0.4), 0 2px 4px rgba(0,0,0,0.8); transform: scale(1.03); }
}

#defeat-screen {
  background: radial-gradient(ellipse at 50% 40%, rgba(50,10,10,0.3), rgba(8,8,18,0.99));
}
#defeat-screen h1 {
  font-size: 3.5em;
  color: #cc3333;
  animation: defeatPulse 2.5s ease-in-out infinite;
}
#defeat-screen h2 {
  color: #884444;
  font-size: 1.1em;
}
@keyframes defeatPulse {
  0%, 100% { text-shadow: 0 0 20px rgba(200,50,50,0.3), 0 2px 4px rgba(0,0,0,0.8); }
  50% { text-shadow: 0 0 40px rgba(200,50,50,0.5), 0 0 80px rgba(200,50,50,0.2), 0 2px 4px rgba(0,0,0,0.8); }
}

/* ==================== SCROLLBARS ==================== */
#citadel-panel::-webkit-scrollbar,
#tech-panel::-webkit-scrollbar,
#list-panel::-webkit-scrollbar,
.list-items::-webkit-scrollbar,
.instructions-content::-webkit-scrollbar {
  width: 5px;
}
#citadel-panel::-webkit-scrollbar-track,
#tech-panel::-webkit-scrollbar-track,
#list-panel::-webkit-scrollbar-track,
.list-items::-webkit-scrollbar-track,
.instructions-content::-webkit-scrollbar-track {
  background: transparent;
}
#citadel-panel::-webkit-scrollbar-thumb,
#tech-panel::-webkit-scrollbar-thumb,
#list-panel::-webkit-scrollbar-thumb,
.list-items::-webkit-scrollbar-thumb,
.instructions-content::-webkit-scrollbar-thumb {
  background: rgba(61, 53, 96, 0.5);
  border-radius: 3px;
}
#citadel-panel::-webkit-scrollbar-thumb:hover,
#tech-panel::-webkit-scrollbar-thumb:hover,
#list-panel::-webkit-scrollbar-thumb:hover,
.list-items::-webkit-scrollbar-thumb:hover,
.instructions-content::-webkit-scrollbar-thumb:hover {
  background: rgba(123, 104, 238, 0.4);
}

/* ==================== MOBILE ==================== */
@media (max-width: 768px) {
  .hk-hint { display: none; }

  #hud {
    flex-wrap: nowrap;
    gap: 6px;
    padding: 5px 8px;
    font-size: 0.72em;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #hud span { font-size: 0.9em; }
  .hud-btn {
    padding: 6px 12px;
    font-size: 0.8em;
    flex-shrink: 0;
    min-height: 32px;
  }

  /* Bottom action bar — full-width row docked to bottom */
  #bottom-actions {
    flex-direction: row;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0;
    gap: 0;
    background: linear-gradient(180deg, rgba(12,10,24,0.96), rgba(8,8,16,0.98));
    border-top: 1px solid rgba(61,53,96,0.5);
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .bottom-btn {
    padding: 14px 6px;
    font-size: 0.7em;
    flex: 1;
    min-height: 48px;
    border-radius: 0;
    border: none;
    border-right: 1px solid rgba(61,53,96,0.3);
    backdrop-filter: none;
    text-align: center;
  }
  .bottom-btn:last-child { border-right: none; }
  .bottom-btn:hover { transform: none; }
  .bottom-btn:active { background: rgba(61,53,96,0.6); transform: none; }

  /* Info panel: above bottom bar */
  #info-panel {
    max-width: 200px;
    font-size: 0.72em;
    padding: 6px 10px;
    bottom: 56px;
  }

  /* Citadel panel: full-width sheet */
  #citadel-panel {
    min-width: 0;
    width: calc(100vw - 16px);
    max-width: 100vw;
    max-height: 75vh;
    left: 8px;
    right: 8px;
    transform: translate(0, -50%);
    padding: 14px;
    border-radius: 10px;
  }
  #citadel-panel .panel-grid {
    grid-template-columns: 1fr;
  }
  #citadel-panel h4 { font-size: 0.85em; margin: 8px 0 4px; }
  #citadel-panel .panel-item { font-size: 0.8em; padding: 12px 10px; min-height: 44px; }

  /* Tech panel: full-width sheet */
  #tech-panel {
    min-width: 0;
    width: calc(100vw - 16px);
    max-width: 100vw;
    max-height: 85vh;
    left: 8px;
    right: 8px;
    transform: translate(0, -50%);
    padding: 12px;
  }
  .tech-tier {
    gap: 8px;
    padding: 14px 0;
  }
  .tech-node { width: 64px; }
  .tech-node-ring { width: 46px; height: 46px; }
  .tech-node .tech-icon { width: 46px; height: 46px; font-size: 1.3em; }
  .tech-label { font-size: 0.58em; }
  .tech-branch-labels { gap: 6px; }
  .tech-branch-label { font-size: 0.65em; padding: 4px 10px; }
  .tech-progress { height: 20px; }
  .tech-progress-text { font-size: 0.65em; }
  .tech-tooltip { min-width: 160px; max-width: 220px; font-size: 0.75em; padding: 10px 12px; }
  .tech-confirm-bar { padding: 14px 12px; }
  .tech-confirm-bar .tcb-name { font-size: 1.05em; }
  .tech-confirm-btn { padding: 12px 24px; font-size: 1em; }

  /* List panel */
  #list-panel {
    min-width: 0;
    width: calc(100vw - 20px);
    max-width: 100vw;
    left: 10px;
    right: 10px;
    max-height: calc(100vh - 56px);
  }
  .list-row { padding: 10px; font-size: 0.8em; min-height: 44px; }

  /* Toasts: above bottom bar */
  #toast-container {
    top: auto;
    bottom: 64px;
    right: 8px;
    left: 8px;
  }
  .toast { font-size: 0.8em; padding: 8px 12px; }

  /* Setup screens */
  .setup-content { min-width: 0; width: calc(100vw - 32px); }
  .setup-row { padding: 10px 12px; }
  .setup-row select { font-size: 0.9em; padding: 8px 10px; min-height: 40px; }
  .setup-buttons { flex-direction: column; gap: 10px; }
  .tribe-picker { gap: 10px; }
  .tribe-card { width: calc(50% - 10px); padding: 12px 10px; }
  .tribe-card .tribe-name { font-size: 0.85em; }
  .tribe-card .tribe-perk { font-size: 0.72em; }

  .instructions-content { padding: 16px; max-height: 90vh; }

  .screen h1 { font-size: 2em; }
  .screen h2 { font-size: 0.85em; }
  .menu-btn { padding: 14px 32px; font-size: 0.95em; min-height: 48px; }

  /* Victory card */
  #victory-card { max-width: 100%; }
}

@media (max-width: 480px) {
  #hud { font-size: 0.62em; gap: 4px 6px; padding: 4px 6px; }
  #hud span { font-size: 0.85em; }
  .hud-btn { padding: 4px 8px; font-size: 0.75em; }

  .bottom-btn { font-size: 0.62em; padding: 12px 2px; min-height: 44px; }

  #info-panel { max-width: 160px; font-size: 0.65em; bottom: 52px; }

  .tech-node { width: 54px; }
  .tech-node-ring { width: 40px; height: 40px; border-width: 2px; }
  .tech-node .tech-icon { width: 40px; height: 40px; font-size: 1.1em; }
  .tech-label { font-size: 0.5em; }
  .tech-tier { gap: 5px; padding: 10px 0; }

  #citadel-panel { padding: 10px; }
  #citadel-panel .panel-item { font-size: 0.75em; padding: 10px 8px; }

  .screen h1 { font-size: 1.6em; }
  .menu-btn { padding: 12px 24px; font-size: 0.85em; }

  .setup-content { width: calc(100vw - 20px); }
  .tribe-card { width: calc(50% - 6px); padding: 10px 6px; }
}
