/* =====================================================================
   ANIMA RUSH v2 — Stylesheet
   ===================================================================== */
:root {
  --gold: #ffd66b;
  --gold-dim: #a87a1d;
  --violet: #a06bff;
  --deep: #0a0518;
  --mist: #5a3aa0;
  --good: #7CFFB8;
  --bad: #ff5b7a;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; height: 100dvh; }
body {
  margin: 0; overflow: hidden; background: #000;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #fff; -webkit-font-smoothing: antialiased;
  touch-action: none;
  /* iOS WebKit needs the -webkit- prefixes to stop long-press text-selection,
     the magnifier loupe, and the copy/share callout menu — without these the
     installed PWA behaves like a web page, not a game. */
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
/* Re-enable selection + callout ONLY for real text entry (login, search, chat)
   so the keyboard caret / paste still work where they're needed. */
input, textarea, [contenteditable="true"] {
  user-select: text; -webkit-user-select: text;
  -webkit-touch-callout: default;
}

#stage {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  background:
    radial-gradient(120% 80% at 50% 10%, #2a1660 0%, #120840 35%, #06021f 70%, #000 100%);
}

#frame {
  position: relative;
  width:  min(100vw,  calc(100vh * 16/9));
  height: min(100vh,  calc(100vw * 9/16));
  width:  min(100dvw, calc(100dvh * 16/9));
  height: min(100dvh, calc(100dvw * 9/16));
  aspect-ratio: 16/9;
  box-shadow: 0 30px 80px rgba(160,107,255,0.25), 0 0 0 1px rgba(255,255,255,0.06) inset;
  border-radius: 12px; overflow: hidden;
  background: #06021f;
}

canvas { display: block; width: 100%; height: 100%; image-rendering: high-quality; }

#scene-root {
  position: absolute; inset: 0;
  pointer-events: auto;
  overflow: hidden;
}
.scene {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: clamp(12px, 2vw, 24px);
}

