:root {
  --app-width: 100vw;
  --app-height: 100dvh;
  --app-top: 0px;
  --aero-cyan: #72e4f2;
  --aero-blue: #1989c7;
  --aero-deep: #125b88;
  --aero-lime: #7ed321;
  --aero-leaf: #4ba90d;
  --aero-white: #f8ffff;
  --aero-ice: #dffcff;
  --aero-ink: #29434e;
  --aero-pink: #ff4fa0;
  --glass: rgba(239, 255, 255, 0.72);
  --glass-strong: rgba(250, 255, 255, 0.9);
  --shadow: 0 18px 50px rgba(15, 91, 122, 0.22);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

body {
  color: var(--aero-ink);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  background: #ccf7ff;
  width: var(--app-width);
  height: var(--app-height);
  min-height: 0;
}

button {
  font: inherit;
}

.hidden {
  display: none !important;
}

/* Compatibilidad con HTML antiguo almacenado por Safari, WhatsApp o Instagram. */
#rotate-device,
.rotate-device,
.rotate-phone {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.aero-background {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(244, 255, 255, 0.04), rgba(65, 210, 237, 0.17)),
    url("assets/images/diamad.webp") center / cover no-repeat;
}

.aero-background::before {
  content: "";
  position: absolute;
  inset: 0;
  display: none;
  background: url("assets/images/diamad.webp") center / contain no-repeat;
  pointer-events: none;
}

.aero-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 45%, transparent 20%, rgba(41, 154, 183, 0.16) 100%),
    linear-gradient(115deg, rgba(255,255,255,0.15), transparent 45%, rgba(103, 237, 255, 0.14));
  backdrop-filter: saturate(1.1);
  pointer-events: none;
}

.signal-field {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  contain: strict;
}

.frequency-signal {
  position: absolute;
  left: var(--signal-x);
  top: var(--signal-y);
  color: rgba(15, 112, 113, 0.62);
  font-family: Consolas, "Courier New", monospace;
  font-size: var(--signal-size);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-shadow: 0 0 7px rgba(101, 255, 218, 0.7);
  opacity: 0;
  will-change: transform, opacity;
  animation: signalDrift var(--signal-speed) linear infinite;
  animation-delay: var(--signal-delay);
}

@keyframes signalDrift {
  0% { opacity: 0; transform: translate3d(0, 45px, 0); }
  14% { opacity: 0.72; }
  52% { opacity: 0.3; transform: translate3d(var(--signal-sway), -20px, 0); }
  82% { opacity: 0.62; }
  100% { opacity: 0; transform: translate3d(calc(var(--signal-sway) * -0.4), -105px, 0); }
}

.aero-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(10px);
  opacity: 0.55;
  animation: floatGlow 13s ease-in-out infinite alternate;
}

.aero-glow-one {
  width: 42vw;
  height: 42vw;
  left: -14vw;
  top: -18vw;
  background: radial-gradient(circle at 65% 65%, rgba(255,255,255,0.9), rgba(110,232,247,0.3) 45%, transparent 72%);
}

.aero-glow-two {
  width: 36vw;
  height: 36vw;
  right: -12vw;
  bottom: -18vw;
  background: radial-gradient(circle at 35% 35%, rgba(223,255,181,0.8), rgba(126,211,33,0.25) 45%, transparent 72%);
  animation-delay: -4s;
}

.aero-bubbles {
  position: absolute;
  inset: 0;
  opacity: 0.45;
  background-image:
    radial-gradient(circle at 18% 73%, rgba(255,255,255,0.9) 0 5px, transparent 6px),
    radial-gradient(circle at 84% 22%, rgba(255,255,255,0.85) 0 8px, transparent 9px),
    radial-gradient(circle at 75% 72%, rgba(125,224,238,0.7) 0 13px, transparent 14px),
    radial-gradient(circle at 28% 24%, rgba(255,255,255,0.7) 0 3px, transparent 4px);
  animation: bubbleDrift 22s linear infinite alternate;
}

@keyframes floatGlow {
  to { transform: translate3d(5vw, 3vh, 0) scale(1.08); }
}

@keyframes bubbleDrift {
  to { transform: translateY(-26px); }
}

#game-shell {
  position: relative;
  z-index: 2;
  width: var(--app-width);
  height: var(--app-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 84px 24px 122px;
}

.console-toolbar {
  display: none;
}

#hud {
  position: absolute;
  z-index: 20;
  top: 20px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  pointer-events: none;
}

.hud-cluster {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.glass-pill,
.glass-panel {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.95);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.95), rgba(218,249,252,0.68) 52%, rgba(168,232,239,0.7));
  box-shadow:
    0 8px 24px rgba(15, 93, 126, 0.18),
    inset 0 1px 0 #fff,
    inset 0 -1px 0 rgba(22, 137, 199, 0.28);
  backdrop-filter: blur(14px) saturate(1.25);
}

.glass-pill::before,
.glass-panel::before {
  content: "";
  position: absolute;
  pointer-events: none;
  inset: 3px 5px auto;
  height: 42%;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.8), transparent);
  opacity: 0.68;
}

.glass-pill {
  min-height: 48px;
  border-radius: 16px 16px 20px 20px;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hud-label,
.room-kicker,
.track-eyebrow {
  position: relative;
  z-index: 1;
  color: var(--aero-deep);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.7px;
}

.hud-value {
  position: relative;
  z-index: 1;
  color: #246378;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1px;
  white-space: nowrap;
  text-shadow: 0 1px 0 #fff;
}

.hud-life .hud-value {
  color: #5ab710;
}

.room-pill {
  align-items: flex-end;
  text-align: right;
  min-width: 210px;
}

#zone-title {
  position: relative;
  z-index: 1;
  color: #315f70;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.9px;
}

