: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; }
#topbar h1 .subtitle { font-weight: 400; color: var(--muted); font-size: 15px; }
.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; font-variant-numeric: tabular-nums; }
.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.small { min-width: 34px; height: 34px; font-size: 14px; }
.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: 225px;
  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;
}
.kpi {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 2px;
  border-bottom: 1px solid rgba(47, 62, 70, 0.08);
  font-size: 14.5px;
}
.kpi b { font-variant-numeric: tabular-nums; }
.kpi b.warn { color: #c0392b; }

#goals h3 {
  margin: 10px 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: '✓ '; }

/* Build menu (right) */
#buildmenu {
  top: 84px;
  right: 10px;
  width: 258px;
  padding: 14px;
  max-height: calc(100% - 280px);
  overflow-y: auto;
}
#buildmenu h2 { margin: 0 0 10px; font-size: 16px; }
.build-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border-radius: 12px;
  background: #fff;
  margin-bottom: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 54px;
}
.build-item.active { border-color: var(--orange); background: #fff7ee; }
.build-item.disabled { opacity: 0.45; }
.build-item .emoji { font-size: 24px; }
.build-item .info { flex: 1; }
.build-item .info b { display: block; font-size: 13.5px; }
.build-item .info small { color: var(--muted); font-size: 11px; line-height: 1.25; display: block; }
.build-item .cost { font-size: 12.5px; font-weight: 700; color: var(--green); white-space: nowrap; }
.locked-hint { font-size: 12px; color: var(--muted); text-align: center; padding: 6px; }

/* Info panel (Gebäude / Besucher) */
#infoPanel {
  left: 10px;
  bottom: 10px;
  width: 268px;
  padding: 12px 14px;
  z-index: 20;
}
.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.info-head b { font-size: 15px; }
.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3.5px 0;
  border-bottom: 1px solid rgba(47, 62, 70, 0.07);
}
.info-row span { color: var(--muted); }
button.slim { padding: 9px 12px; font-size: 14px; margin-top: 8px; width: 100%; }

/* Zwei Verlaufs-Graphen (unten, nebeneinander in eigenen Feldern) */
.graphbox {
  bottom: 10px;
  width: min(330px, 26vw);
  height: 150px;
  padding: 8px 10px 8px;
}
#graphMoney { left: calc(50% - min(330px, 26vw) - 8px); }
#graphSat { left: calc(50% + 8px); }
.graphbox canvas { width: 100%; height: 100%; }

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

/* Overlays & Karten */
.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(460px, 90vw);
  max-height: 84vh;
  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; }
.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; }

/* Social-Media-Feed in Karten */
#cardList { list-style: none; margin: 10px 0 0; padding: 0; text-align: left; }
#cardList li {
  background: #fff;
  border-radius: 12px;
  padding: 9px 12px;
  margin-bottom: 8px;
  border: 1.5px solid var(--beige-dark);
  font-size: 14px;
  line-height: 1.4;
}
.feed-stars { display: block; font-size: 12px; letter-spacing: 1px; }
.feed-text { color: var(--ink); }

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.primary:disabled { opacity: 0.45; cursor: default; }
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;
  cursor: pointer;
}
#logList li small { color: var(--muted); display: block; }

/* Start */
.intro { text-align: center !important; color: var(--muted); }
.start-hint { font-size: 12.5px; color: var(--muted); text-align: center !important; }
#startOverlay input, #playerName, #classCode {
  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;
}
#startOverlay input:focus { outline: none; border-color: var(--green); }
#btnStart { width: 100%; margin-top: 14px; }

