:root {
  --bg: #020202;
  --panel: rgba(10, 10, 10, 0.72);
  --line: rgba(255, 255, 255, 0.16);
  --line-strong: rgba(255, 255, 255, 0.8);
  --glow: rgba(255, 255, 255, 0.92);
  --soft: rgba(255, 255, 255, 0.62);
  --muted: rgba(255, 255, 255, 0.44);
  --danger: rgba(255, 255, 255, 0.96);
  --font-ui: "Bahnschrift", "Arial Narrow", "Segoe UI", sans-serif;
  --font-display: "Consolas", "Lucida Console", monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 42%),
    radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.05), transparent 32%),
    linear-gradient(180deg, #0a0a0a 0%, #020202 56%, #000000 100%);
  color: #fff;
  font-family: var(--font-ui);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

body.install-locked {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.18;
  mask-image: radial-gradient(circle at center, black 52%, transparent 100%);
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: -14%;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.085), transparent 26%),
    radial-gradient(circle at 78% 16%, rgba(255, 255, 255, 0.05), transparent 28%),
    radial-gradient(circle at 68% 78%, rgba(255, 255, 255, 0.065), transparent 24%);
  opacity: 0.2;
  filter: blur(34px);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: driftGlow 18s linear infinite;
}

.app-shell {
  position: relative;
  min-height: 100dvh;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  transition: filter 220ms ease, transform 220ms ease, opacity 220ms ease;
}

body.install-locked .app-shell {
  filter: blur(18px) saturate(0.32);
  transform: scale(0.985);
  opacity: 0.68;
  pointer-events: none;
}

.hud,
.footer-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 22px rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
}

.hud::after,
.footer-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 0%, rgba(255, 255, 255, 0.02) 34%, rgba(255, 255, 255, 0.09) 49%, transparent 62%);
  transform: translateX(-140%);
  pointer-events: none;
  animation: panelSweep 10s linear infinite;
}

.hud-block,
.footer-item {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.hud-center {
  justify-items: center;
  min-width: min(40vw, 280px);
}

.hud-right {
  justify-items: end;
}

.hud-label {
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud strong,
.footer-item strong {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2vw, 1.18rem);
  letter-spacing: 0.16em;
  font-weight: 700;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.32);
}

.danger-track {
  width: min(28vw, 170px);
  height: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.08) inset;
}

.danger-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 1));
  box-shadow:
    0 0 10px rgba(255, 255, 255, 0.6),
    0 0 18px rgba(255, 255, 255, 0.3);
  transition: width 120ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: width;
}

.game-stage {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 18%),
    rgba(0, 0, 0, 0.74);
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 36px rgba(255, 255, 255, 0.08);
  contain: layout paint size;
  isolation: isolate;
}

.game-stage::before,
.game-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.game-stage::before {
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.05), transparent 24%),
    radial-gradient(circle at 80% 85%, rgba(255, 255, 255, 0.04), transparent 22%);
}

.game-stage::after {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 12%, transparent 88%, rgba(255, 255, 255, 0.02) 100%),
    linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.045) 48%, transparent 100%);
  background-size: 100% 100%, 220% 100%;
  background-position: 0 0, 0 0;
  mix-blend-mode: screen;
  animation: stageScan 12s linear infinite;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  position: relative;
  z-index: 1;
  will-change: transform;
}

#gameCanvas:active {
  cursor: grabbing;
}

.message-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(88%, 420px);
  padding: 22px 20px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 18px;
  background: rgba(2, 2, 2, 0.84);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 0 36px rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  cursor: pointer;
  animation: panelEnter 240ms cubic-bezier(0.2, 0.85, 0.24, 1);
  will-change: transform, opacity;
}

.install-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.34);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.install-action {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08)),
    rgba(0, 0, 0, 0.82);
  color: #fff;
  min-width: min(84vw, 420px);
  min-height: 72px;
  padding: 18px 26px;
  font-family: var(--font-ui);
  font-size: clamp(1rem, 2.8vw, 1.22rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 38px rgba(255, 255, 255, 0.14);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.install-action:hover,
.install-action:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.7);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1) inset,
    0 0 46px rgba(255, 255, 255, 0.22);
  outline: none;
}

.install-action:active {
  transform: translateY(0);
}

.install-action:disabled {
  opacity: 0.76;
  cursor: progress;
}

