:root {
  color-scheme: dark;
  --ink-950: #030711;
  --ink-900: #070d1d;
  --ink-850: #0a1428;
  --ink-800: #0e1d35;
  --paper: #fff7e8;
  --paper-dim: #d8d0c5;
  --gold: #e9bd73;
  --gold-bright: #ffe2a3;
  --gold-dark: #8e5d2b;
  --pink: #ff4fa3;
  --pink-hot: #ff2a91;
  --cyan: #43e8ff;
  --cyan-deep: #199fca;
  --violet: #a879ff;
  --danger: #ff5276;
  --success: #63f5c2;
  --glass: rgba(5, 13, 29, 0.8);
  --glass-heavy: rgba(3, 8, 19, 0.94);
  --line: rgba(233, 189, 115, 0.54);
  --display: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  --safe-top: max(12px, env(safe-area-inset-top));
  --safe-right: max(12px, env(safe-area-inset-right));
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  --safe-left: max(12px, env(safe-area-inset-left));
  --stage-scale: min(1vw, 1.78vh);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink-950);
}

body {
  display: grid;
  place-items: center;
  color: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
canvas:focus-visible,
a:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

[hidden],
.hidden,
.is-hidden {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 999;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: var(--ink-950);
  background: var(--paper);
  border-radius: 8px;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.game-shell {
  position: relative;
  isolation: isolate;
  width: min(100vw, calc(100svh * 16 / 9));
  height: min(100svh, calc(100vw * 9 / 16));
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 44%, rgba(49, 29, 86, 0.55), transparent 38%),
    linear-gradient(155deg, #111f3d 0%, #050a16 60%, #02040b 100%);
  box-shadow: 0 0 0 1px rgba(255, 226, 163, 0.1), 0 24px 80px #000;
  contain: layout paint size;
}

#game {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  image-rendering: auto;
}

.screen-light,
.screen-grain {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
}

.screen-light {
  background:
    linear-gradient(90deg, rgba(1, 5, 15, 0.3), transparent 16%, transparent 84%, rgba(1, 5, 15, 0.3)),
    linear-gradient(0deg, rgba(1, 4, 12, 0.42), transparent 16%, transparent 88%, rgba(1, 4, 12, 0.25));
  box-shadow: inset 0 0 11vmin rgba(0, 0, 0, 0.54);
}

.screen-grain {
  opacity: 0.12;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.025) 3px 4px),
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.18) 0 0.55px, transparent 0.8px);
  background-size: auto, 5px 5px;
  mix-blend-mode: soft-light;
}

.hud {
  position: absolute;
  z-index: 10;
  inset: 0;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.hud-player {
  position: absolute;
  top: calc(var(--safe-top) + 0.7%);
  left: calc(var(--safe-left) + 0.5%);
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.75vw, 12px);
  min-width: min(35vw, 470px);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.75));
}

.idol-portrait {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: clamp(50px, calc(var(--stage-scale) * 7.5), 90px);
  aspect-ratio: 1;
  color: var(--paper);
  overflow: hidden;
  background: linear-gradient(145deg, #ff6dae 0%, #5f3c89 45%, #14243c 100%);
  border: max(2px, 0.16vw) solid var(--gold-bright);
  border-radius: 50%;
  box-shadow:
    0 0 0 max(2px, 0.18vw) rgba(255, 65, 155, 0.75),
    0 0 20px rgba(255, 42, 145, 0.42),
    inset 0 0 18px rgba(0, 0, 0, 0.7);
}

.idol-portrait::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  content: "";
  background-image: url("assets/hina-sprites.png");
  background-repeat: no-repeat;
  background-size: 640% 427%;
  background-position: 7% 8%;
  image-rendering: pixelated;
  filter: saturate(1.05) contrast(1.04);
}

.portrait-halo {
  z-index: 1;
  position: absolute;
  inset: 9%;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 50%;
}

.portrait-monogram {
  display: none;
  position: relative;
  margin-top: 12%;
  font-family: var(--display);
  font-size: clamp(16px, calc(var(--stage-scale) * 2.5), 30px);
  font-weight: 800;
  text-shadow: 0 2px 6px #000, 0 0 8px var(--pink);
}

.player-vitals {
  display: grid;
  gap: clamp(4px, 0.55vh, 8px);
  width: min(26vw, 330px);
}

.hearts-row {
  min-height: 24px;
}

.hearts {
  display: flex;
  align-items: center;
  gap: clamp(2px, 0.28vw, 5px);
  color: #ff6486;
  font-size: clamp(20px, calc(var(--stage-scale) * 2.5), 31px);
  font-weight: 800;
  letter-spacing: clamp(1px, 0.18vw, 3px);
  line-height: 1;
  -webkit-text-stroke: 1px #ffd3dd;
  text-shadow: 0 0 6px rgba(255, 51, 117, 0.8), 0 2px 2px #000;
}

