/* MäQu */

:root {
  --bg: #17263a;
  --panel: #213550;
  --panel2: #2b4466;
  --line: #3b5a83;
  --text: #fff;
  --muted: #a9bed8;
  --gold: #ffd23f;
  --gold-dark: #a87400;
  --red: #ff6b6b;
  --green: #46d67a;
  --focus: #ffe066;
  --font: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; outline: none; }
button * { pointer-events: none; }
.i { width: 1em; height: 1em; fill: currentColor; flex: none; vertical-align: -0.125em; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---------- Tasten-Symbole ---------- */

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 .4em;
  border: 2px solid #8aa0bb;
  border-bottom-width: 3px;
  border-radius: .4em;
  font: bold .8em/1.35 var(--font);
  color: #e3edf8;
  text-align: center;
  vertical-align: middle;
}
.g {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6em;
  height: 1.6em;
  padding: 0 .35em;
  border-radius: .8em;
  font-size: .8em;
  font-weight: bold;
  line-height: 1;
  color: #fff;
  background: #64748b;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .3);
  vertical-align: middle;
}
.g-a { background: #2fb45c; }
.g-b { background: #e5484d; }
.g-y { background: #e8b500; color: #222; }
.g-x { background: #2f6fd6; }
.g-sh, .g-pad { border-radius: .4em; }
.only-pad, .only-keys { display: none !important; }
body.dev-pad .only-pad { display: inline-flex !important; }
body.dev-keys .only-keys { display: inline-block !important; }

.coin {
  display: inline-block;
  flex: none;
  width: .95em;
  height: .95em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8c8 0 14%, #ffd23f 42%, #dc9b00 100%);
  box-shadow: inset 0 0 0 .09em var(--gold-dark);
  vertical-align: -0.12em;
}

/* ---------- Kopfleiste ---------- */

#hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 3px solid var(--line);
}
.stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 14px;
  background: var(--panel2);
  font-size: 22px;
  font-weight: bold;
  white-space: nowrap;
}
/* Rohstoffe: fast volles Lager orange, volles rot umrandet */
#hud-res { display: flex; align-items: center; gap: 8px; }
.stat.res { gap: 6px; padding: 5px 12px 5px 8px; }
.stat.res img { width: 26px; height: 26px; }
.stat.r-gold { color: var(--gold); }
.stat.r-wood { color: #f0c58e; }
.stat.r-stone { color: #e3e8ee; }
.stat.res.near { box-shadow: inset 0 0 0 2px #e8a33a; }
.stat.res.full { box-shadow: inset 0 0 0 2px var(--red); color: #ffb0b0; }
.stat.hearts { color: #ffc4c4; }
.stat .heart { color: var(--red); }
.stat.adm { padding: 3px 10px; background: #6b2f7a; color: #f6d9ff; font-size: 15px; letter-spacing: .5px; text-transform: uppercase; }
.bump { animation: bump .3s; }
@keyframes bump { 50% { transform: scale(1.12); } }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.spacer { flex: 1; }
/* Feste Höhe: Tasten-Symbole (Esc, F, Y) dürfen die Kopfleiste nicht höher machen, sonst springt das Spielfeld */
.hbtn {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 3px solid transparent;
  border-radius: 12px;
  background: var(--panel2);
  font-size: 18px;
  font-weight: bold;
  white-space: nowrap;
}
.hbtn .i { font-size: 22px; }
.hbtn:hover { border-color: var(--line); }
.hbtn.on { background: #7a5b10; color: var(--gold); }
.stat .inc { margin-left: 3px; font-size: .62em; font-weight: bold; color: #8fe0a6; }

/* Knopf zum Burghof und zurück; rot, wenn im Burghof Monster nah am Tor sind */
.hbtn.keep { gap: 8px; padding: 4px 12px 4px 6px; background: #6b4a1a; color: #ffe7a8; }
.hbtn.keep img { width: 30px; height: 30px; }
.hbtn.keep.alarm { border-color: #ff6b6b; background: #8a2430; color: #ffe0e0; animation: alarm .8s ease-in-out infinite; }
@keyframes alarm { 50% { box-shadow: 0 0 0 4px rgba(229, 72, 77, .5); } }

/* Preise: kleine Rohstoff-Symbole mit Zahlen, was fehlt, ist rot */
.cost { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 7px; font-weight: bold; color: #fff; white-space: nowrap; }
.cost > span { display: inline-flex; align-items: center; gap: 2px; }
.cost img { width: 1.2em; height: 1.2em; }
.cost .miss { color: #ff9d9d; }

/* ---------- Spielfeld ---------- */

#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#game {
  display: block;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
  touch-action: none;
}

/* Turm-Menü neben einem gebauten Turm */
#tower-menu {
  position: absolute;
  z-index: 5;
  width: 300px;
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: rgba(22, 36, 56, .97);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
#tower-menu.active { display: flex; }
.tm-name { font-size: 20px; font-weight: bold; text-align: center; }
.tm-stars { text-align: center; font-size: 20px; color: #4a6385; }
.tm-stars .on { color: var(--gold); }
.tm-info { text-align: center; font-size: 15px; color: var(--muted); }
.tm-info b { color: #fff; }
.tm-info .nx { color: var(--green); font-weight: bold; }
.mbtn .cost { font-size: 16px; }
/* Markt: was man hergibt, was man bekommt, dann tauschen */
.tm-extra { display: flex; flex-direction: column; gap: 6px; }
.tm-extra:empty { display: none; }
.mk { display: flex; align-items: center; gap: 8px; }
.mkl { flex: none; width: 40px; font-size: 14px; font-weight: bold; color: var(--muted); }
.mkr { display: flex; flex-wrap: wrap; gap: 4px; }
.rb { width: 34px; display: flex; flex-direction: column; align-items: center; padding: 3px 0 1px; border: 3px solid transparent; border-radius: 10px; background: var(--panel2); }
.rb img { width: 22px; height: 22px; }
.rb small { font-size: 11px; color: var(--muted); }
.rb.on { border-color: var(--gold); background: #3b5d8c; }
.mkt { display: flex; gap: 6px; }
.mkt .mbtn { flex: 1; justify-content: center; }
.mbtn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border: 3px solid transparent;
  border-radius: 12px;
  background: var(--panel2);
  font-size: 17px;
  font-weight: bold;
  text-align: left;
}
.mbtn > span { white-space: nowrap; }
.mbtn.up { background: #2d7547; flex-wrap: wrap; row-gap: 2px; }
.mbtn.up.reach { background: #285d88; }
.mbtn.up.dis { background: #38495f; color: #c7d3e2; }
/* Ausbau, der gerade zu teuer ist: blass, das Fehlende rot, unten ein roter Strich (wie bei den Bau-Knöpfen) */
.mbtn.up.poor { background: #26324a; color: #8a9bb3; box-shadow: inset 0 -4px 0 #e5484d; }
.mbtn.up.poor .cost > span { opacity: .45; }
.mbtn.up.poor .cost > .miss { opacity: 1; color: #ff6b6b; }
.mbtn.up.poor .next { color: #8a9bb3; }
.mbtn.up.meh { opacity: .6; }
.mbtn .ul { display: inline-flex; align-items: center; gap: 6px; }
.mbtn .next { flex-basis: 100%; font-size: 13px; font-weight: normal; line-height: 1.25; color: #dff5e6; white-space: normal; }
.mbtn .next b { color: #fff; }
.mbtn.dis .next { color: #c7d3e2; }
.pips { display: inline-flex; gap: 3px; margin-left: 2px; }
.pips i { width: 10px; height: 10px; border-radius: 3px; background: rgba(0, 0, 0, .35); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35); }
.pips i.on { background: var(--gold); box-shadow: none; }
.reach .pips i.on { background: #7dd3fc; }
.skills { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 5px; }
.skill { padding: 1px 8px; border-radius: 8px; background: #4a3512; color: var(--gold); font-size: 12px; font-weight: bold; }
.mbtn.sell { background: #7d3a30; }
.mbtn.sell.arm { background: #c0392b; }
.price { display: inline-flex; align-items: center; gap: 4px; color: var(--gold); white-space: nowrap; }
.price.red { color: #ffb0b0; }

/* ---------- Turmleiste ---------- */

/* Die Leiste hat eine feste Höhe, Info und Wellen-Knopf haben feste Maße: Was darin steht, darf nichts
   verschieben – sonst ändert sich die Größe des Spielfelds und das ganze Bild springt. */
#bar {
  flex: none;
  height: 113px;
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 8px 12px;
  background: var(--panel);
  border-top: 3px solid var(--line);
}
/* Wird es zu eng, werden die Knöpfe etwas schmaler, statt aus dem Bild zu rutschen */
#towers { position: relative; flex: 0 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; }
/* LB/RB liegen als Plaketten auf den Ecken, damit die Knöpfe beim Wechsel zum Controller nicht wandern */
#towers > .g { position: absolute; top: -5px; z-index: 1; font-size: 11px; }
#towers > .g:first-child { left: -6px; }
#towers > .g:last-child { right: -6px; }
.tbtn {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
  width: 84px;
  height: 94px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 3px solid transparent;
  border-radius: 14px;
  background: var(--panel2);
}
.tbtn:hover { border-color: var(--line); }
.tbtn img { width: 40px; height: 40px; max-width: 100%; object-fit: contain; }
.tbtn .cost { max-width: 100%; font-size: 12px; line-height: 15px; gap: 0 4px; }
.tbtn .cost img { width: 13px; height: 13px; }
/* Preise untereinander, jede Zeile mit festem Platz: Gold, Holz, Stein (leere Zeilen bleiben stehen) */
.tbtn .cost.col { width: 100%; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0; padding: 0 9px; }
.tbtn .cost.col > span { height: 14px; justify-content: space-between; }
.tbtn .cost.col > .none { visibility: hidden; }
/* Zu teuer: deutlich blass und grau, nur das Fehlende leuchtet rot, unten ein roter Strich. Bezahlbares bleibt kräftig. */
.tbtn.poor { background: #1d2a3d; box-shadow: inset 0 -4px 0 #e5484d; }
.tbtn.poor img { filter: grayscale(1) brightness(.75); opacity: .45; }
.tbtn.poor .cost > span { opacity: .4; }
.tbtn.poor .cost > .miss { opacity: 1; color: #ff6b6b; }
.tbtn.sel { border-color: var(--gold); background: #3b5d8c; box-shadow: 0 0 0 3px rgba(255, 210, 63, .3); }
.tbtn.locked { opacity: .5; cursor: default; }
.tbtn.locked:hover { border-color: transparent; }
.tbtn .lock { font-size: 28px; color: var(--muted); }
.tbtn .lockt { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.15; }
.tbtn .num { position: absolute; top: 3px; left: 5px; font-size: 11px; }
/* Fallen: kleinere Knöpfe mit erdigem Rand, durch einen Strich von den Türmen getrennt */
.tsep { flex: none; width: 3px; align-self: stretch; margin: 6px 2px; border-radius: 2px; background: var(--line); }
.tbtn.trap { width: 68px; background: #3a3a2e; }
.tbtn.trap img { width: 32px; height: 32px; }
.tbtn.trap.sel { background: #5a5532; }
/* Gebäude im Burghof: erdige Knöpfe wie die Fallen */
.tbtn.bld { background: #3a3a2e; }
.tbtn.bld.sel { background: #5a5532; }
/* Zu teuer gilt auch für Fallen, Gebäude und den gewählten Knopf: dunkel und mit roter Linie */
.tbtn.trap.poor, .tbtn.bld.poor { background: #1d2a3d; }
.tbtn.sel.poor { box-shadow: 0 0 0 3px rgba(255, 210, 63, .3), inset 0 -4px 0 #e5484d; }
#info .tag { padding: 1px 8px; border-radius: 8px; background: #5a5532; color: #f3e6a8; font-size: 13px; }
.hpbar { height: 10px; margin: 6px 10px 2px; border-radius: 5px; background: rgba(0, 0, 0, .4); overflow: hidden; }
.hpbar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(#7ee08f, #34b45a); }
#bar.many .tbtn { width: 70px; height: 84px; }
#bar.many .tbtn img { width: 32px; height: 32px; }
#bar.many .tbtn .cost.col { padding: 0 7px; }
#bar.many .tbtn .cost.col > span { height: 13px; }
#bar.many .tbtn .cost { font-size: 11px; line-height: 13px; gap: 0 3px; }
#bar.many .tbtn .cost img { width: 11px; height: 11px; }
#bar.many .tbtn .lockt { font-size: 11px; }
#bar.many #towers { gap: 5px; }
#bar.many #info .iname { font-size: 18px; }
#bar.many #info .idesc { font-size: 13px; }
.level-grid .world { grid-column: 1 / -1; margin: 6px 0 -4px; font-size: 20px; color: var(--gold); text-align: left; }

#info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 4px 14px;
  border-radius: 14px;
  background: var(--panel2);
  overflow: hidden;
}
/* Jede Zeile hat ihren festen Platz: Name eine Zeile, Beschreibung höchstens zwei, Werte eine */
#info .iname { flex: none; display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: bold; white-space: nowrap; }
#info .iname .cost { font-size: 16px; }
#info .idesc {
  flex: none;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.25;
  color: var(--muted);
}
#info .idesc .vs { color: var(--gold); }
/* Feste Höhe: Werte, die nicht mehr in die Zeile passen, rutschen in die nächste und sind dann ausgeblendet */
.bars { flex: none; height: 16px; display: flex; flex-wrap: wrap; gap: 4px 16px; overflow: hidden; font-size: 13px; line-height: 16px; color: var(--muted); white-space: nowrap; }
.bar { display: flex; align-items: center; gap: 3px; }
.bar.txt { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bar i { display: inline-block; width: 9px; height: 12px; border-radius: 3px; background: #476286; }
/* Legende für die Farben auf dem Spielfeld (wie heatMap in render.js) */
.bar.heatkey { gap: 6px; }
.bar.heatkey i { width: 90px; background: linear-gradient(90deg, hsl(0, 95%, 50%), hsl(62, 95%, 50%), hsl(125, 95%, 50%)); }
.bar i:first-child { margin-left: 4px; }
.bar i.on { background: var(--green); }

/* Feste Größe: Die Vorschau der Monster wird kleiner, wenn viele Sorten kommen (siehe fitWave in ui.js) */
#wave {
  flex: none;
  width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 12px;
  border: 3px solid #1d8a43;
  border-radius: 16px;
  background: linear-gradient(#63e690, #2db35a);
  box-shadow: 0 4px 0 #17693a;
  color: #062e16;
  font-size: 20px;
  font-weight: bold;
  overflow: hidden;
}
/* Leuchten statt Wachsen: Der Knopf bleibt, wo er ist */
#wave.go { animation: glow 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.04); } }
@keyframes glow { 50% { box-shadow: 0 4px 0 #17693a, 0 0 0 4px rgba(99, 230, 144, .55); filter: brightness(1.08); } }
#wave:disabled {
  border-color: var(--line);
  background: var(--panel2);
  box-shadow: none;
  color: var(--muted);
  cursor: default;
  animation: none;
}
#wave .wl { flex: none; max-width: 100%; display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; }
#wave kbd { color: #062e16; border-color: #1d8a43; }
/* Größen in em, damit fitWave alles zusammen über die Schriftgröße verkleinern kann */
#wave .prev {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  align-content: center;
  justify-content: center;
  gap: .12em .5em;
  overflow: hidden;
  font-size: 16px;
  white-space: nowrap;
}
#wave .prev.wrap { flex-wrap: wrap; }
#wave .prev span { display: flex; align-items: center; gap: 1px; }
/* Seitenverhältnis der Monster-Bilder (100 × 92, siehe icons in render.js): so stimmt die Breite schon vor dem Laden */
#wave .prev img { height: 1.75em; width: auto; aspect-ratio: 100 / 92; }
#wave .prev .boss { padding: 0 .25em; border-radius: .6em; background: rgba(200, 30, 60, .3); box-shadow: inset 0 0 0 2px #e5484d; }
#wave .prev .boss img { height: 2.25em; }
#wave:disabled .prev .boss { background: none; box-shadow: none; }

/* Reset-Knopf links neben dem Wellen-Knopf: feste Größe, außerhalb der Bauzeit nur grau (siehe renderUndo in ui.js) */
#undo {
  flex: none;
  width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  border: 3px solid #b86a12;
  border-radius: 16px;
  background: linear-gradient(#ffc163, #f08c1c);
  box-shadow: 0 4px 0 #8a4d0c;
  color: #3a1d00;
  font-size: 16px;
  font-weight: bold;
  white-space: nowrap;
}
#undo .i { font-size: 30px; }
#undo kbd { color: #3a1d00; border-color: #b86a12; }
#undo.arm { border-color: var(--red); background: #c0392b; box-shadow: 0 4px 0 #7a2318; color: #fff; }
#undo.arm kbd { color: #fff; border-color: #fff; }
#undo:disabled { border-color: var(--line); background: var(--panel2); box-shadow: none; color: var(--muted); cursor: default; }
#undo:disabled kbd { color: var(--muted); border-color: var(--line); }

/* Feste Höhe: Die Hinweise für Maus, Tastatur und Controller sind verschieden lang */
#hint {
  flex: none;
  height: 35px;
  padding: 4px 12px 6px;
  overflow: hidden;
  background: var(--panel);
  font-size: 14px;
  line-height: 1.8;
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#hint:empty { display: none; }

/* ---------- Meldungen ---------- */

/* Kleine Meldung unten mitten im Spielfeld, sie schiebt sich von unten herein */
#toast {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 30;
  width: max-content;
  max-width: min(560px, calc(100% - 32px));
  padding: 6px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: rgba(19, 31, 48, .94);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
  font-size: 14px;
  line-height: 1.35;
  color: var(--muted);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, calc(100% + 16px));
  transition: opacity .2s, transform .25s ease-out;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast b { color: #fff; }
#toast small { font-size: inherit; }
#toast small::before { content: " · "; }

/* ---------- Bildschirme ---------- */

#ui .screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(9, 17, 29, .72);
}
#ui .screen.active { display: flex; }
.panel {
  width: 100%;
  max-width: 760px;
  max-height: 100%;
  overflow: auto;
  padding: 24px 28px;
  border: 4px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  text-align: center;
}
.panel.wide { max-width: 860px; }
.panel h2 { font-size: 36px; margin-bottom: 6px; }
.panel p { margin: 6px 0; font-size: 19px; color: var(--muted); }
.panel p b { color: #fff; }
.panel p small { font-size: 16px; }
.logo { font-size: 58px; color: var(--gold); text-shadow: 0 4px 0 var(--gold-dark), 0 8px 18px rgba(0, 0, 0, .4); letter-spacing: 1px; }
.hero { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin: 4px 0; }
.hero img { height: 64px; }
.hero img.mon { height: 52px; }
.hero img.boss { height: 96px; margin-left: -8px; }
.panel p.progress { margin-top: 10px; font-size: 16px; color: var(--gold); }
.panel p.progress:empty { display: none; }
.panel p.progress .i { color: var(--gold); }
.panel p.progress.adm { color: #f0c8ff; }

.btn {
  min-width: 290px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 22px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: var(--panel2);
  font-size: 22px;
  font-weight: bold;
}
.btn.primary { border-color: #1d8a43; background: linear-gradient(#63e690, #2db35a); color: #062e16; }
.btn.danger { border-color: #8e3a33; background: #5e2a27; color: #ffd0cc; font-size: 18px; }
.btn.danger.arm { border-color: #ff6b6b; background: #c0392b; color: #fff; animation: pulse 1s ease-in-out infinite; }
.btn-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 12px; }
.btn-col { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 8px; }
.btn-col .btn { margin-top: 0; }
.btn-col .btn:first-child { margin-top: 10px; }
.focused, .mbtn:hover, .btn:hover, .lcard:hover:not(.locked) {
  border-color: var(--focus) !important;
  box-shadow: 0 0 0 4px rgba(255, 224, 102, .3);
}

.howto { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 14px 0 0; }
.howto div { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-radius: 14px; background: var(--panel2); font-size: 18px; font-weight: bold; }
.howto .n { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: #3a2a00; }
.controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; font-size: 14px; line-height: 1.9; color: var(--muted); text-align: left; }
.controls > div { padding: 10px 12px; border-radius: 14px; background: var(--panel2); }
.controls b { display: block; font-size: 16px; color: #fff; }

.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 14px; }
.lcard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px 12px;
  border: 3px solid var(--line);
  border-top: 10px solid var(--c1);
  border-radius: 16px;
  background: var(--panel2);
}
.lcard .ln { font-size: 36px; font-weight: bold; line-height: 1.15; }
.lcard .lname { font-size: 15px; color: var(--muted); }
.lcard .lst { font-size: 20px; color: #4a6385; }
.lcard .lst .on, .stars .on { color: var(--gold); }
.lcard.locked { opacity: .45; }
.lcard.locked .ln { font-size: 30px; color: var(--muted); }

/* Schwierigkeit: drei Knöpfe nebeneinander (Grün, Blau, Rot wie bei Skipisten), die gewählte Stufe leuchtet in ihrer Farbe */
.diff-pick { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }
.dbtn {
  flex: 0 1 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px 8px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: var(--panel2);
  font-size: 20px;
  font-weight: bold;
  color: var(--muted);
}
.dbtn .dmon { display: flex; align-items: flex-end; height: 30px; }
.dbtn .dmon img { height: 28px; margin: 0 -3px; }
.dbtn:not(.on) .dmon img { filter: grayscale(.7); opacity: .55; }
.dbtn.on { color: #fff; }
.d-easy.on, .dtag.d-easy { border-color: #1d8a43; background: #2a9d55; }
.d-normal.on, .dtag.d-normal { border-color: #2f62a8; background: #3b7fd4; }
.d-hard.on, .dtag.d-hard { border-color: #8e3a33; background: #c6453a; }
.panel p.diff-desc { margin-top: 8px; font-size: 16px; }
/* Schild mit der Stufe neben „Level geschafft!“ */
.dtag { display: inline-block; margin-left: 12px; padding: 2px 12px; border: 2px solid; border-radius: 12px; font-size: 18px; color: #fff; vertical-align: middle; }

.stars { font-size: 64px; line-height: 1.1; color: #3b5a83; }
.stars .i { margin: 0 4px; }
.note { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; padding: 8px 14px; border-radius: 14px; background: var(--panel2); font-size: 19px; }
.note.new { color: var(--gold); font-weight: bold; }
.note img { width: 60px; height: 60px; }
.hints { margin-top: 14px !important; font-size: 15px !important; }
.hints:empty { display: none; }

.noscript { padding: 40px; font-size: 22px; text-align: center; }

/* ---------- Statistik (Klick auf den Bergfried, siehe setStats in ui.js) ---------- */

.panel.stats { position: relative; max-width: 1040px; text-align: left; }
.st-x { position: absolute; top: 16px; right: 16px; width: 46px; height: 46px; display: grid; place-items: center; border: 3px solid var(--line); border-radius: 14px; background: var(--panel2); font-size: 22px; font-weight: bold; }
.st-lv { align-self: center; margin-right: 3px; font-size: 13px; color: var(--muted); }
.panel.stats h2 { display: flex; align-items: center; justify-content: center; gap: 10px; }
.panel.stats h2 .i { color: var(--gold); }
.panel.stats h3 { margin: 18px 0 8px; font-size: 14px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.panel.stats .btn-col, .panel.stats .hints { text-align: center; }
.panel.stats p.st-sub { margin: 0 0 12px; text-align: center; }
.panel.stats p.st-empty { margin: 0; font-size: 16px; }
.st-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.st-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 6px; border-radius: 14px; background: var(--panel2); text-align: center; }
.st-tile b { font-size: 26px; font-variant-numeric: tabular-nums; }
.st-tile span { font-size: 13px; color: var(--muted); }
.st-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }
.st-card { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 16px; background: var(--panel2); }
.st-head { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: bold; }
.st-head img { width: 26px; height: 26px; }
.st-now { margin-left: auto; font-size: 14px; font-weight: normal; color: var(--muted); }
.st-big { display: flex; align-items: baseline; gap: 8px; font-size: 32px; font-weight: bold; color: #8fe0a6; font-variant-numeric: tabular-nums; }
.st-big small { font-size: 14px; font-weight: normal; color: var(--muted); }
/* Balken aus Stücken je Herkunft: grün Burghof, blau Wellenbonus, rosa Monster */
.sbar { display: flex; height: 14px; border-radius: 7px; background: rgba(0, 0, 0, .35); overflow: hidden; }
.sbar.thin { height: 8px; border-radius: 4px; }
.sbar i { display: block; height: 100%; }
.s-keep { background: #8fe0a6; }
.s-base { background: #7dd3fc; }
.s-mobs { background: #f59fd0; }
.s-fill { background: #c9a46a; }
.st-legend { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 14px; color: var(--muted); }
.st-legend span { display: inline-flex; align-items: center; gap: 5px; }
.st-legend i { width: 10px; height: 10px; border-radius: 3px; }
.st-legend b { color: #fff; }
.st-legend.small { font-size: 12px; }
.st-had { display: flex; align-items: baseline; justify-content: space-between; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.st-had b { font-size: 18px; color: #fff; }
.st-store { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; margin-top: 4px; font-size: 14px; color: var(--muted); }
.st-store b { color: #fff; }
.st-store.full .s-fill { background: var(--red); }
.st-store.full b, .st-lost { color: #ffb0b0; }
.st-lost { font-size: 13px; }
.st-note { margin-top: 8px; font-size: 13px; color: var(--muted); text-align: center; }
.st-row { display: flex; align-items: flex-start; gap: 12px; padding: 8px 12px; border-radius: 14px; background: var(--panel2); }
.st-row + .st-row { margin-top: 6px; }
.st-row > img { flex: none; width: 52px; height: 52px; object-fit: contain; }
.st-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.st-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 18px; font-weight: bold; }
.st-name b { color: var(--gold); }
.st-spent { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: normal; color: var(--muted); }
.st-spent .cost { font-size: 15px; }
.st-facts { font-size: 15px; color: var(--muted); }
.st-facts b { color: #fff; }
.st-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.tchip { display: inline-flex; flex-direction: column; gap: 3px; padding: 5px 7px; border-radius: 8px; background: rgba(0, 0, 0, .25); }
.tchip .pips, .st-key .pips { margin: 0; }
.st-row .skills { justify-content: flex-start; margin-top: 0; }
.st-hps { display: flex; flex-wrap: wrap; gap: 6px; }
.st-hps .hpbar { width: 64px; margin: 0; }
.st-key { display: flex; align-items: center; gap: 6px; margin: -2px 0 8px; font-size: 14px; color: var(--muted); }
.st-key .reach { margin-left: 10px; }
.st-invest { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.st-invest > div { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border-radius: 14px; background: var(--panel2); font-size: 16px; }
.st-invest span { font-size: 13px; color: var(--muted); }
.st-invest .cost span { font-size: 16px; color: #fff; }
.st-invest .all { box-shadow: inset 0 0 0 2px var(--gold); }

/* ---------- Kleine Bildschirme ---------- */

/* Die Info wird ausgeblendet, sobald sie zu schmal würde. Reset- und Wellen-Knopf bleiben dann trotzdem rechts. */
#undo { margin-left: auto; }
@media (min-width: 1600px) {
  #wave { width: 400px; }
}
@media (max-width: 1400px) {
  #bar.many #info .idesc { display: none; }
  /* Kopfleiste mit allen Rohstoffen: enger, der Burghof-Knopf nur noch mit Bild */
  #hud { gap: 7px; }
  #hud-res { gap: 6px; }
  .stat.res { gap: 4px; padding: 4px 9px 4px 6px; }
  .hbtn.keep .kl { display: none; }
}
@media (max-width: 1380px) {
  #bar.many #info { display: none; }
}
/* Der Hinweis für die Maus passt nicht mehr in eine Zeile: dann immer zwei Zeilen Platz, für jedes Gerät */
@media (max-width: 1100px) {
  #hint {
    height: 55px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    line-height: 1.6;
    white-space: normal;
  }
}
@media (max-width: 1150px) {
  #bar { height: 103px; }
  #info .idesc { display: none; }
  .bars { height: 36px; }
  .tbtn { width: 70px; height: 84px; }
  .tbtn img { width: 32px; height: 32px; }
  #hud-res { gap: 5px; }
  .stat.res img { width: 20px; height: 20px; }
  .tbtn.trap { width: 58px; }
  .tbtn.trap img { width: 30px; height: 30px; }
  #wave { width: 270px; font-size: 17px; }
  #wave .prev { font-size: 14px; }
  #undo { width: 70px; font-size: 14px; }
  #undo .i { font-size: 26px; }
  .stat { font-size: 18px; padding: 4px 10px; }
  .hbtn { height: 38px; font-size: 16px; padding: 5px 9px; }
  #hud { flex-wrap: wrap; row-gap: 6px; }
}
@media (max-width: 1000px) {
  #info { display: none; }
  #wave { width: 240px; font-size: 16px; }
  #bar.many .tbtn { width: 64px; }
}
@media (max-height: 650px) {
  #bar { height: 92px; }
  #wave { gap: 2px; padding: 3px 10px; }
  #undo { gap: 0; padding: 2px; }
  #undo .i { font-size: 22px; }
  .tbtn, #bar.many .tbtn { height: 72px; }
  .tbtn img { width: 24px; height: 24px; }
  .tbtn .cost.col > span, #bar.many .tbtn .cost.col > span { height: 12px; }
  #hint { display: none; }
  .stat { font-size: 17px; }
}
/* Ganz schmal: Die Leiste darf umbrechen. Ihre Höhe hängt dann nur noch von der Fensterbreite ab. */
@media (max-width: 800px) {
  #bar { flex-wrap: wrap; height: auto; }
  #towers { flex-wrap: wrap; }
  #wave { width: auto; flex: 1 1 100%; height: 76px; }
  #hud { flex-wrap: wrap; }
  /* Das Admin-Schild würde die Kopfleiste hier umbrechen lassen; der Hinweis steht ja in der Levelauswahl */
  #hud .stat.adm { display: none; }
  /* Tasten-Symbole in der Kopfleiste weglassen, sonst bricht sie je nach Gerät anders um */
  body.dev-keys .hbtn .only-keys, body.dev-pad .hbtn .only-pad { display: none !important; }
  .controls { grid-template-columns: 1fr; }
  .level-grid { grid-template-columns: repeat(2, 1fr); }
  .diff-pick { gap: 6px; }
  .dbtn { font-size: 17px; padding: 6px 4px 8px; }
  .logo { font-size: 40px; }
  .btn { min-width: 220px; }
}
