:root {
  --green: #4f7f5e;
  --green-light: #7ba05b;
  --beige: #ede6d6;
  --beige-dark: #d9cfb4;
  --orange: #e8892b;
  --ink: #2f3e46;
  --muted: #6b7a70;
  --panel: rgba(253, 251, 244, 0.92);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: linear-gradient(#d8e7de, #ece7d6);
  touch-action: none;
}

.panel {
  position: fixed;
  background: var(--panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(47, 62, 70, 0.18);
  z-index: 10;
}

/* Top bar */
#topbar {
  top: 10px;
  left: 10px;
  right: 10px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}
#topbar h1 { font-size: 18px; margin: 0; font-weight: 700; white-space: nowrap; }
#sceneName { font-weight: 400; color: var(--muted); font-size: 14px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.clock { font-size: 14px; color: var(--muted); white-space: nowrap; margin-right: 4px; }
.speed { display: flex; gap: 4px; background: var(--beige-dark); border-radius: 14px; padding: 3px; }

.icon-btn {
  position: relative;
  min-width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--beige);
  font-size: 17px;
  color: var(--ink);
  cursor: pointer;
}
.icon-btn.active { background: var(--green); color: #fff; }
.icon-btn.muted { opacity: 0.45; }
.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--orange);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
}

/* KPI panel (left) */
#kpis {
  top: 84px;
  left: 10px;
  width: 220px;
  padding: 14px;
  max-height: calc(100% - 110px);
  overflow-y: auto;
}
.kpi-season {
  background: var(--green);
  color: #fff;
  border-radius: 10px;
  text-align: center;
  padding: 6px;
  font-weight: 700;
  margin-bottom: 10px;
}
/* Jahreskreis: vier Saison-Segmente mit Positions-Marker */
#yearWheel {
  position: relative;
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: visible;
  margin: 0 2px 8px;
}
#yearWheel .seg { flex: 1; }
#yearWheel .seg.sum { background: #a8c65f; }
#yearWheel .seg:first-child { border-radius: 999px 0 0 999px; }
#yearWheel .seg.aut { background: #d8a04e; }
#yearWheel .seg.win { background: #a9c6d8; }
#yearWheel .seg.spr { background: #b5d8a0; }
#yearWheel .seg:nth-last-child(2) { border-radius: 0 999px 999px 0; }
#yearMarker {
  position: absolute;
  top: -3px;
  width: 6px;
  height: 14px;
  background: var(--ink);
  border-radius: 3px;
  border: 1.5px solid #fff;
  transform: translateX(-50%);
  transition: left 0.4s linear;
}

/* Wetter heute + Vorhersage */
#weatherRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px 6px;
  border-bottom: 1px solid rgba(47, 62, 70, 0.08);
}
#weatherRow b { font-size: 16px; }
#weatherRow #forecast { font-size: 12.5px; color: var(--muted); letter-spacing: 0.03em; }

.kpi {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 2px;
  border-bottom: 1px solid rgba(47, 62, 70, 0.08);
  font-size: 15px;
}
.kpi b { font-variant-numeric: tabular-nums; }
.kpi-gap {
  font-size: 11.5px;
  color: #b3541e;
  background: #fdf1e6;
  border-radius: 8px;
  padding: 4px 8px;
  margin: 4px 0 2px;
  line-height: 1.3;
}
.kpi b.warn { color: var(--orange); }

