:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: #b8c8ca;
  --panel: #102627;
  --panel-2: #163739;
  --line: rgba(255,255,255,.16);
  --accent: #78f1c8;
  --gold: #ffd66b;
  --danger: #ff776d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 48% 18%, rgba(255,214,107,.1), transparent 22%),
    radial-gradient(circle at 8% 10%, rgba(120,241,200,.18), transparent 30%),
    linear-gradient(135deg, #0b1a1a 0%, #132d2f 45%, #2b2631 100%);
}

.install-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(5,24,21,.34), rgba(4,13,14,.86)),
    radial-gradient(circle at 68% 20%, rgba(255,214,107,.24), transparent 28%),
    radial-gradient(circle at 18% 75%, rgba(120,241,200,.22), transparent 32%),
    linear-gradient(135deg, #103a33 0%, #172b45 52%, #322340 100%);
  opacity: 1;
  pointer-events: auto;
  transition: opacity .22s ease, visibility .22s ease;
}

.install-gate.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.install-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.install-backdrop span {
  position: absolute;
  width: 190px;
  height: 190px;
  border-radius: 46% 54% 42% 58%;
  background:
    radial-gradient(circle at 42% 36%, rgba(255,255,255,.4) 0 7%, transparent 8%),
    radial-gradient(circle at 58% 58%, rgba(120,241,200,.34), rgba(120,241,200,.06) 58%, transparent 60%);
  filter: drop-shadow(0 16px 32px rgba(0,0,0,.22));
  animation: floatLeaf 5.5s ease-in-out infinite;
}

.install-backdrop span:nth-child(1) {
  left: 7%;
  top: 12%;
  transform: rotate(-18deg);
}

.install-backdrop span:nth-child(2) {
  right: 8%;
  top: 18%;
  width: 140px;
  height: 140px;
  animation-delay: -1.6s;
}

.install-backdrop span:nth-child(3) {
  left: 64%;
  bottom: 8%;
  width: 220px;
  height: 220px;
  animation-delay: -3s;
}

.install-card {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100svh - 28px);
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 26px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 10px;
  text-align: center;
  background: rgba(8,28,28,.72);
  box-shadow:
    0 0 0 1px rgba(120,241,200,.18),
    0 0 46px rgba(120,241,200,.22),
    0 26px 90px rgba(0,0,0,.46);
  backdrop-filter: blur(14px);
}

.player-code-line {
  justify-self: stretch;
  display: flex;
  justify-content: center;
  gap: 8px;
  min-height: 28px;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  color: #cde7e1;
  background: rgba(255,255,255,.06);
  font-size: 13px;
  font-weight: 800;
}

.player-code-line strong {
  color: var(--gold);
  letter-spacing: .12em;
}

.install-icon {
  width: min(190px, 46vw);
  aspect-ratio: 1;
  border-radius: 28%;
  box-shadow:
    0 0 0 6px rgba(255,255,255,.12),
    0 0 34px rgba(255,214,107,.34),
    0 18px 45px rgba(0,0,0,.34);
  animation: iconGlow 2.8s ease-in-out infinite;
}

.install-copy {
  display: grid;
  gap: 8px;
}

.install-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.install-copy h1 {
  font-size: clamp(27px, 5vw, 42px);
  line-height: 1.02;
}

.install-copy p:not(.install-kicker),
.install-status {
  color: #cde7e1;
  line-height: 1.45;
}

