/* ==========================================================================
   Monsterranch — Oberfläche

   Richtung: Spiel-HUD, nicht Formular. Harte Kanten, feste Schatten ohne
   Weichzeichner, kräftige Flächen. Das passt zu den Pixelgrafiken —
   weiche Schatten und dünne Haarlinien würden dagegen arbeiten.

   Farben und Maße stehen als Variablen ganz oben. Wer umfärben will,
   fasst nur diesen Block an.
   ========================================================================== */

:root {
  /* Der Untergrund ist bewusst deutlich dunkler als die Karten.
     Ohne diesen Abstand verschwimmt alles zu einer Flaeche. */
  --ground:   #BDCEB6;
  --card:     #FFFFFF;
  --card-2:   #ECF3E9;
  --sunk:     #D3E0CD;

  --edge:     #7B9375;   /* Schattenkante unter Karten */
  --line:     #8FA88A;   /* sichtbarer Umriss, kein Haarstrich */

  --ink:      #0F1E17;
  --ink-2:    #3E5247;
  --ink-3:    #6E8477;

  --accent:   #0F6E4E;
  --accent-2: #C6E6D6;
  --warm:     #B5501F;
  --warm-2:   #F2DACB;

  --ok:       #2F8C53;
  --low:      #B8850F;
  --crit:     #B33F2A;

  --sky:      #F3F7EE;
  --field:    #C3D9BA;

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;

  --topbar-h: 60px;
  --nav-h: 66px;
  --shell-w: 472px;

  --font: "Fredoka", "Segoe UI", system-ui, sans-serif;
}

[data-theme="dark"] {
  --ground:   #070C09;
  --card:     #18231C;
  --card-2:   #223026;
  --sunk:     #0D150F;

  --edge:     #000000;
  --line:     #3D5245;

  --ink:      #E6EEE6;
  --ink-2:    #A6B9AB;
  --ink-3:    #728878;

  --accent:   #56D2A3;
  --accent-2: #10402D;
  --warm:     #EC9269;
  --warm-2:   #38220F;

  --ok:       #4FC97D;
  --low:      #DDAC3B;
  --crit:     #E9735A;

  --sky:      #202E26;
  --field:    #14201A;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #070C09; --card: #18231C; --card-2: #223026; --sunk: #0D150F;
    --edge: #000000; --line: #3D5245;
    --ink: #E6EEE6; --ink-2: #A6B9AB; --ink-3: #728878;
    --accent: #56D2A3; --accent-2: #10402D; --warm: #EC9269; --warm-2: #38220F;
    --ok: #4FC97D; --low: #DDAC3B; --crit: #E9735A;
    --sky: #202E26; --field: #14201A;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button { font-family: inherit; cursor: pointer; }
.ic { flex: none; vertical-align: -2px; }
.sprite { image-rendering: pixelated; display: block; flex: none; }

/* Der wiederkehrende Griff: 2px Rand plus feste Kante darunter. */
.raise {
  border: 2px solid var(--line);
  box-shadow: 0 3px 0 0 var(--edge);
}

/* --------------------------------------------------------------------------
   Rahmen
   -------------------------------------------------------------------------- */

.app {
  position: relative;
  height: 100%;
  max-width: var(--shell-w);
  margin-inline: auto;
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr var(--nav-h);
  background: var(--ground);
}

.topbar, .stage, .nav { min-width: 0; }

@media (min-width: 540px) {
  body { display: grid; place-items: center; padding: 26px; }
  .app {
    height: min(900px, calc(100vh - 52px));
    border: 2px solid var(--line);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 6px 0 0 var(--edge);
  }
}

/* --------------------------------------------------------------------------
   Kopfzeile
   -------------------------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 0 10px 0 14px;
  background: var(--card);
  border-bottom: 2px solid var(--line);
  overflow: hidden;
}

.brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; }

.brand-mark {
  width: 18px; height: 22px; flex: none;
  background: var(--accent);
  border-radius: 50% 50% 46% 46% / 60% 60% 40% 40%;
  box-shadow: 0 2px 0 0 var(--edge);
}

.brand-name {
  font-size: 17px; font-weight: 600;
  letter-spacing: -0.02em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 359px) { .brand-name { display: none; } }

.wallet { display: flex; align-items: center; gap: 5px; flex: none; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--card-2);
  color: var(--ink-2);
  font-size: 12.5px; white-space: nowrap;
}
.pill .ic { color: var(--ink-3); }
.pill-val { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.icon-btn {
  border: 2px solid var(--line); background: var(--card-2);
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  transition: background 130ms ease;
}
.icon-btn:hover { background: var(--accent-2); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon-moon {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--ink-2);
  box-shadow: inset -4px -1px 0 0 var(--card-2);
  transition: all 200ms ease;
}
[data-theme="dark"] .icon-moon {
  width: 9px; height: 9px;
  box-shadow: 0 0 0 2px var(--card-2), 0 0 0 3.5px var(--ink-2);
}

/* --------------------------------------------------------------------------
   Bühne
   -------------------------------------------------------------------------- */

.stage { overflow-y: auto; overflow-x: hidden; padding: 16px 14px 28px; }

.screen { animation: rise 240ms cubic-bezier(.2,.7,.3,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.screen-head { margin-bottom: 15px; }
.screen-eyebrow {
  display: block; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent);
}
.screen-title {
  font-size: 30px; font-weight: 600;
  letter-spacing: -0.035em; line-height: 1.05; margin: 2px 0 0;
}

.muted-line { color: var(--ink-3); font-size: 13px; margin: 2px 0; }

.panel {
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: 0 3px 0 0 var(--edge);
  border-radius: var(--r-md);
  padding: 12px 13px 13px;
  margin-bottom: 14px;
}

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 11px;
  padding-bottom: 9px; border-bottom: 2px solid var(--card-2);
}
.panel-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--ink-3);
}
.panel-extra { font-size: 12.5px; font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.mini {
  border: 2px solid var(--line); background: var(--card-2);
  color: var(--ink-2); font-size: 11.5px; font-weight: 500;
  padding: 3px 11px; border-radius: 999px;
  transition: all 120ms ease;
}
.mini:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-2); }
.mini:active { transform: translateY(1px); }