#screen-frame {
  position: relative;
  width: min(92vw, 960px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.96);
  border-radius: 24px 24px 30px 30px;
  background: rgba(212, 250, 255, 0.5);
  box-shadow:
    0 28px 70px rgba(9, 73, 105, 0.28),
    0 0 0 5px rgba(49, 183, 207, 0.25),
    0 0 0 8px rgba(255, 255, 255, 0.5),
    inset 0 1px 0 #fff;
  backdrop-filter: blur(9px) saturate(1.15);
}

#screen-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  border-radius: inherit;
  box-shadow:
    inset 0 0 28px rgba(25, 137, 199, 0.18),
    inset 0 -20px 45px rgba(22, 94, 125, 0.08);
}

.screen-shine {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 5%;
  width: 64%;
  height: 28%;
  pointer-events: none;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.28), transparent);
  transform: rotate(-4deg);
}

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

#game-toast {
  position: absolute;
  z-index: 15;
  top: 18px;
  left: 50%;
  min-width: 230px;
  max-width: 80%;
  padding: 10px 18px;
  border: 1px solid rgba(255,255,255,0.95);
  border-radius: 18px;
  color: #23566a;
  background: rgba(242,255,255,0.9);
  box-shadow: 0 10px 30px rgba(23, 104, 137, 0.2), inset 0 1px #fff;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.5px;
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: 180ms ease;
  pointer-events: none;
}

#game-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.interaction-hint {
  position: absolute;
  z-index: 14;
  bottom: 18px;
  left: 50%;
  padding: 7px 14px;
  transform: translateX(-50%);
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: 14px;
  color: #245b70;
  background: rgba(238,255,255,0.87);
  box-shadow: 0 6px 18px rgba(20, 99, 131, 0.18);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.4px;
}

#touch-controls {
  position: absolute;
  z-index: 20;
  left: 26px;
  right: 26px;
  bottom: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}

#dpad {
  position: relative;
  width: 148px;
  height: 148px;
  display: block;
  padding: 7px;
  overflow: visible;
  border-radius: 50%;
  opacity: 0.88;
  pointer-events: auto;
  touch-action: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

#dpad.joystick-active {
  opacity: 1;
  transform: scale(1.025);
}

.control-button {
  position: absolute;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  color: #35758a;
  background: rgba(255,255,255,0.26);
  font-size: 17px;
  font-weight: 900;
  pointer-events: none;
}

.control-button:active,
.control-button.active {
  color: white;
  background: linear-gradient(180deg, #84e831, #4eaa0f);
  box-shadow: inset 0 2px 5px rgba(34, 92, 4, 0.3);
}

.dpad-up { top: 5px; left: 50%; transform: translateX(-50%); }
.dpad-left { top: 50%; left: 5px; transform: translateY(-50%); }
.dpad-right { top: 50%; right: 5px; transform: translateY(-50%); }
.dpad-down { bottom: 5px; left: 50%; transform: translateX(-50%); }

.dpad-center {
  position: absolute;
  z-index: 3;
  top: calc(50% - 24px);
  left: calc(50% - 24px);
  width: 48px;
  height: 48px;
  border: 2px solid rgba(255,255,255,0.9);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,0.92), rgba(91,201,220,0.82) 52%, rgba(29,125,166,0.82));
  box-shadow:
    0 7px 15px rgba(22,91,122,0.28),
    inset 0 2px 3px rgba(255,255,255,0.7);
  pointer-events: none;
  transition: transform 45ms linear;
  will-change: transform;
}

.action-controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  pointer-events: auto;
}

.action-button {
  width: 70px;
  height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.95);
  border-radius: 50%;
  color: white;
  cursor: pointer;
  box-shadow:
    0 9px 24px rgba(17, 100, 129, 0.24),
    inset 0 3px 4px rgba(255,255,255,0.68),
    inset 0 -5px 8px rgba(24, 98, 131, 0.18);
  transition: transform 100ms ease, filter 100ms ease;
  opacity: 0.8;
}

