:root {
  --bg-a: #101827;
  --bg-b: #16233b;
  --card: rgba(255, 255, 255, 0.09);
  --card-border: rgba(255, 255, 255, 0.14);
  --text: #f6f7fb;
  --muted: #b7c0d8;
  --accent: #f7c948;
  --accent-dark: #d89f11;
  --danger: #ff6b6b;
  --safe: #4ade80;
  --blue: #60a5fa;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 10%, rgba(247, 201, 72, 0.2), transparent 26rem),
    radial-gradient(circle at 80% 20%, rgba(96, 165, 250, 0.18), transparent 28rem),
    linear-gradient(145deg, var(--bg-a), var(--bg-b));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
canvas {
  font: inherit;
}

.game-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.game-card {
  width: min(1120px, 100%);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 28px;
  padding: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1;
}

h1 {
  font-size: clamp(2.2rem, 4vw, 4.8rem);
  letter-spacing: -0.08em;
}

h2 {
  font-size: clamp(2rem, 4vw, 4rem);
  letter-spacing: -0.06em;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.status-pills span {
  min-width: 112px;
  text-align: center;
  padding: 10px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  font-weight: 800;
}

.canvas-wrap {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: #16351f;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 250px);
  background: #234c2a;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at center, rgba(16, 24, 39, 0.54), rgba(16, 24, 39, 0.84));
}

.overlay.hidden {
  display: none;
}

.panel {
  width: min(520px, 100%);
  padding: 28px;
  border-radius: 28px;
  background: rgba(16, 24, 39, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  text-align: center;
}

.panel p {
  color: var(--muted);
  line-height: 1.6;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 8px 12px;
  margin: 18px 0 22px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  text-align: left;
}

.controls-grid span {
  color: var(--muted);
}

.controls-grid strong {
  color: var(--text);
}

button {
  width: 100%;
  border: 0;
  border-radius: 18px;
  padding: 15px 20px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #201505;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(247, 201, 72, 0.28);
  transition: transform 0.16s ease, filter 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

button:active {
  transform: translateY(1px);
}

.game-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.game-footer div:first-child {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 13px;
}

.game-footer strong {
  color: var(--text);
}

.hint {
  text-align: right;
}

@media (max-width: 780px) {
  .game-shell {
    padding: 12px;
  }

  .game-card {
    border-radius: 20px;
    padding: 12px;
  }

  .topbar,
  .game-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .status-pills {
    justify-content: flex-start;
  }

  .status-pills span {
    min-width: 0;
    flex: 1 1 130px;
  }

  .hint {
    text-align: left;
  }

  canvas {
    max-height: none;
  }
}


/* Mobile Spielsteuerung */
.mobile-controls {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 4;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 18px 18px;
  pointer-events: none;
}

.joystick-zone {
  width: 154px;
  height: 154px;
  display: grid;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.joystick-base {
  position: relative;
  width: 118px;
  height: 118px;
  border-radius: 999px;
  background: rgba(16, 24, 39, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow:
    inset 0 0 24px rgba(255, 255, 255, 0.06),
    0 14px 34px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(8px);
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(214, 224, 244, 0.82));
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
}

.mobile-sprint {
  width: 108px;
  height: 108px;
  border-radius: 999px;
  padding: 0;
  display: grid;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.mobile-sprint.is-active {
  transform: scale(0.96);
  filter: brightness(1.1);
}

body.is-playing-mobile {
  overscroll-behavior: none;
}

body.is-playing-mobile,
body.is-playing-mobile * {
  -webkit-user-select: none;
  user-select: none;
}

@media (hover: none), (pointer: coarse) {
  .mobile-controls {
    display: flex;
  }

  .game-shell {
    min-height: 100svh;
    padding: 8px;
    place-items: stretch;
  }

  .game-card {
    min-height: calc(100svh - 16px);
    display: flex;
    flex-direction: column;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 10px;
  }

  h1 {
    font-size: 2.2rem;
  }

  .eyebrow {
    font-size: 0.68rem;
  }

  .status-pills {
    gap: 6px;
  }

  .status-pills span {
    padding: 8px 9px;
    font-size: 0.82rem;
  }

  .canvas-wrap {
    flex: 1;
    min-height: 0;
  }

  canvas {
    width: 100%;
    height: min(68svh, 620px);
    max-height: none;
    object-fit: contain;
    touch-action: none;
  }

  .game-footer {
    display: none;
  }

  .panel {
    padding: 22px;
  }

  .panel p {
    font-size: 0.95rem;
  }

  .controls-grid {
    font-size: 0.9rem;
  }
}

@media (max-width: 430px) and (hover: none), (max-width: 430px) and (pointer: coarse) {
  .game-card {
    border-radius: 18px;
    padding: 9px;
  }

  .status-pills span {
    flex: 1 1 95px;
    min-width: 0;
  }

  .mobile-controls {
    padding: 0 10px 12px;
  }

  .joystick-zone {
    width: 136px;
    height: 136px;
  }

  .joystick-base {
    width: 104px;
    height: 104px;
  }

  .joystick-knob {
    width: 48px;
    height: 48px;
  }

  .mobile-sprint {
    width: 94px;
    height: 94px;
    font-size: 0.78rem;
  }

  canvas {
    height: 66svh;
  }
}


/* Version 2: zusätzliche UI */
.secondary-button {
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.secondary-button:hover {
  filter: brightness(1.12);
}

.mobile-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.mobile-actions button {
  pointer-events: auto;
}

.mobile-spray {
  width: 92px;
  height: 92px;
  border-radius: 999px;
  padding: 0;
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #a7f3d0, #14b8a6);
  color: #052e2b;
  box-shadow: 0 14px 30px rgba(20, 184, 166, 0.22);
}

.mobile-spray.is-active,
.mobile-sprint.is-active {
  transform: scale(0.96);
  filter: brightness(1.1);
}

@media (orientation: landscape) and (hover: none), (orientation: landscape) and (pointer: coarse) {
  .topbar {
    flex-direction: row;
    align-items: center;
  }

  .status-pills span {
    flex: 0 1 auto;
    min-width: 95px;
  }

  canvas {
    height: calc(100svh - 138px);
  }

  .game-card {
    min-height: calc(100svh - 16px);
  }
}

@media (max-width: 430px) and (hover: none), (max-width: 430px) and (pointer: coarse) {
  .mobile-actions {
    gap: 9px;
  }

  .mobile-spray {
    width: 82px;
    height: 82px;
    font-size: 0.74rem;
  }
}


/* Version 2.2: Sichtfeld-Fix
   Wichtig: Kein width:auto und keine neue Flex-Logik.
   Das Spielfeld behält die funktionierende Version-2-Größe,
   wird aber nicht mehr optisch beschnitten. */
canvas {
  object-fit: contain;
}

@media (hover: none), (pointer: coarse) {
  canvas {
    object-fit: contain;
  }
}

@media (orientation: landscape) and (hover: none), (orientation: landscape) and (pointer: coarse) {
  canvas {
    width: 100%;
    object-fit: contain;
  }
}

@media (max-width: 430px) and (hover: none), (max-width: 430px) and (pointer: coarse) {
  canvas {
    width: 100%;
    object-fit: contain;
  }
}


/* Kids-Version: größere mobile Bedienflächen */
.mobile-sprint,
.mobile-spray {
  font-weight: 900;
}

@media (hover: none), (pointer: coarse) {
  .joystick-base {
    width: 126px;
    height: 126px;
  }

  .joystick-knob {
    width: 62px;
    height: 62px;
  }

  .mobile-sprint {
    width: 116px;
    height: 116px;
  }

  .mobile-spray {
    width: 102px;
    height: 102px;
  }
}