.install-action.is-hint {
  letter-spacing: 0.08em;
  text-transform: none;
  font-size: clamp(0.96rem, 2.6vw, 1.08rem);
}

.hidden {
  display: none !important;
}

.startup-splash {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: #000;
  pointer-events: auto;
  opacity: 1;
  overflow: hidden;
}

.startup-splash-inner {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.startup-title,
.startup-byline,
.startup-heart-icon {
  opacity: 0;
  transform: translateY(4px);
}

.startup-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 9vw, 4.6rem);
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.96);
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.24);
}

.startup-byline {
  margin: 0;
  font-family: var(--font-ui);
  font-size: clamp(0.72rem, 2.6vw, 0.92rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.74);
}

.startup-heart-icon {
  display: block;
  width: clamp(96px, 18vw, 164px);
  height: auto;
  transform-origin: center;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.18));
}

.startup-splash.is-playing .startup-title {
  animation: splashFadeIn 1300ms cubic-bezier(0.22, 1, 0.36, 1) 180ms forwards;
}

.startup-splash.is-playing .startup-byline {
  animation: splashFadeIn 1100ms cubic-bezier(0.22, 1, 0.36, 1) 1120ms forwards;
}

.startup-splash.is-playing .startup-heart-icon {
  animation: splashFadeIn 1100ms cubic-bezier(0.22, 1, 0.36, 1) 1460ms forwards;
}

.startup-splash.is-revealing {
  animation: splashFadeOut 980ms ease-out forwards;
}

.startup-splash.is-done {
  display: none;
}

.app-update-btn {
  position: fixed;
  z-index: 40;
  right: max(12px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.54);
  border-radius: 999px;
  background: rgba(12, 12, 12, 0.92);
  color: rgba(255, 255, 255, 0.94);
  min-height: 44px;
  padding: 10px 16px;
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.14);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, left 180ms ease, top 180ms ease, right 180ms ease;
}

.app-update-btn:focus-visible,
.app-update-btn:hover {
  border-color: rgba(255, 255, 255, 0.88);
  outline: none;
}

body.update-prompt-active > *:not(.app-update-btn) {
  filter: blur(9px) saturate(0.45) brightness(0.6);
  pointer-events: none;
  user-select: none;
}

body.update-prompt-active .app-update-btn {
  left: 50%;
  top: 50%;
  right: auto;
  transform: translate(-50%, -50%);
  min-height: 54px;
  padding: 12px 22px;
  font-size: 0.86rem;
  border-color: rgba(255, 255, 255, 0.92);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.2) inset,
    0 18px 42px rgba(0, 0, 0, 0.5),
    0 0 34px rgba(255, 255, 255, 0.3);
}

.message-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 2rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.38);
}

.message-text {
  margin: 0;
  line-height: 1.55;
  color: var(--soft);
  letter-spacing: 0.05em;
}

.footer-bar {
  grid-template-columns: auto 1fr;
}

.status-text {
  margin: 0;
  justify-self: end;
  text-align: right;
  color: var(--soft);
  letter-spacing: 0.05em;
  font-size: 0.92rem;
  line-height: 1.3;
  text-wrap: balance;
}

.status-text:empty {
  display: none;
}

.interlude-actions {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.interlude-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(8, 8, 8, 0.88);
  color: rgba(255, 255, 255, 0.9);
  padding: 11px 18px;
  min-width: 116px;
  font-family: var(--font-ui);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.interlude-button:hover,
.interlude-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.76);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.16);
  outline: none;
}

.interlude-button-primary {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.08)),
    rgba(10, 10, 10, 0.92);
}

.tutorial-blur {
  position: absolute;
  inset: 0;
  z-index: 7;
  background: rgba(0, 0, 0, 0.34);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  pointer-events: none;
}

.tutorial-dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(94%, 660px);
  z-index: 9;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 18px;
  background: rgba(6, 6, 6, 0.94);
  box-shadow: 0 0 30px rgba(255, 255, 255, 0.16);
  pointer-events: none;
}

.tutorial-dialog-body {
  display: grid;
  gap: 6px;
}

.tutorial-dialog-meta {
  margin: 0;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  font-size: 0.68rem;
}

.tutorial-avatar {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}

.tutorial-avatar-square {
  border-radius: 4px;
}

.tutorial-avatar-circle {
  border-radius: 999px;
}

.tutorial-avatar-triangle {
  clip-path: polygon(50% 6%, 8% 94%, 92% 94%);
}

