/* Hivemeadow - Ansicht: warme Honig-/Cremefarben, weiche Karten, sichere Raender. */

:root {
  --honig: #efb53d;
  --honig-hell: #ffd970;
  --honig-dunkel: #c98d22;
  --creme: #fff7e6;
  --creme-2: #fbeccd;
  --braun: #4a331d;
  --braun-hell: #7a5a36;
  --gruen: #6f8f46;
  --rot: #b5533a;
  --glas: rgba(255, 248, 232, 0.94);
  --glas-hell: rgba(255, 252, 244, 0.76);
  --rand: rgba(90, 60, 25, 0.16);
  --schatten: 0 12px 32px rgba(74, 48, 18, 0.18), 0 2px 6px rgba(74, 48, 18, 0.1);
  --schatten-klein: 0 6px 18px rgba(74, 48, 18, 0.16);
  --radius: 18px;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Segoe UI", "Trebuchet MS", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  color: var(--braun);
  background: #f4ebd8;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

button {
  font-family: inherit;
}

#buehne {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 85% at 50% -10%, #e2f2fd 0%, #f6ecd6 52%, #eedcba 100%);
  transition: background 1.2s ease;
}

body[data-saison="fruehling"] #buehne {
  background: radial-gradient(120% 85% at 50% -10%, #e2f2fd 0%, #f7eed9 52%, #efdfbe 100%);
}

body[data-saison="sommer"] #buehne {
  background: radial-gradient(120% 90% at 50% -10%, #dcf3ff 0%, #fdf2d6 55%, #f1ddb0 100%);
}

body[data-saison="herbst"] #buehne {
  background: radial-gradient(120% 90% at 50% -10%, #f3e6cf 0%, #f8e7c6 50%, #e9d1a2 100%);
}

body[data-saison="winter"] #buehne {
  background: radial-gradient(120% 90% at 50% -10%, #e6f0fb 0%, #f2f1e9 55%, #dfe4e3 100%);
}

#buehne canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

/* ---------- Wetter- und Jahreszeiten-Schleier ---------- */

#wetter-schleier {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.4s ease, background 1.4s ease;
}

body[data-saison="winter"] #wetter-schleier {
  opacity: 0.4;
  background: radial-gradient(100% 80% at 50% 40%, rgba(238, 246, 255, 0.55), rgba(238, 246, 255, 0.18) 65%, rgba(255, 255, 255, 0));
}

body[data-wetter="regen"] #wetter-schleier {
  opacity: 1;
  background: linear-gradient(180deg, rgba(79, 108, 135, 0.26), rgba(120, 150, 170, 0.1) 45%, rgba(255, 255, 255, 0) 78%);
}

body[data-wetter="hitze"] #wetter-schleier {
  opacity: 1;
  background: radial-gradient(100% 85% at 50% 100%, rgba(255, 150, 50, 0.2), rgba(255, 196, 90, 0.08) 55%, rgba(255, 255, 255, 0));
}

body[data-wetter="kalt"] #wetter-schleier {
  opacity: 1;
  background: linear-gradient(180deg, rgba(150, 190, 235, 0.24), rgba(170, 200, 235, 0.08) 55%, rgba(255, 255, 255, 0));
}

/* ---------- Knoepfe ---------- */

.knopf {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--rand);
  border-radius: 14px;
  background: linear-gradient(180deg, #fffdf7, #fbeccd);
  color: var(--braun);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(90, 60, 25, 0.12), 0 6px 14px rgba(74, 48, 18, 0.1);
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  touch-action: manipulation;
}

.knopf:hover {
  background: linear-gradient(180deg, #fffefb, #fdf3dc);
}

.knopf:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(90, 60, 25, 0.12), 0 3px 8px rgba(74, 48, 18, 0.1);
}

.knopf:disabled {
  opacity: 0.48;
  cursor: default;
  transform: none;
}

.knopf:focus-visible,
#knopf-stock:focus-visible {
  outline: 3px solid rgba(239, 181, 61, 0.85);
  outline-offset: 2px;
}

