:root {
  --red: #e11b1b;
  --red-glow: #ff3b30;
  --bg: #0a0608;
  --text: #f3e9e2;
  --muted: #b09a90;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: "Trebuchet MS", system-ui, sans-serif;
  overflow: hidden; -webkit-user-select: none; user-select: none;
}
.hidden { display: none !important; }

.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; padding: 24px; text-align: center; overflow-y: auto;
}

/* ---- Logo ---- */
.logo { display: flex; flex-direction: column; align-items: center; line-height: .95;
  filter: drop-shadow(0 0 18px rgba(225, 27, 27, .55)); }
.logo.small { filter: none; margin-bottom: 6px; }
.logo-crazy { font-weight: 900; letter-spacing: 2px; font-size: clamp(28px, 7vw, 64px); color: #fff; }
.logo-family { color: var(--red-glow); }
.logo-doom {
  font-weight: 900; letter-spacing: clamp(6px, 3vw, 22px); font-size: clamp(40px, 12vw, 120px);
  background: linear-gradient(180deg, #ff5a4d 0%, #b30d0d 60%, #6e0606 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: 0 0 24px var(--red-glow);
}
.logo.small .logo-doom { font-size: clamp(20px, 5vw, 34px); letter-spacing: 4px;
  -webkit-text-fill-color: var(--red); background: none; text-shadow: 0 0 12px var(--red-glow); }
.tagline { color: var(--muted); max-width: 620px; margin: 0; font-size: 15px; }

/* ---- Phasenauswahl ---- */
.phase-select { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.phase-btn {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  min-width: 230px; padding: 18px 22px; cursor: pointer; text-align: left; color: var(--text);
  background: linear-gradient(160deg, #2a1518, #150c0e);
  border: 2px solid #3a1f22; border-radius: 12px;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.phase-btn strong { font-size: 22px; letter-spacing: 2px; color: var(--red-glow); }
.phase-btn span { font-size: 13px; color: var(--muted); }
.phase-btn:hover { transform: translateY(-3px); border-color: var(--red); box-shadow: 0 8px 28px rgba(225, 27, 27, .35); }

/* ---- Steuerungs-Box ---- */
.controls { max-width: 640px; width: 100%; color: var(--muted); }
.controls summary { cursor: pointer; color: var(--text); padding: 6px; }
.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; margin: 12px 0; font-size: 14px; text-align: left; }
.note { font-size: 13px; }
kbd { display: inline-block; min-width: 20px; padding: 2px 6px; margin: 0 1px;
  background: #2a1a1c; border: 1px solid #4a2a2d; border-bottom-width: 2px; border-radius: 4px;
  font-family: monospace; font-size: 12px; color: #fff; }

/* ---- Ladebalken ---- */
.bar { width: min(420px, 80vw); height: 14px; background: #2a1518; border-radius: 8px; overflow: hidden; }
#bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #ff5a4d, var(--red)); transition: width .15s; }
.bar-text { color: var(--muted); font-size: 13px; }
#status { font-size: 18px; }

/* ---- Spiel ---- */
#game { padding: 0; background: #000; }
#stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
canvas#canvas {
  image-rendering: pixelated; image-rendering: crisp-edges;
  background: #000; outline: none; box-shadow: 0 0 40px rgba(0,0,0,.8);
}
.topbar { position: fixed; top: 10px; left: 0; right: 0; display: flex; gap: 8px; padding: 0 12px; z-index: 10; pointer-events: none; }
.topbar .spacer { flex: 1; }
.topbar button { pointer-events: auto; width: 40px; height: 40px; font-size: 18px; cursor: pointer;
  background: rgba(20,12,14,.7); color: #fff; border: 1px solid #4a2a2d; border-radius: 8px; }

/* ---- Touch-Steuerung ---- */
.touch { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.touch .t {
  pointer-events: auto; position: absolute; width: 56px; height: 56px;
  font-size: 22px; color: #fff; background: rgba(30,16,18,.55);
  border: 1px solid rgba(225,27,27,.5); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; touch-action: none;
}
.touch .t:active, .touch .t.on { background: rgba(225,27,27,.6); transform: scale(.94); }
.dpad { position: absolute; left: 14px; bottom: 18px; width: 200px; height: 200px; }
.dpad .up    { left: 72px; bottom: 130px; }
.dpad .down  { left: 72px; bottom: 14px; }
.dpad .left  { left: 8px;  bottom: 72px; }
.dpad .right { left: 136px; bottom: 72px; }
.dpad .sl    { left: 8px;  bottom: 140px; width: 46px; height: 46px; font-size: 18px; }
.dpad .sr    { left: 146px; bottom: 140px; width: 46px; height: 46px; font-size: 18px; }
.actions { position: absolute; right: 14px; bottom: 18px; width: 200px; height: 200px; }
.actions .fire  { right: 72px; bottom: 96px; width: 70px; height: 70px; }
.actions .use   { right: 12px; bottom: 30px; }
.actions .enter { right: 96px; bottom: 18px; }
.actions .esc   { right: 12px; bottom: 130px; }

/* Gesten (Scroll/Zoom/Doppeltipp) auf der Spielfläche unterdrücken */
#stage, canvas#canvas { touch-action: none; }

/* ---- Footer ---- */
#legal { position: fixed; bottom: 0; left: 0; right: 0; padding: 6px 12px; font-size: 11px;
  color: var(--muted); background: rgba(0,0,0,.4); text-align: center; }
#legal a { color: var(--red-glow); }
body:has(#game:not(.hidden)) #legal { display: none; }

/* ===================== RESPONSIVE / MOBILE ===================== */
@media (max-width: 560px) {
  .screen { padding: 16px; gap: 12px; }
  .tagline { font-size: 13px; }
  .phase-select { gap: 12px; width: 100%; }
  .phase-btn { min-width: 0; width: 100%; padding: 14px 16px; }
  .phase-btn strong { font-size: 19px; }
  .controls-grid { grid-template-columns: 1fr; gap: 6px; }
  .topbar button { width: 36px; height: 36px; font-size: 16px; }
  #cfHud { font-size: 12px; top: 8px; right: 10px; }
}

/* Touch-Steuerung auf sehr schmalen/niedrigen Screens kompakter */
@media (max-width: 420px), (max-height: 460px) {
  .touch .t { width: 50px; height: 50px; font-size: 19px; }
  .dpad, .actions { width: 168px; height: 168px; }
  .dpad .up { left: 60px; bottom: 108px; }
  .dpad .down { left: 60px; bottom: 12px; }
  .dpad .left { left: 6px; bottom: 60px; }
  .dpad .right { left: 114px; bottom: 60px; }
  .dpad .sl { left: 6px; bottom: 116px; width: 42px; height: 42px; font-size: 16px; }
  .dpad .sr { left: 122px; bottom: 116px; width: 42px; height: 42px; font-size: 16px; }
  .actions .fire { right: 60px; bottom: 80px; width: 62px; height: 62px; }
  .actions .use { right: 10px; bottom: 24px; }
  .actions .enter { right: 80px; bottom: 14px; }
  .actions .esc { right: 10px; bottom: 110px; }
}
