/* ============================================================================
 * Plopp-Buddelei – Gestaltung
 * Pixel-Schrift "Press Start 2P" (SIL Open Font License, liegt in assets/fonts)
 * ========================================================================== */
@font-face {
  font-family: "Press Start 2P";
  src: url("../assets/fonts/PressStart2P-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #0d0818;
  --tafel: #241838;
  --tafel-hell: #3a2a58;
  --text: #f1ecff;
  --gedaempft: #b9acd6;
  --bier: #f5a21b;
  --bier-hell: #ffd24a;
  --schaum: #fff6d8;
  --rot: #ff6b5e;
  --gruen: #9de08c;
  --akzent: var(--bier-hell);
  --kante: #120b20;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Press Start 2P", ui-monospace, monospace;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

body { display: flex; flex-direction: column; align-items: center; justify-content: center; }

#huelle {
  position: relative;
  width: min(100vw, calc((100vh - 28px) * 1024 / 704));
  aspect-ratio: 1024 / 704;
  line-height: 1;
}
#buehne {
  display: block; width: 100%; height: 100%;
  image-rendering: auto;
  background: #000; box-shadow: 0 0 0 4px var(--kante), 0 10px 40px rgba(0, 0, 0, .6);
}

#fuss {
  height: 28px; line-height: 28px; font-size: 8px; color: var(--gedaempft);
  white-space: nowrap; overflow: hidden; max-width: 100vw; padding: 0 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 1em;
  width: min(100vw, calc((100vh - 28px) * 1024 / 704));
}
#fuss .tasten { overflow: hidden; text-overflow: ellipsis; }
#werkzeug { display: flex; gap: 4px; flex: 0 0 auto; }
#werkzeug button {
  width: 24px; height: 22px; padding: 0; box-shadow: none; border-width: 2px; background: var(--tafel);
  display: flex; align-items: center; justify-content: center;
}
#werkzeug button svg { width: 14px; height: 14px; fill: var(--text); }
#werkzeug button.aus svg { fill: #6b5f86; }
#werkzeug button.aus::after { content: ''; position: absolute; width: 18px; height: 2px; background: var(--rot); transform: rotate(-40deg); }
#werkzeug button { position: relative; }

/* ---- Überlagerung -------------------------------------------------------- */
#ueberlagerung {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 3%;
}
#ueberlagerung.aus { display: none; }

/* Schriftgrößen skalieren mit der Spielfeldbreite */
#huelle { font-size: calc(min(100vw, (100vh - 28px) * 1024 / 704) / 1024 * 16); }