.action-button span {
  font-size: 23px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.action-button small {
  margin-top: 2px;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.7px;
}

.attack-button {
  background: radial-gradient(circle at 34% 25%, #d8ff9f 0, #82df2e 38%, #50a810 78%);
}

.interact-button {
  width: 62px;
  height: 62px;
  background: radial-gradient(circle at 34% 25%, #c7f8ff 0, #51c9e5 42%, #1686bc 82%);
}

.action-button:active,
.action-button.active {
  transform: scale(0.9);
  filter: brightness(1.08);
  opacity: 1;
}

.now-playing {
  position: absolute;
  z-index: 22;
  left: 50%;
  bottom: 22px;
  width: min(560px, 60vw);
  min-height: 64px;
  padding: 8px 40px 8px 8px;
  display: grid;
  grid-template-columns: 48px minmax(120px, 1fr) minmax(150px, 0.9fr);
  grid-template-rows: auto auto;
  align-items: center;
  gap: 5px 10px;
  border-radius: 22px;
  transform: translateX(-50%);
  transition:
    width 180ms ease,
    min-height 180ms ease,
    padding 180ms ease,
    border-radius 180ms ease;
}

.player-collapse {
  position: absolute;
  z-index: 4;
  top: 7px;
  right: 8px;
  width: 27px;
  height: 27px;
  border: 1px solid rgba(255,255,255,0.95);
  border-radius: 50%;
  color: #286c81;
  background: rgba(255,255,255,0.7);
  box-shadow: inset 0 1px white, 0 2px 7px rgba(27,102,129,0.16);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

.now-playing.collapsed {
  width: min(250px, 58vw);
  min-height: 48px;
  padding: 5px 38px 5px 5px;
  grid-template-columns: 38px minmax(0, 1fr);
  grid-template-rows: 38px;
  gap: 7px;
  border-radius: 17px;
}

.now-playing.collapsed .mini-disc {
  width: 38px;
  height: 38px;
  grid-row: 1;
}

.now-playing.collapsed .track-copy {
  grid-column: 2;
  grid-row: 1;
}

.now-playing.collapsed .track-time,
.now-playing.collapsed .player-controls,
.now-playing.collapsed #track-status {
  display: none;
}

.now-playing.collapsed .track-eyebrow {
  font-size: 7px;
}

.now-playing.collapsed .track-copy strong {
  font-size: 10px;
}

.now-playing.collapsed .player-collapse {
  top: 50%;
  transform: translateY(-50%);
}

.mini-disc {
  position: relative;
  z-index: 2;
  width: 48px;
  height: 48px;
  border: 2px solid white;
  border-radius: 50%;
  color: white;
  background:
    radial-gradient(circle, #fff 0 8%, #1e8ebc 9% 18%, transparent 19%),
    conic-gradient(from 30deg, #72e4f2, #8ddd28, #f8ffff, #4fbde0, #72e4f2);
  box-shadow: 0 5px 12px rgba(22,107,142,0.22), inset 0 0 8px rgba(255,255,255,0.8);
  cursor: pointer;
  grid-row: 1 / 3;
}

.track-copy {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.track-copy strong {
  overflow: hidden;
  color: #285e72;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#track-status {
  color: #5a8492;
  font-size: 9px;
}

.track-time {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  color: #477787;
  font-size: 8px;
  font-weight: 800;
}

.progress-track {
  width: 100%;
  height: 16px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  touch-action: pan-x;
}

.progress-track::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 5px;
  background:
    linear-gradient(90deg, var(--aero-blue), var(--aero-lime)) 0 / var(--seek-progress, 0%) 100% no-repeat,
    rgba(25,137,199,0.18);
  box-shadow: inset 0 1px 2px rgba(28,91,116,0.2);
}

.progress-track::-moz-range-track {
  height: 5px;
  border-radius: 5px;
  background: rgba(25,137,199,0.18);
}

.progress-track::-moz-range-progress {
  height: 5px;
  background: linear-gradient(90deg, var(--aero-blue), var(--aero-lime));
  border-radius: 5px;
}

.progress-track::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -4.5px;
  border: 2px solid white;
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: #61c91b;
  box-shadow: 0 2px 7px rgba(22, 109, 137, 0.35);
}

.progress-track::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 2px solid white;
  border-radius: 50%;
  background: #61c91b;
}

.player-controls {
  position: relative;
  z-index: 2;
  grid-column: 2 / 4;
  display: grid;
  grid-template-columns: repeat(5, minmax(34px, 1fr));
  gap: 5px;
}

.player-controls button {
  min-height: 24px;
  border: 1px solid rgba(255,255,255,0.94);
  border-radius: 9px;
  color: #27677c;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(170,235,241,0.7));
  box-shadow: inset 0 1px white, 0 2px 5px rgba(31,100,127,0.15);
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
}

.player-controls button:active {
  transform: translateY(1px);
  filter: brightness(1.05);
}

.modal-layer {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(197, 247, 251, 0.36);
  backdrop-filter: blur(18px) saturate(1.15);
}

.modal-window {
  position: relative;
  width: min(520px, 92vw);
  overflow: hidden;
  padding: 34px 38px;
  border: 2px solid rgba(255,255,255,0.98);
  border-radius: 34px 34px 42px 42px;
  text-align: center;
  background:
    linear-gradient(155deg, rgba(255,255,255,0.96), rgba(218,251,254,0.86) 55%, rgba(142,226,236,0.74));
  box-shadow:
    0 30px 90px rgba(12, 92, 125, 0.3),
    0 0 0 7px rgba(82, 194, 215, 0.22),
    inset 0 2px 0 #fff,
    inset 0 -2px 0 rgba(17,132,177,0.2);
}

.modal-window::before {
  content: "";
  position: absolute;
  top: -55%;
  left: -10%;
  width: 120%;
  height: 80%;
  border-radius: 50%;
  background: rgba(255,255,255,0.55);
  transform: rotate(-5deg);
  pointer-events: none;
}

.modal-window > * {
  position: relative;
  z-index: 2;
}

.modal-close-button {
  position: absolute;
  z-index: 12;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,0.96);
  border-radius: 50%;
  color: #286a7e;
  background: rgba(255,255,255,0.86);
  box-shadow: inset 0 1px white, 0 4px 12px rgba(25,101,130,0.18);
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
}

.brand-orbit {
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border: 3px solid rgba(255,255,255,0.95);
  border-radius: 50%;
  background: conic-gradient(from 35deg, #7ed321, #e5ffba, #4ec8e6, #1989c7, #7ed321);
  box-shadow: 0 12px 26px rgba(25,137,199,0.25), inset 0 0 15px rgba(255,255,255,0.8);
  animation: orbitPulse 3.4s ease-in-out infinite;
}

.brand-core {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 2px solid white;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #65c514, #218fc5);
  font-size: 23px;
  font-weight: 900;
  box-shadow: inset 0 2px 6px rgba(255,255,255,0.5);
}

@keyframes orbitPulse {
  50% { transform: rotate(8deg) scale(1.035); }
}

.modal-kicker {
  color: var(--aero-deep);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2.5px;
}

.modal-window h1 {
  margin: 5px 0 2px;
  color: #29677b;
  font-size: clamp(38px, 7vw, 62px);
  line-height: 0.82;
  letter-spacing: -3px;
  text-shadow: 0 2px 0 white, 0 6px 20px rgba(21, 118, 154, 0.2);
}

.modal-window h1 span {
  color: var(--aero-lime);
  font-size: 0.78em;
  letter-spacing: 2px;
}

.modal-window h2 {
  margin: 8px 0 10px;
  color: #2e687a;
  font-size: 28px;
  line-height: 1.05;
}

.modal-subtitle {
  margin-top: 7px;
  color: #4f8291;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 2px;
}

.in-app-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  align-items: center;
  border: 1px solid rgba(255,255,255,0.96);
  border-radius: 15px;
  color: #3d7181;
  background: rgba(255,255,255,0.58);
  box-shadow: inset 0 1px white;
  text-align: left;
}

.in-app-note strong {
  color: var(--aero-blue);
  font-size: 9px;
  letter-spacing: 1.2px;
}

.in-app-note span {
  grid-column: 1;
  font-size: 8px;
  line-height: 1.25;
}

.in-app-note button {
  grid-column: 2;
  grid-row: 1 / 3;
  padding: 8px 10px;
  border: 1px solid white;
  border-radius: 10px;
  color: white;
  background: linear-gradient(180deg, #55cbe4, #1688bb);
  box-shadow: inset 0 1px rgba(255,255,255,0.6);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.7px;
}

.controls-card {
  margin: 22px 0 16px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  border: 1px solid rgba(255,255,255,0.95);
  border-radius: 20px;
  background: rgba(255,255,255,0.47);
  box-shadow: inset 0 1px 0 white;
  text-align: left;
}

.controls-card > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.controls-card strong {
  margin-bottom: 3px;
  color: var(--aero-blue);
  font-size: 9px;
  letter-spacing: 1.4px;
}

.controls-card span {
  color: #527885;
  font-size: 10px;
}

.primary-button,
.secondary-button {
  min-width: 190px;
  margin-top: 8px;
  padding: 13px 26px;
  border: 2px solid white;
  border-radius: 22px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.2px;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.primary-button {
  color: white;
  background: linear-gradient(180deg, #9bed4b 0%, #6ac51f 48%, #49a40c 100%);
  box-shadow:
    0 9px 22px rgba(68, 159, 9, 0.24),
    inset 0 3px 4px rgba(255,255,255,0.48),
    inset 0 -4px 6px rgba(40,112,5,0.18);
  text-shadow: 0 1px 1px rgba(35,94,8,0.32);
}

.primary-button:disabled {
  cursor: wait;
  filter: grayscale(0.6);
  opacity: 0.62;
}

.secondary-button {
  color: #397387;
  background: rgba(255,255,255,0.63);
  box-shadow: 0 6px 16px rgba(16,97,130,0.13), inset 0 2px 2px white;
}

.primary-button:not(:disabled):hover,
.secondary-button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px) scale(1.015);
}

.primary-button:not(:disabled):active,
.secondary-button:active {
  transform: translateY(1px) scale(0.98);
}

.load-status {
  min-height: 12px;
  margin-top: 9px;
  color: #678a95;
  font-size: 9px;
}

.compact-window {
  width: min(430px, 92vw);
}

.danger-window {
  background: linear-gradient(155deg, rgba(255,255,255,0.96), rgba(255,222,237,0.9), rgba(255,151,195,0.76));
}

.danger-window h2 {
  color: #c22d72;
}

.danger-button {
  background: linear-gradient(180deg, #ff7eb8, #ef3e8d 55%, #bd1d65);
  box-shadow: 0 9px 22px rgba(184,24,97,0.25), inset 0 3px 4px rgba(255,255,255,0.4);
}

.large-disc {
  width: 110px;
  height: 110px;
  display: grid;
  place-items: center;
  margin: 0 auto 15px;
  border: 3px solid white;
  border-radius: 50%;
  background:
    radial-gradient(circle, #fff 0 8%, #278cb7 9% 17%, transparent 18%),
    conic-gradient(from 20deg, #72e4f2, #fff, #8de338, #1a90c7, #d8fbff, #72e4f2);
  box-shadow: 0 15px 30px rgba(24,125,160,0.25), inset 0 0 16px white;
  animation: discSpin 7s linear infinite;
}

.large-disc span {
  color: transparent;
}

@keyframes discSpin {
  to { transform: rotate(360deg); }
}

.event-card {
  margin: 20px auto 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid white;
  border-radius: 22px;
  color: #397183;
  background: rgba(255,255,255,0.5);
}

.event-card strong {
  color: var(--aero-lime);
  font-size: 21px;
}

.event-card span {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.5px;
}

.reveal-presenter {
  margin: 5px 0 2px;
  color: #56818d;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.8px;
}

.finale-window {
  background:
    linear-gradient(155deg, rgba(255,255,255,0.96), rgba(224,255,244,0.88) 48%, rgba(166,235,116,0.7));
}

.credits-window {
  width: min(720px, 94vw);
  max-height: min(88dvh, 720px);
  background:
    linear-gradient(155deg, rgba(255,255,255,0.97), rgba(218,253,250,0.92) 48%, rgba(139,229,188,0.78));
}

.credits-intro,
.credits-signoff {
  color: #477787;
  font-size: 11px;
  font-weight: 800;
}

.credits-list {
  max-height: min(46dvh, 370px);
  margin: 16px 0;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  user-select: text;
  -webkit-user-select: text;
}

.credits-list article {
  min-height: 74px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: 16px;
  background: rgba(255,255,255,0.5);
  box-shadow: inset 0 1px white;
}

.credits-list strong {
  color: #25667b;
  font-size: 12px;
}

.credits-list span {
  color: #56818d;
  font-size: 9px;
  line-height: 1.35;
}

@media (hover: hover) and (pointer: fine) {
  #touch-controls {
    opacity: 0.22;
    transition: opacity 180ms ease;
  }

  #touch-controls:hover {
    opacity: 1;
  }
}

@media (max-width: 760px) {
  #game-shell {
    padding: 74px 10px 132px;
  }

  #hud {
    top: 10px;
    left: 10px;
    right: 10px;
    gap: 8px;
  }

  .glass-pill {
    min-height: 39px;
    padding: 6px 9px;
    border-radius: 13px 13px 16px 16px;
  }

  .hud-cluster {
    gap: 5px;
  }

  .hud-label,
  .room-kicker {
    font-size: 7px;
    letter-spacing: 1px;
  }

  .hud-value {
    font-size: 11px;
  }

  .room-pill {
    min-width: 124px;
  }

  #zone-title {
    max-width: 145px;
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #screen-frame {
    width: 96vw;
    border-radius: 17px 17px 22px 22px;
  }

  #touch-controls {
    left: 12px;
    right: 12px;
    bottom: 15px;
  }

  #dpad {
    width: 144px;
    height: 144px;
  }

  .action-button {
    width: 62px;
    height: 62px;
  }

  .interact-button {
    width: 56px;
    height: 56px;
  }

  .now-playing {
    bottom: 111px;
    width: min(94vw, 520px);
    grid-template-columns: 42px 1fr;
  }

  .now-playing.collapsed {
    top: 8px;
    bottom: auto;
    width: min(240px, 58vw);
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .track-time {
    grid-column: 1 / -1;
    padding: 0 5px 3px;
  }

  .player-controls {
    grid-column: 1 / -1;
  }

  .mini-disc {
    width: 42px;
    height: 42px;
  }

  .modal-window {
    padding: 26px 22px;
  }

  .credits-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .aero-background::before {
    display: block;
  }

  .aero-background::after,
  .glass-pill,
  .glass-panel,
  #screen-frame {
    backdrop-filter: none;
  }

  .aero-glow,
  .aero-bubbles,
  .screen-shine {
    display: none;
  }

  .frequency-signal {
    text-shadow: none;
  }

  #touch-controls {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

