@font-face {
  font-family: Vazirmatn;
  src: url('./assets/vazirmatn-arabic.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range:
    U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: Vazirmatn;
  src: url('./assets/vazirmatn-latin.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
:root {
  --gold: #ffd36b;
  --gold-deep: #f0a640;
  --turq: #37ded6;
  --ink: #0b1530;
  --cream: #fff8e9;
  --panel: rgba(10, 16, 38, 0.62);
  --panel-strong: rgba(10, 16, 38, 0.82);
  --line: rgba(255, 255, 255, 0.14);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  font-family: Vazirmatn, system-ui, sans-serif;
  font-weight: 700;
  color: var(--cream);
  background: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: var(--ink);
}
#game {
  position: fixed;
  inset: 0;
}
#game canvas {
  display: block;
}
#interface {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
#interface button,
.controls,
.overlay:not(.playing) {
  pointer-events: auto;
}
button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
svg {
  width: 1.25em;
  height: 1.25em;
  flex: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.glass,
.icon-button,
.stage-pill,
.score-chip,
.chip,
.power-chip,
.dialog,
.toast,
.secondary {
  background: var(--panel);
  border: 1px solid var(--line);
}
/* Frosted glass only on still screens; in play the canvas changes every
   frame and a live backdrop blur costs mobile GPUs real frame time. */
.overlay .dialog,
.overlay .secondary,
.overlay .icon-button {
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
}
.hud .icon-button,
.hud .stage-pill,
.hud .score-chip,
.hud .chip,
.hud .power-chip,
.toast {
  background: rgba(10, 16, 38, 0.7);
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0 0 auto 0;
  padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 12px) 0
    calc(var(--safe-l) + 12px);
  display: grid;
  gap: 8px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.hud[hidden] {
  display: none;
}
.hud-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}
.hud-row.second {
  grid-template-columns: auto auto 1fr;
}
.hearts {
  display: flex;
  gap: 2px;
}
.heart svg {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 2px 4px rgba(120, 0, 30, 0.45));
  transition:
    transform 0.25s,
    opacity 0.25s,
    filter 0.25s;
}
.heart.lost svg {
  opacity: 0.28;
  filter: grayscale(1);
  transform: scale(0.82);
}
.stage-pill {
  justify-self: center;
  min-width: 0;
  max-width: 340px;
  width: 100%;
  border-radius: 16px;
  padding: 6px 12px 8px;
  text-align: center;
}
.stage-pill b {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track {
  position: relative;
  height: 6px;
  margin-top: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  overflow: visible;
}
.track > i {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--turq), var(--gold));
  transform-origin: left center;
  transform: scaleX(0);
  box-shadow: 0 0 10px rgba(255, 211, 107, 0.55);
}
[dir='rtl'] .track > i {
  transform-origin: right center;
}
#lantern-marks i {
  position: absolute;
  top: -3px;
  width: 4px;
  height: 12px;
  border-radius: 3px;
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
  translate: -50% 0;
}
[dir='rtl'] #lantern-marks i {
  translate: 50% 0;
}
.hud-actions {
  display: flex;
  gap: 8px;
}
.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  transition:
    transform 0.15s,
    background 0.2s;
}
.icon-button:active {
  transform: scale(0.92);
}
.icon-button.muted {
  color: #ff9aa8;
}
.score-chip {
  border-radius: 14px;
  padding: 4px 12px 6px;
  line-height: 1.1;
}
.score-chip small {
  display: block;
  font-size: 10px;
  opacity: 0.7;
  letter-spacing: 0.08em;
}
.score-chip b {
  font-size: 22px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.collect {
  justify-self: end;
  display: flex;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 10px 0 6px;
  border-radius: 12px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.chip svg,
.chip img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.chip.clock {
  padding: 0 10px;
  opacity: 0.85;
}
.power-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px 0 4px;
  border-radius: 99px;
  font-size: 13px;
  animation: pop-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
.power-chip[hidden] {
  display: none;
}
.power-ring {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: conic-gradient(
    var(--power-color, var(--turq)) calc(var(--power, 1) * 360deg),
    rgba(255, 255, 255, 0.14) 0
  );
  -webkit-mask: radial-gradient(circle, transparent 10px, #000 11px);
  mask: radial-gradient(circle, transparent 10px, #000 11px);
}
#power-icon {
  margin-inline-start: -32px;
  width: 30px;
  display: grid;
  place-items: center;
}
#power-icon svg {
  width: 18px;
  height: 18px;
}
.combo {
  position: absolute;
  top: 30%;
  left: 50%;
  translate: -50% 0;
  font-size: 34px;
  color: var(--gold);
  text-shadow:
    0 0 18px rgba(255, 180, 60, 0.8),
    0 3px 0 #6a3a10;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.combo.show {
  animation: combo 1.1s ease-out forwards;
}
@keyframes combo {
  0% {
    opacity: 0;
    transform: scale(0.4) rotate(-6deg);
  }
  18% {
    opacity: 1;
    transform: scale(1.18) rotate(2deg);
  }
  35% {
    transform: scale(1) rotate(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-40px) scale(1);
  }
}
.toast {
  position: absolute;
  top: calc(var(--safe-t) + 178px);
  left: 50%;
  translate: -50% -10px;
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 15px;
  opacity: 0;
  transition:
    opacity 0.25s,
    translate 0.25s;
  white-space: nowrap;
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show {
  opacity: 1;
  translate: -50% 0;
}
.toast[data-tone='power'] {
  border-color: rgba(103, 255, 227, 0.6);
  box-shadow: 0 0 24px rgba(103, 255, 227, 0.35);
}
.toast[data-tone='gold'] {
  border-color: rgba(255, 211, 107, 0.6);
  box-shadow: 0 0 24px rgba(255, 211, 107, 0.35);
}
.toast[data-tone='heart'] {
  border-color: rgba(255, 111, 138, 0.6);
  box-shadow: 0 0 24px rgba(255, 111, 138, 0.35);
}

/* ---------- touch controls (thumb zones) ---------- */
.controls {
  position: absolute;
  inset: auto 0 0 0;
  height: min(40vh, 280px);
  display: flex;
  direction: ltr;
  pointer-events: none;
}
.controls[hidden] {
  display: none;
}
.pad-move,
.pad-jump {
  position: relative;
  height: 100%;
  pointer-events: auto;
  touch-action: none;
}
.pad-move {
  flex: 1.15;
}
.pad-jump {
  flex: 1;
}
.pad-btn {
  position: absolute;
  bottom: calc(var(--safe-b) + 26px);
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 30px;
  background: radial-gradient(
    circle at 35% 30%,
    rgba(255, 255, 255, 0.26),
    rgba(255, 255, 255, 0.07) 60%
  );
  border: 1.5px solid rgba(255, 255, 255, 0.32);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  color: #fff;
  transition:
    transform 0.08s,
    background 0.12s,
    box-shadow 0.12s;
}
.pad-btn.l {
  left: calc(var(--safe-l) + 20px);
}
.pad-btn.r {
  left: calc(var(--safe-l) + 112px);
}
.pad-btn.j {
  right: calc(var(--safe-r) + 24px);
  width: 92px;
  height: 92px;
  font-size: 36px;
  bottom: calc(var(--safe-b) + 34px);
}
.pad-move[data-left='true'] .l,
.pad-move[data-right='true'] .r,
.pad-jump[data-held='true'] .j {
  transform: scale(0.9);
  background: radial-gradient(
    circle at 35% 30%,
    rgba(255, 236, 170, 0.75),
    rgba(255, 190, 80, 0.35) 65%
  );
  box-shadow:
    0 0 28px rgba(255, 200, 90, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* ---------- overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-t) + 16px) calc(var(--safe-r) + 16px)
    calc(var(--safe-b) + 16px) calc(var(--safe-l) + 16px);
  overflow: auto;
}
.overlay[hidden] {
  display: none;
}
.overlay.paused,
.overlay.won,
.overlay.lost,
.overlay.board,
.overlay.help,
.overlay.error {
  background: radial-gradient(
    ellipse at 50% 40%,
    rgba(10, 16, 38, 0.35),
    rgba(6, 10, 26, 0.78)
  );
  animation: fade 0.3s ease-out;
}
.overlay.loading {
  background: radial-gradient(ellipse at 50% 35%, #1e3c78, #0b1530 70%);
}
.loading-card {
  text-align: center;
  width: min(320px, 80vw);
}
.loading-card h1 {
  margin: 16px 0 6px;
  font-size: 26px;
}
.loading-card p {
  margin: 0 0 18px;
  opacity: 0.75;
}
.load-track {
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.load-track i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--turq), var(--gold));
  transition: width 0.3s;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.12em;
  font-size: 15px;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 20px;
  color: var(--ink);
  background: linear-gradient(
    140deg,
    #fff2c2,
    var(--gold) 45%,
    var(--gold-deep)
  );
  box-shadow:
    0 0 24px rgba(255, 211, 107, 0.45),
    inset 0 1px 0 #fff;
}
.loading-card .brand-mark {
  width: 64px;
  height: 64px;
  font-size: 34px;
  border-radius: 20px;
  animation: breathe 2.4s ease-in-out infinite;
}
.eyebrow {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--turq);
}
.fine {
  font-size: 12.5px;
  line-height: 1.6;
  opacity: 0.82;
  margin: 8px 0 0;
}
.fine.dim {
  opacity: 0.6;
}
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  margin-top: 16px;
  border-radius: 18px;
  font-size: 18px;
  color: #2a1606;
  background: linear-gradient(
    180deg,
    #fff1bf,
    var(--gold) 45%,
    var(--gold-deep)
  );
  box-shadow:
    0 10px 30px rgba(255, 170, 60, 0.35),
    inset 0 1px 0 #fff,
    inset 0 -3px 0 rgba(150, 70, 0, 0.35);
  transition:
    transform 0.12s,
    filter 0.2s;
}
.primary.big {
  min-height: 64px;
  font-size: 21px;
}
.primary:active {
  transform: translateY(2px) scale(0.985);
}
.primary:disabled {
  filter: saturate(0.4) brightness(0.85);
}
[dir='rtl'] .primary svg,
[dir='rtl'] .text-button svg {
  transform: scaleX(-1);
}
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 15px;
  font-size: 15px;
  transition: transform 0.12s;
}
.secondary:active {
  transform: scale(0.97);
}
.text-button {
  margin-top: 12px;
  font-size: 14px;
  opacity: 0.8;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.dialog {
  width: min(440px, 100%);
  border-radius: 26px;
  padding: 24px 20px 20px;
  text-align: center;
  background: var(--panel-strong);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  animation: rise 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.dialog h1 {
  margin: 8px 0 4px;
  font-size: 26px;
}
.dialog-symbol {
  display: inline-grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.08);
  margin-bottom: 6px;
}
.dialog-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

/* ---------- menu ---------- */
.overlay.menu {
  place-items: end center;
  padding-bottom: calc(var(--safe-b) + 18px);
}
.menu-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(6, 10, 26, 0.5) 0%, rgba(6, 10, 26, 0) 22%),
    linear-gradient(
      0deg,
      rgba(6, 10, 26, 0.94) 0%,
      rgba(6, 10, 26, 0.72) 40%,
      rgba(6, 10, 26, 0) 70%
    );
}
.menu-top {
  position: absolute;
  inset: calc(var(--safe-t) + 14px) calc(var(--safe-r) + 16px) auto
    calc(var(--safe-l) + 16px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.menu-card {
  position: relative;
  width: min(460px, 100%);
  text-align: center;
  animation: rise 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.menu-hero {
  display: block;
  width: 150px;
  height: 192px;
  margin: 0 auto -6px;
  filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.45));
}
.title {
  margin: 6px 0 2px;
  line-height: 1.05;
}
.title span {
  display: block;
  font-size: clamp(34px, 10vw, 50px);
  background: linear-gradient(
    180deg,
    #fffaf0 10%,
    var(--gold) 55%,
    var(--gold-deep)
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 14px rgba(255, 170, 60, 0.35));
}
.title small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  letter-spacing: 0.42em;
  color: var(--turq);
}
.subtitle {
  margin: 8px 0 14px;
  font-size: 14px;
  opacity: 0.85;
}
.stage-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  text-align: start;
}
.stage-card small {
  display: block;
  font-size: 10.5px;
  opacity: 0.65;
}
.stage-card > div:first-child b {
  font-size: 30px;
  color: var(--gold);
  line-height: 1;
}
.realm-name b {
  display: block;
  font-size: 15px;
}
.realms {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.realm {
  width: 22px;
  height: 7px;
  border-radius: 9px;
  opacity: 0.35;
}
.realm.on {
  opacity: 1;
  box-shadow: 0 0 10px currentColor;
}
.realm.valley {
  background: linear-gradient(90deg, #78bdf5, #ffe9c2);
  color: #ffe9c2;
}
.realm.bridges {
  background: linear-gradient(90deg, #7a3f8f, #ffb36b);
  color: #ffb36b;
}
.realm.garden {
  background: linear-gradient(90deg, #0c1838, #37ded6);
  color: #37ded6;
}
.realm.citadel {
  background: linear-gradient(90deg, #a7b8ff, #ffd1e6);
  color: #ffd1e6;
}
.best {
  text-align: end;
}
.best b {
  font-size: 14px;
}
.menu-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

/* ---------- help ---------- */
.help-dialog {
  max-height: calc(100vh - 32px);
  overflow: auto;
}
.how-grid {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  text-align: start;
}
.how {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}
.how-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 20px;
  color: var(--gold);
  background: rgba(255, 211, 107, 0.12);
}
.how-icon svg {
  width: 24px;
  height: 24px;
}
.how b {
  display: block;
  font-size: 14px;
}
.how small {
  display: block;
  font-size: 12px;
  opacity: 0.75;
  line-height: 1.5;
}
.powers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 12px;
}
.power {
  padding: 8px 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}
.power span svg {
  width: 30px;
  height: 30px;
}
.power b {
  display: block;
  font-size: 11.5px;
  margin-top: 2px;
}
.power small {
  display: block;
  font-size: 10px;
  opacity: 0.7;
  line-height: 1.4;
}

/* ---------- results ---------- */
.result-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 6px 0 0;
}
.star {
  font-style: normal;
  font-size: 46px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.16);
  transform: scale(0);
  animation: star-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.6) forwards;
  animation-delay: calc(0.25s + var(--i) * 0.18s);
}
.star:nth-child(2) {
  font-size: 58px;
  margin-top: -10px;
}
.star.on {
  color: var(--gold);
  text-shadow:
    0 0 20px rgba(255, 200, 80, 0.8),
    0 3px 0 #a0601a;
}
.result-symbol {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  font-size: 26px;
  background: rgba(255, 111, 138, 0.18);
  color: #ffb3c0;
}
.record {
  display: inline-block;
  margin: 2px 0 6px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 13px;
  color: var(--ink);
  background: linear-gradient(90deg, var(--turq), #b6fff4);
  animation: breathe 1.6s ease-in-out infinite;
}
.result-score small {
  display: block;
  font-size: 11px;
  opacity: 0.65;
}
.result-score b {
  font-size: 40px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(255, 190, 70, 0.45);
}
.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 12px 0 0;
}
.result-stats > div {
  padding: 8px 2px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}