.empty {
  display: grid; place-items: center; gap: 12px;
  min-height: 210px; padding: 30px; text-align: center;
  background: var(--card); border: 2px dashed var(--line); border-radius: var(--r-lg);
}
.empty-mark { width: 40px; height: 40px; border-radius: var(--r-sm); background: var(--sunk); }
.empty-text { color: var(--ink-3); font-size: 13.5px; max-width: 26ch; margin: 0; }

/* Balken — flach, mit Rand, damit sie zum HUD passen */
.bar {
  height: 8px; border-radius: 99px;
  background: var(--sunk);
  border: 1.5px solid var(--line);
  overflow: hidden;
}
.bar span { display: block; height: 100%; background: var(--ok); transition: width 130ms linear; }
.bar[data-tone="low"]  span { background: var(--low); }
.bar[data-tone="crit"] span { background: var(--crit); }
.bar.xp span { background: var(--accent); }
.bar.bag span { background: var(--warm); }

.chip {
  display: inline-block; padding: 1px 7px; border-radius: 5px;
  font-size: 10.5px; font-weight: 600; color: #fff;
  background: var(--c, var(--accent)); margin-right: 3px;
}

/* --------------------------------------------------------------------------
   Kampf — die Arena ist der Held des Bildschirms
   -------------------------------------------------------------------------- */

.route-bar { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.wave { font-size: 13.5px; font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.route-mix { display: flex; flex-wrap: wrap; gap: 9px; }
.mix { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-3); }
.mix i { width: 8px; height: 8px; border-radius: 2px; border: 1px solid rgba(0,0,0,.15); }

.arena {
  position: relative;
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: end; gap: 6px;
  padding: 22px 12px 16px;
  margin-bottom: 14px;
  border-radius: var(--r-lg);
  border: 2px solid var(--line);
  box-shadow: 0 3px 0 0 var(--edge);
  background: var(--sky);
  overflow: hidden;
}

/* Boden mit sichtbarem Horizont */
.arena::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: 104px; background: var(--field);
  border-top: 2px solid var(--line);
}

.fighter { position: relative; text-align: center; min-width: 0; }
.fighter.is-down { opacity: .3; }

.fighter-art { display: grid; place-items: end center; height: 88px; }
.fighter-art .sprite { width: 80px; height: 80px; animation: bob 2.8s ease-in-out infinite; }
.fighter.foe .fighter-art .sprite { animation-name: bobFoe; animation-delay: -1.4s; }
@keyframes bob    { 0%,100% { transform: translateY(0); }            50% { transform: translateY(-6px); } }
@keyframes bobFoe { 0%,100% { transform: scaleX(-1) translateY(0); } 50% { transform: scaleX(-1) translateY(-6px); } }