/* Consola portátil: evita depender del giro de pantalla en Instagram/Safari. */
@media (orientation: portrait) and (max-width: 1100px) {
  body {
    min-height: 100svh;
  }

  #game-shell {
    width: 100vw;
    height: 100svh;
    min-height: 560px;
    display: block;
    padding: 0;
  }

  #game-shell::before {
    content: "DIAMA GAMES";
    position: absolute;
    z-index: 2;
    left: 50%;
    top: clamp(78px, 11.5svh, 116px);
    width: min(94vw, 760px);
    height: clamp(285px, 43svh, 470px);
    transform: translateX(-50%);
    border: 1px solid rgba(255,255,255,0.74);
    border-radius: 26px 26px 54px 54px;
    color: rgba(35,105,125,0.5);
    background: linear-gradient(165deg, rgba(244,255,255,0.62), rgba(119,218,233,0.24));
    box-shadow: 0 22px 55px rgba(13,91,122,0.18), inset 0 2px 0 rgba(255,255,255,0.8);
    padding: 8px 16px;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 2px;
    pointer-events: none;
  }

  #hud {
    top: max(8px, env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    align-items: flex-start;
    gap: 5px;
  }

  .hud-cluster {
    max-width: 72%;
    gap: 4px;
  }

  .glass-pill {
    min-height: 31px;
    padding: 3px 7px;
    border-radius: 11px 11px 14px 14px;
  }

  .hud-label,
  .room-kicker {
    font-size: 6px;
    letter-spacing: .7px;
  }

  .hud-value {
    font-size: 9px;
  }

  .room-pill {
    min-width: 104px;
    max-width: 28%;
  }

  #zone-title {
    max-width: 120px;
    overflow: hidden;
    font-size: 7px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #screen-frame {
    position: absolute;
    z-index: 5;
    top: clamp(104px, 15svh, 150px);
    left: 50%;
    width: min(94vw, 760px);
    transform: translateX(-50%);
    border-radius: 16px 16px 21px 21px;
  }

  #touch-controls {
    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    height: clamp(145px, 20svh, 190px);
    align-items: center;
  }

  #dpad {
    width: clamp(142px, 38vw, 180px);
    height: clamp(142px, 38vw, 180px);
    opacity: .94;
  }

  .action-controls {
    gap: clamp(10px, 3vw, 22px);
    transform: rotate(-8deg);
  }

  .action-button {
    width: clamp(68px, 18vw, 86px);
    height: clamp(68px, 18vw, 86px);
    opacity: .9;
  }

  .interact-button {
    width: clamp(62px, 16vw, 78px);
    height: clamp(62px, 16vw, 78px);
    transform: translateY(22px);
  }

  .action-button:active,
  .action-button.active {
    transform: scale(.92);
  }

  .interact-button:active,
  .interact-button.active {
    transform: translateY(22px) scale(.92);
  }

  .now-playing,
  .now-playing.collapsed {
    top: auto;
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + clamp(150px, 21svh, 200px));
    width: min(92vw, 520px);
  }

  .now-playing.collapsed {
    width: min(235px, 62vw);
  }

  .modal-layer {
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  }

  .modal-window {
    width: min(92vw, 520px);
    max-height: calc(100svh - 20px);
    padding: 22px 18px;
    overflow-y: auto;
  }

  .start-window .brand-orbit {
    width: 64px;
    height: 64px;
    margin-bottom: 7px;
  }

  .start-window .brand-core {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .start-window h1 {
    font-size: clamp(34px, 11vw, 52px);
  }

  .controls-card {
    margin: 13px 0 10px;
    padding: 10px;
    gap: 8px;
  }

  .credits-window {
    max-height: calc(100svh - 20px);
  }
}