/* Build menu (right) */
#buildmenu {
  top: 84px;
  right: 10px;
  width: 250px;
  padding: 14px;
  max-height: calc(100% - 280px);
  overflow-y: auto;
}
#buildmenu h2 { margin: 0 0 10px; font-size: 16px; }
.build-item {
  display: block;
  padding: 9px 10px;
  border-radius: 12px;
  background: #fff;
  margin-bottom: 8px;
  border: 2px solid transparent;
  cursor: pointer;
}
.build-item.active { border-color: var(--orange); background: #fff7ee; }
.build-item.disabled { opacity: 0.45; }
/* Zeile 1: Titel + ℹ links, Preis rechts */
.build-item .bi-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.build-item .bi-title { display: flex; align-items: center; gap: 2px; min-width: 0; }
.build-item .bi-title b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.build-item .cost { font-size: 13px; font-weight: 700; color: var(--green); white-space: nowrap; }
/* Zeile 2: zweispaltig Icon | Beschreibung */
.build-item .bi-body { display: flex; gap: 10px; align-items: flex-start; margin-top: 4px; }
.build-item .emoji { font-size: 24px; line-height: 1.1; flex-shrink: 0; }
.build-item .desc { color: var(--muted); font-size: 11.5px; line-height: 1.3; }

/* Graphs (bottom) */
#graphs {
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: min(780px, 64vw);
  height: 150px;
  padding: 8px 14px 12px;
  display: flex;
  flex-direction: row;
  gap: 14px;
  overflow: hidden;              /* Sicherung: nichts bricht unten aus */
}
.graph-box { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.graph-box canvas, #graphCanvas { flex: 1; width: 100%; min-height: 0; display: block; }
#graphs .legend { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
#graphs .dot { display: inline-block; width: 10px; height: 10px; border-radius: 999px; margin: 0 4px 0 10px; }
#graphs .dot.money { background: var(--green); }
#graphs .dot.guests { background: var(--orange); }
#graphCanvas { flex: 1; width: 100%; }

/* Skipass-Preis */
.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 2px 2px;
  font-size: 15px;
  font-weight: 600;
}
#priceSlider {
  width: 100%;
  margin: 2px 0 6px;
  accent-color: var(--orange);
  height: 28px;
}

/* Ziele */
#goals h3 {
  margin: 8px 0 4px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#goalList { list-style: none; margin: 0; padding: 0; }
#goalList li {
  font-size: 13px;
  padding: 3px 0;
  color: var(--muted);
}
#goalList li.done { color: var(--green); font-weight: 600; }
#goalList li::before { content: '○ '; }
#goalList li.done::before { content: '✓ '; }

/* Auftrag (Quest) */
#quest h3 {
  margin: 10px 0 4px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.quest-body {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  border: 1.5px solid var(--beige-dark);
}
.quest-icon { font-size: 22px; }
.quest-body b { font-size: 13.5px; display: block; }
.quest-body small { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; }
.quest-reward { color: var(--green) !important; font-weight: 700; }

/* Entscheidungs-Karten */
.card-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.card-buttons .secondary { width: auto; padding: 12px 22px; margin-top: 8px; font-size: 15px; }

/* Szenenwahl */
.intro { text-align: center !important; color: var(--muted); }
#valleyName {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border: 2px solid var(--beige-dark);
  border-radius: 12px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
}
#valleyName:focus { outline: none; border-color: var(--green); }
.scene-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.scene-btn {
  text-align: left;
  border: 2px solid var(--beige-dark);
  background: #fff;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  min-height: 56px;
  font-family: inherit;
}
.scene-btn b { display: block; font-size: 15px; color: var(--ink); }
.scene-btn small { color: var(--muted); }
.scene-btn:not(.locked):hover, .scene-btn:not(.locked):active {
  border-color: var(--green);
  background: #f4f8f1;
}
.scene-btn.locked { opacity: 0.5; cursor: default; }

/* Musik-Player (öffnet unter dem 🎵-Button) */
#playerPanel {
  top: 84px;
  right: 60px;
  width: 250px;
  padding: 12px;
  z-index: 30;
}
#trackSelect {
  width: 100%;
  padding: 9px 10px;
  border: 2px solid var(--beige-dark);
  border-radius: 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  margin-bottom: 8px;
}
.player-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.player-controls .icon-btn { min-width: 40px; height: 40px; font-size: 14px; }
#plVol { flex: 1; accent-color: var(--orange); height: 28px; }