.heart {
  display: inline-grid;
  place-items: center;
  width: clamp(20px, calc(var(--stage-scale) * 2.7), 33px);
  height: clamp(20px, calc(var(--stage-scale) * 2.7), 33px);
  color: rgba(255, 255, 255, 0.12);
  font-size: clamp(20px, calc(var(--stage-scale) * 2.5), 31px);
  line-height: 1;
  -webkit-text-stroke: 1px rgba(255, 221, 229, 0.72);
  filter: drop-shadow(0 2px 2px #000);
}

.heart.is-full,
.heart.full {
  color: #ff6486;
  -webkit-text-stroke: 1px #ffd3dd;
  filter: drop-shadow(0 0 5px rgba(255, 51, 117, 0.8)) drop-shadow(0 2px 2px #000);
}

.heart.is-empty,
.heart.empty {
  color: rgba(14, 22, 41, 0.72);
}

.groove-row {
  display: flex;
  align-items: center;
  gap: clamp(5px, 0.5vw, 8px);
}

.meter-icon {
  color: var(--cyan);
  font-family: var(--display);
  font-size: clamp(19px, calc(var(--stage-scale) * 2.4), 30px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 8px rgba(67, 232, 255, 0.8);
}

.groove-meter {
  position: relative;
  flex: 1;
  height: clamp(12px, calc(var(--stage-scale) * 1.45), 18px);
  overflow: hidden;
  background: rgba(1, 6, 17, 0.82);
  border: 1px solid var(--gold-bright);
  border-radius: 3px 10px 3px 10px;
  box-shadow: 0 0 0 2px rgba(4, 8, 20, 0.7), inset 0 2px 5px #000;
  transform: skewX(-7deg);
}

.groove-fill {
  position: absolute;
  inset: 1px auto 1px 1px;
  width: var(--value, var(--groove, 0%));
  min-width: 0;
  border-radius: 2px 8px 2px 8px;
  background: linear-gradient(90deg, #29c9ff, #786fff 47%, #ff50c4 82%, #fff29a);
  box-shadow: 0 0 12px rgba(255, 83, 199, 0.7);
  transition: width 180ms ease-out;
}

.groove-fill-texture {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 14px, rgba(255, 255, 255, 0.24) 14px 15px);
}

.meter-shine {
  position: absolute;
  inset: 1px;
  opacity: 0.5;
  background: repeating-linear-gradient(90deg, transparent 0 9%, rgba(255, 255, 255, 0.28) 9.5% 10%, transparent 10.5% 19%);
}

.mission-card {
  position: absolute;
  top: calc(var(--safe-top) + 0.8%);
  left: 50%;
  width: clamp(250px, 29vw, 430px);
  padding: clamp(6px, 0.65vw, 10px) clamp(14px, 1.3vw, 20px) clamp(7px, 0.72vw, 11px);
  text-align: center;
  background: linear-gradient(180deg, rgba(5, 14, 31, 0.91), rgba(4, 10, 23, 0.72));
  border: 1px solid rgba(233, 189, 115, 0.7);
  clip-path: polygon(5% 0, 95% 0, 100% 50%, 95% 100%, 5% 100%, 0 50%);
  transform: translateX(-50%);
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.6));
}

.mission-card::before {
  content: "";
  position: absolute;
  inset: 3px 11px;
  border-block: 1px solid rgba(255, 226, 163, 0.14);
}

.location,
.objective {
  position: relative;
  z-index: 1;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location {
  color: var(--gold-bright);
  font-family: var(--display);
  font-size: clamp(10px, 0.82vw, 13px);
  font-weight: 800;
  letter-spacing: 0.16em;
}

.objective {
  margin-top: 2px;
  color: var(--paper-dim);
  font-size: clamp(9px, 0.72vw, 12px);
  letter-spacing: 0.035em;
}

.hud-resources {
  position: absolute;
  top: calc(var(--safe-top) + 0.7%);
  right: calc(var(--safe-right) + clamp(86px, 7.8vw, 118px));
  display: flex;
  gap: clamp(4px, 0.5vw, 8px);
}

.resource-chip {
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.45vw, 7px);
  min-width: clamp(54px, 5.4vw, 82px);
  height: clamp(29px, calc(var(--stage-scale) * 3), 38px);
  padding: 0 clamp(7px, 0.7vw, 11px);
  color: var(--paper);
  font-size: clamp(11px, 0.92vw, 15px);
  font-weight: 800;
  letter-spacing: 0.035em;
  background: linear-gradient(180deg, rgba(10, 25, 48, 0.94), rgba(4, 11, 26, 0.9));
  border: 1px solid var(--line);
  border-radius: 4px 11px 4px 11px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.48), inset 0 1px rgba(255, 255, 255, 0.06);
}

.resource-chip > :first-child {
  font-size: 1.2em;
  text-shadow: 0 0 8px currentColor;
}

.resource-notes > :first-child { color: var(--cyan); }
.resource-fans > :first-child { color: var(--gold-bright); }
.resource-secrets > :first-child { color: var(--pink); }

