* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #14151f; color: #fff;
  font-family: ui-monospace, Menlo, Consolas, "Courier New", monospace;
  overscroll-behavior: none; touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

#console {
  position: fixed; inset: 0; display: grid; touch-action: none;
  grid-template-areas: "screen screen" "dpad ab" "meta meta";
  grid-template-rows: auto 1fr auto; grid-template-columns: 1fr 1fr;
  align-items: center; justify-items: center;
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(160deg, #3a3d5c, #2b2d42 55%, #20222f);
}

#bezel {
  grid-area: screen; background: #11121a; padding: 12px 12px 6px; border-radius: 10px 10px 28px 10px;
  box-shadow: inset 0 0 0 2px #000, 0 4px 0 #15161f;
}
#screen { display: block; width: 320px; height: 288px; image-rendering: pixelated; image-rendering: crisp-edges; background: #000; }
#brand { font-size: 10px; letter-spacing: 2px; color: #8d90b0; text-align: center; padding-top: 5px; font-weight: bold; }
#brand span { color: #f878b8; }

#dpad { grid-area: dpad; position: relative; width: 150px; height: 150px; touch-action: none; }
#dpad i { position: absolute; background: #15161f; box-shadow: 0 3px 0 #000; }
#dpad .u, #dpad .d { left: 50px; width: 50px; height: 50px; }
#dpad .l, #dpad .r { top: 50px; width: 50px; height: 50px; }
#dpad .u { top: 0; border-radius: 8px 8px 0 0; }
#dpad .d { top: 100px; border-radius: 0 0 8px 8px; }
#dpad .l { left: 0; border-radius: 8px 0 0 8px; }
#dpad .r { left: 100px; border-radius: 0 8px 8px 0; }
#dpad .c { left: 50px; top: 50px; width: 50px; height: 53px; box-shadow: none; }
#dpad .c::after { content: ""; position: absolute; inset: 15px 15px 18px; border-radius: 50%; background: #23253a; }
#dpad i.on { background: #34375a; }

#ab { grid-area: ab; display: flex; gap: 14px; align-items: center; transform: rotate(-18deg); }
#ab button {
  width: 68px; height: 68px; border-radius: 50%; border: 0; font: bold 22px/1 inherit; font-family: inherit;
  color: #5a0b33; background: #f8508c; box-shadow: 0 5px 0 #8a1c4c; touch-action: none;
}
#ab button[data-key="b"] { margin-top: 44px; background: #f8d830; color: #6b5200; box-shadow: 0 5px 0 #a08400; }
#ab button.on { transform: translateY(4px); box-shadow: 0 1px 0 #000; }

#meta { grid-area: meta; display: flex; gap: 22px; padding: 4px 0 2px; }
#meta button {
  border: 0; border-radius: 12px; background: #15161f; color: #9a9dbd; font: bold 10px/1.2 inherit; font-family: inherit;
  letter-spacing: 1px; padding: 8px 16px; box-shadow: 0 3px 0 #000; touch-action: none;
}
#meta button small { display: block; font-weight: normal; font-size: 8px; color: #6c6f8c; letter-spacing: 0; }
#meta button.on { transform: translateY(2px); box-shadow: 0 1px 0 #000; }

@media (orientation: landscape) and (max-height: 520px) {
  #console { grid-template-areas: "dpad screen ab" "dpad meta ab"; grid-template-columns: 1fr auto 1fr; grid-template-rows: auto auto; align-content: center; }
  #bezel { padding: 6px 6px 2px; }
  #brand { display: none; }
}

/* ---------- Overlay (Name, Anmeldung) ---------- */
#overlay {
  position: fixed; inset: 0; z-index: 10; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: rgba(10, 10, 24, .88); padding: max(14px, env(safe-area-inset-top)) 14px 40px;
  -webkit-user-select: text; user-select: text; touch-action: pan-y;
}
#overlay[hidden] { display: none; }
.panel {
  max-width: 420px; margin: 0 auto; background: #f0e0b0; color: #111; border: 4px solid #111;
  box-shadow: 6px 6px 0 #f8508c; padding: 14px; font-size: 14px; line-height: 1.4;
}
.panel h1 { margin: 0 0 8px; font-size: 20px; letter-spacing: 1px; text-transform: uppercase; }
.panel h2 { margin: 0 0 4px; font-size: 15px; text-transform: uppercase; }
.panel p { margin: 8px 0; }
.panel ul { margin: 0; padding-left: 18px; }
.panel .box { background: #fff; border: 3px solid #111; padding: 10px; margin: 10px 0; }
.panel .excuse { background: #ffe9f2; }
.panel .excuse p { font-size: 16px; font-weight: bold; margin-top: 0; }
.panel label.chk { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-weight: bold; }
.panel input[type=checkbox] {
  appearance: none; -webkit-appearance: none; width: 26px; height: 26px; flex: none; margin: 0;
  border: 3px solid #111; background: #fff; display: grid; place-items: center;
}
.panel input[type=checkbox]:checked::after { content: "X"; font: bold 18px/1 ui-monospace, Menlo, monospace; color: #d82800; }
.panel input[type=text], .panel textarea {
  width: 100%; border: 3px solid #111; background: #fff; color: #111; padding: 10px; border-radius: 0;
  font: bold 16px/1.3 ui-monospace, Menlo, Consolas, monospace;
}
.panel textarea { min-height: 64px; resize: vertical; font-weight: normal; }
.panel .row { display: flex; align-items: center; gap: 12px; margin: 8px 0 10px; font-weight: bold; }
.panel .row span { flex: 1; }
.panel .row button { width: 40px; height: 40px; border: 3px solid #111; background: #fff; font: bold 20px/1 ui-monospace, monospace; color: #111; }
.panel .row b { min-width: 22px; text-align: center; font-size: 18px; }
.btn {
  display: block; width: 100%; margin: 10px 0 0; padding: 13px 10px; border: 3px solid #111; border-radius: 0;
  font: bold 16px/1.1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; color: #111; background: #fff;
  box-shadow: 4px 4px 0 #111; text-transform: uppercase;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #111; }
.btn[disabled] { opacity: .5; }
.btn.yes { background: #58d848; }
.btn.no { background: #f8508c; }
.btn.small { font-size: 13px; padding: 9px; }
.btn.ghost { background: transparent; box-shadow: none; border-style: dashed; font-size: 12px; }
.msg { font-weight: bold; color: #d82800; min-height: 1.2em; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