/* Gebäude-Inspektion */
.bi-level { text-align: center; color: var(--orange); font-weight: 700; margin: -2px 0 8px; letter-spacing: 0.06em; }
.bi-stats { list-style: none; margin: 0 0 10px; padding: 0; text-align: left; }
.bi-stats li { font-size: 14px; padding: 4px 0; border-bottom: 1px solid rgba(47,62,70,0.08); }
.bi-cost { text-align: center; font-size: 13.5px; color: var(--muted); background: #fbf6ec; border-radius: 10px; padding: 8px; margin-bottom: 8px; line-height: 1.45; }
.bi-cost b { color: var(--ink); }
.bi-demolish { display: block; width: 100%; margin-top: 10px; background: none; border: none; color: #a3541e; font-size: 13px; cursor: pointer; padding: 6px; }
.bi-demolish:hover { text-decoration: underline; }
.bi-sec { text-align: left; font-weight: 700; font-size: 13px; color: var(--ink); margin: 2px 0 5px; }
.bi-problems { text-align: left; margin-bottom: 8px; }
.bi-prob { font-size: 13px; line-height: 1.4; background: #fdecea; color: #9a3327; border-radius: 8px; padding: 6px 9px; margin-bottom: 5px; }
.bi-knowledge { text-align: left; margin-bottom: 4px; }
.bi-know { font-size: 12.5px; line-height: 1.45; color: var(--ink); background: #eef4ee; border-left: 3px solid var(--green); border-radius: 6px; padding: 6px 9px; margin-bottom: 5px; }
.bi-know b { color: #2f6b46; }

/* Tagesbericht (Tabelle) */
.report-card { width: min(520px, 92vw); text-align: left; }
#rpBody { font-size: 13.5px; }
.rp-head { display: flex; justify-content: space-between; align-items: baseline;
  color: var(--muted); margin-bottom: 10px; border-bottom: 2px solid var(--beige-dark); padding-bottom: 6px; }
.rp-head b { color: var(--ink); font-size: 15px; }
.rp-sec { margin: 12px 0 4px; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--green); }
.rp-tbl { width: 100%; border-collapse: collapse; }
.rp-tbl td { padding: 3px 0; vertical-align: top; }
.rp-tbl td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-tbl tr.sum td { border-top: 1px solid var(--beige-dark); font-weight: 700; padding-top: 5px; }
.rp-net { display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; padding: 10px 12px; border-radius: 12px; font-size: 16px; font-weight: 700; }
.rp-net.pos { background: #edf5ee; color: #2f7a4e; }
.rp-net.neg { background: #fdecea; color: #a3271f; }
.rp-factor { color: var(--muted); }
.rp-factor.bad { color: #b3541e; font-weight: 600; }
.rp-hint { background: #fbf6ec; border-radius: 8px; padding: 6px 9px; margin-top: 4px;
  font-size: 12.5px; color: #6b5a33; }
.rp-bottleneck { background: #fdf1e6; color: #b3541e; border-radius: 8px; padding: 7px 10px;
  margin: 8px 0; font-size: 13px; }

/* Toast */
#toast {
  bottom: 175px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  font-size: 15px;
  max-width: 80vw;
  text-align: center;
  z-index: 40;
}

/* Overlays & cards */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(47, 62, 70, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.hidden { display: none !important; }
.overlay .card {
  position: static;
  width: min(680px, 92vw);   /* breiter: iPad-Text ohne Scroll-Zwang */
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  text-align: center;
}
.card-icon { font-size: 44px; }
.card h2 { margin: 8px 0 6px; }
.card p { color: var(--ink); line-height: 1.5; white-space: pre-line; text-align: left; }

button.primary:disabled { opacity: 0.45; cursor: default; }
button.primary {
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  min-height: 46px;
  margin-top: 8px;
}
button.secondary {
  width: 100%;
  margin-top: 10px;
  background: var(--beige);
  color: var(--ink);
  border: none;
  border-radius: 12px;
  padding: 10px;
  font-size: 14px;
  cursor: pointer;
  min-height: 44px;
}

#logList { list-style: none; padding: 0; margin: 0; text-align: left; }
#logList li {
  padding: 8px 4px;
  border-bottom: 1px solid rgba(47, 62, 70, 0.1);
  font-size: 14px;
}
#logList li small { color: var(--muted); display: block; }

/* Smaller screens (iPad portrait, small laptops) */
@media (max-width: 900px) {
  #topbar h1 span { display: none; }
  #kpis { width: 190px; }
  #buildmenu { width: 220px; }
  #graphs { width: 420px; height: 120px; }
}

/* Info-Zeile oben (Audio-Modus): Meldung ohne Spielstopp, antippbar */
#infoBanner {
  position: fixed; top: 58px; left: 50%; transform: translateX(-50%);
  max-width: min(680px, 92vw); padding: 9px 16px; cursor: pointer;
  display: flex; align-items: center; gap: 10px; font-size: 14px;
  z-index: 60; animation: ibSlide .25s ease-out;
}
#infoBanner.hidden { display: none; }
#infoBanner .ib-icon { font-size: 20px; }
#infoBanner .ib-hint { color: var(--muted); font-size: 12px; margin-left: 4px; white-space: nowrap; }
@keyframes ibSlide { from { transform: translate(-50%, -14px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ℹ-Button im Baumenü */
.build-item { position: relative; }
.build-item .bi-menu-info {
  background: none; border: none; cursor: pointer; font-size: 14px;
  padding: 4px 6px; opacity: .65; flex-shrink: 0;
}
.build-item .bi-menu-info:hover { opacity: 1; }
