/* Layout: Das Terrarium füllt den ganzen Bildschirm. Status-Leiste oben,
   Werkzeuge unten (Hochformat) bzw. rechts am Rand (Querformat).
   Eine bewusst dunkle, warme Optik wie ein abends beleuchtetes Terrarium. */
:root {
  --room: #1b1411;
  --wood: #2a1f19;
  --wood-hi: #3a2b22;
  --glass: rgba(34, 25, 20, 0.84);
  --sheet-top: #33261d;
  --sheet-bottom: #221913;
  --ink: #f7ecdb;
  --muted: #c4ae93;
  --line: rgba(255, 236, 210, 0.14);
  --tint: rgba(255, 240, 220, 0.06);
  --accent: #f2873a;
  --accent-soft: rgba(242, 135, 58, 0.18);
  --accent-ink: #2a1206;
  --accent-shadow: #a5521b;
  --water: #63c0ec;
  --love: #ff7ba3;
  --danger: #ff6a5c;
  --mouse: #d6ccc1;
  --mint: #7fd1c4;
  --moon: #ffe7a3;
  --sun: #ffd23f;
  --paper: #fff3df;
  --paper-ink: #2a1d14;
  --health: #7ed36a;
  --sponge: #ffd36b;
  --wood-ico: #c98b4f;
  --ok: #7ed36a;
  --scrim: rgba(14, 9, 7, 0.74);
  --font-display: 'Luckiest Guy', 'Baloo 2', ui-rounded, 'Trebuchet MS', system-ui, sans-serif;
  --font-ui: 'Baloo 2', ui-rounded, 'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--room);
  color: var(--ink);
  font-family: var(--font-ui);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* Icons */
.ico-line { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ico-line.dots { stroke-width: 2.8; }
.ico-fill { stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.ico-hl { fill: none; stroke: var(--paper); stroke-width: 1.8; stroke-linecap: round; opacity: 0.8; }
.f-accent { fill: var(--accent-soft); }
.f-love { fill: var(--love); }
.f-water { fill: var(--water); }
.f-mouse { fill: var(--mouse); }
.f-mint { fill: var(--mint); }
.f-moon { fill: var(--moon); }
.f-sun { fill: var(--sun); }
.f-paper { fill: var(--paper); }
.f-ink { fill: var(--paper-ink); }
.f-health { fill: var(--health); }
.f-sponge { fill: var(--sponge); }
.f-wood { fill: var(--wood-ico); }
.f-danger { fill: var(--danger); }

/* Status oben */
#hud {
  position: fixed;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "chip stats actions";
  align-items: center;
  gap: 8px 10px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
  padding-bottom: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.chip {
  grid-area: chip;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 44vw;
  padding: 5px 14px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.chip-dot {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--snake, var(--accent));
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.28), 0 0 0 2px rgba(0, 0, 0, 0.35);
}
.chip-text { display: grid; min-width: 0; text-align: left; line-height: 1.05; }
.chip-name { font-family: var(--font-display); font-size: 18px; letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-top: 2px; }
.chip-species { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats { grid-area: stats; display: flex; justify-content: center; gap: 8px; min-width: 0; pointer-events: none; }
.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.stat-ico { flex: none; width: 20px; height: 20px; }
.bar { position: relative; width: 54px; height: 8px; border-radius: 99px; background: rgba(255, 240, 220, 0.16); overflow: hidden; }
.bar i { position: absolute; inset: 0; border-radius: inherit; background: var(--c); transform-origin: left center; transform: scaleX(var(--v, 0.5)); transition: transform 0.4s ease, background 0.3s; }
#statFull { --c: var(--accent); }
#statWater { --c: var(--water); }
#statMood { --c: var(--love); }
#statHealth { --c: var(--health); }
.stat.low { animation: pulse 1.2s ease-in-out infinite; }
.stat.low .bar i { background: var(--danger); }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px rgba(255, 106, 92, 0.4); } }
.hud-actions { grid-area: actions; display: flex; gap: 6px; }
.round {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  touch-action: manipulation;
}
.round svg { width: 22px; height: 22px; }
#btnSound .snd-off { display: none; }
#btnSound[aria-pressed="false"] .snd-off { display: inline; }
#btnSound[aria-pressed="false"] .snd-on { display: none; }

@media (max-width: 560px) {
  #hud { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "chip actions" "stats stats"; }
  .chip { max-width: 100%; justify-self: start; }
  .stats { justify-content: space-between; }
  .stat { flex: 1 1 0; }
  .bar { flex: 1; width: auto; }
}

/* Werkzeuge */
#toolbar {
  position: fixed;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding-top: 8px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: linear-gradient(180deg, var(--wood-hi), var(--wood));
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.35);
}
.tool {
  flex: 0 1 74px;
  min-width: 0;
  height: 66px;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  align-items: center;
  gap: 2px;
  padding: 6px 2px 6px;
  border-radius: 16px;
  border: 2px solid transparent;
  background: var(--tint);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  touch-action: manipulation;
  transition: transform 0.12s ease, background 0.2s, border-color 0.2s;
}
.tool svg { width: 30px; height: 30px; }
.tool span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tool:active { transform: scale(0.93); }
.tool[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
#btnFeed { touch-action: none; }

@media (max-width: 430px) {
  #toolbar { gap: 4px; }
  .tool { flex: 1 1 0; font-size: 10.5px; padding: 6px 0; letter-spacing: -0.02em; }
  .tool svg { width: 28px; height: 28px; }
}

@media (orientation: landscape) {
  #toolbar {
    top: 0;
    left: auto;
    flex-direction: column;
    padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
    padding-left: 8px;
    padding-right: calc(env(safe-area-inset-right, 0px) + 8px);
    border-top: 0;
    border-left: 1px solid var(--line);
    background: linear-gradient(90deg, var(--wood-hi), var(--wood));
    box-shadow: -6px 0 20px rgba(0, 0, 0, 0.35);
  }
  .tool { flex: 0 1 68px; width: 80px; height: auto; min-height: 50px; }
  #hud { right: var(--tb-w, 96px); }
}
@media (orientation: landscape) and (max-height: 460px) {
  #toolbar { gap: 4px; padding-top: calc(env(safe-area-inset-top, 0px) + 4px); padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 4px); }
  .tool { flex: 1 1 0; min-height: 0; max-height: 64px; width: 72px; padding: 3px 2px; font-size: 10.5px; }
  .tool svg { width: 24px; height: 24px; }
  #hud { padding-top: calc(env(safe-area-inset-top, 0px) + 4px); }
  .chip-dot { width: 22px; height: 22px; }
  .chip-name { font-size: 15px; }
  .round { width: 34px; height: 34px; }
}