.knopf-haupt {
  background: linear-gradient(180deg, #ffd66b, #efb133);
  border-color: #d99a21;
  color: #3f2a12;
  font-weight: 800;
  box-shadow: 0 3px 0 #c98d22, 0 12px 24px rgba(201, 141, 34, 0.3);
}

.knopf-haupt:hover {
  background: linear-gradient(180deg, #ffdd80, #f2b73e);
}

.knopf-gross {
  min-height: 54px;
  padding: 0 24px;
  border-radius: 16px;
  font-size: 17px;
}

.knopf-ikone {
  width: 44px;
  padding: 0;
  font-size: 14px;
  letter-spacing: 1px;
}

.knopf-tempo {
  width: 44px;
  padding: 0;
  font-weight: 800;
  color: var(--braun-hell);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(248, 232, 200, 0.72));
  box-shadow: none;
}

.knopf-tempo.aktiv {
  background: linear-gradient(180deg, #ffd66b, #efb133);
  border-color: #d99a21;
  color: #3f2a12;
  box-shadow: 0 2px 6px rgba(201, 141, 34, 0.32);
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  z-index: 10;
  top: calc(6px + env(safe-area-inset-top, 0px));
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  margin: 0 auto;
  max-width: 1120px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.hud-zeile {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 16px;
  background: var(--glas);
  box-shadow: var(--schatten-klein);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.hud-jahr {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.jahresring {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.jahresring circle {
  fill: none;
}

.jahresring-spur {
  stroke: rgba(90, 60, 25, 0.12);
  stroke-width: 3.2;
}

.jahresring-fortschritt {
  stroke: var(--honig-dunkel);
  stroke-width: 3.2;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 20px 20px;
  transition: stroke-dashoffset 0.5s ease;
}

.jahresring-punkt {
  fill: #8a6a35;
}

.hud-jahr-text {
  display: flex;
  flex-direction: column;
  line-height: 1.08;
  min-width: 0;
}

.hud-jahr-titel {
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.hud-jahr-neben {
  font-size: 13px;
  color: var(--braun-hell);
  white-space: nowrap;
}

.hud-wetter {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 1 1 auto;
  color: var(--braun-hell);
}

.wetter-symbol {
  display: inline-flex;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  color: var(--honig-dunkel);
}

.wetter-symbol svg {
  width: 24px;
  height: 24px;
  display: block;
}

.hud-wetter-text {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-zeit {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex: 0 0 auto;
}

.hud-werte {
  justify-content: space-between;
  gap: 4px 10px;
  flex-wrap: wrap;
  padding-top: 4px;
  padding-bottom: 4px;
}

.wert {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  min-height: 30px;
}

.wert-bild {
  width: 17px;
  height: 17px;
  color: var(--honig-dunkel);
  flex: 0 0 auto;
}

.wert-label {
  font-size: 13px;
  color: var(--braun-hell);
}

.wert-zahl {
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
}

/* ---------- Hinweisleiste ---------- */

#wahl-leiste {
  position: fixed;
  z-index: 26;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 28px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(74, 51, 29, 0.9);
  color: #fff6e2;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 8px 22px rgba(74, 48, 18, 0.28);
  pointer-events: none;
  animation: leisteRein 0.25s ease-out;
}

body[data-bildschirm="spiel"] #wahl-leiste {
  top: calc(112px + env(safe-area-inset-top, 0px));
}

/* ---------- Karten/Panels ---------- */

.karte-schwebend {
  background: linear-gradient(170deg, rgba(255, 251, 242, 0.98), rgba(255, 241, 214, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--schatten);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#wahl-panel {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(600px, 100%);
  max-height: 45dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 18px calc(16px + env(safe-area-inset-bottom, 0px));
  border-radius: 22px 22px 0 0;
  pointer-events: auto;
  animation: panelAuf 0.24s ease-out;
}

.panel-kopf {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.panel-titel {
  font-size: 16px;
  font-weight: 800;
}

.panel-unter {
  font-size: 13px;
  color: var(--braun-hell);
}

.panel-hinweise {
  margin: 4px 0 6px;
}

.hinweis-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  margin: 2px 5px 2px 0;
  border-radius: 999px;
  background: rgba(90, 60, 25, 0.07);
  font-size: 13px;
  white-space: nowrap;
}

.hinweis-chip.gut {
  background: rgba(111, 143, 70, 0.16);
  color: #4b6427;
}

.hinweis-chip.warn {
  background: rgba(181, 83, 58, 0.14);
  color: #8a3a25;
}

.balken-reihe {
  display: grid;
  grid-template-columns: 66px 1fr 48px;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
  font-size: 13px;
}

.balken-name {
  color: var(--braun-hell);
  white-space: nowrap;
}

.balken-spur {
  height: 10px;
  border-radius: 999px;
  background: rgba(90, 60, 25, 0.1);
  box-shadow: inset 0 1px 2px rgba(90, 60, 25, 0.14);
  overflow: hidden;
}

.balken-fuell {
  height: 100%;
  min-width: 3px;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.balken-fuell.fruehling {
  background: linear-gradient(90deg, #a6d987, #6eae4c);
}

.balken-fuell.sommer {
  background: linear-gradient(90deg, #f6d072, #e3a52c);
}

.balken-fuell.herbst {
  background: linear-gradient(90deg, #dfa06b, #b96a35);
}

.balken-wert {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.panel-zeilen {
  display: grid;
  gap: 3px;
  margin: 8px 0 2px;
  font-size: 14px;
}

.panel-zeile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-zeile .panel-wert {
  font-weight: 700;
}

.sterne {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 20px;
  line-height: 1;
  color: #d99a21;
}

.stern {
  opacity: 0.22;
}

.stern.an {
  opacity: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.panel-hinweis {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--braun-hell);
}

.panel-fehler {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: #a5432a;
}

.panel-knoepfe {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.panel-knoepfe .knopf {
  flex: 1 1 auto;
  min-height: 50px;
}

/* ---------- Start-, Todes- und Fehlerbild ---------- */

.ebene {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(14px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
  background: radial-gradient(100% 80% at 50% 40%, rgba(255, 248, 230, 0.08), rgba(246, 235, 212, 0.42) 58%, rgba(236, 219, 185, 0.66) 100%);
  pointer-events: auto;
}

#startbild {
  background: radial-gradient(100% 80% at 50% 42%, rgba(255, 248, 230, 0.05), rgba(246, 235, 212, 0.38) 58%, rgba(236, 219, 185, 0.62) 100%);
  animation: bildEin 0.5s ease-out;
}

#todbild {
  z-index: 46;
  background: radial-gradient(100% 80% at 50% 40%, rgba(60, 40, 20, 0.16), rgba(60, 40, 20, 0.36) 70%, rgba(40, 26, 12, 0.46) 100%);
  animation: bildEin 0.5s ease-out;
}

.start-karte {
  width: min(540px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: clamp(20px, 5vw, 36px) clamp(18px, 5vw, 34px);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  background: linear-gradient(160deg, rgba(255, 251, 243, 0.97), rgba(255, 243, 220, 0.93));
  box-shadow: 0 24px 70px rgba(74, 48, 18, 0.24), 0 4px 12px rgba(74, 48, 18, 0.12);
  text-align: center;
}

.start-titel {
  margin: 0 0 8px;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(44px, 9vw, 70px);
  line-height: 1;
  letter-spacing: 0.5px;
  color: #43301a;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.75), 0 6px 16px rgba(74, 48, 18, 0.16);
}

.start-untertitel {
  margin: 0 auto 20px;
  max-width: 40ch;
  font-size: 16px;
  color: var(--braun-hell);
}

.start-knoepfe {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.start-knoepfe .knopf {
  flex: 1 1 170px;
  max-width: 240px;
}

.start-fuss {
  margin: 18px auto 0;
  max-width: 46ch;
  font-size: 13px;
  color: var(--braun-hell);
  opacity: 0.9;
}

.tod-titel {
  font-size: clamp(30px, 6vw, 42px);
  margin-bottom: 10px;
}

.tod-grund {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: #8a3a25;
}

#todbild .start-knoepfe {
  margin-top: 18px;
}

#webgl-hinweis {
  z-index: 60;
  background: radial-gradient(100% 80% at 50% 40%, #f7eedb, #ead9b7 100%);
}

.webgl-text {
  max-width: 42ch;
  margin: 0 auto;
  font-size: 16px;
  line-height: 1.5;
  text-align: center;
}

#lade-hinweis {
  z-index: 55;
  background: rgba(247, 238, 213, 0.72);
}

.lade-pille {
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--glas);
  box-shadow: var(--schatten-klein);
  font-size: 15px;
  font-weight: 600;
  color: var(--braun-hell);
}

/* ---------- Einblendungen ---------- */

#toasts {
  position: fixed;
  z-index: 45;
  top: calc(120px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(430px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  pointer-events: none;
}

body[data-bildschirm="wahl"] #toasts {
  top: calc(70px + env(safe-area-inset-top, 0px));
}

.toast {
  padding: 10px 14px;
  border-radius: 14px;
  border-left: 4px solid var(--honig);
  background: rgba(74, 51, 29, 0.93);
  color: #fff6e2;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 26px rgba(50, 32, 12, 0.3);
  animation: toastRein 0.26s ease-out;
}

.toast.fort {
  animation: toastWeg 0.4s ease-in forwards;
}

/* ---------- Stock-Knopf und P3-Platzhalter ---------- */

#knopf-stock {
  position: fixed;
  z-index: 22;
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  min-width: 92px;
  height: 58px;
  padding: 0 20px;
  border-radius: 20px;
  border: 1px solid #d99a21;
  background: linear-gradient(165deg, #ffe08a, #efb133);
  color: #3f2a12;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 0 #c98d22, 0 16px 28px rgba(74, 48, 18, 0.28);
  transition: transform 0.08s ease, box-shadow 0.15s ease;
  touch-action: manipulation;
}

#knopf-stock:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 #c98d22, 0 8px 16px rgba(74, 48, 18, 0.24);
}

body.panel-offen #knopf-stock {
  display: none;
}

#platzhalter {
  position: fixed;
  z-index: 24;
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  width: min(340px, calc(100vw - 28px));
  max-height: 62dvh;
  overflow-y: auto;
  padding: 16px 18px;
  border-radius: 20px;
  pointer-events: auto;
  animation: panelAuf 0.2s ease-out;
}

.platzhalter-titel {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 800;
}

.platzhalter-hinweis {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--braun-hell);
}

.platzhalter-werte {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 14px;
}

.platzhalter-zeile {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.platzhalter-zeile b {
  font-variant-numeric: tabular-nums;
}

#platzhalter .knopf {
  width: 100%;
}

/* ---------- Querformat/PC: HUD einzeilig, Panel als Seitenleiste ---------- */

@media (orientation: landscape) {
  #hud {
    flex-direction: row;
    align-items: stretch;
    max-width: calc(100% - 16px);
  }

  .hud-oben {
    flex: 0 0 auto;
  }

  .hud-werte {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    align-items: center;
  }

  #wahl-panel {
    left: auto;
    right: calc(10px + env(safe-area-inset-right, 0px));
    top: calc(10px + env(safe-area-inset-top, 0px));
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    transform: none;
    width: min(400px, 44vw);
    max-height: none;
    border-radius: 22px;
    padding: 16px 18px;
    animation: panelSeite 0.24s ease-out;
  }

  body[data-bildschirm="spiel"] #wahl-panel {
    top: calc(74px + env(safe-area-inset-top, 0px));
  }

  body[data-bildschirm="spiel"] #wahl-leiste {
    top: calc(80px + env(safe-area-inset-top, 0px));
  }

  #toasts {
    top: calc(84px + env(safe-area-inset-top, 0px));
  }

  body[data-bildschirm="wahl"] #toasts {
    top: calc(66px + env(safe-area-inset-top, 0px));
  }

  #knopf-stock {
    right: calc(16px + env(safe-area-inset-right, 0px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  #platzhalter {
    right: calc(16px + env(safe-area-inset-right, 0px));
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 540px) {
  .hud-wetter-text {
    display: none;
  }

  .hud-zeile {
    padding: 5px 8px;
    gap: 5px;
  }

  .hud-jahr {
    gap: 5px;
  }

  .jahresring {
    width: 36px;
    height: 36px;
  }

  #wahl-panel {
    padding-left: 14px;
    padding-right: 14px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  #hud {
    top: calc(4px + env(safe-area-inset-top, 0px));
    gap: 4px;
  }

  .hud-zeile {
    padding: 3px 8px;
    gap: 5px;
  }

  .jahresring {
    width: 32px;
    height: 32px;
  }

  .hud-jahr-titel {
    font-size: 13px;
  }

  .hud-jahr-neben {
    font-size: 13px;
  }

  .hud-werte {
    padding-top: 2px;
    padding-bottom: 2px;
  }

  .wert {
    min-height: 26px;
  }

  .start-karte {
    padding: 16px 22px;
    border-radius: 22px;
  }

  .start-titel {
    font-size: clamp(32px, 8vh, 48px);
    margin-bottom: 4px;
  }

  .start-untertitel {
    margin-bottom: 12px;
    font-size: 14px;
  }

  .start-fuss {
    display: none;
  }

  .knopf-gross {
    min-height: 48px;
    font-size: 15px;
  }

  #startbild .start-karte {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0 18px;
    width: min(620px, 100%);
  }

  #startbild .start-titel {
    flex: 1 1 100%;
  }

  #startbild .start-untertitel {
    flex: 1 1 100%;
  }

  #startbild .start-knoepfe {
    flex: 1 1 100%;
  }

  #wahl-panel {
    width: min(370px, 46vw);
    top: calc(10px + env(safe-area-inset-top, 0px));
    padding: 12px 14px;
  }

  body[data-bildschirm="spiel"] #wahl-panel {
    top: calc(66px + env(safe-area-inset-top, 0px));
  }

  .panel-knoepfe .knopf {
    min-height: 44px;
  }

  #toasts {
    top: calc(72px + env(safe-area-inset-top, 0px));
    width: min(360px, calc(100vw - 440px));
  }

  #platzhalter {
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- Bewegung ---------- */