@media (orientation: portrait) and (max-width: 430px) and (max-height: 700px) {
  #screen-frame {
    top: 88px;
  }

  #game-shell::before {
    top: 66px;
    height: 280px;
  }

  #dpad {
    width: 132px;
    height: 132px;
  }

  .action-button {
    width: 62px;
    height: 62px;
  }

  .interact-button {
    width: 58px;
    height: 58px;
  }
}

@media (max-height: 570px) and (orientation: landscape) {
  #game-shell {
    padding: 42px 4px 6px;
  }

  #screen-frame {
    width: min(60vw, 760px);
  }

  #hud {
    top: 4px;
    left: 8px;
    right: 8px;
  }

  .glass-pill {
    min-height: 31px;
    padding: 3px 7px;
  }

  .hud-cluster {
    gap: 4px;
  }

  .hud-label,
  .room-kicker {
    font-size: 6px;
    letter-spacing: 0.8px;
  }

  .hud-value {
    font-size: 10px;
  }

  .room-pill {
    min-width: 116px;
  }

  #zone-title {
    max-width: 135px;
    font-size: 8px;
  }

  #touch-controls {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  #dpad {
    width: 138px;
    height: 138px;
  }

  .action-button {
    width: 61px;
    height: 61px;
  }

  .interact-button {
    width: 56px;
    height: 56px;
  }

  .now-playing {
    bottom: 8px;
    width: min(470px, 55vw);
    min-height: 54px;
    padding-block: 5px;
  }

  .now-playing.collapsed {
    top: 7px;
    bottom: auto;
    width: min(235px, 42vw);
    min-height: 48px;
    padding: 5px 38px 5px 5px;
  }

  .start-window {
    transform: scale(0.78);
  }

  .credits-window {
    width: min(760px, 96vw);
    max-height: calc(100dvh - 10px);
    padding: 10px 14px;
    overflow-y: auto;
    border-radius: 22px 22px 28px 28px;
  }

  .credits-window .modal-kicker {
    margin-bottom: 2px;
    font-size: 7px;
  }

  .credits-window h2 {
    margin-bottom: 3px;
    font-size: 18px;
    line-height: 0.95;
  }

  .credits-intro,
  .credits-signoff {
    display: none;
  }

  .credits-list {
    max-height: none;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    margin: 5px 0 6px;
    padding: 3px;
    overflow: visible;
  }

  .credits-list article {
    min-height: 58px;
    padding: 5px 6px;
    border-radius: 10px;
  }

  .credits-list strong {
    font-size: 8px;
  }

  .credits-list span {
    font-size: 6.5px;
    line-height: 1.18;
  }

  .credits-window .primary-button {
    min-height: 30px;
    margin-top: 0;
    padding: 6px 16px;
    font-size: 9px;
  }

  .credits-window .modal-close-button {
    position: sticky;
    top: 0;
    float: right;
    width: 30px;
    height: 30px;
    margin: 0 0 -30px;
    font-size: 20px;
  }
}