.panel {
  width: min(88%, 40em); max-height: 94%; overflow: auto;
  background: var(--tafel); text-align: center;
  padding: 1.6em 1.8em; font-size: 1em;
  border: 0.25em solid var(--kante);
  box-shadow:
    0 0 0 0.25em var(--tafel-hell),
    0 0 0 0.5em var(--kante),
    0 1em 0 0.5em rgba(0, 0, 0, .35);
  animation: auftauchen .18s steps(4);
}
.panel.breit { width: min(92%, 52em); }
#ueberlagerung[data-art~="titel"] { align-items: flex-end; padding-bottom: 3.5%; }
.panel.titel {
  width: min(92%, 44em); background: rgba(22, 12, 38, .82); padding: .9em 1.2em 1em;
  box-shadow: 0 0 0 .25em rgba(58, 42, 88, .9), 0 0 0 .5em var(--kante);
}
.panel.titel .klein { margin-bottom: .2em; }
.panel.titel .knoepfe { margin-top: .5em; gap: .6em; }
.panel.titel button { padding: .8em 1em; }
.nur-leser { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.einstellung { display: flex; align-items: center; justify-content: space-between; gap: 1em; margin: .5em 0; font-size: .62em; text-align: left; }
.einstellung span { flex: 1; line-height: 1.6; }
.versionszeile { font-size: .5em; color: var(--gedaempft); margin-top: 1.4em; }
.seitenzahl { font-size: .55em; color: var(--gedaempft); margin: .4em 0 0; }

@keyframes auftauchen { from { transform: translateY(1.2em); opacity: 0; } to { transform: none; opacity: 1; } }

.panel h1, .panel h2 { margin: 0 0 .6em; font-weight: normal; line-height: 1.3; }
.panel h2 { font-size: 1.5em; color: var(--akzent); text-shadow: .12em .12em 0 var(--kante); }
.panel h2.gold { color: var(--akzent); }
.panel h2.rot { color: var(--rot); }
.panel p { margin: 0 0 1em; line-height: 1.7; font-size: .72em; }
.panel p.klein { font-size: .55em; color: var(--gedaempft); margin: 0 0 .8em; }
.panel p.unterzeile { color: var(--schaum); font-size: .7em; margin-bottom: 1.2em; }
.panel p.ziel { color: var(--akzent); font-size: .75em; }
.panel p.tipp { color: var(--gruen); font-size: .62em; }
.panel p.text { font-size: .75em; }
.panel b { color: var(--schaum); }

.logo {
  font-size: 2.7em !important; letter-spacing: .02em; color: var(--bier-hell) !important;
  display: flex; flex-direction: column; gap: .12em; margin-bottom: .35em !important;
  text-shadow: .08em .08em 0 var(--kante), .16em .16em 0 #8a4d0b;
}
.logo span:last-child { color: var(--schaum); text-shadow: .08em .08em 0 var(--kante), .16em .16em 0 #b07a2a; }

.parade { display: flex; justify-content: center; gap: .8em; margin: .6em 0 1em; }
.ikone { width: 3em; height: 3em; image-rendering: pixelated; vertical-align: middle; }
.parade .ikone { width: 3.6em; height: 3.6em; animation: huepfen 0.9s steps(2) infinite; }
.parade .ikone:nth-child(2n) { animation-delay: .3s; }
.parade .ikone:nth-child(3n) { animation-delay: .6s; }
@keyframes huepfen { 50% { transform: translateY(-.35em); } }

.knoepfe { display: flex; flex-wrap: wrap; gap: .8em; justify-content: center; margin-top: 1em; }
button {
  font: inherit; font-size: .72em; color: var(--text); cursor: pointer;
  background: var(--tafel-hell); border: .22em solid var(--kante);
  padding: .9em 1.2em; box-shadow: 0 .3em 0 var(--kante); text-transform: none;
}
button:hover, button:focus-visible { background: #5a418a; outline: none; }
button:active { transform: translateY(.2em); box-shadow: 0 .1em 0 var(--kante); }
button.primaer { background: var(--bier); color: #2a1706; }
button.primaer:hover, button.primaer:focus-visible { background: var(--bier-hell); }
button:disabled { opacity: .35; cursor: default; }

.spalten { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2em; text-align: left; }
.spalten p { font-size: .6em; }
.legende { list-style: none; padding: 0; margin: .6em 0 0; text-align: left; font-size: .58em; line-height: 1.7; }
.legende li { display: flex; align-items: center; gap: .9em; margin-bottom: .6em; }
.legende .ikone { flex: 0 0 auto; width: 2.6em; height: 2.6em; }

.raster { display: grid; grid-template-columns: repeat(5, 1fr); gap: .55em; margin: .2em 0 .4em; }
.raster .lv { display: flex; flex-direction: column; align-items: center; gap: .3em; padding: .45em .3em; font-size: .6em; }
.raster .nr { font-size: 1.7em; color: var(--akzent); }
.raster .nm { font-size: .78em; line-height: 1.3; color: var(--gedaempft); min-height: 2.6em; }
.raster .gesperrt .nr { color: #6b5f86; }
.raster .med { display: flex; gap: .15em; justify-content: center; }
.raster .med .ikone { width: 2.2em; height: 2.2em; }
.raster .best { font-size: .72em; color: var(--gedaempft); min-height: 1em; }
.panel.breit h2 { margin-bottom: .35em; }

.medaillen { list-style: none; margin: .4em auto 1em; padding: 0; text-align: left; font-size: .6em; line-height: 1.5; max-width: 40em; }
.medaillen li { display: flex; align-items: center; gap: .8em; margin: .3em 0; }
.medaillen li.aus { opacity: .6; }
.medaillen .ikone { width: 3.4em; height: 3.4em; flex: 0 0 auto; }
.verdeckt { visibility: hidden; }
.neu { color: var(--gruen); animation: blinken .6s steps(2) infinite; }
@keyframes blinken { 50% { opacity: .3; } }
.medziel { display: flex; align-items: center; justify-content: center; gap: .6em; flex-wrap: wrap; }
.medziel .ikone { width: 2.6em; height: 2.6em; }

.wertung { margin: 0 auto 1em; font-size: .7em; text-align: left; border-collapse: collapse; }
.wertung td { padding: .4em 1em; }
.wertung td:last-child { color: var(--bier-hell); text-align: right; }

/* ---- Meldung unten ------------------------------------------------------- */
#toast {
  position: absolute; left: 50%; bottom: 3%; transform: translate(-50%, 1em);
  background: var(--tafel); border: .2em solid var(--kante); box-shadow: 0 0 0 .2em var(--tafel-hell);
  padding: .8em 1.2em; font-size: .7em; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
#toast.sichtbar { opacity: 1; transform: translate(-50%, 0); }

/* ---- Spielhinweise (kommen nur einmal, erklären das Neue) -------------------- */
#hinweis {
  position: absolute; left: 2%; bottom: 3%; max-width: 58%;
  display: flex; align-items: center; gap: 1em;
  background: var(--tafel); border: .2em solid var(--kante); box-shadow: 0 0 0 .2em var(--akzent);
  padding: .7em 1.1em .7em .8em; font-size: .62em; line-height: 1.6;
  opacity: 0; transform: translateY(1em); pointer-events: none; transition: opacity .25s, transform .25s;
}
#hinweis.sichtbar { opacity: 1; transform: none; }
#hinweis.warn { box-shadow: 0 0 0 .2em var(--rot); }
#hinweis .ikone { width: 3.2em; height: 3.2em; flex: 0 0 auto; }
#hinweis b { color: var(--schaum); }

/* ---- Touch-Steuerung (nur auf Geräten ohne Maus) ------------------------- */
#touch { display: none; }
@media (pointer: coarse) {
  #fuss { display: none; }
  #huelle { width: min(100vw, calc((100vh - 8px) * 1024 / 704)); }
  /* Steuerung liegt am Bildschirmrand, in Maßen von vmin, damit die Tasten groß genug für Finger sind */
  #touch { display: block; position: fixed; inset: 0; pointer-events: none; z-index: 5; }
  #touch button {
    pointer-events: auto; position: absolute; opacity: .5; touch-action: none; user-select: none;
    width: 13vmin; height: 13vmin; padding: 0; font-size: 5vmin; border-radius: 2vmin; box-shadow: none;
  }
  #touch button.an { background: var(--bier); color: #2a1706; opacity: .85; }
  .kreuz { position: absolute; left: 2vmin; bottom: 2vmin; width: 40vmin; height: 40vmin; }
  .kreuz [data-t="o"] { left: 13.5vmin; top: 0; }
  .kreuz [data-t="l"] { left: 0; top: 13.5vmin; }
  .kreuz [data-t="r"] { left: 27vmin; top: 13.5vmin; }
  .kreuz [data-t="u"] { left: 13.5vmin; top: 27vmin; }
  #touch .greifen { right: 3vmin; bottom: 6vmin; width: 26vmin; font-size: 3.4vmin; }
  #touch .pause { right: 3vmin; top: 3vmin; width: 9vmin; height: 9vmin; font-size: 4vmin; }
  #fuss { display: none; }
  #touch .werk { top: 3vmin; width: 9vmin; height: 9vmin; font-size: 4vmin; }
  #touch .werk svg { width: 55%; height: 55%; fill: var(--text); }
  #touch .werk.aus svg { fill: #6b5f86; }
  #touch .werk[data-w="musik"] { right: 24vmin; }
  #touch .werk[data-w="sfx"] { right: 14vmin; }
  #touch .werk[data-w="zoom"] { right: 34vmin; }
}

/* weniger Bewegung gewünscht: keine Einblend- und Hüpfanimationen */
@media (prefers-reduced-motion: reduce) {
  .panel, .parade .ikone, .neu, #hinweis, #toast { animation: none !important; transition: none !important; }
}

/* ---- Rückweg zu echotec.de, Impressum, Datenschutz ----------------------- */
.rechtlich { display: flex; flex: 0 0 auto; gap: 1.2em; }
.rechtlich a { color: var(--gedaempft); text-decoration: underline; text-underline-offset: .25em; }
.rechtlich a:hover, .rechtlich a:focus-visible { color: var(--bier-hell); }
p.klein.rechtlich { justify-content: center; margin-top: 1.4em; }