@keyframes panelAuf {
  from {
    transform: translate(-50%, 18px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

@keyframes panelSeite {
  from {
    transform: translateX(18px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastRein {
  from {
    transform: translateY(-6px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes toastWeg {
  to {
    transform: translateY(-8px);
    opacity: 0;
  }
}

@keyframes leisteRein {
  from {
    transform: translate(-50%, -8px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

@keyframes bildEin {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
}

/* ---------- P4: Ton-Knopf ---------- */

.knopf-ton {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(248, 232, 200, 0.72));
  box-shadow: none;
}

.knopf-ton.aus {
  opacity: 0.58;
}

@media (max-width: 540px) {
  .knopf-ton {
    width: 36px;
    min-width: 36px;
    font-size: 15px;
  }
}

/* ---------- P4: kleine Honig-Toasts direkt unter dem HUD ---------- */

#toasts {
  z-index: 12;
  top: calc(104px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(350px, calc(100vw - 24px));
  align-items: center;
  gap: 5px;
}

.toast {
  max-width: 100%;
  padding: 6px 11px;
  border-radius: 11px;
  border-left: 3px solid var(--honig);
  background: rgba(255, 248, 232, 0.86);
  color: #5a3c1c;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 12px rgba(74, 48, 18, 0.16);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: toastRein 0.22s ease-out;
}

.toast.wetter {
  border-left-color: #86a9c4;
  background: rgba(244, 250, 255, 0.86);
}

.toast.jahr {
  border-left-color: var(--honig-dunkel);
}

.toast.ereignis {
  border-left-color: #9c8b5c;
}

.toast.warnung {
  border-left-color: #d06a2c;
  background: rgba(255, 236, 214, 0.92);
  color: #7a3416;
}

.toast.tod {
  border-left-color: #b5342a;
  background: rgba(255, 228, 222, 0.94);
  color: #7d1f16;
  font-weight: 800;
}

.toast.wichtig {
  box-shadow: 0 5px 16px rgba(122, 52, 22, 0.28);
}

body[data-bildschirm="tot"] #toasts {
  z-index: 47;
}

@media (orientation: portrait) {
  #toasts {
    top: calc(102px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
    width: min(350px, calc(100vw - 24px));
  }
}

@media (orientation: landscape) {
  #toasts {
    top: calc(66px + env(safe-area-inset-top, 0px));
    left: calc(12px + env(safe-area-inset-left, 0px));
    transform: none;
    align-items: flex-start;
    width: min(340px, 42vw);
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  #toasts {
    top: calc(56px + env(safe-area-inset-top, 0px));
  }
}

/* ---------- P3: Stockansicht ---------- */

#stock-ansicht {
  position: fixed;
  inset: 0;
  z-index: 9;
  overflow: hidden;
  background: radial-gradient(120% 86% at 50% 0%, #f8efdb 0%, #f2e3c4 55%, #e7d1a6 100%);
}

#stock-buehne {
  position: absolute;
  inset: 0;
}

#stock-buehne canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
  outline: none;
}

body.stock-offen #buehne {
  visibility: hidden;
}

body.stock-offen #wahl-panel,
body.stock-offen #platzhalter,
body.stock-offen #knopf-stock,
body.stock-offen #knopf-rangliste {
  display: none !important;
}

.stock-kopf {
  position: absolute;
  z-index: 3;
  left: calc(10px + env(safe-area-inset-left, 0px));
  right: calc(10px + env(safe-area-inset-right, 0px));
  top: calc(132px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 7px;
  pointer-events: none;
}

.stock-kopf > * {
  pointer-events: auto;
}

.stock-kopf-mitte {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--rand);
  border-radius: 16px;
  background: var(--glas);
  box-shadow: var(--schatten-klein);
}

.stock-name {
  appearance: none;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 36px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--braun);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  touch-action: manipulation;
}

.stock-name-feld {
  flex: 1 1 auto;
  width: 100%;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--honig-dunkel);
  border-radius: 10px;
  background: #fffaf0;
  color: var(--braun);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
}

.stock-zustand {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e9eeda;
  color: #4a642c;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stock-zustand.zustand-thriving {
  background: #dff0c2;
  color: #3f6b18;
}

.stock-zustand.zustand-growing {
  background: #fbecc6;
  color: #8a5a12;
}

.stock-zustand.zustand-hungry {
  background: #f7d2bd;
  color: #96380f;
}

.stock-zustand.zustand-weak {
  background: #eadfe7;
  color: #6d3656;
}

.stock-pfeil,
.stock-zu {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  border: 1px solid var(--rand);
  border-radius: 14px;
  background: var(--glas);
  color: var(--braun);
  font: inherit;
  font-size: 17px;
  font-weight: 800;
  box-shadow: var(--schatten-klein);
  cursor: pointer;
  touch-action: manipulation;
}

.stock-pfeil:disabled {
  opacity: 0.4;
  cursor: default;
}

.stock-zu {
  background: linear-gradient(180deg, #f7ddcb, #eec4a8);
  color: #7d3018;
  border-color: #dcae90;
}

.stock-schublade {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  max-height: 50dvh;
  border: 1px solid var(--rand);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: var(--glas);
  box-shadow: 0 -12px 34px rgba(74, 48, 18, 0.24);
  transition: transform 0.28s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.stock-schublade.zu {
  transform: translateY(calc(100% - 46px));
}

.stock-griff {
  position: relative;
  flex: 0 0 46px;
  height: 46px;
  border: 0;
  background: transparent;
  color: var(--braun-hell);
  font: inherit;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.stock-griff::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 7px;
  width: 44px;
  height: 4px;
  margin-left: -22px;
  border-radius: 2px;
  background: rgba(90, 60, 25, 0.24);
}

.stock-inhalt {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 12px 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.stock-karte {
  padding: 10px 12px;
  border: 1px solid var(--rand);
  border-radius: 16px;
  background: rgba(255, 250, 238, 0.72);
}

.stock-karte-titel {
  margin-bottom: 6px;
  color: var(--braun-hell);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stock-hinweis {
  margin: 0 0 8px;
  color: var(--braun-hell);
  font-size: 12px;
}

.stock-rat {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--honig);
  border-radius: 8px;
  background: rgba(242, 184, 63, 0.13);
  color: var(--braun);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
}

.stock-werte-raster {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.stock-wert {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 4px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.52);
}

.stock-wert-label {
  color: var(--braun-hell);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-wert-zahl {
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stock-kurve {
  display: block;
  width: 100%;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 224, 138, 0.24), rgba(255, 255, 255, 0));
}

.stock-regler {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  font-size: 12px;
}

.stock-regler-name {
  color: var(--braun);
  font-weight: 700;
  white-space: nowrap;
}

.stock-regler input[type="range"] {
  width: 100%;
  height: 34px;
  margin: 0;
  accent-color: #c98d22;
  touch-action: manipulation;
}

.stock-regler-wert {
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ausbau-karte {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px dashed rgba(90, 60, 25, 0.16);
}

.ausbau-karte:first-of-type {
  border-top: 0;
  padding-top: 2px;
}

.ausbau-kopf {
  display: flex;
  align-items: baseline;
  gap: 7px;
  grid-column: 1;
}

.ausbau-titel {
  font-size: 13px;
  font-weight: 800;
}

.ausbau-stufe {
  color: var(--braun-hell);
  font-size: 11px;
  font-weight: 700;
}

.ausbau-nutzen {
  grid-column: 1;
  color: var(--braun-hell);
  font-size: 11.5px;
}

.ausbau-fuss {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.ausbau-preis {
  color: var(--honig-dunkel);
  font-weight: 700;
}

.ausbau-knopf {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  min-width: 76px;
}

.ausbau-karte.gesperrt {
  opacity: 0.56;
}

.knopf-klein {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 13px;
}

.stock-flug {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stock-flug-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stock-flug-label {
  color: var(--braun-hell);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stock-flug-feld {
  font-weight: 800;
}

.stock-flug-knoepfe {
  display: flex;
  gap: 6px;
}

.stock-schwarm {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.stock-schwarm-knopf {
  width: 100%;
}

.stock-ereignisse {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ereignis-zeile {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}

.ereignis-woche {
  flex: 0 0 auto;
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--creme-2);
  color: var(--braun-hell);
  font-size: 10px;
  font-weight: 800;
}

.ereignis-text {
  color: var(--braun);
}

.ereignis-leer {
  color: var(--braun-hell);
  font-size: 12px;
}

.stock-stil-karte {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.stock-stil-karte .stock-karte-titel {
  flex: 0 0 100%;
  margin-bottom: 0;
}

.stock-stil {
  flex: 1 1 auto;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--rand);
  border-radius: 12px;
  background: #fffaf0;
  color: var(--braun);
  font: inherit;
  font-weight: 700;
}

.stock-rang-knopf {
  margin-left: auto;
}

#knopf-rangliste {
  position: fixed;
  z-index: 22;
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  min-width: 84px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--glas);
  color: var(--braun);
  font-size: 13px;
  font-weight: 800;
  box-shadow: var(--schatten-klein);
}

body:not([data-bildschirm="spiel"]) #knopf-rangliste {
  display: none;
}

/* Jahresbilanz und Rangliste */

#bilanz {
  z-index: 44;
}

#rangliste {
  z-index: 44;
}

.bilanz-karte {
  width: min(430px, 100%);
}

.bilanz-titel {
  margin: 0 0 4px;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(26px, 6vw, 38px);
  line-height: 1.05;
  color: #43301a;
}

.bilanz-text {
  margin: 0 0 14px;
  color: var(--braun-hell);
  font-size: 14px;
}

.bilanz-werte {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
  text-align: left;
}

.bilanz-zeile {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.bilanz-zeile b {
  font-variant-numeric: tabular-nums;
}

.bilanz-sorten-box {
  margin-bottom: 8px;
  text-align: left;
}

.bilanz-sorten-titel {
  margin-bottom: 4px;
  color: var(--braun-hell);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bilanz-sorten {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
}

.bilanz-sorte {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.bilanz-sorte b {
  font-variant-numeric: tabular-nums;
}

.bilanz-leer {
  color: var(--braun-hell);
  font-size: 12px;
}

.bilanz-rang {
  margin: 4px 0 14px;
  color: var(--honig-dunkel);
  font-weight: 800;
}

.bilanz-knoepfe {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bilanz-knoepfe .knopf {
  width: 100%;
}

@media (orientation: landscape) and (max-height: 520px) {
  .bilanz-karte {
    padding: 16px 22px;
  }

  .bilanz-titel {
    font-size: 26px;
  }

  .bilanz-text {
    margin-bottom: 8px;
  }

  .bilanz-werte {
    gap: 3px;
    margin-bottom: 8px;
  }

  .bilanz-sorten-box {
    margin-bottom: 4px;
  }

  .bilanz-rang {
    margin: 2px 0 8px;
  }

  .bilanz-knoepfe {
    flex-direction: row;
  }

  .bilanz-knoepfe .knopf {
    width: auto;
    flex: 1 1 0;
    min-height: 46px;
  }
}

.rang-karte {
  width: min(460px, 100%);
  text-align: left;
}

.rang-zu {
  float: right;
  min-height: 44px;
  margin: -6px -6px 0 8px;
  font-size: 13px;
}

.rang-titel {
  margin: 0 0 12px;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(26px, 6vw, 36px);
  color: #43301a;
}

.rang-liste {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 52dvh;
  margin: 0 0 10px;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.rang-zeile {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  font-size: 13px;
}

.rang-zeile.rang-du {
  background: linear-gradient(90deg, rgba(255, 214, 107, 0.55), rgba(255, 245, 214, 0.55));
  font-weight: 800;
}

.rang-platz {
  color: var(--braun-hell);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rang-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rang-punkte {
  font-variant-numeric: tabular-nums;
}

.rang-trenner,
.rang-leer {
  padding: 4px 8px;
  color: var(--braun-hell);
  font-size: 12px;
}

.rang-eigen {
  margin: 0;
  color: var(--honig-dunkel);
  font-weight: 800;
  font-size: 14px;
}

/* Erste Hinweise */

.stock-hinweis-karte {
  position: fixed;
  z-index: 32;
  left: 50%;
  top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(380px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(74, 51, 29, 0.94);
  color: #fff6e2;
  box-shadow: 0 14px 30px rgba(50, 32, 12, 0.28);
  transform: translateX(-50%);
  pointer-events: none;
  animation: hinweisRein 0.26s ease-out;
}

@keyframes hinweisRein {
  from {
    transform: translate(-50%, -8px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

.hinweis-textbox {
  flex: 1 1 auto;
  min-width: 0;
}

.hinweis-titel {
  margin-bottom: 2px;
  font-size: 13px;
  font-weight: 800;
}

.hinweis-text {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
}

.hinweis-ok {
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 44px;
  padding: 0 14px;
  border-color: #d99a21;
  background: linear-gradient(180deg, #ffd66b, #efb133);
  color: #3f2a12;
  font-weight: 800;
  pointer-events: auto;
}

body[data-bildschirm="spiel"] .stock-hinweis-karte {
  top: calc(132px + env(safe-area-inset-top, 0px));
}

body.stock-offen #hinweis,
body.bilanz-offen #hinweis,
body.rang-offen #hinweis {
  display: none;
}

/* Einblendungen nicht ueber Kopfzeile und Schliessen-Knopf legen. */
body.stock-offen #toasts {
  top: calc(194px + env(safe-area-inset-top, 0px));
}

/* Jahresbilanz und Rangliste bleiben frei von Einblendungen. */
body.bilanz-offen #toasts,
body.rang-offen #toasts {
  display: none;
}

@media (orientation: landscape) {
  body.stock-offen #toasts {
    top: calc(134px + env(safe-area-inset-top, 0px));
  }

  .stock-kopf {
    top: calc(74px + env(safe-area-inset-top, 0px));
    right: calc(min(400px, 42vw) + 20px + env(safe-area-inset-right, 0px));
  }

  .stock-schublade {
    left: auto;
    top: calc(74px + env(safe-area-inset-top, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    width: min(400px, 42vw);
    max-height: none;
    border: 1px solid var(--rand);
    border-radius: 20px;
    padding-bottom: 0;
    transform: none;
  }

  .stock-schublade.zu {
    transform: translateX(calc(100% - 46px));
  }

  body[data-bildschirm="spiel"] .stock-hinweis-karte {
    top: calc(72px + env(safe-area-inset-top, 0px));
  }

  #knopf-rangliste {
    right: calc(16px + env(safe-area-inset-right, 0px));
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 420px) {
  .stock-werte-raster {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stock-regler {
    grid-template-columns: 66px minmax(0, 1fr) 40px;
  }
}

