/*
 * Gestaltung der Warteseite und der Donkey-Games.
 *
 * Bewusst eine einzige Datei ohne Baukasten und ohne Schriftart aus dem Netz:
 * Die Seite erscheint, wenn gerade etwas nicht läuft. Sie soll in dem Moment
 * nichts nachladen müssen, was auch fehlen könnte.
 *
 * Die Farben und Maße sind dieselben wie auf geodonkey.com – dort stehen sie
 * als CSS-Variablen in `geodonkey-frontend/src/index.css`, hier noch einmal
 * als feste Werte. Eine Kopie, die auseinanderlaufen kann, ist der Preis
 * dafür, dass diese Seite ohne das Frontend auskommt; genau derselbe Handel
 * wie bei den Farben der Kartenstile im Eselsprung.
 *
 * Eine Ausnahme ist die Schrift: Die Website lädt Inter von Google, diese
 * Seite darf das nicht. Sie nimmt die Schrift des Systems – dieselbe, die
 * auch auf geodonkey.com einspringt, solange Inter noch nicht da ist.
 */

:root {
  /* Flächen und Schrift – hell wie der Rest der Website. */
  --bg: #ffffff;
  --fg: #020817;
  --muted-bg: #f1f5f9;
  --muted-fg: #64748b;
  --border: #e2e8f0;

  /* Die beiden Logofarben. */
  --brand: #002060;
  --brand-deep: #00133b;
  --green: #40e060;
  --green-deep: #2fc94d;

  --amber: #f59e0b;
  /* Fehlertexte stehen nur in der Einblendung über dem dunklen Feld – dort
     braucht Rot mehr Helligkeit als auf weißem Grund. */
  --red: #fca5a5;

  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  /* Beim Wischen über das Spielfeld soll die Seite nicht mitrutschen. */
  overscroll-behavior-y: contain;
}

/* Derselbe zurückhaltende Schimmer wie auf der Website – zwei Farbkreise,
   die man eher spürt als sieht. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 80% -10%, rgba(64, 224, 96, 0.05) 0%, transparent 42%),
    radial-gradient(ellipse at 20% 110%, rgba(0, 32, 96, 0.04) 0%, transparent 42%);
}

.page {
  flex: 1 0 auto;
  margin: 0 auto;
  max-width: 46rem;
  padding: 2rem 1rem 3rem;
  width: 100%;
}

.muted {
  color: var(--muted-fg);
}

.small {
  font-size: 0.8125rem;
}

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

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

::selection {
  background-color: rgba(0, 32, 96, 0.2);
}

/* --------------------------------------------------------------- Kopf --- */
/* Eine klebende Leiste mit Trennlinie, wie der Kopf der Website. */
.head {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.head__inner {
  align-items: center;
  display: flex;
  gap: 0.875rem;
  margin: 0 auto;
  max-width: 46rem;
  padding: 0.75rem 1rem;
  width: 100%;
}

.head__logo {
  width: 3rem;
  height: auto;
  flex: none;
}

.head__text {
  flex: 1 1 auto;
  min-width: 0;
}

.head h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 0;
}

.head p {
  font-size: 0.875rem;
  margin: 0.0625rem 0 0;
}

.head__lang select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9999px;
  color: var(--fg);
  cursor: pointer;
  font: inherit;
  font-size: 0.8125rem;
  padding: 0.35rem 0.625rem;
}

.head__lang select:hover {
  background: var(--muted-bg);
}

