/* ============================================================
   FIETES METEORITEN-FLUG
   Die Seite drumherum. Das Spiel selbst wird komplett im
   Canvas gezeichnet – hier geht es nur um die Verpackung.
   ============================================================ */

* {
  box-sizing: border-box;
}

:root {
  --hintergrund: #07070f;
  --karte: #12122400;
  --rand: #2a2a45;
  --text: #e8e8f5;
  --gedaempft: #9a9ab8;
  --blau: #8fa4ff;
  --gruen: #3dff88;
  --rot: #ff5252;
  --gold: #ffd447;
}

body {
  margin: 0;
  padding: 0 16px 60px;
  background:
    radial-gradient(ellipse at 50% -10%, #1a1035 0%, transparent 60%),
    var(--hintergrund);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
}

/* ---------------- Kopfbereich ---------------- */

header {
  position: relative;
  text-align: center;
  padding: 40px 0 24px;
}

/* Der Zurück-Knopf oben links */
.zurueck {
  position: absolute;
  top: 42px;
  left: 0;
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid var(--rand);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--gedaempft);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.zurueck:hover,
.zurueck:focus-visible {
  border-color: var(--blau);
  background: rgba(143, 164, 255, 0.12);
  color: var(--text);
  outline: none;
}

.fuss-link {
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
}

.fuss-link:hover { text-decoration: underline; }

h1 {
  margin: 0;
  font-size: clamp(30px, 6vw, 46px);
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(180deg, #ffffff 30%, #9fb0ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.untertitel {
  margin: 8px 0 0;
  color: var(--gedaempft);
  font-size: 15px;
}

/* ---------------- Das Spielfeld ---------------- */

main {
  max-width: 940px;
  margin: 0 auto;
}

#spielfeld {
  /* Hält das Seitenverhältnis 900:540, egal wie breit der
     Bildschirm ist. Das Canvas skaliert einfach mit. */
  aspect-ratio: 900 / 540;
  width: 100%;
  border: 2px solid var(--rand);
  border-radius: 14px;
  overflow: hidden;
  background: #0d0d1c;
  box-shadow:
    0 0 80px rgba(90, 120, 255, 0.16),
    0 20px 50px rgba(0, 0, 0, 0.5);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#hilfe {
  margin: 18px 0 0;
  text-align: center;
  color: var(--gedaempft);
  font-size: 14px;
}

.maus-tipp {
  display: block;
  margin-top: 6px;
  color: #6a6a88;
  font-size: 13px;
}

/* ---------------- Tasten-Optik ---------------- */

kbd {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid #3a3a5c;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #1a1a2e;
  color: #dcdcf0;
  font-family: inherit;
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------------- Handy-Steuerung ----------------
   Die Leisten werden von src/touch.js gebaut und nur auf
   Geräten mit Touchscreen überhaupt eingehängt.
   Es sind nie alle gleichzeitig sichtbar: beim Fliegen die
   Spiel-Reihe, in den Menüs die beiden Menü-Reihen.        */

.touch-reihe {
  display: grid;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  touch-action: none;
}

.touch-reihe.versteckt {
  display: none;
}

#touch-spiel        { grid-template-columns: 1fr 1fr 1.5fr 1fr 1fr; }
#touch-menue-oben   { grid-template-columns: repeat(5, 1fr); }
#touch-menue-unten  { grid-template-columns: repeat(7, 1fr); }

/* Auf Touchgeräten darf das Spielfeld nicht wegscrollen,
   wenn man den Finger zum Lenken darüber zieht. */
body.touch canvas {
  touch-action: none;
}

/* Kein Zoom beim schnellen Doppeltippen */
body.touch {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

.touch-knopf {
  height: 66px;
  padding: 0;
  border: 1px solid #3a3a5c;
  border-bottom-width: 4px;
  border-radius: 12px;
  background: #1a1a2e;
  color: var(--text);
  font-family: inherit;
  font-size: 25px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  transition: transform 0.06s, background 0.06s;
}

.touch-knopf.aktiv {
  border-bottom-width: 1px;
  background: #2a2a4e;
  transform: translateY(3px);
}

.k-hoch, .k-runter, .k-links, .k-rechts {
  border-color: #4a5a8c;
  background: #1c2242;
  font-size: 28px;
}

.k-feuer {
  border-color: #2f7a4d;
  background: #123322;
  font-size: 28px;
}

.k-ok {
  border-color: #4a5a8c;
  background: #1c2242;
  font-size: 18px;
}

/* Die untere Menü-Reihe ist flacher */
#touch-menue-unten .touch-knopf {
  height: 48px;
  font-size: 19px;
  background: #16162a;
}

/* Am Rechner brauchen wir das alles nicht */
body:not(.touch) .touch-reihe,
body:not(.touch) #gross-knopf {
  display: none;
}

/* ---------------- Namensfeld ---------------- */
/* Das gab es hier bisher gar nicht – das Feld sah aus wie ein
   nacktes Browser-Eingabefeld. */

#namensfeld {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  justify-content: center;
  max-width: 940px;
  margin: 22px auto 0;
  padding: 16px 20px;
  border: 1px solid #2a2a55;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

#namensfeld label { font-size: 15px; font-weight: 600; }

#namensfeld input {
  width: 170px;
  padding: 9px 12px;
  border: 1px solid #3a3a5c;
  border-radius: 8px;
  background: #12122a;
  color: #e8e8f5;
  font-family: inherit;
  font-size: 15px;
}

