/* base.css — das Aussehen der App.
   Cartoon-Holz-Optik, passend zu den gemalten Bildern. */

/* Die Farben der App an EINER Stelle. Ein Bereich, der eine davon braucht,
   nimmt sie von hier und schreibt keinen eigenen Farbwert hin.
   ⚠️ shop.css traegt dieselben Werte noch einmal, weil es allein lauffaehig
   sein soll — steht als Aufgabe stil-farben-einmal in AUFGABEN.md. */
:root {
  --holz-rand:    #a9714b;
  --holz-dunkel:  #78482a;
  --schrift:      #5b3a1e;
  --schrift-matt: #8a705a;

  /* ⚠️ Gedaempfte Schrift, die noch LESBAR ist. Nachgerechnet gegen das
     Pergament: --schrift-matt kommt auf 4,49:1 und liegt damit knapp unter
     der Grenze von 4,5:1 — bei kurzen Beschriftungen faellt das nicht auf,
     bei ganzen Saetzen schon. Dieser Ton kommt auf 6,6:1.
     Fuer Fliesstext diesen nehmen, nicht --schrift-matt. */
  --schrift-lesbar: #6f5641;
  --pergament:    rgba(255, 252, 240, .96);
  --fokus:        #ffd54a;
  --gruen:        #4a9b3c;
  --gruen-tief:   #35722a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;              /* die Karte scrollt nicht */
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: #1b3b5a;
  color: #fff;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* position: relative ist wichtig — ohne das bezieht sich die Karte darunter
   nicht auf diesen Kasten, sondern auf die ganze Seite, und wird zu breit. */
#buehne { position: relative; width: 100%; height: 100%; overflow: hidden; }

/* -------------------------------------------------- Die Flaeche drumherum

   Auf einem breiten Bildschirm steht die App als hochformatiges Feld in der
   Mitte. Aussen bleibt Flaeche — bewusst ruhig und dunkel, damit das Auge
   beim Spielfeld bleibt und nichts mit der Insel um Aufmerksamkeit ringt.
   Auf einem Handy ist von alldem nichts zu sehen: dort fuellt das Feld den
   ganzen Bildschirm. */

.app-root {
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #24547f 0%, #16324c 62%, #0f2337 100%);
}

.field {
  position: absolute;
  inset: 0;
  margin: auto;                  /* zentriert in beiden Richtungen */
  overflow: hidden;
  /* Der Schatten setzt das Feld von der Flaeche ab, ohne einen Rahmen zu
     zeichnen — dieselbe Tiefe wie bei den Kacheln, nur weicher. */
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 18px 60px rgba(0, 0, 0, .55);
}

/* --------------------------------------------------- Der Startbildschirm

   Seit Etappe 18. Zwei Szenen im selben Feld wie die Karte: das Titelbild mit
   dem PLAY-Knopf, danach die Ladeszene mit Pumo und dem kreisenden Pudding.

   ⚠️ Groesse und Lage der Buehne rechnet start.js aus — genau wie bei der
   Karte, und aus demselben Grund: der PLAY-Knopf ist in das Bild EINGEMALT.
   Hier steht nur, wie es aussieht. */

.start-scene { position: absolute; inset: 0; overflow: hidden; }
.start-scene[hidden] { display: none; }

.start-stage { position: absolute; }

.start-stage-title {
  background-image: url('../bilder/start-background.jpg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

/* Das Titelbild faehrt beim Druecken heran und blendet aus.
   ⚠️ 540 ms — dieselbe Zahl steht als FADE_MS in start.js. */
.start-title .start-stage {
  transition: transform 540ms ease-in, opacity 340ms ease-in 200ms;
}
.start-title.leaves .start-stage { transform: scale(1.18); opacity: 0; }

/* ---- Der PLAY-Knopf

   Er liegt durchsichtig genau auf dem gemalten. Die Zahlen sind am Bild
   GEMESSEN, nicht geschaetzt: der gemalte Knopf liegt bei 25,5 bis 78,5
   Prozent der Breite und 75,0 bis 87,2 Prozent der Hoehe. */

.start-play {
  position: absolute;
  left: 25.5%;
  top: 75%;
  width: 53%;
  height: 12.2%;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 90ms ease-out;
}

.start-play:active { transform: scale(.96); }

.start-play:focus-visible {
  outline: 4px solid var(--fokus);
  outline-offset: 4px;
}

/* ⚠️ 260 ms — dieselbe Zahl steht als BOUNCE_MS in start.js. */
.start-play.bounces { animation: start-federn 260ms ease-out; }

@keyframes start-federn {
  0%   { transform: scale(1); }
  35%  { transform: scale(.90); }
  70%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ---- Die Ladeszene */

.start-stage-load {
  background-image: radial-gradient(circle at 50% 42%,
                    #cdefff 0%, #8fd6f5 55%, #5fb9e8 100%);
}

.start-pumo {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 42%;
  transform: translate(-50%, -50%);
  animation: start-schweben 1.6s ease-in-out infinite;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .25));
}

@keyframes start-schweben {
  0%, 100% { transform: translate(-50%, -50%) translateY(-1.5%) rotate(-3deg); }
  50%      { transform: translate(-50%, -50%) translateY(1.5%)  rotate(3deg); }
}

/* Drei Puddings auf drei Kreisbahnen um Pumo.
   ⚠️ JEDE BAHN BRAUCHT EINE ECHTE GROESSE. In einem Kasten ohne Groesse ist
   jedes Prozent darin null — dann liegen alle drei genau AUF Pumo. */
.start-orbit {
  position: absolute;
  left: 50%;
  top: 42%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
}

.start-orbit-turn {
  position: absolute;
  inset: 0;
  animation: start-kreisen 3.6s linear infinite;
}

.start-orbit img {
  position: absolute;
  left: 50%;
  top: 0;
  width: 26%;
  transform: translate(-50%, -50%);
}

.start-orbit.orbit-1 { width: 74%; }
.start-orbit.orbit-2 { width: 88%; }
.start-orbit.orbit-3 { width: 62%; }

/* Jeder startet an einer anderen Stelle des Kreises und braucht eine andere
   Zeit — sonst sieht es aus wie ein starres Windrad. */
.start-orbit.orbit-2 .start-orbit-turn {
  animation-duration: 5.2s;
  animation-direction: reverse;
  rotate: 130deg;
}
.start-orbit.orbit-3 .start-orbit-turn {
  animation-duration: 2.9s;
  rotate: 245deg;
}

@keyframes start-kreisen { to { transform: rotate(360deg); } }

.start-line {
  position: absolute;
  left: 10%;
  width: 80%;
  top: 76%;
  text-align: center;
  color: #fff;
  font-weight: 800;
  line-height: 1.25;
  /* ⚠️ Die Schrift haengt an der BUEHNE, nicht am Fenster — start.js rechnet
     sie aus. Mit einem vh-Wert war sie auf dem schmalen Handy 41 Punkte
     gross, brach um und stand halb ausserhalb. */
  font-size: var(--start-schrift, 20px);
  text-shadow: 0 2px 8px rgba(0, 0, 0, .45);
}

.start-dots { display: inline-block; width: 1.6em; text-align: left; }

@media (prefers-reduced-motion: reduce) {
  .start-play, .start-title .start-stage { transition: none; }
  .start-play.bounces, .start-pumo, .start-orbit-turn { animation: none; }
}

/* ---------------------------------------------------------------- Die Karte

   Die Buehne hat das Seitenverhaeltnis des Hintergrundbilds und wird wie ein
   Foto formatfuellend skaliert. Die Kacheln sitzen in Prozent DIESER Flaeche —
   dadurch treffen sie auf jedem Geraet dieselbe Insel. */

.map {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #7cc6ef;           /* Himmelblau, falls das Bild noch laedt */
}

.map[hidden] { display: none; }

/* Die Buehne: Groesse und Lage rechnet map.js aus, damit Bild und Kacheln
   nicht auseinanderlaufen. Hier steht nur, wie sie aussieht. */
.stage-image {
  position: absolute;
  background-image: url('../bilder/map-background.jpg');
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

/* ------------------------------------------- Der Einzug nach dem Startbild

   Seit Etappe 18. Die Insel kommt herangefahren, dann ploppen die Schilder
   nacheinander auf, zuletzt kommt die Kopfzeile.

   ⚠️ ALLES HIER HAENGT AN .map.intro UND NUR DARAN. Ohne diese Klasse ist
   jede Kachel von Anfang an da und die Kopfzeile steht. Das ist Absicht: Wenn
   ein Geraet diese Bewegungen nicht ausfuehrt, soll die Karte trotzdem
   vollstaendig dastehen — nicht unsichtbar bleiben. Eine Kachel, die auf eine
   Bewegung wartet, die nie kommt, waere ein Bereich, den niemand mehr
   aufmachen kann. */

.map.intro .stage-image {
  transform: scale(1.35);
  transition: transform 760ms cubic-bezier(.22, .7, .28, 1);
}

.map.intro.arrived .stage-image { transform: scale(1); }

.map.intro.builds .tile {
  animation: start-plopp 420ms cubic-bezier(.2, 1.5, .4, 1) backwards;
  animation-delay: calc(var(--nr, 0) * 90ms);
}

@keyframes start-plopp {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.3); }
  70%  { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.map.intro .topbar { opacity: 0; transition: opacity 320ms ease-out; }
.map.intro.built .topbar { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .map.intro .stage-image { transform: none; transition: none; }
  .map.intro.builds .tile { animation: none; }
  .map.intro .topbar { opacity: 1; transition: none; }
}

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

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  z-index: 10;
}

.balance {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 4px 18px 4px 6px;
  border-radius: 999px;
  background: rgba(255, 252, 240, .94);
  border: 3px solid #a9714b;
  box-shadow: 0 3px 0 rgba(120, 72, 40, .45), 0 6px 14px rgba(0, 0, 0, .28);
}

.balance-image { height: 38px; width: auto; display: block; }

.balance-value {
  font-size: 22px;
  font-weight: 900;
  color: #5b3a1e;
  font-variant-numeric: tabular-nums;   /* die Zahl huepft beim Zaehlen nicht */
  letter-spacing: .01em;
}

.topbar .round-button:first-of-type { margin-left: auto; }

.round-button {
  width: 52px; height: 52px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: transform 160ms ease-out;
}

.round-button img { width: 100%; height: 100%; display: block; }

/* ---------------------------------------------------------------- Die Kacheln */

.tile {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  line-height: 0;
  transition: transform 160ms ease-out;
}

.tile-image {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35));
}

/* Das Namensschild ist unten in die gemalte Kachel eingebaut —
   der Text wird daraufgelegt. */
.tile-sign {
  position: absolute;
  left: 8%;                                 /* so weit reicht das gemalte Schild */
  right: 8%;
  bottom: 7.5%;                             /* 18.09.2026: von 3.5% hoeher gesetzt */
  line-height: 1.05;
  font-size: var(--sign-schrift, 13px);   /* map.js rechnet sie aus */
  font-weight: 900;
  letter-spacing: .01em;
  color: #8a5a2b;                           /* heller als das alte #5b3a1e */
  text-shadow: 0 1px 0 rgba(255, 248, 225, .75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------ Verschlossene Bereiche

   Sichtbar, aber erkennbar zu — und nicht nur an der Farbe: es liegt ein
   Schloss darauf und der Text sagt es. */

/* Gedaempft, aber nicht duester — es soll neugierig machen, nicht kaputt
   aussehen. Den Ausschlag gibt ohnehin das Schloss, nicht die Farbe. */
.tile.locked .tile-image {
  filter: grayscale(.62) brightness(.88) drop-shadow(0 6px 10px rgba(0, 0, 0, .35));
}

.tile.locked .tile-sign { color: #8d7a63; }   /* mit aufgehellt, 18.09.2026 */

.tile-lock {
  position: absolute;
  top: 34%;
  left: 50%;
  width: 34%;
  height: auto;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .45));
}

/* ------------------------------------------------------------- Rueckmeldung */

.tile:active, .round-button:active { transform: translate(-50%, -50%) scale(.94); }
.round-button:active { transform: scale(.92); }

.tile:focus-visible, .round-button:focus-visible {
  outline: 4px solid #ffd54a;
  outline-offset: 3px;
  border-radius: 12px;
}

/* Tippen auf einen verschlossenen Bereich: er wackelt, oeffnet aber nicht. */
.tile.wiggles { animation: wackeln 380ms ease-out; }

@keyframes wackeln {
  0%, 100% { transform: translate(-50%, -50%) rotate(0); }
  25%      { transform: translate(-50%, -50%) rotate(-4deg); }
  75%      { transform: translate(-50%, -50%) rotate(4deg); }
}

@media (prefers-reduced-motion: reduce) {
  .tile, .round-button { transition: none; }
  .tile.wiggles { animation: none; }
}

/* ------------------------------------------------- Ein geoeffneter Bereich */

.area { position: absolute; inset: 0; }
.area[hidden] { display: none; }

/* ------------------------------------------------------------- Das Konto

   Der Anmeldeschirm liegt ueber der Karte und haengt am Zahnradknopf —
   keine siebte Kachel, dafuer ist auf der Insel kein Platz
   (karte-kein-scroll).

   ⚠️ Er steht bewusst HIER in base.css und nicht in einer eigenen Datei.
   Der Shop hat sich genau daran gestossen: sein eigenes Stylesheet lud
   base.css nicht mit, hatte deshalb kein box-sizing, und auf dem Tablet
   lief die Seite seitlich ueber. Der Schirm laeuft nur in dieser einen
   Seite — also gehoert er in deren Stylesheet. */

.account-screen {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
  background: rgba(27, 59, 90, .72);
  overflow-y: auto;                 /* langes Formular auf kleinem Geraet */
  -webkit-overflow-scrolling: touch;
}

.account-sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: auto;
  padding: 26px 22px 22px;
  border-radius: 20px;
  border: 4px solid var(--holz-rand);
  background: var(--pergament);
  box-shadow: 0 6px 0 rgba(120, 72, 40, .4), 0 16px 34px rgba(0, 0, 0, .4);
  color: var(--schrift);
}

.account-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 44px; height: 44px;        /* nie kleiner — alles Antippbare ist 44 */
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--schrift-lesbar);
  cursor: pointer;
}