.combo {
  position: absolute;
  top: 16%;
  left: calc(var(--safe-left) + 1.5%);
  display: grid;
  justify-items: center;
  color: #fff4f7;
  filter: drop-shadow(0 3px 4px #000);
  visibility: hidden;
  opacity: 0;
}

.combo.is-visible {
  visibility: visible;
  opacity: 1;
  animation: combo-pop 180ms cubic-bezier(0.2, 1.7, 0.5, 1);
}

.combo-number {
  font-family: var(--display);
  font-size: clamp(32px, 5.8vw, 78px);
  font-weight: 700;
  line-height: 0.86;
  text-shadow: 0 0 6px #fff, 0 0 18px var(--pink), 0 0 35px rgba(255, 42, 145, 0.55);
}

.combo-label {
  margin-top: 7px;
  color: var(--gold-bright);
  font-size: clamp(9px, 0.8vw, 13px);
  font-weight: 900;
  letter-spacing: 0.28em;
}

@keyframes combo-pop {
  from { opacity: 0; transform: scale(1.4); }
  to { opacity: 1; transform: scale(1); }
}

.boss-bar {
  position: absolute;
  top: 12%;
  left: 50%;
  width: min(52%, 680px);
  transform: translateX(-50%);
  filter: drop-shadow(0 4px 8px #000);
}

.boss-heading {
  display: flex;
  justify-content: space-between;
  margin: 0 1.5% 5px;
  color: var(--gold-bright);
  font-family: var(--display);
  font-size: clamp(10px, 0.84vw, 14px);
  font-weight: 800;
  letter-spacing: 0.15em;
  text-shadow: 0 2px 3px #000;
}

.boss-health-meter {
  position: relative;
  height: clamp(12px, 1.4vw, 19px);
  padding: 2px;
  overflow: hidden;
  background: #080714;
  border: 1px solid var(--gold);
  border-radius: 2px 10px 2px 10px;
  box-shadow: 0 0 0 2px rgba(1, 3, 10, 0.72), inset 0 2px 5px #000;
}

.boss-health-fill {
  display: block;
  width: var(--boss-health, 100%);
  height: 100%;
  background: linear-gradient(90deg, #8b1d61, var(--pink-hot), #ff7bb9);
  border-radius: inherit;
  box-shadow: 0 0 13px var(--pink-hot);
  transition: width 220ms ease-out;
}

.beat-pulse {
  --beat-color: var(--cyan);
  position: absolute;
  bottom: 7.5%;
  left: 50%;
  display: grid;
  place-items: center;
  width: clamp(38px, 4vw, 58px);
  aspect-ratio: 1;
  color: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(4, 12, 28, 0.56);
  box-shadow: 0 0 12px color-mix(in srgb, var(--beat-color) 60%, transparent), inset 0 0 10px rgba(255, 255, 255, 0.1);
  transform: translateX(-50%);
  opacity: 0.75;
}

.beat-pulse.is-beat,
.beat-pulse.pulse {
  animation: beat-hit 260ms ease-out;
}

.beat-ring {
  position: absolute;
  inset: -1px;
  border: 2px solid var(--beat-color);
  border-radius: 50%;
  opacity: 0.65;
}

.beat-core {
  font-family: var(--display);
  font-size: clamp(15px, 1.8vw, 25px);
  text-shadow: 0 0 8px var(--beat-color);
}

@keyframes beat-hit {
  0% { opacity: 1; transform: translateX(-50%) scale(1.32); box-shadow: 0 0 30px var(--beat-color); }
  100% { opacity: 0.75; transform: translateX(-50%) scale(1); }
}

.system-controls {
  position: absolute;
  z-index: 35;
  top: calc(var(--safe-top) + 0.7%);
  right: calc(var(--safe-right) + 0.4%);
  display: flex;
  gap: clamp(4px, 0.45vw, 7px);
}

.icon-button,
.close-button {
  display: grid;
  place-items: center;
  width: clamp(32px, calc(var(--stage-scale) * 3.35), 43px);
  aspect-ratio: 1;
  padding: 0;
  color: var(--gold-bright);
  font-weight: 900;
  background: linear-gradient(180deg, rgba(10, 25, 47, 0.96), rgba(3, 9, 21, 0.96));
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

.icon-button:hover,
.close-button:hover {
  color: #fff;
  border-color: var(--gold-bright);
  box-shadow: 0 0 15px rgba(233, 189, 115, 0.3), inset 0 1px rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.icon-button:active,
.close-button:active {
  transform: translateY(1px) scale(0.96);
}

#mute-button .sound-off {
  display: none;
}

#mute-button[aria-pressed="true"] .sound-on {
  opacity: 0.35;
}

#mute-button[aria-pressed="true"] .sound-off {
  position: absolute;
  display: block;
  color: var(--danger);
  font-size: 1.4em;
}

.toast {
  position: absolute;
  z-index: 30;
  top: 20%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: min(76%, 270px);
  max-width: min(88%, 580px);
  padding: clamp(10px, 1vw, 15px) clamp(18px, 2vw, 30px);
  color: var(--paper);
  font-family: var(--display);
  font-size: clamp(13px, 1.3vw, 19px);
  text-align: center;
  background: linear-gradient(90deg, rgba(5, 14, 31, 0.96), rgba(31, 15, 44, 0.96), rgba(5, 14, 31, 0.96));
  border-block: 1px solid var(--gold);
  border-radius: 6px;
  box-shadow: 0 8px 28px #000, 0 0 22px rgba(255, 79, 163, 0.15);
  visibility: hidden;
  opacity: 0;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast.is-visible {
  visibility: visible;
  opacity: 1;
  animation: toast-in 260ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.toast-icon {
  flex: 0 0 auto;
  color: var(--pink);
  text-shadow: 0 0 8px var(--pink);
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -12px) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.dialogue {
  position: absolute;
  z-index: 32;
  right: 10%;
  bottom: 4.5%;
  left: 10%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(10px, 1.3vw, 20px);
  min-height: clamp(82px, 10vw, 130px);
  padding: clamp(12px, 1.2vw, 18px) clamp(14px, 1.5vw, 24px);
  background:
    linear-gradient(90deg, rgba(13, 25, 48, 0.98), rgba(5, 11, 25, 0.98)),
    var(--glass-heavy);
  border: 1px solid var(--gold);
  border-radius: 8px 22px 8px 22px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.72), inset 0 0 0 3px rgba(255, 255, 255, 0.025);
  pointer-events: auto;
  animation: dialogue-in 200ms ease-out;
}

.dialogue::before,
.dialogue::after {
  content: "";
  position: absolute;
  width: 42px;
  height: 18px;
  pointer-events: none;
}

.dialogue::before {
  top: -4px;
  left: -4px;
  border-top: 2px solid var(--pink);
  border-left: 2px solid var(--pink);
}

.dialogue::after {
  right: -4px;
  bottom: -4px;
  border-right: 2px solid var(--cyan);
  border-bottom: 2px solid var(--cyan);
}

.dialogue-portrait {
  display: grid;
  place-items: center;
  width: clamp(50px, 6vw, 82px);
  aspect-ratio: 1;
  color: #fff;
  font-family: var(--display);
  font-size: clamp(20px, 2.5vw, 34px);
  background: radial-gradient(circle at 55% 36%, #ffafd1, #5a2955 39%, #141b34 72%);
  border: 2px solid var(--gold-bright);
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(255, 79, 163, 0.35);
}

.dialogue-copy {
  min-width: 0;
}

.dialogue-speaker,
.dialogue-text {
  margin: 0;
}

.dialogue-speaker {
  margin-bottom: 5px;
  color: var(--pink);
  font-family: var(--display);
  font-size: clamp(14px, 1.25vw, 19px);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.dialogue-text {
  color: var(--paper);
  font-size: clamp(12px, 1.1vw, 17px);
  line-height: 1.55;
}

.dialogue-next {
  display: grid;
  place-items: center;
  width: clamp(34px, 3.4vw, 48px);
  aspect-ratio: 1;
  padding: 0;
  color: var(--cyan);
  font-size: clamp(25px, 3vw, 40px);
  line-height: 1;
  background: rgba(17, 40, 66, 0.75);
  border: 1px solid rgba(67, 232, 255, 0.62);
  border-radius: 50%;
  cursor: pointer;
  animation: dialogue-arrow 900ms ease-in-out infinite alternate;
}

@keyframes dialogue-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes dialogue-arrow {
  to { transform: translateX(4px); box-shadow: 0 0 15px rgba(67, 232, 255, 0.32); }
}

.overlay {
  position: absolute;
  z-index: 24;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  overflow: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 50% 42%, rgba(72, 31, 90, 0.24), transparent 40%),
    rgba(1, 5, 14, 0.76);
  backdrop-filter: blur(7px) saturate(0.85);
  -webkit-backdrop-filter: blur(7px) saturate(0.85);
  pointer-events: auto;
  animation: overlay-in 220ms ease-out;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.title-overlay {
  z-index: 26;
  align-content: center;
  justify-items: center;
  gap: clamp(15px, 2.4vh, 28px);
  padding-top: max(var(--safe-top), 4vh);
  padding-bottom: max(var(--safe-bottom), 3vh);
  text-align: center;
  background:
    linear-gradient(90deg, rgba(2, 7, 19, 0.72), rgba(5, 8, 23, 0.25) 30% 70%, rgba(2, 7, 19, 0.72)),
    radial-gradient(ellipse at 50% 46%, rgba(255, 54, 157, 0.12), transparent 42%),
    linear-gradient(180deg, rgba(1, 5, 14, 0.32), rgba(1, 5, 14, 0.76));
}

.title-overlay::before,
.title-overlay::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.title-overlay::before {
  inset: clamp(12px, 2vw, 28px);
  border: 1px solid rgba(233, 189, 115, 0.32);
  clip-path: polygon(0 0, 24% 0, 25% 2px, 75% 2px, 76% 0, 100% 0, 100% 100%, 76% 100%, 75% calc(100% - 2px), 25% calc(100% - 2px), 24% 100%, 0 100%);
}

.title-overlay::after {
  inset: 0;
  opacity: 0.55;
  background:
    radial-gradient(circle at 15% 19%, rgba(255, 79, 163, 0.8) 0 1px, transparent 2px),
    radial-gradient(circle at 79% 24%, rgba(67, 232, 255, 0.7) 0 1px, transparent 2px),
    radial-gradient(circle at 32% 82%, rgba(255, 226, 163, 0.8) 0 1px, transparent 2px),
    radial-gradient(circle at 88% 74%, rgba(255, 79, 163, 0.7) 0 1px, transparent 2px);
  background-size: 140px 130px, 170px 160px, 210px 190px, 250px 220px;
  animation: star-drift 12s linear infinite;
}

@keyframes star-drift {
  to { background-position: 140px -130px, -170px 160px, 210px -190px, -250px -220px; }
}

.title-sakura,
.title-lockup,
.title-actions,
.control-legend {
  position: relative;
  z-index: 1;
}

.title-sakura {
  margin-bottom: -8px;
  color: var(--pink);
  font-size: clamp(10px, 1.3vw, 17px);
  letter-spacing: 0.8em;
  text-shadow: 0 0 10px var(--pink);
}

.title-kicker,
.title-japanese,
.title-tagline {
  margin: 0;
}

.title-kicker {
  color: var(--gold-bright);
  font-size: clamp(8px, 0.76vw, 12px);
  font-weight: 800;
  letter-spacing: 0.42em;
}

.game-title {
  margin: clamp(4px, 0.7vh, 8px) 0 0;
  color: var(--paper);
  font-family: var(--display);
  font-size: clamp(42px, 8vw, 108px);
  font-weight: 500;
  letter-spacing: 0.13em;
  line-height: 0.92;
  text-indent: 0.13em;
  text-shadow:
    0 2px 0 #3b264b,
    0 0 9px rgba(255, 255, 255, 0.3),
    0 0 28px rgba(255, 79, 163, 0.22),
    0 5px 20px #000;
}

.title-japanese {
  margin-top: clamp(5px, 0.9vh, 10px);
  color: var(--gold-bright);
  font-family: var(--display);
  font-size: clamp(15px, 2.1vw, 28px);
  letter-spacing: 0.72em;
  text-indent: 0.72em;
  text-shadow: 0 0 11px rgba(233, 189, 115, 0.5);
}

.title-rule {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(52vw, 540px);
  margin: clamp(8px, 1.3vh, 14px) auto clamp(7px, 1.2vh, 13px);
  color: var(--pink);
}

.title-rule::before,
.title-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}

.title-rule::after {
  background: linear-gradient(90deg, var(--gold), transparent);
}

.title-tagline {
  color: var(--paper-dim);
  font-size: clamp(10px, 1vw, 15px);
  letter-spacing: 0.08em;
}

.title-actions {
  display: flex;
  justify-content: center;
  gap: clamp(8px, 1vw, 14px);
  width: min(90%, 680px);
}

.menu-button {
  position: relative;
  min-width: min(330px, 72vw);
  min-height: clamp(44px, 6.8vh, 68px);
  padding: clamp(9px, 1.1vh, 13px) clamp(22px, 2.5vw, 38px);
  overflow: hidden;
  color: var(--paper);
  font-family: var(--display);
  font-size: clamp(14px, 1.35vw, 19px);
  font-weight: 700;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, rgba(19, 34, 58, 0.98), rgba(7, 13, 29, 0.98));
  border: 1px solid var(--gold);
  border-radius: 4px 15px 4px 15px;
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.46), inset 0 0 0 2px rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, filter 140ms ease, box-shadow 140ms ease;
}

.menu-button::after {
  content: "";
  position: absolute;
  top: -80%;
  left: -30%;
  width: 24%;
  height: 260%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transform: rotate(19deg);
  transition: left 420ms ease;
}

.menu-button:hover {
  filter: brightness(1.13);
  border-color: var(--gold-bright);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.54), 0 0 18px rgba(233, 189, 115, 0.22);
  transform: translateY(-2px);
}

.menu-button:hover::after {
  left: 110%;
}

.menu-button:active {
  transform: translateY(1px) scale(0.985);
}

.menu-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: saturate(0.2);
}