/* ============================================================
   Consola táctil adaptable · iPhone, iPad y WebViews de Instagram
   ============================================================ */

body.touch-layout #game-shell {
  position: fixed;
  inset: var(--app-top) auto auto 0;
  min-width: 0;
  min-height: 0;
}

body.touch-layout #game-shell::before {
  content: "";
  position: absolute;
  z-index: 0;
  border: 1px solid rgba(255,255,255,0.78);
  background: linear-gradient(145deg, rgba(239,255,255,0.3), rgba(89,202,222,0.13));
  box-shadow: inset 0 1px rgba(255,255,255,0.82), 0 16px 45px rgba(19,105,136,0.12);
  pointer-events: none;
}

body.touch-layout #screen-frame {
  z-index: 2;
  flex: 0 0 auto;
}

body.touch-layout #touch-controls {
  inset: 0;
  padding: 0;
}

body.touch-layout #dpad {
  position: absolute;
  margin: 0;
  opacity: 0.94;
}

body.touch-layout .action-controls {
  position: absolute;
  margin: 0;
}

body.touch-layout .console-toolbar {
  position: absolute;
  z-index: 21;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  color: rgba(39,103,123,0.86);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 1.5px;
  white-space: nowrap;
}

body.touch-layout .console-brand {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

body.touch-layout .console-brand strong {
  color: #2b7084;
  font-size: 15px;
  letter-spacing: -0.5px;
  text-shadow: 0 1px rgba(255,255,255,0.9);
}

body.touch-layout .console-brand small {
  color: rgba(39,103,123,0.68);
  font-size: 6px;
  letter-spacing: 1.2px;
}

body.touch-layout .console-toolbar button {
  padding: 5px 9px;
  border: 1px solid rgba(255,255,255,0.94);
  border-radius: 10px;
  color: #2b6c80;
  background: rgba(242,255,255,0.72);
  box-shadow: inset 0 1px white, 0 3px 9px rgba(26,105,134,0.12);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.6px;
}

body.touch-layout .modal-layer {
  inset: var(--app-top) auto auto 0;
  width: var(--app-width);
  height: var(--app-height);
  padding: 8px;
}

body.touch-layout .modal-window {
  max-height: calc(var(--app-height) - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: none;
}

@media (orientation: landscape) {
  body.touch-layout #game-shell {
    padding: 42px max(6px, env(safe-area-inset-right)) 30px max(6px, env(safe-area-inset-left));
  }

  body.touch-layout #game-shell::before {
    inset: 35px max(4px, env(safe-area-inset-right)) 4px max(4px, env(safe-area-inset-left));
    border-radius: 44px 44px 54px 54px;
  }

  body.touch-layout #screen-frame {
    width: min(
      60vw,
      calc(var(--app-width) - 260px),
      calc((var(--app-height) - 76px) * 1.7778),
      780px
    );
    max-height: calc(var(--app-height) - 76px);
    border-radius: 16px 16px 20px 20px;
  }

  body.touch-layout #dpad {
    left: max(10px, env(safe-area-inset-left));
    top: 53%;
    width: clamp(112px, 16vw, 148px);
    height: clamp(112px, 16vw, 148px);
    transform: translateY(-50%);
  }

  body.touch-layout #dpad.joystick-active {
    transform: translateY(-50%) scale(1.025);
  }

  body.touch-layout .action-controls {
    right: max(10px, env(safe-area-inset-right));
    top: 53%;
    gap: clamp(7px, 1.3vw, 13px);
    transform: translateY(-50%);
  }

  body.touch-layout .action-button {
    width: clamp(56px, 7.6vw, 72px);
    height: clamp(56px, 7.6vw, 72px);
  }

  body.touch-layout .interact-button {
    width: clamp(52px, 6.9vw, 64px);
    height: clamp(52px, 6.9vw, 64px);
  }

  body.touch-layout .console-toolbar {
    bottom: max(6px, env(safe-area-inset-bottom));
  }

  body.touch-layout .now-playing.collapsed {
    top: 4px;
    bottom: auto;
    width: min(214px, 30vw);
    min-height: 36px;
    padding: 3px 30px 3px 3px;
    grid-template-columns: 30px minmax(0, 1fr);
    grid-template-rows: 30px;
  }

  body.touch-layout .now-playing.collapsed .mini-disc {
    width: 30px;
    height: 30px;
  }
}

