:root {
  --bg: #1a1208;
  --bg-2: #241a0d;
  --bg-3: #2f2211;
  --panel: #2d2012;
  --panel-2: #3a2a17;
  --border: #53391d;
  --border-strong: #7b552a;
  --text: #f7e6c3;
  --text-dim: #c9b38a;
  --text-mute: #8e7a56;
  --amber: #f6b642;
  --amber-2: #f08a1c;
  --amber-3: #ffd86b;
  --honey: #e9a53a;
  --honey-glow: #ffcc59;
  --green: #9fc25e;
  --green-2: #6ea03f;
  --purple: #9a6bc2;
  --red: #e0603c;
  --blue: #5fa8d6;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.55);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(ellipse at 20% 10%, #3a2814 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, #3a2a14 0%, transparent 50%),
    var(--bg);
  overflow: hidden;
  user-select: none;
}

button, input { font-family: inherit; color: inherit; }

#app { height: 100%; width: 100%; position: relative; }

.scene {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.scene.active { display: flex; }

/* ==========  START SCREEN  ========== */
.scene-start {
  display: none;
  flex-direction: row;
  gap: 40px;
  padding: 48px;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}
.scene-start.active { display: flex; }

.start-panel {
  flex: 0 1 640px;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 40px;
  background: linear-gradient(165deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.start-panel::before {
  content: '';
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 30% 30%, rgba(246, 182, 66, 0.18) 0, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(240, 138, 28, 0.12) 0, transparent 40%);
  pointer-events: none;
}
.logo {
  font-size: 68px;
  font-weight: 900;
  margin: 0 0 12px;
  letter-spacing: -1.5px;
  background: linear-gradient(160deg, var(--amber-3) 0%, var(--amber-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  position: relative;
}
.logo-crown {
  -webkit-background-clip: text;
  background-clip: text;
  color: var(--amber-3);
  margin-right: 8px;
  filter: drop-shadow(0 2px 8px rgba(255, 216, 107, 0.5));
}
.tagline {
  color: var(--text-dim);
  font-size: 18px;
  margin: 0 0 32px;
  max-width: 440px;
  line-height: 1.45;
}

.leaderboard {
  flex: 0 1 440px;
  max-width: 440px;
  max-height: calc(100vh - 96px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px;
  overflow-y: auto;
}
.leaderboard h2 {
  margin: 0 0 16px;
  color: var(--amber);
  font-size: 22px;
  letter-spacing: 0.5px;
}
.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.leaderboard-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.leaderboard-list li:nth-child(odd) { background: rgba(255, 255, 255, 0.03); }
.leaderboard-list .lb-rank { color: var(--text-mute); font-weight: 700; }
.leaderboard-list li.top1 { background: rgba(246, 182, 66, 0.15); border: 1px solid rgba(246, 182, 66, 0.4); }
.leaderboard-list li.top1 .lb-rank { color: var(--amber-3); }
.leaderboard-list .lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-list .lb-score { color: var(--amber-3); font-weight: 700; }
.leaderboard-empty { color: var(--text-mute); font-style: italic; }

/* ==========  BUTTONS  ========== */
.btn {
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, filter 0.12s ease;
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}
.btn:hover { background: var(--bg-3); border-color: var(--border-strong); }
.btn:active { filter: brightness(0.92); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 32px; font-size: 16px; margin-bottom: 14px; }
.btn-primary {
  background: linear-gradient(135deg, var(--amber) 0%, var(--amber-2) 100%);
  color: #23180a;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(246, 182, 66, 0.3);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.05); }
.btn.active, .btn[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--amber) 0%, var(--amber-2) 100%);
  color: #23180a;
  border-color: transparent;
  box-shadow: 0 0 0 1px rgba(246, 182, 66, 0.4);
}
.btn.active:hover, .btn[aria-pressed="true"]:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--amber) 0%, var(--amber-2) 100%); }

/* ==========  MODAL  ========== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }
.modal-inner {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  margin: 16px;
}
.modal-inner h2 { margin-top: 0; color: var(--amber); }
.howto-list { line-height: 1.55; color: var(--text-dim); padding-left: 20px; }
.howto-list b { color: var(--text); }

/* ==========  TOPBAR  ========== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  row-gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.topbar-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; row-gap: 4px; }
.sound-controls { display: inline-flex; gap: 4px; align-items: center; padding: 2px 6px; background: rgba(20, 14, 8, 0.4); border: 1px solid var(--border); border-radius: 6px; }
.sound-controls input[type=range] { width: 60px; accent-color: var(--amber, #f6b642); }
@media (max-width: 640px) { .sound-controls input[type=range] { display: none; } }
@media (max-width: 1100px) {
  .btn.small { padding: 5px 10px; font-size: 12px; }
  .hud-pill { padding: 5px 10px; font-size: 12px; }
  .topbar { gap: 8px; padding: 8px 12px; }
}
.tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.tab.active { background: var(--bg-3); color: var(--amber-3); border-color: var(--border-strong); }
.tab:hover:not(.active) { color: var(--text); }
.hud { gap: 12px; }
.hud-pill {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
#hud-score { color: var(--amber-3); font-weight: 700; }

/* ==========  GAME LAYOUT  ========== */
.game-main {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  gap: 0;
  overflow: hidden;
  min-height: 0;
}
.sidebar {
  background: var(--panel);
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.sidebar-right { border-right: none; border-left: 1px solid var(--border); }
.sidebar h3 {
  margin: 12px 0 10px;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.sidebar h3:first-child { margin-top: 0; }
.sidebar h3 small { font-weight: 600; color: var(--amber); font-size: 11px; letter-spacing: 0.5px; text-transform: none; }

/* Hive-Tab-Tier-Markierung — farbiger Rand je nach Stufe */
.hive-tab[data-tier="🥉"] { border-left: 3px solid #c4793a; }
.hive-tab[data-tier="🥈"] { border-left: 3px solid #c9c2b3; }
.hive-tab[data-tier="🥇"] { border-left: 3px solid #f6b642; }
.hive-tab[data-tier="⭐"] { border-left: 3px solid #ffd86b; box-shadow: 0 0 8px rgba(255, 216, 107, 0.4); }

/* Mobile-Sheet-Handles standardmäßig versteckt (nur ≤640px sichtbar) */
.mobile-sheet-handle { display: none; }

/* Aufklappbare Sidebar-Bereiche */
.sidebar-section { margin: 0 0 10px; border: 1px solid var(--border); border-radius: 8px; background: rgba(20, 14, 8, 0.4); overflow: hidden; }
.sidebar-section.hidden { display: none; }
.sidebar-section > summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 12px;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  user-select: none;
  background: rgba(36, 26, 13, 0.7);
  border-bottom: 1px solid transparent;
}
.sidebar-section[open] > summary { border-bottom-color: var(--border); }
.sidebar-section > summary::-webkit-details-marker { display: none; }
.sidebar-section > summary::before { content: '▸'; margin-right: 8px; color: var(--amber-3, #ffd86b); transition: transform 0.15s; display: inline-block; font-size: 10px; }
.sidebar-section[open] > summary::before { transform: rotate(90deg); }
.sidebar-section > summary:hover { background: rgba(50, 35, 18, 0.85); color: var(--text); }
.sidebar-section > summary small { font-weight: 600; color: var(--amber); font-size: 11px; letter-spacing: 0.5px; text-transform: none; margin-left: auto; }
.sidebar-section > .roles, .sidebar-section > .build-panel { padding: 10px 12px; }

.resource-list { list-style: none; padding: 0; margin: 0; }
.resource-list li {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  align-items: center;
  font-variant-numeric: tabular-nums;
  background: var(--bg-2);
  margin-bottom: 4px;
  transition: background 0.2s;
}
.res-ico {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: block;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}
.res-ico.bees   { background: radial-gradient(circle at 30% 30%, #ffd86b, #b47923); }
.res-ico.honey  { background: radial-gradient(circle at 30% 30%, var(--honey-glow), #b07517); }
.res-ico.nectar { background: radial-gradient(circle at 30% 30%, #ffe58c, var(--amber-2)); }
.res-ico.wax    { background: radial-gradient(circle at 30% 30%, #f4e0a8, #b89746); }
.res-ico.pollen { background: radial-gradient(circle at 30% 30%, #ffca68, #d9763c); }
.res-label { color: var(--text-dim); font-size: 13px; }
.res-val { color: var(--text); font-weight: 700; font-size: 14px; }
.res-val-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  font-variant-numeric: tabular-nums;
  min-width: 56px;
}
.res-num { color: var(--text); font-weight: 700; font-size: 13px; line-height: 1.1; }
.res-rate {
  color: var(--text-mute);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
  min-height: 12px;
}
.res-rate.positive { color: var(--green); }
.res-rate.negative { color: var(--red); }

.event-log {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  max-height: 220px;
  overflow-y: auto;
}
.event-log li {
  padding: 6px 8px;
  border-left: 2px solid var(--border);
  margin-bottom: 4px;
  background: var(--bg-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.3;
}
.event-log li.ev-good { border-left-color: var(--green); color: var(--green); }
.event-log li.ev-bad  { border-left-color: var(--red);   color: var(--red); }
.event-log li.ev-warn { border-left-color: var(--amber); color: var(--amber-3); }

.canvas-wrap {
  position: relative;
  background:
    radial-gradient(ellipse at center, #2a1b0c 0%, #120a04 80%);
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
}

.toast-layer {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 200;
}
.toast {
  background: rgba(45, 32, 18, 0.95);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toastIn 0.25s ease, toastOut 0.3s ease 2.5s forwards;
}
.toast.good { border-color: var(--green); color: var(--green); }
.toast.bad  { border-color: var(--red);   color: var(--red); }
.toast.warn { border-color: var(--amber); color: var(--amber-3); }
@keyframes toastIn  { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(-10px); } }

/* ==========  ROLES  ========== */
.roles { display: flex; flex-direction: column; gap: 10px; }
.role-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.role-row.locked { opacity: 0.55; }
.role-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 13px;
  color: var(--text);
  min-width: 90px;
}
.role-name-text { font-weight: 600; }
.role-count {
  font-size: 10px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}
.role-bar {
  height: 6px;
  background: var(--bg-3);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.role-bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, var(--amber-2), var(--amber-3));
  transition: width 0.15s ease;
}
.role-val {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: right;
}
.role-controls {
  display: flex;
  gap: 2px;
}
.role-controls button {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.role-controls button:hover { background: var(--border); }

/* ==========  BUILD PANEL  ========== */
.build-panel { display: flex; flex-direction: column; gap: 6px; }
.build-panel.hidden { display: none; }
.build-btn {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
  transition: border-color 0.15s, background 0.15s;
}
.build-btn:hover { border-color: var(--border-strong); background: var(--bg-3); }
.build-btn.active { border-color: var(--amber); background: rgba(246, 182, 66, 0.08); }
.build-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.build-btn.insufficient { opacity: 0.65; }
.build-btn.insufficient .build-btn-cost { color: var(--red, #e0603c); }
.build-status { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: rgba(36, 26, 13, 0.7); border: 1px solid var(--border); font-size: 12px; line-height: 1.45; }
.build-status.hidden { display: none; }
.build-status.build-status-ok  { border-color: rgba(143, 208, 112, 0.55); background: rgba(40, 60, 30, 0.5); }
.build-status.build-status-bad { border-color: rgba(224, 96, 60, 0.55); background: rgba(60, 30, 20, 0.5); }
.build-status .build-status-head { font-weight: 700; color: var(--amber-3, #ffd86b); margin-bottom: 4px; }
.build-status .build-status-msg { color: var(--text-dim); margin: 0 0 4px; }
.build-status .build-status-list { margin: 4px 0 0; padding: 0 0 0 18px; color: #f0c9a8; }
.build-status .build-status-list li { margin-bottom: 2px; }
.build-btn-name { font-weight: 600; font-size: 13px; }
.build-btn-cost { font-size: 11px; color: var(--text-mute); }
.build-btn-desc { grid-column: 1 / -1; font-size: 11px; color: var(--text-mute); }

/* ==========  PAUSE OVERLAY  ========== */
.pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 8, 3, 0.82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  cursor: pointer;
  animation: fadeIn 0.25s ease;
}
.pause-overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.pause-inner {
  background: linear-gradient(155deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 44px;
  text-align: center;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  pointer-events: none;
}
.pause-inner h2 {
  margin: 0 0 10px;
  font-size: 32px;
  color: var(--amber-3);
}
.pause-inner p {
  margin: 0 0 22px;
  color: var(--text-dim);
  line-height: 1.5;
}
.pause-inner button { pointer-events: auto; }
.pause-checklist {
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 22px;
  max-height: 280px;
  overflow-y: auto;
  pointer-events: auto;
}
.pause-checklist h3 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 700;
}
.pause-checklist ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: task;
}
.pause-checklist li {
  counter-increment: task;
  position: relative;
  padding: 5px 0 5px 28px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.35;
}
.pause-checklist li::before {
  content: counter(task);
  position: absolute;
  left: 0;
  top: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-mute);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 20px;
}

/* ==========  ADVISOR  ========== */
.advisor-card {
  position: absolute;
  top: 56px;
  right: 20px;
  width: 320px;
  max-width: calc(100% - 40px);
  max-height: calc(100% - 80px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(150deg, rgba(45, 32, 18, 0.98) 0%, rgba(58, 42, 23, 0.98) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
  color: var(--text);
  z-index: 40;
  transition: opacity 0.25s ease, transform 0.25s ease;
  backdrop-filter: blur(6px);
}
.advisor-card.hidden { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.advisor-card.pulse { animation: advisorPulse 0.55s ease; }
@keyframes advisorPulse {
  0%   { box-shadow: 0 0 0 0 rgba(246, 182, 66, 0.55), var(--shadow); }
  60%  { box-shadow: 0 0 0 18px rgba(246, 182, 66, 0),   var(--shadow); }
  100% { box-shadow: var(--shadow); }
}
.advisor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.advisor-badge {
  background: linear-gradient(135deg, var(--amber) 0%, var(--amber-2) 100%);
  color: #23180a;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 12px;
}
.advisor-progress {
  color: var(--text-mute);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  flex: 1;
  text-align: right;
}
.advisor-dismiss {
  background: transparent;
  border: none;
  color: var(--text-mute);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.advisor-dismiss:hover { color: var(--text); }
.advisor-list {
  list-style: none;
  counter-reset: advtask;
  margin: 2px 0 10px;
  padding: 0;
  overflow-y: auto;
  max-height: 360px;
  flex: 1 1 auto;
}
.advisor-list li {
  counter-increment: advtask;
  position: relative;
  padding: 8px 4px 8px 30px;
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.3;
  border-radius: 4px;
  transition: background 0.15s;
}
.advisor-list li::before {
  content: counter(advtask);
  position: absolute;
  left: 0;
  top: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-mute);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 22px;
}
.advisor-list li.done { color: var(--text-mute); }
.advisor-list li.done .advisor-task-title { text-decoration: line-through; opacity: 0.85; }
.advisor-list li.done::before {
  content: '✓';
  background: linear-gradient(135deg, var(--amber) 0%, var(--amber-2) 100%);
  border-color: transparent;
  color: #23180a;
  font-size: 13px;
}
.advisor-list li.current {
  background: rgba(246, 182, 66, 0.08);
  color: var(--text);
}
.advisor-list li.current::before {
  background: transparent;
  border-color: var(--amber);
  color: var(--amber-3);
  box-shadow: 0 0 0 0 rgba(246,182,66,0.5);
  animation: currentPulse 1.8s infinite;
}
@keyframes currentPulse {
  0%   { box-shadow: 0 0 0 0 rgba(246,182,66,0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(246,182,66,0); }
  100% { box-shadow: 0 0 0 0 rgba(246,182,66,0); }
}
.advisor-task-title { font-weight: 600; display: block; }
.advisor-list li.current .advisor-task-title { color: var(--amber-3); }
.advisor-task-hint {
  display: none;
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
  font-weight: 400;
}
.advisor-list li.current .advisor-task-hint { display: block; }

.advisor-card.collapsed .advisor-list,
.advisor-card.collapsed .advisor-steps {
  display: none;
}

.advisor-steps {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}
.advisor-step {
  flex: 1;
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
}
.advisor-step.done {
  background: linear-gradient(90deg, var(--amber-2), var(--amber-3));
}
.advisor-step.current {
  background: linear-gradient(90deg, var(--amber-2), var(--amber-3));
  opacity: 0.6;
  animation: stepShimmer 1.6s infinite ease-in-out;
}
@keyframes stepShimmer { 50% { opacity: 1; } }

@media (max-width: 860px) {
  .advisor-card { position: static; width: auto; margin: 8px; }
}

/* ==========  GAME OVER  ========== */
.postmortem {
  text-align: left;
  background: rgba(60, 30, 18, 0.45);
  border: 1px solid rgba(224, 96, 60, 0.35);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 0 0 20px;
}
.postmortem h2 { margin: 0 0 8px; font-size: 18px; color: #ffba84; }
.postmortem h3 { margin: 14px 0 6px; font-size: 14px; color: #ffd86b; }
.postmortem-cause { margin: 0 0 12px; color: #f0d9c0; font-size: 14px; line-height: 1.5; }
.postmortem-snapshot { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; margin: 8px 0 4px; }
.postmortem-snapshot .pm-row { display: flex; justify-content: space-between; padding: 3px 0; color: var(--text-dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.postmortem-snapshot .pm-row b { color: var(--text); font-weight: 600; }
.postmortem-tips { margin: 4px 0 0; padding: 0 0 0 18px; color: #d8c2a4; font-size: 13px; line-height: 1.55; }
.postmortem-tips li { margin: 0 0 6px; }
.postmortem-events { margin-top: 12px; }
.postmortem-events summary { cursor: pointer; color: var(--text-dim); font-size: 13px; }
.postmortem-events ul { margin: 8px 0 0; padding: 0 0 0 18px; font-size: 12px; }
.pm-ev { margin-bottom: 3px; }
.pm-ev-good { color: #8fd070; }
.pm-ev-bad  { color: #e0603c; }
.pm-ev-warn { color: #ffba84; }
.pm-ev-info { color: var(--text-dim); }

.postmortem-losses { margin-top: 12px; padding: 10px 14px; border-radius: 8px; background: rgba(60, 30, 18, 0.35); }
.postmortem-losses.hidden { display: none; }
.postmortem-losses h3 { margin: 0 0 8px; }
.postmortem-losses-intro { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.pm-loss-row { display: grid; grid-template-columns: 150px 1fr 90px; gap: 10px; align-items: center; padding: 4px 0; font-size: 12px; color: #f0c9a8; font-variant-numeric: tabular-nums; }
.pm-loss-row b { color: var(--text); text-align: right; }
.pm-loss-bar { height: 10px; background: rgba(20, 14, 8, 0.6); border-radius: 5px; overflow: hidden; }
.pm-loss-fill { height: 100%; background: linear-gradient(90deg, #e0603c, #ffba84); }
@media (max-width: 520px) { .pm-loss-row { grid-template-columns: 1fr 80px; } .pm-loss-bar { display: none; } }

/* Bedrohungs-Banner: zeigt aktive Wespen- und Rivalen-Angriffe gut sichtbar an */
.threat-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(90deg, rgba(120,30,20,0.95), rgba(80,20,15,0.85));
  border-bottom: 1px solid #e0603c;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  align-items: center;
  animation: threat-pulse 1.4s ease-in-out infinite;
}
.threat-banner.hidden { display: none; }
.threat-banner .threat-icon { font-size: 16px; }
.threat-banner .threat-item {
  background: rgba(255, 90, 40, 0.18);
  border: 1px solid rgba(255, 90, 40, 0.5);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
}
.threat-banner .threat-hunger {
  background: rgba(246, 182, 66, 0.22);
  border-color: rgba(246, 182, 66, 0.6);
  color: #ffe9c5;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.threat-banner .threat-btn {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 12px;
  border: 1px solid rgba(255, 220, 140, 0.7);
  background: rgba(20, 14, 8, 0.55);
  color: #ffe9c5;
  cursor: pointer;
  font-weight: 600;
}
.threat-banner .threat-btn:hover {
  background: rgba(246, 182, 66, 0.25);
  border-color: #ffd86b;
}
@keyframes threat-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(255,90,40,0.3); }
  50%      { box-shadow: inset 0 0 18px rgba(255,90,40,0.6); }
}

/* ===========  Mehrspieler-Lobby & Partie-Warteraum  =========== */
#scene-mp-lobby, #scene-mp-waiting, #scene-mp-match {
  overflow-y: auto;
  padding: 24px;
  flex-direction: column;
  align-items: stretch;
}
.mp-lobby, .mp-match {
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.mp-lobby-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.mp-lobby-head h1 { margin: 0; font-size: 22px; color: var(--amber-3, #ffd86b); }
.mp-user { flex: 1 1 100%; font-size: 12px; color: var(--text-dim); }
.mp-lobby-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mp-lobby-body h2 { font-size: 14px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-mute); margin: 12px 0 8px; }
.mp-match-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.mp-match-entry {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  justify-content: space-between;
}
.mp-match-head { display: flex; gap: 10px; align-items: baseline; }
.mp-match-head strong { color: var(--text); }
.mp-match-status { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--amber); }
.mp-match-meta { font-size: 12px; color: var(--text-dim); flex: 1; min-width: 100px; }
.mp-empty { color: var(--text-mute); font-style: italic; padding: 12px; }
.mp-invite-info { background: rgba(246, 182, 66, 0.08); border: 1px solid rgba(246, 182, 66, 0.25); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px; }
.mp-match-log { background: var(--bg-2); border-radius: var(--radius-sm); padding: 12px; max-height: 400px; overflow-y: auto; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; color: var(--text-dim); }
.mp-match-log div { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,0.03); }
.mp-logbox { margin-top: 16px; }
.mp-logbox > summary { cursor: pointer; color: var(--text-mute); font-size: 12px; padding: 6px 0; }

.mp-game-root { display: flex; flex-direction: column; gap: 14px; }
.mp-game-head h2 { margin: 0 0 4px; color: var(--amber-3, #ffd86b); font-size: 18px; }
.mp-hive-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.mp-hive-card.own { border-color: rgba(246, 182, 66, 0.6); background: rgba(36, 26, 13, 0.5); }
.mp-hive-card h3 { margin: 0 0 8px; font-size: 15px; color: var(--text); }
.mp-res-row { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-dim); }
.mp-res { white-space: nowrap; }
.mp-res b { color: var(--amber-3, #ffd86b); font-weight: 700; }
.mp-res small { color: var(--text-mute); font-size: 10px; }
.mp-other-head { margin: 8px 0 4px; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-mute); }
.mp-other-meta { font-size: 11px; color: var(--text-mute); margin-top: 6px; }
.mp-subpanel { margin-top: 10px; background: rgba(20, 14, 8, 0.4); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.mp-subpanel > summary { cursor: pointer; font-size: 12px; color: var(--amber-3, #ffd86b); font-weight: 600; letter-spacing: 0.5px; padding: 2px 0; }
.mp-subpanel[open] { padding-bottom: 10px; }
.mp-roles-grid { display: grid; grid-template-columns: 1fr 70px; gap: 4px 12px; margin: 8px 0; }
.mp-role-row { display: contents; font-size: 12px; }
.mp-role-row label { color: var(--text-dim); }
.mp-role-row input { padding: 3px 6px; background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 4px; font-size: 12px; text-align: right; }
.mp-build-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mp-build-desc { margin: 6px 0; font-size: 11px; color: var(--text-mute); }
.mp-danger { color: #e0603c !important; }
.mp-incoming { border-color: #e0603c !important; background: rgba(224, 96, 60, 0.12) !important; animation: mp-pulse 1.5s ease-in-out infinite; }
@keyframes mp-pulse { 0%,100% { box-shadow: inset 0 0 0 1px rgba(224,96,60,0.3); } 50% { box-shadow: inset 0 0 18px rgba(224,96,60,0.4); } }
.mp-peace-card { background: rgba(143, 208, 112, 0.12); border: 1px solid rgba(143, 208, 112, 0.5); padding: 14px 16px; border-radius: 8px; margin-bottom: 8px; }
.mp-peace-card h3 { margin: 0 0 6px; color: #9fc25e; }
.mp-spy-report { margin-top: 8px; padding: 6px 10px; background: rgba(200, 156, 240, 0.1); border: 1px solid rgba(200, 156, 240, 0.35); border-radius: 4px; font-size: 11px; color: #c89cf0; font-variant-numeric: tabular-nums; }
.mp-select { padding: 3px 6px; background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }
.mp-endscreen { text-align: center; padding: 30px 20px; }
.mp-endscreen h1 { font-size: 28px; color: var(--amber-3, #ffd86b); margin: 0 0 20px; }
.mp-endscreen-scores { display: flex; flex-direction: column; gap: 8px; max-width: 600px; margin: 20px auto; }
.mp-endscreen-row { display: grid; grid-template-columns: 40px 1fr 100px; align-items: center; gap: 12px; padding: 10px 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; text-align: left; font-size: 13px; }
.mp-endscreen-row.me { border-color: rgba(246, 182, 66, 0.6); background: rgba(36, 26, 13, 0.5); }
.mp-endscreen-row.winner { border-color: rgba(246, 182, 66, 0.8); background: rgba(246, 182, 66, 0.12); }
.mp-endscreen-row.winner b:first-child { color: var(--amber-3, #ffd86b); }
.mp-endscreen-score { color: var(--amber-3, #ffd86b); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; font-size: 15px; }

/* ===========  Game-Over-Bildschirm: Sticky Header + Scroll Body + Sticky Footer  =========== */
#scene-gameover {
  overflow: hidden;
  padding: 16px;
  align-items: stretch;
  justify-content: center;
  box-sizing: border-box;
}
.gameover-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 32px);
  margin: 0 auto;
  max-width: 960px;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
  text-align: left;
}
.gameover-header {
  flex-shrink: 0;
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  background: linear-gradient(180deg, rgba(36,26,13,0.7), rgba(20,14,8,0.4));
}
.gameover-header #gameover-title { margin: 0 0 4px; font-size: 26px; }
.gameover-header .gameover-reason { margin: 0 0 10px; font-size: 13px; }
.gameover-header .gameover-final {
  display: inline-flex; gap: 12px; align-items: baseline;
  padding: 6px 16px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(246,182,66,0.15), rgba(240,138,28,0.05));
  border: 1px solid rgba(246,182,66,0.3); margin: 0;
}
.gameover-header .gameover-label { font-size: 11px; color: var(--text-mute); letter-spacing: 1px; text-transform: uppercase; }
.gameover-header .gameover-score { font-size: 22px; font-weight: 700; color: var(--amber-3, #ffd86b); }
.gameover-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 22px;
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}
.gameover-col-title { margin: 0 0 8px; font-size: 16px; color: #ffba84; }
@media (min-width: 1024px) {
  .gameover-body { grid-template-columns: 1.4fr 1fr; }
}
.gameover-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 12px 22px calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  align-items: center;
  background: rgba(20,14,8,0.55);
}
/* Eintragen / Nochmal spielen / Hauptmenü auf einer Linie — Eingabe schrumpft mit */
.gameover-footer .submit-form { display: flex; gap: 6px; flex: 1 1 0; min-width: 0; align-items: center; }
.gameover-footer .submit-form input { flex: 1; min-width: 80px; padding: 7px 10px; background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.gameover-footer .submit-form .btn { white-space: nowrap; }
.gameover-footer .gameover-actions { display: flex; gap: 6px; flex-shrink: 0; }
.gameover-footer .gameover-actions .btn { white-space: nowrap; }
.gameover-footer .submit-result { position: absolute; bottom: -22px; left: 22px; font-size: 11px; color: var(--text-dim); margin: 0; }
.gameover-footer .submit-result.hidden { display: none; }
.gameover-footer { position: relative; }
@media (max-width: 720px) {
  .gameover-footer .submit-form input::placeholder { font-size: 11px; }
  .gameover-footer .btn { padding: 6px 10px; font-size: 12px; }
}
@media (max-height: 600px) {
  .gameover-header { padding: 10px 16px 8px; }
  .gameover-header #gameover-title { font-size: 20px; }
  .gameover-header .gameover-reason { margin-bottom: 6px; font-size: 12px; }
  .gameover-header .gameover-score { font-size: 18px; }
  .gameover-body { padding: 12px 16px; gap: 12px; }
  .postmortem h2 { font-size: 14px; }
  .gameover-footer { padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 520px) {
  .postmortem-snapshot { grid-template-columns: 1fr !important; }
}
#gameover-title { margin: 0 0 8px; font-size: 34px; color: var(--amber-3); }
.gameover-reason { color: var(--text-dim); margin: 0 0 24px; font-style: italic; }
.score-breakdown {
  text-align: left;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.score-breakdown div {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.score-breakdown div b { color: var(--text); font-weight: 600; }
.gameover-final {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(246, 182, 66, 0.15), rgba(240, 138, 28, 0.05));
  border: 1px solid rgba(246, 182, 66, 0.3);
  border-radius: var(--radius-sm);
  padding: 16px 22px;
  margin-bottom: 24px;
}
.gameover-label { color: var(--text-dim); font-size: 14px; letter-spacing: 1px; text-transform: uppercase; }
.gameover-score { color: var(--amber-3); font-size: 40px; font-weight: 900; font-variant-numeric: tabular-nums; }
.submit-form {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}
.submit-form label { text-align: left; color: var(--text-dim); font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.submit-form input {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 15px;
  color: var(--text);
  outline: none;
}
.submit-form input:focus { border-color: var(--amber); }
.submit-result { color: var(--amber-3); padding: 12px; background: var(--bg-2); border-radius: var(--radius-sm); margin-bottom: 12px; }
.submit-result.hidden { display: none; }
.gameover-actions { display: flex; gap: 10px; justify-content: center; }

/* ==========  CELL INSPECTOR  ========== */
.cell-inspector {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 320px;
  max-width: calc(100% - 40px);
  max-height: 55%;
  overflow-y: auto;
  background: linear-gradient(150deg, rgba(45, 32, 18, 0.98) 0%, rgba(58, 42, 23, 0.98) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  color: var(--text);
  z-index: 30;
  backdrop-filter: blur(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.cell-inspector.hidden { opacity: 0; transform: translateY(8px); pointer-events: none; }
.cell-inspector-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.cell-inspector-title {
  font-weight: 700;
  color: var(--amber-3);
  font-size: 14px;
}
#cell-inspector-close {
  background: transparent; border: none; color: var(--text-mute);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px;
}
#cell-inspector-close:hover { color: var(--text); }
.cell-inspector-lines {
  list-style: none; padding: 0; margin: 0;
  font-size: 12px; color: var(--text-dim); line-height: 1.4;
}
.cell-inspector-lines li {
  padding: 4px 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.06);
}
.cell-inspector-lines li:first-child { border-top: none; }

/* ==========  HIVE TABS  ========== */
.hive-tabs {
  display: flex;
  gap: 6px;
  padding: 6px 16px;
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}
.hive-tab {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
  padding: 6px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.hive-tab:hover { background: var(--bg-3); color: var(--text); }
.hive-tab.active {
  background: linear-gradient(135deg, rgba(246, 182, 66, 0.15), rgba(200, 156, 240, 0.1));
  border-color: var(--amber);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(246, 182, 66, 0.3);
}
.hive-tab-name { font-size: 13px; font-weight: 700; }
.hive-tab-stats { font-size: 11px; color: var(--text-mute); font-variant-numeric: tabular-nums; }
.hive-tab.active .hive-tab-stats { color: var(--amber-3); }

/* ==========  ROLLEN-PANEL — Aufwertung  ========== */
.role-row {
  background: linear-gradient(135deg, rgba(36, 26, 13, 0.8) 0%, rgba(45, 32, 18, 0.8) 100%);
  border: 1px solid transparent;
  padding: 8px 10px;
  transition: border-color 0.2s, transform 0.15s, background 0.2s;
}
.role-row:hover { border-color: rgba(246, 182, 66, 0.35); }
.role-bar {
  height: 8px;
  background: linear-gradient(180deg, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.15) 100%);
  border-radius: 4px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.role-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber-2), var(--amber-3));
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(255, 216, 107, 0.4);
  transition: width 0.25s cubic-bezier(.2,.8,.2,1);
}
.role-controls button {
  background: linear-gradient(180deg, var(--bg-3) 0%, var(--bg-2) 100%);
  transition: background 0.15s, filter 0.12s;
}
.role-controls button:hover { background: var(--border); }
.role-controls button:active { filter: brightness(0.85); }

/* ==========  BAU-PANEL — Aufwertung  ========== */
.build-btn {
  background: linear-gradient(135deg, rgba(36, 26, 13, 0.9), rgba(45, 32, 18, 0.9));
  transition: border-color 0.2s, background 0.2s, transform 0.1s, box-shadow 0.2s;
}
.build-btn:hover:not(:disabled) {
  /* kein translateY — das verursacht Hover-Flicker, wenn der Button 1px hochspringt
     und die Maus dadurch nicht mehr drüber ist. Stattdessen nur Farbe/Glow. */
  border-color: var(--amber);
  box-shadow: 0 2px 10px rgba(246, 182, 66, 0.15);
  background: linear-gradient(135deg, rgba(58, 42, 23, 0.95), rgba(74, 52, 30, 0.95));
}
.build-btn.active {
  background: linear-gradient(135deg, rgba(246, 182, 66, 0.18), rgba(200, 156, 240, 0.12));
  border-color: var(--amber);
  box-shadow: 0 0 0 1px rgba(246, 182, 66, 0.4), 0 2px 12px rgba(246, 182, 66, 0.25);
}
.build-btn-name {
  background: linear-gradient(135deg, var(--amber-3), var(--amber));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}
.build-btn:disabled .build-btn-name { color: var(--text-mute); background: none; -webkit-background-clip: initial; background-clip: initial; }
.build-btn-cost { color: var(--text-mute); font-family: ui-monospace, SFMono-Regular, monospace; }

/* ==========  HANDELS-MODAL  ========== */
.trade-dialog {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  max-width: 440px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}
.trade-dialog h3 {
  margin: 0 0 16px;
  color: var(--amber);
  font-size: 20px;
  font-weight: 700;
}
.trade-dialog label {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-dim);
}
.trade-select, .trade-input {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  /* native browser-styling erzwingen, damit die Option-Liste beim Klick sicher aufgeht */
  -webkit-appearance: auto;
  appearance: auto;
  cursor: pointer;
  min-width: 0;
}
.trade-select option { background: var(--panel); color: var(--text); }
.trade-select:focus, .trade-input:focus { border-color: var(--amber); }
.trade-info {
  font-size: 12px;
  color: var(--text-mute);
  background: var(--bg-2);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
  line-height: 1.4;
}
.trade-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* ==========  UTIL  ========== */
.hidden { display: none !important; }

@media (max-width: 1100px) {
  .scene-start { flex-direction: column; }
  .game-main { grid-template-columns: 200px 1fr 240px; }
}
@media (max-width: 860px) {
  .game-main { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .sidebar { max-height: 220px; }
  .sidebar-left, .sidebar-right { border: none; border-bottom: 1px solid var(--border); }
}

/* ===========  MOBILE (≤640px)  ===========
   Canvas hat Priorität, Sidebars werden zu schiebbaren Panels.
   Topbar wird kompakt, Buttons bleiben fingerfreundlich (mind. 36 px hoch). */
@media (max-width: 640px) {
  /* Topbar: kompakter, dichter Wrap */
  .topbar { padding: 6px 8px; gap: 6px; }
  .topbar-group { gap: 4px; }
  .topbar .btn.small { padding: 6px 9px; font-size: 11px; min-height: 32px; }
  .topbar .tab { padding: 6px 10px; font-size: 12px; }
  .hud-pill { font-size: 10px; padding: 3px 7px; letter-spacing: 0; }
  /* Wenig wichtige Buttons hinter "Mehr" verstecken */
  #btn-tasks, #btn-research, #btn-auto-forager { display: none; }
  /* Sidebars werden zu Bottom-Sheets, gesteuert durch is-mobile-open */
  .game-main {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "canvas";
    position: relative;
  }
  .canvas-wrap { grid-area: canvas; }
  .sidebar-left, .sidebar-right {
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    z-index: 20;
    max-height: 65dvh;
    border: none;
    border-top: 1px solid var(--border-strong);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
    transform: translateY(calc(100% - 44px));
    transition: transform 0.25s ease;
    padding: 6px 12px 12px;
  }
  .sidebar-left.is-mobile-open,
  .sidebar-right.is-mobile-open { transform: translateY(0); }
  .sidebar::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--border-strong);
    border-radius: 2px;
    margin: 6px auto 8px;
  }
  /* Sidebar-Header (immer sichtbar) — dient als Tap-Bereich für Open/Close */
  .mobile-sheet-handle {
    display: block;
    cursor: pointer;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--amber-3, #ffd86b);
    padding: 4px 0 8px;
    user-select: none;
  }
  /* Game-Over: Footer-Buttons untereinander auf sehr schmalen Bildschirmen */
  .gameover-footer { flex-wrap: wrap; }
  .gameover-footer .submit-form,
  .gameover-footer .gameover-actions { flex: 1 1 100%; }
  .gameover-footer .submit-result { position: static; margin-top: 4px; }
  .gameover-header #gameover-title { font-size: 18px; }
  /* Modale full-screen */
  .modal-inner {
    margin: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    max-width: 100%;
    border-radius: 0;
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom, 0px));
  }
  /* Threat-Banner: horizontal scrollbar, damit lange Inhalte nicht stapeln */
  .threat-banner { padding: 6px 8px; gap: 6px; overflow-x: auto; flex-wrap: nowrap; }
  .threat-banner .threat-item { white-space: nowrap; flex-shrink: 0; font-size: 11px; }
  /* Hive-Tabs scrollbar */
  .hive-tabs { overflow-x: auto; flex-wrap: nowrap; }
  /* Berater (advisor) kompakter */
  #advisor { font-size: 12px; padding: 8px 12px; max-width: 90vw; }
  /* Inspector kompakter */
  #cell-inspector { max-width: 90vw; font-size: 12px; }
}

/* Sehr kleine Höhen (Landscape Phone): Sidebar-Sheets etwas kleiner */
@media (max-width: 640px) and (max-height: 500px) {
  .sidebar-left, .sidebar-right { max-height: 80dvh; }
}
