/* Shrimp oder Mensch? – ein festes Meeres-Design (kein Hell/Dunkel-Umschalter). Handy zuerst. */
:root {
  --sea-top: #14507f;
  --sea: #0d3b66;
  --deep: #071a30;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.18);
  --text: #f1f8ff;
  --muted: #a9c6dd;
  --shrimp: #ff8f73;
  --shrimp-deep: #c9482b;
  --human: #ffd166;
  --human-deep: #b07a00;
  --danger: #ff5d5d;
  --good: #6ee7a8;
  --focus: #ffffff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--deep);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
}

/* Meer als feststehende Ebene hinter allem (background-attachment: fixed ruckelt auf iOS) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, var(--sea-top) 0%, var(--sea) 30%, var(--deep) 100%);
}

#app {
  max-width: 32rem;
  margin: 0 auto;
  padding: 0.5rem 0.75rem calc(1.5rem + env(safe-area-inset-bottom));
}

.boot { text-align: center; font-size: 3rem; margin-top: 30vh; }

h1, h2, h3, p { margin: 0; }

button, input { font: inherit; color: inherit; }

button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.grow { flex: 1; }

/* ------------------------------------------------------------------ Kopfzeile, Knoepfe */

.top {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 2.75rem;
}

.ghost {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.35rem 0.7rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
}
.ghost:hover { color: var(--text); background: var(--panel); }

.primary {
  min-height: 2.9rem;
  padding: 0.5rem 1.3rem;
  background: var(--human);
  border: 0;
  border-radius: 999px;
  color: #2a1d00;
  font-weight: 700;
}
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.primary:disabled { opacity: 0.5; }

/* ------------------------------------------------------------------ Menue */

.menu { display: grid; gap: 0.9rem; }

.hero { text-align: center; padding: 0.5rem 0 0.25rem; }
.hero-art { font-size: 3.2rem; line-height: 1.1; }
.hero-art span { font-size: 1.9rem; margin: 0 0.15rem; }
.hero h1 { font-size: 1.9rem; margin-top: 0.3rem; }
.hero p { color: var(--muted); }

.panel {
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
}
.panel h2 { font-size: 1.05rem; margin-bottom: 0.7rem; }

.choices { display: grid; gap: 0.5rem; }
.choices.three { grid-template-columns: repeat(3, 1fr); }
.choices.two { grid-template-columns: repeat(2, 1fr); }

.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 4.6rem;
  padding: 0.6rem 0.4rem;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  text-align: center;
}
.choice:hover:not(:disabled) { border-color: var(--human); }
.choice:disabled { opacity: 0.5; }
.choice strong { font-size: 1.02rem; }
.choice small { color: var(--muted); font-size: 0.78rem; line-height: 1.25; }
.choice .stats { color: var(--human); }

