/* spielstdumit — Gestaltung nach 00_Marke/Markenrichtlinie.md (Farben S. 26, Typografie S. 13–16).
   Die Palette führt weder Rot noch Grün. Schrift auf Amber und Coral ist immer dunkel.
   Spielbretter liegen auf Steady Blue: Coral und Amber erreichen dort 5,3 : 1 und 9 : 1. */

@font-face {
  font-family: 'Baloo 2';
  src: url('schriften/Baloo2-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('schriften/DMSans-Medium.ttf') format('truetype');
  font-weight: 500;
  font-display: swap;
}

:root {
  --blau: #211e42;
  --blau-2: #4d4b68;
  --blau-3: #908ea0;
  --blau-4: #e9e8ec;
  --lavendel: #a981ca;
  --lavendel-2: #e5d9ef;
  --lavendel-3: #f6f2fa;
  --amber: #ffb60d;
  --amber-2: #ffe9b6;
  --amber-3: #fff8e7;
  --koralle: #ff614f;
  --koralle-2: #ffd0ca;
  --koralle-3: #ffefed;
  --biscuit: #f7f7f2;
  --biscuit-2: #f2efe8;
  --weiss: #ffffff;

  --spieler-0: var(--koralle);
  --spieler-1: var(--amber);

  --f-kopf: 'Baloo 2', 'Trebuchet MS', sans-serif;
  --f-text: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--biscuit);
  color: var(--blau);
  font-family: var(--f-text);
  font-weight: 500;
  font-size: 18px;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--blau); outline-offset: 3px; }
h1, h2 { font-family: var(--f-kopf); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(28px, 5vw, 40px); }
h2 { font-size: 21px; }
p { margin: 0; }
small { font-size: .75em; color: var(--blau-2); }
.nur-vorlesen { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Rahmen --- */

.kopf {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
}
.marke {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--blau);
  font-family: var(--f-kopf); font-weight: 600; font-size: 26px; line-height: 1;
}
.marke img { width: 34px; height: 34px; }
.profil-knopf {
  display: flex; align-items: center; gap: 6px; max-width: 55vw;
  background: var(--weiss); border: 2px solid var(--blau-4); border-radius: 999px;
  padding: 6px 14px 6px 10px; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.profil-knopf.ruhig { border-color: transparent; background: none; }

main {
  flex: 1; width: 100%; max-width: 1200px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
}
.seite { width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; }
.seite.schmal { max-width: 560px; }
.unterzeile { font-size: 20px; color: var(--blau-2); margin-top: -6px; }

.fuss {
  margin-top: auto; padding-top: 28px; display: flex; flex-wrap: wrap; gap: 6px 18px;
  align-items: center; justify-content: center; font-size: 15px; color: var(--blau-2);
}
.fuss img { height: 20px; width: auto; vertical-align: -4px; margin-left: 4px; }

/* --- Knöpfe --- */

.haupt {
  background: var(--amber); color: var(--blau); border: 0; border-radius: 999px;
  padding: 12px 30px; min-height: 56px; font-family: var(--f-kopf); font-weight: 600; font-size: 22px;
  box-shadow: 0 3px 0 rgba(33, 30, 66, .22);
}
.haupt:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(33, 30, 66, .22); }
.knopf {
  background: var(--weiss); border: 2px solid var(--blau-4); border-radius: 999px;
  padding: 10px 22px; min-height: 52px; font-size: 18px;
}
.knopf:disabled { color: var(--blau-3); }
.leise { background: none; border: 0; color: var(--blau-2); text-decoration: underline; text-underline-offset: 3px; padding: 10px 12px; min-height: 44px; font-size: 17px; }
.knoepfe { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* --- Profil --- */

.beschriftung { font-family: var(--f-kopf); font-weight: 600; font-size: 21px; margin: 6px 0 -6px; }
.feld-name {
  width: min(100%, 360px); padding: 12px 16px; font-size: 26px; text-align: center;
  background: var(--weiss); border: 2px solid var(--blau-3); border-radius: 16px;
}
.leise-text { color: var(--blau-2); font-size: 16px; margin-top: -8px; }
.tiere { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; width: min(100%, 520px); }
.tier-knopf {
  aspect-ratio: 1; font-size: clamp(28px, 7vw, 40px); line-height: 1; padding: 0;
  background: var(--weiss); border: 3px solid var(--blau-4); border-radius: 18px;
}
.tier-knopf[aria-pressed="true"] { border-color: var(--blau); background: var(--amber-3); }
.fehler { min-height: 1.45em; color: var(--blau); font-size: 17px; }
.fehler:not(:empty) { background: var(--koralle-3); border: 2px solid var(--koralle-2); border-radius: 12px; padding: 6px 14px; }

/* --- Start --- */

.wahl { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; width: min(100%, 720px); margin-top: 8px; }
.kachel {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--weiss); border: 2px solid var(--blau-4); border-radius: 26px; padding: 26px 20px;
}
.kachel svg { width: 84px; height: 84px; }
.kachel b { font-family: var(--f-kopf); font-weight: 600; font-size: 28px; line-height: 1.1; }
.kachel span { color: var(--blau-2); font-size: 17px; }
.kachel:active, .spielkarte:active { transform: translateY(2px); }

