@font-face { font-family: "Silkscreen"; src: url("fonts/silkscreen-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Silkscreen"; src: url("fonts/silkscreen-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #14121a;
  --panel: rgba(22, 20, 28, 0.86);
  --panel-edge: #3b3746;
  --text: #f3eee4;
  --muted: #b9b2a6;
  --gold: #ffd25a;
  --green: #5fbf3a;
  --green-dark: #2f6b1c;
  --red: #e5483a;
  --diamond: #6ee7f0;
  --pixel: "Silkscreen", ui-monospace, monospace;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overscroll-behavior: none; }
/* Kein Scrollen, kein Gummiband, kein Doppeltipp-Zoom: jede Ansicht wird per JS eingepasst (einpassen() in app.js) */
html { position: fixed; inset: 0; overflow: hidden; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body { font: 15px/1.45 var(--body); -webkit-font-smoothing: antialiased; overflow: hidden; }
img { image-rendering: auto; }
.px { image-rendering: pixelated; }
button { font: inherit; color: inherit; }

/* Auf breiten Bildschirmen: Handy-Spalte in der Mitte, Szene verschwommen dahinter */
.backdrop {
  position: fixed; inset: -40px; background: var(--bg) center/cover no-repeat;
  filter: blur(28px) brightness(0.45) saturate(1.2); transition: background-image .6s;
}
.stage {
  position: relative; height: 100dvh; max-width: 480px; margin: 0 auto; overflow: hidden;
  box-shadow: 0 0 80px rgba(0, 0, 0, .6);
}

/* Bildschirm = Szene + scrollbarer Inhalt */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; animation: rein .7s ease both; }
.screen.raus { animation: raus .45s ease both; }
@keyframes rein { from { opacity: 0; transform: scale(1.03); } }
@keyframes raus { to { opacity: 0; transform: scale(.98); } }

.scene {
  position: absolute; inset: 0; background: center/cover no-repeat;
  animation: kenburns 30s ease-in-out infinite alternate;
}
@keyframes kenburns { from { transform: scale(1.02); } to { transform: scale(1.12) translateY(-2%); } }
.scene::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10, 8, 14, .55) 0%, rgba(10, 8, 14, 0) 18%, rgba(10, 8, 14, 0) 34%, rgba(10, 8, 14, .78) 58%, rgba(10, 8, 14, .96) 100%);
}

.screen > .scroll:last-child { padding-bottom: calc(14px + var(--safe-b)); }
.scroll {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  padding: calc(12px + var(--safe-t)) 16px 10px;
  display: flex; flex-direction: column;
}
.spacer { flex: 1 1 auto; min-height: 12px; }
.wechsel { animation: rein .45s ease both; }