.tutorial-dialog-text {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.02em;
  line-height: 1.4;
  font-size: 1rem;
}

.tutorial-dialog-next {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.84);
  color: rgba(255, 255, 255, 0.9);
  min-height: 42px;
  padding: 8px 14px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
}

.start-menu {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  justify-items: center;
  padding:
    max(24px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.38), rgba(0, 0, 0, 0.5) 55%, rgba(0, 0, 0, 0.62)),
    radial-gradient(circle at 20% 16%, rgba(255, 255, 255, 0.08), transparent 42%),
    radial-gradient(circle at 82% 84%, rgba(255, 255, 255, 0.06), transparent 44%);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: opacity 220ms ease;
}

.start-menu.hidden {
  display: none;
}

.menu-best-time {
  margin: 0;
  justify-self: center;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 0.12em;
  font-size: 0.76rem;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: center;
  margin-bottom: max(30px, env(safe-area-inset-bottom));
}

.menu-orbs {
  margin: 0;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 0.11em;
  font-size: 0.72rem;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: max(16px, env(safe-area-inset-bottom));
}

.menu-orbs strong {
  color: rgba(255, 255, 255, 0.96);
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.14em;
}

.menu-best-time strong {
  font-family: var(--font-display);
  letter-spacing: 0.16em;
  font-size: clamp(1.05rem, 2.8vw, 1.24rem);
  color: rgba(255, 255, 255, 0.95);
}

.menu-title {
  margin: 0;
  position: absolute;
  top: max(26px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 10vw, 6.2rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 800;
  color: #fff;
  pointer-events: none;
}

.glitch-letter {
  position: relative;
  display: inline-block;
  color: rgba(255, 255, 255, 0.94);
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.2);
  animation: subtleGlitch 2.8s infinite steps(2, end);
}

.glitch-letter::before,
.glitch-letter::after {
  content: attr(data-char);
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  pointer-events: none;
}

.glitch-letter::before {
  color: rgba(255, 255, 255, 0.56);
  transform: translate(-1px, 0);
  animation: glitchA 3.4s infinite steps(2, end);
}

.glitch-letter::after {
  color: rgba(255, 255, 255, 0.36);
  transform: translate(1px, 0);
  animation: glitchB 3.7s infinite steps(2, end);
}

.glitch-letter:nth-child(2) { animation-delay: 0.1s; }
.glitch-letter:nth-child(3) { animation-delay: 0.2s; }
.glitch-letter:nth-child(4) { animation-delay: 0.08s; }
.glitch-letter:nth-child(5) { animation-delay: 0.16s; }
.glitch-letter:nth-child(6) { animation-delay: 0.12s; }

.menu-actions {
  display: grid;
  gap: 12px;
  width: min(86vw, 360px);
  margin-bottom: 14px;
}

.menu-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.84);
  color: rgba(255, 255, 255, 0.88);
  min-height: 56px;
  padding: 12px 20px;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.menu-button:hover,
.menu-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.76);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.14);
  outline: none;
}

.menu-button-primary {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05)),
    rgba(8, 8, 8, 0.88);
}

.tutorial-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 999px;
  width: 44px;
  height: 44px;
  background: rgba(10, 10, 10, 0.84);
  color: rgba(255, 255, 255, 0.9);
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease;
}

.tutorial-button:hover,
.tutorial-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.8);
  outline: none;
}

.shop-menu {
  position: fixed;
  inset: 0;
  z-index: 31;
  padding:
    max(24px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  justify-items: center;
  gap: 14px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.46), rgba(0, 0, 0, 0.66)),
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.08), transparent 42%);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

.shop-menu.hidden {
  display: none;
}

.shop-title {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.18em;
  font-size: clamp(1.6rem, 6vw, 2.4rem);
}

.shop-wallet {
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
}

.shop-wallet strong {
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.08rem;
  letter-spacing: 0.14em;
  margin-left: 8px;
}

.shop-section-title {
  margin: 4px 0 -2px;
  font-family: var(--font-display);
  letter-spacing: 0.14em;
  font-size: clamp(0.88rem, 3vw, 1.05rem);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}

