/* style.css — Seitenlayout, Overlay, Touch-Steuerung.
   Drei Zielgeräte: PC (Tastatur, kein Touch-Pad), Tablet (viel Platz),
   Handy im Querformat (Steuerung über das Spielfeld gelegt, iPhone-tauglich). */

:root {
  --fackel: #ffb03a;
  --stein: #43414f;
  --nacht: #0d0b1a;
  --panel: #14121f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #050409;
  color: #d8d2c0;
  font-family: "Courier New", monospace;
  min-height: 100%;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12px;
}

.rahmen {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Überschrift in gesperrten Versalien, Fackelgelb. */
.titel {
  margin: 4px 0;
  font-size: clamp(18px, 5vw, 34px);
  letter-spacing: 0.35em;
  color: var(--fackel);
  text-shadow: 0 0 8px rgba(255, 176, 58, 0.5), 2px 2px 0 #000;
  text-align: center;
}

/* Spielfeld mit doppeltem Steinrahmen und tiefem Schlagschatten. */
.buehne {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 4px solid var(--stein);
  outline: 4px solid #26232f;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8), inset 0 0 0 2px #0d0b1a;
  background: #000;
}

canvas#spiel {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}

/* Sichtbarer Tastaturfokus (Barrierefreiheit). */
canvas#spiel:focus-visible,
.start-knopf:focus-visible,
.tt:focus-visible,
.menue-knopf:focus-visible,
.sys-knopf:focus-visible {
  outline: 3px solid var(--fackel);
  outline-offset: 2px;
}

/* Overlay für Titel und Spielende. */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(6, 5, 12, 0.82);
  text-align: center;
  padding: 16px;
  z-index: 30;
}

.overlay.versteckt {
  display: none;
}

.overlay-inhalt {
  max-width: 90%;
}

.overlay h2 {
  color: var(--fackel);
  letter-spacing: 0.2em;
  font-size: clamp(16px, 4vw, 26px);
  margin: 0 0 10px;
  text-shadow: 2px 2px 0 #000;
}

.overlay p {
  margin: 6px 0;
  font-size: clamp(11px, 2.4vw, 14px);
  line-height: 1.5;
}

.overlay-punkte {
  color: #efe9d4;
  white-space: pre-line;
}

.overlay-hinweis {
  opacity: 0.7;
  font-size: clamp(9px, 2vw, 12px);
}

.start-knopf {
  margin: 12px 0 6px;
  padding: 12px 26px;
  font-family: inherit;
  font-size: clamp(13px, 3vw, 17px);
  letter-spacing: 0.1em;
  color: #14121f;
  background: var(--fackel);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 4px 0 #a4691f;
}

.start-knopf:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #a4691f;
}