/* --- Code --- */

.code-gross {
  font-family: var(--f-kopf); font-weight: 600; font-size: clamp(56px, 13vw, 96px); line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: .04em;
  background: var(--weiss); border: 3px dashed var(--lavendel); border-radius: 26px; padding: 8px 30px 2px;
}
.link-feld { width: min(100%, 460px); padding: 10px 14px; border: 2px solid var(--blau-4); border-radius: 12px; background: var(--weiss); font-size: 16px; text-align: center; }
.code-felder { display: flex; gap: 8px; }
.code-felder span {
  width: clamp(40px, 12vw, 56px); height: clamp(54px, 16vw, 72px); display: grid; place-items: center;
  background: var(--weiss); border: 2px solid var(--blau-4); border-radius: 14px;
  font-family: var(--f-kopf); font-weight: 600; font-size: clamp(30px, 9vw, 42px);
}
.code-felder span.aktuell { border-color: var(--blau); border-width: 3px; }
.ziffern { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: min(100%, 330px); }
.ziffern button {
  height: 66px; border-radius: 18px; background: var(--weiss); border: 2px solid var(--blau-4);
  font-family: var(--f-kopf); font-weight: 600; font-size: 30px;
}
.ziffern button:active { background: var(--amber-3); }

.warte { color: var(--blau-2); display: flex; align-items: center; gap: 10px; }
.punkte { display: inline-flex; gap: 5px; }
.punkte i { width: 9px; height: 9px; border-radius: 50%; background: var(--lavendel); animation: huepfen 1.2s infinite ease-in-out; }
.punkte i:nth-child(2) { animation-delay: .15s; }
.punkte i:nth-child(3) { animation-delay: .3s; }
@keyframes huepfen { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(-7px); } }
.tier-gross { font-size: 76px; line-height: 1; }

/* --- Dialoge und Meldungen --- */

.schleier { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(33, 30, 66, .45); }
.dialog {
  width: min(100%, 460px); max-height: calc(100vh - 32px); overflow: auto;
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
  background: var(--biscuit); border-radius: 26px; padding: 26px; box-shadow: 0 20px 60px rgba(33, 30, 66, .3);
}
.dialog.breit { width: min(100%, 620px); text-align: left; align-items: stretch; }
.eltern { margin: 0; }
.eltern dt { font-family: var(--f-kopf); font-weight: 600; font-size: 19px; margin-top: 12px; }
.eltern dd { margin: 2px 0 0; color: var(--blau-2); font-size: 16px; }
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); background: var(--blau); color: var(--weiss); border-radius: 14px; padding: 12px 20px; font-size: 17px;
}
.banner { width: 100%; text-align: center; background: var(--koralle-2); border-radius: 12px; padding: 8px 14px; margin-bottom: 10px; }
.hinweis { background: var(--amber-3); border: 2px solid var(--amber-2); border-radius: 14px; padding: 8px 16px; margin-bottom: 10px; text-align: center; }

/* --- Raum --- */