.fighter.is-new .fighter-art .sprite { animation: drop 340ms cubic-bezier(.2,.8,.3,1); }
@keyframes drop { from { transform: translateY(-18px) scale(.8); opacity: 0; } }

/* Standfläche in der Typfarbe */
.plate {
  width: 66px; height: 10px; margin: 2px auto 9px;
  border-radius: 50%;
  background: var(--type, var(--accent));
  opacity: .3;
}

.fighter-name {
  font-size: 15px; font-weight: 600; letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fighter-lvl { font-size: 11px; font-weight: 500; color: var(--ink-3); margin-bottom: 8px; }
.fighter .bar { background: var(--sunk); }

.arena-mid { display: grid; place-items: center; padding-bottom: 40px; }
.arena-vs {
  font-size: 10px; font-weight: 600; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink-3);
}

/* Aufsteigende Schadenszahlen */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.fx-num {
  position: absolute; top: 50px;
  font-size: 17px; font-weight: 600;
  color: var(--ink);
  -webkit-text-stroke: 3px var(--sky);
  paint-order: stroke fill;
  animation: float 900ms ease-out forwards;
  font-variant-numeric: tabular-nums;
}
.fx-num.good { color: var(--ok); }
.fx-num.crit { color: var(--warm); font-size: 21px; }
.fx-num.weak { color: var(--ink-3); font-size: 14px; }
.fx-num.hurt { color: var(--crit); }
.fx-num.heal { color: var(--ok); }
@keyframes float {
  from { opacity: 0; transform: translateY(8px) scale(.8); }
  25%  { opacity: 1; transform: translateY(-2px) scale(1); }
  to   { opacity: 0; transform: translateY(-38px); }
}

/* Buffs */
.buffs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.buffs:empty { display: none; }
.buff {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px;
  border: 2px solid var(--accent);
  background: var(--accent-2); color: var(--accent);
  font-size: 11.5px; font-weight: 600;
}
.buff em { font-style: normal; opacity: .75; font-variant-numeric: tabular-nums; }

/* Teamplätze */
.slots { display: flex; flex-direction: column; gap: 7px; }
.slot {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 34px 1fr 80px;
  align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--card-2);
  border: 2px solid transparent;
}
.slot { border-color: var(--line); }
/* Farbstreifen in der Typfarbe der Kreatur — die einzige Stelle,
   an der die Oberflaeche bunt wird, und genau deshalb wirkt sie. */
