:root {
  color-scheme: dark;
  --bg: #080d18;
  --bg-elevated: #0f1524;
  --panel: rgba(15, 21, 36, 0.82);
  --panel-solid: #121a2a;
  --border: rgba(25, 215, 242, 0.14);
  --border-strong: rgba(25, 215, 242, 0.28);
  --text: #f4f7ff;
  --muted: #8b9bb8;
  --cyan: #19d7f2;
  --blue-magic: #267bff;
  --violet: #7b61ff;
  --magenta: #e82d98;
  --gold: #ffd166;
  --nature: #20c997;
  --good: #20c997;
  --accent: #19d7f2;
  --accent2: #7b61ff;
  --glow-cyan: rgba(25, 215, 242, 0.35);
  --glow-violet: rgba(123, 97, 255, 0.28);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-display: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html.scroll-locked,
body.scroll-locked {
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  width: 100%;
  height: 100%;
}

body {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ── Ambient background ── */
.app-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(25, 215, 242, 0.08), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 80%, rgba(123, 97, 255, 0.06), transparent 50%),
    var(--bg);
}

.app-bg-runes {
  position: absolute;
  inset: -20%;
  opacity: 0.14;
  background-image:
    radial-gradient(circle at center, transparent 38%, rgba(25, 215, 242, 0.5) 39%, transparent 40%),
    radial-gradient(circle at center, transparent 58%, rgba(123, 97, 255, 0.35) 59%, transparent 60%);
  background-size: 88px 88px;
  background-position: center;
  animation: rune-drift 48s linear infinite;
}

.app-bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
}

.app-bg-glow--cyan {
  width: 220px;
  height: 220px;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--glow-cyan);
}

.app-bg-glow--violet {
  width: 180px;
  height: 180px;
  bottom: 18%;
  right: -40px;
  background: var(--glow-violet);
}

body.theme-adventure .app-bg-glow--cyan {
  background: rgba(32, 201, 151, 0.22);
}

body.theme-arena .app-bg {
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(232, 45, 152, 0.1), transparent 55%),
    radial-gradient(ellipse 50% 35% at 0% 100%, rgba(25, 215, 242, 0.07), transparent 50%),
    var(--bg);
}

@keyframes rune-drift {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.run-active #app {
  max-width: none;
}

body.run-active .top-bar {
  display: none;
}

body.run-active main {
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

body.run-active .screen-run {
  flex: 1;
  display: flex !important;
  flex-direction: column;
}

/* ── Top bar ── */
.top-bar {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  padding-top: calc(0.65rem + var(--safe-top));
  border-bottom: 1px solid var(--border);
  background: rgba(8, 13, 24, 0.88);
  backdrop-filter: blur(8px);
}

.top-bar[hidden] {
  display: none !important;
}

.top-bar-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  color: var(--muted);
}

.btn-icon {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(15, 21, 36, 0.9);
  color: var(--cyan);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.ys-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(15, 21, 36, 0.92);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.35rem 0.75rem 0.35rem 0.55rem;
  font-size: 0.82rem;
  color: var(--cyan);
  font-weight: 700;
  box-shadow: 0 0 12px rgba(25, 215, 242, 0.12);
}

.ys-icon {
  display: block;
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

.ys-icon--lg {
  width: 1.375rem;
  height: 1.375rem;
}

.ys-icon--inline {
  width: 1rem;
  height: 1rem;
  vertical-align: -0.15em;
  margin-right: 0.15rem;
}

.shop-balance-line {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.ys-pill--gold {
  color: var(--gold);
  border-color: rgba(255, 209, 102, 0.35);
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.12);
}

main {
  flex: 1;
  padding: 1rem;
  padding-bottom: calc(1rem + var(--safe-bottom));
}

.screen[hidden] {
  display: none !important;
}

/* ── Typography ── */
.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan);
}

.eyebrow--nature { color: var(--nature); }
.eyebrow--arena { color: var(--magenta); }