.menu-button span,
.menu-button small {
  display: block;
}

.menu-button small {
  margin-top: 3px;
  color: rgba(255, 247, 232, 0.64);
  font-family: var(--sans);
  font-size: clamp(8px, 0.68vw, 11px);
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.menu-button-primary {
  background:
    linear-gradient(135deg, rgba(116, 24, 74, 0.96), rgba(45, 20, 66, 0.98)),
    var(--pink);
  border-color: #ffb4d1;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.48), 0 0 20px rgba(255, 42, 145, 0.22), inset 0 1px rgba(255, 255, 255, 0.16);
}

.menu-button-secondary {
  background: linear-gradient(135deg, rgba(15, 52, 77, 0.98), rgba(9, 19, 39, 0.98));
  border-color: rgba(67, 232, 255, 0.72);
}

.menu-button-danger {
  color: #ffb8c5;
  border-color: rgba(255, 82, 118, 0.55);
}

.control-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px clamp(12px, 1.5vw, 22px);
  max-width: 92%;
  color: rgba(255, 247, 232, 0.64);
  font-size: clamp(8px, 0.66vw, 11px);
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 1.8em;
  min-height: 1.8em;
  margin-right: 3px;
  padding: 0.1em 0.45em;
  color: var(--gold-bright);
  font-family: var(--sans);
  font-size: 0.88em;
  font-weight: 800;
  background: rgba(3, 10, 23, 0.76);
  border: 1px solid rgba(233, 189, 115, 0.44);
  border-radius: 4px;
  box-shadow: inset 0 -2px rgba(0, 0, 0, 0.35);
}