/* Meldungen */
#toast {
  position: fixed;
  z-index: 11; /* über Fenstern (10), unter dem Artikel (12); fängt keine Tipps ab */
  left: max(16px, env(safe-area-inset-left, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(var(--tb-h, 84px) + 14px);
  width: fit-content;
  max-width: 460px;
  margin: 0 auto;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--paper);
  color: var(--paper-ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show { opacity: 1; transform: none; }
@media (orientation: landscape) {
  #toast { right: calc(var(--tb-w, 96px) + 16px); bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }
}

#hint {
  position: fixed;
  z-index: 6;
  left: 16px;
  right: 16px;
  top: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: 420px;
  margin: 0 auto;
  padding: 12px 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--glass);
  font-weight: 700;
  font-size: 16px;
  transform: translateY(-50%);
  pointer-events: none;
  animation: hint 4s ease forwards;
}
#hint svg { flex: none; width: 48px; height: 24px; animation: swipe 1s ease-in-out infinite alternate; }
@keyframes hint { 0% { opacity: 0; } 10% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes swipe { from { transform: translateX(-6px); } to { transform: translateX(6px); } }

/* Auswahl und Steckbrief */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--scrim);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  touch-action: pan-y;
}
.sheet-card {
  width: min(960px, 100%);
  min-width: 0;
  margin: auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 20px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--sheet-top), var(--sheet-bottom));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
