/* Einsatzbereit -- Spiel im Gameboy-Stil.
 * Ein Spielpixel ist --px (2 CSS-Pixel); die Pixelschrift (schrift/pixel.ttf)
 * hat 10 Spielpixel je Geviert, also font-size 20px = 2 CSS-Pixel je Pixel.
 * Keine Inline-Stile (strenge CSP): alles Aussehen steht hier. */

@font-face {
  font-family: "Einsatzbereit Pixel";
  src: url("schrift/pixel.ttf") format("truetype");
  font-display: swap;
}

:root {
  --px: 2px;
  --schrift: 20px;
  --zeile: 24px;
  --gehaeuse: #2b2e33;
  --gehaeuse-hell: #3a3e45;
  --rand: #15171a;
  --kreuz: #1b1d21;
  --knopf: #8f3a56;
  --knopf-text: #f2dbe2;
  --beschriftung: #c9cdd2;
  /* Palette des Bildschirms (wie js/grafik.js) */
  --k: #1b241c;
  --d: #2f5a3a;
  --g: #6ea65c;
  --l: #b7d696;
  --w: #f4f4e2;
  --o: #e8843a;
  --r: #b04a3a;
  --grau: #5d646c;
  --tipp: 44px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--gehaeuse);
  color: var(--beschriftung);
  font-family: "Einsatzbereit Pixel", ui-monospace, monospace;
  font-size: var(--schrift);
  line-height: var(--zeile);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select { font: inherit; }

.geraet {
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
}

/* ------------------------------------------------------------ Meldeleiste */