.menu-panel {
  position: relative;
  width: min(86%, 480px);
  padding: clamp(24px, 4vw, 54px);
  text-align: center;
  background:
    linear-gradient(155deg, rgba(13, 27, 51, 0.98), rgba(3, 8, 19, 0.99)),
    var(--glass-heavy);
  border: 1px solid var(--gold);
  border-radius: 7px 28px 7px 28px;
  box-shadow: 0 20px 70px #000, inset 0 0 0 4px rgba(255, 255, 255, 0.025);
}

.menu-panel::before,
.menu-panel::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 18%;
  pointer-events: none;
}

.menu-panel::before {
  top: -6px;
  left: -6px;
  border-top: 2px solid var(--pink);
  border-left: 2px solid var(--pink);
}

.menu-panel::after {
  right: -6px;
  bottom: -6px;
  border-right: 2px solid var(--cyan);
  border-bottom: 2px solid var(--cyan);
}

.panel-kicker {
  margin: 0 0 8px;
  color: var(--pink);
  font-size: clamp(9px, 0.78vw, 12px);
  font-weight: 900;
  letter-spacing: 0.28em;
}

.menu-panel h2 {
  margin: 0;
  color: var(--paper);
  font-family: var(--display);
  font-size: clamp(30px, 4vw, 52px);
  font-weight: 500;
  line-height: 1.1;
  text-shadow: 0 0 18px rgba(255, 79, 163, 0.2);
}

.panel-copy {
  max-width: 34em;
  margin: 14px auto 24px;
  color: var(--paper-dim);
  font-size: clamp(11px, 1vw, 15px);
  line-height: 1.55;
}

.menu-stack {
  display: grid;
  gap: 10px;
}

.menu-stack .menu-button,
.menu-panel > .menu-button {
  width: 100%;
  min-width: 0;
}

.menu-hint {
  margin: 18px 0 0;
  color: rgba(255, 247, 232, 0.45);
  font-size: 11px;
}

.map-overlay {
  background: rgba(1, 6, 16, 0.89);
}