#namensfeld input:focus { border-color: #8fa4ff; outline: none; }

#namensfeld .hinweis {
  flex-basis: 100%;
  order: 2;
  text-align: center;
  color: #8a8aa8;
  font-size: 13px;
}

/* Die Rückmeldung nach dem Eintippen */
.name-meldung {
  flex-basis: 100%;
  order: 1;                 /* immer direkt unter das Feld */
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
}

.name-meldung.gut { color: #7dff5e; }
.name-meldung.leer { color: #8a8aa8; font-weight: 400; }
.name-meldung.schlecht { color: #ff8f8f; }

/* Kurz grün aufleuchten, wenn gespeichert wurde */
#namensfeld input.gespeichert {
  border-color: #7dff5e;
  box-shadow: 0 0 0 3px rgba(125, 255, 94, 0.18);
  transition: border-color 0.12s, box-shadow 0.12s;
}

/* ---------------- Großmodus ---------------- */

#gross-knopf {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 11px;
  border: 1px solid #3a3a5c;
  border-radius: 10px;
  background: #16162a;
  color: var(--gedaempft);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Alles außer Spielfeld und Knöpfen ausblenden */
body.gross header,
body.gross .infos,
body.gross .tasten,
body.gross footer,
body.gross #hilfe,
body.gross #namensfeld {
  display: none;
}

body.gross {
  padding: 0;
}

body.gross main {
  max-width: none;
}

body.gross #spielfeld {
  border-radius: 0;
  border-left: none;
  border-right: none;
  box-shadow: none;
}

body.gross .touch-reihe {
  margin-top: 6px;
  padding: 0 8px;
}

body.gross #gross-knopf {
  width: calc(100% - 16px);
  margin: 8px;
}

/* Im Querformat ist Platz – dann Spielfeld und Knöpfe nebeneinander */
@media (orientation: landscape) and (max-height: 520px) {
  body.gross #spielfeld {
    max-height: 74vh;
    margin: 0 auto;
    width: auto;
    aspect-ratio: 900 / 540;
  }

  body.gross .touch-knopf { height: 52px; font-size: 21px; }
  body.gross #touch-menue-unten .touch-knopf { height: 40px; font-size: 17px; }
  body.gross #gross-knopf { padding: 7px; font-size: 12px; margin: 5px 8px; }
}

/* ---------------- Info-Kacheln ---------------- */

.infos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 48px;
}

.infos article,
.tasten {
  padding: 22px 24px;
  border: 1px solid var(--rand);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.infos h2,
.tasten h2 {
  margin: 0 0 12px;
  font-size: 19px;
}

.infos ul {
  margin: 0;
  padding-left: 20px;
}

.infos li {
  margin-bottom: 6px;
  font-size: 14.5px;
}

.infos p {
  margin: 0 0 10px;
  font-size: 14.5px;
}

.notiz {
  margin-top: 12px !important;
  margin-bottom: 0 !important;
  padding-top: 12px;
  border-top: 1px solid var(--rand);
  color: var(--gedaempft);
  font-size: 13.5px !important;
}

.gruen { color: var(--gruen); }
.rot   { color: var(--rot); }
.blau  { color: #4db8ff; }
.gold  { color: var(--gold); }
.rosa  { color: #ff5ecd; }

/* ---------------- Tastentabelle ---------------- */

.tasten {
  margin-top: 16px;
}

.tasten table {
  width: 100%;
  border-collapse: collapse;
}

.tasten td {
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 14.5px;
  vertical-align: middle;
}

.tasten td:first-child {
  width: 130px;
  white-space: nowrap;
}

.tasten tr:last-child td {
  border-bottom: none;
}

/* ---------------- Fußzeile ---------------- */

footer {
  max-width: 940px;
  margin: 44px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--rand);
  text-align: center;
  color: var(--gedaempft);
  font-size: 14px;
}

footer p {
  margin: 0 0 6px;
}

.klein {
  font-size: 12.5px;
  opacity: 0.7;
}

/* ---------------- Kleine Bildschirme ---------------- */

@media (max-width: 620px) {
  body { padding: 0 12px 40px; }
  header { padding: 16px 0 16px; }

  /* Auf dem Handy über den Titel statt daneben */
  .zurueck {
    position: static;
    margin-bottom: 12px;
  }
  .infos { margin-top: 32px; }
  .infos article, .tasten { padding: 18px; }

  /* Die Tastatur-Hinweiszeile ist auf dem Handy nur im Weg –
     dort gibt es ja die Knöpfe. */
  body.touch #hilfe kbd { display: none; }
  body.touch #hilfe { font-size: 0; }
  body.touch #hilfe::after { font-size: 13px; }

  .touch-knopf { height: 60px; font-size: 23px; }
  .k-hoch, .k-runter, .k-links, .k-rechts, .k-feuer { font-size: 25px; }
  #touch-menue-unten .touch-knopf { height: 44px; font-size: 17px; }
  .touch-reihe { gap: 6px; }
}