.raumleiste { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-bottom: 12px; }
.chip {
  display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 42%;
  background: var(--weiss); border: 3px solid var(--blau-4); border-radius: 999px; padding: 4px 6px 4px 8px;
  transition: border-color .2s, box-shadow .2s;
}
.chip .tier { font-size: 30px; line-height: 1; }
.chip .name { font-family: var(--f-kopf); font-weight: 600; font-size: 19px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chip .name small { font-family: var(--f-text); font-weight: 500; }
.marke-rund { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--blau); padding: 5px; display: grid; }
.chip.dran { border-color: var(--blau); box-shadow: 0 0 0 4px var(--amber-2); }
.chip.weg { opacity: .55; }
.stand { font-family: var(--f-kopf); font-weight: 600; font-size: 26px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.spielfuss { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 16px; margin-top: 18px; }
.fuss-knoepfe { display: flex; gap: 4px; }
.reaktionen { display: flex; gap: 2px; background: var(--weiss); border: 2px solid var(--blau-4); border-radius: 999px; padding: 3px 6px; }
.reaktionen button { width: 46px; height: 46px; border: 0; background: none; border-radius: 50%; font-size: 26px; line-height: 1; padding: 0; }
.reaktionen button:active { background: var(--amber-3); transform: scale(.9); }
.blase { position: fixed; z-index: 50; font-size: 56px; line-height: 1; pointer-events: none; animation: aufsteigen 2.4s ease-out forwards; }
@keyframes aufsteigen {
  0% { transform: translate(-50%, 0) scale(.4); opacity: 0; }
  15% { transform: translate(-50%, -24px) scale(1.15); opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translate(-50%, -120px) scale(1); opacity: 0; }
}

.spielkarten { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; width: min(100%, 860px); }
.spielkarte {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--weiss); border: 2px solid var(--blau-4); border-radius: 26px; padding: 22px 16px;
}
.spielkarte svg { width: 96px; height: 96px; }
.spielkarte b { font-family: var(--f-kopf); font-weight: 600; font-size: 24px; line-height: 1.1; margin-top: 4px; }
.spielkarte span { color: var(--blau-2); font-size: 16px; }

.status { font-family: var(--f-kopf); font-weight: 600; font-size: clamp(21px, 3.4vw, 28px); line-height: 1.2; min-height: 1.2em; }
.ende { display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--amber-3); border: 2px solid var(--amber-2); border-radius: 22px; padding: 14px 24px; }
.ende-text { font-family: var(--f-kopf); font-weight: 600; font-size: clamp(26px, 4vw, 34px); line-height: 1.15; }

/* --- Zeichen: Kreuz für Spieler 0, Kreis für Spieler 1 --- */

.zeichen { width: 100%; height: 100%; fill: none; stroke-width: 15; stroke-linecap: round; }
.zeichen-0 { stroke: var(--spieler-0); }
.zeichen-1 { stroke: var(--spieler-1); }

/* --- Tic Tac Toe --- */

.ttt {
  display: grid; grid-template: repeat(3, minmax(0, 1fr)) / repeat(3, minmax(0, 1fr)); gap: 10px; padding: 10px;
  width: min(100%, calc(100vh - 330px), 470px); min-width: 240px; aspect-ratio: 1;
  background: var(--blau); border-radius: 26px;
}
.ttt-feld { background: var(--blau-2); border: 0; border-radius: 16px; padding: 14%; display: grid; min-height: 0; }
.ttt-feld .zeichen { min-height: 0; }
.ttt-feld:not(:disabled):hover { box-shadow: inset 0 0 0 4px var(--amber); }
.ttt-feld:focus-visible { outline-color: var(--amber); outline-offset: -6px; }
.ttt-feld.gewinn { box-shadow: inset 0 0 0 5px var(--lavendel); animation: pulsen 1s ease-in-out 3; }
.neu .zeichen, .ttt-feld.neu .zeichen { animation: auftauchen .25s ease-out; }
@keyframes auftauchen { from { transform: scale(.3); opacity: 0; } }
@keyframes pulsen { 50% { transform: scale(.93); } }

/* --- Vier gewinnt --- */

.vg {
  display: flex; gap: 5px; padding: 10px;
  width: min(100%, calc((100vh - 320px) * 1.14), 620px); min-width: 280px;
  background: var(--blau); border-radius: 22px;
}
.vg-spalte { flex: 1; display: flex; flex-direction: column; gap: 5px; background: none; border: 0; padding: 3px; border-radius: 14px; }
.vg-spalte:not(:disabled):hover { background: rgba(255, 255, 255, .14); }
.vg-spalte:focus-visible { outline-color: var(--amber); outline-offset: 0; }
.vg-loch { aspect-ratio: 1; border-radius: 50%; background: var(--biscuit); display: grid; }
.stein { border-radius: 50%; display: grid; place-items: center; }
.stein-0 { background: var(--koralle); }
.stein-1 { background: var(--amber); }
.stein .zeichen { width: 56%; height: 56%; stroke: var(--blau); stroke-width: 12; opacity: .45; }
.stein.gewinn { box-shadow: 0 0 0 4px var(--lavendel); animation: pulsen 1s ease-in-out 3; }
.stein.faellt { animation: fallen calc(70ms * var(--fall) + 140ms) cubic-bezier(.45, 0, 1, 1); }
@keyframes fallen { from { transform: translateY(calc(var(--fall) * -112%)); } }