/* -------------------------------------------------------------- Karten --- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  padding: 1.125rem;
}

.card__title {
  color: var(--muted-fg);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  margin: 0 0 0.75rem;
  text-transform: uppercase;
}

/* -------------------------------------------------------------- Status --- */
.status {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.status__dot {
  border-radius: 50%;
  flex: none;
  height: 0.75rem;
  width: 0.75rem;
}

.status__text {
  flex: 1 1 14rem;
  margin: 0;
  font-size: 0.9375rem;
}

.status[data-state='checking'] .status__dot {
  background: var(--muted-fg);
  animation: pulse 1.4s ease-in-out infinite;
}

.status[data-state='down'] .status__dot {
  background: var(--amber);
  animation: pulse 1.4s ease-in-out infinite;
}

.status[data-state='up'] .status__dot,
.status[data-state='arcade'] .status__dot {
  background: var(--green-deep);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* ------------------------------------------------------------- Knöpfe --- */
/* Der Hauptknopf trägt das Dunkelblau des Logos, so wie auf der Website.
   Das Grün bleibt der Akzent und wird nicht zur Fläche. */
.button {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  cursor: pointer;
  display: inline-block;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.button:hover {
  background: var(--muted-bg);
}

.button--brand {
  background: var(--brand);
  border-color: var(--brand);
  color: #f8fafc;
  font-weight: 600;
}

.button--brand:hover {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
}

/* -------------------------------------------------------------- Spiel --- */
.game__hud {
  display: flex;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  font-weight: 600;
  gap: 0.375rem 1rem;
  justify-content: space-between;
  margin-bottom: 0.625rem;
}

.game__stage {
  position: relative;
}

/*
 * Das Spielfeld ist das eine dunkle Feld auf einer hellen Seite – und das
 * soll es auch sein. Es ist kein Abschnitt der Seite, sondern ein Bild, und
 * die Landschaften des Eselsprungs leben davon, dass sie die Farbe wechseln
 * dürfen. Ein Rahmen und ein Schatten setzen es ab, statt es zu verstecken.
 */
#board {
  background: var(--brand-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  display: block;
  /* Quadratisch und immer so breit wie die Karte – auf dem Telefon ebenso
     wie am Schreibtisch. */
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  touch-action: none;
}

.overlay {
  align-items: center;
  background: rgba(0, 19, 59, 0.9);
  border-radius: var(--radius-lg);
  color: #f8fafc;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 1rem;
  position: absolute;
}

.overlay[hidden] {
  display: none;
}

/* Die Einblendung liegt über dem dunklen Feld, nicht über der Seite –
   dort gilt deshalb weiter die helle Schrift. */
.overlay .muted {
  color: #b9c7de;
}

.overlay .button {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  color: #f8fafc;
}

.overlay .button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.overlay .button--brand {
  background: var(--green);
  border-color: var(--green-deep);
  color: var(--brand-deep);
}

.overlay .button--brand:hover {
  background: var(--green-deep);
}

.overlay :focus-visible {
  outline-color: var(--green);
}

.overlay__box {
  max-width: 22rem;
  text-align: center;
  width: 100%;
}

.overlay__box h2 {
  font-size: 1.125rem;
  margin: 0 0 0.5rem;
}

.overlay__box p {
  font-size: 0.875rem;
  margin: 0 0 0.875rem;
}

/* Zwei gleichwertige Antworten stehen nebeneinander und rutschen auf
   schmalen Geräten untereinander – nicht nebeneinander und dann halb aus
   dem Bild. Steht nur ein Knopf da, sieht man von der Leiste nichts. */
.overlay__acts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.overlay__acts .button {
  flex: 1 1 10rem;
}

.score {
  color: var(--green);
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.nick {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
}

.nick__label {
  font-size: 0.875rem;
  text-align: left;
}

.nick input {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--radius);
  color: #f8fafc;
  font: inherit;
  padding: 0.5rem 0.625rem;
  width: 100%;
}

.nick__note {
  font-size: 0.75rem;
  margin: 0;
  text-align: left;
}

.nick__problem {
  color: var(--red);
  font-size: 0.8125rem;
  margin: 0;
  text-align: left;
}

/* ------------------------------------------------------------ Spielwahl --- */
.choose__list {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  margin-bottom: 0.625rem;
}

.choose__item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font: inherit;
  gap: 0.15rem;
  padding: 0.625rem 0.75rem;
  text-align: left;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.choose__item:hover {
  background: var(--muted-bg);
}

/* Das gewählte Spiel steht im Dunkelblau des Logos – dieselbe Art, wie die
   Website einen aktiven Punkt hervorhebt. */
.choose__item[aria-pressed='true'] {
  background: var(--brand);
  border-color: var(--brand);
  color: #f8fafc;
}

.choose__item[aria-pressed='true'] .choose__desc {
  color: #b9c7de;
}

.choose__name {
  font-weight: 600;
}

.choose__desc {
  color: var(--muted-fg);
  font-size: 0.8125rem;
  line-height: 1.4;
}

/* ---------------------------------------------------------- Steuerkreuz --- */
.pad {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.875rem 0 0.5rem;
}

.pad__cross {
  display: grid;
  gap: 0.375rem;
  grid-template-areas:
    '. up .'
    'left down right';
  justify-content: center;
}

/* Laufen und Springen: zwei Richtungen links, der Sprung rechts unter dem
   Daumen. Ein Steuerkreuz wäre hier falsch – nach unten gibt es nichts. */
.pad__run {
  display: grid;
  gap: 0.375rem;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  width: 100%;
  max-width: 22rem;
}

.pad__key--jump {
  width: 100%;
}

.pad__acts {
  display: flex;
  gap: 0.5rem;
}

.pad__acts .button {
  touch-action: manipulation;
}

.pad__key {
  background: var(--muted-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 1.25rem;
  height: 3.25rem;
  width: 3.75rem;
  touch-action: manipulation;
  cursor: pointer;
}

.pad__key:active {
  background: var(--brand);
  border-color: var(--brand);
  color: #f8fafc;
}

.pad__key--up {
  grid-area: up;
}
.pad__key--left {
  grid-area: left;
}
.pad__key--down {
  grid-area: down;
}
.pad__key--right {
  grid-area: right;
}

/* Am Schreibtisch tut die Tastatur den Dienst; das Kreuz stört dort nur. */
@media (hover: hover) and (pointer: fine) {
  .pad {
    display: none;
  }
}

/* --------------------------------------------------------------- Anzeige --- */
/* Drei Zahlen nebeneinander: Punkte, Baustellen, Zeit. Beim Esel sind es
   zwei – die mittlere trägt dann `hidden`.

   Umbrechen dürfen sie, abgeschnitten werden nicht. Auf einem schmalen
   Handy passen „Punkte: 4760“, „Strecke: 1500 m“ und „Zeit: 212 s“ nicht in
   eine Zeile; in zwei Zeilen passen sie, und zwei Zeilen sind allemal
   besser als eine halbe Zahl. */
.game__hud span {
  white-space: nowrap;
}

/* ---------------------------------------------------------- Bestenliste --- */
.highscore {
  counter-reset: rank;
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
}

.highscore li {
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  padding: 0.4rem 0;
}

.highscore li:last-child {
  border-bottom: 0;
}

.highscore__rank {
  color: var(--muted-fg);
  flex: none;
  font-variant-numeric: tabular-nums;
  width: 1.75rem;
}

.highscore__name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.highscore__score {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Der eigene Eintrag im Dunkelblau: Auf hellem Grund liest sich das Grün
   des Logos schlecht, und eine Hervorhebung, die man suchen muss, ist
   keine. */
.highscore li[data-own='true'] .highscore__name,
.highscore li[data-own='true'] .highscore__score {
  color: var(--brand);
  font-weight: 600;
}

/* ----------------------------------------------------------------- Fuß --- */
.foot {
  background: rgba(241, 245, 249, 0.3);
  border-top: 1px solid var(--border);
  flex: none;
  margin-top: auto;
}

.foot__inner {
  margin: 0 auto;
  max-width: 46rem;
  padding: 1.5rem 1rem;
  text-align: center;
}

@media (max-width: 30rem) {
  .head h1 {
    font-size: 1.0625rem;
  }

  .head__logo {
    width: 2.25rem;
  }

  .page {
    padding: 1.25rem 0.75rem 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status__dot {
    animation: none !important;
  }
}

/*
 * Ganz zum Schluss: Eigene Regeln mit `display` schlagen sonst die Vorgabe
 * des Browsers für das Attribut `hidden`. Ohne diese Zeilen stünde der Knopf
 * zur Website die ganze Zeit da und das Nickname-Feld schon vor der Runde.
 */
[hidden] {
  display: none !important;
}