.map-panel {
  position: relative;
  width: min(92%, 1060px);
  max-height: 92%;
  overflow: auto;
  background:
    linear-gradient(rgba(67, 232, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(67, 232, 255, 0.035) 1px, transparent 1px),
    linear-gradient(145deg, rgba(10, 28, 51, 0.99), rgba(3, 9, 22, 0.99));
  background-size: 28px 28px, 28px 28px, auto;
  border: 1px solid var(--gold);
  border-radius: 5px 22px 5px 22px;
  box-shadow: 0 20px 70px #000, inset 0 0 60px rgba(9, 24, 49, 0.72);
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: clamp(16px, 2vw, 28px) clamp(18px, 2.5vw, 34px) clamp(12px, 1.4vw, 20px);
  border-bottom: 1px solid rgba(233, 189, 115, 0.24);
}

.map-header h2 {
  margin: 0;
  color: var(--paper);
  font-family: var(--display);
  font-size: clamp(22px, 2.7vw, 38px);
  font-weight: 500;
  letter-spacing: 0.12em;
}

.map-header h2 span {
  margin-left: 0.5em;
  color: var(--gold-bright);
  font-family: var(--sans);
  font-size: 0.36em;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.close-button {
  flex: 0 0 auto;
  font-size: clamp(20px, 2.2vw, 30px);
}

.map-content {
  position: relative;
  min-height: 250px;
  padding: 1% 3% 0;
}

.map-route {
  display: block;
  width: 100%;
  max-height: 42vh;
  overflow: visible;
}

.map-route-list {
  position: absolute;
  right: 5%;
  bottom: 10%;
  left: 5%;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(4px, 1vw, 14px);
  pointer-events: none;
}

.map-route-list .map-node {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  padding: clamp(5px, 0.7vw, 9px);
  color: rgba(255, 247, 232, 0.46);
  text-align: center;
  background: rgba(3, 10, 23, 0.86);
  border: 1px solid rgba(255, 247, 232, 0.18);
  border-radius: 3px 9px 3px 9px;
}

.map-route-list .map-node span,
.map-route-list .map-node strong,
.map-route-list .map-node small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-route-list .map-node span {
  color: inherit;
  font-size: clamp(8px, 0.7vw, 11px);
  font-weight: 900;
}

.map-route-list .map-node strong {
  margin-top: 2px;
  color: inherit;
  font-family: var(--display);
  font-size: clamp(9px, 0.82vw, 13px);
}

.map-route-list .map-node small {
  margin-top: 1px;
  font-size: clamp(6px, 0.5vw, 8px);
  letter-spacing: 0.06em;
}

.map-route-list .map-node.is-visited {
  color: var(--cyan);
  border-color: rgba(67, 232, 255, 0.4);
}

.map-route-list .map-node.is-active {
  color: #fff;
  background: rgba(111, 23, 74, 0.9);
  border-color: var(--pink);
  box-shadow: 0 0 14px rgba(255, 79, 163, 0.42);
  transform: translateY(-4px);
}

.map-street,
.map-progress {
  fill: none;
  stroke: rgba(213, 196, 176, 0.35);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 6 10;
}

.map-street-faint {
  stroke: rgba(67, 232, 255, 0.1);
  stroke-width: 2;
}

.map-progress {
  stroke: var(--pink);
  stroke-width: 5;
}

.map-node circle {
  fill: var(--ink-900);
  stroke: rgba(255, 247, 232, 0.52);
  stroke-width: 4;
}

.map-node text {
  fill: var(--paper-dim);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-anchor: middle;
}

.map-node.is-cleared circle {
  fill: var(--cyan-deep);
  stroke: var(--cyan);
}

.map-node.is-current circle {
  fill: var(--pink);
  stroke: #fff;
  stroke-width: 5;
  filter: drop-shadow(0 0 10px var(--pink));
}

.map-node.is-locked {
  opacity: 0.42;
}

.map-legend {
  position: absolute;
  right: 4%;
  bottom: 3%;
  display: flex;
  gap: 17px;
  color: rgba(255, 247, 232, 0.6);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  aspect-ratio: 1;
  margin-right: 5px;
  border-radius: 50%;
  background: #6b7280;
}

.legend-dot.cleared { background: var(--cyan); }
.legend-dot.current { background: var(--pink); box-shadow: 0 0 6px var(--pink); }

.map-footer {
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1.4fr;
  gap: 1px;
  padding: 1px 0 0;
  background: rgba(233, 189, 115, 0.2);
  border-top: 1px solid rgba(233, 189, 115, 0.2);
}

.map-footer > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: clamp(11px, 1.4vw, 18px) clamp(14px, 1.8vw, 24px);
  background: rgba(3, 10, 23, 0.92);
}

.map-footer span {
  color: rgba(255, 247, 232, 0.5);
  font-size: clamp(8px, 0.7vw, 11px);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.map-footer strong {
  color: var(--gold-bright);
  font-family: var(--display);
  font-size: clamp(11px, 1vw, 15px);
  font-weight: 600;
  text-align: right;
}

.death-overlay {
  background:
    radial-gradient(circle, rgba(74, 9, 34, 0.24), transparent 48%),
    rgba(1, 3, 10, 0.88);
}

.death-overlay .menu-panel {
  filter: saturate(0.72);
}

.victory-overlay {
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 67, 166, 0.24), transparent 34%),
    rgba(2, 7, 18, 0.84);
}

.victory-rays {
  position: absolute;
  width: min(100vw, 100vh);
  aspect-ratio: 1;
  opacity: 0.2;
  background: repeating-conic-gradient(from 0deg, transparent 0deg 11deg, rgba(255, 226, 163, 0.75) 11deg 14deg, transparent 14deg 29deg);
  animation: victory-spin 32s linear infinite;
}

@keyframes victory-spin {
  to { transform: rotate(360deg); }
}

.victory-panel {
  z-index: 1;
}

.victory-grade {
  margin: 5px 0 12px;
  color: var(--gold-bright);
  font-family: var(--display);
  font-size: clamp(54px, 8vw, 94px);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 0 6px #fff, 0 0 20px var(--gold), 0 0 40px var(--pink);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0 0 22px;
  border-block: 1px solid rgba(233, 189, 115, 0.24);
}

.result-grid > div {
  padding: 11px 6px;
}

.result-grid > div + div {
  border-left: 1px solid rgba(233, 189, 115, 0.18);
}

.result-grid dt {
  color: rgba(255, 247, 232, 0.5);
  font-size: clamp(8px, 0.68vw, 10px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-grid dd {
  margin: 5px 0 0;
  color: var(--paper);
  font-family: var(--display);
  font-size: clamp(17px, 1.8vw, 25px);
}

.touch-controls {
  position: absolute;
  z-index: 18;
  inset: 0;
  display: none;
  pointer-events: none;
}

.touch-left,
.touch-right {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 2.5%);
  pointer-events: none;
}

.touch-left {
  left: calc(var(--safe-left) + 2.5%);
}

.touch-right {
  right: calc(var(--safe-right) + 2.5%);
  width: clamp(190px, 34vw, 280px);
  height: clamp(150px, 25vw, 220px);
}

.touch-button {
  position: absolute;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 800;
  background: rgba(8, 18, 37, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 50%;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.46), inset 0 0 18px rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  pointer-events: auto;
  touch-action: none;
}

.touch-button:active,
.touch-button.is-pressed,
.touch-button[data-input-active],
.touch-button.is-active,
.touch-button.active {
  color: #fff;
  background: rgba(255, 79, 163, 0.46);
  border-color: #fff;
  box-shadow: 0 0 18px rgba(255, 79, 163, 0.72), inset 0 0 15px rgba(255, 255, 255, 0.2);
  transform: scale(0.91);
}

.d-pad {
  position: relative;
  width: clamp(132px, 23vw, 188px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(5, 13, 28, 0.65) 0 34%, rgba(12, 26, 49, 0.44) 35% 68%, transparent 69%);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.42), 0 4px 18px rgba(0, 0, 0, 0.32);
  pointer-events: none;
}

