:root {
  --bg: #07090d;
  --panel: #11151d;
  --text: #eef2f7;
  --muted: #aab4c3;
  --accent: #ffbd62;
  --accent-dark: #ffbd62;
  --warning: #f6d365;
  --danger: #ff5d5d;
  --line: rgba(238, 242, 247, 0.24);
  --glass: rgba(17, 21, 29, 0.94);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

button {
  font: inherit;
}

.app-shell {
  position: absolute;
  width: min(960px, calc(100vw - 24px));
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(var(--game-scale, 1));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 0;
}

.game-stage {
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 0;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background-color: #0d1118;
  background-image:
    linear-gradient(rgba(238, 242, 247, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(238, 242, 247, 0.06) 1px, transparent 1px);
  background-size: 36px 36px;
  border: 1px solid rgba(255, 189, 98, 0.28);
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

#gameCanvas {
  image-rendering: pixelated;
  display: block;
  width: 100%;
  height: 100%;
}

.hud {
  width: 100%;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #eef2f7;
  background: var(--glass);
  border: 1px solid rgba(255, 189, 98, 0.28);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.24);
  backdrop-filter: none;
}

.hud__group {
  min-width: 92px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(238, 242, 247, 0.16);
}

.hud__group span {
  display: block;
  color: rgba(238, 242, 247, 0.62);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
}

.hud__group strong {
  display: block;
  margin-top: 2px;
  color: #ffffff;
  font-size: 18px;
  line-height: 1.1;
}

.icon-button {
  width: 42px;
  height: 42px;
  margin-left: auto;
  border: 1px solid rgba(238, 242, 247, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}

.new-record-banner {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 0 14px;
  background: var(--warning);
  border: 1px solid rgba(75, 57, 32, 0.28);
  color: #2d2112;
  font-weight: 800;
  animation: record-pop 0.72s ease both;
}

.active-effects {
  position: absolute;
  width: 144px;
  transform: translate(-50%, -100%);
  pointer-events: none;
  display: grid;
  gap: 4px;
  padding: 5px;
  background: rgba(7, 9, 13, 0.9);
  border: 1px solid rgba(238, 242, 247, 0.16);
  border-radius: 5px;
}

.active-effect {
  display: grid;
  grid-template-columns: 18px 1fr 34px;
  align-items: center;
  gap: 5px;
  min-height: 16px;
}

.active-effect__icon {
  width: 24px;
  height: 24px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.active-effect__icon--fallback {
  width: 16px;
  height: 16px;
  justify-self: center;
  border: 2px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(currentColor, currentColor) center / 8px 2px
    no-repeat;
}

.active-effects--reviving {
  width: 216px;
  border-color: var(--danger);
}

.active-effect__bar {
  height: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(238, 242, 247, 0.14);
}

.active-effect__fill {
  width: 100%;
  height: 100%;
  background: var(--accent);
}

.active-effect__time {
  color: rgba(238, 242, 247, 0.72);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.inventory {
  position: static;
  display: grid;
  width: min(400px, 100%);
  align-self: center;
  flex-shrink: 0;
  margin: 8px auto 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  transform: none;
  padding: 12px;
  background: #171c26;
  border: 1px solid rgba(255, 189, 98, 0.5);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.inventory__slot {
  width: 100%;
  height: 54px;
  padding: 15px 3px 3px;
  position: relative;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(238, 242, 247, 0.2);
  color: rgba(238, 242, 247, 0.86);
  font-size: 11px;
  font-weight: 900;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.inventory__slot::before {
  content: attr(data-slot-label);
  position: absolute;
  top: 3px;
  left: 5px;
  color: rgba(238, 242, 247, 0.52);
  font-size: 10px;
  font-weight: 800;
}

.inventory__slot.inventory__slot--occupied {
  height: 62px;
  padding: 16px 3px 3px;
  font-size: 0;
  background-position: center bottom -2px;
  background-repeat: no-repeat;
  background-size: 53px 53px;
}

.inventory__slot--occupied::before {
  left: 3px;
  right: 3px;
  color: #eef2f7;
  font-size: 9px;
  line-height: 1;
  text-align: center;
}

.inventory__slot--occupied::after {
  content: attr(data-item-icon);
  color: #b59cff;
  font-size: 20px;
}

.inventory__slot--occupied[data-item-icon=""]::after {
  display: none;
}

.inventory__slot--selected {
  transform: translateY(-2px);
  background: rgba(255, 189, 98, 0.3);
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 18px rgba(255, 189, 98, 0.4);
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 9, 13, 0.82);
  backdrop-filter: blur(5px);
}

.screen__content {
  width: min(420px, 100%);
  padding: 26px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
  text-align: center;
  animation: panel-enter 260ms ease both;
}

.screen__eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  margin-bottom: 10px;
  line-height: 1.05;
}

h1 {
  font-size: clamp(34px, 5vw, 54px);
}

h2 {
  font-size: clamp(28px, 4vw, 42px);
}

.screen p:not(.screen__eyebrow) {
  color: var(--muted);
  line-height: 1.45;
}

.screen-actions {
  display: grid;
  gap: 10px;
  justify-items: center;
  margin-top: 16px;
}

.game-over-stats {
  margin: 14px 0 18px;
  display: grid;
  gap: 8px;
}

.game-over-stats p {
  margin: 0;
  color: var(--text);
}

.primary-button {
  min-width: 160px;
  height: 44px;
  border: 0;
  background: var(--accent);
  color: #07120e;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(255, 189, 98, 0.22);
}

.secondary-button {
  min-width: 118px;
  height: 42px;
  border: 1px solid rgba(255, 189, 98, 0.36);
  background: #202633;
  color: #eef2f7;
  cursor: pointer;
  font-weight: 800;
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover {
  filter: brightness(1.08);
}

.instructions-content {
  width: min(560px, 100%);
  max-height: calc(100vh - 80px);
  overflow: auto;
  text-align: left;
}

.instructions-content h2,
.instructions-content h3 {
  margin: 0 0 10px;
}

.instructions-content h3 {
  margin-top: 18px;
  font-size: 17px;
}

.controls-grid {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 6px 10px;
  margin-bottom: 16px;
}

.controls-grid span {
  display: grid;
  min-height: 28px;
  place-items: center;
  padding: 4px 8px;
  background: #202633;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.controls-grid p,
.instructions-notes p {
  margin: 0;
  color: var(--text);
}

.controls-grid p {
  display: flex;
  align-items: center;
}

.instructions-notes {
  display: grid;
  gap: 7px;
  margin: 16px 0;
  padding: 12px;
  background: rgba(255, 189, 98, 0.12);
  border: 1px solid rgba(255, 189, 98, 0.24);
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--text);
  font-weight: 700;
}

.settings-toggle input {
  width: 18px;
  height: 18px;
}

.settings-toggle--centered {
  justify-content: center;
  text-align: left;
}

.instructions-countdown {
  margin: 12px 0;
  padding: 10px;
  background: var(--warning);
  color: #2d2112;
  font-size: 22px;
  font-weight: 900;
  text-align: center;
}

.feedback-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.feedback-pop {
  position: absolute;
  left: 50%;
  top: 42%;
  min-width: 150px;
  padding: 10px 14px;
  transform: translate(-50%, -50%);
  background: #171c26;
  border: 1px solid rgba(255, 255, 255, 0.62);
  color: #eef2f7;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.24);
  animation: feedback-rise 760ms ease-out forwards;
}

.feedback-pop--hit {
  background: rgba(255, 93, 93, 0.95);
  color: #ffffff;
}

.feedback-pop--collect {
  background: rgba(246, 211, 101, 0.96);
  color: #2d2112;
}

.game-stage.is-hit {
  animation: stage-hit 220ms ease both;
}

#gameOverScreen:not(.hidden) .screen__content {
  animation: game-over-enter 420ms ease both;
}

.hidden {
  display: none;
}

@keyframes panel-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes record-pop {
  0% {
    transform: scale(0.92);
  }
  42% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes feedback-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, -35%) scale(0.94);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -96%) scale(1);
  }
}

@keyframes stage-hit {
  0% {
    box-shadow:
      0 26px 70px rgba(0, 0, 0, 0.42),
      inset 0 0 0 1px rgba(255, 93, 93, 0.1);
  }
  50% {
    box-shadow:
      0 26px 70px rgba(0, 0, 0, 0.42),
      inset 0 0 0 999px rgba(255, 93, 93, 0.14);
  }
  100% {
    box-shadow:
      0 26px 70px rgba(0, 0, 0, 0.42),
      inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  }
}

@keyframes game-over-enter {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
  }
  55% {
    transform: translateY(0) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 640px) and (orientation: portrait) {
  .game-stage {
    width: 100%;
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  .hud {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
  }

  .hud__group {
    min-width: 72px;
    flex: 1 1 90px;
  }

  .screen {
    padding: 14px;
  }

  .screen__content {
    padding: 20px;
  }
}

.asset-loading {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 9, 13, 0.97);
  color: #eef2f7;
  text-align: center;
}

.asset-loading p {
  max-width: 100%;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.asset-loading.hidden {
  display: none;
}

/* Vista a toda la ventana, con controles sobre los márgenes del escenario. */
.app-shell {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  width: 100%;
  height: 100dvh;
  gap: 0;
  padding: 0;
  --inventory-bottom: max(8px, env(safe-area-inset-bottom));
}

.hud {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  width: auto;
  max-width: none;
  z-index: 4;
  margin: 0;
  padding: 4px;
  gap: 4px;
  flex-shrink: 0;
}

.hud__group {
  min-width: 0;
  flex: 1 1 62px;
  padding: 4px;
}

.hud__group strong {
  font-size: 16px;
}

.hud .secondary-button {
  min-width: 88px;
  font-size: 11px;
}

.hud.hidden {
  display: none;
}

.fullscreen-icon {
  display: block;
  width: 24px;
  height: 24px;
  margin: auto;
}

.primary-button,
.secondary-button,
.icon-button,
.input-mode {
  min-height: 48px;
  height: auto;
}

.icon-button {
  min-width: 48px;
  margin-left: 0;
}

.game-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: visible;
  border: 0;
  outline: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
}

#gameCanvas,
.touch-controls,
.inventory__slot {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(64px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.screen__content {
  padding: 20px;
  margin: auto;
  flex-shrink: 0;
}

.instructions-content {
  max-height: none;
  overflow: visible;
}

.settings-toggle {
  min-height: 48px;
}

.settings-toggle input {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.input-choice {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #eef2f7;
  font-size: 14px;
}

body[data-game-status="playing"] .input-choice,
body[data-game-status="paused"] .input-choice {
  display: none;
}

.input-mode {
  max-width: 100%;
  padding: 8px;
  border-radius: 6px;
  background: #202633;
  color: #eef2f7;
  font: inherit;
}

.input-help {
  font-size: 14px;
}

.active-effects,
.active-effects--reviving {
  position: absolute;
  left: 0;
  bottom: auto;
  top: 0;
  z-index: 4;
  width: min(180px, calc(100% - 16px));
  transform: translate(-50%, -100%);
  grid-template-columns: minmax(0, 1fr);
  flex-shrink: 0;
}

.active-effect {
  grid-template-columns: 24px 1fr 38px;
  min-height: 24px;
}

.inventory {
  position: absolute;
  left: 50%;
  bottom: var(--inventory-bottom);
  z-index: 4;
  transform: translateX(-50%);
  width: min(360px, calc(100% - 24px));
  margin: 0;
  padding: 5px;
  gap: 5px;
}

.inventory__slot {
  height: 62px;
  min-width: 48px;
  min-height: 48px;
  cursor: pointer;
}

.inventory-help {
  grid-column: 1 / -1;
  margin: 0;
  color: #eef2f7;
  font-size: 12px;
  text-align: center;
}

.touch-controls {
  display: none;
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 4;
  width: auto;
  height: 140px;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  pointer-events: none;
}

.touch-joystick,
.touch-actions {
  pointer-events: auto;
}

body[data-input-method="touch"] .touch-controls {
  display: flex;
}

body:not([data-game-status="playing"]) .touch-controls {
  visibility: hidden;
  pointer-events: none;
}

.touch-joystick {
  position: relative;
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  border: 2px solid rgba(255, 189, 98, 0.5);
  border-radius: 50%;
  background: rgba(255, 189, 98, 0.12);
  box-shadow: inset 0 0 24px rgba(255, 189, 98, 0.12);
}

.touch-joystick.is-floating {
  position: absolute;
}

.touch-controls:has(.touch-joystick.is-floating) {
  justify-content: flex-end;
}

.joystick-directions {
  position: absolute;
  color: rgba(255, 189, 98, 0.4);
  font-size: 90px;
}

.joystick-knob {
  width: 48px;
  height: 48px;
  border: 2px solid #ffbd62;
  border-radius: 50%;
  background: rgba(255, 189, 98, 0.65);
  box-shadow: 0 4px 12px #07090d;
  pointer-events: none;
}

.touch-actions {
  position: relative;
  width: 160px;
  height: 136px;
}

.touch-action {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 50%;
  color: #07090d;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.4);
}

.touch-action span {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.touch-action small {
  font-size: 10px;
  font-weight: 800;
}

.touch-action--jump {
  right: 0;
  bottom: 0;
  width: 76px;
  height: 76px;
  background: var(--accent);
}

.touch-action--jump span {
  font-size: 38px;
}

.touch-action--crouch {
  left: 0;
  bottom: 4px;
  background: #b59cff;
}

.touch-action--use {
  right: 26px;
  top: 0;
  background: var(--warning);
}

.is-pressed {
  filter: brightness(1.25);
  border-color: #fff;
  box-shadow: inset 0 0 14px rgba(255, 255, 255, 0.4);
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid var(--warning);
  outline-offset: 2px;
}

#gameCanvas:focus,
#gameCanvas:focus-visible {
  outline: none;
}

@media (max-width: 640px) and (orientation: portrait) {
  .hud {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hud #hudControlsButton {
    grid-column: 2 / 4;
  }

  .hud #newRecordBanner {
    position: absolute;
    top: 100%;
    left: 4px;
    margin-top: 8px;
  }

  .inventory {
    width: min(360px, calc(100% - 16px));
  }

  .hud__group {
    flex: 1 1 54px;
    min-width: 0;
  }

  .hud__group span {
    font-size: 10px;
  }

  .screen {
    padding-top: 72px;
  }

  .screen__content {
    padding: 18px;
  }

  h1 {
    font-size: 34px;
  }
}

@media (orientation: landscape) {
  body[data-input-method="touch"] .inventory {
    width: min(320px, calc(100% - 292px));
    min-width: 214px;
  }
}

@media (orientation: portrait) {
  body[data-input-method="touch"] .app-shell {
    --inventory-bottom: calc(max(8px, env(safe-area-inset-bottom)) + 122px);
  }
}

@media (max-width: 480px) and (orientation: portrait),
  (max-height: 500px) and (orientation: landscape) {
  .touch-controls {
    height: 114px;
  }

  .touch-joystick {
    width: 100px;
    height: 100px;
  }

  .joystick-directions {
    font-size: 74px;
  }

  .touch-actions {
    width: 130px;
    height: 112px;
  }

  .touch-action {
    width: 48px;
    height: 48px;
  }

  .touch-action--jump {
    width: 66px;
    height: 66px;
  }

  .touch-action--use {
    right: 31px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .screen {
    padding-top: max(16px, env(safe-area-inset-top));
  }
}

body[data-input-method="touch"] .inventory {
  max-width: 248px;
  padding: 3px;
  gap: 3px;
}

body[data-input-method="touch"] .inventory__slot {
  height: 46px;
  min-height: 46px;
  font-size: 9px;
  padding-top: 11px;
}

body[data-input-method="touch"] .inventory__slot--occupied {
  font-size: 0;
  background-size: 38px 38px;
}

body[data-input-method="touch"] .inventory-help {
  display: none;
}

.touch-joystick {
  background: radial-gradient(circle, #303b4e 0%, #202633 60%, #11151d 100%);
  border-color: #ffbd62;
}

.touch-action {
  border-color: rgba(255, 255, 255, 0.55);
  color: #f3fcff;
  background: #263a49;
}

.touch-action--jump {
  background: #825117;
  border-color: #ffbd62;
}

.touch-action--crouch {
  background: #523c7e;
  border-color: #cbb6ff;
}

.touch-action--use {
  background: #795316;
  border-color: #f6d365;
}

body {
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 189, 98, 0.08), transparent 42%),
    linear-gradient(135deg, rgba(246, 211, 101, 0.05), transparent 38%), #07090d;
  color: var(--text);
  font-family: var(--font-body);
}

.falconio-logo {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
  margin: 0 auto 6px;
}

.screen__content {
  border: 1px solid rgba(255, 189, 98, 0.36);
  border-radius: 16px;
}

.primary-button,
.secondary-button,
.input-mode {
  border-radius: 8px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

#menuScreen {
  padding-block: max(60px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-bottom));
}

#menuScreen .screen__content {
  padding: 12px;
}

#menuScreen h1 {
  margin-bottom: 6px;
  font-size: clamp(27px, 6vw, 40px);
}