.account-close svg { width: 22px; height: 22px; }

.account-page { display: flex; flex-direction: column; gap: 14px; }

.account-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 44px 0 0;               /* Platz fuer das Kreuz */
  font-size: 21px;
  font-weight: 900;
  line-height: 1.2;
  color: var(--schrift);
}

.account-title-icon { width: 26px; height: 26px; flex: none; color: var(--holz-dunkel); }

.account-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--schrift-lesbar);
}

.account-name {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
  line-height: 1.2;
  color: var(--gruen-tief);
  overflow-wrap: anywhere;          /* ein langer Name sprengt nichts */
}

.account-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px dashed var(--holz-rand);
  font-size: 15px;
  line-height: 1.4;
  color: var(--schrift);
}

.account-form { display: flex; flex-direction: column; gap: 12px; margin: 0; }

.account-field { display: flex; flex-direction: column; gap: 5px; }

.account-field-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--schrift-lesbar);
}

.account-field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 3px solid var(--holz-rand);
  background: #fffdf6;
  color: var(--schrift);
  /* ⚠️ Mindestens 16px. Darunter zoomt Safari auf dem iPhone beim
     Hineintippen in das Feld — und danach steht die Karte schief. */
  font: inherit;
  font-size: 17px;
  user-select: text;
  -webkit-user-select: text;
}