h1, h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 1.05;
  color: var(--accent);
  text-wrap: balance;
  text-shadow: 0 3px 0 var(--accent-ink);
}
h1 { font-size: clamp(28px, 6vw, 44px); }
h2 { font-size: clamp(28px, 6vw, 38px); }
h3 { margin: 4px 0 0; font-size: 18px; font-weight: 800; }
.lead { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.4; max-width: 65ch; }
.species-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; }
@media (max-width: 480px) { .species-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 4px;
  min-width: 0;
  padding: 8px 8px 12px;
  border-radius: 18px;
  border: 2px solid var(--line);
  background: rgba(255, 240, 220, 0.04);
  text-align: left;
  touch-action: manipulation;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.card:active { transform: scale(0.98); }
.card[aria-pressed="true"] { border-color: var(--accent); background: rgba(242, 135, 58, 0.12); }
.card .preview {
  position: relative;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 10;
  margin-bottom: 4px;
  border-radius: 12px;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 30%, #7a5533, #3f2a1a);
}
.card canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.card h3 { margin: 0 4px; font-size: clamp(15px, 4.1vw, 17px); line-height: 1.15; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; }
.card .tag { margin: 0 4px; font-size: 13.5px; line-height: 1.25; opacity: 0.88; overflow-wrap: anywhere; }
.card .latin { margin: 0 4px; font-size: 12.5px; font-style: italic; color: var(--muted); overflow-wrap: anywhere; }
.adopt { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.adopt label { font-size: 16px; font-weight: 700; }
.adopt-row { display: flex; gap: 8px; }
.adopt input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 50px;
  padding: 0 14px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font: 700 20px var(--font-ui);
  -webkit-user-select: text;
  user-select: text;
}
.adopt .round { width: 50px; height: 50px; }
.adopt .round svg { width: 28px; height: 28px; }
.primary {
  height: 56px;
  padding: 4px 18px 0;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-size: 23px;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 0 var(--accent-shadow);
  touch-action: manipulation;
}
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--accent-shadow); }
.secondary {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--tint);
  font-weight: 700;
  touch-action: manipulation;
}

.info-card { width: min(640px, 100%); }
.info-sub { margin: 6px 0 0; color: var(--muted); }
.facts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.facts-grid div { padding: 10px 12px; border-radius: 14px; background: rgba(255, 240, 220, 0.05); min-width: 0; }
.facts-grid dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.facts-grid dd { margin: 2px 0 0; font-weight: 700; line-height: 1.25; }
.fun { display: grid; gap: 6px; margin: 0; padding-left: 20px; line-height: 1.4; max-width: 65ch; }
.info-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.info-stats div { display: grid; padding: 10px 6px; border-radius: 14px; background: rgba(255, 240, 220, 0.05); }
.info-stats strong { font-family: var(--font-display); font-weight: 400; font-size: 28px; color: var(--accent); font-variant-numeric: tabular-nums; }
.info-stats span { font-size: 12.5px; color: var(--muted); }
.info-actions { display: flex; justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) {
  .bar i, #toast, .tool, .card { transition: none; }
  .stat.low { animation: none; }
  #hint svg { animation: none; }
}


/* Abzeichen an Knöpfen */
.tool { position: relative; }
.badge {
  position: absolute;
  top: 3px;
  right: 6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
}
.badge.warn { background: var(--danger); color: var(--paper); animation: pulse 1.2s ease-in-out infinite; }
.stats { flex-wrap: nowrap; }
@media (min-width: 561px) { .bar { width: 44px; } .stat { padding: 5px 8px 5px 5px; } }

/* Pflege-Menü */
.popover {
  position: fixed;
  z-index: 9; /* über dem Hinweis-Toast, sonst verdeckt er das Futter */
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--sheet-top);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.popover button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 14px 6px 8px;
  border: 0;
  border-radius: 12px;
  background: var(--tint);
  font-weight: 700;
  font-size: 15px;
  text-align: left;
  touch-action: manipulation;
}
.popover button:active { transform: scale(0.97); }
.popover svg { width: 30px; height: 30px; flex: none; }