.install-actions {
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.install-actions button {
  min-height: 48px;
  font-size: 15px;
  font-weight: 900;
}

.install-actions .primary-action {
  color: #07201d;
  background: var(--accent);
  box-shadow: 0 12px 32px rgba(120,241,200,.22);
}

.install-actions .wide-action {
  grid-column: 1 / -1;
}

.modes-panel {
  display: none;
  width: min(420px, 100%);
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  text-align: left;
}

.modes-panel.is-visible {
  display: grid;
}

.modes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modes-head strong {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.modes-head button {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.modes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.modes-grid button {
  min-height: 38px;
  padding: 8px 9px;
  color: #dffaf2;
  background: rgba(255,255,255,.08);
  font-size: 12px;
  font-weight: 900;
}

.modes-grid button:hover,
.modes-grid button:focus-visible {
  color: #09201e;
  background: var(--accent);
}

.profile-menu,
.multiplayer-menu {
  width: min(420px, 100%);
  display: grid;
  gap: 8px;
}

.profile-menu input,
.multiplayer-menu input {
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255,255,255,.08);
  font: inherit;
  text-align: center;
}

.multiplayer-menu {
  padding: 10px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 8px;
  background: rgba(255,255,255,.05);
  text-align: left;
}

.multiplayer-menu label,
.multiplayer-menu p {
  color: var(--muted);
  font-size: 12px;
}

.multiplayer-menu > div:not(.invite-box) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.invite-box {
  display: none;
  gap: 8px;
  align-items: center;
  grid-template-columns: 1fr auto auto;
  padding-top: 6px;
}

.invite-box.is-visible {
  display: grid;
}

.coop-invite {
  position: absolute;
  left: 50%;
  top: 82px;
  z-index: 9;
  display: none;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  width: min(430px, calc(100% - 28px));
  min-height: 48px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(7,18,19,.82);
  box-shadow: 0 14px 38px rgba(0,0,0,.32), 0 0 24px rgba(120,241,200,.18);
  backdrop-filter: blur(10px);
  transform: translateX(-50%);
}

.coop-invite.is-visible {
  display: grid;
}

.coop-invite span {
  min-width: 0;
  overflow: hidden;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coop-invite button {
  min-width: 52px;
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
}

.update-toast {
  position: absolute;
  left: 50%;
  top: 138px;
  z-index: 10;
  display: none;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  width: min(560px, calc(100% - 28px));
  min-height: 52px;
  padding: 9px;
  border: 1px solid rgba(255,214,107,.38);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(8,20,20,.88);
  box-shadow: 0 16px 42px rgba(0,0,0,.34), 0 0 28px rgba(255,214,107,.2);
  backdrop-filter: blur(10px);
  transform: translateX(-50%);
}

.update-toast.is-visible {
  display: grid;
}

.update-toast span {
  min-width: 0;
  overflow: hidden;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.update-toast button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.update-toast button:first-of-type {
  color: #09201e;
  background: var(--gold);
}

.install-status {
  min-height: 22px;
  font-size: 13px;
}

@keyframes floatLeaf {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -18px;
  }
}

@keyframes iconGlow {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-5px) scale(1.02);
  }
}

.game-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  padding: 18px;
}

.game-shell.panel-open {
  grid-template-columns: minmax(0, 1fr) 360px;
}

.stage-wrap {
  position: relative;
  width: min(100%, calc((100svh - 36px) * 16 / 9));
  margin-inline: auto;
  min-height: 0;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  background: #061112;
  border-radius: 10px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(120,241,200,.16),
    0 0 34px rgba(120,241,200,.18),
    0 24px 70px rgba(0,0,0,.34);
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  image-rendering: auto;
}

.mobile-button,
.mobile-stick,
.mobile-actions {
  position: absolute;
  z-index: 6;
  display: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.mobile-button,
.mobile-action {
  border: 1px solid rgba(255,255,255,.22);
  color: #09201e;
  background: rgba(120,241,200,.84);
  box-shadow: 0 10px 30px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.32);
  backdrop-filter: blur(8px);
  font-weight: 900;
}

.mobile-q {
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

.mobile-cheat {
  left: 14px;
  bottom: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,214,107,.86);
}

.mobile-esc {
  top: 64px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 11px;
}

.mobile-stick {
  left: 20px;
  bottom: 54px;
  width: 126px;
  height: 126px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(7,18,19,.38);
  box-shadow: inset 0 0 22px rgba(120,241,200,.2), 0 12px 32px rgba(0,0,0,.26);
  backdrop-filter: blur(8px);
}

.mobile-stick span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(120,241,200,.9);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.32);
}

.mobile-actions {
  right: 20px;
  bottom: 48px;
  grid-template-columns: 82px 54px;
  align-items: end;
  gap: 12px;
}

.mobile-action {
  display: grid;
  place-items: center;
  border-radius: 50%;
  font: inherit;
}

.mobile-action.jump {
  width: 82px;
  height: 82px;
  font-size: 36px;
}

.mobile-action.power {
  width: 54px;
  height: 54px;
  background: rgba(255,214,107,.9);
}

.hud {
  position: absolute;
  inset: 12px 12px auto 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(7,18,19,.72);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  pointer-events: none;
}

.hud strong,
.hud span {
  display: block;
}

.hud strong {
  font-size: 15px;
}

.hud span {
  color: var(--muted);
  font-size: 13px;
}

.bars {
  text-align: right;
}

#health {
  color: #ff9690;
  letter-spacing: 2px;
}

#powerName {
  color: var(--gold);
}

#progressStats {
  color: var(--accent);
}

.panel-hint {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(7,18,19,.66);
  backdrop-filter: blur(8px);
  font-size: 13px;
  pointer-events: none;
}

