/* Layout: one game stage under the logo, missions + controls below. Single dark look: Sauerland at dusk, sodium-lamp amber. */
:root {
  color-scheme: dark;
  --bg: #121316;
  --panel: #1c1e23;
  --line: #2e3138;
  --fg: #ebe5d6;
  --muted: #9b968a;
  --accent: #f0ac2e;
  --money: #7fc455;
  --danger: #e2483d;
  --font-display: "Bungee", "Impact", "Arial Black", sans-serif;
  --font-body: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
}
html, body { height: 100%; }
/* Kein Browser-Zoom auf dem Handy: Doppeltippen und Pinch stören die Steuerung */
html, body, button { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
.game-shell, .stage, .stage * { -webkit-touch-callout: none; }
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.4;
}
.game-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 18px 32px;
  display: grid;
  gap: 16px;
}
.game-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; }
.game-logo { margin: 0; font-family: var(--font-display); font-weight: 400; line-height: 0.95; letter-spacing: 0.01em; text-wrap: balance; }
.logo-city { color: var(--fg); font-size: clamp(30px, 6vw, 52px); }
.logo-sub { display: block; color: var(--danger); font-size: clamp(14px, 2.4vw, 20px); letter-spacing: 0.32em; margin-top: 4px; }
.game-tagline { margin: 0; color: var(--muted); font-size: 18px; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 74vh;
  min-height: 340px;
  max-width: 100%;
  border: 1px solid var(--line);
  background: #000;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#game-canvas { display: block; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 100%; height: 100%; }
.stage:fullscreen, .stage.is-pseudo-fullscreen { aspect-ratio: auto; max-height: none; min-height: 0; width: 100%; height: 100%; border: 0; }
.stage.is-pseudo-fullscreen { position: fixed; inset: 0; z-index: 100; height: 100dvh; }
body.has-pseudo-fullscreen { overflow: hidden; }
.stage-buttons { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
.stage-btn {
  font-family: var(--font-display); font-size: 12px; letter-spacing: 0.04em;
  background: rgba(14, 14, 17, 0.78); color: var(--fg);
  border: 1px solid rgba(235, 229, 214, 0.3); padding: 6px 10px; cursor: pointer;
}
.stage-btn:hover { border-color: var(--accent); color: var(--accent); }
.stage-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stage-btn-key { color: var(--muted); margin-left: 4px; }
@media (max-width: 600px) { .stage-btn-key { display: none; } }
/* Als installierte App: nur das Spiel, randlos */
body.is-app .game-header, body.is-app .info-grid, body.is-app .game-footer { display: none; }
body.is-app .game-shell { padding: 0; max-width: none; gap: 0; }
body.is-app .stage { aspect-ratio: auto; width: 100%; height: 100vh; height: 100dvh; max-height: none; min-height: 0; border: 0; }
body.is-app #btn-fullscreen { display: none; }
/* Handy: großes Spielfeld im Hochformat, Startbildschirm über allem, Buttons unten mittig */
.start-overlay { z-index: 6; overflow-y: auto; }
.stage-buttons { z-index: 5; }
.touch-pad, .touch-action { z-index: 4; }
@media (max-width: 600px) {
  .stage { aspect-ratio: auto; height: 74vh; height: 74dvh; min-height: 420px; max-height: none; }
  .stage-buttons { top: auto; bottom: 14px; gap: 4px; }
  .stage-btn { font-size: 10px; padding: 7px 8px; }
  .start-text { font-size: 15px; }
  .start-title { font-size: 22px; }
}
@media (max-width: 600px) {
  /* Mit Touch-Steuerung: Knöpfe senkrecht über dem E-Knopf, während Dialogen ausgeblendet */
  body.show-touch .stage-buttons { left: auto; right: 12px; transform: none; flex-direction: column; align-items: stretch; bottom: calc(var(--action) + 36px); }
  body.show-touch.hand-links .stage-buttons { right: auto; left: 12px; }
  body.has-dialog .stage-buttons { display: none; }
}

.start-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(10, 11, 13, 0.82);
  padding: 20px;
  text-align: center;
}
.start-card { display: grid; gap: 14px; max-width: 520px; justify-items: center; }
.start-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: clamp(22px, 4vw, 34px); color: var(--accent); text-wrap: balance; }
.start-text { margin: 0; color: var(--fg); font-size: 18px; }
.start-button {
  font-family: var(--font-display); font-size: 20px;
  background: var(--accent); color: #1a1408;
  border: 0; padding: 12px 28px; cursor: pointer;
}
.start-button:hover { filter: brightness(1.08); }
.start-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.start-button-secondary { background: transparent; color: var(--fg); border: 1px solid rgba(235, 229, 214, 0.4); font-size: 15px; }
.start-button-secondary.is-armed { border-color: var(--danger); color: var(--danger); }
.start-save-note { margin: 0; color: var(--muted); font-size: 15px; }
.start-button:focus-visible, .touch-btn:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }

.touch-pad, .touch-action { display: none; }
/* Touch-Steuerung: per Optionsmenü an, aus oder automatisch (body.show-touch), Größe über --pad */
body { --pad: 48px; --action: 76px; }
body.pad-klein { --pad: 40px; --action: 62px; }
body.pad-gross { --pad: 64px; --action: 96px; }
body.show-touch .touch-pad {
  position: absolute; left: 12px; bottom: 12px;
  display: grid; grid-template-columns: repeat(3, var(--pad)); grid-template-rows: repeat(3, var(--pad)); gap: 4px;
}
body.show-touch .touch-action { display: block; position: absolute; right: 16px; bottom: 24px; width: var(--action); height: var(--action); }
body.show-touch.hand-links .touch-pad { left: auto; right: 12px; }
body.show-touch.hand-links .touch-action { right: auto; left: 16px; }
.touch-btn {
  background: rgba(235, 229, 214, 0.16);
  border: 1px solid rgba(235, 229, 214, 0.35);
  color: var(--fg);
  font-family: var(--font-display);
  font-size: 18px;
  touch-action: none;
}
.touch-btn.is-up { grid-column: 2; grid-row: 1; }
.touch-btn.is-left { grid-column: 1; grid-row: 2; }
.touch-btn.is-right { grid-column: 3; grid-row: 2; }
.touch-btn.is-down { grid-column: 2; grid-row: 3; }
.touch-action { border-radius: 50%; background: rgba(240, 172, 46, 0.85); color: #1a1408; border: 0; font-size: 22px; }

.info-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.controls-panel { background: var(--panel); border: 1px solid var(--line); padding: 14px 16px 16px; min-width: 0; }
.panel-title { margin: 0 0 10px; font-family: var(--font-display); font-weight: 400; font-size: 16px; letter-spacing: 0.06em; color: var(--accent); }
.controls-list { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; }
.controls-list dt { font-family: var(--font-display); font-size: 13px; color: var(--fg); padding-top: 3px; }
.controls-list dd { margin: 0; color: var(--muted); }
.disclaimer { margin: 14px 0 0; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
@media (prefers-reduced-motion: reduce) { .start-button { transition: none; } }

.game-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.footer-version { font-variant-numeric: tabular-nums; letter-spacing: 0.04em; font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.footer-version:hover, .footer-version:focus-visible { color: var(--accent); }
.changelog-overlay { position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; background: rgba(10, 11, 13, 0.86); padding: 16px; overflow: hidden; }
.changelog-card { width: min(560px, 100%); max-height: 100%; overflow: hidden; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 12px; background: var(--panel); border: 1px solid var(--line); padding: 18px; color: var(--fg); }
.changelog-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 24px; color: var(--accent); }
.changelog-hint { margin: 0; color: var(--muted); font-size: 14px; }
.changelog-list { overflow-y: auto; display: grid; gap: 14px; padding-right: 4px; min-height: 0; }
.changelog-entry { display: grid; gap: 4px; }
.changelog-version { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 16px; font-weight: 700; }
.changelog-number { color: var(--accent); font-variant-numeric: tabular-nums; }
.changelog-date { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 13px; font-variant-numeric: tabular-nums; }
.changelog-items { margin: 0; padding-left: 18px; display: grid; gap: 2px; font-size: 15px; line-height: 1.4; }
.changelog-close { justify-self: end; }

/* Optionsmenü */
.options-overlay { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(10, 11, 13, 0.86); padding: 16px; overflow-y: auto; }
.options-card { width: min(640px, 100%); max-height: 100%; overflow-y: auto; display: grid; gap: 14px; background: var(--panel); border: 1px solid var(--line); padding: 18px 18px 16px; color: var(--fg); }
.options-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 24px; color: var(--accent); }
.options-hint { margin: 0; color: var(--muted); font-size: 15px; }
.options-groups { display: grid; gap: 16px; }
.options-section { display: grid; gap: 10px; }
.options-section-title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 14px; letter-spacing: 0.08em; color: var(--fg); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.options-group { margin: 0; padding: 0; border: 0; display: grid; gap: 6px; min-width: 0; }
.options-legend { padding: 0; color: var(--muted); font-size: 15px; }
.options-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.options-radio { position: absolute; opacity: 0; pointer-events: none; }
.options-choice { cursor: pointer; padding: 8px 12px; min-height: 40px; display: inline-flex; align-items: center; border: 1px solid rgba(235, 229, 214, 0.3); font-size: 16px; font-weight: 500; }
.options-choice:hover { border-color: var(--accent); }
.options-radio:checked + .options-choice { background: var(--accent); border-color: var(--accent); color: #1a1408; }
.options-radio:focus-visible + .options-choice { outline: 2px solid var(--fg); outline-offset: 2px; }
.options-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
/* Belegung im Optionsmenü */
.bindings { display: grid; gap: 4px; }
.binding-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 6px; align-items: center; }
.binding-label { color: var(--fg); font-size: 15px; min-width: 0; }
.binding-btn { min-height: 36px; padding: 6px 8px; background: transparent; color: var(--fg); border: 1px solid rgba(235, 229, 214, 0.3); font: 500 15px var(--font-body); cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.binding-btn:hover { border-color: var(--accent); }
.binding-btn:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.binding-btn.is-waiting { background: var(--accent); color: #1a1408; border-color: var(--accent); }
.bindings-reset { justify-self: start; font-size: 15px; }
@media (max-width: 600px) { .binding-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .binding-label { grid-column: 1 / -1; } }
.binding-head .binding-col { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
@media (max-width: 600px) { .binding-head .binding-col:first-child { display: none; } }
.footer-links a, .options-legal a { color: var(--muted); }
.footer-links a:hover, .options-legal a:hover { color: var(--accent); }
.options-legal { margin: 0; font-size: 15px; color: var(--muted); }