#floaters {
  position: absolute; inset: 0;
  pointer-events: none; overflow: hidden;
}
.floater {
  position: absolute; transform: translate(-50%, -50%);
  font-weight: 900;
  font-size: clamp(14px, 2.2vw, 28px);
  text-shadow: 0 2px 6px #000, 0 0 18px currentColor;
  animation: floatup 0.9s ease-out forwards;
  will-change: transform, opacity;
}
@keyframes floatup {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

/* =================== buttons =================== */
.btn {
  appearance: none; cursor: pointer; border: 0;
  font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 12px 24px; border-radius: 999px;
  font-size: clamp(13px, 1.6vw, 16px);
  background: linear-gradient(180deg, rgba(40,18,90,0.7), rgba(10,5,24,0.85));
  color: #c9b3ff;
  border: 1px solid rgba(160,107,255,0.4);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.15); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(180deg, var(--violet), #5e2eb8);
  color: #fff;
  box-shadow: 0 12px 30px rgba(160,107,255,0.45), 0 0 0 1px rgba(255,255,255,0.15) inset;
  border-color: transparent;
}
.btn.ghost {
  background: transparent;
  color: rgba(201,179,255,0.7);
  border: 1px solid rgba(255,255,255,0.15);
}

/* =================== shared bars =================== */
.xp-bar {
  width: 100%; height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 6px; overflow: hidden;
  margin: 6px 0 4px;
}
.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--violet));
  transition: width 0.4s ease;
}
.xp-text { font-size: 11px; color: #c9b3ff; opacity: 0.7; letter-spacing: 0.08em; }

.stat-label { display: block; font-size: 10px; color: #c9b3ff; letter-spacing: 0.18em; opacity: 0.7; }
.stat-val   { display: block; font-size: clamp(18px, 2.4vw, 26px); font-weight: 900; }

/* =================== TITLE SCREEN =================== */
.scene-title {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.title-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: brightness(0.55) saturate(1.15);
  animation: titleBgZoom 30s ease-in-out infinite alternate;
}
@keyframes titleBgZoom {
  0%   { transform: scale(1.05) translate(0, 0); }
  100% { transform: scale(1.18) translate(-3%, -1.5%); }
}
.title-vignette {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 50% at 50% 50%, transparent 20%, rgba(6,2,31,0.85) 100%),
    linear-gradient(180deg, rgba(6,2,31,0.6) 0%, transparent 40%, rgba(6,2,31,0.9) 100%);
}
.title-particles {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,0.5) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 70% 20%, rgba(160,107,255,0.7) 50%, transparent 50%),
    radial-gradient(2px 2px at 40% 70%, rgba(255,214,107,0.5) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 85% 85%, rgba(255,255,255,0.4) 50%, transparent 50%);
  animation: csParticles 10s linear infinite;
}
.title-content {
  position: relative; z-index: 2; text-align: center;
  padding: clamp(20px, 4vw, 48px);
  max-width: min(720px, 92vw);
}
.title-tag { font-size: 11px; letter-spacing: 0.4em; color: #c9b3ff; opacity: 0.7; margin-bottom: 18px; font-weight: 800; }
.title-logo {
  font-size: clamp(48px, 7vw, 88px); font-weight: 900;
  background: linear-gradient(180deg, #fff 0%, #d6b8ff 35%, #a06bff 60%, #5e2eb8 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 28px rgba(160,107,255,0.7));
  letter-spacing: 0.08em; line-height: 0.95; margin-bottom: 0;
}
.title-logo-sub {
  font-size: clamp(18px, 2.2vw, 26px);
  font-weight: 700; font-style: italic;
  color: var(--gold); letter-spacing: 0.18em;
  margin: -4px 0 12px;
  filter: drop-shadow(0 2px 12px rgba(255,214,107,0.5));
}
.title-tagline { font-size: 12px; color: #c9b3ff; opacity: 0.85; letter-spacing: 0.3em; margin-bottom: 28px; }
/* Boot loader subtitle ("New Light" under big "ANIMA WORLD") */
#boot-loader .title-sub {
  display: block;
  font-size: 0.34em; font-weight: 700; font-style: italic;
  color: var(--gold);
  letter-spacing: 0.16em; margin-top: 2px;
  background: none;
  -webkit-background-clip: initial; background-clip: initial;
  -webkit-text-fill-color: var(--gold);
}
.title-flavor {
  font-size: clamp(12px, 1.4vw, 14px); color: #c9b3ff;
  line-height: 1.8; opacity: 0.7; font-style: italic;
  margin: 0 auto 36px; max-width: 540px;
}
.title-start {
  appearance: none; cursor: pointer; border: 0;
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: #2a1500; font-weight: 900; letter-spacing: 0.24em; font-size: 16px;
  padding: 16px 42px; border-radius: 999px;
  box-shadow: 0 14px 36px rgba(255,214,107,0.45), 0 0 0 1px rgba(255,255,255,0.15) inset;
  animation: titleStartPulse 1.8s ease-in-out infinite;
}
.title-start:hover { filter: brightness(1.1); transform: translateY(-3px); }
@keyframes titleStartPulse {
  0%, 100% { box-shadow: 0 14px 36px rgba(255,214,107,0.45), 0 0 0 1px rgba(255,255,255,0.15) inset; transform: translateY(0); }
  50%      { box-shadow: 0 20px 56px rgba(255,214,107,0.85), 0 0 0 1px rgba(255,255,255,0.15) inset, 0 0 40px rgba(255,214,107,0.5); transform: translateY(-2px); }
}
.title-credit { position: absolute; bottom: 14px; right: 18px; font-size: 10px; color: rgba(201,179,255,0.4); letter-spacing: 0.3em; }

/* ================================================================
   LOGIN SCREEN (MMO-style entry)
   ================================================================ */
.login-layout {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  gap: 28px; padding: clamp(20px, 4vw, 48px);
  width: min(560px, 92vw);
  text-align: center;
}
.login-brand { display: flex; flex-direction: column; align-items: center; }
.login-brand .title-flavor { margin-bottom: 0; }

.login-card {
  width: 100%;
  background: linear-gradient(180deg, rgba(22,10,50,0.92), rgba(8,4,26,0.96));
  border: 1px solid rgba(160,107,255,0.4);
  border-radius: 16px;
  padding: 26px 28px 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55), 0 0 40px rgba(160,107,255,0.2);
  backdrop-filter: blur(8px);
}
.login-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  background: rgba(0,0,0,0.4); padding: 4px; border-radius: 9px;
}
.login-tab {
  flex: 1; background: none; border: 0; cursor: pointer;
  color: rgba(255,255,255,0.55);
  font-size: 12px; font-weight: 900; letter-spacing: 0.12em;
  padding: 11px; border-radius: 6px; transition: all 0.12s ease;
}
.login-tab.active {
  background: linear-gradient(180deg, rgba(160,107,255,0.4), rgba(80,40,160,0.55));
  color: #fff; box-shadow: 0 0 12px rgba(160,107,255,0.35);
}
.login-tab:hover:not(.active) { color: #fff; }
.login-form { display: flex; flex-direction: column; gap: 13px; }
.login-label {
  display: flex; flex-direction: column; gap: 5px; text-align: left;
  font-size: 10px; font-weight: 900; letter-spacing: 0.12em; color: rgba(201,179,255,0.75);
}
.login-label input {
  background: rgba(0,0,0,0.5); border: 1px solid rgba(160,107,255,0.3);
  color: #fff; font-size: 15px; font-family: inherit;
  padding: 12px 14px; border-radius: 7px; transition: border-color 0.12s ease;
}
.login-label input:focus { outline: none; border-color: #7CFFB8; }
.login-error {
  background: rgba(255,90,120,0.16); border: 1px solid rgba(255,90,120,0.5);
  color: #ffb6c0; font-size: 12px; padding: 9px 11px; border-radius: 6px; text-align: left;
}
.login-submit {
  margin-top: 6px; cursor: pointer; border: 0;
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: #2a1500; font-weight: 900; letter-spacing: 0.16em; font-size: 15px;
  padding: 14px; border-radius: 9px;
  box-shadow: 0 10px 28px rgba(255,214,107,0.4);
  transition: all 0.12s ease;
}
.login-submit:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-2px); }
.login-submit:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.login-links {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px;
}
.login-ghost-link {
  background: none; border: 0; cursor: pointer;
  color: rgba(201,179,255,0.75); font-size: 12px; font-weight: 700;
  font-family: inherit; padding: 4px 2px; transition: color 0.12s ease;
}
.login-ghost-link:hover { color: #fff; text-decoration: underline; }
.login-note { font-size: 11px; color: rgba(201,179,255,0.6); line-height: 1.5; }
.login-welcome { font-size: 12px; letter-spacing: 0.1em; color: rgba(201,179,255,0.7); text-align: center; }
.login-email { font-size: 16px; font-weight: 800; color: #7CFFB8; text-align: center; margin: 4px 0 18px; word-break: break-all; }
.login-profile-email { font-size: 11px; color: rgba(201,179,255,0.62); text-align: center; margin: -10px 0 18px; word-break: break-all; }
.login-note.profile-note { display: block; text-align: center; margin: -4px 0 14px; color: rgba(255,214,107,0.78); }
.login-card .login-ghost-link { display: block; margin: 12px auto 0; }
@media (max-width: 560px) {
  .login-brand .title-flavor { display: none; }
}

/* =================== CHARACTER CREATION =================== */
.scene-cc { position: absolute; inset: 0; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.cc-bg { position: absolute; inset: 0; background-size: cover; background-position: center; filter: brightness(0.4) saturate(1.05); }
.cc-bg-vignette {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 50% at 50% 50%, transparent 20%, rgba(6,2,31,0.75) 100%),
    linear-gradient(180deg, rgba(6,2,31,0.7) 0%, transparent 40%, rgba(6,2,31,0.85) 100%);
}
.cc-top {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; padding: clamp(12px, 1.6vw, 18px) clamp(18px, 3vw, 36px); gap: 12px;
}
.cc-back {
  appearance: none; cursor: pointer;
  background: rgba(20,8,55,0.7); color: #c9b3ff;
  border: 1px solid rgba(160,107,255,0.45);
  padding: 8px 16px; border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.14em;
}
.cc-back:hover { background: linear-gradient(180deg, var(--violet), #5e2eb8); color: #fff; }
.cc-title {
  text-align: center;
  font-size: clamp(20px, 2.6vw, 28px); font-weight: 900;
  letter-spacing: 0.2em; color: var(--gold);
  text-shadow: 0 2px 12px rgba(255,214,107,0.4);
}
.cc-slot-tag {
  font-size: 10px; font-weight: 800; letter-spacing: 0.2em;
  color: var(--gold);
  background: rgba(20,8,55,0.7); border: 1px solid var(--gold);
  padding: 6px 12px; border-radius: 999px;
}
.cc-body {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 360px 1fr;
  gap: clamp(14px, 2vw, 24px);
  padding: 0 clamp(18px, 3vw, 36px); min-height: 0;
}
.cc-grid-wrap {
  background: linear-gradient(180deg, rgba(20,8,55,0.7), rgba(10,5,24,0.85));
  border: 1px solid rgba(160,107,255,0.35);
  border-radius: 14px; padding: 12px;
  display: flex; flex-direction: column; min-height: 0;
}
.cc-grid-title {
  font-size: 11px; font-weight: 900; letter-spacing: 0.2em;
  color: var(--gold); padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,214,107,0.2);
  margin-bottom: 10px;
}
.cc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; overflow-y: auto; }
.cc-card {
  position: relative;
  background: linear-gradient(180deg, rgba(40,18,90,0.55), rgba(10,5,24,0.75));
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 6px 4px 4px;
  cursor: pointer;
  transition: all 0.12s ease;
  text-align: center;
}
.cc-card:hover { transform: translateY(-2px); border-color: var(--el); }
.cc-card.picked {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold) inset, 0 6px 18px color-mix(in srgb, var(--gold) 35%, transparent);
  transform: translateY(-3px);
}
.cc-card.taken { cursor: not-allowed; filter: grayscale(0.6) brightness(0.6); }
.cc-card img { width: 56px; height: 56px; object-fit: contain; }
.cc-card-name { font-size: 11px; font-weight: 900; color: #fff; letter-spacing: 0.04em; }
.cc-card-meta { font-size: 9px; color: var(--el); letter-spacing: 0.08em; }
.cc-card-taken {
  position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%);
  background: rgba(0,0,0,0.7); color: #ff5b7a;
  padding: 4px 0; font-size: 9px; font-weight: 900; letter-spacing: 0.16em;
}
.cc-detail {
  background: linear-gradient(180deg, rgba(20,8,55,0.85), rgba(10,5,24,0.95));
  border: 2px solid var(--el);
  border-radius: 16px; padding: 16px 20px;
  display: grid;
  grid-template-columns: 160px 1fr;
  grid-template-areas:
    "preview head"
    "preview stats"
    "preview skills"
    "back back";
  gap: 14px; overflow-y: auto;
  box-shadow: 0 0 32px color-mix(in srgb, var(--el) 25%, transparent);
}
.cc-detail-preview {
  grid-area: preview;
  display: grid; place-items: center;
  background: radial-gradient(80% 60% at 50% 30%, color-mix(in srgb, var(--el) 25%, transparent), transparent);
  border-radius: 12px; padding: 12px;
}
.cc-detail-preview img {
  width: 140px; height: 140px; object-fit: contain;
  filter: drop-shadow(0 6px 16px color-mix(in srgb, var(--el) 55%, transparent));
  animation: csPreviewBob 3.5s ease-in-out infinite;
}
.cc-detail-head { grid-area: head; }
.cc-name {
  font-size: clamp(22px, 3vw, 30px); font-weight: 900;
  background: linear-gradient(180deg, #fff, var(--el));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: 0.06em; line-height: 1;
}
.cc-meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.cc-meta-pill { font-size: 10px; font-weight: 900; letter-spacing: 0.12em; padding: 3px 10px; border-radius: 999px; }
.cc-meta-pill.cls { background: linear-gradient(180deg, var(--gold), var(--gold-dim)); color: #2a1500; }
.cc-meta-pill.el  { background: rgba(160,107,255,0.25); color: var(--el); border: 1px solid var(--el); }
.cc-stats { grid-area: stats; display: flex; flex-direction: column; gap: 4px; }
.cc-stat { display: grid; grid-template-columns: 36px 1fr 24px; gap: 8px; align-items: center; }
.cc-stat-label { font-size: 10px; font-weight: 900; letter-spacing: 0.12em; color: #c9b3ff; }
.cc-stat-bar { display: flex; gap: 2px; height: 12px; }
.cc-stat-pip { flex: 1; background: rgba(255,255,255,0.08); border-radius: 2px; transition: background 0.18s ease; }
.cc-stat-pip.on { background: var(--c); box-shadow: 0 0 4px var(--c); }
.cc-stat-num { font-size: 11px; font-weight: 900; color: #fff; text-align: right; }
.cc-skills { grid-area: skills; display: flex; flex-direction: column; gap: 4px; }
.cc-skill {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center;
  background: rgba(0,0,0,0.25); border-radius: 6px; padding: 4px 8px; font-size: 11px;
}
.cc-skill-key { background: var(--gold); color: #2a1500; font-size: 9px; font-weight: 900; padding: 1px 5px; border-radius: 3px; text-align: center; }
.cc-skill-name { color: #fff; font-weight: 700; }
.cc-skill-meta { font-size: 9px; color: #c9b3ff; opacity: 0.6; letter-spacing: 0.08em; }
.cc-backstory { grid-area: back; }
.cc-section-title { font-size: 10px; font-weight: 900; letter-spacing: 0.2em; color: var(--el); margin-bottom: 4px; }
.cc-backstory p { font-size: 12px; color: #c9b3ff; line-height: 1.6; font-style: italic; margin: 0; }
.cc-bottom { position: relative; z-index: 2; display: flex; justify-content: center; padding: clamp(14px, 2vw, 20px); }
.cc-create {
  appearance: none; cursor: pointer; border: 0;
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: #2a1500; font-weight: 900; letter-spacing: 0.18em; font-size: 14px;
  padding: 14px 40px; border-radius: 999px;
  box-shadow: 0 12px 32px rgba(255,214,107,0.5), 0 0 0 1px rgba(255,255,255,0.15) inset;
}
.cc-create:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-2px); }
.cc-create:disabled { background: rgba(60,50,80,0.6); color: rgba(255,255,255,0.3); box-shadow: none; cursor: not-allowed; }
@media (max-width: 880px) {
  .cc-body { grid-template-columns: 1fr; }
  .cc-detail { grid-template-columns: 1fr; grid-template-areas: "preview" "head" "stats" "skills" "back"; }
  .cc-detail-preview img { width: 100px; height: 100px; }
}

/* =================== NEW CHARACTER SELECT (slot-based) =================== */
.scene-cs2 { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.cs2-bg {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  filter: brightness(0.5) saturate(1.1);
  animation: csBgDrift 60s linear infinite;
}
.cs2-vignette {
  position: absolute; inset: 0;
  background:
    radial-gradient(70% 60% at 50% 50%, transparent 30%, rgba(6,2,31,0.8) 100%),
    linear-gradient(180deg, rgba(6,2,31,0.6) 0%, transparent 40%, rgba(6,2,31,0.85) 100%);
}
.cs2-top {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; padding: clamp(14px, 2vw, 22px) clamp(18px, 3vw, 36px); gap: 12px;
}
.cs2-world-tag {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.2em;
  color: #c9b3ff;
  background: rgba(20,8,55,0.6); border: 1px solid rgba(160,107,255,0.45);
  padding: 6px 14px; border-radius: 999px; width: fit-content;
}
.cs2-w-dot { width: 8px; height: 8px; border-radius: 50%; background: #7CFFB8; box-shadow: 0 0 8px #7CFFB8; animation: csWDotPulse 2s ease-in-out infinite; }
.cs2-title-wrap { text-align: center; }
.cs2-title {
  font-size: clamp(24px, 3.6vw, 38px); font-weight: 900;
  background: linear-gradient(180deg, #fff, var(--gold) 70%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: 0.18em;
  filter: drop-shadow(0 2px 16px rgba(255,214,107,0.4));
}
.cs2-sub { font-size: 11px; color: #c9b3ff; opacity: 0.7; letter-spacing: 0.18em; margin-top: 4px; }
.cs2-quit {
  appearance: none; cursor: pointer;
  background: transparent; color: rgba(201,179,255,0.7);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 8px 14px; border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.14em; justify-self: end;
}
.cs2-quit:hover { background: rgba(160,107,255,0.2); color: #fff; }
.cs2-slots {
  position: relative; z-index: 2;
  flex: 1; min-height: 0;
  display: flex; justify-content: center; align-items: center;
  gap: clamp(14px, 2.4vw, 26px);
  padding: clamp(14px, 3vw, 36px); flex-wrap: wrap;
}
.cs2-slot {
  position: relative;
  width: clamp(180px, 22vw, 260px);
  aspect-ratio: 3 / 4;
  background: linear-gradient(180deg, rgba(40,18,90,0.55), rgba(10,5,24,0.85));
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  cursor: pointer; overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  padding: 16px 14px 14px; text-align: center;
}
.cs2-slot:hover { transform: translateY(-6px); border-color: rgba(160,107,255,0.6); }
.cs2-slot.empty { border: 2px dashed rgba(160,107,255,0.4); display: grid; place-items: center; gap: 6px; }
.cs2-slot.empty:hover { border-color: var(--gold); background: linear-gradient(180deg, rgba(255,214,107,0.1), rgba(10,5,24,0.85)); }
.cs2-slot-plus { font-size: 64px; color: rgba(160,107,255,0.6); font-weight: 100; line-height: 1; }
.cs2-slot.empty:hover .cs2-slot-plus { color: var(--gold); }
.cs2-slot-cta { font-size: 12px; font-weight: 900; color: #c9b3ff; letter-spacing: 0.18em; }
.cs2-slot-num { position: absolute; top: 10px; left: 12px; font-size: 9px; color: rgba(201,179,255,0.5); letter-spacing: 0.2em; font-weight: 800; }
.cs2-slot.filled.selected {
  border-color: var(--gold);
  transform: translateY(-10px) scale(1.04);
  box-shadow: 0 14px 38px rgba(255,214,107,0.4), 0 0 0 2px var(--gold) inset, 0 0 28px color-mix(in srgb, var(--el) 50%, transparent);
}
.cs2-slot.filled { border-color: var(--el); }
.cs2-slot.filled:hover { box-shadow: 0 10px 26px color-mix(in srgb, var(--el) 40%, transparent); }
.cs2-slot-portrait {
  width: 100%; height: 60%;
  object-fit: contain; margin-top: 6px;
  filter: drop-shadow(0 6px 12px color-mix(in srgb, var(--el) 60%, transparent));
}
.cs2-slot-name { font-size: clamp(15px, 1.8vw, 18px); font-weight: 900; color: #fff; margin-top: 8px; letter-spacing: 0.04em; }
.cs2-slot-meta { display: flex; justify-content: center; gap: 6px; margin-top: 4px; }
.cs2-lv { background: linear-gradient(180deg, var(--gold), var(--gold-dim)); color: #2a1500; padding: 1px 8px; border-radius: 999px; font-size: 10px; font-weight: 900; letter-spacing: 0.06em; }
.cs2-cls { font-size: 10px; color: var(--el); font-weight: 800; letter-spacing: 0.1em; }
.cs2-slot-el { font-size: 10px; color: #c9b3ff; opacity: 0.7; margin-top: 2px; letter-spacing: 0.1em; }
.cs2-slot-del {
  position: absolute; top: 10px; right: 10px;
  appearance: none; cursor: pointer; border: 0;
  background: rgba(255,90,120,0.2); color: #fff;
  width: 26px; height: 26px; border-radius: 50%;
  font-size: 12px; border: 1px solid rgba(255,90,120,0.4);
  opacity: 0; transition: opacity 0.15s ease;
}
.cs2-slot:hover .cs2-slot-del { opacity: 1; }
.cs2-slot-del:hover { background: var(--bad); }
.cs2-bottom { position: relative; z-index: 2; display: flex; justify-content: center; padding: clamp(16px, 2.4vw, 26px); }
.cs2-enter {
  appearance: none; cursor: pointer; border: 0;
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: #2a1500; font-weight: 900; letter-spacing: 0.2em; font-size: 16px;
  padding: 16px 56px; border-radius: 999px;
  box-shadow: 0 14px 36px rgba(255,214,107,0.5), 0 0 0 1px rgba(255,255,255,0.15) inset;
  animation: csEnterPulse 2.4s ease-in-out infinite;
}
.cs2-enter:disabled { background: rgba(60,50,80,0.6); color: rgba(255,255,255,0.3); box-shadow: none; cursor: not-allowed; animation: none; }
.cs2-enter:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-3px); }
.cs2-credit { position: absolute; bottom: 8px; right: 14px; z-index: 2; font-size: 9px; color: rgba(201,179,255,0.4); letter-spacing: 0.3em; }

/* =================== OLD CHARACTER SELECT (fallback) =================== */
.scene-cs {
  position: absolute; inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  overflow: hidden;
}
.cs-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: brightness(0.55) saturate(1.1);
  animation: csBgDrift 60s linear infinite;
}
@keyframes csBgDrift {
  0% { transform: scale(1.05) translate(0, 0); }
  50% { transform: scale(1.08) translate(-1.5%, -0.6%); }
  100% { transform: scale(1.05) translate(0, 0); }
}
.cs-bg-vignette {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 50% at 50% 50%, transparent 30%, rgba(6,2,31,0.7) 100%),
    linear-gradient(180deg, rgba(6,2,31,0.7) 0%, transparent 30%, transparent 70%, rgba(6,2,31,0.9) 100%);
}
.cs-bg-particles {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,0.4) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 70% 20%, rgba(160,107,255,0.6) 50%, transparent 50%),
    radial-gradient(2px 2px at 40% 70%, rgba(255,214,107,0.4) 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 85% 85%, rgba(255,255,255,0.3) 50%, transparent 50%),
    radial-gradient(2.5px 2.5px at 12% 80%, rgba(124,255,184,0.4) 50%, transparent 50%);
  animation: csParticles 12s linear infinite;
  opacity: 0.8;
}
@keyframes csParticles {
  0% { transform: translateY(0); opacity: 0.5; }
  50% { opacity: 1; }
  100% { transform: translateY(-20px); opacity: 0.5; }
}

/* Top bar */
.cs-topbar {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: clamp(12px, 1.8vw, 22px) clamp(18px, 3vw, 36px);
}
.cs-world-tag {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 800; letter-spacing: 0.2em;
  color: #c9b3ff;
  background: rgba(20,8,55,0.6);
  border: 1px solid rgba(160,107,255,0.45);
  padding: 6px 14px; border-radius: 999px;
  width: fit-content;
}
.cs-w-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #7CFFB8;
  box-shadow: 0 0 8px #7CFFB8;
  animation: csWDotPulse 2s ease-in-out infinite;
}
@keyframes csWDotPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.cs-title-wrap { text-align: center; }
.cs-title {
  font-size: clamp(28px, 4vw, 52px); font-weight: 900;
  background: linear-gradient(180deg, #fff 0%, #d6b8ff 40%, #a06bff 70%, #5e2eb8 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 24px rgba(160,107,255,0.7));
  letter-spacing: 0.08em;
  line-height: 1;
}
.cs-sub {
  font-size: 11px; color: #c9b3ff; opacity: 0.7;
  letter-spacing: 0.3em; margin-top: 4px;
}
.cs-stats {
  display: flex; gap: 14px; justify-content: flex-end;
}
.cs-stats > div {
  background: rgba(20,8,55,0.6);
  border: 1px solid rgba(160,107,255,0.35);
  border-radius: 10px;
  padding: 6px 14px;
  display: flex; flex-direction: column;
}
.cs-s-label { font-size: 9px; color: #c9b3ff; opacity: 0.7; letter-spacing: 0.2em; }
.cs-s-val { font-size: clamp(15px, 1.8vw, 18px); font-weight: 900; color: #fff; font-variant-numeric: tabular-nums; }

/* Big selected character preview */
.cs-preview-wrap {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  padding: 0 clamp(20px, 4vw, 60px);
  min-height: 0;
}
.cs-preview {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(20px, 3vw, 40px);
  align-items: center;
  max-width: 760px;
  width: 100%;
}
.cs-preview img {
  /* Source sprites are 200×200 — never upscale past native size to avoid blur */
  width:  clamp(120px, 14vw, 180px);
  height: clamp(120px, 14vw, 180px);
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  filter: drop-shadow(0 10px 30px color-mix(in srgb, var(--el) 60%, transparent))
          drop-shadow(0 0 24px color-mix(in srgb, var(--el) 50%, transparent));
  animation: csPreviewBob 3.5s ease-in-out infinite;
}
@keyframes csPreviewBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
.cs-preview-locked {
  width: 200px; height: 200px;
  display: grid; place-items: center;
  font-size: 100px; color: rgba(255,255,255,0.2);
}
.cs-preview-info { color: #fff; }
.cs-preview-name {
  font-size: clamp(28px, 4vw, 44px); font-weight: 900;
  background: linear-gradient(180deg, #fff, var(--el));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 16px color-mix(in srgb, var(--el) 40%, transparent));
  letter-spacing: 0.06em;
  line-height: 1;
}
.cs-preview-cls {
  font-size: clamp(12px, 1.4vw, 14px); font-weight: 700;
  color: var(--el); letter-spacing: 0.16em; margin: 4px 0 12px;
}
.cs-preview-lvl {
  display: inline-block;
  font-size: 18px; font-weight: 900;
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: #2a1500;
  padding: 4px 14px; border-radius: 999px;
  letter-spacing: 0.06em; margin-bottom: 6px;
}
.cs-xp-bar {
  width: 100%; max-width: 360px;
  height: 6px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px; overflow: hidden;
}
.cs-xp-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--violet));
}
.cs-xp-text { font-size: 10px; color: #c9b3ff; opacity: 0.7; letter-spacing: 0.08em; margin-top: 4px; }
.cs-blurb { font-size: 13px; color: #c9b3ff; opacity: 0.85; margin-top: 12px; line-height: 1.5; font-style: italic; max-width: 380px; }
.cs-preview-locked-hint { font-size: 13px; color: #c9b3ff; opacity: 0.6; font-style: italic; }

/* Slot row */
.cs-slots-row {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 10px;
  padding: 0 clamp(18px, 3vw, 36px);
}
.cs-arrow {
  appearance: none; cursor: pointer; border: 0;
  width: 36px; height: 80px;
  background: linear-gradient(180deg, rgba(20,8,55,0.7), rgba(10,5,24,0.85));
  border: 1px solid rgba(160,107,255,0.45);
  border-radius: 10px;
  color: #fff; font-size: 24px; font-weight: 900;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.cs-arrow:hover { background: linear-gradient(180deg, var(--violet), #5e2eb8); transform: translateY(-2px); }
.cs-slots-scroll {
  flex: 1; overflow-x: auto; overflow-y: visible;
  scrollbar-width: thin;
  scrollbar-color: rgba(160,107,255,0.5) transparent;
  /* Need breathing room top+bottom so lifted/scaled selected slot doesn't clip */
  padding: 16px 0 14px;
  margin: -16px 0 -14px;
}
.cs-slots-scroll::-webkit-scrollbar { height: 6px; }
.cs-slots-scroll::-webkit-scrollbar-thumb { background: rgba(160,107,255,0.5); border-radius: 3px; }
.cs-slots {
  display: flex; gap: 8px;
  padding: 4px 6px;
  min-width: max-content;
}
.cs-slot {
  position: relative;
  flex-shrink: 0;
  width: 90px; height: 110px;
  background: linear-gradient(180deg, rgba(40,18,90,0.55), rgba(10,5,24,0.75));
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.cs-slot.on { border-color: var(--el); cursor: pointer; }
.cs-slot.locked { cursor: not-allowed; filter: grayscale(0.7) brightness(0.4); }
.cs-slot:hover.on { transform: translateY(-4px); box-shadow: 0 8px 24px color-mix(in srgb, var(--el) 40%, transparent); }
.cs-slot.selected.on {
  transform: translateY(-6px) scale(1.05);
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold) inset,
              0 12px 32px color-mix(in srgb, var(--gold) 50%, transparent),
              0 0 24px color-mix(in srgb, var(--el) 50%, transparent);
}
.cs-slot-bg {
  position: absolute; inset: 0;
  background: radial-gradient(80% 60% at 50% 30%, color-mix(in srgb, var(--el) 30%, transparent), transparent);
}
.cs-slot-portrait {
  position: absolute; top: 4px; left: 50%; transform: translateX(-50%);
  width: 70px; height: 70px;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.6));
}
.cs-slot-info {
  position: absolute; left: 4px; right: 4px; bottom: 4px;
  text-align: center;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.5));
  padding: 2px 0;
  border-radius: 0 0 8px 8px;
}
.cs-slot-name {
  font-size: 10px; font-weight: 900; color: #fff;
  letter-spacing: 0.04em; line-height: 1.1;
  text-shadow: 0 1px 2px #000;
}
.cs-slot-meta { display: flex; justify-content: center; gap: 4px; margin-top: 2px; }
.cs-slot-lv {
  font-size: 8px; font-weight: 900;
  background: var(--gold); color: #2a1500;
  padding: 1px 4px; border-radius: 3px;
  letter-spacing: 0.08em;
}
.cs-slot-cls { font-size: 8px; color: var(--el); font-weight: 800; letter-spacing: 0.08em; }
.cs-slot-el { font-size: 8px; color: #c9b3ff; opacity: 0.7; }
.cs-slot-lock {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 28px; color: rgba(255,255,255,0.4);
}
.cs-slot-locked-name {
  position: absolute; bottom: 8px; left: 0; right: 0; text-align: center;
  font-size: 10px; color: rgba(255,255,255,0.4);
  letter-spacing: 0.2em; font-weight: 900;
}

/* Action buttons */
.cs-actions {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: clamp(14px, 2vw, 24px);
}
.cs-action {
  appearance: none; cursor: pointer; border: 0;
  font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 12px 28px; border-radius: 999px;
  font-size: 13px;
  background: linear-gradient(180deg, rgba(40,18,90,0.7), rgba(10,5,24,0.85));
  color: #c9b3ff;
  border: 1px solid rgba(160,107,255,0.45);
  transition: all 0.15s ease;
}
.cs-action:hover { background: linear-gradient(180deg, var(--violet), #5e2eb8); color: #fff; transform: translateY(-2px); }
.cs-action.ghost { background: transparent; color: rgba(201,179,255,0.7); border: 1px solid rgba(255,255,255,0.15); padding: 8px 18px; font-size: 11px; }
.cs-action.ghost:hover { background: rgba(160,107,255,0.2); color: #fff; }
.cs-action.ghost.danger { color: rgba(255,90,120,0.7); border-color: rgba(255,90,120,0.3); }
.cs-action.ghost.danger:hover { background: rgba(255,90,120,0.2); color: #fff; }
.cs-enter {
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: #2a1500; font-size: 18px; padding: 16px 56px;
  border: 0;
  box-shadow: 0 14px 36px rgba(255,214,107,0.45), 0 0 0 1px rgba(255,255,255,0.15) inset;
  animation: csEnterPulse 2.4s ease-in-out infinite;
}
.cs-enter:disabled {
  background: rgba(60, 50, 80, 0.6); color: rgba(255,255,255,0.3);
  box-shadow: none; cursor: not-allowed; animation: none;
}
.cs-enter:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-3px); }
@keyframes csEnterPulse {
  0%, 100% { box-shadow: 0 14px 36px rgba(255,214,107,0.45), 0 0 0 1px rgba(255,255,255,0.15) inset; }
  50%      { box-shadow: 0 18px 48px rgba(255,214,107,0.7),  0 0 0 1px rgba(255,255,255,0.15) inset, 0 0 32px rgba(255,214,107,0.4); }
}
.cs-secondary { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.cs-credit {
  position: absolute; bottom: 8px; right: 14px; z-index: 2;
  font-size: 9px; color: rgba(201,179,255,0.4); letter-spacing: 0.3em;
}

@media (max-width: 720px) {
  .cs-topbar { grid-template-columns: 1fr; gap: 8px; text-align: center; }
  .cs-world-tag, .cs-stats { justify-self: center; }
  .cs-preview { grid-template-columns: 1fr; text-align: center; }
  .cs-preview img { margin: 0 auto; }
  .cs-xp-bar { margin: 0 auto; }
}

/* =================== HOME (legacy — kept for safety) =================== */
.scene-home {
  align-items: center; justify-content: center; text-align: center;
  background: radial-gradient(80% 60% at 50% 30%, rgba(160,107,255,0.2), transparent 70%);
}
.home-title {
  font-size: clamp(40px, 6vw, 80px); font-weight: 900;
  background: linear-gradient(180deg, #fff, #d6b8ff 40%, #a06bff 70%, #5e2eb8 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 18px rgba(160,107,255,0.6));
  margin-bottom: 6px;
}
.home-sub { font-size: clamp(12px, 1.5vw, 16px); color: #c9b3ff; opacity: 0.8; margin-bottom: 18px; }

.home-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: clamp(12px, 2vw, 28px);
  align-items: center;
  background: linear-gradient(180deg, rgba(40,18,90,0.55), rgba(10,5,24,0.7));
  border: 1px solid rgba(160,107,255,0.32);
  border-radius: 18px;
  padding: clamp(14px, 2vw, 24px);
  width: min(820px, 92vw);
  margin-bottom: 18px;
}
.hero-portrait {
  width: clamp(80px, 14vw, 140px);
  aspect-ratio: 1;
  border-radius: 18px;
  background: radial-gradient(120% 80% at 50% 30%, color-mix(in srgb, var(--el) 35%, transparent), transparent);
  display: grid; place-items: center; overflow: hidden;
  border: 2px solid var(--el);
}
.hero-portrait img { width: 100%; height: 100%; object-fit: contain; }
.portrait-fallback { font-size: 48px; font-weight: 900; color: var(--el); }
.hero-info { text-align: left; min-width: 0; }
.hero-name { font-size: clamp(18px, 2.4vw, 26px); font-weight: 900; letter-spacing: 0.04em; }
.hero-element { font-size: 12px; color: #c9b3ff; opacity: 0.8; margin: 2px 0 6px; letter-spacing: 0.1em; }
.hero-blurb { font-size: 12px; color: #c9b3ff; opacity: 0.75; margin-top: 6px; line-height: 1.4; }
.hero-cls {
  font-size: 10px; font-weight: 800;
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: #2a1500;
  padding: 2px 8px; border-radius: 999px;
  letter-spacing: 0.12em; margin-left: 8px;
  vertical-align: middle;
}
.hero-stats-inline {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-size: 11px; color: #c9b3ff;
  margin: 6px 0 2px;
  letter-spacing: 0.06em;
}
.hero-stats-inline span { background: rgba(20,8,55,0.6); padding: 2px 8px; border-radius: 6px; }
.sk-key {
  display: inline-block; margin-top: 4px;
  font-size: 11px; font-weight: 900;
  background: rgba(0,0,0,0.4); padding: 1px 6px; border-radius: 4px;
  color: var(--el);
}
.hero-stats { display: grid; gap: 8px; min-width: 80px; }
.hero-stats > div { display: flex; flex-direction: column; align-items: flex-end; }

.home-nav { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.home-credit { position: absolute; bottom: 8px; right: 14px; font-size: 10px; color: #6b5494; letter-spacing: 0.16em; }

/* =================== WORLD MAP =================== */
.scene-worldmap {
  background: radial-gradient(80% 60% at 50% 10%, rgba(160,107,255,0.18), #06021f 70%);
}
.map-title {
  font-size: clamp(20px, 2.6vw, 30px); font-weight: 900;
  text-align: center; letter-spacing: 0.16em;
  margin-bottom: 14px; color: #fff;
  text-shadow: 0 2px 12px rgba(160,107,255,0.6);
}
.world-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(8px, 1.4vw, 18px);
  overflow-y: auto; padding-bottom: 60px;
}
@media (max-width: 720px) { .world-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 480px) { .world-grid { grid-template-columns: repeat(2, 1fr); } }
.world-card {
  position: relative; aspect-ratio: 16 / 9;
  border-radius: 14px;
  background-size: cover; background-position: center;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--el) 50%, rgba(255,255,255,0.1));
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.world-card:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 30px color-mix(in srgb, var(--el) 35%, transparent);
  border-color: var(--el);
}
.world-card.locked { cursor: not-allowed; filter: grayscale(0.7) brightness(0.4); }
.world-card.cleared { box-shadow: 0 0 0 2px var(--el) inset; }
.wc-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(6,2,31,0.95) 100%);
}
.wc-num {
  position: absolute; top: 6px; left: 8px;
  font-size: 11px; font-weight: 900; letter-spacing: 0.18em;
  color: var(--el); text-shadow: 0 1px 3px #000;
}
.wc-info {
  position: absolute; left: 10px; right: 10px; bottom: 28px;
  color: #fff;
}
.wc-name { font-size: clamp(11px, 1.2vw, 14px); font-weight: 800; line-height: 1.1; text-shadow: 0 1px 3px #000; }
.wc-element { font-size: 9px; color: #c9b3ff; opacity: 0.8; letter-spacing: 0.1em; margin-top: 2px; }
.wc-progress {
  position: absolute; left: 10px; right: 10px; bottom: 6px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 9px; color: #c9b3ff;
}
.wc-stars { color: var(--gold); letter-spacing: 1px; font-size: 10px; }
.wc-stars-empty { color: rgba(255,255,255,0.18); }
.wc-stage { font-size: 9px; opacity: 0.7; }
.wc-badge {
  position: absolute; top: 6px; right: 6px;
  background: var(--gold); color: #2a1500;
  font-size: 8px; font-weight: 900; padding: 2px 6px; border-radius: 4px; letter-spacing: 0.18em;
}
.wc-lock {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 30px; color: rgba(255,255,255,0.55);
  text-shadow: 0 2px 12px rgba(0,0,0,0.7);
}
.wc-lock-req { font-size: 9px; margin-top: 8px; color: #c9b3ff; text-shadow: 0 1px 3px #000; padding: 0 6px; text-align: center; }
.back-btn { position: absolute; top: 12px; left: 12px; }

/* =================== STAGE SELECT =================== */
.scene-stageselect { padding: 0; }
.ss-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  filter: brightness(0.55);
}
.ss-bg-vignette {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 50% at 50% 50%, transparent 30%, rgba(6,2,31,0.85) 100%),
    linear-gradient(180deg, rgba(6,2,31,0.5), transparent 30%, transparent 70%, rgba(6,2,31,0.9));
}
.ss-header {
  position: relative;
  padding: 60px clamp(20px, 4vw, 40px) 20px;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 8px #000;
}
.ss-name { font-size: clamp(22px, 3.5vw, 38px); font-weight: 900; letter-spacing: 0.06em; color: var(--el); }
.ss-element { font-size: 12px; color: #c9b3ff; opacity: 0.85; margin: 4px 0; letter-spacing: 0.18em; }
.ss-flavor { font-size: clamp(11px, 1.4vw, 14px); opacity: 0.8; max-width: 600px; margin: 8px auto 0; line-height: 1.5; }
.ss-stages {
  position: relative;
  flex: 1;
  display: flex; align-items: center; justify-content: space-evenly;
  padding: 20px clamp(14px, 2vw, 30px);
  gap: clamp(8px, 1.5vw, 20px);
}
.stage-node {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.stage-node:hover { transform: translateY(-4px); }
.stage-node.locked { cursor: not-allowed; opacity: 0.45; }
.sn-circle {
  width: clamp(56px, 8vw, 100px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(40,18,90,0.85), rgba(10,5,24,0.95));
  border: 2px solid var(--el);
  font-size: clamp(20px, 2.5vw, 32px); font-weight: 900;
  color: #fff;
  box-shadow: 0 0 24px color-mix(in srgb, var(--el) 50%, transparent);
}
.stage-node.boss .sn-circle {
  background: linear-gradient(180deg, #7a0030, #2a0010);
  border-color: var(--bad);
  box-shadow: 0 0 28px rgba(255,90,120,0.6);
}
.stage-node.locked .sn-circle {
  background: rgba(20,8,55,0.5); border-color: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.55); box-shadow: none;
}
.sn-label { font-size: clamp(10px, 1.2vw, 13px); text-align: center; color: #fff; text-shadow: 0 1px 3px #000; }
.sn-stars { color: var(--gold); letter-spacing: 1px; font-size: 11px; margin-top: 2px; }

.ss-anima-pick {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 12px clamp(14px, 2vw, 30px);
  background: linear-gradient(180deg, transparent, rgba(6,2,31,0.9));
}
.ss-pick-label { font-size: 11px; color: #c9b3ff; letter-spacing: 0.18em; }
.ss-pick-list { display: flex; gap: 8px; overflow-x: auto; flex: 1; }
.anima-pick {
  position: relative; flex: 0 0 auto;
  width: 56px; height: 56px;
  border-radius: 14px;
  background: rgba(20,8,55,0.6);
  border: 2px solid rgba(255,255,255,0.1);
  overflow: hidden; cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.anima-pick:hover { transform: translateY(-2px); border-color: var(--el); }
.anima-pick.selected { border-color: var(--el); box-shadow: 0 0 0 2px var(--el) inset, 0 0 16px color-mix(in srgb, var(--el) 50%, transparent); }
.anima-pick img { width: 100%; height: 100%; object-fit: cover; }
.ap-lvl {
  position: absolute; bottom: 0; right: 0;
  background: rgba(0,0,0,0.7); color: var(--gold);
  font-size: 9px; font-weight: 900; padding: 1px 4px;
}

/* =================== BATTLE HUD (MapleStory style) =================== */
.battle-hud.ms-style {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 5;
}
.battle-hud.ms-style > * { pointer-events: auto; }
.battle-hud.ms-style .hud-top,
.battle-hud.ms-style .hud-mid,
.battle-hud.ms-style .hud-bottom { display: none; }

/* TOP RIGHT — stage info pill */
.ms-stage-info {
  position: absolute; top: 12px; right: 14px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, rgba(20,8,55,0.78), rgba(10,5,24,0.82));
  border: 1px solid rgba(160,107,255,0.45);
  padding: 8px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.ms-stage-world { font-size: 13px; font-weight: 900; color: #fff; text-shadow: 0 1px 2px #000; }
.ms-stage-sub { font-size: 11px; color: #c9b3ff; letter-spacing: 0.12em; opacity: 0.85; }
.ms-pause-btn {
  appearance: none; cursor: pointer; border: 0;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(160,107,255,0.25); color: #fff;
  font-size: 13px; font-weight: 900;
  border: 1px solid rgba(160,107,255,0.6);
}
.ms-pause-btn:hover { background: rgba(160,107,255,0.45); }

/* TOP CENTER — wave banner */
.ms-wave-banner {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  padding: 8px 22px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,90,120,0.92), rgba(122,0,48,0.92));
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff; font-weight: 900; font-size: 14px;
  letter-spacing: 0.14em; text-shadow: 0 1px 3px #000;
  box-shadow: 0 8px 24px rgba(255,90,120,0.45);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* BOTTOM LEFT — character card */
.ms-char-card {
  position: absolute; bottom: 14px; left: 14px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, rgba(20,8,55,0.75), rgba(10,5,24,0.85));
  border: 1px solid var(--el, rgba(160,107,255,0.5));
  border-radius: 14px;
  padding: 8px 14px 8px 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.5), 0 0 16px color-mix(in srgb, var(--el, #fff) 25%, transparent);
  backdrop-filter: blur(8px);
}
.ms-portrait {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: radial-gradient(120% 80% at 50% 30%, color-mix(in srgb, var(--el, #fff) 35%, transparent), transparent);
  border: 2px solid var(--el, rgba(160,107,255,0.5));
  overflow: hidden;
  flex-shrink: 0;
}
.ms-portrait img { width: 100%; height: 100%; object-fit: contain; }
.ms-char-info { display: flex; flex-direction: column; gap: 2px; }
.ms-char-name { font-size: 13px; font-weight: 900; color: #fff; letter-spacing: 0.04em; }
.ms-char-lvl { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--el, #c9b3ff); font-weight: 800; }
.ms-lv-tag {
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: #2a1500; font-size: 9px; font-weight: 900;
  padding: 1px 5px; border-radius: 4px; letter-spacing: 0.1em;
}

/* BOTTOM CENTER — HP / MP / EXP bars (MS style) */
.ms-bars {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 14px;
  display: flex; flex-direction: column; gap: 3px;
  width: min(560px, 50vw);
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(8,4,22,0.5), rgba(8,4,22,0.85));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  backdrop-filter: blur(6px);
}
.ms-bar {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px; align-items: center;
  position: relative;
}
.ms-bar-icon {
  font-size: 12px; font-weight: 900;
  text-align: center;
}
.ms-bar-hp .ms-bar-icon { color: #ff5b7a; text-shadow: 0 0 6px rgba(255,90,120,0.6); }
.ms-bar-mp .ms-bar-icon { color: #6bd1ff; text-shadow: 0 0 6px rgba(107,209,255,0.6); }
.ms-bar-xp .ms-bar-icon { color: #ffd66b; text-shadow: 0 0 6px rgba(255,214,107,0.6); }
.ms-bar-track {
  position: relative;
  height: 16px;
  background: linear-gradient(180deg, rgba(0,0,0,0.75), rgba(0,0,0,0.55));
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  overflow: hidden;
}
.ms-bar-fill {
  position: absolute; inset: 0;
  width: 100%;
  transition: width 0.18s ease;
  box-shadow: inset 0 2px 3px rgba(255,255,255,0.3);
}
.ms-bar-hp .ms-bar-fill { background: linear-gradient(180deg, #ff9ec2, #ff3b6b 50%, #7a0030); }
.ms-bar-mp .ms-bar-fill { background: linear-gradient(180deg, #a0e7ff, #3a9bff 50%, #143a7a); }
.ms-bar-xp { grid-template-columns: 18px 1fr; }
.ms-bar-xp .ms-bar-track { height: 8px; }
.ms-bar-xp .ms-bar-fill { background: linear-gradient(180deg, #fff5b0, #ffd66b 50%, #a87a1d); }
.ms-bar-text {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 10px; font-weight: 800;
  color: #fff; text-shadow: 0 1px 2px #000;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.ms-bar-xp .ms-bar-text { right: auto; left: 22px; bottom: -14px; top: auto; transform: none; font-size: 9px; color: #c9b3ff; }

/* BOTTOM RIGHT — skill quick slots */
.ms-quickslots {
  position: absolute; right: 14px; bottom: 14px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  background: linear-gradient(180deg, rgba(8,4,22,0.6), rgba(8,4,22,0.85));
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 6px 8px;
  backdrop-filter: blur(6px);
}
.ms-quickslots-label {
  font-size: 9px; font-weight: 900; letter-spacing: 0.18em;
  color: rgba(201,179,255,0.65);
}
.ms-quickslots-row { display: flex; gap: 4px; }
.ms-skill {
  position: relative;
  width: 46px; height: 46px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(40,18,90,0.85), rgba(10,5,24,0.95));
  border: 2px solid var(--el, rgba(255,255,255,0.2));
  overflow: hidden;
  box-shadow: 0 0 10px color-mix(in srgb, var(--el, #fff) 25%, transparent);
}
.ms-skill.locked { border-color: rgba(255,255,255,0.1); box-shadow: none; opacity: 0.5; }
.ms-skill-icon {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 22px; color: var(--el, #fff);
  text-shadow: 0 0 8px color-mix(in srgb, var(--el, #fff) 50%, transparent);
}
.ms-skill-icon.muted { color: rgba(255,255,255,0.4); text-shadow: none; font-size: 16px; }
.ms-skill-key {
  position: absolute; top: 1px; right: 3px;
  font-size: 9px; font-weight: 900;
  color: #fff;
  background: rgba(0,0,0,0.55);
  padding: 0 4px; border-radius: 3px;
  letter-spacing: 0.08em;
}
.ms-skill-cd {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.ms-skill-cd-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 0%;
  background: rgba(0,0,0,0.65);
  transition: height 0.05s linear;
}

/* BOTTOM-LEFT META — combo, coins, inventory */
.ms-meta {
  position: absolute; left: 230px; bottom: 16px;
  display: flex; gap: 6px;
}
.ms-meta-pill {
  background: linear-gradient(180deg, rgba(40,18,90,0.75), rgba(10,5,24,0.85));
  border: 1px solid rgba(160,107,255,0.4);
  padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.06em;
  color: #c9b3ff;
  display: flex; align-items: center; gap: 6px;
  cursor: default;
  appearance: none;
  transition: all 0.12s ease;
}
.ms-meta-pill.ms-combo.hot {
  border-color: var(--bad); color: #fff;
  background: linear-gradient(180deg, rgba(255,90,120,0.55), rgba(122,0,48,0.7));
  box-shadow: 0 0 16px rgba(255,90,120,0.5);
  transform: scale(1.06);
}
.ms-meta-pill.ms-coins { color: var(--gold); border-color: rgba(255,214,107,0.5); }
.ms-meta-pill.ms-inv-btn { cursor: pointer; border-color: rgba(160,107,255,0.7); font-size: 14px; }
.ms-meta-pill.ms-inv-btn:hover { background: linear-gradient(180deg, rgba(160,107,255,0.45), rgba(40,18,90,0.85)); transform: translateY(-1px); }

@media (max-width: 720px) {
  .ms-bars { width: 60vw; }
  .ms-meta { left: 14px; bottom: 88px; }
}

/* =================== legacy battle HUD (kept for ref, not rendered) =================== */
.battle-hud {
  position: absolute; inset: 0;
  pointer-events: none;
  display: flex; flex-direction: column;
  padding: 12px;
  z-index: 5;
}
.battle-hud > * { pointer-events: auto; }

.hud-top {
  display: flex; gap: 14px; align-items: flex-start; flex-wrap: nowrap;
  background: linear-gradient(180deg, rgba(6,2,31,0.7) 30%, transparent);
  padding: 8px 12px 12px;
  border-radius: 0 0 16px 16px;
  margin: -12px -12px 0;
}
.hud-stats { flex: 1; max-width: 520px; display: flex; flex-direction: column; gap: 4px; }
.bar-row {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px; align-items: center;
}
.bar-label {
  font-size: clamp(10px, 1.1vw, 12px); font-weight: 900;
  color: #c9b3ff; letter-spacing: 0.1em; text-align: right;
}
.stat-bar {
  position: relative;
  height: 18px;
  background: linear-gradient(180deg, rgba(0,0,0,0.7), rgba(0,0,0,0.5));
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4) inset;
}
.stat-bar .bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(180deg, #ff5b7a, #7a0030);
  width: 100%;
  transition: width 0.2s ease;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.25);
}
.stat-bar.hp .bar-fill { background: linear-gradient(180deg, #ff9ec2 0%, #ff3b6b 45%, #7a0030 100%); }
.stat-bar.hp .bar-fill.critical { animation: hpPulse 0.6s ease-in-out infinite; }
@keyframes hpPulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.5); } }
.stat-bar.mp .bar-fill { background: linear-gradient(180deg, #a0e7ff 0%, #3a9bff 50%, #143a7a 100%); }
.stat-bar.xp { height: 12px; }
.stat-bar.xp .bar-fill { background: linear-gradient(180deg, #fff5b0 0%, #ffd66b 50%, #a87a1d 100%); }
.bar-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
  color: #fff; text-shadow: 0 1px 2px #000;
  letter-spacing: 0.04em;
}

.hud-meta {
  text-align: right;
  display: flex; flex-direction: column; gap: 4px; align-items: flex-end;
}
.hud-stage { font-size: clamp(13px, 1.4vw, 15px); font-weight: 900; color: #fff; text-shadow: 0 1px 4px #000; }
.hud-stage-sub { font-size: 10px; color: #c9b3ff; letter-spacing: 0.16em; opacity: 0.8; }
.hud-anima {
  margin-top: 4px;
  padding: 4px 12px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(20,8,55,0.85), rgba(10,5,24,0.85));
  border: 1px solid var(--el);
  box-shadow: 0 0 12px color-mix(in srgb, var(--el) 30%, transparent);
  font-size: 12px; font-weight: 800; letter-spacing: 0.08em;
}

.hud-mid {
  flex: 1;
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 12px;
  pointer-events: none;
}
.wave-indicator {
  background: linear-gradient(180deg, rgba(255,90,120,0.9), rgba(122,0,48,0.9));
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 13px; font-weight: 900;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow: 0 1px 3px #000;
  box-shadow: 0 6px 18px rgba(255,90,120,0.4);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.hud-bottom {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  margin-top: auto;
}
.combo-pill {
  background: linear-gradient(180deg, rgba(40,18,90,0.75), rgba(10,5,24,0.75));
  border: 1px solid rgba(160,107,255,0.5);
  padding: 6px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: 0.08em;
  color: #c9b3ff;
  transition: all 0.15s ease;
}
.combo-pill.hot {
  border-color: var(--bad); color: #fff;
  background: linear-gradient(180deg, rgba(255,90,120,0.5), rgba(122,0,48,0.7));
  box-shadow: 0 0 18px rgba(255,90,120,0.5);
  transform: scale(1.08);
}

.skill-bar { display: flex; gap: 6px; }
.skill-slot {
  position: relative;
  width: 64px; height: 56px;
  background: linear-gradient(180deg, rgba(40,18,90,0.75), rgba(10,5,24,0.85));
  border: 2px solid var(--el, rgba(255,255,255,0.2));
  border-radius: 10px;
  padding: 4px;
  text-align: center;
  overflow: hidden;
  box-shadow: 0 0 12px color-mix(in srgb, var(--el, #fff) 25%, transparent);
}
.skill-slot.locked { opacity: 0.4; border-color: rgba(255,255,255,0.1); box-shadow: none; }
.ss-key {
  position: absolute; top: 2px; left: 4px;
  font-size: 10px; font-weight: 900; color: var(--el, #fff);
  text-shadow: 0 1px 2px #000;
  letter-spacing: 0.1em;
}
.ss-name { font-size: 9px; font-weight: 800; color: #fff; margin-top: 14px; line-height: 1.1; }
.ss-mp { font-size: 9px; color: #6bd1ff; font-weight: 700; margin-top: 2px; }
.ss-cd {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  pointer-events: none;
  overflow: hidden;
}
.ss-cd-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 0%;
  background: rgba(0,0,0,0.65);
  transition: height 0.05s linear;
}
.coin-pill {
  background: linear-gradient(180deg, rgba(40,18,90,0.75), rgba(10,5,24,0.75));
  border: 1px solid var(--gold);
  padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 800;
  color: var(--gold);
  display: flex; align-items: center; gap: 6px;
}
.hud-btn {
  appearance: none; cursor: pointer; border: 0;
  background: rgba(20,8,55,0.85); color: #fff;
  font-weight: 900; font-size: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid rgba(160,107,255,0.5);
}

/* Touch controls */
.hud-touch {
  display: none;
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 12px;
  justify-content: space-between; align-items: flex-end;
  pointer-events: none;
}
.hud-touch > * { pointer-events: auto; }
@media (hover: none) and (pointer: coarse) {
  .hud-touch { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: flex-end; }
  .hud-bottom { padding-bottom: 80px; }
  .skill-bar { display: none; } /* hide keyboard skill bar on touch — touch-skills below replaces it */

  /* Floating movement joystick (replaces the fixed D-pad). Spawns at the touch point.
     The zone sits UNDER the buttons (low z-index); the stick base/knob render above it. */
  .touch-joy-zone {
    position: fixed; left: 0; bottom: 0;
    width: 48vw; height: 52vh; z-index: 1; touch-action: none; pointer-events: auto;
  }
  .touch-joy {
    position: fixed; width: 124px; height: 124px; border-radius: 50%;
    transform: translate(-50%, -50%); pointer-events: none; z-index: 7;
    border: 2px solid rgba(160,107,255,0.35); background: rgba(20,8,55,0.22);
    backdrop-filter: blur(2px); opacity: 0; transition: opacity .12s;
  }
  .touch-joy.on { opacity: 1; }
  .touch-joy-knob {
    position: absolute; left: 50%; top: 50%; width: 58px; height: 58px;
    border-radius: 50%; background: rgba(160,107,255,0.65); border: 2px solid #fff;
    transform: translate(-50%, -50%);
  }

  /* Bigger thumb-zone targets; action + skill clusters anchored bottom-right and
     stacked ABOVE the joystick zone. Containers pass touches through so empty
     space falls to the stick — only the buttons themselves catch taps. */
  .touch-actions, .touch-skills { gap: 12px; position: relative; z-index: 8; pointer-events: none; }
  .tp-btn { width: 60px; height: 60px; pointer-events: auto; }
  .tp-sk  { width: 52px; height: 52px; }
}
.touch-pad, .touch-actions, .touch-skills { display: flex; gap: 6px; }
.touch-skills { width: 100%; justify-content: center; }
.tp-btn {
  appearance: none;
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(20,8,55,0.7); color: #fff;
  font-size: 18px; font-weight: 900;
  border: 2px solid rgba(160,107,255,0.5);
  user-select: none; touch-action: none;
  backdrop-filter: blur(6px);
}
.tp-btn:active { background: rgba(160,107,255,0.5); transform: scale(0.92); }
.tp-attack { background: rgba(255,90,120,0.4); border-color: var(--bad); }
.tp-jump   { background: rgba(124,255,184,0.3); border-color: var(--good); }
.tp-heavy  { background: rgba(255,160,40,0.4); border-color: #ffa028; }
.tp-dodge  { background: rgba(200,200,255,0.3); border-color: #c0c0ff; }
.tp-sk     { width: 44px; height: 44px; font-size: 14px; background: rgba(40,18,90,0.85); border-color: var(--violet); }

/* ============================================================
   MOBILE GAME HUD — glass touch controls (Warframe / MapleStory M look)
   Gated by html.is-touch (robust JS detection) so touch devices reliably
   get the game HUD instead of the desktop keycap layout. Flat letter
   buttons become translucent glass with glowing accents + icon glyphs.
   ============================================================ */
.is-touch .skill-bar { display: none; }                 /* hide desktop keyboard skill bar */
.is-touch .hud-touch {
  display: flex; flex-wrap: wrap; gap: 12px;
  justify-content: flex-end; align-items: flex-end;
  padding: 12px;
  padding-right: max(12px, env(safe-area-inset-right));
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.is-touch .touch-skills { width: 100%; justify-content: flex-end; gap: 12px; }
.is-touch .touch-actions { gap: 12px; }
.is-touch .touch-actions, .is-touch .touch-skills { position: relative; z-index: 8; pointer-events: none; }

/* Floating movement stick (mirrors the coarse-pointer rules under .is-touch) */
.is-touch .touch-joy-zone { position: fixed; left: 0; bottom: 0; width: 48vw; height: 52vh; z-index: 1; touch-action: none; pointer-events: auto; }
.is-touch .touch-joy {
  position: fixed; width: 128px; height: 128px; border-radius: 50%;
  transform: translate(-50%,-50%); pointer-events: none; z-index: 7;
  opacity: 0; transition: opacity .12s;
  border: 2px solid rgba(160,107,255,0.45);
  background: radial-gradient(circle, rgba(40,20,90,0.28), rgba(8,4,22,0.10));
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  box-shadow: 0 0 18px -4px rgba(160,107,255,0.6), inset 0 0 14px rgba(160,107,255,0.18);
}
.is-touch .touch-joy.on { opacity: 1; }
.is-touch .touch-joy-knob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; border-radius: 50%;
  transform: translate(-50%,-50%);
  background: radial-gradient(circle at 38% 32%, rgba(205,175,255,0.96), rgba(140,90,240,0.85));
  border: 2px solid rgba(255,255,255,0.85); box-shadow: 0 0 16px rgba(160,107,255,0.8);
}

/* Glass buttons */
.is-touch .tp-btn {
  position: relative; width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 120% at 50% 22%, rgba(60,40,120,0.34), rgba(8,4,22,0.55));
  border: 1.5px solid rgba(160,107,255,0.6);
  box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 12px -3px rgba(160,107,255,0.7), inset 0 1px 0 rgba(255,255,255,0.14);
  -webkit-backdrop-filter: blur(10px) saturate(1.25); backdrop-filter: blur(10px) saturate(1.25);
  color: #fff; font-weight: 900; font-size: 16px;
  transition: transform .08s ease, filter .08s ease;
}
.is-touch .tp-btn:active { transform: scale(0.9); filter: brightness(1.45); }
.is-touch .tp-sk { width: 56px; height: 56px; font-size: 15px; }

/* per-action accent glow */
.is-touch .tp-attack { border-color: rgba(255,90,120,0.85); box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 14px -2px rgba(255,90,120,0.75), inset 0 1px 0 rgba(255,255,255,0.14); }
.is-touch .tp-heavy  { border-color: rgba(255,160,40,0.9);  box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 14px -2px rgba(255,160,40,0.75), inset 0 1px 0 rgba(255,255,255,0.14); }
.is-touch .tp-jump   { border-color: rgba(124,255,184,0.85); box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 14px -2px rgba(124,255,184,0.7), inset 0 1px 0 rgba(255,255,255,0.14); }
.is-touch .tp-dodge  { border-color: rgba(190,200,255,0.85); }
.is-touch .tp-use    { border-color: rgba(255,214,107,0.9);  box-shadow: 0 3px 12px rgba(0,0,0,0.5), 0 0 14px -2px rgba(255,214,107,0.75), inset 0 1px 0 rgba(255,255,255,0.14); }

/* icon glyphs replace the letter labels on action buttons (mask tinted white) */
.is-touch .tp-jump, .is-touch .tp-dodge, .is-touch .tp-heavy, .is-touch .tp-attack, .is-touch .tp-use { color: transparent; }
.is-touch .tp-jump::before, .is-touch .tp-dodge::before, .is-touch .tp-heavy::before,
.is-touch .tp-attack::before, .is-touch .tp-use::before {
  content: ""; position: absolute; inset: 0; background: #fff;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-size: 46%; mask-size: 46%;
}
.is-touch .tp-jump::before  { -webkit-mask-image: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0,0,24,24'><path%20d='M12,3l8,8h-5v8h-6v-8H4z'/></svg>"); mask-image: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0,0,24,24'><path%20d='M12,3l8,8h-5v8h-6v-8H4z'/></svg>"); }
.is-touch .tp-dodge::before { -webkit-mask-image: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0,0,24,24'><path%20d='M3,5l8,7-8,7zM12,5l8,7-8,7z'/></svg>"); mask-image: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0,0,24,24'><path%20d='M3,5l8,7-8,7zM12,5l8,7-8,7z'/></svg>"); }
.is-touch .tp-heavy::before { -webkit-mask-image: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0,0,24,24'><path%20d='M12,1l2.6,7.4L22,11l-7.4,2.6L12,21l-2.6-7.4L2,11l7.4-2.6z'/></svg>"); mask-image: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0,0,24,24'><path%20d='M12,1l2.6,7.4L22,11l-7.4,2.6L12,21l-2.6-7.4L2,11l7.4-2.6z'/></svg>"); }
.is-touch .tp-attack::before { -webkit-mask-image: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0,0,24,24'><path%20d='M19,3l2,2-10,10-3,1,1-3z'/></svg>"); mask-image: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0,0,24,24'><path%20d='M19,3l2,2-10,10-3,1,1-3z'/></svg>"); }
.is-touch .tp-use::before   { -webkit-mask-image: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0,0,24,24'><path%20d='M3,4h18v11H8l-5,4z'/></svg>"); mask-image: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0,0,24,24'><path%20d='M3,4h18v11H8l-5,4z'/></svg>"); }

/* ============================================================
   TOUCH RELAYOUT — MapleStory-M layout: compact status top-left,
   menu icons top-right, the ENTIRE bottom freed for controls
   (joystick bottom-left, big skill/action cluster bottom-right).
   The desktop command-deck was a full-width bottom bar that
   collided with the touch buttons — this re-anchors it.
   ============================================================ */
.is-touch .ar-hud .ms-command-deck {
  left: max(12px, env(safe-area-inset-left)); right: auto; bottom: auto;
  top: 128px;                       /* tucked just under the minimap */
  transform: none;
  width: min(72vw, 360px); min-height: 0;   /* 360 in landscape; wider in portrait so bars don't cramp */
  display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 8px;
}
.is-touch .ar-hud .ms-char-card { grid-template-columns: 46px minmax(0,1fr); padding: 6px; }
.is-touch .ar-hud .ms-bars { width: 100%; }   /* fill the card so HP/MP/EXP tracks render (deck flex was centering them to min-content → 28px → 0px fills) */
.is-touch .ar-hud .ms-portrait { width: 44px; height: 44px; }
/* CHAIN SKILLS + QUICK ITEMS are redundant on touch (the big skill buttons replace them) */
.is-touch .ar-hud .ms-quickslots,
.is-touch .ar-hud .ms-itemslots { display: none; }
/* Menus (BAG/SKILLS/QUEST/MAP + coins) → compact wrap row inside the left status
   stack. (Can't escape to top-right via position:fixed — the deck's backdrop-filter
   makes it a containing block — and stripping that would kill the glass look.) */
.is-touch .ar-hud .ms-meta {
  display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 6px;
  width: auto; margin-top: 2px;
}
.is-touch .ar-hud .ms-meta-pill { font-size: 11px; padding: 6px 9px; }
.is-touch .ar-hud .ms-meta-pill { font-size: 11px; padding: 6px 9px; }

/* Bottom freed → bigger, well-spaced control cluster */
.is-touch .hud-touch { gap: 14px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.is-touch .touch-actions { gap: 14px; }
.is-touch .touch-skills  { width: 100%; justify-content: flex-end; gap: 14px; margin-top: 2px; }
.is-touch .tp-btn { width: 66px; height: 66px; }
.is-touch .tp-sk  { width: 60px; height: 60px; }
/* faint resting hint for the movement stick so players know the left zone is draggable */
.is-touch .touch-joy-zone::after {
  content: ""; position: absolute; left: 64px; bottom: 70px;
  width: 86px; height: 86px; border-radius: 50%;
  border: 2px dashed rgba(160,107,255,0.28);
  pointer-events: none;
}

/* Combat Power pill — aggregate progression stat (MapleStory-M style) */
.ms-char-cp {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 3px; font-size: 11px; font-weight: 800;
  color: var(--gold); letter-spacing: .3px;
}
.ms-char-cp .ms-cp-ico { filter: drop-shadow(0 0 3px rgba(255,214,107,0.7)); }

/* Loading-screen rotating tip line */
.boot-tip {
  margin-top: 14px; max-width: 80vw;
  font-size: 12.5px; line-height: 1.4; color: rgba(200,190,255,0.78);
  text-align: center; letter-spacing: .2px;
  transition: opacity .22s ease; opacity: 1;
}

/* =================== PAUSE OVERLAY =================== */
.pause-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(60% 60% at 50% 45%, rgba(20,8,60,0.85), rgba(2,0,12,0.95));
  backdrop-filter: blur(6px);
  z-index: 10; gap: 14px;
}
.pause-title {
  font-size: clamp(36px, 6vw, 64px); font-weight: 900;
  background: linear-gradient(180deg, #fff, var(--violet));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* =================== RESULT / VICTORY =================== */
.scene-result, .scene-victory {
  background-size: cover; background-position: center;
  align-items: center; justify-content: center;
}
.result-vignette, .victory-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(60% 60% at 50% 45%, rgba(20,8,60,0.6), rgba(2,0,12,0.92));
  backdrop-filter: blur(4px);
}
.result-card, .victory-card {
  position: relative; z-index: 1;
  background: linear-gradient(180deg, rgba(40,18,90,0.85), rgba(10,5,24,0.95));
  border: 1px solid rgba(160,107,255,0.5);
  border-radius: 22px;
  padding: clamp(20px, 3vw, 32px);
  width: min(520px, 92vw);
  text-align: center;
  display: flex; flex-direction: column; gap: 10px;
}
.result-title {
  font-size: clamp(26px, 4vw, 42px); font-weight: 900; letter-spacing: 0.08em;
  background: linear-gradient(180deg, #fff, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 18px rgba(255,214,107,0.5));
}
.result-title.fail {
  background: linear-gradient(180deg, #fff, var(--bad));
  -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 2px 18px rgba(255,90,120,0.5));
}
.result-stars { font-size: clamp(28px, 4vw, 42px); color: var(--gold); letter-spacing: 4px; }
.result-stats { display: flex; gap: 20px; justify-content: center; margin: 12px 0; }
.result-stats > div, .victory-stats > div { display: flex; flex-direction: column; }
.result-anima { font-size: 13px; color: #c9b3ff; margin: 8px 0; }
.result-sub { font-size: 13px; color: #c9b3ff; opacity: 0.8; }

.victory-banner {
  font-size: clamp(28px, 4.5vw, 48px); font-weight: 900; letter-spacing: 0.12em;
  background: linear-gradient(180deg, #fff, var(--gold) 50%, #ff9bcd 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 24px rgba(255,214,107,0.7));
}
.victory-world { font-size: clamp(14px, 2vw, 18px); color: #c9b3ff; letter-spacing: 0.06em; }
.victory-stars { font-size: clamp(32px, 5vw, 48px); color: var(--gold); letter-spacing: 6px; margin: 8px 0; }
.victory-stats { display: flex; gap: 20px; justify-content: center; }
.victory-unlock {
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: #2a1500; padding: 8px 16px; border-radius: 999px;
  font-weight: 800; letter-spacing: 0.06em; margin-top: 10px;
}
.victory-next { font-size: 12px; color: #c9b3ff; letter-spacing: 0.1em; }
.victory-end { font-size: 13px; color: #ff9bcd; font-style: italic; margin: 10px 0; }

/* =================== COLLECTION =================== */
.scene-collection {
  background: radial-gradient(80% 60% at 50% 10%, rgba(160,107,255,0.18), #06021f 70%);
}
.col-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(8px, 1.4vw, 16px);
  overflow-y: auto; padding-bottom: 60px;
}
@media (max-width: 720px) { .col-grid { grid-template-columns: repeat(3, 1fr); } }
.col-card {
  position: relative;
  background: linear-gradient(180deg, rgba(40,18,90,0.5), rgba(10,5,24,0.7));
  border: 1px solid rgba(160,107,255,0.32);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.col-card:hover { transform: translateY(-3px); border-color: var(--el); }
.col-card.selected { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }
.col-card.locked { cursor: not-allowed; filter: grayscale(0.7) brightness(0.5); }
.col-portrait {
  aspect-ratio: 1; border-radius: 12px;
  background: radial-gradient(120% 80% at 50% 30%, color-mix(in srgb, var(--el) 20%, transparent), transparent);
  margin-bottom: 8px; overflow: hidden;
}
.col-portrait img { width: 100%; height: 100%; object-fit: contain; }
.col-name { font-size: clamp(11px, 1.3vw, 14px); font-weight: 800; letter-spacing: 0.04em; }
.col-element { font-size: 10px; color: #c9b3ff; opacity: 0.7; letter-spacing: 0.1em; }
.col-level { font-size: 10px; color: var(--gold); letter-spacing: 0.18em; font-weight: 700; margin-top: 4px; }
.col-locked { font-size: 10px; color: #c9b3ff; opacity: 0.6; margin-top: 4px; }

/* =================== SKILL TREE =================== */
.scene-skills { background: radial-gradient(80% 60% at 50% 10%, rgba(160,107,255,0.18), #06021f 70%); }
.sk-header {
  display: flex; gap: 16px; align-items: center;
  background: linear-gradient(180deg, rgba(40,18,90,0.55), rgba(10,5,24,0.75));
  border: 1px solid var(--el);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 14px;
}
.sk-header img { width: clamp(60px, 10vw, 100px); aspect-ratio: 1; border-radius: 12px; object-fit: contain; background: color-mix(in srgb, var(--el) 15%, transparent); }
.sk-name { font-size: clamp(16px, 2.2vw, 22px); font-weight: 900; }
.sk-element { font-size: 11px; color: #c9b3ff; letter-spacing: 0.16em; margin: 2px 0 8px; }
.sk-tree { display: grid; gap: 8px; overflow-y: auto; padding-bottom: 60px; }
.sk-node {
  display: grid; grid-template-columns: 60px 1fr 40px;
  gap: 12px; align-items: center;
  background: rgba(20,8,55,0.4);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px 14px;
}
.sk-node.on { border-color: var(--el); background: linear-gradient(180deg, color-mix(in srgb, var(--el) 12%, rgba(20,8,55,0.5)), rgba(10,5,24,0.6)); }
.sk-node.off { opacity: 0.55; }
.sk-lvl { font-size: 14px; font-weight: 900; color: var(--gold); letter-spacing: 0.1em; }
.sk-name-row { font-size: 14px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.sk-tag { font-size: 9px; padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,0.1); letter-spacing: 0.16em; }
.sk-desc { font-size: 12px; color: #c9b3ff; opacity: 0.85; line-height: 1.4; margin-top: 2px; }
.sk-cd { font-size: 10px; color: var(--gold); opacity: 0.7; margin-top: 2px; }
.sk-status { font-size: 18px; text-align: center; color: var(--el); }
.sk-node.off .sk-status { color: rgba(255,255,255,0.4); }

/* =================== MMORPG MINI-MAP =================== */
.ms-minimap {
  position: absolute; top: 12px; left: 14px;
  background: linear-gradient(180deg, rgba(20,8,55,0.8), rgba(10,5,24,0.9));
  border: 1px solid rgba(160,107,255,0.45);
  border-radius: 10px;
  padding: 6px 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
}
.mm-title {
  font-size: 11px; font-weight: 900; color: #c9b3ff;
  letter-spacing: 0.14em; margin-bottom: 4px;
}
.ms-minimap canvas {
  display: block; border-radius: 5px;
  background: rgba(0,0,0,0.5);
}

/* =================== QUEST TRACKER (top-right under stage info) =================== */
.ms-quest-tracker {
  position: absolute; right: 14px; top: 88px;
  display: flex; flex-direction: column; gap: 4px;
  width: 220px;
  pointer-events: none;
}
.qt-card {
  background: linear-gradient(180deg, rgba(20,8,55,0.75), rgba(10,5,24,0.85));
  border: 1px solid rgba(255,214,107,0.45);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 10px; color: #c9b3ff;
}
.qt-name { font-weight: 900; color: var(--gold); font-size: 11px; margin-bottom: 2px; letter-spacing: 0.06em; }
.qt-line { font-size: 10px; padding: 1px 0; }
.qt-line.done { color: #7CFFB8; text-decoration: line-through; opacity: 0.7; }

/* =================== DIALOGUE OVERLAY =================== */
.dialogue-modal {
  position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%);
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 14px; align-items: stretch;
  width: min(800px, 92vw);
  z-index: 220;
  background: linear-gradient(180deg, rgba(20,8,55,0.95), rgba(10,5,24,0.98));
  border: 2px solid rgba(160,107,255,0.7);
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.7);
  pointer-events: auto;
}
.dlg-portrait {
  display: grid; place-items: center;
  background: radial-gradient(80% 60% at 50% 30%, color-mix(in srgb, var(--el) 30%, transparent), transparent);
  border: 2px solid var(--el);
  border-radius: 12px;
  width: 80px; height: 80px;
}
.dlg-glyph {
  font-size: 36px;
  color: var(--el);
  text-shadow: 0 0 16px color-mix(in srgb, var(--el) 50%, transparent);
}
.dlg-body { min-width: 0; display: flex; flex-direction: column; }
.dlg-name { font-size: 14px; font-weight: 900; color: #fff; letter-spacing: 0.06em; }
.dlg-role { font-size: 10px; color: #c9b3ff; opacity: 0.8; letter-spacing: 0.14em; margin-bottom: 6px; }
.dlg-text {
  font-size: 13px; color: #fff; line-height: 1.5;
  background: rgba(0,0,0,0.3); border-radius: 6px; padding: 8px 12px;
  margin-bottom: 8px;
}
.dlg-options { display: flex; flex-wrap: wrap; gap: 6px; }
.dlg-opt {
  appearance: none; cursor: pointer; border: 0;
  background: linear-gradient(180deg, rgba(160,107,255,0.4), rgba(94,46,184,0.4));
  border: 1px solid rgba(160,107,255,0.6);
  color: #fff;
  padding: 6px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
}
.dlg-opt:hover { background: linear-gradient(180deg, var(--violet), #5e2eb8); transform: translateY(-1px); }
.dlg-close {
  appearance: none; cursor: pointer; border: 0;
  background: rgba(255,90,120,0.25); color: #fff;
  border: 1px solid rgba(255,90,120,0.5);
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
  padding: 4px 10px; border-radius: 6px;
  align-self: flex-start;
}

/* =================== SHOP MODAL =================== */
.shop-modal {
  position: fixed; inset: 0; z-index: 220;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2,0,12,0.65);
  backdrop-filter: blur(4px);
}
.shop-frame {
  width: min(960px, 96vw); max-height: 92vh; overflow: hidden;
  background: linear-gradient(180deg, rgba(20,8,55,0.95), rgba(10,5,24,0.98));
  border: 1px solid rgba(160,107,255,0.5);
  border-radius: 18px;
  padding: 14px 18px;
  position: relative;
}
.shop-close { position: absolute; top: 10px; right: 12px; appearance: none; cursor: pointer; border: 1px solid rgba(255,90,120,0.6); background: rgba(255,90,120,0.25); color: #fff; width: 28px; height: 28px; border-radius: 50%; font-weight: 900; }
.shop-header {
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(160,107,255,0.3);
  padding-bottom: 10px; margin-bottom: 10px;
}
.shop-glyph { font-size: 28px; }
.shop-title { font-size: 16px; font-weight: 900; color: #fff; letter-spacing: 0.06em; flex: 1; }
.shop-frags, .shop-mesos { font-size: 14px; color: var(--gold); font-weight: 800; }
.shop-grid {
  display: grid; grid-template-columns: 1fr 240px 1fr; gap: 10px;
  min-height: 360px;
}
.shop-panel {
  background: rgba(20,8,55,0.45);
  border: 1px solid rgba(160,107,255,0.3);
  border-radius: 10px;
  padding: 8px;
  display: flex; flex-direction: column; min-height: 0;
}
.shop-panel-title { font-size: 10px; font-weight: 900; color: var(--gold); letter-spacing: 0.18em; margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid rgba(255,214,107,0.2); }
.shop-list { overflow-y: auto; flex: 1; }
.shop-row {
  display: grid; grid-template-columns: 28px 1fr auto;
  gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  margin-bottom: 2px;
}
.shop-row:hover { background: rgba(160,107,255,0.15); }
.shop-row.selected { background: rgba(255,214,107,0.18); box-shadow: 0 0 0 1px var(--gold) inset; }
.sr-icon { font-size: 18px; text-align: center; }
.sr-name { color: #fff; }
.sr-price { color: var(--gold); font-weight: 700; font-size: 11px; }
.shop-empty { font-size: 11px; color: rgba(201,179,255,0.5); padding: 16px; text-align: center; }
.shop-detail {
  background: linear-gradient(180deg, rgba(40,18,90,0.55), rgba(10,5,24,0.7));
  border: 1px solid rgba(160,107,255,0.4);
  border-radius: 10px;
  padding: 16px; text-align: center;
  display: flex; flex-direction: column; gap: 8px;
}
.shop-d-icon { font-size: 56px; line-height: 1; }
.shop-d-name { font-size: 16px; font-weight: 900; color: #fff; }
.shop-d-desc { font-size: 11px; color: #c9b3ff; font-style: italic; opacity: 0.85; }
.shop-d-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.shop-d-stats span {
  background: rgba(160,107,255,0.18); border: 1px solid rgba(160,107,255,0.4);
  padding: 2px 6px; border-radius: 6px;
  font-size: 10px; font-weight: 800; color: var(--violet); letter-spacing: 0.06em;
}
.shop-d-price { font-size: 14px; color: var(--gold); font-weight: 900; margin: 8px 0; }
.shop-d-empty { color: rgba(201,179,255,0.5); font-size: 12px; padding: 30px; }

/* =================== QUEST LOG MODAL =================== */
.ql-modal {
  position: fixed; inset: 0; z-index: 220;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2,0,12,0.65); backdrop-filter: blur(4px);
}
.ql-frame {
  width: min(820px, 96vw); max-height: 92vh;
  background: linear-gradient(180deg, rgba(20,8,55,0.95), rgba(10,5,24,0.98));
  border: 1px solid rgba(160,107,255,0.5); border-radius: 18px;
  padding: 18px; position: relative; display: flex; flex-direction: column;
}
.ql-close { position: absolute; top: 10px; right: 12px; appearance: none; cursor: pointer; border: 1px solid rgba(255,90,120,0.6); background: rgba(255,90,120,0.25); color: #fff; width: 28px; height: 28px; border-radius: 50%; font-weight: 900; }
.ql-title { font-size: 18px; font-weight: 900; color: var(--gold); letter-spacing: 0.18em; text-align: center; margin-bottom: 12px; }
.ql-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.ql-tab {
  appearance: none; cursor: pointer; border: 0;
  flex: 1; background: rgba(20,8,55,0.5); border: 1px solid rgba(160,107,255,0.3);
  padding: 8px; border-radius: 8px;
  color: #c9b3ff; font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
}
.ql-tab.active { background: linear-gradient(180deg, var(--violet), #5e2eb8); color: #fff; }
.ql-list { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 200px; }
.ql-card {
  background: rgba(20,8,55,0.55); border: 1px solid rgba(160,107,255,0.35);
  border-radius: 10px; padding: 12px;
}
.ql-card.done { opacity: 0.5; }
.ql-name { font-size: 14px; font-weight: 900; color: var(--gold); }
.ql-giver { font-size: 10px; color: #c9b3ff; opacity: 0.7; letter-spacing: 0.1em; margin: 2px 0 6px; }
.ql-brief { font-size: 12px; color: #fff; line-height: 1.4; margin-bottom: 8px; }
.ql-objs { background: rgba(0,0,0,0.3); padding: 6px 10px; border-radius: 6px; margin-bottom: 6px; }
.ql-obj { font-size: 11px; color: #c9b3ff; padding: 2px 0; }
.ql-bar { height: 4px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.ql-bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--violet)); transition: width 0.3s ease; }
.ql-rewards { font-size: 10px; color: #c9b3ff; opacity: 0.85; letter-spacing: 0.04em; }
.ql-empty { font-size: 12px; color: rgba(201,179,255,0.5); text-align: center; padding: 40px; }

/* =================== WORLD MAP MODAL =================== */
.wm-modal {
  position: fixed; inset: 0; z-index: 220;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2,0,12,0.75); backdrop-filter: blur(6px);
}
.wm-frame {
  width: min(1100px, 96vw); max-height: 92vh; overflow: hidden;
  background: linear-gradient(180deg, rgba(20,8,55,0.95), rgba(10,5,24,0.98));
  border: 1px solid rgba(160,107,255,0.5); border-radius: 18px;
  padding: 18px; position: relative; display: flex; flex-direction: column;
}
.wm-close { position: absolute; top: 10px; right: 12px; appearance: none; cursor: pointer; border: 1px solid rgba(255,90,120,0.6); background: rgba(255,90,120,0.25); color: #fff; width: 28px; height: 28px; border-radius: 50%; font-weight: 900; }
.wm-title { font-size: 22px; font-weight: 900; color: var(--gold); letter-spacing: 0.2em; text-align: center; }
.wm-sub { font-size: 12px; color: #c9b3ff; text-align: center; opacity: 0.7; margin-bottom: 14px; letter-spacing: 0.04em; }
.wm-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  overflow-y: auto; padding-bottom: 8px;
}
@media (max-width: 720px) { .wm-grid { grid-template-columns: repeat(2, 1fr); } }
.wm-card {
  position: relative; aspect-ratio: 16/9;
  background-size: cover; background-position: center;
  border-radius: 12px;
  border: 2px solid var(--el);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.wm-card.open:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 10px 28px color-mix(in srgb, var(--el) 40%, transparent); }
.wm-card.locked { cursor: not-allowed; filter: grayscale(0.8) brightness(0.4); }
.wm-card-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(6,2,31,0.95) 100%);
}
.wm-card-num {
  position: absolute; top: 6px; left: 10px;
  font-size: 14px; font-weight: 900; color: var(--el);
  text-shadow: 0 1px 3px #000;
}
.wm-card-info {
  position: absolute; left: 10px; right: 10px; bottom: 8px; color: #fff;
}
.wm-card-name { font-size: 13px; font-weight: 900; line-height: 1.1; text-shadow: 0 1px 3px #000; }
.wm-card-meta { font-size: 9px; color: #c9b3ff; letter-spacing: 0.1em; margin-top: 2px; }
.wm-card-flavor { font-size: 10px; color: #fff; opacity: 0.7; line-height: 1.3; margin-top: 4px; text-shadow: 0 1px 2px #000; }
.wm-soon, .wm-lock {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.7); color: #fff;
  padding: 4px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 900; letter-spacing: 0.18em;
}
.wm-soon { color: var(--gold); border: 1px solid var(--gold); }
.wm-lock { color: #c9b3ff; }

/* =================== DEATH OVERLAY =================== */
.death-overlay {
  position: fixed; inset: 0; z-index: 230;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(60% 50% at 50% 50%, rgba(122,0,48,0.5), rgba(2,0,12,0.95));
  backdrop-filter: blur(6px);
}
.death-card {
  background: linear-gradient(180deg, rgba(40,18,90,0.95), rgba(10,5,24,0.98));
  border: 1px solid rgba(255,90,120,0.6);
  border-radius: 18px; padding: 32px; text-align: center;
  display: flex; flex-direction: column; gap: 14px;
}
.death-title {
  font-size: 48px; font-weight: 900; letter-spacing: 0.16em;
  background: linear-gradient(180deg, #fff, var(--bad));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 18px rgba(255,90,120,0.5));
}
.death-sub { font-size: 13px; color: #c9b3ff; }

/* =================== INVENTORY MODAL (MapleStory-style) =================== */
.inv-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
}
.inv-overlay {
  position: absolute; inset: 0;
  background: rgba(2, 0, 12, 0.65);
  backdrop-filter: blur(4px);
}
.inv-frame {
  position: relative;
  display: grid;
  grid-template-columns: 280px 1fr 240px;
  gap: 10px;
  width: min(1100px, 96vw);
  max-height: 92vh;
  padding: 14px;
  background: linear-gradient(180deg, rgba(20, 8, 55, 0.95), rgba(10, 5, 24, 0.98));
  border: 1px solid rgba(160, 107, 255, 0.5);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  z-index: 1;
}
.inv-close {
  position: absolute; top: 10px; right: 12px;
  appearance: none; cursor: pointer; border: 0;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255, 90, 120, 0.25); color: #fff;
  font-size: 14px; font-weight: 900;
  border: 1px solid rgba(255, 90, 120, 0.6);
  z-index: 2;
}
.inv-close:hover { background: rgba(255, 90, 120, 0.5); }

.inv-panel {
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(40, 18, 90, 0.45), rgba(10, 5, 24, 0.6));
  border: 1px solid rgba(160, 107, 255, 0.3);
  border-radius: 12px;
  padding: 10px;
  min-height: 0;
}
.inv-panel-title {
  font-size: 11px; font-weight: 900;
  color: var(--gold);
  letter-spacing: 0.18em;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 214, 107, 0.2);
  display: flex; justify-content: space-between; align-items: center;
}
.inv-count { color: #c9b3ff; opacity: 0.7; font-size: 10px; letter-spacing: 0.1em; }

/* Equipment panel */
.eq-preview {
  text-align: center;
  padding: 12px 8px 8px;
  background: radial-gradient(80% 60% at 50% 30%, color-mix(in srgb, var(--el) 25%, transparent), transparent);
  border-radius: 10px;
  margin-bottom: 10px;
}
.eq-preview img {
  width: 110px; height: 110px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}
.eq-name {
  margin-top: 6px;
  font-size: 13px; font-weight: 900;
  color: #fff;
  letter-spacing: 0.06em;
}
.eq-cls {
  font-size: 10px; color: var(--el);
  letter-spacing: 0.1em; margin-top: 2px;
}
.eq-slots {
  display: flex; flex-direction: column; gap: 6px;
}
.eq-slot {
  display: grid;
  grid-template-columns: 76px 36px 1fr;
  gap: 8px; align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(20, 8, 55, 0.5);
  border: 1px solid var(--rar, rgba(255, 255, 255, 0.1));
  cursor: pointer;
  transition: all 0.12s ease;
}
.eq-slot.empty { border-color: rgba(255, 255, 255, 0.08); cursor: default; }
.eq-slot:not(.empty):hover {
  background: rgba(40, 18, 90, 0.75);
  transform: translateX(-2px);
  box-shadow: 0 0 12px color-mix(in srgb, var(--rar, #fff) 25%, transparent);
}
.eq-slot-label {
  font-size: 9px; font-weight: 900;
  color: var(--rar, #c9b3ff);
  letter-spacing: 0.14em;
}
.eq-slot-icon { font-size: 22px; text-align: center; }
.eq-slot-icon.muted { color: rgba(255, 255, 255, 0.25); font-size: 18px; }
.eq-slot-name { font-size: 11px; font-weight: 700; color: #fff; }
.eq-slot-name.muted { color: rgba(255, 255, 255, 0.35); font-style: italic; }

/* Item inventory panel */
.inv-tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 8px;
}
.inv-tab {
  appearance: none; cursor: pointer; border: 0;
  background: rgba(20, 8, 55, 0.6);
  border: 1px solid rgba(160, 107, 255, 0.3);
  padding: 5px 10px; border-radius: 999px;
  font-size: 10px; font-weight: 800;
  color: #c9b3ff;
  letter-spacing: 0.08em;
  display: flex; align-items: center; gap: 4px;
  transition: all 0.12s ease;
}
.inv-tab:hover { background: rgba(40, 18, 90, 0.9); color: #fff; }
.inv-tab.active {
  background: linear-gradient(180deg, var(--violet), #5e2eb8);
  color: #fff;
  border-color: var(--violet);
  box-shadow: 0 2px 12px rgba(160, 107, 255, 0.4);
}
.inv-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.inv-cell {
  aspect-ratio: 1;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0.35));
  border: 1px solid var(--rar, rgba(255, 255, 255, 0.08));
  border-radius: 6px;
  position: relative;
  cursor: pointer;
  display: grid; place-items: center;
  transition: all 0.1s ease;
  overflow: hidden;
}
.inv-cell.empty { cursor: default; background: rgba(0,0,0,0.25); border-color: rgba(255,255,255,0.04); }
.inv-cell:not(.empty):hover {
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px var(--rar, #fff), 0 6px 14px color-mix(in srgb, var(--rar, #fff) 35%, transparent);
}
.inv-cell.selected {
  box-shadow: 0 0 0 2px var(--gold), 0 0 14px color-mix(in srgb, var(--gold) 50%, transparent);
}
.ic-icon { font-size: 22px; }
.ic-qty {
  position: absolute; bottom: 1px; right: 3px;
  font-size: 9px; font-weight: 900;
  background: rgba(0,0,0,0.7); color: var(--gold);
  padding: 0 3px; border-radius: 3px;
}
.inv-detail {
  background: linear-gradient(180deg, rgba(20, 8, 55, 0.7), rgba(10, 5, 24, 0.85));
  border: 1px solid var(--rar, rgba(160, 107, 255, 0.3));
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: auto;
}
.inv-detail.empty { padding: 22px; text-align: center; }
.id-placeholder { font-size: 11px; color: rgba(201, 179, 255, 0.5); letter-spacing: 0.1em; }
.id-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.id-icon { font-size: 28px; }
.id-name { font-size: 13px; font-weight: 900; color: #fff; }
.id-rarity { font-size: 10px; color: var(--rar); letter-spacing: 0.12em; font-weight: 700; }
.id-stats { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.id-stat {
  background: rgba(20, 8, 55, 0.6);
  border: 1px solid var(--rar);
  padding: 2px 8px; border-radius: 6px;
  font-size: 10px; font-weight: 800;
  color: var(--rar);
  letter-spacing: 0.06em;
}
.id-desc {
  font-size: 11px; color: #c9b3ff;
  font-style: italic; opacity: 0.85;
  margin: 4px 0 8px;
  line-height: 1.4;
}
.id-actions { display: flex; gap: 8px; align-items: center; }
.id-qty { font-size: 10px; color: var(--gold); letter-spacing: 0.08em; font-weight: 700; }
.id-actions .btn { padding: 8px 16px; font-size: 11px; }

/* Character stat panel */
.stat-block {
  background: rgba(20, 8, 55, 0.5);
  border: 1px solid rgba(160, 107, 255, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: #c9b3ff;
  letter-spacing: 0.04em;
  padding: 3px 0;
}
.stat-row b { font-size: 13px; color: #fff; font-weight: 900; }
.stat-row.hp b { color: #ff5b7a; }
.stat-row.mp b { color: #6bd1ff; }
.stat-row.atk b { color: #ffd66b; }
.stat-row.def b { color: var(--good); }
.stat-row .bonus { font-size: 9px; color: rgba(201, 179, 255, 0.7); margin-left: 2px; }

@media (max-width: 880px) {
  .inv-frame { grid-template-columns: 1fr; max-height: 95vh; overflow-y: auto; }
  .inv-grid { grid-template-columns: repeat(8, 1fr); }
}

/* =================== LOADING SHIM =================== */
.loading-shim {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #06021f;
  z-index: 20;
}
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid rgba(160,107,255,0.25);
  border-top-color: var(--violet);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ls-text { color: #c9b3ff; margin-top: 14px; font-size: 13px; letter-spacing: 0.2em; }
.ls-bar { width: 240px; height: 6px; background: rgba(255,255,255,0.08); border-radius: 6px; margin-top: 14px; overflow: hidden; }
.ls-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--violet), var(--gold)); transition: width 0.2s; }

/* =================== BOOT LOADER =================== */
#boot-loader {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #06021f;
  z-index: 100;
  transition: opacity 0.4s ease;
}
#boot-loader .title {
  font-size: clamp(32px, 5vw, 56px); font-weight: 900;
  background: linear-gradient(180deg, #fff, var(--violet));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 18px;
}
#boot-bar { width: 240px; height: 6px; background: rgba(255,255,255,0.08); border-radius: 6px; overflow: hidden; }
#boot-bar > div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--violet), var(--gold)); transition: width 0.15s; }

/* =================== INSTALL TOAST (from v1, still used) =================== */
#install-toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  z-index: 50; display: none; align-items: center; gap: 10px;
  padding: 10px 14px 10px 16px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(40,18,90,0.92), rgba(10,5,24,0.92));
  border: 1px solid rgba(160,107,255,0.55);
  box-shadow: 0 10px 28px rgba(0,0,0,0.5), 0 0 18px rgba(160,107,255,0.35);
  backdrop-filter: blur(10px);
  color: #fff; font-size: 13px; font-weight: 600; max-width: calc(100vw - 24px);
}
#install-toast.show { display: inline-flex; }
#install-toast .it-icon {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(180deg, var(--violet), #5e2eb8);
  display: inline-grid; place-items: center; font-size: 13px; font-weight: 900;
}
#install-toast .it-action {
  appearance: none; cursor: pointer;
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: #2a1500; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  border: 0; padding: 6px 12px; border-radius: 999px; font-size: 11px;
}
#install-toast .it-close {
  appearance: none; cursor: pointer; background: transparent;
  color: #c9b3ff; border: 0; font-size: 16px; padding: 2px 4px; opacity: 0.7;
}
#install-sheet {
  position: fixed; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(6px); padding: 24px;
}
#install-sheet.show { display: flex; }
#install-sheet .sheet {
  max-width: 360px; width: 100%;
  background: linear-gradient(180deg, #1b0f3e, #0a0518);
  border: 1px solid rgba(160,107,255,0.4);
  border-radius: 18px; padding: 22px; text-align: center;
}
#install-sheet h3 {
  margin: 0 0 6px; font-size: 18px; font-weight: 900;
  background: linear-gradient(180deg, #fff, var(--violet));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
#install-sheet p { margin: 4px 0; color: #c9b3ff; font-size: 13px; line-height: 1.5; }
#install-sheet .step { display: flex; align-items: center; gap: 10px; text-align: left; margin: 10px 0; font-size: 13px; }
#install-sheet .step .n {
  flex: 0 0 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: #2a1500; font-weight: 900; font-size: 12px;
  display: grid; place-items: center;
}
#install-sheet .share-glyph {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 5px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.2);
  color: #7CC3FF; font-weight: 900;
}
#install-sheet .close {
  margin-top: 14px; appearance: none; cursor: pointer;
  background: rgba(255,255,255,0.06); color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
  padding: 10px 20px; border-radius: 999px; font-weight: 700;
}

/* =====================================================================
   MODERN MMORPG UI SKIN
   MapleStory-style clarity + GrandChase arcade energy, built as DOM HUD.
   ===================================================================== */
:root {
  --ui-ink: rgba(12, 13, 30, 0.84);
  --ui-ink-strong: rgba(7, 8, 19, 0.94);
  --ui-panel: rgba(23, 21, 47, 0.78);
  --ui-line: rgba(255, 255, 255, 0.16);
  --ui-soft: #d8e4ff;
  --ui-muted: #9fb0d5;
  --ui-red: #ff4f6f;
  --ui-blue: #4eb5ff;
  --ui-green: #72f0ad;
  --ui-amber: #ffd268;
  --ui-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
}

.ar-hud {
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
}

.ar-hud .ms-minimap,
.ar-hud .ms-stage-info,
.ar-hud .ms-command-deck,
.ar-hud .ms-quest-tracker .qt-card,
.ar-hud .ms-context-prompt,
.ar-hud .ms-boss-plate {
  border: 1px solid var(--ui-line);
  box-shadow: var(--ui-shadow), 0 0 0 1px rgba(255,255,255,0.06) inset;
  backdrop-filter: blur(10px) saturate(1.25);
}

.ar-hud .ms-minimap {
  top: 14px;
  left: 14px;
  width: 254px;
  padding: 8px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), transparent 34%),
    linear-gradient(180deg, color-mix(in srgb, var(--el) 15%, var(--ui-panel)), var(--ui-ink-strong));
}
.ar-hud .mm-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--ui-soft);
  font-size: 10px;
  letter-spacing: 0;
  margin: 0 0 6px;
}
.ar-hud .mm-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ar-hud .mm-title b {
  flex: 0 0 auto;
  color: #10131f;
  background: linear-gradient(180deg, #f6fff9, var(--ui-green));
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 9px;
  box-shadow: 0 0 12px rgba(114,240,173,0.25);
}
.ar-hud .ms-minimap canvas {
  width: 236px;
  height: 86px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  background:
    linear-gradient(180deg, rgba(19, 34, 50, 0.8), rgba(10, 13, 30, 0.92));
}

.ar-hud .ms-stage-info {
  top: 14px;
  right: 14px;
  min-width: 196px;
  padding: 8px 8px 8px 14px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.09), transparent 38%),
    linear-gradient(180deg, color-mix(in srgb, var(--el) 14%, var(--ui-panel)), var(--ui-ink-strong));
}
.ms-stage-copy {
  min-width: 0;
  flex: 1;
}
.ar-hud .ms-stage-world {
  color: #fff;
  font-size: 12px;
  line-height: 1.1;
  letter-spacing: 0;
}
.ar-hud .ms-stage-sub {
  color: var(--ui-muted);
  font-size: 10px;
  letter-spacing: 0;
  margin-top: 2px;
}
.ar-hud .ms-stage-sub span {
  color: var(--ui-amber);
}
.ar-hud .ms-pause-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.02)),
    color-mix(in srgb, var(--el) 30%, rgba(16,18,36,0.9));
  border: 1px solid color-mix(in srgb, var(--el) 58%, rgba(255,255,255,0.18));
  box-shadow: 0 6px 14px rgba(0,0,0,0.28);
}

.ar-hud .ms-command-deck {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  width: min(1060px, calc(100% - 28px));
  min-height: 92px;
  display: grid;
  grid-template-columns: 190px minmax(250px, 1fr) auto 174px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  overflow: visible;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.11), transparent 28%),
    linear-gradient(180deg, color-mix(in srgb, var(--el) 12%, var(--ui-panel)), var(--ui-ink-strong));
}
.ar-hud .ms-deck-bg {
  position: absolute;
  inset: 4px;
  pointer-events: none;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
}
.ar-hud .ms-command-deck > :not(.ms-deck-bg) {
  position: relative;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  z-index: 1;
}

.ar-hud .ms-char-card {
  position: static;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px;
  border-radius: 8px;
  background:
    radial-gradient(80% 90% at 26% 22%, color-mix(in srgb, var(--el) 32%, transparent), transparent),
    rgba(0,0,0,0.18);
  border: 1px solid color-mix(in srgb, var(--el) 50%, rgba(255,255,255,0.14));
  box-shadow: none;
  backdrop-filter: none;
}
.ar-hud .ms-char-card.danger {
  animation: hudDanger 0.72s ease-in-out infinite;
}
@keyframes hudDanger {
  0%, 100% { border-color: rgba(255,79,111,0.58); }
  50% { border-color: rgba(255,210,104,0.86); box-shadow: 0 0 16px rgba(255,79,111,0.32); }
}
.ar-hud .ms-portrait {
  width: 60px;
  height: 60px;
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14), transparent),
    radial-gradient(80% 80% at 50% 36%, color-mix(in srgb, var(--el) 34%, rgba(255,255,255,0.08)), rgba(0,0,0,0.22));
  border: 1px solid color-mix(in srgb, var(--el) 64%, rgba(255,255,255,0.18));
}
.ar-hud .ms-portrait img {
  padding: 2px;
  filter: drop-shadow(0 5px 8px rgba(0,0,0,0.45));
}
.ar-hud .ms-char-name {
  font-size: 15px;
  line-height: 1;
  color: #fff;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ar-hud .ms-char-lvl {
  margin-top: 5px;
  color: var(--ui-soft);
  font-size: 13px;
}
.ar-hud .ms-anima-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ar-hud .ms-lv-tag {
  color: #382300;
  background: linear-gradient(180deg, #fff2ae, var(--ui-amber));
  border-radius: 5px;
  padding: 2px 6px;
}

.ar-hud .ms-bars {
  position: static;
  transform: none;
  width: auto;
  min-width: 0;
  gap: 4px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  backdrop-filter: none;
}
.ar-hud .ms-bar {
  grid-template-columns: 31px minmax(0, 1fr);
  gap: 6px;
}
.ar-hud .ms-bar-icon {
  color: var(--ui-soft);
  font-size: 10px;
  line-height: 1;
  text-align: right;
  text-shadow: 0 1px 2px #000;
}
.ar-hud .ms-bar-track {
  height: 15px;
  border-radius: 5px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(0,0,0,0.16)),
    rgba(0,0,0,0.42);
  border: 1px solid rgba(255,255,255,0.17);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.34) inset;
}
.ar-hud .ms-bar-fill {
  border-radius: 4px;
  box-shadow:
    inset 0 2px 4px rgba(255,255,255,0.28),
    inset 0 -3px 5px rgba(0,0,0,0.2);
}
.ar-hud .ms-bar-hp .ms-bar-fill {
  background: linear-gradient(180deg, #ffb3c2 0%, var(--ui-red) 48%, #b41736 100%);
}
.ar-hud .ms-bar-mp .ms-bar-fill {
  background: linear-gradient(180deg, #bfe9ff 0%, var(--ui-blue) 50%, #1c65d8 100%);
}
.ar-hud .ms-bar-xp .ms-bar-track {
  height: 9px;
}
.ar-hud .ms-bar-xp .ms-bar-fill {
  background: linear-gradient(180deg, #fff6be 0%, var(--ui-amber) 52%, #c6781d 100%);
}
.ar-hud .ms-bar-text,
.ar-hud .ms-bar-xp .ms-bar-text {
  right: 8px;
  left: auto;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  color: #fff;
  font-size: 10px;
  letter-spacing: 0;
}
.ar-hud .ms-bar-xp .ms-bar-text {
  font-size: 9px;
}

.ar-hud .ms-quickslots {
  position: static;
  align-items: stretch;
  gap: 5px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  backdrop-filter: none;
}
.ar-hud .ms-quickslots-label {
  color: var(--ui-muted);
  font-size: 10px;
  letter-spacing: 0;
  text-align: right;
}
.ar-hud .ms-quickslots-row {
  gap: 6px;
}
.ar-hud .ms-skill {
  width: 49px;
  height: 52px;
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02)),
    linear-gradient(180deg, color-mix(in srgb, var(--el) 24%, #22263b), #070914);
  border: 1px solid color-mix(in srgb, var(--el) 62%, rgba(255,255,255,0.16));
  box-shadow: 0 8px 18px rgba(0,0,0,0.28), 0 0 14px color-mix(in srgb, var(--el) 24%, transparent);
}
.ar-hud .ms-skill-icon {
  inset: 4px 4px 13px;
  font-size: 22px;
}
.ar-hud .ms-skill-icon.muted {
  font-size: 9px;
  color: rgba(255,255,255,0.44);
}
.ar-hud .ms-skill-name {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  color: rgba(255,255,255,0.82);
  font-size: 7px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000;
}
.ar-hud .ms-skill-key {
  top: 3px;
  right: 3px;
  min-width: 15px;
  color: #1a1524;
  background: linear-gradient(180deg, #fff6bd, var(--ui-amber));
  border-radius: 4px;
  text-align: center;
  font-size: 9px;
}
.ar-hud .ms-skill-cd-fill {
  background: rgba(0,0,0,0.68);
}

.ar-hud .ms-meta {
  position: static;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.ar-hud .ms-meta-pill {
  justify-content: center;
  min-height: 29px;
  padding: 5px 7px;
  border-radius: 7px;
  color: var(--ui-soft);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.13);
  font-size: 11px;
  letter-spacing: 0;
}
.ar-hud .ms-meta-pill b {
  color: var(--ui-amber);
  font-size: 10px;
  margin-left: 2px;
}
.ar-hud .ms-meta-pill.ms-coins {
  grid-column: 1 / -1;
  color: var(--ui-amber);
  border-color: rgba(255,210,104,0.38);
}
.ar-hud .ms-meta-pill.ms-inv-btn {
  font-size: 10px;
  border-color: rgba(255,255,255,0.16);
}

.ar-hud .ms-context-prompt {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, calc(-100% + 8px));
  opacity: 0;
  pointer-events: none;
  border-radius: 7px;
  padding: 6px 12px;
  color: #111525;
  background: linear-gradient(180deg, #fff7bd, var(--ui-amber));
  font-weight: 900;
  font-size: 12px;
  white-space: nowrap;
  z-index: 8;
  box-shadow: 0 8px 18px rgba(0,0,0,0.24), 0 0 0 1px rgba(255,255,255,0.5) inset;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ar-hud .ms-context-prompt.show {
  opacity: 1;
  transform: translate(-50%, -100%);
}

.ar-hud .ms-boss-plate {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translate(-50%, -10px);
  opacity: 0;
  width: min(560px, 44vw);
  padding: 8px 10px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), transparent 34%),
    linear-gradient(180deg, rgba(72,14,34,0.86), rgba(11,8,20,0.94));
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ar-hud .ms-boss-plate.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.ar-hud .ms-boss-name {
  color: #fff;
  font-weight: 900;
  font-size: 12px;
  text-align: center;
  margin-bottom: 5px;
  text-shadow: 0 1px 2px #000;
}
.ar-hud .ms-boss-track {
  height: 12px;
  border-radius: 5px;
  overflow: hidden;
  background: rgba(0,0,0,0.46);
  border: 1px solid rgba(255,255,255,0.16);
}
.ar-hud .ms-boss-fill {
  height: 100%;
  width: 100%;
  border-radius: 4px;
  background: linear-gradient(180deg, #ffb0bc, #ff365e 50%, #90112b);
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.3);
  transition: width 0.16s ease;
}

.ar-hud .ms-quest-tracker {
  top: 72px;
  right: 14px;
  width: 230px;
  gap: 6px;
}
.ar-hud .ms-quest-tracker.empty {
  display: none;
}
.ar-hud .qt-card {
  border-radius: 7px;
  padding: 8px 10px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), transparent 35%),
    var(--ui-ink);
  border-color: rgba(255,210,104,0.28);
}
.ar-hud .qt-label {
  color: var(--ui-amber);
  font-size: 9px;
  font-weight: 900;
  margin-bottom: 2px;
}
.ar-hud .qt-name {
  color: #fff;
  font-size: 12px;
  line-height: 1.1;
  letter-spacing: 0;
}
.ar-hud .qt-line {
  color: var(--ui-muted);
  font-size: 10px;
}
.ar-hud .qt-line.done {
  color: var(--ui-green);
  text-decoration: none;
}

.hud-touch {
  z-index: 6;
}
.touch-pad,
.touch-actions,
.touch-skills {
  align-items: center;
}
.tp-btn {
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02)),
    rgba(10,12,25,0.74);
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 8px 18px rgba(0,0,0,0.28);
}
.tp-attack { background-color: rgba(255,79,111,0.38); }
.tp-jump { background-color: rgba(114,240,173,0.28); }
.tp-heavy { background-color: rgba(255,210,104,0.32); }
.tp-dodge { background-color: rgba(78,181,255,0.28); }

.dialogue-modal,
.shop-frame,
.ql-frame,
.wm-frame,
.inv-frame,
.pause-overlay .btn,
.death-card,
.result-card,
.victory-card {
  border-radius: 8px;
}
.dialogue-modal,
.shop-frame,
.ql-frame,
.wm-frame,
.inv-frame {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.07), transparent 28%),
    linear-gradient(180deg, rgba(25,25,54,0.96), rgba(7,8,19,0.98));
  border-color: rgba(255,255,255,0.16);
  box-shadow: 0 24px 60px rgba(0,0,0,0.62), 0 0 0 1px rgba(255,255,255,0.05) inset;
}
.dlg-text,
.shop-panel,
.ql-card,
.inv-panel,
.inv-detail,
.stat-block {
  border-radius: 7px;
}
.btn,
.cs-action,
.dlg-opt,
.ql-tab,
.inv-tab,
.shop-row,
.wm-card,
.world-card,
.stage-node .sn-circle,
.anima-pick,
.col-card {
  border-radius: 8px;
}

@media (max-width: 980px) {
  .ar-hud .ms-command-deck {
    width: calc(100% - 20px);
    grid-template-columns: 178px minmax(220px, 1fr) auto;
  }
  .ar-hud .ms-meta {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .ar-hud .ms-meta-pill.ms-coins {
    grid-column: auto;
  }
  .ar-hud .ms-skill {
    width: 48px;
  }
  .ar-hud .ms-minimap {
    width: 222px;
  }
  .ar-hud .ms-minimap canvas {
    width: 204px;
  }
}

@media (max-width: 720px) {
  .ar-hud .ms-minimap {
    width: 174px;
    padding: 6px;
  }
  .ar-hud .ms-minimap canvas {
    width: 160px;
    height: 54px;
  }
  .ar-hud .mm-title {
    font-size: 9px;
  }
  .ar-hud .mm-title b {
    display: none;
  }
  .ar-hud .ms-stage-info {
    min-width: 116px;
    padding: 7px;
  }
  .ar-hud .ms-stage-world {
    font-size: 10px;
  }
  .ar-hud .ms-stage-sub {
    font-size: 9px;
  }
  .ar-hud .ms-command-deck {
    bottom: 8px;
    min-height: 92px;
    grid-template-columns: 136px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }
  .ar-hud .ms-char-card {
    grid-template-columns: 48px minmax(0, 1fr);
  }
  .ar-hud .ms-portrait {
    width: 48px;
    height: 48px;
  }
  .ar-hud .ms-char-name {
    font-size: 12px;
  }
  .ar-hud .ms-char-lvl {
    font-size: 11px;
  }
  .ar-hud .ms-bars {
    grid-column: 2;
  }
  .ar-hud .ms-bar {
    grid-template-columns: 26px minmax(0, 1fr);
  }
  .ar-hud .ms-bar-track {
    height: 14px;
  }
  .ar-hud .ms-bar-icon,
  .ar-hud .ms-bar-text {
    font-size: 8px;
  }
  .ar-hud .ms-quickslots {
    display: none;
  }
  .ar-hud .ms-meta {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .ar-hud .ms-meta-pill {
    min-height: 28px;
    font-size: 9px;
    padding: 4px 6px;
  }
  .ar-hud .ms-quest-tracker {
    display: none;
  }
  .ar-hud .ms-context-prompt {
    bottom: 112px;
    font-size: 11px;
  }
  .ar-hud .ms-boss-plate {
    width: min(360px, 52vw);
  }
}

@media (orientation: portrait) and (max-width: 720px) {
  #stage {
    place-items: stretch;
    padding: 0;
  }
  #frame {
    width: 100dvw;
    height: 100dvh;
    aspect-ratio: auto;
    border-radius: 0;
  }
}

@media (hover: none) and (pointer: coarse) {
  .ar-hud .hud-touch {
    display: flex;
    left: 8px;
    right: 8px;
    bottom: 126px;
    padding: 0;
  }
  .ar-hud .tp-btn {
    width: 44px;
    height: 44px;
    font-size: 14px;
  }
  .ar-hud .tp-sk,
  .ar-hud .tp-use {
    width: 36px;
    height: 36px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ar-hud *,
  .ar-hud *::before,
  .ar-hud *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ================================================================
   AUTH BADGE + LOGIN/REGISTER MODAL
   ================================================================ */
.auth-badge {
  position: absolute; top: 18px; right: 18px;
  z-index: 50;
  background: linear-gradient(180deg, rgba(10,5,24,0.88), rgba(20,10,44,0.92));
  border: 1px solid rgba(160,107,255,0.35);
  border-radius: 10px;
  padding: 8px 12px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  color: #fff;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 22px rgba(0,0,0,0.45);
  min-width: 220px;
}
.auth-badge-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.auth-badge-row.sub {
  margin-top: 4px;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  color: rgba(201,179,255,0.7);
  letter-spacing: 0.08em;
}
.auth-badge-row.sub span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-badge-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.auth-badge-dot.guest { background: #ffd66b; box-shadow: 0 0 6px #ffd66b; }
.auth-badge-dot.logged { background: #7CFFB8; box-shadow: 0 0 6px #7CFFB8; }
.auth-badge-text {
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 220px;
}
.auth-badge-tag {
  font-weight: 900; letter-spacing: 0.1em;
}
.auth-badge-btn {
  background: none;
  border: 1px solid rgba(160,107,255,0.45);
  color: #c9b3ff;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 10px; font-weight: 900; letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.12s ease;
}
.auth-badge-btn:hover {
  border-color: #fff; color: #fff;
  background: rgba(160,107,255,0.18);
}
.auth-badge-btn.primary {
  border-color: #7CFFB8;
  color: #7CFFB8;
}
.auth-badge-btn.primary:hover {
  background: rgba(124,255,184,0.15);
  color: #fff;
}

.auth-modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: grid; place-items: center;
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.auth-modal-overlay {
  position: absolute; inset: 0;
  background: rgba(2,1,8,0.78);
  backdrop-filter: blur(6px);
}
.auth-modal-frame {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  background: linear-gradient(180deg, #1c0e3e, #0a0521);
  border: 1px solid rgba(160,107,255,0.45);
  border-radius: 14px;
  padding: 28px 28px 22px;
  color: #fff;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6), 0 0 30px rgba(160,107,255,0.25);
}
.auth-modal-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: 0;
  color: rgba(255,255,255,0.55);
  font-size: 18px; cursor: pointer;
  padding: 6px 10px;
}
.auth-modal-close:hover { color: #fff; }
.auth-modal-title {
  font-size: 22px; font-weight: 900; letter-spacing: 0.12em;
  color: #fff;
  margin-bottom: 4px;
}
.auth-modal-sub {
  font-size: 12px;
  color: rgba(201,179,255,0.7);
  margin-bottom: 18px;
}
.auth-modal-tabs {
  display: flex; gap: 4px;
  margin-bottom: 18px;
  background: rgba(0,0,0,0.4);
  padding: 4px;
  border-radius: 8px;
}
.auth-modal-tab {
  flex: 1;
  background: none; border: 0;
  color: rgba(255,255,255,0.55);
  font-size: 11px; font-weight: 900; letter-spacing: 0.1em;
  padding: 9px 12px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.auth-modal-tab.active {
  background: linear-gradient(180deg, rgba(160,107,255,0.35), rgba(80,40,160,0.5));
  color: #fff;
  box-shadow: 0 0 10px rgba(160,107,255,0.3);
}
.auth-modal-tab:hover:not(.active) { color: #fff; }
.auth-modal-form { display: flex; flex-direction: column; gap: 12px; }
.auth-modal-label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 10px; font-weight: 900; letter-spacing: 0.1em;
  color: rgba(201,179,255,0.75);
}
.auth-modal-label input {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(160,107,255,0.3);
  color: #fff;
  font-size: 14px; font-family: inherit;
  padding: 10px 12px;
  border-radius: 6px;
  transition: border-color 0.12s ease;
}
.auth-modal-label input:focus {
  outline: none;
  border-color: #7CFFB8;
}
.auth-modal-error {
  background: rgba(255,90,120,0.18);
  border: 1px solid rgba(255,90,120,0.55);
  color: #ffb6c0;
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 5px;
}
.auth-modal-submit {
  margin-top: 4px;
  background: linear-gradient(180deg, #6BD1FF, #3a9bff);
  border: 0;
  color: #0a0521;
  font-size: 14px; font-weight: 900; letter-spacing: 0.12em;
  padding: 13px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.auth-modal-submit:hover { filter: brightness(1.1); transform: translateY(-1px); }
.auth-modal-submit:disabled {
  opacity: 0.5; cursor: not-allowed;
  transform: none; filter: grayscale(0.3);
}
.auth-modal-note {
  margin-top: 14px;
  font-size: 11px;
  color: rgba(201,179,255,0.55);
  line-height: 1.5;
}

/* ================================================================
   SKILL TREE MODAL
   ================================================================ */
.st-modal { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center;
  font-family: ui-sans-serif, system-ui, sans-serif; }
.st-overlay { position: absolute; inset: 0; background: rgba(2,1,8,0.82); backdrop-filter: blur(6px); }
.st-frame {
  position: relative;
  width: min(960px, calc(100vw - 32px));
  height: min(720px, calc(100vh - 32px));
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #160a32, #08041a);
  border: 1px solid rgba(160,107,255,0.45);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.6), 0 0 40px rgba(160,107,255,0.2);
  color: #fff; overflow: hidden;
}
.st-close { position: absolute; top: 10px; right: 14px; z-index: 4;
  background: none; border: 0; color: rgba(255,255,255,0.55); font-size: 20px; cursor: pointer; padding: 6px 10px; }
.st-close:hover { color: #fff; }
.st-header { display: flex; align-items: baseline; gap: 14px; padding: 16px 22px 10px; }
.st-title { font-size: 20px; font-weight: 900; letter-spacing: 0.14em; }
.st-sub { font-size: 12px; color: rgba(201,179,255,0.7); flex: 1; }
.st-points { font-size: 13px; letter-spacing: 0.1em; color: #7CFFB8; }
.st-points b { font-size: 18px; }

.st-graph { position: relative; flex: 1; margin: 4px 16px; border-radius: 12px;
  background:
    radial-gradient(circle at 50% 30%, rgba(160,107,255,0.10), transparent 60%),
    rgba(0,0,0,0.25);
  overflow: hidden; }
.st-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.st-node { position: absolute; transform: translate(-50%, -50%);
  width: 76px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; user-select: none; }
.st-node-hex {
  width: 46px; height: 46px;
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.02)),
              linear-gradient(180deg, color-mix(in srgb, var(--c) 22%, #1a1430), #0a0518);
  border: 2px solid color-mix(in srgb, var(--c) 55%, rgba(255,255,255,0.18));
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: all 0.12s ease;
}
.st-node-label { font-size: 9px; font-weight: 800; text-align: center; line-height: 1.05;
  color: rgba(255,255,255,0.78); max-width: 84px; text-shadow: 0 1px 2px #000; }
.st-node-rank { position: absolute; top: 30px; font-size: 10px; font-weight: 900;
  color: #fff; background: rgba(0,0,0,0.6); padding: 0 5px; border-radius: 4px; }
.st-node-lock { position: absolute; top: 12px; font-size: 16px; }

.st-node.tier0 .st-node-hex { width: 54px; height: 54px; }
.st-node.tier3 .st-node-hex { width: 56px; height: 56px;
  border-color: color-mix(in srgb, var(--c) 80%, #fff); }
.st-node.available .st-node-hex {
  border-color: var(--c);
  box-shadow: 0 0 16px color-mix(in srgb, var(--c) 60%, transparent);
  animation: stPulse 1.4s ease-in-out infinite;
}
.st-node.maxed .st-node-hex {
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c));
  border-color: #fff;
  box-shadow: 0 0 18px color-mix(in srgb, var(--c) 75%, transparent);
}
.st-node.locked { opacity: 0.45; cursor: default; }
.st-node.locked .st-node-hex { filter: grayscale(0.7); }
.st-node.selected .st-node-hex { outline: 2px solid #fff; outline-offset: 2px; }
.st-node:hover .st-node-hex { transform: scale(1.08); }
@keyframes stPulse {
  0%,100% { box-shadow: 0 0 12px color-mix(in srgb, var(--c) 45%, transparent); }
  50%     { box-shadow: 0 0 22px color-mix(in srgb, var(--c) 85%, transparent); }
}

.st-detail { min-height: 96px; margin: 6px 22px; padding: 10px 14px;
  background: rgba(0,0,0,0.3); border-radius: 10px; border: 1px solid rgba(255,255,255,0.08); }
.st-detail-name { font-size: 15px; font-weight: 900; letter-spacing: 0.05em; color: var(--c, #fff); }
.st-detail-rank { font-size: 11px; color: rgba(201,179,255,0.7); margin: 2px 0 6px; }
.st-detail-blurb { font-size: 12px; color: rgba(255,255,255,0.82); line-height: 1.5; }
.st-detail-locked { font-size: 11px; color: #ff9bb0; margin-top: 6px; }
.st-detail-maxed { font-size: 11px; color: #7CFFB8; margin-top: 6px; }
.st-spend-btn { margin-top: 8px; background: linear-gradient(180deg, #7CFFB8, #2fbf7a);
  border: 0; color: #04140c; font-size: 13px; font-weight: 900; letter-spacing: 0.08em;
  padding: 9px 18px; border-radius: 7px; cursor: pointer; transition: all 0.12s ease; }
.st-spend-btn:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.st-spend-btn:disabled { opacity: 0.4; cursor: not-allowed; background: #444; color: #aaa; }

.st-footer { display: flex; align-items: center; justify-content: space-between; padding: 8px 22px 16px; }
.st-respec { background: none; border: 1px solid rgba(255,90,120,0.5); color: #ff9bb0;
  font-size: 11px; font-weight: 800; letter-spacing: 0.06em; padding: 7px 14px; border-radius: 6px; cursor: pointer; }
.st-respec:hover:not(:disabled) { background: rgba(255,90,120,0.15); color: #fff; }
.st-respec:disabled { opacity: 0.4; cursor: not-allowed; }
.st-hint { font-size: 11px; color: rgba(255,255,255,0.4); }

/* ================================================================
   CONSUMABLE QUICKSLOTS (1..5 hotbar)
   ================================================================ */
.ms-itemslots {
  display: flex; flex-direction: column; align-items: stretch; gap: 5px;
  padding: 0;
}
.ms-itemslots-label {
  color: var(--ui-muted, rgba(201,179,255,0.65));
  font-size: 10px; font-weight: 900; letter-spacing: 0.06em;
  text-align: right;
}
.ms-itemslots-row { display: flex; gap: 6px; }
.ms-itemslot {
  position: relative;
  width: 49px; height: 52px;
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.02)),
    linear-gradient(180deg, color-mix(in srgb, var(--el, #7CFFB8) 24%, #22263b), #070914);
  border: 1px solid color-mix(in srgb, var(--el, #7CFFB8) 62%, rgba(255,255,255,0.16));
  box-shadow: 0 8px 18px rgba(0,0,0,0.28), 0 0 14px color-mix(in srgb, var(--el, #7CFFB8) 24%, transparent);
  cursor: pointer;
  user-select: none;
  transition: transform 0.08s ease;
}
.ms-itemslot:hover { transform: translateY(-1px); }
.ms-itemslot:active { transform: translateY(1px); }
.ms-itemslot.empty {
  border-color: rgba(255,255,255,0.10);
  box-shadow: none;
  opacity: 0.55;
  background: linear-gradient(180deg, rgba(40,18,90,0.4), rgba(10,5,24,0.6));
  cursor: default;
}
.ms-itemslot-icon {
  position: absolute; inset: 3px 3px 14px;
  display: grid; place-items: center;
  font-size: 22px;
  text-shadow: 0 0 8px color-mix(in srgb, var(--el, #7CFFB8) 50%, transparent);
}
.ms-itemslot-icon.muted { color: rgba(255,255,255,0.36); font-size: 14px; text-shadow: none; }
.ms-itemslot-qty {
  position: absolute; bottom: 1px; left: 3px;
  font-size: 10px; font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 4px rgba(0,0,0,0.8);
  pointer-events: none;
}
.ms-itemslot-key {
  position: absolute; top: 1px; right: 3px;
  font-size: 9px; font-weight: 900;
  color: #fff;
  background: rgba(0,0,0,0.55);
  padding: 0 4px; border-radius: 3px;
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* ================================================================
   INVENTORY MODAL — BIND TO HOTBAR row
   ================================================================ */
.id-bind-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin: 8px 0;
  padding: 6px 8px;
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
}
.id-bind-label {
  font-size: 10px; font-weight: 900; letter-spacing: 0.08em;
  color: rgba(201,179,255,0.75);
  margin-right: 4px;
}
.id-bind-btn {
  position: relative;
  min-width: 30px; height: 30px;
  padding: 0 6px;
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(40,18,90,0.7), rgba(10,5,24,0.85));
  border: 1px solid rgba(160,107,255,0.45);
  color: #c9b3ff;
  font-size: 12px; font-weight: 900; letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.12s ease;
}
.id-bind-btn:hover {
  border-color: #c9b3ff;
  color: #fff;
  background: linear-gradient(180deg, rgba(80,40,160,0.85), rgba(30,10,60,0.95));
}
.id-bind-btn.active {
  border-color: #7CFFB8;
  color: #7CFFB8;
  background: linear-gradient(180deg, rgba(20,80,55,0.9), rgba(10,30,20,0.95));
  box-shadow: 0 0 8px rgba(124,255,184,0.45);
}
.id-bind-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 11px;
  opacity: 0.75;
}

/* ================================================================
   COMPACT MAPLE-STYLE HUD BAR OVERRIDE
   Keep the persistent HUD as a slim bottom strip that scales with #frame.
   ================================================================ */
.ar-hud .ms-minimap {
  width: clamp(150px, 17vw, 254px);
  padding: clamp(5px, 0.55vw, 8px);
}
.ar-hud .ms-minimap canvas {
  width: calc(100% - 2px);
  height: clamp(46px, 5.2vw, 76px);
}
.ar-hud .mm-title { font-size: clamp(8px, 0.72vw, 10px); }
.ar-hud .mm-title b {
  padding: 1px 5px;
  font-size: clamp(7px, 0.62vw, 9px);
}
.ar-hud .ms-stage-info {
  min-width: clamp(118px, 13vw, 188px);
  padding: clamp(5px, 0.55vw, 8px) clamp(8px, 0.8vw, 12px);
}
.ar-hud .ms-stage-world { font-size: clamp(10px, 0.95vw, 13px); }
.ar-hud .ms-stage-sub { font-size: clamp(8px, 0.75vw, 10px); }

.ar-hud .ms-command-deck {
  bottom: clamp(4px, 0.7vw, 8px);
  width: min(1180px, calc(100% - clamp(10px, 1.4vw, 24px)));
  min-height: 0;
  display: grid;
  grid-template-columns:
    clamp(132px, 14vw, 174px)
    minmax(210px, 1fr)
    auto
    auto
    clamp(168px, 14vw, 220px);
  gap: clamp(5px, 0.55vw, 8px);
  align-items: center;
  padding: clamp(5px, 0.55vw, 8px);
  border-radius: 7px;
}
.ar-hud .ms-deck-bg { inset: 3px; }
.ar-hud .ms-char-card {
  grid-template-columns: clamp(34px, 4vw, 48px) minmax(0, 1fr);
  gap: clamp(5px, 0.55vw, 8px);
  padding: clamp(4px, 0.5vw, 6px);
  background: rgba(0,0,0,0.12);
}
.ar-hud .ms-portrait {
  width: clamp(34px, 4vw, 48px);
  height: clamp(34px, 4vw, 48px);
}
.ar-hud .ms-char-name { font-size: clamp(11px, 1.05vw, 15px); }
.ar-hud .ms-char-lvl {
  margin-top: 3px;
  font-size: clamp(10px, 0.9vw, 12px);
}
.ar-hud .ms-lv-tag { padding: 1px 5px; }
.ar-hud .ms-bars { gap: clamp(2px, 0.35vw, 4px); }
.ar-hud .ms-bar {
  grid-template-columns: clamp(22px, 2.2vw, 30px) minmax(0, 1fr);
  gap: clamp(4px, 0.45vw, 6px);
}
.ar-hud .ms-bar-icon { font-size: clamp(8px, 0.75vw, 10px); }
.ar-hud .ms-bar-track { height: clamp(9px, 1.05vw, 13px); }
.ar-hud .ms-bar-xp .ms-bar-track { height: clamp(6px, 0.8vw, 9px); }
.ar-hud .ms-bar-text,
.ar-hud .ms-bar-xp .ms-bar-text {
  right: 5px;
  font-size: clamp(8px, 0.78vw, 10px);
}
.ar-hud .ms-quickslots,
.ar-hud .ms-itemslots { gap: 3px; }
.ar-hud .ms-quickslots-label,
.ar-hud .ms-itemslots-label {
  display: none;
}
.ar-hud .ms-quickslots-row,
.ar-hud .ms-itemslots-row { gap: clamp(3px, 0.4vw, 5px); }
.ar-hud .ms-skill,
.ar-hud .ms-itemslot {
  width: clamp(32px, 3.55vw, 44px);
  height: clamp(36px, 3.95vw, 48px);
  border-radius: 6px;
}
.ar-hud .ms-skill-icon,
.ar-hud .ms-itemslot-icon {
  inset: 3px 3px 12px;
  font-size: clamp(15px, 1.55vw, 20px);
}
.ar-hud .ms-skill-name { font-size: clamp(5px, 0.55vw, 7px); }
.ar-hud .ms-skill-key,
.ar-hud .ms-itemslot-key {
  min-width: 13px;
  font-size: clamp(7px, 0.65vw, 9px);
  padding: 0 3px;
}
.ar-hud .ms-itemslot-qty { font-size: clamp(7px, 0.7vw, 9px); }
.ar-hud .ms-meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
}
.ar-hud .ms-meta-pill {
  min-height: clamp(19px, 2vw, 24px);
  padding: 3px 5px;
  font-size: clamp(8px, 0.72vw, 10px);
  border-radius: 6px;
}
.ar-hud .ms-meta-pill.ms-coins { grid-column: auto; }
.ar-hud .ms-meta-pill.ms-inv-btn { font-size: clamp(8px, 0.72vw, 10px); }

@media (max-width: 1100px) {
  .ar-hud .ms-command-deck {
    grid-template-columns:
      clamp(118px, 16vw, 150px)
      minmax(180px, 1fr)
      auto
      auto
      clamp(142px, 15vw, 184px);
  }
  .ar-hud .ms-meta {
    grid-column: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ar-hud .ms-skill-name {
    display: none;
  }
  .ar-hud .ms-skill,
  .ar-hud .ms-itemslot {
    width: clamp(29px, 3.6vw, 38px);
    height: clamp(31px, 3.8vw, 40px);
  }
  .ar-hud .ms-meta-pill { min-height: 20px; }
}

@media (max-width: 820px) {
  .ar-hud .ms-command-deck {
    width: calc(100% - 10px);
    grid-template-columns: clamp(82px, 21vw, 124px) minmax(140px, 1fr) auto clamp(84px, 18vw, 118px);
    gap: 4px;
    padding: 5px;
  }
  .ar-hud .ms-itemslots { display: none; }
  .ar-hud .ms-bars,
  .ar-hud .ms-meta {
    grid-column: auto;
  }
  .ar-hud .ms-char-card { grid-template-columns: clamp(30px, 8vw, 40px) minmax(0, 1fr); }
  .ar-hud .ms-portrait {
    width: clamp(30px, 8vw, 40px);
    height: clamp(30px, 8vw, 40px);
  }
  .ar-hud .ms-char-name { font-size: clamp(10px, 2.8vw, 12px); }
  .ar-hud .ms-char-lvl { font-size: 10px; }
  .ar-hud .ms-meta-pill { font-size: 8px; }
}

@media (max-width: 560px) {
  .ar-hud .ms-command-deck {
    grid-template-columns: clamp(70px, 25vw, 96px) minmax(118px, 1fr) clamp(74px, 22vw, 94px);
  }
  .ar-hud .ms-quickslots { display: none; }
  .ar-hud .ms-meta {
    grid-column: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ar-hud .ms-meta-pill {
    min-height: 18px;
    padding: 2px 4px;
  }
  .ar-hud .ms-meta-pill.ms-inv-btn { font-size: 0; }
  .ar-hud .ms-meta-pill b {
    margin-left: 0;
    font-size: 9px;
  }
}

/* ================================================================
   VIEWPORT-FILL GAME WINDOW
   Browser games generally either letterbox intentionally or fill the
   viewport and let the camera/HUD adapt. For this MMO layout, fill wins:
   no purple/blue bars on resize and the HUD scales with the visible game.
   ================================================================ */
#stage {
  place-items: stretch;
  padding: 0;
  background: #000;
}

#frame {
  width: 100vw;
  height: 100vh;
  width: 100dvw;
  height: 100dvh;
  aspect-ratio: auto;
  border-radius: 0;
  box-shadow: none;
}

/* ════════════════════════════════════════════════════════════
   MOBILE LANDSCAPE HUD v2 — built to the approved wireframe.
   Appended last → authoritatively overrides earlier .is-touch rules.
   TL: sprite+HP/MP+PwR · TR: MAP · midR: items · lowerR: skills+ATK+Jump
   · BL: big visible joystick · BC: chat bar.  --sa-*: iOS safe-area (island).
   ════════════════════════════════════════════════════════════ */
:root{
  --sa-left: env(safe-area-inset-left,0px);  --sa-right: env(safe-area-inset-right,0px);
  --sa-top:  env(safe-area-inset-top,0px);   --sa-bottom: env(safe-area-inset-bottom,0px);
}
/* ---- TOP-RIGHT: MAP ---- */
.is-touch .ar-hud .ms-minimap{ top:max(10px,var(--sa-top)); right:max(10px,var(--sa-right)); left:auto; width:208px; }
.is-touch .ar-hud .ms-stage-info{ display:none; }
/* ---- TOP-LEFT: status (sprite + HP/MP + PwR) ---- */
.is-touch .ar-hud .ms-command-deck{
  position:fixed; left:max(10px,var(--sa-left)); top:max(10px,var(--sa-top)); right:auto; bottom:auto; transform:none;
  width:min(44vw,330px); min-height:0; display:flex; flex-direction:column; align-items:stretch; gap:5px; padding:8px;
  -webkit-backdrop-filter:none; backdrop-filter:none;
  background:linear-gradient(180deg, rgba(20,12,40,0.92), rgba(8,4,20,0.92));
}
.is-touch .ar-hud .ms-char-card{ grid-template-columns:46px minmax(0,1fr); padding:5px; }
.is-touch .ar-hud .ms-portrait{ width:44px; height:44px; }
.is-touch .ar-hud .ms-bars{ width:100%; }
.is-touch .ar-hud .ms-quickslots{ display:none; }
.is-touch .ar-hud .ms-meta{ display:flex; flex-wrap:wrap; gap:5px; margin-top:2px; }
.is-touch .ar-hud .ms-meta-pill{ font-size:10px; padding:5px 8px; }
/* ---- MID-RIGHT: item usage row (escapes deck; deck has no backdrop-filter) ---- */
.is-touch .ar-hud .ms-itemslots{ display:block; position:fixed; right:max(10px,var(--sa-right)); top:38%; width:auto; padding:0; background:none; border:0; z-index:7; }
.is-touch .ar-hud .ms-itemslots-label{ font-size:9px; text-align:right; margin:0 0 4px; opacity:.85; }
.is-touch .ar-hud .ms-itemslots-row{ display:flex; gap:8px; justify-content:flex-end; }
/* ---- BOTTOM-LEFT: big VISIBLE joystick ---- */
.is-touch .touch-joy-zone{ position:fixed; left:0; bottom:0; width:46vw; height:64vh; z-index:6; touch-action:none; pointer-events:auto; }
.is-touch .touch-joy{
  position:fixed; left:calc(max(18px,var(--sa-left)) + 18px); bottom:calc(max(16px,var(--sa-bottom)) + 30px);
  width:222px; height:222px; border-radius:50%; transform:none; opacity:1; pointer-events:none; z-index:6;
  border:2px solid rgba(160,107,255,0.5); background:radial-gradient(circle, rgba(40,20,90,0.42), rgba(8,4,22,0.22));
  -webkit-backdrop-filter:blur(2px); backdrop-filter:blur(2px);
  box-shadow:0 0 22px -4px rgba(160,107,255,0.55), inset 0 0 18px rgba(160,107,255,0.18);
}
.is-touch .touch-joy.on{ border-color:rgba(190,150,255,0.9); box-shadow:0 0 32px -2px rgba(160,107,255,0.9), inset 0 0 18px rgba(160,107,255,0.3); }
.is-touch .touch-joy-knob{
  position:absolute; left:50%; top:50%; width:96px; height:96px; border-radius:50%; transform:translate(-50%,-50%);
  background:radial-gradient(circle at 38% 32%, rgba(210,180,255,0.98), rgba(150,100,245,0.92));
  border:2px solid rgba(255,255,255,0.92); box-shadow:0 0 18px rgba(160,107,255,0.9);
}
.is-touch .touch-joy-zone::after{ content:none; }
/* ---- LOWER-RIGHT: skills (small) on top, ATK + Jump (big) bottom ---- */
.is-touch .hud-touch{
  display:flex; flex-direction:column; align-items:flex-end; gap:10px;
  left:auto; right:0; bottom:0; top:auto; flex-wrap:nowrap;
  padding:0 max(12px,var(--sa-right)) max(16px,var(--sa-bottom)) 0;
}
.is-touch .touch-skills{ width:auto; justify-content:flex-end; gap:10px; order:1; }
.is-touch .touch-actions{ gap:12px; order:2; align-items:flex-end; }
.is-touch .touch-actions,.is-touch .touch-skills{ position:relative; z-index:8; pointer-events:none; }
.is-touch .tp-btn{ pointer-events:auto; }
.is-touch .tp-sk{ width:50px; height:50px; font-size:13px; }
.is-touch .tp-use,.is-touch .tp-heavy,.is-touch .tp-dodge{ width:56px; height:56px; }
/* order the bottom action row so the big pair (Jump, ATK) sits adjacent at the far right */
.is-touch .tp-dodge{ order:1; }
.is-touch .tp-heavy{ order:2; }
.is-touch .tp-jump{ width:86px; height:86px; order:3; }
.is-touch .tp-attack{ width:78px; height:78px; order:4; }
/* ---- BOTTOM-CENTER: chat bar (override social.js toggle/panel on touch) ---- */
.is-touch #anima-chat-toggle{
  left:50% !important; right:auto !important; transform:translateX(-50%);
  bottom:max(8px,var(--sa-bottom)) !important; width:min(62vw,640px); text-align:center;
  padding:14px 22px !important; font-size:16px !important;
  background:rgba(14,18,34,0.86); border-color:rgba(120,140,200,0.45);
}
.is-touch #anima-chat-panel{
  left:50% !important; right:auto; transform:translateX(-50%);
  bottom:calc(max(8px,var(--sa-bottom)) + 54px) !important;
  width:min(72vw,660px) !important; height:min(66vh,430px) !important;
}

/* ---- Chat is an in-world overlay ONLY. Outside the gameplay world (login,
   character / ANIMA select, home) the body lacks .in-world, so hide the chat
   button + panel entirely. Without this the floating chat toggle overlaps and
   blocks the ENTER WORLD button on the select screen. !important beats the
   social.js inline/positioned styles + the .is-touch overrides above. ---- */
body:not(.in-world) #anima-chat-toggle,
body:not(.in-world) #anima-chat-panel{ display:none !important; }

/* ════════════════════════════════════════════════════════════
   MOBILE HUD v3 — Felix's detailed spec (appended last = wins).
   2x buttons + reorder, joystick +20px, items above skills, MAP 1.5x
   + corner-safe, status [name+portrait | HP/MP/EXP] + POWER, menu below MAP.
   ════════════════════════════════════════════════════════════ */
/* MAP — 1.5x + cleared from the rounded corner */
.is-touch .ar-hud .ms-minimap{ width:312px; top:max(12px,var(--sa-top)); right:calc(max(12px,var(--sa-right)) + 10px); left:auto; }
.is-touch .ar-hud .ms-minimap canvas{ width:100%; height:118px; }
/* MENU row below the MAP: Item | Skill | CashShop | Setting */
.is-touch .ar-hud .ms-meta{
  position:fixed; top:calc(max(12px,var(--sa-top)) + 158px); right:calc(max(12px,var(--sa-right)) + 10px);
  left:auto; bottom:auto; display:flex; flex-wrap:nowrap; justify-content:flex-end; gap:7px; width:auto; z-index:7;
}
.is-touch .ar-hud .ms-meta .ms-coins{ display:none; }
.is-touch .ar-hud .ms-meta-pill{ font-size:12px; padding:9px 12px; }
/* STATUS card — [name+portrait | HP/MP/EXP bars]; POWER under the name */
.is-touch .ar-hud .ms-command-deck{ display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:9px; width:min(50vw,380px); }
.is-touch .ar-hud .ms-char-card{ display:flex; flex-direction:column-reverse; align-items:center; gap:4px; }
.is-touch .ar-hud .ms-char-info{ text-align:center; }
.is-touch .ar-hud .ms-bars{ width:100%; }
/* ITEM row — just above the skill cluster */
.is-touch .ar-hud .ms-itemslots{ position:fixed; right:max(12px,var(--sa-right)); left:auto; top:auto; bottom:calc(max(16px,var(--sa-bottom)) + 236px); }
/* ITEM buttons 1.5x */
.is-touch .ms-itemslot{ width:74px; height:78px; }
.is-touch .ms-itemslot-icon{ font-size:21px; }
.is-touch .ar-hud .ms-itemslots-row{ gap:10px; }
/* JOYSTICK — nudged ~20px from edge, then +10px right per Felix */
.is-touch .touch-joy{ left:calc(max(18px,var(--sa-left)) + 48px); }
/* BUTTONS — 2x; skills row (A S D F V) over actions (Heavy Dash Atk Jump) */
.is-touch .touch-skills{ gap:12px; } .is-touch .touch-actions{ gap:12px; }
.is-touch .tp-sk{ width:88px; height:88px; font-size:18px; }
.is-touch .tp-heavy,.is-touch .tp-dodge,.is-touch .tp-attack,.is-touch .tp-jump{ width:104px; height:104px; }
.is-touch .tp-heavy{ order:1; } .is-touch .tp-dodge{ order:2; } .is-touch .tp-attack{ order:3; } .is-touch .tp-jump{ order:4; }
/* INTERACT / engagement (E) — above the item-usage bar (right side). NOTE: the right
   column (map+menu+items+engagement+skills+actions) is tight on a 440px-tall screen;
   exact gap may need device tuning. */
.is-touch .tp-use{ position:fixed; right:max(12px,var(--sa-right)); left:auto; bottom:calc(max(16px,var(--sa-bottom)) + 320px); width:66px; height:66px; z-index:8; }
/* placeholder toast */
.hud-notify{ position:fixed; left:50%; top:32%; transform:translate(-50%,-50%) scale(.96); z-index:99;
  background:rgba(10,6,28,0.92); color:#fff; border:1px solid rgba(160,107,255,0.6); border-radius:12px;
  padding:12px 18px; font:700 14px/1 system-ui,sans-serif; opacity:0; pointer-events:none; transition:opacity .18s, transform .18s; }
.hud-notify.show{ opacity:1; transform:translate(-50%,-50%) scale(1); }