.message {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: min(520px, calc(100% - 36px));
  transform: translate(-50%, -50%);
  padding: 16px 18px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(8,20,20,.84);
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0,0,0,.3);
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
}

.message.is-visible {
  opacity: 1;
}

.scene-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 28% 24%, rgba(120,241,200,.18), transparent 30%),
    radial-gradient(circle at 70% 68%, rgba(255,214,107,.13), transparent 28%),
    linear-gradient(180deg, rgba(5,15,16,.28), rgba(5,15,16,.74));
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.scene-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.skill-overlay,
.cheat-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4,14,15,.74);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.skill-overlay.is-visible,
.cheat-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.skill-overlay > div,
.cheat-overlay > div {
  width: min(620px, 100%);
  max-height: min(460px, calc(100% - 24px));
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  background: rgba(12,31,31,.94);
  box-shadow: 0 22px 80px rgba(0,0,0,.42);
}

.skill-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.skill-head strong {
  font-size: 22px;
}

.skill-head span {
  color: var(--accent);
  font-weight: 900;
}

.skill-overlay p,
.cheat-overlay p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.cheat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 14px 0;
}

.cheat-row input {
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255,255,255,.08);
  font: inherit;
}

.cheat-result {
  min-height: 20px;
}

code {
  color: var(--gold);
}

.skill-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.skill-overlay h3 {
  margin: 14px 0 8px;
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.skin-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.skin-list button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  overflow: hidden;
  font-size: 12px;
  padding: 8px 6px;
  border-color: rgba(255,255,255,.24);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 8px 22px rgba(0,0,0,.18);
}

.skin-list button.is-active {
  color: #09201e;
  background: linear-gradient(135deg, var(--skin-a, var(--accent)), var(--skin-b, var(--gold)));
  box-shadow: 0 0 0 2px rgba(255,255,255,.28), 0 0 22px color-mix(in srgb, var(--skin-a, var(--accent)) 55%, transparent);
}

.skin-swatch {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.72);
  background: radial-gradient(circle at 35% 30%, #fff 0 12%, var(--skin-b, #ffd66b) 13% 38%, var(--skin-a, #78f1c8) 39% 100%);
  box-shadow: 0 0 11px var(--skin-a, #78f1c8);
}

.skill-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 56px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
}

.skill-row.is-locked {
  opacity: .5;
}

.skill-row strong,
.skill-row small {
  display: block;
}

.skill-row small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.scene-overlay > div {
  width: min(560px, 100%);
  padding: 20px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(12,31,31,.86);
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 22px 80px rgba(0,0,0,.38);
}

.scene-overlay.is-story > div {
  transform: translateY(112px);
  background: rgba(12,31,31,.72);
}

.scene-overlay strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.scene-overlay p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.scene-overlay button {
  margin-top: 16px;
  min-width: 142px;
  background: var(--accent);
  color: #09201e;
  font-weight: 800;
}

.panel {
  display: none;
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(16,38,39,.9);
  padding: 16px;
  overflow: auto;
}

.game-shell.panel-open .panel {
  display: block;
}

.panel-close {
  width: 100%;
  margin-bottom: 12px;
  color: #09201e;
  background: var(--accent);
  font-weight: 900;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  color: #112322;
  background: var(--accent);
  border-radius: 8px;
  font-weight: 900;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.12;
  letter-spacing: 0;
}

.brand p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.controls span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

kbd {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
  background: #eefaf7;
  color: #102627;
  font-weight: 800;
  font-size: 12px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.18);
}

.panel-section {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

h2 {
  margin-bottom: 10px;
  color: #dff9f4;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.button-grid,
.power-grid {
  display: grid;
  gap: 8px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.level-map {
  position: relative;
  min-height: 132px;
  margin-top: 12px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(120,241,200,.08), rgba(255,214,107,.07));
  overflow: hidden;
}

.map-node {
  position: absolute;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,.22);
  background: #203b3b;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.map-node.is-open {
  background: var(--accent);
  color: #09201e;
}

.map-node.is-active {
  outline: 3px solid var(--gold);
}

.map-line {
  position: absolute;
  height: 3px;
  transform-origin: left center;
  background: rgba(120,241,200,.42);
}

button {
  min-height: 38px;
  border: 1px solid rgba(255,255,255,.16);
  color: var(--ink);
  background: rgba(255,255,255,.07);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

button:hover {
  border-color: rgba(120,241,200,.8);
  background: rgba(120,241,200,.12);
}

button:disabled {
  cursor: not-allowed;
  opacity: .46;
}

button.is-locked {
  border-color: rgba(255,255,255,.08);
  background: rgba(0,0,0,.16);
}

button.is-active {
  border-color: var(--accent);
  color: #09201e;
  background: var(--accent);
  font-weight: 800;
}

.power-grid {
  grid-template-columns: 1fr;
}

.power-grid button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  text-align: left;
}

.power-grid button span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.power-grid button b {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #102627;
  font-size: 12px;
}

.power-grid button.info-only {
  cursor: help;
}

.power-grid small {
  color: var(--muted);
  font-size: 11px;
}

.power-grid .is-active small {
  color: #164440;
}

.compact p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.48;
}