.shop-grid {
  width: min(96vw, 860px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.shop-card {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 16px;
  background: rgba(8, 8, 8, 0.46);
  padding: 14px 12px;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 8px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}

.shape-preview {
  width: min(22vw, 96px);
  height: min(22vw, 96px);
  position: relative;
}

.shape-preview::before {
  content: "";
  position: absolute;
  inset: 20%;
  background: #fff;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.45));
}

.shape-preview::after {
  content: none;
}

.shape-preview-square::before {
  animation: previewSquare 2.1s ease-in-out infinite;
}

.shape-preview-triangle::before {
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  animation: previewTriangle 2.2s ease-in-out infinite;
}

.shape-preview-circle::before {
  border-radius: 999px;
  animation: previewCircle 1.8s ease-in-out infinite;
}

.shape-preview-diamond::before {
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  animation: previewDiamond 2.1s ease-in-out infinite;
}

.shape-preview-hex::before {
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  animation: previewHex 2.3s ease-in-out infinite;
}

.shape-preview-star::before {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: previewStar 2.2s ease-in-out infinite;
}

.shape-preview-capsule::before {
  border-radius: 999px;
  inset: 28% 14%;
  animation: previewCapsule 2s ease-in-out infinite;
}

.shape-preview-cross::before {
  clip-path: polygon(35% 0%, 65% 0%, 65% 35%, 100% 35%, 100% 65%, 65% 65%, 65% 100%, 35% 100%, 35% 65%, 0% 65%, 0% 35%, 35% 35%);
  animation: previewCross 2.4s ease-in-out infinite;
}

.shape-preview-droplet::before {
  clip-path: polygon(50% 0%, 72% 20%, 84% 46%, 78% 72%, 62% 90%, 38% 90%, 22% 72%, 16% 46%, 28% 20%);
  animation: previewDroplet 2.15s ease-in-out infinite;
}

.shape-preview-heart::before {
  inset: 18%;
  clip-path: polygon(50% 92%, 8% 52%, 8% 26%, 26% 10%, 50% 28%, 74% 10%, 92% 26%, 92% 52%);
  animation: previewHeart 2.25s ease-in-out infinite;
}

.shape-preview-moon::before {
  inset: 19%;
  border-radius: 999px;
  animation: previewMoon 2.4s ease-in-out infinite;
}

.shape-preview-moon::after {
  content: "";
  position: absolute;
  inset: 26% 30% 26% 38%;
  border-radius: 999px;
  background: rgba(8, 8, 8, 0.9);
  animation: previewMoon 2.4s ease-in-out infinite reverse;
}

.shape-preview-crown::before {
  inset: 18% 16%;
  clip-path: polygon(0% 100%, 0% 52%, 20% 64%, 34% 28%, 50% 62%, 66% 28%, 80% 64%, 100% 52%, 100% 100%);
  animation: previewCrown 2.3s ease-in-out infinite;
}

.shape-preview-bolt::before {
  inset: 16% 24%;
  clip-path: polygon(54% 0%, 22% 46%, 48% 46%, 24% 100%, 82% 40%, 54% 40%);
  animation: previewBolt 1.85s ease-in-out infinite;
}

.shape-preview-cog::before {
  inset: 16%;
  clip-path: polygon(50% 0%, 62% 9%, 76% 5%, 82% 18%, 95% 24%, 91% 38%, 100% 50%, 91% 62%, 95% 76%, 82% 82%, 76% 95%, 62% 91%, 50% 100%, 38% 91%, 24% 95%, 18% 82%, 5% 76%, 9% 62%, 0% 50%, 9% 38%, 5% 24%, 18% 18%, 24% 5%, 38% 9%);
  animation: previewCog 2.45s linear infinite;
}

.shape-preview-hourglass::before {
  inset: 18%;
  clip-path: polygon(10% 0%, 90% 0%, 58% 46%, 90% 100%, 10% 100%, 42% 46%);
  animation: previewHourglass 2.5s ease-in-out infinite;
}

.shape-preview-kite::before {
  inset: 16%;
  clip-path: polygon(50% 0%, 84% 50%, 50% 100%, 16% 50%);
  animation: previewKite 2.05s ease-in-out infinite;
}

.shape-preview-orbit::before {
  inset: 26%;
  border-radius: 999px;
  animation: previewOrbitCore 2s ease-in-out infinite;
}

.shape-preview-orbit::after {
  content: "";
  position: absolute;
  inset: 18%;
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 999px;
  transform: rotate(26deg);
  animation: previewOrbitRing 2.3s linear infinite;
}


.shop-item-title {
  margin: 0;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.9rem;
}

.shop-item-price {
  margin: 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.shop-button,
.shop-close {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.86);
  color: rgba(255, 255, 255, 0.9);
  min-height: 42px;
  padding: 10px 16px;
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.shop-button.is-selected {
  border-color: rgba(255, 255, 255, 0.84);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.22);
}

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

.shop-close {
  min-width: 130px;
}


.challenge-menu {
  position: fixed;
  inset: 0;
  z-index: 32;
  display: grid;
  grid-template-rows: auto auto auto auto auto auto;
  gap: 14px;
  justify-items: center;
  align-content: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.52), rgba(0, 0, 0, 0.72)),
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.08), transparent 44%);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.challenge-menu.hidden {
  display: none;
}