.screen-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.screen-title--arena {
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.screen-title--victory { color: var(--gold); }
.screen-title--defeat { color: var(--magenta); }

.screen-intro {
  margin-bottom: 1rem;
}

.screen-sub {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.section-label {
  margin: 0 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

/* ── Panels & buttons ── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
}

.panel-glass {
  background: rgba(12, 18, 32, 0.78);
  backdrop-filter: blur(10px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    0 8px 32px rgba(0, 0, 0, 0.35);
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(15, 21, 36, 0.92);
  color: var(--text);
  border-radius: 0.65rem;
  padding: 0.7rem 1rem;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), var(--blue-magic));
  border-color: rgba(25, 215, 242, 0.45);
  color: #041018;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 0 18px rgba(25, 215, 242, 0.25);
}

.btn-accent {
  background: linear-gradient(135deg, var(--violet), var(--magenta));
  border-color: transparent;
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn-lg {
  padding: 1rem;
  font-size: 0.95rem;
}

.btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
}

.btn-stack {
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}

.stat-line {
  margin: 0.35rem 0;
}

/* ── HOME ── */
.screen-home {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 2rem);
  padding: 0.25rem 0 0;
}

.home-ys {
  align-self: flex-end;
  margin-bottom: 0.5rem;
}

.home-auth {
  align-self: stretch;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.35rem;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.35rem 0.25rem 0.25rem;
  background: rgba(8, 13, 24, 0.72);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.auth-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
}

.auth-name {
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.auth-signin {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.auth-providers {
  display: flex;
  gap: 0.35rem;
}

.btn-auth {
  border-color: rgba(25, 215, 242, 0.35);
}

.btn-auth-out {
  font-size: 1rem;
  line-height: 1;
  opacity: 0.75;
}

.vic-ranked {
  color: var(--cyan);
  font-size: 0.85rem;
}

.home-hero {
  position: relative;
  text-align: center;
  padding: 0.75rem 0 1.25rem;
}

.home-studio {
  position: relative;
  margin: 0 0 0.5rem;
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.home-logo {
  position: relative;
  margin: 0;
  line-height: 0;
}

.home-logo-img {
  display: block;
  width: min(88vw, 320px);
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 0 24px rgba(25, 215, 242, 0.22));
}

.home-tagline {
  position: relative;
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.home-menu {
  display: grid;
  gap: 0.65rem;
  flex: 1;
}

.btn-hero {
  display: grid;
  gap: 0.25rem;
  text-align: left;
  padding: 1rem 1.1rem;
  border-radius: 0.85rem;
}

.btn-hero-label {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.btn-hero-sub {
  font-size: 0.76rem;
  font-weight: 400;
  line-height: 1.35;
  opacity: 0.85;
}

.btn-hero--adventure {
  background: linear-gradient(135deg, rgba(32, 201, 151, 0.18), rgba(255, 209, 102, 0.1));
  border-color: rgba(32, 201, 151, 0.45);
  box-shadow: 0 0 20px rgba(32, 201, 151, 0.12);
  color: var(--text);
}

.btn-hero--adventure .btn-hero-label { color: var(--nature); }

.btn-hero--arena {
  background: linear-gradient(135deg, rgba(25, 215, 242, 0.12), rgba(232, 45, 152, 0.12));
  border-color: rgba(123, 97, 255, 0.4);
  box-shadow: 0 0 20px rgba(123, 97, 255, 0.12);
  color: var(--text);
}

.btn-hero--arena .btn-hero-label {
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.home-menu-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.btn-menu-secondary {
  padding: 0.65rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}

.home-foot {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 1rem 0 0.25rem;
}

.home-foot a {
  color: var(--muted);
  text-decoration: none;
}

/* ── ADVENTURE MAP ── */
.screen-adventure {
  padding-bottom: 0.5rem;
}

.adventure-path {
  display: grid;
  gap: 0.75rem;
}

.stage-card {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0;
  padding: 0;
  border-radius: 0.85rem;
  border: 1px solid var(--border);
  background: rgba(10, 16, 28, 0.75);
  overflow: hidden;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.stage-card-thumb {
  min-height: 5.5rem;
  position: relative;
}

.stage-card-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 60%, rgba(8, 13, 24, 0.85));
}

.stage-theme-forest { background: linear-gradient(160deg, #0d3d35, #20c997 45%, #7b61ff); }
.stage-theme-path { background: linear-gradient(160deg, #2a3d1a, #20c997, #ffd166); }
.stage-theme-marsh { background: linear-gradient(160deg, #1a2a4a, #267bff, #20c997); }
.stage-theme-mist { background: linear-gradient(160deg, #1a2238, #7b61ff, #94a3b8); }
.stage-theme-ancient { background: linear-gradient(160deg, #1a3320, #ffd166, #20c997); }

.stage-card-body {
  padding: 0.75rem 0.85rem 0.75rem 0;
  display: grid;
  gap: 0.15rem;
  align-content: center;
}

.stage-card-num {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--gold);
}

.stage-card-body strong {
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.stage-card-meta {
  font-size: 0.72rem;
  color: var(--muted);
}

.stage-card-reward {
  font-size: 0.72rem;
  color: var(--gold);
  font-weight: 600;
}

.stage-card-status {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  width: fit-content;
}

.stage-card.is-available {
  border-color: rgba(32, 201, 151, 0.45);
  box-shadow: 0 0 16px rgba(32, 201, 151, 0.1);
}

.stage-card.is-available .stage-card-status {
  color: var(--nature);
  border-color: rgba(32, 201, 151, 0.35);
}

.stage-card.is-completed {
  border-color: rgba(255, 209, 102, 0.4);
}

.stage-card.is-completed .stage-card-status {
  color: var(--gold);
  border-color: rgba(255, 209, 102, 0.35);
}

.stage-card.is-locked {
  opacity: 0.48;
  cursor: not-allowed;
}

.stage-card.is-locked .stage-card-thumb {
  filter: grayscale(0.6);
}

/* ── BRIEFING ── */
.overlay-briefing {
  z-index: 30;
  background: rgba(4, 8, 16, 0.88);
  backdrop-filter: blur(6px);
}

.briefing-panel {
  width: min(100%, 380px);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
}

.boss-portrait-slot {
  position: relative;
  width: 7rem;
  height: 7rem;
  margin: 0 auto 1rem;
  border-radius: 1rem;
  border: 1px dashed rgba(25, 215, 242, 0.35);
  background: rgba(8, 13, 24, 0.6);
  display: grid;
  place-items: center;
  --boss-glow: #7b61ff;
}

.boss-portrait-glow {
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--boss-glow) 40%, transparent), transparent 70%);
}

.boss-portrait-icon {
  font-size: 2rem;
  font-weight: 800;
  color: var(--violet);
  z-index: 1;
}

.boss-portrait-label {
  position: absolute;
  bottom: 0.35rem;
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.briefing-title {
  margin: 0 0 0.75rem;
  text-align: center;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
}

.briefing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.briefing-stat {
  padding: 0.55rem 0.65rem;
  border-radius: 0.55rem;
  background: rgba(8, 13, 24, 0.55);
  border: 1px solid var(--border);
}

.briefing-stat span {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.briefing-stat strong {
  color: var(--cyan);
  font-size: 0.88rem;
}

.boss-attacks-slot {
  margin-bottom: 0.5rem;
}

.attacks-list {
  margin: 0;
  padding: 0 0 0 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.attacks-list li {
  margin-bottom: 0.25rem;
}

.btn-fight {
  box-shadow: 0 0 22px rgba(32, 201, 151, 0.2);
}

/* ── FULL SKILL ARENA ── */
.screen-arena {
  padding-bottom: 1rem;
}

.pact-list {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.pact-card {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: rgba(8, 13, 24, 0.65);
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.pact-card.is-selected {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(25, 215, 242, 0.15);
}

.pact-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  border: 1px solid var(--border);
}

.pact-card--magenta .pact-icon {
  background: rgba(232, 45, 152, 0.15);
  border-color: rgba(232, 45, 152, 0.35);
  color: var(--magenta);
}

.pact-card--cyan .pact-icon {
  background: rgba(25, 215, 242, 0.12);
  border-color: rgba(25, 215, 242, 0.35);
  color: var(--cyan);
}

.pact-card--purple .pact-icon {
  background: rgba(123, 97, 255, 0.15);
  border-color: rgba(123, 97, 255, 0.35);
  color: var(--violet);
}

.pact-card strong {
  display: block;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pact-card small {
  color: var(--muted);
  font-size: 0.72rem;
}

.pact-detail {
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}

.pact-detail ul {
  margin: 0.5rem 0 0;
  padding-left: 1rem;
  color: var(--muted);
}

.panel-arena-lb {
  margin-bottom: 1rem;
}

.fullskill-lb {
  font-size: 0.82rem;
}

.lb-row {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}

.lb-row:last-child {
  border-bottom: none;
}

.arena-launch-wrap {
  position: sticky;
  bottom: 0;
  padding-top: 0.5rem;
}

.btn-arena-launch {
  width: 100%;
  display: grid;
  gap: 0.25rem;
  padding: 1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(135deg, rgba(25, 215, 242, 0.15), rgba(232, 45, 152, 0.15));
  border-color: rgba(123, 97, 255, 0.35);
  opacity: 0.55;
  cursor: not-allowed;
}

.badge-soon {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--magenta);
}

/* ── SHOP / SCORES ── */
.shop-list {
  display: grid;
  gap: 0.5rem;
}

.shop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem;
  background: rgba(8, 13, 24, 0.55);
  border-radius: 0.5rem;
  border: 1px solid var(--border);
}

.shop-row-info {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: help;
  -webkit-touch-callout: none;
  user-select: none;
}

.shop-row-info:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 0.25rem;
}

.shop-row-info span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.shop-tip-hint {
  font-size: 0.8rem;
  margin: 0.35rem 0 0;
}

.upgrade-tip {
  position: fixed;
  z-index: 2000;
  max-width: min(280px, calc(100vw - 24px));
  padding: 0.65rem 0.75rem;
  background: rgba(12, 20, 36, 0.96);
  border: 1px solid rgba(0, 220, 255, 0.35);
  border-radius: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  font-size: 0.85rem;
  line-height: 1.35;
  pointer-events: none;
}

.upgrade-tip strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--cyan);
  font-size: 0.9rem;
}

.upgrade-tip p {
  margin: 0;
  color: var(--text);
}

@media (prefers-reduced-motion: no-preference) {
  .upgrade-tip {
    animation: upgrade-tip-in 0.15s ease-out;
  }
}

@keyframes upgrade-tip-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scores-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.scores-scope {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.scores-scope.is-active,
.scores-scope .is-active {
  background: rgba(25, 215, 242, 0.14);
  border-color: rgba(25, 215, 242, 0.35);
}

.scores-stage-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.scores-stage-picker .btn.is-active {
  background: linear-gradient(135deg, var(--gold), #d4a017);
  border-color: transparent;
  color: #1a1200;
  font-weight: 700;
}

.global-lb-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  background: rgba(8, 13, 24, 0.55);
  border-radius: 0.5rem;
  border: 1px solid var(--border);
}

.global-lb-row.is-me {
  border-color: rgba(25, 215, 242, 0.45);
  box-shadow: 0 0 0 1px rgba(25, 215, 242, 0.12) inset;
}

.global-lb-rank {
  min-width: 1.75rem;
  font-weight: 700;
  color: var(--gold);
}

.global-lb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
}

.global-lb-main {
  flex: 1;
  min-width: 0;
}

.global-lb-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-lb-main span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.scores-tab.is-active {
  background: linear-gradient(135deg, var(--cyan), var(--blue-magic));
  border-color: transparent;
  color: #041018;
  font-weight: 700;
}

.scores-list {
  display: grid;
  gap: 0.4rem;
}

.score-stage-row {
  padding: 0.65rem;
  background: rgba(8, 13, 24, 0.55);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.score-stage-head strong {
  display: block;
}

.score-stage-stats {
  display: grid;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.score-stage-stats strong {
  color: var(--cyan);
}

.scores-soon {
  text-align: center;
  padding: 1.5rem 0;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.panel-victory h2,
.panel-victory .screen-title--victory {
  color: var(--gold);
}

/* ── RUN / GAMEPLAY (preserved) ── */
.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.hud-run {
  margin: 0;
  padding: 0.55rem 0.75rem;
  padding-top: calc(0.55rem + var(--safe-top));
  background: rgba(8, 13, 24, 0.94);
  border-bottom: 1px solid var(--border);
  justify-content: space-between;
}

.hud-stat {
  white-space: nowrap;
}

.hud strong {
  color: var(--cyan);
}

.btn-pause {
  margin-left: auto;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0;
  font-size: 1rem;
}

.run-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.run-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0;
  padding-bottom: var(--safe-bottom);
  min-height: 0;
}

body.run-active .run-stage {
  flex: 1;
  width: 100%;
}

body.run-active .screen-run .canvas-wrap {
  width: 100%;
  max-width: 100vw;
  height: auto;
  max-height: calc(100dvh - 3.25rem - var(--safe-top) - var(--safe-bottom));
  aspect-ratio: 9 / 16;
  flex: 1;
  border-radius: 0;
  border-left: none;
  border-right: none;
}

body.run-active .hint {
  display: none;
}

.joystick-root {
  position: absolute;
  left: max(0.75rem, env(safe-area-inset-left, 0px));
  bottom: calc(0.75rem + var(--safe-bottom));
  width: var(--vjoy-size, 136px);
  height: var(--vjoy-size, 136px);
  z-index: 5;
  touch-action: none;
}

.vjoy {
  position: relative;
  width: 100%;
  height: 100%;
}

.vjoy-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(15, 21, 36, 0.72);
  border: 2px solid rgba(25, 215, 242, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.vjoy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--vjoy-knob, 54px);
  height: var(--vjoy-knob, 54px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(25, 215, 242, 0.95), rgba(123, 97, 255, 0.85));
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.vjoy-active .vjoy-base {
  border-color: rgba(25, 215, 242, 0.65);
  background: rgba(15, 21, 36, 0.88);
}

body.is-touch .screen-run .canvas-wrap {
  touch-action: none;
}

.canvas-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  background: #000;
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 9 / 16;
}

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  z-index: 20;
  padding: 1rem;
  padding-top: calc(1rem + var(--safe-top));
  padding-bottom: calc(1rem + var(--safe-bottom));
}

.overlay-run {
  backdrop-filter: blur(4px);
}

.overlay[hidden] {
  display: none !important;
}

.pause-card,
.levelup-card {
  width: min(100%, 360px);
  text-align: center;
}

.levelup-sub {
  margin-bottom: 1rem;
}

.levelup-choices {
  display: grid;
  gap: 0.55rem;
}

.levelup-choice {
  display: grid;
  gap: 0.2rem;
  text-align: left;
  padding: 0.85rem 1rem;
  background: rgba(8, 13, 24, 0.65);
  border-color: var(--border);
}

.levelup-choice strong {
  color: var(--cyan);
  font-size: 0.95rem;
}

.levelup-choice span {
  color: var(--muted);
  font-size: 0.82rem;
}

.levelup-choice small {
  color: var(--nature);
  font-size: 0.75rem;
}

@media (min-width: 768px) {
  body.run-active .screen-run .canvas-wrap {
    width: min(405px, 100%);
    max-height: min(720px, calc(100dvh - 4rem));
    border-radius: 0.85rem;
    border: 1px solid var(--border);
  }

  body.is-touch .joystick-root {
    left: 50%;
    transform: translateX(calc(-50% - 8rem));
    bottom: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-bg-runes {
    animation: none;
  }
}