@media (max-width: 980px) {
  .game-shell,
  .game-shell.panel-open {
    grid-template-columns: 1fr;
  }

  .panel {
    max-height: none;
  }

  .panel-hint {
    display: none;
  }

  .mobile-button,
  .mobile-stick {
    display: block;
  }

  .mobile-actions {
    display: grid;
  }

  .hud {
    inset: 10px 62px auto 10px;
  }
}

@media (max-width: 620px) {
  .install-gate {
    align-items: start;
    padding: 10px;
    overflow-y: auto;
  }

  .install-card {
    width: min(100%, 420px);
    gap: 9px;
    padding: 12px;
  }

  .install-icon {
    width: min(96px, 28vw);
  }

  .install-copy {
    gap: 4px;
  }

  .install-kicker,
  .multiplayer-menu label,
  .multiplayer-menu p,
  .install-status {
    font-size: 11px;
  }

  .install-copy h1 {
    font-size: clamp(22px, 8vw, 30px);
  }

  .install-copy p:not(.install-kicker) {
    font-size: 13px;
  }

  .install-actions button {
    min-height: 42px;
    font-size: 13px;
  }

  .modes-panel {
    padding: 8px;
    gap: 8px;
  }

  .modes-grid {
    gap: 6px;
  }

  .modes-grid button {
    min-height: 34px;
    padding: 6px 7px;
    font-size: 11px;
  }

  .multiplayer-menu {
    padding: 8px;
    gap: 6px;
  }

  .profile-menu input,
  .multiplayer-menu input {
    height: 36px;
  }

  .game-shell {
    min-height: 100svh;
    padding: 8px;
    gap: 10px;
    align-content: center;
  }

  .stage-wrap {
    width: min(calc(100vw - 16px), calc((100svh - 16px) * 16 / 9));
    max-height: calc(100svh - 16px);
  }

  .hud {
    align-items: flex-start;
    padding: 8px;
    gap: 8px;
  }

  .level-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .mobile-stick {
    left: 12px;
    bottom: 40px;
    width: 108px;
    height: 108px;
  }

  .mobile-actions {
    right: 12px;
    bottom: 38px;
  }

  .mobile-action.jump {
    width: 74px;
    height: 74px;
  }

  .mobile-action.power {
    width: 52px;
    height: 52px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  body {
    overflow: hidden;
  }

  .install-gate {
    place-items: start center;
    padding: 8px;
    overflow-y: auto;
  }

  .install-card {
    width: min(540px, 100%);
    max-height: calc(100svh - 16px);
    grid-template-columns: 86px minmax(0, 1fr);
    align-items: center;
    justify-items: stretch;
    gap: 8px 12px;
    padding: 10px;
    text-align: left;
  }

  .player-code-line,
  .install-actions,
  .modes-panel,
  .multiplayer-menu,
  .profile-menu,
  .install-status {
    grid-column: 2;
  }

  .install-icon {
    grid-row: 1 / span 5;
    width: 78px;
    align-self: start;
  }

  .install-copy {
    grid-column: 2;
    gap: 3px;
  }

  .install-copy h1 {
    font-size: 22px;
  }

  .install-copy p:not(.install-kicker),
  .install-status {
    font-size: 12px;
  }

  .install-actions button {
    min-height: 34px;
  }

  .profile-menu input,
  .multiplayer-menu input {
    height: 32px;
  }

  .game-shell,
  .game-shell.panel-open {
    width: 100vw;
    min-height: 100svh;
    padding: 8px;
    place-items: center;
  }

  .stage-wrap {
    width: min(calc(100vw - 16px), calc((100svh - 16px) * 16 / 9));
    height: min(calc(100svh - 16px), calc((100vw - 16px) * 9 / 16));
  }

  canvas {
    width: 100%;
    height: 100%;
  }

  .panel {
    position: absolute;
    right: 8px;
    top: 8px;
    width: min(360px, calc(100vw - 16px));
    max-height: calc(100svh - 16px);
    z-index: 8;
  }
}