.meldeleiste {
  margin: 0;
  padding: 6px 10px;
  background: var(--o);
  color: var(--k);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.meldeleiste[hidden] { display: none; }
.leisten-knopf {
  min-height: var(--tipp);
  padding: 0 12px;
  background: var(--k);
  color: var(--w);
  border: 0;
  cursor: pointer;
}

/* ------------------------------------------------------------ Bildschirm */

.bildschirm {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--l);
  color: var(--k);
  border: 3px solid var(--rand);
  border-radius: 4px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.kopf {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 8px;
  background: var(--k);
  color: var(--w);
  white-space: nowrap;
  overflow: hidden;
}
.kopf-titel { overflow: hidden; text-overflow: ellipsis; }
.kopf-status { color: var(--l); }

.buehne {
  flex: 0 0 auto;
  max-height: 55%;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ohne-buehne .buehne { display: none; }
.buehne > * { flex-shrink: 0; }

.unten {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 8px 8px;
}
.ohne-buehne .unten { padding-top: 8px; }
.laden { margin: auto; }

/* Gameboy-Rahmen: schwarz, Papierspalt, schwarze Innenlinie, Papier */
.box {
  background: var(--w);
  border: var(--px) solid var(--k);
  box-shadow: inset 0 0 0 var(--px) var(--w), inset 0 0 0 calc(var(--px) * 2) var(--k);
  padding: 10px 14px;
  min-height: 0;
}

/* ------------------------------------------------------------ Textbox */

.textbox {
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
}
.textbox-text {
  margin: 0;
  height: calc(var(--zeile) * 5);
  overflow-y: auto;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.textbox.gross, .textbox.lang { flex: 1 1 auto; display: flex; flex-direction: column; }
.textbox.gross .textbox-text, .textbox.lang .textbox-text { flex: 1 1 auto; height: auto; min-height: calc(var(--zeile) * 4); }
.weiter {
  position: absolute;
  right: 10px;
  bottom: 4px;
  animation: blinken 0.8s steps(2, start) infinite;
}
@keyframes blinken { to { visibility: hidden; } }
.textbox:focus-visible, .wahl:focus-visible, .zurueck:focus-visible, .taste:focus-visible, .knopf-text:focus-visible {
  outline: 3px solid var(--o);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ Menue */

.menue-box {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: calc(var(--tipp) * 2 + var(--zeile));
}
.menue-box.gross { max-height: none; flex: 1 1 auto; }
.menue-titel { margin: 0 0 4px; color: var(--d); }
.menue {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
}
.wahl {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: var(--tipp);
  padding: 2px 4px;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--k);
  text-align: left;
  cursor: pointer;
  line-height: var(--zeile);
}
.wahl .zeiger { flex: 0 0 auto; visibility: hidden; width: 12px; }
.wahl.gewaehlt .zeiger { visibility: visible; }
.wahl.gewaehlt { background: var(--l); }
.wahl.inaktiv { color: var(--grau); }
.wahl-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.wahl .rechts { flex: 0 0 auto; margin-left: auto; color: var(--d); }
.wahl.inaktiv .rechts { color: var(--grau); }
.zeichen { flex: 0 0 auto; width: 16px; text-align: center; }
.zeichen-ja { color: var(--d); }
.zeichen-nein { color: var(--r); }
.menue-info { margin: 6px 0 0; padding-top: 4px; border-top: var(--px) solid var(--k); min-height: var(--zeile); }
.zurueck {
  align-self: flex-start;
  min-height: var(--tipp);
  margin-top: 4px;
  padding: 0 10px;
  border: var(--px) solid var(--k);
  background: var(--w);
  color: var(--k);
  cursor: pointer;
}

/* ------------------------------------------------------------ Figuren, Titel */

canvas.figur { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }

.titelbild { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px 0; text-align: center; }
.titel-gross { margin: 0; font-size: calc(var(--schrift) * 2); line-height: calc(var(--zeile) * 2); font-weight: normal; }
.titel-unter { margin: 0; color: var(--d); }

/* ------------------------------------------------------------ Einsatz, Dialog, Nachbesprechung */

.leise { color: var(--grau); }
.einsatz-kopf, .dialog-kopf, .anleiterin {
  display: flex;
  align-items: center;
  gap: 12px;
}
.einsatz-zeit { margin-left: auto; text-align: right; }
.einsatz-zeit p, .anleiterin p { margin: 0; }
.befundliste { margin: 0; padding: 6px 12px; display: grid; gap: 0 12px; }
.befund { display: flex; justify-content: space-between; gap: 12px; }
.befund dt { min-width: 0; }
.befund dd { margin: 0; text-align: right; }
.werte { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.wert p { margin: 0; }
.wert-zahl { color: var(--d); }
.wert-balken {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: calc(var(--px) * 4);
  border: var(--px) solid var(--k);
  background: var(--w);
}
.wert-balken::-webkit-progress-bar { background: var(--w); }
.wert-balken::-webkit-progress-value { background: var(--d); }
.wert-balken::-moz-progress-bar { background: var(--d); }
.sprechblase { margin: 0; white-space: pre-line; }
.anleiterin canvas { background: var(--w); border-bottom: var(--px) solid var(--k); }

/* ------------------------------------------------------------ Tafel: Code, QR, Kamera */

.buehne:has(.tafel) { max-height: 70%; }
.tafel { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tafel p, .tafel label { margin: 0; align-self: stretch; }
canvas.qr, video.kamera {
  display: block;
  width: min(100%, 320px);
  height: auto;
  image-rendering: pixelated;
}
.code-text {
  width: 100%;
  min-height: calc(var(--zeile) * 3);
  padding: 6px 8px;
  border: var(--px) solid var(--k);
  background: var(--w);
  color: var(--k);
  resize: vertical;
  overflow-wrap: anywhere;
  user-select: text;
  -webkit-user-select: text;
}
.hinweis { color: var(--d); }
.vorschau { white-space: pre-line; }

/* ------------------------------------------------------------ Steuerung */

.tastenhinweis { margin: 0; text-align: center; font-size: var(--schrift); color: var(--beschriftung); }
.steuerung { display: none; }
html.touch .tastenhinweis { display: none; }
html.touch .zurueck { display: none; }   /* am Telefon ist B die Taste */
html.touch .steuerung {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 8px 6px;
}
.kreuz {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
}
.taste {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  touch-action: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.kreuz .taste, .kreuz .mitte { background: var(--kreuz); }
.kreuz .hoch { grid-column: 2; grid-row: 1; border-radius: 8px 8px 0 0; }
.kreuz .links { grid-column: 1; grid-row: 2; border-radius: 8px 0 0 8px; }
.kreuz .mitte { grid-column: 2; grid-row: 2; }
.kreuz .rechts { grid-column: 3; grid-row: 2; border-radius: 0 8px 8px 0; }
.kreuz .runter { grid-column: 2; grid-row: 3; border-radius: 0 0 8px 8px; }
.kreuz .taste::after {
  content: "";
  display: block;
  margin: auto;
  width: 0;
  height: 0;
  border: 8px solid transparent;
}
.kreuz .hoch::after { border-bottom-color: var(--gehaeuse-hell); border-top-width: 0; }
.kreuz .runter::after { border-top-color: var(--gehaeuse-hell); border-bottom-width: 0; }
.kreuz .links::after { border-right-color: var(--gehaeuse-hell); border-left-width: 0; }
.kreuz .rechts::after { border-left-color: var(--gehaeuse-hell); border-right-width: 0; }
.ab { display: flex; gap: 14px; align-items: center; transform: rotate(-20deg); }
.knopf {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--knopf);
  color: var(--knopf-text);
  font-size: var(--schrift);
  box-shadow: 0 3px 0 var(--rand);
}
.knopf-a { margin-top: -28px; }
.taste.gedrueckt { filter: brightness(1.35); }
.knopf.gedrueckt { transform: translateY(2px); box-shadow: 0 1px 0 var(--rand); }

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