.join { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.join input {
  flex: 1;
  min-width: 0;
  min-height: 2.9rem;
  padding: 0 0.9rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-weight: 700;
}
.join input::placeholder { letter-spacing: normal; font-weight: 400; text-transform: none; color: var(--muted); }

.error { margin-top: 0.6rem; color: #ffb3b3; }

.rules, .tips { margin: 0; padding-left: 1.3rem; display: grid; gap: 0.5rem; }
.rules li::marker { color: var(--human); font-weight: 700; }

.foot { margin-top: 1.25rem; text-align: center; font-size: 0.9rem; color: var(--muted); }
.foot a { color: var(--muted); }

.lobby { display: grid; gap: 0.8rem; justify-items: center; text-align: center; }
.lobby h2 { margin: 0; }
.code {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: 0.3em;
  margin-right: -0.3em;
  color: var(--human);
}
.invite { display: flex; gap: 0.5rem; width: 100%; }
.invite input {
  flex: 1; min-width: 0; min-height: 2.9rem; padding: 0 0.9rem;
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
}
.note { color: var(--muted); }
.waiting { animation: pulse 1.6s ease-in-out infinite; }

/* ------------------------------------------------------------------ Partie */

.game { display: grid; gap: 0.7rem; }

.round-line { display: flex; align-items: center; gap: 0.5rem; }
.round .last { color: var(--human); font-weight: 700; }
.order { display: inline-flex; align-items: center; gap: 0.25rem; }
.order .chip {
  display: inline-grid; place-items: center;
  width: 1.9rem; height: 1.9rem;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--panel);
  filter: saturate(0.6);
}
.order .chip.now { border-color: var(--human); filter: none; background: var(--panel-strong); }
.order .chip.done { opacity: 0.4; }
.order .arrow { color: var(--muted); }

.day {
  position: relative;
  height: 0.5rem;
  margin: 0.6rem 0.7rem 0.2rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #7fd0ff, #ffe08a 55%, #ff9a5a 80%, #5b4b9a);
}
.day .sun {
  position: absolute;
  top: 50%;
  left: calc(var(--p) * 100%);
  transform: translate(-50%, -50%);
  font-size: 1.25rem;
  transition: left 0.5s ease;
}

.alarm {
  padding: 0.55rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
}
.alarm.hot { border-color: var(--danger); background: rgba(255, 93, 93, 0.16); }
.slots { display: flex; align-items: center; gap: 0.4rem; }
.alarm-name { font-weight: 700; margin-right: 0.3rem; }
.slot {
  display: inline-grid; place-items: center;
  width: 2rem; height: 2rem;
  border-radius: 50%;
  border: 2px dashed var(--line);
  filter: grayscale(1);
  opacity: 0.45;
}
.slot.on { filter: none; opacity: 1; border: 2px solid var(--human); background: rgba(255, 209, 102, 0.2); }
.slot.harpoon { border-style: solid; }
.alarm.hot .slot.harpoon { filter: none; opacity: 1; border-color: var(--danger); animation: pulse 1s ease-in-out infinite; }
.alarm-text { margin-top: 0.3rem; font-size: 0.9rem; color: var(--muted); }
.alarm.hot .alarm-text { color: #ffd0d0; }

.monsters {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 0.4rem;
}
.vs { align-self: center; font-size: 1.6rem; font-weight: 800; color: var(--muted); }

.monster {
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 0.1rem;
  min-height: 9.5rem;
  padding: 0.5rem 0.4rem 0.6rem;
  background: var(--panel);
  border: 2px solid transparent;
  border-radius: 1rem;
}
.monster.active { border-color: var(--human); background: var(--panel-strong); }
.monster.winner { border-color: var(--good); }
.who { font-weight: 700; font-size: 0.95rem; color: var(--muted); }
.monster.active .who { color: var(--human); }
.body {
  /* waechst mit der Groesse des Monsters */
  font-size: calc(2rem + var(--size) * 0.07rem);
  line-height: 1.15;
  transition: font-size 0.4s ease;
}
.size { display: flex; align-items: center; gap: 0.35rem; min-height: 2.2rem; }
.size .num { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.target { font-size: 1rem; opacity: 0.55; }
.target.hot { opacity: 1; animation: pulse 0.9s ease-in-out infinite; }
.eaten { font-size: 0.8rem; color: var(--muted); }

.delta { font-weight: 800; font-size: 1.05rem; animation: rise 1.6s ease-out both; }
.delta.plus { color: var(--good); }
.delta.minus { color: var(--danger); }

.monster.ate .body { animation: chomp 0.5s ease; }
.monster.hit { animation: shake 0.5s ease; border-color: var(--danger); }
.monster.hit .num { color: var(--danger); }

.feed {
  min-height: 3.1rem;
  padding: 0.5rem 0.8rem;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 0.8rem;
  font-size: 0.92rem;
  color: var(--muted);
}
.feed .new { color: var(--text); }
.feed .boom { color: #ffc2c2; }

.notice {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  text-align: center;
  color: var(--human);
}

.turn { text-align: center; color: var(--muted); min-height: 1.4rem; }
.turn.mine { color: var(--text); font-weight: 700; }

.offer { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-height: 11rem;
  padding: 0.7rem 0.4rem 0.8rem;
  border: 0;
  border-radius: 1.1rem;
  color: #26120b;
  box-shadow: 0 0.3rem 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.2s ease;
}
.card.shrimp { background: linear-gradient(180deg, #ffb39f, var(--shrimp)); box-shadow: 0 0.3rem 0 var(--shrimp-deep); }
.card.human { background: linear-gradient(180deg, #ffe39a, var(--human)); color: #2a1d00; box-shadow: 0 0.3rem 0 var(--human-deep); }
.card:hover:not(:disabled) { transform: translateY(-2px); }
.card:active:not(:disabled) { transform: translateY(0.25rem); box-shadow: 0 0.05rem 0 rgba(0, 0, 0, 0.3); }
.card:disabled { opacity: 0.55; }

.food { display: grid; place-items: center; min-height: 3.6rem; font-size: 2.8rem; line-height: 1; }
.food.n2 { font-size: 2.2rem; }
.food.n3 { font-size: 1.75rem; }
.card .name { font-weight: 700; }
.card .gain { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.card .bell { font-size: 1rem; }
.pre { font-size: 0.82rem; line-height: 1.25; }
.pre.then { font-weight: 700; }
.pre.boom { font-weight: 700; color: #8f0f0f; }
.pre.chance { margin-top: 0.15rem; padding: 0.05rem 0.5rem; border-radius: 999px; background: rgba(0, 0, 0, 0.14); }
.pre.chance.best { background: rgba(0, 0, 0, 0.75); color: #fff; }

.hint {
  display: flex; align-items: center; justify-content: center; gap: 0.3rem;
  min-height: 2.5rem; color: var(--muted); font-size: 0.92rem;
}
.hint input { width: 1.15rem; height: 1.15rem; accent-color: var(--human); }

.end {
  display: grid;
  justify-items: center;
  gap: 0.3rem;
  padding: 1.1rem 1rem 1.2rem;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 1rem;
  text-align: center;
}
.end.won { border-color: var(--good); }
.end-art { font-size: 3rem; line-height: 1; animation: chomp 0.6s ease; }
.end h2 { font-size: 1.6rem; }
.score { font-size: 1.3rem; font-weight: 800; color: var(--human); }
.end-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.6rem; margin-top: 0.5rem; }
.end-actions .note { flex-basis: 100%; }

.log { color: var(--muted); font-size: 0.9rem; }
.log summary { min-height: 2.4rem; padding: 0.5rem 0.2rem; cursor: pointer; }
.log ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
.log li { display: flex; gap: 0.45rem; padding: 0.3rem 0.5rem; background: rgba(0, 0, 0, 0.18); border-radius: 0.5rem; }
.log .r { min-width: 1.4rem; font-variant-numeric: tabular-nums; }
.log .what { flex: 1; }
.log .after { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.log li.boom .what { color: #ffc2c2; }

/* ------------------------------------------------------------------ Regeln-Fenster, Hinweis */

.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  padding: 1rem;
  background: rgba(3, 12, 24, 0.75);
}
.dialog {
  display: flex; flex-direction: column; gap: 0.9rem;
  width: 100%; max-width: 30rem; max-height: 90vh; max-height: 90dvh;
  padding: 1.2rem;
  background: #10385f;
  border: 1px solid var(--line);
  border-radius: 1rem;
}
/* Nur der Text scrollt, der Schliessen-Knopf bleibt darunter sichtbar */
.dialog-body { display: grid; gap: 0.8rem; overflow: auto; min-height: 0; }
.dialog h2 { font-size: 1.3rem; }
.dialog h3 { font-size: 1rem; color: var(--human); }
.dialog .primary { align-self: center; flex: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 20;
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  padding: 0.6rem 1rem;
  background: #06121f;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-align: center;
}

/* ------------------------------------------------------------------ Bewegung */

@keyframes pulse { 50% { opacity: 0.45; } }
@keyframes chomp { 30% { transform: scale(1.25) rotate(-6deg); } 60% { transform: scale(0.95) rotate(4deg); } }
@keyframes shake {
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
@keyframes rise { 0% { opacity: 0; transform: translateY(0.5rem); } 20% { opacity: 1; transform: none; } 100% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 22rem) {
  .choices.three { grid-template-columns: 1fr; }
  .card { min-height: 10rem; }
}