#menuScreen p {
  margin: 0;
  font-size: 13px;
}

#menuScreen .screen-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-items: stretch;
  gap: 6px;
  margin-top: 10px;
}

#menuScreen .screen-actions button {
  min-width: 0;
  min-height: 44px;
  padding: 4px;
  font-size: 12px;
}

@media (min-width: 520px) and (max-height: 420px) {
  #menuScreen {
    padding-top: max(52px, env(safe-area-inset-top));
  }

  #menuScreen .screen__content {
    width: min(520px, 100%);
    padding: 8px;
  }

  #menuScreen .falconio-logo {
    width: 32px;
    height: 32px;
  }

  #menuScreen h1 {
    font-size: 30px;
  }

  #menuScreen .screen-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen__content,
  #gameOverScreen:not(.hidden) .screen__content,
  .new-record-banner,
  .game-stage.is-hit {
    animation: none;
  }

  .feedback-pop {
    animation-name: feedback-fade;
  }

  .inventory__slot {
    transition: none;
  }
}

.screen:not(#menuScreen) {
  padding-block: max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-bottom));
}

.screen:not(#menuScreen) .screen__content {
  max-height: 100%;
  padding: 12px;
  overflow: auto;
  font-size: 13px;
}

.screen:not(#menuScreen) h2 {
  margin-bottom: 6px;
  font-size: clamp(24px, 5vw, 32px);
}