.account-field input:focus-visible,
.account-button:focus-visible,
.account-close:focus-visible {
  outline: 4px solid var(--fokus);
  outline-offset: 2px;
}

.account-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  font-size: 15px;
  line-height: 1.4;
  cursor: pointer;
}

.account-check input {
  width: 26px; height: 26px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--gruen);
}

.account-details { font-size: 14px; color: var(--schrift-lesbar); }
.account-details summary { cursor: pointer; padding: 6px 0; min-height: 32px; }
.account-details p { margin: 4px 0 0; line-height: 1.45; }

/* Die Meldung nimmt keinen Platz weg, solange nichts zu sagen ist —
   sonst huepft der Knopf beim ersten Fehler nach unten. */
.account-message { display: none; margin: 0; }

.account-message.visible {
  display: block;
  padding: 9px 12px;
  border-radius: 10px;
  background: #ffe9e4;
  border: 2px solid #c8553d;
  color: #8a2f1c;
  font-size: 15px;
  line-height: 1.4;
}

.account-buttons { display: flex; flex-direction: column; gap: 10px; }

.account-button {
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: 14px;
  font: inherit;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease-out;
}

/* ⚠️ --gruen-tief statt --gruen (medien-gruen-ist-zu-hell). Weiss auf
   --gruen kommt auf 3,47:1, verlangt sind fuer Schrift dieser Groesse
   4,5:1; auf --gruen-tief sind es 5,85:1. */
.account-button.main {
  border: 3px solid #23501c;
  background: var(--gruen-tief);
  color: #fff;
  box-shadow: 0 4px 0 #23501c;
}

.account-button.side {
  border: 3px solid var(--holz-rand);
  background: transparent;
  color: var(--schrift);
}

.account-button:active { transform: translateY(2px); }

/* Aus heisst aus — und das nicht nur an der Farbe, sondern auch daran,
   dass der Knopf nicht mehr nachgibt. */
.account-button[disabled] { opacity: .55; cursor: default; }
.account-button[disabled]:active { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .account-button { transition: none; }
}