.result-stats span svg {
  width: 22px;
  height: 22px;
  color: var(--turq);
}
.result-stats small {
  display: block;
  font-size: 10px;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-stats b {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.credit-note {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(55, 222, 214, 0.1);
  border: 1px solid rgba(55, 222, 214, 0.25);
  font-size: 12.5px;
}
.credit-note b {
  display: block;
  font-size: 16px;
  color: var(--turq);
}
.credit-note.pending {
  background: rgba(255, 211, 107, 0.1);
  border-color: rgba(255, 211, 107, 0.3);
}
.credit-note.pending b {
  color: var(--gold);
}

/* ---------- leaderboard ---------- */
.board-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  text-align: start;
  min-height: 60px;
}
.board-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}
.board-rank {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
}
.top1 .board-rank {
  background: linear-gradient(140deg, #fff2c2, var(--gold));
  color: var(--ink);
}
.top2 .board-rank {
  background: linear-gradient(140deg, #ffffff, #b9c6d8);
  color: var(--ink);
}
.top3 .board-rank {
  background: linear-gradient(140deg, #ffd2a8, #c98652);
  color: var(--ink);
}
.board-row b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-score {
  text-align: end;
  font-size: 13px;
}
.board-score small {
  display: block;
  opacity: 0.6;
  font-size: 11px;
}

/* ---------- landscape phones and desktop ---------- */
@media (orientation: landscape) {
  .overlay.menu {
    place-items: center end;
    padding-inline-end: calc(var(--safe-r) + 6vw);
  }
  [dir='rtl'] .overlay.menu {
    place-items: center start;
  }
  .menu-shade {
    background:
      linear-gradient(180deg, rgba(6, 10, 26, 0.45) 0%, rgba(6, 10, 26, 0) 25%),
      linear-gradient(
        270deg,
        rgba(6, 10, 26, 0.92) 0%,
        rgba(6, 10, 26, 0.6) 40%,
        rgba(6, 10, 26, 0) 75%
      );
  }
  [dir='rtl'] .menu-shade {
    background:
      linear-gradient(180deg, rgba(6, 10, 26, 0.45) 0%, rgba(6, 10, 26, 0) 25%),
      linear-gradient(
        90deg,
        rgba(6, 10, 26, 0.92) 0%,
        rgba(6, 10, 26, 0.6) 40%,
        rgba(6, 10, 26, 0) 75%
      );
  }
  .hud {
    grid-template-columns: 1fr;
  }
  .hud-row.second {
    position: absolute;
    top: calc(var(--safe-t) + 62px);
    inset-inline: calc(var(--safe-l) + 12px) calc(var(--safe-r) + 12px);
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  .menu-hero {
    display: none;
  }
  .title span {
    font-size: 34px;
  }
  .subtitle,
  .fine.dim {
    display: none;
  }
  .primary.big {
    min-height: 52px;
    margin-top: 10px;
  }
  .stage-card {
    padding: 8px 12px;
  }
  .controls {
    height: 60vh;
  }
  .pad-btn {
    bottom: calc(var(--safe-b) + 16px);
  }
  .dialog {
    padding: 14px 16px;
  }
  .result-stars .star {
    font-size: 34px;
  }
  .result-score b {
    font-size: 30px;
  }
}
@media (max-width: 480px) {
  .chip.clock {
    display: none;
  }
  #power-name {
    display: none;
  }
  .power-chip {
    padding: 0 4px;
  }
  .chip {
    padding: 0 8px 0 4px;
    font-size: 14px;
  }
}
.power-chip,
.chip {
  white-space: nowrap;
}
@media (min-width: 900px) {
  .stage-pill b {
    font-size: 15px;
  }
  .score-chip b {
    font-size: 26px;
  }
}

/* ---------- motion ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes pop-in {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
}
@keyframes star-pop {
  to {
    transform: scale(1);
  }
}
@keyframes breathe {
  50% {
    transform: scale(1.05);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
  .star {
    transform: scale(1);
  }
}
html[data-preview='true'] #interface {
  display: none;
}
@media (max-width: 420px) {
  .dialog-actions .secondary {
    font-size: 14px;
    padding: 0 8px;
    gap: 6px;
  }
  .dialog-actions .secondary svg {
    display: none;
  }
}

/* ---------- phase 2: shards, medals, guardian, stage select ---------- */
.sun {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  background: radial-gradient(
    circle,
    #fff7cc 20%,
    #ffc93d 45%,
    #d4801a 70%,
    transparent 72%
  );
  clip-path: polygon(
    50% 0,
    61% 30%,
    93% 21%,
    72% 46%,
    100% 62%,
    66% 66%,
    72% 100%,
    50% 76%,
    28% 100%,
    34% 66%,
    0 62%,
    28% 46%,
    7% 21%,
    39% 30%
  );
}
.chip .sun {
  width: 22px;
  height: 22px;
}
.chip.clock[data-tier='gold'] {
  color: #ffd36b;
}
.chip.clock[data-tier='silver'] {
  color: #dfe7f2;
}
.chip.clock[data-tier='bronze'] {
  color: #e8a26a;
}
.chip.clock[data-tier='late'] {
  opacity: 0.6;
}
.boss-bar {
  justify-self: center;
  width: min(320px, 70vw);
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: #ffb38a;
}
.boss-bar[hidden] {
  display: none;
}
.boss-track {
  height: 9px;
  border-radius: 99px;
  background: rgba(10, 16, 38, 0.7);
  border: 1px solid rgba(255, 179, 138, 0.5);
  overflow: hidden;
  margin-top: 3px;
}
.boss-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ff5d73, #ffb35c);
  transform-origin: left center;
  transition: transform 0.3s;
}
.banner {
  position: absolute;
  top: 34%;
  left: 50%;
  translate: -50% 0;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.55);
}
.banner small {
  display: block;
  font-size: 15px;
  letter-spacing: 0.2em;
  color: #37ded6;
}
.banner b {
  display: block;
  font-size: clamp(30px, 8vw, 46px);
  color: #fff8e9;
}
.banner em {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 14px;
  border-radius: 99px;
  font-style: normal;
  background: rgba(255, 93, 115, 0.85);
}
.banner.show {
  animation: banner 2.4s ease-out forwards;
}
@keyframes banner {
  0% {
    opacity: 0;
    transform: scale(0.85);
  }
  15%,
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-20px);
  }
}
.medals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.medal {
  padding: 6px 2px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  opacity: 0.45;
  font-size: 12px;
}
.medal.on {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}
.medal i,
.medal-dot {
  display: block;
  width: 20px;
  height: 20px;
  margin: 0 auto 2px;
  border-radius: 50%;
}
.medal-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin: 0 2px;
}
.m3 i,
.medal-dot.m3 {
  background: radial-gradient(circle at 35% 30%, #fff6c8, #ffc43d 55%, #b9741a);
}
.m2 i,
.medal-dot.m2 {
  background: radial-gradient(circle at 35% 30%, #ffffff, #c9d3e0 55%, #7d8ca0);
}
.m1 i,
.medal-dot.m1 {
  background: radial-gradient(circle at 35% 30%, #ffe0c4, #d9895a 55%, #8a4a25);
}
.medal small {
  display: block;
  opacity: 0.75;
}
.extras {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 8px;
  font-size: 13px;
}
.extras .on {
  color: #ff8fa3;
}
.secondary.wide {
  width: 100%;
  margin-top: 10px;
}
.stages-dialog {
  max-height: calc(100vh - 32px);
  overflow: auto;
}
.worlds {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  text-align: start;
}
.world-row small {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: #37ded6;
}
.stage-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.stage-tile {
  aspect-ratio: 1;
  border-radius: 12px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 15px;
}
.stage-tile.done {
  background: rgba(55, 222, 214, 0.14);
}
.stage-tile.boss {
  border-color: rgba(255, 93, 115, 0.6);
}
.stage-tile.locked {
  opacity: 0.3;
}
.tile-stars {
  font-size: 9px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.25);
}
.tile-stars .on {
  color: #ffd36b;
}
.tile-stars i {
  font-style: normal;
}
.tile-meta {
  font-size: 9px;
  min-height: 10px;
}
.tile-meta .sun {
  width: 9px;
  height: 9px;
  vertical-align: -1px;
}