@media (orientation: portrait) {
  body.touch-layout #game-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px 10px 190px;
  }

  body.touch-layout #game-shell::before {
    inset: auto 6px 7px;
    width: auto;
    height: 176px;
    transform: none;
    border-radius: 34px 34px 44px 44px;
    background:
      radial-gradient(circle at 50% 15%, rgba(255,255,255,0.62), transparent 40%),
      linear-gradient(145deg, rgba(239,255,255,0.72), rgba(89,202,222,0.3));
  }

  body.touch-layout #screen-frame {
    position: relative;
    top: auto;
    left: auto;
    width: min(94vw, calc((var(--app-height) - 270px) * 1.7778), 720px);
    max-height: calc(var(--app-height) - 270px);
    transform: none;
    border-radius: 16px 16px 20px 20px;
  }

  body.touch-layout #dpad {
    top: auto;
    left: 13px;
    left: calc(13px + env(safe-area-inset-left, 0px));
    bottom: 15px;
    bottom: calc(15px + env(safe-area-inset-bottom, 0px));
    width: 132px;
    height: 132px;
  }

  body.touch-layout .action-controls {
    top: auto;
    right: 13px;
    right: calc(13px + env(safe-area-inset-right, 0px));
    bottom: 25px;
    bottom: calc(25px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
  }

  body.touch-layout .action-button {
    width: 64px;
    height: 64px;
  }

  body.touch-layout .interact-button {
    width: 58px;
    height: 58px;
  }

  body.touch-layout .console-toolbar {
    top: auto;
    bottom: 57px;
    bottom: calc(57px + env(safe-area-inset-bottom, 0px));
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
  }

  body.touch-layout .now-playing,
  body.touch-layout .now-playing.collapsed {
    top: auto;
    bottom: max(
      clamp(132px, calc(var(--app-height) * 0.22), 191px),
      calc(env(safe-area-inset-bottom) + 122px)
    );
  }

  body.touch-layout .now-playing.collapsed {
    width: min(225px, 58vw);
  }

  body.touch-layout .credits-list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (orientation: portrait) and (min-width: 600px) {
  body.touch-layout #game-shell::before {
    height: 220px;
  }

  body.touch-layout #dpad {
    width: 188px;
    height: 188px;
  }

  body.touch-layout .action-button {
    width: 86px;
    height: 86px;
  }

  body.touch-layout .interact-button {
    width: 78px;
    height: 78px;
  }

  body.touch-layout .console-toolbar {
    bottom: 78px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }
}

body.touch-layout.compact-landscape #hud {
  top: 3px;
  left: max(7px, env(safe-area-inset-left));
  right: max(7px, env(safe-area-inset-right));
}

body.touch-layout.compact-landscape .start-window {
  width: min(640px, calc(var(--app-width) - 16px));
  max-height: calc(var(--app-height) - 10px);
  padding: 7px 18px;
  border-radius: 22px 22px 28px 28px;
}

body.touch-layout.compact-landscape .start-window .brand-orbit {
  width: 42px;
  height: 42px;
  margin-bottom: 2px;
}

body.touch-layout.compact-landscape .start-window .brand-core {
  width: 29px;
  height: 29px;
  font-size: 13px;
}

body.touch-layout.compact-landscape .start-window h1 {
  margin: 1px 0;
  font-size: 27px;
  letter-spacing: -1px;
}