/* --- Schiffe versenken --- */

.sv-regel { color: var(--blau-2); font-size: 16px; max-width: 520px; }
.sv-brett {
  display: grid; grid-template-columns: .55fr repeat(8, 1fr); gap: 3px; padding: 8px;
  background: var(--blau); border-radius: 18px; font-size: 13px;
}
.sv-marke { color: var(--blau-3); display: grid; place-items: center; line-height: 1; padding: 2px 0; }
.sv-zelle { aspect-ratio: 1; border: 0; padding: 0; border-radius: 6px; background: var(--blau-2); display: grid; place-items: center; position: relative; }
button.sv-zelle:not(:disabled):hover { box-shadow: inset 0 0 0 3px var(--amber); }
button.sv-zelle:focus-visible { outline-color: var(--amber); outline-offset: -3px; }
.sv-zelle.schiff { background: var(--lavendel); border-radius: 3px; }
.sv-zelle.schiff.quer.kopf { border-radius: 40% 3px 3px 40%; }
.sv-zelle.schiff.quer.heck { border-radius: 3px 40% 40% 3px; }
.sv-zelle.schiff.hoch.kopf { border-radius: 40% 40% 3px 3px; }
.sv-zelle.schiff.hoch.heck { border-radius: 3px 3px 40% 40%; }
.sv-zelle.gewaehlt { background: var(--amber); }
.sv-zelle.wasser::after, .sv-zelle.sicher::after { content: ''; width: 26%; aspect-ratio: 1; border-radius: 50%; background: var(--blau-3); }
.sv-zelle.sicher { background: transparent; }
.sv-zelle.sicher::after { width: 14%; background: var(--blau-2); }
.sv-zelle.treffer { background: var(--koralle); }
.sv-zelle.versenkt { background-image: repeating-linear-gradient(45deg, transparent 0 5px, rgba(33, 30, 66, .28) 5px 8px); }
.sv-zelle.aufgedeckt { background: transparent; box-shadow: inset 0 0 0 3px var(--lavendel); }
.sv-zelle.neu { animation: pulsen .5s ease-in-out 2; }
.sv-kreuz { width: 70%; height: 70%; fill: none; stroke: var(--blau); stroke-width: 14; stroke-linecap: round; }

.sv-setzen { width: min(100%, calc(100vh - 380px), 500px); min-width: 280px; }
.hinweis-klein { min-height: 1.45em; font-size: 17px; }

.sv-schlacht { display: grid; gap: 20px; justify-items: center; width: 100%; }
.sv-ziel, .sv-eigen { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sv-ziel-brett { width: min(94vw, calc(100vh - 470px), 560px); min-width: 290px; }
.sv-eigen-brett { width: min(66vw, 300px); min-width: 220px; font-size: 11px; gap: 2px; padding: 6px; }
.sv-eigen.allein .sv-eigen-brett, .sv-eigen.allein .sv-setzen { width: min(100%, calc(100vh - 360px), 460px); }
.sv-schlacht.ich-dran .sv-ziel-brett { box-shadow: 0 0 0 5px var(--amber-2); }
.sv-flotte { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sv-mini { display: inline-flex; gap: 2px; position: relative; }
.sv-mini i { width: 14px; height: 14px; border-radius: 3px; background: var(--lavendel); }
.sv-mini.weg i { background: var(--blau-4); }
.sv-mini.weg::after { content: ''; position: absolute; left: -3px; right: -3px; top: 50%; height: 2px; background: var(--blau); transform: rotate(-12deg); }

/* Ab Tablet-Breite liegen beide Meere nebeneinander, im Hoch- wie im Querformat. */
@media (min-width: 700px) {
  .sv-schlacht { grid-template-columns: auto auto; align-items: start; justify-content: center; gap: 24px; }
  .sv-ziel-brett { width: min(56vw, calc(100vh - 330px), 580px); min-width: 0; }
  .sv-eigen-brett { width: min(34vw, calc(100vh - 420px), 360px); min-width: 0; }
}

@media (max-width: 520px) {
  body { font-size: 17px; }
  .chip .tier { font-size: 24px; }
  .chip .name { font-size: 16px; }
  .stand { font-size: 21px; }
  .reaktionen button { width: 40px; height: 40px; font-size: 22px; }
}

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