.challenge-title {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.18em;
  font-size: clamp(1.6rem, 6vw, 2.5rem);
}

.challenge-subtitle {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: 0.06em;
  text-align: center;
  max-width: min(92vw, 520px);
}

.challenge-actions {
  display: grid;
  gap: 10px;
  width: min(86vw, 360px);
}

.challenge-action,
.challenge-copy,
.challenge-close {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.86);
  color: rgba(255, 255, 255, 0.9);
  min-height: 46px;
  padding: 10px 16px;
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.challenge-action-primary {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05)),
    rgba(8, 8, 8, 0.88);
}

.challenge-code-wrap {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.challenge-join-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(86vw, 360px);
  padding: 14px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
    rgba(8, 8, 8, 0.72);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 10px 28px rgba(0, 0, 0, 0.45);
}

.challenge-join-panel.hidden {
  display: none;
}

.challenge-join-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.challenge-code-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(10, 10, 10, 0.86);
  color: rgba(255, 255, 255, 0.95);
  text-align: center;
  text-transform: uppercase;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  outline: none;
}

.challenge-code-input::placeholder {
  color: rgba(255, 255, 255, 0.34);
}

.challenge-code-input:focus-visible {
  border-color: rgba(255, 255, 255, 0.78);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.14);
}

.challenge-code-label {
  color: rgba(255, 255, 255, 0.62);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.68rem;
}

.challenge-code-value {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 5vw, 1.6rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.95);
}

.challenge-status {
  margin: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.72);
  max-width: min(92vw, 540px);
  min-height: 1.4em;
}

.challenge-result {
  position: fixed;
  inset: 0;
  z-index: 33;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.8));
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.challenge-result.hidden {
  display: none;
}

.challenge-result-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  letter-spacing: 0.16em;
  font-size: clamp(1.4rem, 5.2vw, 2.2rem);
  text-transform: uppercase;
}

.challenge-result-line {
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.challenge-result-line strong {
  color: #fff;
  letter-spacing: 0.1em;
}

.challenge-result-detail {
  margin: 6px 0 2px;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  max-width: min(92vw, 520px);
  min-height: 1.2em;
}

.challenge-result-close {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.86);
  color: rgba(255, 255, 255, 0.92);
  min-height: 46px;
  padding: 10px 18px;
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}


@keyframes driftGlow {
  0% {
    transform: translate3d(-1.5%, -1%, 0) scale(1);
  }
  50% {
    transform: translate3d(2.5%, 1.5%, 0) scale(1.04);
  }
  100% {
    transform: translate3d(-1.5%, -1%, 0) scale(1);
  }
}

@keyframes stageScan {
  0% {
    background-position: 0 0, -140% 0;
  }
  100% {
    background-position: 0 0, 140% 0;
  }
}

@keyframes panelSweep {
  0%,
  72% {
    transform: translateX(-140%);
  }
  100% {
    transform: translateX(140%);
  }
}

@keyframes panelEnter {
  0% {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 12px)) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes subtleGlitch {
  0%,
  78%,
  100% {
    transform: translate(0, 0);
    opacity: 1;
  }
  82% {
    transform: translate(-0.5px, 0);
    opacity: 0.94;
  }
  86% {
    transform: translate(0.5px, 0);
    opacity: 0.96;
  }
}

@keyframes glitchA {
  0%,
  79%,
  100% {
    opacity: 0;
  }
  80%,
  84% {
    opacity: 0.26;
  }
}

@keyframes glitchB {
  0%,
  82%,
  100% {
    opacity: 0;
  }
  83%,
  87% {
    opacity: 0.18;
  }
}