/* Endauswertung */
.end-card { width: min(540px, 92vw) !important; }
.end-stars { font-size: 17px; font-weight: 700; margin: 8px 0 14px; }
.end-bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 34px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 6px;
  text-align: left;
}
.end-bar { background: var(--beige-dark); border-radius: 999px; height: 12px; overflow: hidden; }
.end-bar div { height: 100%; border-radius: 999px; }
.end-bar-row b { text-align: right; font-variant-numeric: tabular-nums; }
.end-goals { list-style: none; padding: 0; margin: 12px 0 4px; text-align: left; font-size: 13.5px; }
.end-goals li { color: #c0392b; padding: 2px 0; }
.end-goals li.done { color: var(--green); }
.end-facts { font-size: 12.5px; color: var(--muted); text-align: center !important; }
.end-feedback {
  background: #fff;
  border-radius: 12px;
  border: 1.5px solid var(--beige-dark);
  padding: 4px 14px;
  margin-top: 8px;
}
.end-feedback p { font-size: 13.5px; line-height: 1.45; }

/* Kleinere Screens (iPad Hochformat) */
@media (max-width: 900px) {
  #topbar h1 .subtitle { display: none; }
  .clock { font-size: 12px; }
  #kpis { width: 195px; }
  #buildmenu { width: 228px; }
  .graphbox { width: 240px; height: 120px; }
  #graphMoney { left: calc(50% - 248px); }
  #infoPanel { width: 240px; }
}

/* Musik-Player (rechts oben, links neben dem Baumenü) */
#musicPanel {
  top: 84px;
  right: 278px;
  width: 236px;
  padding: 10px 12px;
  z-index: 15;
}
.music-row { display: flex; align-items: center; gap: 6px; }
#muVol { flex: 1; accent-color: var(--orange); height: 28px; min-width: 60px; }
#muSelect {
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border: 2px solid var(--beige-dark);
  border-radius: 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
}
@media (max-width: 900px) {
  #musicPanel { right: 248px; width: 200px; }
}

/* Kartenwahl im Start-Overlay */
.map-title { margin: 14px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; text-align: left; }
#mapList { display: flex; flex-direction: column; gap: 8px; max-height: 34vh; overflow-y: auto; }
.map-btn {
  display: flex; gap: 10px; align-items: center; text-align: left;
  border: 2px solid var(--beige-dark); background: #fff; border-radius: 14px;
  padding: 8px 10px; cursor: pointer; font-family: inherit; min-height: 56px;
}
.map-btn img { width: 84px; height: 56px; object-fit: cover; border-radius: 8px; }
.map-btn b { display: block; font-size: 14px; color: var(--ink); }
.map-btn small { color: var(--muted); font-size: 11.5px; line-height: 1.25; display: block; }
.map-btn.active { border-color: var(--orange); background: #fff7ee; }

/* Ruf-Leiste (Reputation, TD-„Basis-HP") */
#repRow { margin: 4px 0 8px; }
.rep-head { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.rep-bar { height: 9px; border-radius: 999px; background: var(--beige-dark); overflow: hidden; }
#repFill { height: 100%; width: 60%; border-radius: 999px; background: var(--green);
  transition: width .4s ease, background .4s ease; }
#repFill.mid { background: var(--orange); }
#repFill.low { background: #c0392b; }
#repRow.pulse { animation: repPulse .5s ease; }
@keyframes repPulse { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: scale(1); } }

/* Wellen-Status-Banner in der Topbar */
.wave-status {
  margin-left: 14px; padding: 5px 14px; border-radius: 999px;
  background: var(--beige-dark); font-size: 13px; font-weight: 700; color: var(--ink);
  white-space: nowrap;
}
.wave-status.running { background: #fbe3cd; color: #b4560f; }
.wave-status.pause { background: #dce9dd; color: #326046; }
@media (max-width: 900px) { .wave-status { display: none; } }

/* Statistik-Overlay */
#statsBody { text-align: left; }
.stat-group { margin-bottom: 10px; }
.stat-group h3 { font-size: 13px; margin: 6px 0 4px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; }
.stat-row { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center;
  gap: 8px; font-size: 13px; margin-bottom: 4px; }
.stat-bar { background: var(--beige-dark); border-radius: 999px; height: 11px; overflow: hidden; }
.stat-bar div { height: 100%; border-radius: 999px; }
.stat-row b { text-align: right; font-variant-numeric: tabular-nums; }

/* Synergie-Anzeige im Info-Panel */
.info-row b.syn { color: #7b3fa0; }
.syn-why { font-size: 11px; color: #7b3fa0; padding: 1px 0 1px 4px; }

.heat-canvas { display: block; border-radius: 10px; margin: 2px auto 4px; max-width: 100%; }

/* Reflexionsfragen in der Endauswertung */
.end-reflect { text-align:left; margin-top:10px; background:#f4f0e4; border-radius:12px;
  border:1.5px solid var(--beige-dark); padding:6px 14px 10px; }
.end-reflect h3 { font-size:14px; margin:8px 0 4px; }
.end-reflect ul { margin:0 0 4px; padding-left:20px; }
.end-reflect li { font-size:13.5px; line-height:1.5; margin-bottom:5px; color:var(--ink); }

.tools-links { text-align:center !important; font-size:12.5px; margin-top:8px; }
.tools-links a { color:var(--muted); text-decoration:none; }
.tools-links a:hover { color:var(--green); text-decoration:underline; }