/* Einrichten-Katalog */
#buildDrawer, #roomBar, #scrBar {
  position: fixed;
  z-index: 5;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: 8px;
  padding-top: 10px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: linear-gradient(180deg, var(--wood-hi), var(--wood));
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.35);
  min-width: 0;
}
.drawer-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.drawer-head strong { font-family: var(--font-display); font-weight: 400; font-size: 20px; letter-spacing: 0.04em; color: var(--accent); }
.drawer-hint { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { min-height: 38px; padding: 0 16px; border-radius: 19px; border: 1px solid var(--line); background: var(--tint); font-weight: 800; touch-action: manipulation; }
.primary-pill { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.cat-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; touch-action: pan-x; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tabs button {
  flex: none;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 17px;
  border: 1px solid var(--line);
  background: var(--tint);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  touch-action: manipulation;
}
.cat-tabs button[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); }
.item-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; min-width: 0; scrollbar-width: thin; touch-action: pan-x; }
.item-tile {
  flex: none;
  width: 92px;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 4px 7px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: rgba(255, 240, 220, 0.07);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  touch-action: none;
}
.item-tile canvas { width: 80px; height: 64px; display: block; }
.item-tile.on { border-color: var(--accent); }
.item-tile span { max-width: 100%; overflow-wrap: anywhere; }
@media (orientation: landscape) {
  #buildDrawer, #roomBar, #scrBar {
    top: 0;
    left: auto;
    width: min(320px, 42vw);
    align-content: start;
    grid-template-rows: auto auto minmax(0, 1fr);
    padding-top: calc(env(safe-area-inset-top, 0px) + 10px);
    padding-left: 12px;
    padding-right: calc(env(safe-area-inset-right, 0px) + 12px);
    border-top: 0;
    border-left: 1px solid var(--line);
    background: linear-gradient(90deg, var(--wood-hi), var(--wood));
  }
  .drawer-hint { display: none; }
  .cat-tabs { flex-wrap: wrap; overflow: visible; }
  .item-list { flex-wrap: wrap; overflow-x: hidden; overflow-y: auto; align-content: start; touch-action: pan-y; }
  .item-tile { width: calc(50% - 4px); }
}

/* Leiste am ausgewählten Gegenstand */
.item-bar {
  position: fixed;
  z-index: 6;
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 16px;
  background: var(--sheet-top);
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -100%);
}
.item-bar button { width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--tint); display: grid; place-items: center; padding: 0; touch-action: manipulation; }
.item-bar svg { width: 26px; height: 26px; }

/* Auswahl */
.group-title { margin: 10px 0 8px; font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.start-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 8px; margin: 4px 0 0; padding: 0; border: 0; min-width: 0; }
.start-choice legend { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.start-choice label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--line); background: rgba(0, 0, 0, 0.18); cursor: pointer; }
.start-choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.start-choice input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.start-choice span { display: grid; }
.start-choice small { color: var(--muted); font-size: 12.5px; }
.start-choice label.disabled { opacity: 0.45; pointer-events: none; }
.warn-note { margin: 0; color: var(--sponge); font-weight: 700; font-size: 14px; }