@keyframes previewSquare {
  0%, 100% { transform: rotate(0deg) scale(1); }
  40% { transform: rotate(-6deg) scale(1.04, 0.96); }
  70% { transform: rotate(5deg) scale(0.96, 1.04); }
}

@keyframes previewTriangle {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  50% { transform: rotate(180deg) translateY(-3px); }
}

@keyframes previewCircle {
  0%, 100% { transform: scale(1, 1); }
  40% { transform: scale(1.12, 0.86); }
  60% { transform: scale(0.9, 1.08); }
}

@keyframes previewDiamond {
  0%, 100% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(45deg) scale(0.9, 1.08); }
}

@keyframes previewHex {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.08, 0.92) rotate(10deg); }
  70% { transform: scale(0.94, 1.06) rotate(-8deg); }
}

@keyframes previewStar {
  0%, 100% { transform: rotate(0deg) scale(1); }
  40% { transform: rotate(22deg) scale(1.08); }
  75% { transform: rotate(-12deg) scale(0.92); }
}

@keyframes previewCapsule {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  30% { transform: translateY(-2px) scale(1.08, 0.92); }
  60% { transform: translateY(1px) scale(0.92, 1.06); }
}

@keyframes previewCross {
  0%, 100% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(90deg) scale(0.94); }
}

@keyframes previewDroplet {
  0%, 100% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(12deg) scale(0.94, 1.1); }
}

@keyframes splashFadeIn {
  0% {
    opacity: 0;
    transform: translateY(4px) scale(0.99);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes splashFadeOut {
  0% { opacity: 1; }
  100% { opacity: 0; }
}


.daily-menu {
  position: fixed;
  inset: 0;
  z-index: 34;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.56), rgba(0, 0, 0, 0.78)),
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.08), transparent 44%);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.daily-menu.hidden {
  display: none;
}

.daily-title {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.16em;
  font-size: clamp(1.4rem, 5.2vw, 2.2rem);
  text-transform: uppercase;
}

.daily-date {
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.daily-status {
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
  text-align: center;
  max-width: min(92vw, 560px);
  min-height: 1.4em;
}

.daily-leaderboard {
  margin: 0;
  padding: 0 0 0 18px;
  width: min(92vw, 460px);
  max-height: min(42vh, 320px);
  overflow: auto;
  display: grid;
  gap: 6px;
  color: rgba(255, 255, 255, 0.86);
}

.daily-leaderboard li {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 10, 10, 0.58);
  font-family: var(--font-ui);
  letter-spacing: 0.06em;
}

.daily-actions {
  width: min(86vw, 360px);
  display: grid;
  gap: 10px;
}

.global-leaderboard-btn {
  position: fixed;
  z-index: 35;
  left: max(10px, env(safe-area-inset-left));
  bottom: max(10px, env(safe-area-inset-bottom));
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 999px;
  background: rgba(12, 12, 12, 0.9);
  color: rgba(255, 255, 255, 0.92);
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.14);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.global-leaderboard-btn:hover,
.global-leaderboard-btn:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.76);
  box-shadow: 0 0 22px rgba(255, 255, 255, 0.2);
  outline: none;
}

.global-leaderboard-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.global-leaderboard-icon {
  display: block;
  width: 22px;
  height: 22px;
  margin: 0 auto;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.22));
}

.global-leaderboard-menu {
  position: fixed;
  inset: 0;
  z-index: 36;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.56), rgba(0, 0, 0, 0.82)),
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.07), transparent 46%);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.global-leaderboard-menu.hidden {
  display: none;
}

.global-leaderboard-title {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.15em;
  font-size: clamp(1.25rem, 4.8vw, 2rem);
  text-transform: uppercase;
}

.global-leaderboard-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(94vw, 560px);
}

.global-lb-tab {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.82);
  color: rgba(255, 255, 255, 0.84);
  min-height: 42px;
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease, background 140ms ease;
}

.global-lb-tab:hover,
.global-lb-tab:focus-visible {
  border-color: rgba(255, 255, 255, 0.66);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
  outline: none;
}

.global-lb-tab.is-active {
  border-color: rgba(255, 255, 255, 0.8);
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04)),
    rgba(10, 10, 10, 0.92);
}

.global-leaderboard-status {
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
  text-align: center;
  min-height: 1.4em;
  max-width: min(92vw, 560px);
}