/* System-Tasten (Pause + Ton) als kleines Overlay unten mittig. */
.sys-knoepfe {
  position: absolute;
  bottom: max(8px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  gap: 8px;
}

.sys-knopf {
  width: 36px;
  height: 36px;
  font-size: 16px;
  color: #efe9d4;
  background: rgba(20, 18, 31, 0.55);
  border: 1px solid var(--stein);
  border-radius: 10px;
  cursor: pointer;
  padding: 0;
}

.sys-knopf:active {
  background: rgba(255, 176, 58, 0.4);
}

/* Sekundär-Knopf im Overlay (Zum Menü). */
.menue-knopf {
  margin: 4px 0;
  padding: 9px 20px;
  font-family: inherit;
  font-size: clamp(12px, 2.6vw, 15px);
  letter-spacing: 0.08em;
  color: #efe9d4;
  background: var(--panel);
  border: 1px solid var(--stein);
  border-radius: 6px;
  cursor: pointer;
}

.menue-knopf:active {
  transform: translateY(1px);
}

/* --- Touch-Steuerung: über die Spielfeld-Ecken gelegt ------------------- */
.touch {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none; /* nur die Tasten selbst fangen Eingaben */
}

.touch-links,
.touch-rechts {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.touch-links {
  left: max(14px, env(safe-area-inset-left));
}

.touch-rechts {
  right: max(14px, env(safe-area-inset-right));
}

.touch-neben {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tt {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  color: #f2ede0;
  background: rgba(20, 18, 31, 0.42);
  border: 2px solid rgba(160, 150, 130, 0.55);
  border-radius: 50%;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: transform 0.05s, background 0.05s;
}

.tt:active {
  background: rgba(255, 176, 58, 0.55);
  border-color: var(--fackel);
  transform: scale(0.94);
}

/* Größen: Laufen und die zwei Hauptaktionen groß, Neben­tasten kleiner. */
.tt-lauf {
  width: clamp(58px, 12vw, 78px);
  height: clamp(58px, 12vw, 78px);
  font-size: clamp(22px, 5vw, 30px);
}

.tt-gross {
  width: clamp(64px, 13vw, 86px);
  height: clamp(64px, 13vw, 86px);
  font-size: clamp(24px, 6vw, 34px);
}

.tt-sprung {
  background: rgba(255, 176, 58, 0.22);
}

.tt-klein {
  width: clamp(44px, 9vw, 58px);
  height: clamp(44px, 9vw, 58px);
  font-size: clamp(16px, 4vw, 22px);
}

/* Dreh-Hinweis (nur Hochformat, Handy). */
.dreh-hinweis {
  display: none;
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 22;
  padding: 6px 12px;
  font-size: 12px;
  color: #14121f;
  background: rgba(255, 176, 58, 0.9);
  border-radius: 20px;
  white-space: nowrap;
  pointer-events: none;
}

/* Fußzeile. */
.fuss {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  opacity: 0.75;
  flex-wrap: wrap;
  justify-content: center;
}

/* --- PC mit Maus/Tastatur: Touch-Steuerung ausblenden ------------------- */
@media (hover: hover) and (pointer: fine) {
  .touch {
    display: none;
  }
  .sys-knopf {
    font-size: 17px;
  }
}

/* --- Handy im Querformat: Spielfeld füllt die Höhe, Rand/Überschrift weg -- */
@media (orientation: landscape) and (max-height: 560px) {
  body {
    padding: 0;
    height: 100dvh;
    overflow: hidden;
    align-items: center;
  }
  .titel,
  .fuss {
    display: none;
  }
  .rahmen {
    max-width: none;
    gap: 0;
    height: 100dvh;
    justify-content: center;
  }
  .buehne {
    height: 100dvh;
    width: auto;
    aspect-ratio: 16 / 9;
    max-width: 100vw;
    margin: 0 auto;
    border: none;
    outline: none;
    box-shadow: none;
  }

  /* Im Querformat kompakter und transparenter, damit weniger Spielfeld
     verdeckt wird. */
  .tt {
    background: rgba(20, 18, 31, 0.26);
    border-color: rgba(170, 160, 140, 0.4);
  }
  .tt-lauf {
    width: 46px;
    height: 46px;
    font-size: 19px;
  }
  .tt-gross {
    width: 52px;
    height: 52px;
    font-size: 22px;
  }
  .tt-klein {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }
  .touch-links,
  .touch-rechts {
    gap: 9px;
    bottom: max(9px, env(safe-area-inset-bottom));
  }
  .touch-links {
    left: max(9px, env(safe-area-inset-left));
  }
  .touch-rechts {
    right: max(9px, env(safe-area-inset-right));
  }
  .touch-neben {
    gap: 7px;
  }
}

/* --- Hochformat auf Touch-Geräten: Dreh-Hinweis zeigen ------------------- */
@media (orientation: portrait) and (pointer: coarse) {
  body {
    align-items: center;
    min-height: 100dvh;
  }
  .dreh-hinweis {
    display: block;
  }
}

/* --- Prefers-reduced-motion: keine Button-Skalierung -------------------- */
@media (prefers-reduced-motion: reduce) {
  .tt,
  .start-knopf {
    transition: none;
  }
}