/* Listen */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 6px; }
.checklist li { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 12px; background: rgba(255, 240, 220, 0.05); font-weight: 600; min-width: 0; }
.checklist li::before { content: ""; flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--ok); box-shadow: inset 0 0 0 5px var(--sheet-top); }
.checklist li.no::before { background: var(--danger); }
.checklist li.no { color: var(--paper); background: rgba(255, 106, 92, 0.14); }
.small-note { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.health-row { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.bar.big { flex: 1; height: 12px; width: auto; }
#vetBar { --c: var(--health); }
.vet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.vet-actions button:disabled { opacity: 0.45; }
.speed-list { display: grid; gap: 6px; }
.speed-list button { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 48px; padding: 6px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--tint); text-align: left; font-weight: 700; touch-action: manipulation; }
.speed-list button small { color: var(--muted); font-weight: 600; }
.speed-list button[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.switch-row { display: flex; gap: 10px; align-items: center; font-weight: 600; line-height: 1.3; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.journal-list { display: grid; gap: 6px; }
.journal-list button { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--tint); text-align: left; touch-action: manipulation; }
.journal-list small { color: var(--muted); font-weight: 600; }
.journal-list b { font-size: 15.5px; }
.info-actions { flex-wrap: wrap; gap: 8px; }

/* Artikel */
.article-sheet { z-index: 12; }
.article-card { width: min(620px, 100%); gap: 10px; }
.art-pic { position: relative; height: 150px; border-radius: 16px; overflow: hidden; background: radial-gradient(120% 90% at 50% 30%, #7a5533, #3f2a1a); }
.art-pic canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.art-badge { position: absolute; left: 10px; top: 10px; padding: 3px 10px; border-radius: 10px; background: var(--paper); color: var(--paper-ink); font-weight: 800; font-size: 13px; }
.art-lead { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.45; max-width: 65ch; }
#artBody { display: grid; gap: 10px; }
#artBody h3 { margin: 0; font-size: 16.5px; color: var(--accent); }
#artBody p { margin: 2px 0 0; line-height: 1.5; max-width: 65ch; }
.tips { margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.tips li { padding: 8px 12px; border-radius: 12px; background: rgba(255, 210, 63, 0.12); line-height: 1.4; }

@media (orientation: landscape) { body.building .stats { visibility: hidden; } }

/* Anmeldung */
.login-sheet { z-index: 20; align-items: center; background: var(--room); }
.login-card { width: min(440px, 100%); text-align: center; justify-items: center; }
.login-buttons { display: grid; gap: 10px; width: 100%; }
.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 16px;
  border: 2px solid var(--line);
  font-size: 17px;
  font-weight: 800;
  touch-action: manipulation;
}
.login-btn svg { width: 22px; height: 22px; flex: none; }
.login-btn.google { background: var(--paper); color: var(--paper-ink); }
.login-btn.apple { background: #000; color: #fff; border-color: #000; }
#noAccess { display: grid; gap: 10px; }
#noAccess b { overflow-wrap: anywhere; }
.account-row { display: grid; gap: 8px; padding: 12px; border-radius: 14px; background: rgba(255, 240, 220, 0.05); }
.account-row b { overflow-wrap: anywhere; }
.adopt input[type="email"] { -webkit-user-select: text; user-select: text; }
.admin-entry { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--tint); }
.admin-entry .row { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-entry small { color: var(--muted); font-weight: 600; overflow-wrap: anywhere; }
.admin-entry button { min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.2); font-weight: 700; touch-action: manipulation; }

/* Schild „Vorschau“ auf der Netlify-Vorschau */
.preview-badge {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 1px 10px 2px;
  border-radius: 0 0 8px 8px;
  background: var(--sun);
  color: var(--paper-ink);
  font: 700 10px/1.3 system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
}

/* Zeitraffer-Knopf oben links über dem Terrarium */
.turbo {
  position: fixed;
  z-index: 5;
  top: var(--turbo-top, 110px);
  left: calc(env(safe-area-inset-left, 0px) + 12px);
  display: grid;
  place-items: center;
  width: 58px;
  height: 38px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 240, 220, 0.22);
  background: rgba(20, 12, 8, 0.28);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  touch-action: manipulation;
}
.turbo svg { width: 40px; height: 24px; }
.turbo path { fill: rgba(255, 248, 235, 0.7); }
.turbo[data-speed="2"] path,
.turbo[data-speed="3"] path { fill: rgba(255, 210, 63, 0.9); }
.turbo[data-speed="2"],
.turbo[data-speed="3"] { border-color: rgba(255, 210, 63, 0.55); box-shadow: 0 0 14px rgba(255, 210, 63, 0.35); }
.turbo:active { transform: scale(0.95); }

/* Leiste im Haus */
#roomBar .pill { white-space: nowrap; }
#roomBar .drawer-head strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (orientation: landscape) {
  #roomBar { grid-template-rows: auto minmax(0, 1fr); }
  #roomBar .drawer-head { flex-wrap: wrap; }
}
body.in-room #toolbar, body.in-room .turbo { display: none; }

/* Futter-Auswahl */
.food-pop canvas { width: 46px; height: 36px; flex: none; }
.food-pop button[disabled] { opacity: 0.45; }
.food-pop .count { margin-left: auto; padding-left: 10px; color: var(--muted); font-weight: 800; }
.food-pop .best { color: var(--sun); font-size: 12px; font-weight: 800; }
.food-pop .why { display: block; color: var(--muted); font-size: 11.5px; font-weight: 700; line-height: 1.2; }
.food-pop button[disabled] .why { color: #ffb38a; }
.food-pop .more { background: transparent; border: 1px dashed var(--line); }
.food-pop .more[aria-expanded="true"] { border-style: solid; }
.food-pop .more-ico { width: 46px; display: grid; place-items: center; flex: none; }
.food-pop .more .count { font-weight: 800; }
.item-tile.locked { opacity: 0.5; }

/* Zimmer und Zooladen */
body.in-screen #hud, body.in-screen #toolbar, body.in-screen .turbo, body.in-screen .power-banner, body.in-screen #hint, body.in-screen #toast { display: none; }
#scrBar { gap: 8px; }
.scr-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.scr-head strong { flex: 1; min-width: 0; font-family: var(--font-display); font-weight: 400; font-size: 20px; letter-spacing: 0.04em; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gold-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px 3px 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); font-weight: 800; font-size: 17px; }
.gold-chip svg, .scr-actions svg { width: 22px; height: 22px; vertical-align: -5px; }
.scr-speech { margin: 0; padding: 10px 12px; border-radius: 14px; background: var(--paper); color: var(--paper-ink); font-size: 15px; line-height: 1.35; max-height: 34vh; overflow-y: auto; }
.scr-speech b { display: block; font-size: 12.5px; letter-spacing: 0.06em; text-transform: uppercase; color: #9a4a12; }
.scr-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.scr-actions button { min-height: 42px; padding: 0 14px; border-radius: 21px; border: 1px solid var(--line); background: var(--tint); font-weight: 800; font-size: 15px; touch-action: manipulation; }
.scr-actions button.primary-pill { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.scr-basket { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13.5px; max-height: 21vh; overflow-y: auto; overscroll-behavior: contain; }
.scr-basket > span { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 11px; border-radius: 999px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); }
.scr-basket em { font-style: normal; font-weight: 700; margin-right: 2px; }
.scr-basket b { min-width: 1.3em; text-align: center; font-weight: 800; font-size: 15px; }
.scr-basket small { display: inline-flex; align-items: center; gap: 2px; margin-left: 2px; font-weight: 800; font-size: 13px; color: var(--muted); }
.scr-basket small svg { width: 15px; height: 15px; }
.scr-basket button { width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--tint); font-weight: 800; font-size: 17px; line-height: 1; padding: 0; touch-action: manipulation; }
.power-banner { position: fixed; z-index: 6; left: 16px; right: 16px; width: fit-content; max-width: calc(100vw - 32px); margin: 0 auto; text-align: center; top: calc(var(--turbo-top, 110px) + 4px); padding: 8px 16px; border-radius: 999px; border: 2px solid #2a1206; background: #ffd23f; color: #2a1206; font-weight: 800; font-size: 15px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); animation: powerPulse 1.2s ease-in-out infinite alternate; }
@keyframes powerPulse { from { transform: scale(1); } to { transform: scale(1.05); } }
@media (orientation: portrait) {
  #scrBar { max-height: 64vh; overflow-y: auto; overscroll-behavior: contain; }
}
@media (orientation: landscape) {
  #scrBar { grid-template-rows: auto auto auto auto minmax(0, 1fr); }
  .scr-speech { max-height: 40vh; }
}
@media (prefers-reduced-motion: reduce) { .power-banner { animation: none; } }

/* Umlaut-Punkte nicht abschneiden */
.scr-head strong, #roomBar .drawer-head strong, .chip-name { line-height: 1.4; padding-top: 3px; }

/* Spinnen-Menü (lange ins Bild drücken) */
.spider { position: fixed; inset: 0; z-index: 11; background: rgba(12, 7, 4, 0.52); touch-action: none; -webkit-user-select: none; user-select: none; animation: spiderFade 0.16s ease-out; }
.spider[hidden] { display: none; }
.spider-web { position: absolute; inset: 0; pointer-events: none; }
.spider-web svg { position: absolute; inset: 0; }
.spider-web .thread { stroke: rgba(255, 246, 230, 0.36); stroke-width: 1.3; fill: none; }
.spider-web .silk { stroke: rgba(255, 255, 255, 0.5); stroke-width: 1; }
.spider-web .spider-bug { animation: spiderBob 2.4s ease-in-out infinite alternate; transform-box: fill-box; }
.spider-bub { position: absolute; width: var(--b, 78px); height: var(--b, 78px); margin: calc(var(--b, 78px) / -2) 0 0 calc(var(--b, 78px) / -2); padding: 0; border: 0; background: none; color: var(--ink); touch-action: none; animation: spiderPop 0.24s cubic-bezier(0.3, 1.45, 0.6, 1) both; }
.spider-face { display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 35% 30%, #5a4232, #2a1f19 70%); border: 3px solid var(--accent); box-shadow: 0 8px 18px rgba(0, 0, 0, 0.55), inset 0 2px 0 rgba(255, 255, 255, 0.12); transition: transform 0.12s; }
.spider-face svg { width: 56%; height: 56%; }
.spider-face canvas { display: block; width: 100%; height: 100%; }
.spider-bub.food .spider-face canvas { width: 80%; height: auto; }
.spider-bub.pic .spider-face { background: #1b1411; }
.spider-bub.here .spider-face { border-color: var(--sun); box-shadow: 0 0 0 5px rgba(255, 210, 63, 0.35), 0 8px 18px rgba(0, 0, 0, 0.55); }
.spider-bub.off .spider-face { border-color: #6b5a4c; }
.spider-bub.off .spider-face > * { opacity: 0.6; filter: saturate(0.35); }
.spider-bub.hot .spider-face, .spider-bub:active .spider-face { transform: scale(1.12); border-color: var(--sun); }
.spider-bub.shake .spider-face { animation: spiderShake 0.3s; }
.spider-lab { position: absolute; left: 50%; top: calc(100% + 4px); transform: translateX(-50%); padding: 3px 11px 1px; border-radius: 999px; background: var(--paper); color: var(--paper-ink); font-weight: 800; font-size: 14px; line-height: 1.35; white-space: nowrap; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4); }
.spider-lab small { display: block; margin-top: -1px; font-size: 11px; line-height: 1.1; color: #9a4a12; text-align: center; }
.spider-bub.off .spider-lab { background: #cdbfae; }
.spider-badge { position: absolute; right: -6px; top: -6px; min-width: 28px; height: 26px; padding: 3px 7px 0; border-radius: 13px; border: 2px solid #2a1206; background: var(--sun); color: #2a1206; font-weight: 800; font-size: 14px; line-height: 1.2; text-align: center; pointer-events: none; }
.spider-tag { position: absolute; left: 50%; bottom: calc(100% + 1px); transform: translateX(-50%); padding: 2px 9px 0; border-radius: 999px; border: 2px solid #2a1206; background: var(--sun); color: #2a1206; font-style: normal; font-weight: 800; font-size: 11.5px; white-space: nowrap; pointer-events: none; }
.spider-mid { position: absolute; width: 56px; height: 56px; margin: -28px 0 0 -28px; padding: 3px 0 0; border-radius: 50%; border: 3px solid #2a1206; background: var(--paper); color: var(--paper-ink); font-weight: 800; font-size: 30px; line-height: 1; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5); touch-action: none; animation: spiderPop 0.18s ease-out both; }
.spider-hold { position: fixed; z-index: 11; width: 104px; height: 104px; margin: -52px 0 0 -52px; pointer-events: none; }
.spider-hold[hidden] { display: none; }
.spider-hold svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.spider-hold .bg { fill: rgba(255, 240, 220, 0.2); stroke: rgba(42, 18, 6, 0.45); stroke-width: 9; }
.spider-hold .fg { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 239; stroke-dashoffset: 239; }
.spider-hold.run .fg { animation: spiderHold 0.35s linear forwards; }
body.spider-open #toast { z-index: 13; top: calc(env(safe-area-inset-top, 0px) + 10px); bottom: auto; }
@keyframes spiderHold { to { stroke-dashoffset: 0; } }
@keyframes spiderPop { from { transform: translate(var(--dx, 0), var(--dy, 0)) scale(0.3); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes spiderFade { from { opacity: 0; } }
@keyframes spiderShake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes spiderBob { to { transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  .spider, .spider-bub, .spider-mid, .spider-web .spider-bug { animation: none; }
  .spider-hold.run .fg { animation-duration: 0.01s; }
}

/* Getippter Text mit Cursor */
.type-caret { display: inline-block; margin-left: 1px; opacity: 0.75; animation: typeCaret 0.9s steps(1) infinite; }
.type-rest { visibility: hidden; }
#scrSpeech { cursor: pointer; }
@keyframes typeCaret { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .type-caret { animation: none; } }

/* Betreiber: App-Zugang teilen */
.share-box { display: grid; gap: 8px; margin: 4px 0 14px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--tint); }
.share-box h3 { margin: 0; }
.share-url { display: block; font-family: var(--font-ui); padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); font-size: 14px; font-weight: 700; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.share-actions .primary { height: 48px; font-size: 19px; }
.share-actions a.secondary { display: inline-flex; align-items: center; color: inherit; text-decoration: none; }
.share-msg { color: var(--ok); font-weight: 700; }

/* Zimmer einrichten: Kacheln lassen sich wischen (waagrecht im Hochformat, senkrecht im Querformat) */
#scrList .item-tile { touch-action: pan-x pan-y; }
#scrTabs { margin-bottom: -2px; }

/* Querformat auf kleinen Handys: Statusbalken in eine eigene Zeile, sonst bleiben nur die Symbole */
@media (orientation: landscape) and (max-width: 760px) {
  #hud { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "chip actions" "stats stats"; gap: 4px 8px; }
  .chip { max-width: 100%; justify-self: start; }
  .stats { justify-content: flex-start; }
  .stat { flex: 0 1 112px; padding: 4px 8px 4px 5px; }
  .bar { flex: 1; width: auto; min-width: 24px; }
}
@media (orientation: landscape) {
  .power-banner { right: calc(var(--tb-w, 96px) + 16px); }
}
/* Querformat, niedrige Handys: Kategorien in einer Zeile zum Wischen, damit Platz für die Gegenstände bleibt */
@media (orientation: landscape) and (max-height: 460px) {
  .cat-tabs { flex-wrap: nowrap; overflow-x: auto; touch-action: pan-x; }
  .cat-tabs button { min-height: 30px; padding: 0 10px; }
}
/* Sehr schmale Handys: Werkzeug-Namen etwas kleiner, damit „Hochheben“ ganz passt */
@media (max-width: 380px) and (orientation: portrait) {
  .tool { font-size: 9.5px; letter-spacing: -0.03em; }
}
/* Zooladen im Querformat: Warenkorb-Zeilen nicht halb abschneiden, Leiste darf scrollen */
@media (orientation: landscape) {
  #scrBar { overflow-y: auto; overscroll-behavior: contain; }
  .scr-basket { min-height: min(78px, 24vh); }
}
/* Lange Titel lieber kleiner als abgeschnitten */
.scr-head strong { font-size: clamp(16px, 4.6vw, 20px); }
/* Kataloge mit dem Finger scrollen: Kacheln lassen das Wischen in Listenrichtung durch */
#itemList .item-tile { touch-action: pan-x; }
#roomList .item-tile { touch-action: pan-x pan-y; }
@media (orientation: landscape) {
  #itemList .item-tile { touch-action: pan-y; }
  body.in-room .stats { visibility: hidden; }
}
/* Hinweis oben in der Futter-Auswahl (z. B. „hat gerade keinen Hunger“) */
.food-pop .pop-note { margin: 0; padding: 4px 8px 2px; max-width: 250px; font-size: 13px; font-weight: 700; line-height: 1.3; color: var(--muted); }
/* Strom-Banner lässt den Zeitraffer-Knopf links frei */
.power-banner { left: calc(env(safe-area-inset-left, 0px) + 84px); }
/* Titel in der Seitenleiste: nach der Breite der Leiste, nicht des Bildschirms */
#scrBar { container-type: inline-size; }
.scr-head strong { font-size: clamp(13px, 6.2cqw, 20px); }
/* Bei offenem Fenster (Einstellungen …) erscheinen Meldungen oben, nicht über dem gerade getippten Schalter */
body:has(.sheet:not([hidden]):not(.article-sheet)) #toast { top: calc(env(safe-area-inset-top, 0px) + 10px); bottom: auto; }