.global-leaderboard-list {
  margin: 0;
  padding: 0 0 0 18px;
  width: min(94vw, 560px);
  max-height: min(46vh, 380px);
  overflow: auto;
  display: grid;
  gap: 6px;
  color: rgba(255, 255, 255, 0.88);
}

.global-leaderboard-list li {
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 10, 10, 0.6);
  letter-spacing: 0.05em;
}

@keyframes previewHeart {
  0%, 100% { transform: scale(1) translateY(0); }
  35% { transform: scale(1.06, 0.96) translateY(-1px); }
  65% { transform: scale(0.96, 1.06) translateY(1px); }
}

@keyframes previewMoon {
  0%, 100% { transform: rotate(0deg) translateX(0); }
  50% { transform: rotate(10deg) translateX(2px); }
}

@keyframes previewCrown {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-2px) scale(1.04); }
  75% { transform: translateY(1px) scale(0.97); }
}

@keyframes previewBolt {
  0%, 100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-3px) scale(1.06); }
  55% { transform: translateY(1px) scale(0.95); }
}

@keyframes previewCog {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes previewHourglass {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(0.95, 1.05) rotate(180deg); }
}

@keyframes previewKite {
  0%, 100% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(16deg) scale(1.03); }
}

@keyframes previewOrbitCore {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

@keyframes previewOrbitRing {
  0% { transform: rotate(26deg) scale(1); }
  100% { transform: rotate(386deg) scale(1.03); }
}

@media (pointer: coarse) {
  body::before {
    opacity: 0.08;
    mask-image: none;
  }

  body::after {
    inset: 0;
    opacity: 0.09;
    filter: blur(14px);
    animation: none;
  }

  body.install-locked .app-shell {
    filter: blur(10px) saturate(0.65);
    transform: none;
    opacity: 0.54;
  }

  .hud,
  .footer-bar,
  .message-panel,
  .install-gate {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .hud::after,
  .footer-bar::after {
    animation: none;
    transform: none;
    opacity: 0.42;
    background: linear-gradient(115deg, transparent 0%, rgba(255, 255, 255, 0.035) 46%, transparent 72%);
  }

  .game-stage::after {
    opacity: 0.32;
    animation: none;
    background-position: 0 0, 42% 0;
  }

  .message-panel {
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.08) inset,
      0 0 24px rgba(255, 255, 255, 0.08);
  }

  .install-gate {
    background: rgba(0, 0, 0, 0.46);
  }

  body.hq-mobile .hud,
  body.hq-mobile .footer-bar,
  body.hq-mobile .message-panel {
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }

  body.hq-mobile .hud::after,
  body.hq-mobile .footer-bar::after {
    animation: panelSweep 10s linear infinite;
    opacity: 0.58;
  }

  body.hq-mobile::after {
    animation: driftGlow 18s linear infinite;
    opacity: 0.14;
    filter: blur(20px);
  }
}

@media (max-width: 900px), (pointer: coarse) {
  .app-shell {
    gap: 8px;
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .hud,
  .footer-bar {
    padding: 8px 10px;
    gap: 8px;
    border-radius: 14px;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

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

  .hud-center {
    min-width: 0;
  }

  .danger-track {
    width: 100%;
    min-width: 0;
    height: 5px;
  }

  .footer-bar {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .hud-label {
    font-size: 0.56rem;
    letter-spacing: 0.16em;
  }

  .hud strong,
  .footer-item strong {
    font-size: clamp(0.82rem, 2.8vw, 1rem);
    letter-spacing: 0.12em;
  }

  .status-text {
    justify-self: start;
    text-align: left;
    font-size: 0.74rem;
    line-height: 1.24;
    letter-spacing: 0.03em;
  }


  .game-stage {
    border-radius: 16px;
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.05) inset,
      0 0 24px rgba(255, 255, 255, 0.06);
  }

  .message-panel {
    width: min(92%, 360px);
    padding: 16px 14px;
    border-radius: 16px;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .install-gate {
    padding:
      max(16px, env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
  }

  .install-action {
    min-width: min(90vw, 360px);
    min-height: 68px;
    padding: 16px 20px;
    letter-spacing: 0.1em;
  }

  body::before {
    background-size: 36px 36px;
    opacity: 0.12;
  }

  body::after {
    opacity: 0.12;
    filter: blur(12px);
    animation: none;
  }

  .menu-button,
  .challenge-action,
  .challenge-copy,
  .challenge-close,
  .challenge-result-close,
  .tutorial-dialog-next,
  .interlude-button {
    min-height: 54px;
  }

  .global-leaderboard-btn {
    width: 42px;
    height: 42px;
    min-height: 42px;
  }

  .global-leaderboard-tabs {
    width: min(96vw, 520px);
    gap: 6px;
  }

  .global-lb-tab {
    min-height: 40px;
    font-size: 0.66rem;
    letter-spacing: 0.06em;
    padding: 7px 8px;
  }

  .global-leaderboard-list {
    width: min(96vw, 520px);
    max-height: min(44vh, 340px);
  }

  .challenge-code-value {
    font-size: clamp(1.25rem, 6.2vw, 1.9rem);
    letter-spacing: 0.24em;
  }

  .tutorial-dialog {
    width: min(95%, 560px);
    padding: 14px 14px;
    border-radius: 16px;
    gap: 10px;
  }

  .tutorial-avatar {
    width: 38px;
    height: 38px;
  }

  .tutorial-dialog-text {
    font-size: 0.92rem;
    line-height: 1.36;
  }

  .tutorial-dialog-meta {
    font-size: 0.62rem;
  }

  .start-menu {
    padding:
      max(12px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .menu-title {
    font-size: clamp(2.4rem, 12vw, 4rem);
    top: max(18px, env(safe-area-inset-top));
  }

  .interlude-actions {
    gap: 8px;
  }

  .interlude-button {
    min-width: 100px;
    padding: 10px 14px;
    font-size: 0.76rem;
  }
}

@media (max-width: 560px) {
  .app-shell {
    gap: 6px;
  }

  .hud,
  .footer-bar {
    padding: 7px 9px;
  }

  .hud-label {
    font-size: 0.52rem;
  }

  .status-text {
    font-size: 0.7rem;
  }

  .install-action {
    min-width: 100%;
    min-height: 64px;
    padding: 15px 18px;
    font-size: 0.94rem;
  }

  .menu-button {
    min-height: 50px;
    font-size: 0.84rem;
  }

  .tutorial-button {
    width: 40px;
    height: 40px;
  }

  .menu-best-time {
    font-size: 0.68rem;
    gap: 8px;
  }

  .menu-best-time strong {
    font-size: 0.96rem;
  }

  .menu-orbs {
    font-size: 0.64rem;
    gap: 8px;
  }

  .menu-orbs strong {
    font-size: 0.88rem;
  }

  .shop-grid {
    grid-template-columns: 1fr;
    width: min(92vw, 360px);
  }

  .shape-preview {
    width: 78px;
    height: 78px;
  }

  .global-leaderboard-btn {
    left: max(8px, env(safe-area-inset-left));
    bottom: max(8px, env(safe-area-inset-bottom));
    width: 38px;
    height: 38px;
    min-height: 38px;
  }
}

@media (pointer: coarse) and (orientation: portrait) {
  .app-shell {
    gap: 5px;
    padding:
      max(6px, env(safe-area-inset-top))
      max(6px, env(safe-area-inset-right))
      max(6px, env(safe-area-inset-bottom))
      max(6px, env(safe-area-inset-left));
  }

  .hud,
  .footer-bar {
    padding: 6px 8px;
    gap: 6px;
    border-radius: 12px;
  }

  .hud-label {
    font-size: 0.48rem;
    letter-spacing: 0.14em;
  }

  .hud strong,
  .footer-item strong {
    font-size: clamp(0.78rem, 3vw, 0.94rem);
  }

  .status-text {
    font-size: 0.68rem;
    line-height: 1.16;
  }


  .message-panel {
    width: min(94%, 340px);
    padding: 14px 12px;
  }
}

@media (pointer: coarse) and (orientation: landscape) {
  .hud,
  .footer-bar {
    padding: 6px 10px;
    gap: 6px;
  }

  .status-text {
    font-size: 0.68rem;
    line-height: 1.14;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::after,
  .hud::after,
  .footer-bar::after,
  .game-stage::after,
  .message-panel,
  .app-shell,
  .install-action,
  .glitch-letter,
  .glitch-letter::before,
  .glitch-letter::after {
    animation: none;
    transition: none;
  }

  .startup-splash,
  .startup-title,
  .startup-byline,
  .startup-heart-icon {
    animation: none !important;
    transition: none !important;
  }
}