.slot::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 5px; background: var(--type, var(--line));
}
.slot.is-front { box-shadow: inset 0 0 0 2px var(--accent-2); }
.slot.is-down { opacity: .4; }
.slot .sprite { width: 34px; height: 34px; }
.slot-info { min-width: 0; }
.slot-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-meta { font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.slot-bars { display: flex; flex-direction: column; gap: 4px; }
.slot .bar { height: 6px; background: var(--card); }

/* Futter */
.food-row { display: flex; flex-wrap: wrap; gap: 7px; }
.food {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px 6px 9px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--card-2);
  color: var(--ink-2); font-size: 12px;
  transition: all 120ms ease;
}
.food i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.food-name { font-weight: 500; color: var(--ink); }
.food-meta { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.food:hover { border-color: var(--accent); }
.food:active { transform: translateY(1px); }
.food.is-on { border-color: var(--accent); background: var(--accent-2); }
.food.is-on .food-name, .food.is-on .food-meta { color: var(--accent); }

/* Protokoll */
.log { display: flex; flex-direction: column; gap: 3px; }
.log-line {
  font-size: 12px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.log-line.good { color: var(--ok); }
.log-line.bad  { color: var(--crit); }
.log-line.evo  { color: var(--warm); font-weight: 600; }
.log-line.info { color: var(--ink-2); }

/* --------------------------------------------------------------------------
   Fertigkeiten
   -------------------------------------------------------------------------- */

.skill-panel { padding-top: 13px; }

.skill-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.skill-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  border: 2px solid var(--accent);
  background: var(--accent-2); color: var(--accent); flex: none;
}
.skill-name { font-size: 18px; font-weight: 600; letter-spacing: -0.025em; }
.skill-lvl { margin-left: auto; font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.skill-lvl b { font-size: 17px; font-weight: 600; color: var(--ink); }

.skill-xp { margin-bottom: 13px; }

.actions { display: flex; flex-direction: column; gap: 7px; }

.action {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 10px 1fr auto;
  align-items: center; gap: 11px; text-align: left; width: 100%;
  padding: 10px 12px 13px; border-radius: var(--r-sm);
  border: 2px solid var(--line); background: var(--card-2);
  color: var(--ink);
  transition: border-color 120ms ease, background 120ms ease, transform 100ms ease;
}
.action:hover:not(:disabled) { border-color: var(--accent); }
.action:active:not(:disabled) { transform: translateY(1px); }
.action:disabled { cursor: default; opacity: .4; }

.action-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.action-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.action-name { font-size: 14px; font-weight: 500; }
.action-sub { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.action-needs { display: flex; flex-wrap: wrap; gap: 8px; font-size: 10.5px; color: var(--ink-3); margin-top: 3px; }
.action-needs .is-short { color: var(--crit); }
.action-have { font-size: 13px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.action-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 4px; background: var(--sunk);
}
.action-bar i { display: block; height: 100%; width: 0; background: var(--c); }

.action.is-running { border-color: var(--accent); background: var(--accent-2); }
.action.is-running .action-name { color: var(--accent); }
.action.is-running .action-bar i { transition: width 110ms linear; }

/* --------------------------------------------------------------------------
   Listen, Dex, Karte
   -------------------------------------------------------------------------- */

.rows { display: flex; flex-direction: column; gap: 6px; }
.row {
  display: grid; grid-template-columns: 34px 1fr auto;
  align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm); background: var(--card-2);
}
.row .sprite { width: 34px; height: 34px; }
.row .dot { width: 14px; height: 14px; border-radius: 50%; margin: 0 10px; border: 2px solid rgba(0,0,0,.12); }
.row-main { min-width: 0; }
.row-name { font-size: 14px; font-weight: 500; }
.row-sub { font-size: 10.5px; color: var(--ink-3); }
.row-count { font-size: 12.5px; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.dex-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
  gap: 7px; margin-top: 12px;
}
.dex-cell {
  display: grid; place-items: center; gap: 5px;
  padding: 10px 4px; border-radius: var(--r-sm);
  background: var(--card-2); border: 2px solid transparent;
}
.dex-cell:not(.is-unknown) { border-color: var(--line); }
.dex-cell .sprite { width: 40px; height: 40px; }
.dex-cell.is-unknown { opacity: .4; }
.dex-blank { width: 40px; height: 40px; border-radius: var(--r-xs); background: var(--sunk); }
.dex-name { font-size: 10.5px; font-weight: 500; color: var(--ink-2); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.route-list { display: flex; flex-direction: column; gap: 11px; }
.route-card {
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: 0 3px 0 0 var(--edge);
  border-radius: var(--r-md); padding: 13px 14px;
  cursor: pointer;
  transition: border-color 120ms ease, transform 100ms ease, box-shadow 100ms ease;
}
.route-card:hover { border-color: var(--accent); }
.route-card:active { transform: translateY(3px); box-shadow: 0 0 0 0 var(--edge); }
.route-card.is-active { border-color: var(--accent); background: var(--accent-2); }
.route-card.is-locked { cursor: default; opacity: .4; box-shadow: none; }
.route-card.is-locked:hover { border-color: var(--line); }
.route-card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.route-card-name { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.route-card-mix { display: flex; gap: 4px; }
.route-card-mix i { width: 9px; height: 9px; border-radius: 2px; border: 1px solid rgba(0,0,0,.15); }
.route-card-sub { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }

/* --------------------------------------------------------------------------
   Navigation und Einblendung
   -------------------------------------------------------------------------- */

.nav {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  gap: 2px; padding: 7px 6px;
  background: var(--card);
  border-top: 2px solid var(--line);
  padding-bottom: calc(7px + env(safe-area-inset-bottom));
}

.nav-tab {
  border: 0; background: none; color: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 5px 2px; border-radius: var(--r-sm);
  transition: color 130ms ease, background 130ms ease;
}
.nav-tab:hover { color: var(--ink-2); }
.nav-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-tab[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-2);
}
.nav-tab .ic { transition: transform 180ms cubic-bezier(.2,.8,.3,1); }
.nav-tab[aria-current="page"] .ic { transform: translateY(-1px) scale(1.1); }
.nav-label { font-size: 10.5px; font-weight: 500; }

.toast {
  position: absolute; left: 50%; bottom: calc(var(--nav-h) + 14px);
  transform: translate(-50%, 8px);
  padding: 9px 17px; border-radius: 999px;
  border: 2px solid var(--edge);
  background: var(--ink); color: var(--ground);
  font-size: 12.5px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 20;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