/* Rätselansicht: Szene abgedunkelt, Rätsel unten über der Hotbar */
.screen.dunkel .scene::after { background: linear-gradient(180deg, rgba(10, 8, 14, .55), rgba(10, 8, 14, .72) 30%, rgba(10, 8, 14, .92)); }
.kopf { margin: auto 0 8px; padding-top: 10px; font: 700 18px/1.2 var(--pixel); text-transform: uppercase; text-shadow: 2px 2px 0 #000; }
.panel.raetsel { padding: 14px 14px 8px; margin-top: 0; }
.fuss { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; }
.fuss .meldung { margin: 0; text-align: left; font-size: 14px; line-height: 1.3; }
.fuss .leise { margin: 0; flex: none; padding: 8px 4px; }

/* Kopfzeile */
.top { display: flex; align-items: center; gap: 10px; }
.chip {
  font: 700 11px var(--pixel); letter-spacing: .08em; text-transform: uppercase;
  background: rgba(0, 0, 0, .55); border: 2px solid rgba(255, 255, 255, .18); padding: 5px 9px;
}
.fortschritt { display: flex; gap: 4px; margin-left: auto; }
.fortschritt i { width: 14px; height: 14px; background: rgba(0, 0, 0, .5); border: 2px solid rgba(255, 255, 255, .25); }
.fortschritt i.voll { background: var(--green); border-color: #a5ef7f; box-shadow: inset -3px -3px 0 var(--green-dark); }
.fortschritt i.jetzt { border-color: var(--gold); animation: puls 1.2s ease-in-out infinite; }
@keyframes puls { 50% { box-shadow: 0 0 10px var(--gold); } }

/* Titel */
.titel {
  font: 700 clamp(20px, 6vw, 28px)/1.1 var(--pixel); text-transform: uppercase; margin: 0 0 8px; overflow-wrap: anywhere; hyphens: auto;
  color: #fff; text-shadow: 3px 3px 0 #000, 0 0 24px rgba(0, 0, 0, .6);
}
.titel small { display: block; font-size: max(11px, .42em); line-height: 1.4; color: var(--gold); letter-spacing: .12em; margin-bottom: 8px; }
.logo { font-size: clamp(30px, 9.6vw, 46px); letter-spacing: 0; }
.logo span { color: var(--gold); }

/* Panel im Block-Stil */
.panel {
  background: var(--panel); border: 3px solid #000; outline: 3px solid var(--panel-edge); outline-offset: -6px;
  box-shadow: inset 0 0 0 6px rgba(0, 0, 0, .25), 0 12px 40px rgba(0, 0, 0, .5);
  padding: 16px 14px; margin-top: 12px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.story p { margin: 0 0 8px; }
.story p:last-child { margin: 0; }
.story strong { color: var(--gold); font-weight: 700; }
.aufgabe { font: 700 12px/1.4 var(--pixel); color: var(--gold); text-transform: uppercase; margin: 0 0 10px; letter-spacing: .04em; }

/* Knöpfe */
.btn {
  display: block; width: 100%; padding: 12px 14px; margin-top: 10px; border: 3px solid #000; cursor: pointer;
  font: 700 15px var(--pixel); text-transform: uppercase; letter-spacing: .06em; color: #fff;
  background: #6b6b74; text-shadow: 2px 2px 0 rgba(0, 0, 0, .55);
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, .28), inset -3px -4px 0 rgba(0, 0, 0, .35);
  transition: transform .08s, filter .15s;
}
.btn:active { transform: translateY(2px); box-shadow: inset 3px 3px 0 rgba(0, 0, 0, .3); }
.btn.gruen { background: var(--green); }
.btn.gold { background: #d69a1c; }
.btn:disabled { filter: grayscale(1) brightness(.7); cursor: default; }
.btn:focus-visible, .slot:focus-visible, .hebel:focus-visible, .wahl:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.leise {
  background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: 14px;
  padding: 10px; margin: 6px auto 0; display: block; cursor: pointer;
}

.meldung { min-height: 1.5em; margin-top: 10px; font-weight: 600; text-align: center; }
.meldung.falsch { color: #ff8a7d; }
.meldung.ok { color: #9ff07a; }
.wackeln { animation: wackeln .4s; }
@keyframes wackeln { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.tipp { margin-top: 12px; padding: 12px; background: rgba(255, 210, 90, .1); border-left: 4px solid var(--gold); font-size: 15px; }

/* Werkbank */
.werkbank { display: flex; align-items: center; justify-content: center; gap: 12px; }
.raster { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px; background: #000; }
.slot {
  width: clamp(50px, min(16vw, 7.4dvh), 66px); aspect-ratio: 1; padding: 5px; border: 0; cursor: pointer;
  background: #8b8b8b; box-shadow: inset 3px 3px 0 #373737, inset -3px -3px 0 #fff;
  display: grid; place-items: center;
}
.slot img { width: 100%; height: 100%; pointer-events: none; }
.slot.gewaehlt { background: #b5b5b5; outline: 3px solid var(--gold); outline-offset: -3px; }
.pfeil { font: 700 28px var(--pixel); color: var(--muted); }
.ergebnis { width: clamp(64px, 19vw, 80px); }
.inventar { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin-top: 10px; padding: 4px; background: #000; }
.inventar .slot { padding: 4px; }
.inventar .slot { width: 100%; }
.inventar .slot span { position: absolute; }

/* Rätsel-Bibliothek, Eingabefelder */
.gewaehlt-name { margin: 6px 0 0; font: 700 13px var(--pixel); color: var(--gold); text-transform: uppercase; }
.eingabe {
  width: 100%; margin-top: 14px; padding: 14px; font: 700 22px var(--pixel); text-align: center; text-transform: uppercase;
  letter-spacing: .12em; color: #fff; background: #000; border: 3px solid #555; border-radius: 0;
}
.eingabe:focus { outline: none; border-color: var(--gold); }
.koord { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.koord label { font: 700 13px var(--pixel); color: var(--muted); }
.koord .eingabe { margin-top: 4px; }
.formel { text-align: center; font: 700 15px var(--pixel); background: rgba(0, 0, 0, .4); padding: 10px; margin: 0 0 12px; }

/* Lava-Parkour */
.festung, .ufer { text-align: center; font: 700 11px var(--pixel); text-transform: uppercase; letter-spacing: .08em; padding: 5px; }
.festung { background: linear-gradient(#2a1416, #3a1a1c); border: 3px solid #000; border-bottom: 0; color: #ffb38a; }
.ufer { background: url(art/netherrack.png) center/48px; border: 3px solid #000; border-top: 0; color: #fff; text-shadow: 2px 2px 0 #000; }
.see { --zelle: min(62px, calc((100vw - 76px) / 5), calc((100dvh - 455px) / 7)); display: grid; grid-template-columns: repeat(var(--spalten), var(--zelle)); width: max-content; margin: 0 auto; border: 3px solid #000; background: #000; }
.festung, .ufer { width: calc(var(--zelle, 60px) * 5 + 6px); margin: 0 auto; }
#feld:has(.see) { --zelle: min(62px, calc((100vw - 76px) / 5), calc((100dvh - 455px) / 7)); }
.feld {
  aspect-ratio: 1; border: 0; padding: 0; cursor: pointer; position: relative;
  background: url(art/lava.png) center/100% no-repeat, #e8641c; image-rendering: pixelated;
  animation: lava 2.6s ease-in-out infinite; animation-delay: calc(var(--d, 0) * 1s);
}
.feld:nth-child(3n) { --d: .7; } .feld:nth-child(4n+1) { --d: 1.4; } .feld:nth-child(5n+2) { --d: 2; }
@keyframes lava { 50% { filter: brightness(1.18) saturate(1.15); } }
.feld::after { content: ""; position: absolute; inset: 0; background: rgba(40, 10, 0, .25); transition: background .2s; }
.feld.leuchtet, .feld.fest { background: url(art/netherrack.png) center/100% no-repeat, #6b1d1d; animation: none; }
.feld.leuchtet::after { background: rgba(255, 220, 120, .35); box-shadow: inset 0 0 0 3px #ffd25a, 0 0 18px #ffb43c; z-index: 1; }
.feld.fest::after { background: none; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .5); }
.feld.platsch { animation: platsch .6s ease; }
@keyframes platsch { 30% { filter: brightness(2.2); transform: scale(.85); } }
#zeigen { margin-top: 4px; }
#parkour-info { margin: 6px 0 0; min-height: 1.4em; font-size: 14px; }

/* Redstone */
.regeln { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 5px; font-size: 14px; line-height: 1.35; }
.regeln li { display: flex; gap: 10px; align-items: center; padding: 7px 10px; background: rgba(0, 0, 0, .35); border-left: 4px solid #555; transition: border-color .2s, background .2s; }
.regeln li.an { border-color: #ffcf4d; background: rgba(255, 190, 60, .14); }
.regeln li.boom { border-color: var(--red); background: rgba(229, 72, 58, .2); }
.lampe { flex: none; width: 26px; height: 26px; background: #4a3420; border: 3px solid #000; box-shadow: inset -4px -4px 0 rgba(0, 0, 0, .35); transition: background .2s, box-shadow .2s; }
.an .lampe { background: #ffd66b; box-shadow: inset -4px -4px 0 #d18b1a, 0 0 18px #ffbe3c; }
.tnt { background: linear-gradient(#d33 0 30%, #eee 30% 60%, #d33 60%); }
.boom .tnt { animation: blink .3s steps(2) infinite; }
@keyframes blink { 50% { background: #fff; } }
.hebel-reihe { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.hebel {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; cursor: pointer;
  background: #6f6f6f; border: 3px solid #000; box-shadow: inset 3px 3px 0 rgba(255, 255, 255, .25), inset -3px -3px 0 rgba(0, 0, 0, .35);
  font: 700 18px var(--pixel);
}
.hebel .griff { width: 10px; height: 34px; background: #7a5530; border: 2px solid #000; transform-origin: bottom center; transform: rotate(-35deg); transition: transform .18s; position: relative; }
.hebel .griff::before { content: ""; position: absolute; top: -6px; left: -4px; width: 14px; height: 10px; background: #555; border: 2px solid #000; }
.hebel.an { background: #8a3c32; }
.hebel.an .griff { transform: rotate(35deg); }
.hebel.an .griff::before { background: #ff3a2a; box-shadow: 0 0 10px #ff3a2a; }
.hebel small { font: 600 11px var(--body); color: #ddd; }

/* Quiz */
.frage { margin-bottom: 16px; }
.frage.kompakt { margin-bottom: 10px; }
.frage.kompakt p { font-size: 14px; line-height: 1.35; margin: 0 0 5px; }
.frage.kompakt .inventar { margin-top: 0; }
.frage.kompakt .slot { width: 100%; max-height: 52px; }
.frage p { margin: 0 0 8px; font-weight: 600; }
.wahl-reihe { display: grid; gap: 6px; }
.wahl {
  text-align: left; padding: 12px 14px; cursor: pointer; background: rgba(0, 0, 0, .45); border: 3px solid #444;
  font-size: 15px;
}
.wahl.gewaehlt { border-color: var(--gold); background: rgba(255, 210, 90, .16); }
.quiz-punkte { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.quiz-punkte i { width: 12px; height: 12px; border: 2px solid rgba(255, 255, 255, .3); }
.quiz-punkte i.voll { background: var(--gold); border-color: var(--gold); }
.quiz-punkte i.jetzt { border-color: var(--gold); }
.quiz-frage { font-weight: 700; font-size: 17px; text-align: center; margin: 0 0 14px; min-height: 3em; }
.quiz .wahl { padding: 14px; text-align: center; font-weight: 600; }

/* Belohnung */
.belohnung { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(0, 0, 0, .78); animation: rein .35s both; padding: 16px; }
.belohnung .karte { max-width: 380px; width: 100%; text-align: center; }
.hinweis .karte { text-align: left; }
.hinweis .karte p { margin: 0 0 6px; }
.belohnung img { width: 128px; height: 128px; margin: 6px auto 4px; display: block; animation: schweben 2.4s ease-in-out infinite, auftauchen .6s cubic-bezier(.2, 1.6, .4, 1) both; filter: drop-shadow(0 0 22px rgba(255, 220, 120, .55)); }
@keyframes schweben { 50% { transform: translateY(-8px); } }
@keyframes auftauchen { from { transform: scale(0) rotate(-30deg); } }
.belohnung h2 { font: 700 22px var(--pixel); color: var(--gold); margin: 6px 0; text-transform: uppercase; }
.strahlen { position: absolute; width: 520px; height: 520px; background: repeating-conic-gradient(rgba(255, 210, 90, .12) 0 10deg, transparent 10deg 20deg); border-radius: 50%; animation: drehen 18s linear infinite; pointer-events: none; mask: radial-gradient(circle, #000 20%, transparent 65%); -webkit-mask: radial-gradient(circle, #000 20%, transparent 65%); }
@keyframes drehen { to { transform: rotate(360deg); } }

/* Hotbar */
.hotbar {
  /* eigene Zeile unter dem Inhalt (nicht darüber), damit einpassen() sie nie überdeckt */
  position: relative; z-index: 5; flex: none; align-self: center; margin: 0 0 calc(12px + var(--safe-b));
  display: flex; gap: 2px; padding: 3px; background: rgba(0, 0, 0, .7); border: 2px solid #000; outline: 2px solid #555;
}
.hotbar div { width: 48px; height: 48px; background: rgba(140, 140, 140, .35); box-shadow: inset 2px 2px 0 rgba(0, 0, 0, .5), inset -2px -2px 0 rgba(255, 255, 255, .15); display: grid; place-items: center; }
.hotbar img { width: 38px; height: 38px; }
.hotbar .neu img { animation: auftauchen .6s cubic-bezier(.2, 1.6, .4, 1) both; }

/* Finale */
.truhe-gross { display: block; margin: 0 auto; width: min(160px, 18dvh); height: min(160px, 18dvh); cursor: pointer; background: none; border: 0; padding: 0; animation: schweben 2s ease-in-out infinite; filter: drop-shadow(0 0 30px rgba(255, 200, 80, .7)); }
.truhe-gross img { width: 100%; height: 100%; }
.truhe-gross.auf { animation: aufgehen .7s ease both; }
@keyframes aufgehen { 40% { transform: scale(1.25) rotate(-6deg); } 70% { transform: scale(.9) rotate(4deg); } to { transform: scale(0); opacity: 0; } }
.code {
  font: 700 clamp(16px, 5vw, 22px) var(--pixel); letter-spacing: .02em; text-align: center; overflow-wrap: anywhere;
  background: #000; border: 3px solid var(--gold); color: var(--gold); padding: 16px 10px; margin: 12px 0 0;
  box-shadow: 0 0 30px rgba(255, 210, 90, .35); user-select: all; -webkit-user-select: all;
}
.glueckwunsch { text-align: center; }
.glueckwunsch .titel { font-size: clamp(22px, 6.6vw, 32px); }

.konfetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; }

.ton {
  position: fixed; top: calc(12px + var(--safe-t)); right: max(12px, calc(50vw - 240px + 12px)); z-index: 10;
  width: 40px; height: 40px; border: 2px solid rgba(255, 255, 255, .3); background: rgba(0, 0, 0, .5); color: #fff; cursor: pointer; font-size: 18px;
}
.ton.aus { opacity: .45; text-decoration: line-through; }
.screen .top { padding-right: 52px; }

/* Kleine Handys (z. B. iPhone SE): alles etwas dichter */
@media (max-height: 720px) {
  body { font-size: 15px; line-height: 1.42; }
  .story p { margin-bottom: 8px; }
  .btn { padding: 11px 12px; margin-top: 10px; font-size: 14px; }
  .hotbar div { width: 40px; height: 40px; }
  .hotbar img { width: 32px; height: 32px; }
  .frage.kompakt p { font-size: 13px; }
  .frage.kompakt .slot { max-height: 44px; }
  .regeln li { padding: 5px 8px; font-size: 13px; }
  .hebel .griff { height: 26px; }
  .see, #feld:has(.see) { --zelle: min(56px, calc((100vw - 76px) / 5), calc((100dvh - 410px) / 7)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