.d-pad .touch-button {
  width: 38%;
  aspect-ratio: 1;
  font-size: clamp(11px, 2.1vw, 18px);
  background: rgba(13, 25, 46, 0.52);
  border-color: rgba(255, 255, 255, 0.18);
}

.d-up { top: 0; left: 31%; }
.d-down { bottom: 0; left: 31%; }
.d-left { top: 31%; left: 0; }
.d-right { top: 31%; right: 0; }

.d-pad-center {
  position: absolute;
  top: 37%;
  left: 37%;
  width: 26%;
  aspect-ratio: 1;
  border: 1px solid rgba(233, 189, 115, 0.26);
  border-radius: 50%;
  background: rgba(5, 11, 25, 0.52);
}

.action-button {
  width: clamp(48px, 8vw, 68px);
  aspect-ratio: 1;
  border-color: rgba(255, 255, 255, 0.38);
}

.action-glyph,
.action-name {
  line-height: 1;
}

.action-glyph {
  font-family: var(--display);
  font-size: clamp(17px, 3.2vw, 28px);
  text-shadow: 0 0 8px currentColor;
}

.action-name {
  margin-top: -5px;
  font-size: clamp(6px, 1.1vw, 9px);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.action-jump {
  right: 0;
  bottom: 38%;
  color: var(--cyan);
  border-color: rgba(67, 232, 255, 0.7);
}

.action-attack {
  right: 27%;
  bottom: 0;
  color: #ff7bbb;
  border-color: rgba(255, 79, 163, 0.74);
}

.action-dance {
  right: 52%;
  bottom: 44%;
  color: #c89aff;
  border-color: rgba(168, 121, 255, 0.68);
}

.action-dash {
  right: 31%;
  bottom: 72%;
  color: var(--cyan);
  border-color: rgba(67, 232, 255, 0.5);
}

.action-encore {
  right: 0;
  bottom: -1%;
  width: clamp(55px, 9vw, 77px);
  color: var(--gold-bright);
  border-color: rgba(255, 226, 163, 0.76);
  background: rgba(78, 46, 16, 0.58);
  box-shadow: 0 0 16px rgba(233, 189, 115, 0.2), inset 0 0 18px rgba(255, 226, 163, 0.08);
}

.action-encore.is-ready,
.action-encore.ready {
  animation: encore-ready 900ms ease-in-out infinite alternate;
}

.action-interact {
  right: 3%;
  bottom: 80%;
  width: clamp(32px, 5vw, 42px);
  color: var(--paper);
  border-color: rgba(255, 255, 255, 0.48);
}

@keyframes encore-ready {
  to { color: #fff; box-shadow: 0 0 28px var(--gold), inset 0 0 18px rgba(255, 255, 255, 0.2); transform: scale(1.06); }
}

.rotate-notice {
  position: absolute;
  z-index: 40;
  inset: 0;
  display: none;
  place-items: center;
  margin: 0;
  padding: 30px;
  color: var(--paper);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  background: rgba(2, 7, 17, 0.92);
}

.rotate-notice span {
  display: block;
  margin-bottom: 8px;
  color: var(--cyan);
  font-size: 30px;
}

.noscript-message {
  position: fixed;
  z-index: 9999;
  inset: 50% auto auto 50%;
  width: min(88%, 500px);
  margin: 0;
  padding: 22px;
  color: var(--paper);
  text-align: center;
  background: var(--ink-900);
  border: 1px solid var(--gold);
  border-radius: 8px;
  transform: translate(-50%, -50%);
}

@media (hover: none), (pointer: coarse) {
  .touch-controls {
    display: block;
  }

  .control-legend {
    display: none;
  }

  .beat-pulse {
    bottom: 3.5%;
  }

  .icon-button {
    min-width: 42px;
  }
}

@media (max-width: 700px) {
  .touch-controls {
    display: block;
  }
}

@media (max-aspect-ratio: 4 / 3) {
  .game-shell {
    width: 100vw;
    height: 100svh;
  }

  #game {
    right: auto;
    left: 50%;
    width: auto;
    min-width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
    transform: translateX(-50%);
  }

  .mission-card {
    top: calc(var(--safe-top) + 66px);
    width: min(67vw, 380px);
  }

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

  .player-vitals {
    width: min(47vw, 280px);
  }

  .hud-resources {
    top: calc(var(--safe-top) + 48px);
    right: calc(var(--safe-right) + 0.5%);
  }

  .resource-chip {
    min-width: 48px;
  }

  .resource-chip > :first-child {
    display: none;
  }

  .resource-secrets {
    display: none;
  }

  .boss-bar {
    top: calc(var(--safe-top) + 126px);
    width: 72%;
  }

  .dialogue {
    right: 4%;
    bottom: calc(var(--safe-bottom) + 19%);
    left: 4%;
  }

  .title-actions {
    flex-direction: column;
    align-items: center;
  }

  .map-panel {
    width: 96%;
  }
}

@media (orientation: portrait) and (hover: none) {
  :root {
    --stage-scale: min(1.7vw, 1.05vh);
  }

  .game-shell {
    width: 100vw;
    height: 100svh;
    aspect-ratio: auto;
  }

  #game {
    left: 50%;
    width: auto;
    min-width: 100%;
    height: 100%;
    aspect-ratio: 16 / 9;
    transform: translateX(-50%);
  }

  .screen-light {
    box-shadow: inset 0 0 16vmax rgba(0, 0, 0, 0.38);
  }

  .idol-portrait {
    width: clamp(52px, 15vw, 72px);
  }

  .player-vitals {
    width: min(52vw, 250px);
  }

  .heart {
    width: clamp(18px, 5.3vw, 27px);
    height: clamp(18px, 5.3vw, 27px);
    font-size: clamp(18px, 5.3vw, 27px);
  }

  .mission-card {
    top: calc(var(--safe-top) + 69px);
    width: min(78vw, 350px);
  }

  .location {
    font-size: 10px;
  }

  .objective {
    font-size: 9px;
  }

  .hud-resources {
    top: calc(var(--safe-top) + 46px);
    right: var(--safe-right);
  }

  .resource-chip {
    min-width: 48px;
    height: 27px;
    padding-inline: 7px;
    font-size: 11px;
  }

  .combo {
    top: 18%;
  }

  .combo-number {
    font-size: clamp(39px, 13vw, 62px);
  }

  .boss-bar {
    top: calc(var(--safe-top) + 123px);
    width: 82%;
  }

  .beat-pulse {
    bottom: calc(var(--safe-bottom) + 22%);
  }

  .touch-left,
  .touch-right {
    bottom: calc(var(--safe-bottom) + 3.5%);
  }

  .touch-left {
    left: calc(var(--safe-left) + 1%);
  }

  .touch-right {
    right: calc(var(--safe-right) + 1%);
    width: clamp(188px, 51vw, 245px);
    height: clamp(160px, 43vw, 208px);
  }

  .d-pad {
    width: clamp(132px, 38vw, 178px);
  }

  .action-button {
    width: clamp(49px, 13vw, 64px);
  }

  .action-encore {
    width: clamp(56px, 15vw, 72px);
  }

  .action-interact {
    width: clamp(34px, 9vw, 42px);
  }

  .dialogue {
    right: 3%;
    bottom: calc(var(--safe-bottom) + 23%);
    left: 3%;
    min-height: 84px;
  }

  .title-overlay {
    gap: clamp(13px, 2.3vh, 24px);
    padding-inline: max(var(--safe-left), 16px) max(var(--safe-right), 16px);
  }

  .game-title {
    font-size: clamp(40px, 14vw, 74px);
    letter-spacing: 0.06em;
    text-indent: 0.06em;
  }

  .title-japanese {
    font-size: clamp(16px, 5vw, 24px);
  }

  .title-rule {
    width: min(78vw, 430px);
  }

  .title-tagline {
    max-width: 30em;
    padding-inline: 12px;
    font-size: 11px;
    line-height: 1.5;
  }

  .menu-button {
    min-width: min(78vw, 330px);
    min-height: 54px;
  }

  .map-panel {
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--safe-left) - var(--safe-right));
    height: min(88%, 720px);
  }

  .map-content {
    display: grid;
    align-items: center;
    flex: 1;
  }

  .map-route {
    width: 165%;
    max-width: none;
    margin-left: -32%;
  }

  .map-legend {
    right: 4%;
    bottom: 2%;
    left: 4%;
    justify-content: center;
    gap: 12px;
    font-size: 8px;
  }

  .map-footer {
    grid-template-columns: repeat(2, 1fr);
  }

  .map-footer > div:last-child {
    grid-column: 1 / -1;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .title-overlay {
    gap: 7px;
    padding-block: max(var(--safe-top), 8px) max(var(--safe-bottom), 8px);
  }

  .title-sakura {
    display: none;
  }

  .game-title {
    font-size: clamp(38px, 9.4vh, 67px);
  }

  .title-japanese {
    font-size: clamp(13px, 3.1vh, 20px);
  }

  .title-rule {
    margin-block: 5px;
  }

  .title-actions .menu-button {
    min-height: 42px;
    padding-block: 6px;
  }

  .control-legend {
    display: none;
  }

  .dialogue {
    bottom: 3%;
    min-height: 70px;
  }

  .menu-panel {
    padding: 22px 34px;
  }

  .menu-panel h2 {
    font-size: 28px;
  }

  .panel-copy {
    margin-block: 8px 12px;
  }

  .menu-stack {
    grid-template-columns: repeat(3, 1fr);
  }

  .menu-stack .menu-button {
    min-height: 42px;
    padding: 6px 10px;
    font-size: 12px;
  }

  .menu-hint {
    display: none;
  }

  .map-header {
    padding-block: 10px;
  }

  .map-content {
    min-height: 180px;
  }

  .map-route {
    max-height: 44vh;
  }

  .map-footer > div {
    padding-block: 8px;
  }

  .touch-left,
  .touch-right {
    bottom: calc(var(--safe-bottom) + 1%);
  }

  .d-pad {
    width: clamp(112px, 22vh, 148px);
  }

  .touch-right {
    width: clamp(200px, 47vh, 270px);
    height: clamp(142px, 34vh, 194px);
  }

  .action-button {
    width: clamp(43px, 10.5vh, 59px);
  }

  .action-encore {
    width: clamp(49px, 12vh, 66px);
  }
}

@media (max-width: 520px) {
  .desktop-action {
    display: none;
  }

  .system-controls {
    right: var(--safe-right);
  }

  .dialogue-portrait {
    display: none;
  }

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

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

  .result-grid > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 4px;
  }

  .result-grid > div + div {
    border-top: 1px solid rgba(233, 189, 115, 0.18);
    border-left: 0;
  }

  .result-grid dd {
    margin: 0;
  }
}

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

@media (prefers-contrast: more) {
  :root {
    --line: rgba(255, 226, 163, 0.9);
  }

  .screen-grain {
    display: none;
  }

  .resource-chip,
  .mission-card,
  .icon-button,
  .dialogue,
  .menu-panel,
  .map-panel {
    background-color: #030711;
  }
}
