:root {
  --bg: #0d0e10;
  --panel: #17191c;
  --line: #2a2d32;
  --text: #eceae4;
  --dim: #8d9096;
  --pcb: #f2c230;
  --pcb-dark: #b88c12;
  --good: #3ddc6f;
  --bad: #ff4d4d;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body { overflow: hidden; }

/* ------------------------------------------------------------ bühne */

.stage {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* Das Gerät: gelbe Platine um das Display, wie beim Cheap Yellow Display */
.device {
  --pad: 14px;
  position: relative;
  padding: var(--pad);
  background: linear-gradient(160deg, var(--pcb), var(--pcb-dark));
  border-radius: var(--radius);
  box-shadow: 0 20px 60px -20px rgb(0 0 0 / .8), inset 0 1px 0 rgb(255 255 255 / .35);
  /* 4:3, so groß wie möglich; die Leiste darunter braucht ~60px */
  width: min(calc(100vw - 32px), calc((100dvh - 110px) * 4 / 3 + 2 * var(--pad)), 1000px);
}

#screen {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border-radius: 3px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  transition: filter .25s;
}

.boot {
  position: absolute;
  inset: var(--pad);
  display: grid;
  place-items: center;
  color: var(--dim);
  font-size: 14px;
  pointer-events: none;
}
.boot[hidden] { display: none; }
.boot.error { color: var(--bad); padding: 24px; text-align: center; }

/* ------------------------------------------------------------ leiste */

.rail {
  display: flex;
  gap: 10px;
  align-items: center;
}

.rail button {
  height: 40px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}
.rail button:hover { border-color: #3d4148; }
.rail button:focus-visible { outline: 2px solid var(--pcb); outline-offset: 2px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px 0 14px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bad);
  transition: background .3s;
}
.dot.on { background: var(--good); }

.icon {
  width: 40px;
  display: grid;
  place-items: center;
  padding: 0;
}
.icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Querformat mit wenig Höhe (Handy quer): Display so hoch wie möglich, Leiste an die Seite */
@media (orientation: landscape) and (max-height: 560px) {
  .stage { flex-direction: row; gap: 12px; padding-top: 0; padding-bottom: 0; }
  .device {
    --pad: 0px;
    border-radius: 0;
    background: none;
    box-shadow: none;
    width: min(calc(100vw - 80px), calc(100dvh * 4 / 3));
  }
  #screen { border-radius: 0; }
  .rail { flex-direction: column-reverse; }
  .chip { width: 40px; padding: 0; justify-content: center; }
  .chip #name-label { display: none; }
}

/* Vollbild: nur noch das Display */
:fullscreen .rail, .is-fullscreen .rail { display: none; }
:fullscreen .device, .is-fullscreen .device {
  --pad: 0px;
  border-radius: 0;
  background: none;
  box-shadow: none;
  width: min(100vw, calc(100dvh * 4 / 3));
}
:fullscreen .stage, .is-fullscreen .stage { padding: 0; }

/* ------------------------------------------------------------ dialoge */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(8 9 10 / .82);
  backdrop-filter: blur(6px);
}
.overlay[hidden] { display: none; }

.card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.card h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.01em; }
.card p { margin: 0 0 16px; color: var(--dim); }
.card .hint { font-size: 13px; margin: 8px 0 18px; }
.card .hint.error { color: var(--bad); }

.card input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: 600 18px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: .02em;
}
.card input:focus { outline: 2px solid var(--pcb); outline-offset: 1px; border-color: transparent; }

.actions { display: flex; gap: 10px; justify-content: flex-end; }

.card button {
  height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font: 600 15px/1 inherit;
  font-family: inherit;
  cursor: pointer;
}
.card button:focus-visible { outline: 2px solid var(--pcb); outline-offset: 2px; }
.primary { background: var(--pcb); color: #1a1500; border-color: var(--pcb); }
.primary:hover { background: #ffd23f; }
.ghost { background: transparent; color: var(--text); }
.ghost:hover { border-color: #3d4148; }

#rotate .card { text-align: center; }
.phone { width: 64px; height: 64px; fill: none; stroke: var(--pcb); stroke-width: 3; stroke-linecap: round; margin-bottom: 8px; }