body.touch-layout.compact-landscape .start-window .modal-subtitle {
  margin-top: 2px;
  font-size: 7px;
}

body.touch-layout.compact-landscape .controls-card {
  margin: 5px 0 4px;
  padding: 5px 9px;
  gap: 10px;
  border-radius: 12px;
}

body.touch-layout.compact-landscape .controls-card strong,
body.touch-layout.compact-landscape .controls-card span {
  font-size: 7px;
}

body.touch-layout.compact-landscape .start-window .primary-button {
  min-width: 170px;
  margin-top: 3px;
  padding: 7px 18px;
  font-size: 9px;
}

body.touch-layout.compact-landscape .start-window .load-status {
  margin-top: 3px;
  font-size: 7px;
}

body.touch-layout.compact-landscape .in-app-note {
  margin-top: 4px;
  padding: 5px 8px;
}

body.touch-layout.compact-landscape .in-app-note span {
  font-size: 7px;
}

body.touch-layout.compact-landscape .in-app-note button {
  padding: 5px 8px;
  font-size: 7px;
}

/* ============================================================
   Composición vertical final. Usa el viewport real en vez del
   reporte de orientación de Safari, WhatsApp o Instagram.
   ============================================================ */

body.touch-layout.portrait-layout .aero-background {
  background:
    linear-gradient(180deg, rgba(244,255,255,0.04), rgba(65,210,237,0.12)),
    url("assets/images/diamad.webp") 42% center / cover no-repeat;
}

body.touch-layout.portrait-layout .aero-background::before {
  display: block;
  inset: auto 0 0;
  width: 100%;
  height: 54%;
  opacity: 0.78;
  background: url("assets/images/diamad.webp") 82% center / cover no-repeat;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.18) 13%, #000 38%);
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.18) 13%, #000 38%);
}

body.touch-layout.portrait-layout .aero-background::after {
  background:
    linear-gradient(180deg, rgba(229,252,255,0.08), transparent 52%),
    radial-gradient(circle at 50% 76%, rgba(209,252,255,0.12), transparent 55%);
  backdrop-filter: none;
}

body.touch-layout.portrait-layout #game-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 10px 190px;
}

body.touch-layout.portrait-layout #game-shell::before {
  display: none !important;
}

body.touch-layout.portrait-layout #screen-frame {
  position: relative;
  top: auto;
  left: auto;
  width: min(94vw, calc((var(--app-height) - 270px) * 1.7778), 720px);
  max-height: calc(var(--app-height) - 270px);
  transform: none;
}

/* La franja de controles vive abajo como una sola pieza. Esto evita que
   Safari/Instagram ignoren `bottom` al combinar `inset` con una altura fija. */
body.touch-layout.portrait-layout #touch-controls {
  top: auto;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: calc(164px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 calc(16px + env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
}

body.touch-layout.portrait-layout #dpad {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  flex: 0 0 auto;
  margin: 0;
  width: 132px;
  height: 132px;
  transform: none;
}

body.touch-layout.portrait-layout #dpad.joystick-active {
  transform: scale(1.025);
}

body.touch-layout.portrait-layout .action-controls {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  flex: 0 0 auto;
  margin: 0 0 11px;
  gap: 10px;
  transform: none;
}

body.touch-layout.portrait-layout .action-button {
  width: 64px;
  height: 64px;
}

body.touch-layout.portrait-layout .interact-button {
  width: 58px;
  height: 58px;
  transform: translateY(16px);
}

body.touch-layout.portrait-layout .interact-button:active,
body.touch-layout.portrait-layout .interact-button.active {
  transform: translateY(16px) scale(0.92);
}

body.touch-layout.portrait-layout .console-toolbar {
  top: auto;
  bottom: 65px;
  bottom: calc(65px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

body.touch-layout.portrait-layout .console-brand strong {
  font-size: 19px;
}

body.touch-layout.portrait-layout .console-brand small {
  font-size: 6px;
}

body.touch-layout.portrait-layout .now-playing,
body.touch-layout.portrait-layout .now-playing.collapsed {
  top: auto;
  bottom: 151px;
  bottom: calc(151px + env(safe-area-inset-bottom, 0px));
}

body.touch-layout.portrait-layout.tablet-layout #game-shell {
  padding-bottom: 252px;
}

body.touch-layout.portrait-layout.tablet-layout #screen-frame {
  width: min(92vw, calc((var(--app-height) - 330px) * 1.7778), 720px);
  max-height: calc(var(--app-height) - 330px);
}

body.touch-layout.portrait-layout.tablet-layout #touch-controls {
  height: calc(220px + env(safe-area-inset-bottom, 0px));
  padding-right: calc(28px + env(safe-area-inset-right, 0px));
  padding-left: calc(28px + env(safe-area-inset-left, 0px));
}

body.touch-layout.portrait-layout.tablet-layout #dpad {
  width: 188px;
  height: 188px;
}

body.touch-layout.portrait-layout.tablet-layout .action-controls {
  margin-bottom: 24px;
  gap: 18px;
}

body.touch-layout.portrait-layout.tablet-layout .action-button {
  width: 86px;
  height: 86px;
}

body.touch-layout.portrait-layout.tablet-layout .interact-button {
  width: 78px;
  height: 78px;
}

body.touch-layout.portrait-layout.tablet-layout .console-toolbar {
  bottom: 88px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
}

body.touch-layout.portrait-layout.tablet-layout .now-playing,
body.touch-layout.portrait-layout.tablet-layout .now-playing.collapsed {
  bottom: 213px;
  bottom: calc(213px + env(safe-area-inset-bottom, 0px));
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