.screen:not(#menuScreen) .screen-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-items: stretch;
  gap: 6px;
  margin-top: 8px;
}

#optionsScreen .screen-actions {
  grid-template-columns: 1fr;
}

#pauseMenuButton {
  grid-column: 2;
}

.screen:not(#menuScreen) .screen-actions button,
.instructions-footer button {
  min-width: 0;
  min-height: 44px;
  padding: 4px;
  font-size: 12px;
}

.screen .settings-toggle {
  justify-content: center;
  margin: 6px 0;
}

#pauseScreen [data-input-help] {
  margin: 0;
}

.game-over-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 8px 0;
}

.game-over-stats strong {
  display: block;
}

#instructionsScreen .instructions-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.instructions-body {
  min-height: 0;
  overflow: auto;
  padding: 4px;
  overscroll-behavior: contain;
}

.instructions-body > p {
  margin: 0 0 6px;
}

.instructions-body .controls-grid {
  grid-template-columns: minmax(60px, auto) 1fr minmax(22px, auto) 1fr;
  gap: 4px;
  margin-bottom: 6px;
}

.instructions-body .controls-grid span {
  min-height: 24px;
  padding: 2px 4px;
}

.instructions-body .instructions-notes {
  gap: 4px;
  margin: 6px 0;
  padding: 6px;
}

.instructions-footer {
  display: flex;
  flex: none;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.instructions-footer .instructions-countdown {
  margin: 0;
  padding: 4px 8px;
  font-size: 15px;
}

.instructions-footer button {
  width: 100px;
}

@keyframes feedback-fade {
  to {
    opacity: 0;
  }
}
