:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html,
body.mobile-game {
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mobile-game .game-shell {
  width: 200vw;
  height: 200svh;
  min-height: 200dvh;
  transform: scale(0.5);
  transform-origin: top left;
}

.mobile-game #game {
  touch-action: none;
}

.mobile-game .brand-block {
  top: calc(var(--safe-top) + 14px);
  left: calc(var(--safe-left) + 16px);
}

.mobile-game .brand-block .eyebrow {
  margin-bottom: 5px;
  font-size: 7px;
}

.mobile-game h1 {
  font-size: clamp(19px, 6.2vh, 29px);
}

.mobile-game .stats-panel {
  top: calc(var(--safe-top) + 12px);
  right: calc(var(--safe-right) + 14px);
  width: clamp(180px, 27vw, 235px);
  padding: 10px 12px 11px;
}

.mobile-game .stat-row + .stat-row {
  margin-top: 3px;
}

.mobile-game .stat-row span,
.mobile-game .evolution-copy {
  font-size: 8px;
}

.mobile-game .stat-row strong {
  font-size: 12px;
}

.mobile-game .evolution-copy {
  margin-top: 7px;
}

.mobile-game .progress-track {
  margin-top: 5px;
}

.mobile-game .controls-panel {
  right: calc(var(--safe-right) + 14px);
  bottom: calc(var(--safe-bottom) + 12px);
  gap: 7px;
  padding: 6px;
}

.mobile-game .controls-panel p {
  margin: 0 7px 0 4px;
  font-size: 7px;
  letter-spacing: 0.04em;
}

.mobile-game .icon-button {
  width: 88px;
  height: 88px;
  border-radius: 2px;
  font-size: 34px;
}

.mobile-game .icon-button:active,
.mobile-game .primary-button:active {
  transform: scale(0.96);
  border-color: var(--acid);
}

.mobile-game .corner-accent,
.mobile-game .key-cluster {
  display: none;
}

.touch-indicator {
  --finger-x: 50%;
  --finger-y: 50%;
  position: absolute;
  z-index: 5;
  top: var(--finger-y);
  left: var(--finger-x);
  width: 58px;
  height: 58px;
  border: 2px solid rgba(217, 255, 67, 0.78);
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(217, 255, 67, 0.09), 0 0 28px rgba(217, 255, 67, 0.3);
  transform: translate(-50%, -50%) scale(0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms ease, transform 100ms ease;
}

.touch-indicator i {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--acid);
  transform: translate(-50%, -50%);
}

.touch-indicator--active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.touch-guidance {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 34px);
  margin: 0;
  color: rgba(249, 244, 232, 0.42);
  font-size: 14px;
  letter-spacing: 0.13em;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 180ms ease;
}

.touch-steering-active .touch-guidance,
.overlay--visible ~ .touch-guidance {
  opacity: 0;
}

.mobile-game #start-screen {
  place-items: center start;
  padding: calc(var(--safe-top) + 12px) calc(var(--safe-right) + 18px) calc(var(--safe-bottom) + 12px) calc(var(--safe-left) + 18px);
  background-position: center;
}

/* Gameplay is intentionally rendered at 0.5x. Keep modal screens at normal
   mobile size so starting, pausing and restarting remain easy to tap. */
.mobile-game .overlay,
.mobile-game .orientation-gate {
  width: 100vw;
  height: 100dvh;
  transform: scale(2);
  transform-origin: top left;
}

.mobile-game .start-card {
  width: min(480px, 55vw);
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
  padding: clamp(16px, 4vh, 27px);
  overflow: auto;
}

.mobile-game .start-card h2 {
  font-size: clamp(42px, 15vh, 76px);
}

.mobile-game .intro-copy {
  margin: clamp(10px, 3vh, 18px) 0;
  font-size: clamp(9px, 2.1vh, 12px);
  line-height: 1.55;
}

.mobile-game .objective-strip {
  gap: 9px;
  padding: 9px 0;
  font-size: 8px;
}

.mobile-game .primary-button {
  min-height: 44px;
  margin-top: 12px;
  padding: 12px 15px;
}

.mobile-game .keyboard-hint {
  margin-top: 7px;
  font-size: 8px;
}

.mobile-game .pause-card {
  width: min(350px, calc(100% - var(--safe-left) - var(--safe-right) - 32px));
  padding: clamp(20px, 5vh, 30px);
}

.mobile-game .pause-card h2 {
  font-size: clamp(45px, 16vh, 72px);
}

.mobile-game .victory-card {
  margin: 0 0 calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 18px);
}

.orientation-gate {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: none;
  place-content: center;
  padding: 32px;
  background: radial-gradient(circle at 50% 42%, #281244, #0a0512 70%);
  text-align: center;
}

.orientation-gate h2 {
  font-size: clamp(35px, 12vw, 58px);
  line-height: 0.88;
}

.orientation-gate p {
  max-width: 320px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.phone-rotate {
  margin-bottom: 20px;
  color: var(--acid);
  font-size: 70px;
  line-height: 1;
  transform: rotate(90deg);
  animation: phone-nudge 1.8s ease-in-out infinite;
}

@keyframes phone-nudge {
  0%, 100% { transform: rotate(0deg); }
  45%, 65% { transform: rotate(90deg); }
}

@media (orientation: portrait) and (max-width: 900px) {
  .orientation-gate {
    display: grid;
  }
}

@media (max-height: 430px) {
  .mobile-game .brand-block .eyebrow,
  .mobile-game .touch-copy {
    display: none;
  }

  .mobile-game .start-card {
    width: min(440px, 58vw);
  }

  .mobile-game .start-card h2 {
    font-size: clamp(39px, 14vh, 58px);
  }

  .mobile-game .start-card .eyebrow,
  .mobile-game .keyboard-hint {
    margin-bottom: 4px;
  }
}

@media (max-height: 340px) {
  .mobile-game .intro-copy {
    display: none;
  }

  .mobile-game .objective-strip {
    margin-top: 8px;
  }
}
