:root {
  --bg: #12062e;
  --surface: #241058;
  --surface-2: #33187a;
  --line: #5a35b5;
  --text: #ffffff;
  --muted: #c9bdf0;
  --pink: #ff5fd8;
  --violet: #8b3dff;
  --gold: #fee440;
  --danger: #f75d5d;
  --info: #4fd1c5;
  --clout: #ff8a3d;
  --aura: #46c8ff;
  --accent: var(--pink);
  --glow: 0 0 16px rgba(170, 80, 255, .55);
  --radius: 18px;
  /* Design standard: every text size, weight, icon size and corner comes from here. */
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;
  --fs-4xl: 3rem;
  --fs-5xl: 4.25rem;
  --fw-regular: 400;
  --fw-medium: 600;
  --fw-bold: 700;
  --fw-heavy: 800;
  --icon-sm: 20px;
  --icon-md: 26px;
  --icon-lg: 32px;
  --icon-xl: 44px;
  --icon-2xl: 52px;
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Khmer", sans-serif;
  --scale: 1;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: calc(16px * var(--scale)); }
body {
  margin: 0;
  background: linear-gradient(rgba(18, 6, 46, .3), rgba(18, 6, 46, .8)), url("/art/backdrops/city.svg") center bottom / cover no-repeat fixed var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
body.dyslexia { font-family: Verdana, Tahoma, var(--font); letter-spacing: .04em; word-spacing: .12em; line-height: 1.7; }
body.reduced-motion *, body.reduced-motion *::before { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition-duration: 0s !important; } }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 20px 16px 100px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
body.no-nav #app { padding-bottom: 28px; }
body.no-nav #nav { display: none; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--fs-2xl); line-height: 1.1; letter-spacing: -.02em; }
h2 { font-size: var(--fs-xl); line-height: 1.2; letter-spacing: -.01em; }
h3 { font-size: var(--fs-md); }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.center { text-align: center; }
.brand { font-weight: var(--fw-heavy); letter-spacing: .14em; font-size: var(--fs-xs); color: var(--pink); text-transform: uppercase; }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
a.card { text-decoration: none; }
a.card:hover { border-color: var(--accent); }
.card.hero { border-color: var(--accent); background: linear-gradient(160deg, var(--surface-2), var(--surface)); }

button, .btn {
  font: inherit;
  font-weight: var(--fw-bold);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  min-height: 48px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
  width: 100%;
  transition: transform .08s ease, border-color .12s ease;
}
button:active, .btn:active { transform: scale(.98); }
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--pink); border-color: var(--pink); color: #1c0612; }
.ghost { background: transparent; }
.linkish { background: none; border: 0; min-height: 36px; padding: 6px; color: var(--muted); font-weight: var(--fw-medium); text-decoration: underline; width: auto; }
.danger { color: #ff9db0; border-color: #6d2a3a; }
.option { text-align: left; font-weight: var(--fw-medium); padding: 16px; }
.option:hover { border-color: var(--pink); }
.option.selected { border-color: var(--pink); background: #3b1c3c; }
:focus-visible { outline: 3px solid var(--aura); outline-offset: 2px; }

input[type="text"] {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 13px;
  width: 100%;
}
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: var(--fw-medium); }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 40px; }
.setting select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px; }
.setting input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--pink); }
.error { color: #ff9db0; font-size: var(--fs-sm); }

/* Progress and timers */
.progress { display: flex; gap: 6px; }
.progress span { flex: 1; height: 5px; background: var(--surface-2); border-radius: var(--r-xs); }
.progress span.done { background: var(--pink); }
.timer { height: 6px; background: var(--surface-2); border-radius: var(--r-xs); overflow: hidden; }
.timer div { height: 100%; width: 100%; background: var(--clout); transform-origin: left; }

/* Stats. Icons and labels carry the meaning, so nothing relies on color alone. */
.stat { display: grid; grid-template-columns: 76px 1fr 30px; gap: 8px; align-items: center; font-weight: var(--fw-bold); font-size: var(--fs-sm); }
.stat .track { height: 10px; background: var(--surface-2); border-radius: var(--r-xs); overflow: hidden; }
.stat .fill { height: 100%; border-radius: var(--r-xs); transition: width .5s ease; }
.stat.clout .fill { background: var(--clout); }
.stat.aura .fill { background: var(--aura); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--surface-2); border-radius: var(--r-pill); padding: 4px 10px; font-size: var(--fs-sm); font-weight: var(--fw-bold); }
.pop { animation: pop .28s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* Story */
.scene { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; cursor: pointer; min-height: 45dvh; width: 100%; background: none; border: 0; padding: 0; font-weight: var(--fw-regular); text-align: left; }
.scene:active { transform: none; }
.speaker { color: var(--accent); font-weight: var(--fw-heavy); font-size: var(--fs-sm); letter-spacing: .06em; text-transform: uppercase; }
.speaker-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.portrait { width: 4.5rem; height: 4.5rem; flex: none; border-radius: var(--r-lg); }
.line { font-size: var(--fs-xl); line-height: 1.4; }
.tap-hint { color: var(--muted); font-size: var(--fs-sm); }

/* Persona card */
.persona {
  border: 2px solid var(--accent);
  border-radius: var(--r-xl);
  padding: 24px 20px;
  background: linear-gradient(165deg, color-mix(in srgb, var(--accent) 24%, var(--surface)), var(--surface) 65%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.persona h1 { color: var(--accent); font-size: var(--fs-3xl); }
.emblem { display: block; flex: none; width: 6rem; height: 6rem; }
.masked { filter: blur(7px); user-select: none; }

.score { font-size: var(--fs-5xl); font-weight: var(--fw-heavy); line-height: 1; color: var(--pink); letter-spacing: -.03em; }
.compare { display: grid; grid-template-columns: 1fr 26px; gap: 4px 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.tick { font-weight: var(--fw-heavy); text-align: right; }

/* Receipt */
.receipt { border: 1px dashed var(--muted); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.receipt .final { font-size: var(--fs-xl); font-weight: var(--fw-heavy); color: var(--pink); text-transform: uppercase; }
.member { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 36px; }
.member .linkish { font-size: var(--fs-sm); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; background: var(--surface); font-weight: var(--fw-bold); font-size: var(--fs-sm); }
.tile.locked { color: var(--muted); border-style: dashed; font-weight: var(--fw-medium); display: flex; align-items: center; justify-content: center; min-height: 7.75rem; }
.tile.owned { border-color: var(--accent); color: var(--text); } /* the name stays readable whatever the Persona colour */
.tile .emblem { width: 3.25rem; height: 3.25rem; margin-bottom: 8px; }

#nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center;
  background: rgba(11, 10, 20, .94);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#nav a { flex: 1; min-width: 0; max-width: 80px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; text-decoration: none; color: var(--muted); font-size: var(--fs-xs); font-weight: var(--fw-bold); }
#nav a[aria-current="page"] { color: var(--pink); }

#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-weight: var(--fw-bold);
  padding: 10px 16px; border-radius: var(--r-pill); max-width: 90vw; width: max-content;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
#toast.show { opacity: 1; }

.mini { width: auto; flex: 1; min-height: 44px; padding: 8px 14px; }
.mini.wide { flex: none; min-width: 84px; }
.member.card { flex-direction: row; }
select.report { font: inherit; font-size: var(--fs-sm); color: var(--muted); background: transparent; border: 0; text-decoration: underline; padding: 6px; max-width: 84px; }
select.report option { color: var(--text); background: var(--surface); }
.orbit { background: var(--surface); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 10px 14px; font-size: var(--fs-md); }
.hidden-route { border-color: var(--aura); }
.hidden-route::before { content: '🔓 '; }
.stat-track { height: 8px; background: var(--surface-2); border-radius: var(--r-xs); overflow: hidden; }
.stat-fill { height: 100%; background: var(--pink); border-radius: var(--r-xs); transition: width .5s ease; }
button.tile { font-weight: var(--fw-bold); min-height: 48px; }

.flicker { animation: flicker 2.8s steps(1) infinite; }
@keyframes flicker { 0%, 91%, 95%, 100% { opacity: 1; } 92%, 94% { opacity: .55; } 93% { opacity: .85; } }

.bubble { align-self: flex-start; background: var(--surface-2); border-radius: var(--r-md); padding: 8px 12px; max-width: 85%; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; background: #3b1c3c; }
.chat-list { max-height: 320px; overflow-y: auto; }
form.row input { flex: 1; min-width: 0; }

/* Avatar: every layer has the same canvas, so stacking them lines up exactly. */
.avatar { position: relative; flex: none; width: min(60%, 210px); aspect-ratio: 3 / 4; margin: 0 auto; }
.avatar::before { content: ''; position: absolute; left: 12%; right: 12%; bottom: 0; height: 7%; border-radius: 50%; background: color-mix(in srgb, var(--accent) 28%, transparent); }
.avatar img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.closet-group { display: flex; flex-direction: column; gap: 10px; }

/* Duo frame: only drawn when both friends wear the same one. */
.persona.duo-frame { outline: 2px solid var(--accent); outline-offset: 4px; }
.cosmetic-tag { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; max-width: 100%; border: 1px solid var(--tag); color: var(--tag); border-radius: var(--r-pill); padding: 2px 10px; font-size: var(--fs-xs); font-weight: var(--fw-heavy); overflow-wrap: anywhere; }

body.has-backdrop::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(rgba(11, 10, 20, .35), rgba(11, 10, 20, .8)), var(--backdrop) center / cover no-repeat;
}

/* Animated art. The global reduced-motion rules at the top of this file turn all of it off. */
.scene.pop img { animation: portrait-in .35s ease both, portrait-idle 5s ease-in-out .35s infinite; }
.persona.pop img { animation: emblem-reveal .7s cubic-bezier(.2, 1.5, .4, 1) both, emblem-glow 3.5s ease-in-out .7s infinite; }
body.has-backdrop::before { animation: backdrop-drift 40s ease-in-out infinite alternate; }
@keyframes portrait-in { from { opacity: 0; transform: translateY(10px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes portrait-idle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes emblem-reveal { from { opacity: 0; transform: scale(.4) rotate(-14deg); } to { opacity: 1; transform: none; } }
@keyframes emblem-glow { 0%, 100% { filter: drop-shadow(0 0 2px var(--accent)); } 50% { filter: drop-shadow(0 0 12px var(--accent)); } }
@keyframes backdrop-drift { from { background-position: center, 42% center; } to { background-position: center, 58% center; } }

body.reduced-motion.has-backdrop::before { animation: none; }
@media (prefers-reduced-motion: reduce) { body.has-backdrop::before { animation: none; } }

/* Mobile usability: tab labels stay readable, and everything tappable is at least 44px. */
#nav a { font-size: var(--fs-xs); max-width: 96px; min-height: 56px; justify-content: center; }
#nav a span:first-child { font-size: var(--fs-lg); line-height: 1.2; }
a.small.muted { display: inline-flex; align-items: center; align-self: flex-start; min-height: 44px; min-width: 44px; padding-right: 12px; }
.linkish { min-height: 44px; min-width: 44px; }
.setting select, select.report { min-height: 44px; }
.card > a:not(.btn) { display: block; min-height: 44px; }
.big-link { flex-direction: row; align-items: center; min-height: 64px; font-weight: var(--fw-bold); }
.big-link span { font-size: var(--fs-xl); }
.lang-bar { display: flex; gap: 6px; }
.lang { width: auto; min-width: 72px; min-height: 44px; padding: 6px 12px; font-weight: var(--fw-medium); }
.lang.selected { border-color: var(--pink); background: #3b1c3c; }

/* Khmer and Thai stack marks above and below letters, so they need more room and no tracking. */
html:lang(km) { font-size: calc(17px * var(--scale)); }
:lang(km) body, :lang(th) body { line-height: 1.7; }
:lang(km) .speaker, :lang(km) .brand, :lang(th) .speaker, :lang(th) .brand { letter-spacing: 0; text-transform: none; }
:lang(km) h1, :lang(th) h1, :lang(km) h2, :lang(th) h2 { line-height: 1.35; }
label.setting { min-height: 48px; }
.linkish { max-width: 100%; overflow-wrap: anywhere; }

/* MIRRIX look: neon violet glass, pill buttons, italic display headlines. */
.logo { font-style: italic; font-weight: var(--fw-heavy); font-size: var(--fs-2xl); letter-spacing: -.01em; line-height: 1; color: #fff; text-shadow: 0 0 14px var(--violet), 2px 2px 0 #6d28d9; }
.logo-big { font-size: var(--fs-5xl); }
.display { font-style: italic; font-weight: var(--fw-heavy); }
.gold { color: var(--gold); }
.prove { font-size: var(--fs-2xl); transform: rotate(-3deg); }
:lang(km) .display, :lang(km) .logo, :lang(th) .display { font-style: normal; }

.splash { min-height: calc(100dvh - 48px); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding-top: 14dvh; }
.splash-crown { width: 72px; height: auto; }
.splash p.display { font-size: var(--fs-xl); transform: rotate(-3deg); }
.splash-bar { width: 70%; height: 8px; border-radius: var(--r-xs); background: rgba(255, 255, 255, .2); overflow: hidden; margin-bottom: 16px; }
.splash-bar div { height: 100%; width: 40%; border-radius: var(--r-xs); background: #fff; animation: splash 1.2s ease-in-out infinite alternate; }
@keyframes splash { from { transform: translateX(-20%); } to { transform: translateX(170%); } }

.card { background: rgba(36, 16, 88, .86); border-color: rgba(150, 100, 255, .5); }
.card.hero { background: linear-gradient(135deg, rgba(90, 40, 200, .9), rgba(36, 16, 88, .92)); border-color: #a970ff; box-shadow: var(--glow); }
button, .btn { border-radius: var(--r-pill); background: rgba(51, 24, 122, .9); border-color: #8a5cf0; }
.primary { background: linear-gradient(95deg, #6d28d9, #a21caf); border: 2px solid #c79bff; color: #fff; box-shadow: var(--glow); }
.ghost { background: transparent; border-color: #b794ff; }
.danger { border-color: #a0405a; }
.linkish, .linkish:hover { border-radius: var(--r-sm); }

.option { display: flex; align-items: center; gap: 12px; background: #efe6ff; color: #1c0f3f; border: 0; border-radius: var(--r-lg); padding: 10px 16px 10px 10px; }
.option:hover { outline: 2px solid var(--pink); }
.option.selected { background: #ffd9f6; outline: 3px solid var(--pink); }
.option:not(:has(.letter)) { padding-left: 18px; }
.letter { flex: none; width: 32px; height: 32px; border-radius: 50%; background: #1c0f3f; color: #fff; display: grid; place-items: center; font-weight: var(--fw-heavy); font-size: var(--fs-sm); }
.question-bubble { background: rgba(245, 238, 255, .96); color: #1c0f3f; border-radius: var(--r-lg); padding: 16px 18px; font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.question-bubble h2 { font-size: var(--fs-lg); color: inherit; }
.question-bubble .speaker { color: #7a1fa8; }
.question { font-size: var(--fs-lg); }

.screen-title { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: var(--fs-lg); }
.back { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; margin-left: -10px; font-size: var(--fs-2xl); line-height: 1; text-decoration: none; color: #fff; }
.icon-btn { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(51, 24, 122, .85); text-decoration: none; }
.dot { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--pink); }
.stack.tight { gap: 2px; min-width: 0; }

.ring { flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; overflow: hidden; border: 2px solid #d9b8ff; box-shadow: var(--glow); background: var(--surface-2); }
.ring .avatar { width: 100%; margin: 28% 0 0; }
.ring .avatar::before { display: none; }
.ring-big { width: 112px; height: 112px; }
.initial { background: hsl(var(--hue) 65% 42%); color: #fff; font-weight: var(--fw-heavy); font-size: var(--fs-xl); }
.level { align-self: flex-start; background: var(--violet); color: #fff; border-radius: var(--r-sm); padding: 1px 8px; font-size: var(--fs-xs); font-weight: var(--fw-heavy); }

.player-strip { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--r-lg); background: rgba(36, 16, 88, .86); text-decoration: none; }
.drop-hero { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 18px; border-radius: var(--r-lg); text-decoration: none; overflow: hidden; border: 2px solid #a970ff; box-shadow: var(--glow); background: linear-gradient(rgba(36, 16, 88, .35), rgba(36, 16, 88, .85)), url("/art/backdrops/city.svg") center / cover; }
.drop-label { font-size: var(--fs-md); }
.drop-title { font-size: var(--fs-xl); font-weight: var(--fw-heavy); line-height: 1.25; }
.ribbon { position: absolute; top: 0; right: 0; background: var(--pink); color: #2a0620; font-weight: var(--fw-heavy); font-size: var(--fs-xs); padding: 4px 14px; border-bottom-left-radius: 12px; }
.pill { display: inline-flex; align-items: center; min-height: 44px; gap: 6px; padding: 8px 18px; border-radius: var(--r-pill); background: linear-gradient(95deg, #6d28d9, #a21caf); border: 1px solid #c79bff; font-weight: var(--fw-heavy); }
.small-pill { min-height: 36px; padding: 4px 12px; font-size: var(--fs-sm); flex: none; }

.mode-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 96px; padding: 10px 6px; border-radius: var(--r-lg); text-align: center; text-decoration: none; font-weight: var(--fw-heavy); font-size: var(--fs-sm); line-height: 1.2; border: 1px solid rgba(255, 255, 255, .28); overflow-wrap: anywhere; }
.mode-tile.tone-0 { background: linear-gradient(160deg, #b5179e, #7209b7); }
.mode-tile.tone-1 { background: linear-gradient(160deg, #0f6f96, #3a2a8a); }
.mode-tile.tone-2 { background: linear-gradient(160deg, #6d28d9, #3b1a9c); }
.mode-icon { font-size: var(--fs-2xl); line-height: 1.1; }

.persona-strip { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-lg); background: rgba(36, 16, 88, .86); border: 1px solid rgba(150, 100, 255, .5); text-decoration: none; }
.persona-thumb { flex: none; display: grid; place-items: center; width: 68px; height: 68px; border-radius: var(--r-md); border: 2px solid var(--accent); background: var(--surface-2); }
.persona-thumb .emblem { width: 52px; height: 52px; }
.persona-name { font-size: var(--fs-md); }
.persona-strip > .stack { flex: 1; }
.see-all { display: inline-flex; align-items: center; min-height: 44px; color: var(--aura); text-decoration: none; font-weight: var(--fw-bold); font-size: var(--fs-sm); }
.friend-row { display: flex; gap: 10px; overflow-x: auto; }
.friend-chip { text-decoration: none; flex: none; }

.persona { border: 0; background: transparent; padding: 8px 0; align-items: stretch; }
.persona h1 { color: #fff; font-size: var(--fs-3xl); text-transform: uppercase; text-shadow: 0 0 14px var(--accent); }
.persona-kicker { color: #e8d4ff; font-size: var(--fs-lg); }
.crown { align-self: center; width: 64px; height: 48px; margin-bottom: -12px; position: relative; filter: drop-shadow(0 0 8px var(--gold)); }
.persona-frame { align-self: center; display: grid; place-items: center; width: min(68%, 240px); aspect-ratio: 1; border-radius: var(--r-xl); border: 3px solid var(--accent); box-shadow: 0 0 24px var(--accent); background: radial-gradient(circle, color-mix(in srgb, var(--accent) 35%, var(--surface)), var(--surface)); }
.persona-frame .emblem { width: 72%; height: auto; aspect-ratio: 1; }
.stat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-tile { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-md); background: rgba(36, 16, 88, .86); font-size: var(--fs-lg); }
.stat-icon { font-size: var(--fs-2xl); line-height: 1; }

.meter { display: grid; grid-template-columns: minmax(0, 7.5rem) 1fr 2.75rem; align-items: center; gap: 10px; font-size: var(--fs-sm); min-height: 28px; }
.meter > strong { text-align: right; }
.meter-track { height: 10px; border-radius: var(--r-xs); background: rgba(255, 255, 255, .14); overflow: hidden; }
.meter-fill { height: 100%; border-radius: var(--r-xs); transition: width .5s ease; }
.tone-0 .meter-fill { background: linear-gradient(90deg, #2d7bff, #46c8ff); }
.tone-1 .meter-fill { background: linear-gradient(90deg, #d916c8, #ff5fd8); }
.tone-2 .meter-fill { background: linear-gradient(90deg, #6d3dff, #b78bff); }

.duel { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; text-align: center; }
.duel-side { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.duel .ring { width: 104px; height: 104px; }
.duel .initial { font-size: var(--fs-3xl); }
.duel-mid.heart { font-size: var(--fs-3xl); color: var(--pink); text-shadow: 0 0 14px var(--pink); }
.duel-mid.vs { font-size: var(--fs-4xl); font-weight: var(--fw-heavy); font-style: italic; color: #fff; text-shadow: 0 0 12px var(--aura), 3px 3px 0 #b5179e; }
.match-level { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--r-lg); background: linear-gradient(95deg, rgba(160, 30, 170, .55), rgba(60, 25, 150, .85)); border: 1px solid #a970ff; }
.heart-big { font-size: var(--fs-3xl); line-height: 1; }
.match-level .display { font-size: var(--fs-xl); }
.friend-card, .entry { flex-direction: row; align-items: center; gap: 12px; }
.entry-icon { flex: none; font-size: var(--fs-2xl); width: 2.25rem; text-align: center; }
.create-action { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 60px; font-size: var(--fs-md); }

.profile-head { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: -40px; }
.profile-head .level { align-self: center; }
.banner { padding: 12px; border-radius: var(--r-pill); text-align: center; font-weight: var(--fw-heavy); background: linear-gradient(95deg, #6d28d9, #a21caf); box-shadow: var(--glow); }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.profile-stat { display: flex; flex-direction: column; }
.tabs { display: flex; gap: 8px; }
.tab { flex: 1; min-width: 0; min-height: 44px; padding: 6px 8px; font-size: var(--fs-sm); font-weight: var(--fw-bold); background: rgba(36, 16, 88, .86); border-color: rgba(150, 100, 255, .5); }
.tab.selected { background: #efe6ff; color: #1c0f3f; }
.persona-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.persona-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: var(--r-md); border: 2px solid var(--accent); background: rgba(36, 16, 88, .86); text-decoration: none; text-align: center; font-weight: var(--fw-heavy); font-size: var(--fs-sm); text-transform: uppercase; overflow-wrap: anywhere; }
.persona-tile .emblem { width: 3.75rem; height: 3.75rem; }
.reward { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-lg); background: linear-gradient(95deg, rgba(109, 40, 217, .9), rgba(60, 25, 150, .9)); border: 1px solid #a970ff; }
.reward-icon { font-size: var(--fs-3xl); line-height: 1; }

.episode-bar { height: 6px; border-radius: var(--r-xs); background: rgba(255, 255, 255, .18); overflow: hidden; }
.episode-bar div { height: 100%; border-radius: var(--r-xs); background: linear-gradient(90deg, #a21caf, #ff5fd8); }
.portrait { width: min(62vw, 15rem); height: auto; aspect-ratio: 1; border-radius: var(--r-xl); box-shadow: 0 0 22px rgba(170, 80, 255, .7); }
.speaker-row { flex-direction: column; align-items: flex-start; }
.line { background: rgba(36, 16, 88, .9); border-radius: var(--r-lg); padding: 14px 16px; }
.speaker { color: #f0a8ff; }

/* The tab bar, with the raised + in the middle. */
#nav { background: rgba(18, 6, 46, .96); border-top-color: rgba(150, 100, 255, .4); }
#nav .tab-icon { display: block; height: 24px; }
#nav a[aria-current="page"] { color: #f0a8ff; }
#nav a.fab { flex: none; width: 60px; height: 60px; min-height: 60px; margin: -18px 6px 4px; border-radius: 50%; color: #fff; background: linear-gradient(135deg, #8b3dff, #d916c8); border: 3px solid #e3c7ff; box-shadow: var(--glow); }
#toast { bottom: 96px; }

.group-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.group-tile { display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 10px; border-radius: var(--r-md); background: rgba(36, 16, 88, .86); border: 1px solid rgba(150, 100, 255, .5); text-decoration: none; overflow-wrap: anywhere; }
.rank-row { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 8px 12px; border-radius: var(--r-md); background: rgba(36, 16, 88, .86); }
.rank-row.me { outline: 2px solid var(--pink); }
.rank-row .ring { width: 44px; height: 44px; font-size: var(--fs-lg); }
.rank-number { width: 1.75rem; text-align: center; flex: none; }
.rank-name { flex: 1; overflow-wrap: anywhere; }
.quick-replies { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-replies .mini { flex: 1 1 40%; }

/* Form states and switches */
input[type="text"] { background: rgba(18, 6, 46, .85); border-color: var(--line); }
input[type="text"]:focus { outline: none; border-color: #c79bff; box-shadow: var(--glow); }
input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 10px rgba(247, 93, 93, .6); }
.error { color: #ffb0b0; }
.setting input[type="checkbox"] { appearance: none; width: 48px; height: 28px; flex: none; margin: 0; border-radius: var(--r-md); background: rgba(255, 255, 255, .22); position: relative; cursor: pointer; transition: background .15s ease; }
.setting input[type="checkbox"]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s ease; }
.setting input[type="checkbox"]:checked { background: linear-gradient(95deg, #6d28d9, #d916c8); }
.setting input[type="checkbox"]:checked::after { transform: translateX(20px); }
.setting select { background: rgba(18, 6, 46, .85); }

/* Friend comparison wheel */
.wheel { position: relative; width: min(100%, 360px); aspect-ratio: 1; margin: 0 auto; border-radius: 50%; border: 2px solid rgba(170, 110, 255, .6); box-shadow: var(--glow), inset 0 0 40px rgba(139, 61, 255, .35); background: radial-gradient(circle, rgba(90, 40, 200, .55), rgba(36, 16, 88, .75)); }
.wheel-centre { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.wheel-centre .ring { width: 84px; height: 84px; }
.wheel-friend { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; min-width: 48px; min-height: 48px; text-decoration: none; }
.wheel-friend .ring { width: 48px; height: 48px; font-size: var(--fs-lg); }
.wheel-score { font-size: var(--fs-xs); font-weight: var(--fw-heavy); }

/* The 7-day reward. The reveal is the same short animation every time, never a random wait. */
.reward-week { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: var(--r-lg); background: linear-gradient(95deg, rgba(109, 40, 217, .9), rgba(60, 25, 150, .9)); border: 1px solid #a970ff; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.week-day { display: grid; place-items: center; aspect-ratio: 1; border-radius: var(--r-sm); background: rgba(18, 6, 46, .6); font-weight: var(--fw-heavy); font-size: var(--fs-sm); }
.week-day.done { background: var(--gold); color: #2a1a00; }

/* Neon icon set (js/icons.js). Sized in em, so an icon follows the text around it. */
.ni { display: inline-block; flex: none; width: 1.2em; height: 1.2em; vertical-align: -.24em; }
.ni svg { display: block; width: 100%; height: 100%; }
.ni-flame { color: #ff8a3d; }
.ni-drop { color: #3dd6ff; }
.ni-spark, .ni-trophy, .ni-medal { color: var(--gold, #ffd34d); }
.ni-heart { color: var(--pink, #ff5fa2); }
.ni-warning { color: #ffb020; }
button.primary .ni, .btn.primary .ni, .pill .ni, #nav .ni { color: inherit; }
.mode-icon .ni, .reward-icon .ni, .stat-icon .ni, .entry-icon .ni, .heart-big .ni, .duel-mid .ni, .screen-title > .ni { filter: drop-shadow(0 0 6px currentColor); }
#nav .tab-icon .ni { display: block; width: var(--icon-md); height: var(--icon-md); }
.place-2 .ni { color: #d5d9e6; }
.place-3 .ni { color: #d98a4f; }

/* ---- Redesign to match the mock-ups (painted art from js art helpers, SVG fallback) ---- */
.persona-frame.painted { width: min(78%, 280px); aspect-ratio: 3 / 4; padding: 0; overflow: hidden; }
.persona-art { display: block; width: 100%; height: 100%; object-fit: cover; }
.persona-thumb .persona-art, .persona-tile .persona-art { border-radius: var(--r-sm); }
.persona-tile .persona-art { width: 100%; aspect-ratio: 3 / 4; height: auto; }
.tile .persona-art { width: 100%; aspect-ratio: 3 / 4; height: auto; border-radius: var(--r-sm); margin-bottom: 8px; }

/* Story: what you chose */
.choice-result { align-items: center; text-align: center; gap: 14px; }
.chose-title { font-size: var(--fs-2xl); color: #fff; text-shadow: 0 0 14px var(--pink); }
.big-letter { display: grid; place-items: center; width: 104px; height: 104px; font-size: var(--fs-4xl); font-weight: var(--fw-heavy); color: #fff;
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); background: linear-gradient(160deg, #a855f7, #5b21b6); box-shadow: var(--glow); }
.big-letter .ni { width: .8em; height: .8em; }
.deltas { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 320px; }
.delta { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 14px; border-radius: var(--r-md); font-size: var(--fs-lg); font-weight: var(--fw-heavy);
  background: rgba(36, 16, 88, .86); border: 1px solid rgba(150, 100, 255, .5); }
.bubble-row { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.bubble { position: relative; max-width: 340px; padding: 12px 16px; border-radius: 18px 18px 18px 4px; background: #f4eefc; color: #1d1033; font-weight: var(--fw-medium); text-align: left; }
.continue-pill { margin-top: 6px; padding: 12px 30px; font-size: var(--fs-md); }
.scene-hero { display: block; align-self: center; width: min(62%, 240px); aspect-ratio: 1; object-fit: cover; border-radius: var(--r-xl); border: 2px solid rgba(217, 184, 255, .7); box-shadow: var(--glow); }

/* Friend prediction result */
.reveal-title { font-size: var(--fs-2xl); color: #fff; text-shadow: 0 0 14px var(--pink); margin: 0; }
.reveal-avatar { position: relative; display: inline-grid; margin: 8px auto; }
.reveal-avatar .ring { width: 96px; height: 96px; font-size: var(--fs-3xl); }
.reveal-avatar.right .ring { border-color: #7dff9b; box-shadow: 0 0 20px rgba(125, 255, 155, .6); }
.check-badge { position: absolute; right: -4px; bottom: -4px; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #22c55e; color: #fff; }

/* Battle result */
.battle-banner { display: flex; align-items: center; justify-content: center; gap: 10px; }
.battle-banner .display { font-size: var(--fs-3xl); transform: rotate(-4deg); color: var(--gold); text-shadow: 0 0 16px rgba(254, 228, 64, .6); }
.battle-banner .ni { width: 2.4rem; height: 2.4rem; }
.battle-banner.lose .display, .battle-banner.draw .display { color: #fff; text-shadow: 0 0 14px var(--pink); }

/* Group vote members */
.avatar-row { display: flex; align-items: center; }
.avatar-row .ring { width: 40px; height: 40px; margin-right: -8px; font-size: var(--fs-md); }
.avatar-row .more { background: var(--surface-2); color: var(--text); font-size: var(--fs-sm); }

/* Shop grid */
.shop-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.shop-item { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 10px; border-radius: var(--r-md); text-align: center;
  background: rgba(36, 16, 88, .86); border: 1px solid rgba(150, 100, 255, .5); }
.shop-item.worn { border-color: var(--item, var(--pink)); box-shadow: 0 0 14px var(--item, var(--pink)); }
.shop-art { display: grid; place-items: center; width: 88px; height: 88px; border-radius: var(--r-md); background: rgba(18, 6, 46, .7); color: var(--item, #d9b8ff); }
.shop-art .ni { width: var(--icon-xl); height: var(--icon-xl); filter: drop-shadow(0 0 8px currentColor); }
.item-art { width: 100%; height: 100%; object-fit: cover; border-radius: var(--r-md); }
.shop-name { font-weight: var(--fw-bold); font-size: var(--fs-sm); min-height: 2.4em; display: grid; place-items: center; }
.shop-item button, .shop-item .muted { width: 100%; }

/* Rewards */
.task-row { display: grid; grid-template-columns: 40px 1fr auto auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-md);
  background: rgba(36, 16, 88, .86); border: 1px solid rgba(150, 100, 255, .5); }
.task-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-sm); background: rgba(168, 85, 247, .25); color: #e9d5ff; }
.task-label { font-weight: var(--fw-bold); }
.task-done { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #22c55e; color: #fff; }
.task-row .mini { min-width: 64px; }

/* Events and Season complete */
.event-card { position: relative; overflow: hidden; }
.event-art, .season-art, .drop-art { display: block; width: calc(100% + 36px); margin: -18px -18px 4px; aspect-ratio: 16 / 9; object-fit: cover; }
.countdown { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border-radius: var(--r-sm); background: rgba(18, 6, 46, .8); border: 1px solid rgba(150, 100, 255, .5); }
.countdown strong { font-size: var(--fs-lg); letter-spacing: .04em; }
.season-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.season-hero .season-art { width: 100%; margin: 0 0 6px; border-radius: var(--r-lg); }
.season-hero h1 { font-size: var(--fs-3xl); color: var(--gold); text-shadow: 0 0 16px rgba(254, 228, 64, .5); margin: 0; }
.stat-trio { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-trio > div { display: flex; flex-direction: column; gap: 4px; padding: 10px; border-radius: var(--r-md); background: rgba(36, 16, 88, .86); border: 1px solid rgba(150, 100, 255, .5); text-align: center; }
.stat-trio strong { font-size: var(--fs-md); color: var(--gold); overflow-wrap: anywhere; }
.drop-hero .drop-art { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: .45; z-index: -1; }
.drop-hero { isolation: isolate; }

/* Settings head */
.settings-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); text-decoration: none; color: var(--text);
  background: rgba(36, 16, 88, .86); border: 1px solid rgba(150, 100, 255, .5); }
.settings-head > span[aria-hidden] { font-size: var(--fs-2xl); color: var(--muted); }

/* Break reminder, gifts, wishlist */
.nudge { position: fixed; left: 16px; right: 16px; top: calc(12px + env(safe-area-inset-top)); z-index: 30; display: flex; align-items: center; gap: 12px;
  max-width: 480px; margin: 0 auto; padding: 12px 14px; border-radius: var(--r-md); background: #2a1170; border: 1px solid #d9b8ff; box-shadow: var(--glow); }
.nudge p { flex: 1; margin: 0; }
.gift-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; text-decoration: none; color: var(--text); }
.wish.on { color: var(--pink); border-color: var(--pink); }
.row.wrap { flex-wrap: wrap; }
textarea { font: inherit; color: var(--text); background: rgba(18, 6, 46, .85); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; width: 100%; resize: vertical; }

/* Admin console (public/admin.html) */
body.admin main { display: flex; flex-direction: column; gap: 14px; max-width: 860px; margin: 0 auto; padding: 16px; }
.admin blockquote { margin: 0; padding: 10px 12px; border-left: 3px solid var(--pink); background: rgba(18, 6, 46, .7); border-radius: var(--r-sm); white-space: pre-wrap; }
.admin input[type="password"], .admin input[type="text"] { width: 100%; }
.admin .chip.on { background: #166534; }
.admin .chip.off { background: #991b1b; }
.admin-status { min-height: 1.4em; color: var(--gold); }
.admin-table { overflow-x: auto; }
.admin-table table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.admin-table th, .admin-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 10px; }
.admin-dl dd { margin: 0; font-weight: var(--fw-bold); }
.admin pre { white-space: pre-wrap; font-size: var(--fs-sm); }

/* Painted scenes behind a whole screen, or behind a card */
.scene-backdrop { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; object-fit: cover; opacity: .4; pointer-events: none;
  -webkit-mask-image: linear-gradient(#000 40%, transparent); mask-image: linear-gradient(#000 40%, transparent); }
.story-card { position: relative; overflow: hidden; isolation: isolate; }
.story-card .card-art { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; object-fit: cover; object-position: center 30%; opacity: .45; }

/* Stronger card art, with a fade behind the text so it stays readable */
.drop-hero .drop-art, .story-card .card-art { opacity: .85; }
.drop-hero::after, .story-card::after { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(90deg, rgba(36, 12, 90, .95) 0%, rgba(36, 12, 90, .75) 45%, rgba(36, 12, 90, .1) 100%); }
.story-card .card-art { object-position: center 72%; }
.scene-backdrop { opacity: .55; }

/* 3D avatars */
.ring.photo { padding: 0; background: #1d1033; }
.ring.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.avatar-pick { padding: 0; aspect-ratio: 1; border-radius: 50%; overflow: hidden; border: 3px solid transparent; background: #1d1033; min-height: 0; }
.avatar-pick img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar-pick.selected, .avatar-pick:focus-visible { border-color: var(--pink); box-shadow: 0 0 18px var(--pink); }
.btn.selected { border-color: var(--pink); }

/* Friends' polls */
.poll-card { gap: 10px; }
.poll-card .ring { width: 44px; height: 44px; }
.poll-meta { align-items: center; gap: 12px; }
.heart-btn.on { color: var(--pink); border-color: var(--pink); }

/* Hidden means hidden, even on flex and grid containers. */
[hidden] { display: none !important; }

/* Co-op Cases */
.clue { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--r-sm); background: rgba(18, 6, 46, .7); border: 1px solid rgba(150, 100, 255, .4); }
.clue p { margin: 0; }
.clue .mini, .clue .chip { align-self: flex-start; }

.case-card { position: relative; overflow: hidden; }
.case-card .ribbon + h2 { margin-top: 14px; }

.group-streak { flex-direction: row; align-items: center; gap: 12px; }

/* One per visit (main.js); lays out as if its children were #app's own. */
.screen { display: contents; }
#app > .splash ~ .screen:empty { display: none; }

/* V2.4: daily time limit, Bedtime mode, status banner, hints */
.limit-screen { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px; background: rgba(10, 3, 28, .94); }
.limit-screen .card { max-width: 420px; width: 100%; }
.limit-screen svg { width: 40px; height: 40px; margin: 0 auto; }
body.bedtime::after { content: ''; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 18, .22); pointer-events: none; }
.status-banner { position: sticky; top: 0; z-index: 31; display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: #5a2a00; color: #ffe7c2; font-size: var(--fs-sm); }
.status-banner svg { width: 18px; height: 18px; flex: none; }
.hint p { margin: 0; }

/* Screen titles get focus for screen readers; they are not buttons, so no focus box. */
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }

/* Vibe Check */
.vibe-title { margin: 4px 0 0; }
.vibe-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.vibe-pick { display: flex; flex-direction: column; gap: 0; padding: 0; overflow: hidden; border-radius: var(--r-lg); border: 2px solid var(--line); background: rgba(18, 6, 46, .8); color: var(--text); }
.vibe-pick img, .vibe-pick canvas, .vibe-pick svg { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; display: block; }
.vibe-pick .vibe-name { padding: 8px 6px 10px; font-weight: var(--fw-bold); }
.vibe-pick.selected { border-color: var(--accent, var(--pink)); box-shadow: 0 0 0 2px var(--accent, var(--pink)), var(--glow); }
.vibe-result { display: flex; flex-direction: column; gap: 10px; }
.vibe-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.vibe-row:last-of-type { border-bottom: 0; }
.vibe-verdict { margin: 0; font-weight: var(--fw-bold); color: var(--gold, #ffd76a); }
.vibe-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.vibe-chip { flex: none; width: 92px; display: flex; flex-direction: column; gap: 4px; padding: 4px; border-radius: var(--r-md); border: 2px solid var(--line); background: rgba(18, 6, 46, .8); color: var(--text); font-size: var(--fs-xs); scroll-snap-align: start; }
.vibe-chip img, .vibe-chip canvas, .vibe-chip svg { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-sm); }
.vibe-chip.selected { border-color: var(--accent, var(--pink)); box-shadow: 0 0 0 2px var(--accent, var(--pink)); }

/* Settings menu, like a phone settings list */
.menu { display: flex; flex-direction: column; padding: 4px 12px; }
.menu-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; color: var(--text); text-align: left; font-weight: var(--fw-medium); box-shadow: none; min-height: 48px; }
.menu-row:last-child { border-bottom: 0; }
.menu-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm); background: rgba(160, 90, 255, .2); }
.menu-icon svg { width: 18px; height: 18px; }
.menu-label { flex: 1; }
.menu-row .chev { opacity: .6; font-size: var(--fs-lg); }

/* Gift wraps: free, only a colour */
.wrap-classic { --wrap: #ff4fa3; } .wrap-neon { --wrap: #9b5cff; } .wrap-gold { --wrap: #ffcf4a; }
.wrap-static { --wrap: #3fa8ff; } .wrap-mint { --wrap: #3fe0b0; } .wrap-galaxy { --wrap: #6a4cff; }
.gift-card[class*="wrap-"] { border-color: var(--wrap); box-shadow: 0 0 0 1px var(--wrap), var(--glow); }
.wrap-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; }
.wrap-chip { flex: none; min-height: 40px; padding: 6px 12px; border-radius: var(--r-pill); border: 2px solid var(--wrap); background: rgba(18, 6, 46, .8); color: var(--text); font-size: var(--fs-sm); }
.wrap-chip.selected { background: var(--wrap); color: #12062e; font-weight: var(--fw-bold); }
.thanks-card { display: flex; align-items: center; gap: 12px; }

/* Weekly wellbeing */
.week-bars { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; height: 90px; padding: 8px 0; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.week-bar { width: 100%; max-width: 28px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--pink), #9b5cff); }

.case-files summary { cursor: pointer; font-weight: var(--fw-bold); min-height: 44px; display: flex; align-items: center; }
.orbit-memory ul { margin: 0; padding-left: 18px; }

/* Group Events */
.event-card { display: flex; align-items: center; gap: 12px; }
.plan-event .plan-form { padding: 12px; border-radius: var(--r-md); background: rgba(18, 6, 46, .55); border: 1px solid var(--line); }
.plan-event input[type="datetime-local"] { min-height: 40px; border-radius: var(--r-sm); background: rgba(18, 6, 46, .8); color: var(--text); border: 1px solid var(--line); padding: 4px 8px; }

.bundle { padding: 10px 0; border-bottom: 1px solid var(--line); }
.bundle:last-child { border-bottom: 0; }
.bundle ul { margin: 6px 0; padding-left: 18px; }

/* Guardian Link */
.guardian-code { font-size: var(--fs-2xl); letter-spacing: .2em; margin: 4px 0; }
.guardian-box { padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }

.try-on .avatar { max-width: 200px; margin: 0 auto; }
.try-on .persona { margin: 0; }
.shop-item .try { width: 100%; }

/* Splash and sign-in, like the mockup */
.welcome { position: relative; min-height: calc(100dvh - 32px); display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: 32px 8px 24px; overflow: hidden; border-radius: var(--r-xl); }
.welcome-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; }
.welcome-art.dim { filter: brightness(.55) saturate(1.1); }
.welcome-top { text-align: center; }
.welcome-top .logo { font-size: var(--fs-4xl); }
.welcome-tag { font-size: var(--fs-xl); margin: 6px 0 0; transform: rotate(-4deg); text-shadow: 0 2px 12px rgba(0, 0, 0, .6); }
.welcome-start { width: min(320px, 100%); }
.welcome-actions { width: min(340px, 100%); }
.signin-btn { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1d1036; border: 0; font-weight: var(--fw-bold); }
.signin-mark { font-weight: var(--fw-heavy); font-size: var(--fs-lg); }
.signin-google .signin-mark { color: #4285f4; }

.persona-now { border-color: var(--accent); }
.persona-now img, .persona-now canvas, .persona-now svg { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }

/* Switches on menu rows */
.menu-row .row-switch { appearance: none; width: 44px; height: 26px; border-radius: var(--r-pill); background: rgba(255, 255, 255, .18); position: relative; cursor: pointer; flex: none; margin: 0; }
.menu-row .row-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.menu-row .row-switch:checked { background: linear-gradient(90deg, var(--pink), #9b5cff); }
.menu-row .row-switch:checked::after { transform: translateX(18px); }
.menu-row .row-switch:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
.logout { width: min(240px, 100%); align-self: center; margin: 4px auto; display: block; }

/* Bank QR payments */
.pay-panel { max-height: calc(100dvh - 48px); overflow-y: auto; width: min(400px, 100%); }
.pay-qr { width: min(260px, 80vw); height: auto; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: var(--r-md); padding: 8px; margin: 0 auto; display: block; }
.pay-amount { font-size: var(--fs-2xl); margin: 4px 0; }
.pay-ref { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px; border: 2px dashed var(--pink); border-radius: var(--r-sm); }
.pay-ref strong { letter-spacing: .15em; font-size: var(--fs-xl); }
.pay-method { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 12px 14px; }
.pay-bank { font-weight: var(--fw-heavy); font-size: var(--fs-md); }
.bank-aba { border-left: 6px solid #0a5bab; } .bank-acleda { border-left: 6px solid #1c3f94; } .bank-wing { border-left: 6px solid #a5cd39; }
.bank-method { align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bank-qr-thumb { background: #fff; border-radius: var(--r-sm); object-fit: contain; }

/* Welcome, sign-in and intro (second mockup) */
.welcome-links .linkish { background: none; border: 0; color: var(--text); text-decoration: underline; padding: 4px 6px; min-height: 32px; box-shadow: none; }
.or-line { margin: 2px 0; }
.input-icon { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: var(--r-md); border: 1px solid var(--line); background: rgba(18, 6, 46, .75); }
.input-icon input { flex: 1; border: 0; background: none; color: var(--text); min-height: 46px; outline: none; }
.input-icon .eye { width: 36px; height: 36px; padding: 0; background: none; border: 0; box-shadow: none; }
.signin-facebook .signin-mark { color: #1877f2; }
.intro-title { font-size: var(--fs-2xl); line-height: 1.1; transform: rotate(-3deg); }
.dots { display: flex; gap: 8px; justify-content: center; margin: 6px 0; }
.dot-step { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .35); }
.dot-step.on { width: 22px; border-radius: var(--r-pill); background: var(--pink); }

.friends-chose { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.friend-faces { display: flex; justify-content: center; }
.friend-faces > * { width: 40px; height: 40px; margin-left: -8px; border: 2px solid var(--bg, #12062e); border-radius: 50%; overflow: hidden; }
.friend-faces > *:first-child { margin-left: 0; }
.more-faces { display: grid; place-items: center; background: rgba(160, 90, 255, .35); font-size: var(--fs-sm); font-weight: var(--fw-bold); }

/* Live Room gifts */
.live-badge { background: #ff2d55; color: #fff; font-weight: var(--fw-heavy); font-size: var(--fs-xs); padding: 3px 8px; border-radius: var(--r-xs); letter-spacing: .05em; }
.gift-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.gift-float { position: absolute; bottom: 120px; animation: gift-up 2.5s ease-out forwards; }
.gift-float svg { width: 34px; height: 34px; filter: drop-shadow(0 0 8px currentColor); }
.gift-rose { color: #ff4f8b; } .gift-crown { color: #ffd23d; } .gift-gem { color: #7dd6ff; }
@keyframes gift-up { from { transform: translateY(0) scale(.6); opacity: 0; } 15% { opacity: 1; } to { transform: translateY(-60vh) scale(1.2); opacity: 0; } }
.gift-bar { position: sticky; bottom: 84px; display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: var(--r-lg); background: rgba(18, 6, 46, .9); border: 1px solid var(--line); }
.gift-feed p { margin: 0; }
.gift-row { justify-content: space-around; }
.gift-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 72px; padding: 8px; border-radius: var(--r-md); }
.gift-btn svg { width: 28px; height: 28px; }

.mini-avatar { position: relative; display: block; width: 72px; height: 96px; margin: 0 auto; }
.mini-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; }

.level-bar { width: min(240px, 80%); height: 8px; border-radius: var(--r-pill); background: rgba(255, 255, 255, .15); overflow: hidden; margin: 4px auto; }
.level-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--pink), #9b5cff); }
.settings-uid { font-family: ui-monospace, monospace; }

.welcome-crown { display: block; margin: 0 auto -6px; filter: drop-shadow(0 0 10px rgba(255, 200, 80, .7)); }
.welcome-loading { width: min(300px, 90%); text-align: center; text-shadow: 0 1px 6px rgba(0, 0, 0, .8); }
.loading-bar { height: 6px; border-radius: var(--r-pill); background: rgba(255, 255, 255, .2); overflow: hidden; }
.loading-bar span { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--pink), #9b5cff, #3dd6ff); transform-origin: left; animation: load-fill 1.3s ease-out forwards; }
@keyframes load-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .loading-bar span { animation: none; } }
.welcome-links { display: flex; justify-content: center; align-items: center; gap: 6px; }
.welcome-links .linkish { width: auto; flex: none; }

/* ── Home: clearer, brighter art (phone and web) ── */
body {
  background: linear-gradient(rgba(18, 6, 46, .55), rgba(18, 6, 46, .9)), url("/art/gen/bg-city.webp") center top / cover no-repeat fixed var(--bg);
}
/* Today's Drop: the picture in full colour; text sits on a fade at the bottom. */
.drop-hero { min-height: 230px; justify-content: flex-end; background: #1d0b45; }
.drop-hero .drop-art { opacity: 1; object-position: center 35%; }
.drop-hero::after { background: linear-gradient(180deg, rgba(20, 6, 60, 0) 25%, rgba(20, 6, 60, .55) 55%, rgba(20, 6, 60, .95) 100%); }
.drop-hero .drop-label, .drop-hero .drop-title { text-shadow: 0 2px 10px rgba(0, 0, 0, .7); }
/* Episode card: the scene shows clearly on the right; a softer fade behind the text on the left. */
.story-card { min-height: 170px; display: flex; flex-direction: column; justify-content: flex-end; }
.story-card .card-art { opacity: 1; object-position: 70% 40%; }
.story-card::after { background: linear-gradient(90deg, rgba(30, 10, 80, .92) 0%, rgba(30, 10, 80, .6) 45%, rgba(30, 10, 80, 0) 80%); }
/* Picture tiles */
.mode-tile.has-art { position: relative; overflow: hidden; isolation: isolate; justify-content: flex-end; min-height: 128px; padding: 8px 6px; }
.mode-tile.has-art .tile-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; transition: transform .3s ease; }
.mode-tile.has-art::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(20, 6, 60, 0) 40%, rgba(20, 6, 60, .9) 100%); }
.mode-tile.has-art .mode-icon { display: none; }
.mode-tile.has-art .mode-label { text-shadow: 0 2px 8px rgba(0, 0, 0, .8); }
.mode-tile.has-art:hover .tile-art, .mode-tile.has-art:focus-visible .tile-art { transform: scale(1.06); }
@media (prefers-reduced-motion: reduce) { .mode-tile.has-art .tile-art { transition: none; } }

/* Big screens: Home gets a wider, two-column layout. */
@media (min-width: 1000px) {
  body[data-route="/"] #app { max-width: 1040px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; align-items: start; }
  body[data-route="/"] #app > * { grid-column: auto; }
  body[data-route="/"] #app .screen > .row:first-child,
  body[data-route="/"] #app .screen > .player-strip,
  body[data-route="/"] #app .screen > [role="status"],
  body[data-route="/"] #app > nav,
  body[data-route="/"] #app > .bottom-nav { grid-column: 1 / -1; }
  body[data-route="/"] .drop-hero { min-height: 340px; grid-row: span 2; }
  body[data-route="/"] .mode-tile.has-art { min-height: 150px; }
}

.signin-box.guest { border: 2px solid var(--pink); box-shadow: var(--glow); }

/* ── Smart screens: phone, iPad and web ── */
/* Clear keyboard focus everywhere, for players who use a keyboard. */
.option:focus-visible, .mode-tile:focus-visible, .btn:focus-visible, button:focus-visible { outline: 3px solid #ffd23d; outline-offset: 2px; }

/* Mouse and trackpad: a gentle lift on things you can tap. */
@media (hover: hover) and (pointer: fine) {
  .option, .mode-tile, .card.entry, .shop-item, .vibe-pick, .persona-tile { transition: transform .15s ease, box-shadow .15s ease; }
  .option:hover, .mode-tile:hover, .card.entry:hover, .shop-item:hover, .vibe-pick:hover, .persona-tile:hover { transform: translateY(-2px); box-shadow: var(--glow); }
  .scene { cursor: pointer; }
  .tap-hint::after { content: ' · Enter'; opacity: .7; }
}
@media (prefers-reduced-motion: reduce) {
  .option:hover, .mode-tile:hover, .card.entry:hover, .shop-item:hover, .vibe-pick:hover, .persona-tile:hover { transform: none; }
}

/* Tablets (iPad portrait and up): a wider column, bigger answers and more per row. */
@media (min-width: 700px) {
  #app { max-width: 720px; }
  #nav a { max-width: 110px; font-size: var(--fs-xs); }
  .option { min-height: 60px; font-size: var(--fs-md); padding: 12px 18px 12px 12px; }
  .scene .line { font-size: var(--fs-xl); }
  .shop-grid { grid-template-columns: repeat(3, 1fr); }
  .vibe-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .avatar-grid { grid-template-columns: repeat(4, 1fr); }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .mode-tile.has-art { min-height: 170px; font-size: var(--fs-md); }
  .drop-hero { min-height: 300px; }
  .story-card { min-height: 220px; }
  .welcome { min-height: min(calc(100dvh - 32px), 1100px); }
}

/* Computers and iPad landscape: a little wider still for other screens (Home has its own layout). */
@media (min-width: 1000px) {
  body:not([data-route="/"]) #app { max-width: 820px; }
  .shop-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Phones turned sideways: less height, so keep things compact. */
@media (orientation: landscape) and (max-height: 500px) {
  .welcome { min-height: calc(100dvh - 16px); padding: 12px 8px; }
  .welcome-top .logo { font-size: var(--fs-2xl); }
  .drop-hero { min-height: 180px; }
  .scene .line { font-size: var(--fs-md); }
  .option { min-height: 44px; padding-top: 6px; padding-bottom: 6px; }
  .mode-tile.has-art { min-height: 96px; }
}

.signin-telegram { background: #0b6ba8; color: #fff; }
.signin-whatsapp { background: #25d366; color: #0b2b16; }
.signin-telegram .signin-mark, .signin-whatsapp .signin-mark { color: inherit; }
.signin-telegram svg, .signin-whatsapp svg { width: 20px; height: 20px; }
.phone-signin { width: 100%; }

/* Invite Friends */
.invite-count { font-size: var(--fs-4xl); margin: 0; line-height: 1; }
.invite-url { word-break: break-all; padding: 8px; border-radius: var(--r-sm); background: rgba(0, 0, 0, .25); }
.invite-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.invite-buttons .btn, .invite-buttons button { display: flex; align-items: center; justify-content: center; gap: 6px; }
.invite-banner { border: 2px solid var(--pink); }
.invite-banner .pill { margin-left: auto; }
body[data-route="/"] #app .screen > .invite-banner { grid-column: 1 / -1; }

/* Shop cards: tidy actions and right-sized icons */
.shop-actions { display: flex; gap: 6px; width: 100%; }
.shop-actions .try { flex: 1; width: auto; }
.shop-actions .wish { flex: none; width: 44px; padding: 0; }
.shop-actions .wish.on { color: var(--pink); border-color: var(--pink); }
.shop-item .shop-actions button { width: auto; }
.shop-item .shop-actions .try { flex: 1; }
.shop-item button svg, .try-on button svg, .bundle button svg { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.try-on .primary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.try-on .avatar { width: 200px; height: 266px; position: relative; margin: 0 auto; }
.shop-item .shop-actions .wish { width: 44px; min-width: 44px; flex: none; display: grid; place-items: center; }

/* MIRRIX Wallet, like the mockup */
.wallet-boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.wallet-box { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; border-radius: var(--r-md); text-align: center; background: rgba(18, 6, 46, .85); }
.wallet-box.earned { border: 2px solid #b44cff; box-shadow: 0 0 16px rgba(180, 76, 255, .5); }
.wallet-box.total { border: 2px solid #e8b23a; box-shadow: 0 0 16px rgba(232, 178, 58, .45); }
.wallet-number { font-size: var(--fs-2xl); color: #ffd76a; line-height: 1.1; }
.wallet-sub { display: flex; justify-content: space-between; gap: 8px; padding: 0 4px; }
.wallet-refresh { align-self: center; background: linear-gradient(180deg, #ffe08a, #e8a92e); color: #2a1500; font-weight: var(--fw-heavy); border: 0; padding: 8px 18px; }
.wallet-refresh svg { width: 18px; height: 18px; }
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger-row { display: grid; grid-template-columns: 74px 28px 1fr auto; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ledger-row:last-child { border-bottom: 0; }
.ledger-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-sm); background: rgba(232, 178, 58, .15); color: #ffd76a; }
.ledger-icon svg { width: 16px; height: 16px; }
.ledger-label { font-size: var(--fs-sm); }
.ledger-row.plus .ledger-amount { color: #ffd76a; }
.ledger-row.minus .ledger-amount { color: #e879ff; }
.wallet-link { align-self: flex-end; margin-top: -6px; text-decoration: none; color: var(--muted); }
@media (min-width: 700px) { .ledger-row { grid-template-columns: 120px 32px 1fr auto; } }

/* Avatar look: outfit colour, glow and aura */
.avatar .outfit-layer { filter: hue-rotate(var(--outfit-hue, 0deg)); }
.avatar { --glow: 0; }
.avatar img { filter: drop-shadow(0 0 calc(var(--glow) * 14px) rgba(180, 120, 255, calc(var(--glow)))); }
.avatar .outfit-layer { filter: hue-rotate(var(--outfit-hue, 0deg)) drop-shadow(0 0 calc(var(--glow) * 14px) rgba(180, 120, 255, calc(var(--glow)))); }
.avatar.aura-violet::before, .avatar.aura-gold::before, .avatar.aura-cyan::before { content: ''; position: absolute; inset: 8% -6% 2%; border-radius: 50%; z-index: -1; filter: blur(18px); opacity: .75; }
.avatar.aura-violet::before { background: radial-gradient(circle, #b44cff 0%, transparent 70%); }
.avatar.aura-gold::before { background: radial-gradient(circle, #ffd23d 0%, transparent 70%); }
.avatar.aura-cyan::before { background: radial-gradient(circle, #3dd6ff 0%, transparent 70%); }

/* Persona Customization */
.style-card { display: grid; grid-template-columns: 1fr; gap: 14px; }
.style-stage { position: relative; display: grid; place-items: center; padding: 16px 0 24px; border-radius: var(--r-lg); background: radial-gradient(circle at 50% 85%, rgba(61, 214, 255, .25), transparent 55%), rgba(10, 6, 30, .6); isolation: isolate; }
.stage-ring { position: absolute; bottom: 14px; width: 60%; height: 22px; border-radius: 50%; border: 2px solid rgba(61, 214, 255, .7); box-shadow: 0 0 18px rgba(61, 214, 255, .7); z-index: -1; }
.style-row { display: flex; flex-direction: column; gap: 6px; }
.style-label { font-weight: var(--fw-bold); text-transform: uppercase; font-size: var(--fs-xs); letter-spacing: .04em; display: flex; align-items: center; gap: 6px; }
.style-label svg { width: 16px; height: 16px; }
.style-row input[type="range"] { width: 100%; accent-color: #b44cff; }
.style-chips { display: flex; gap: 8px; }
.style-chip { width: 48px; height: 48px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.style-chip svg { width: 22px; height: 22px; }
.style-chip.selected { border-color: var(--pink); box-shadow: 0 0 0 2px var(--pink), var(--glow); }
.aura-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5); }
.aura-dot-violet { background: #b44cff; } .aura-dot-gold { background: #ffd23d; } .aura-dot-cyan { background: #3dd6ff; } .aura-dot-none { background: transparent; }
@media (min-width: 700px) { .style-card { grid-template-columns: 1fr 1fr; align-items: center; } }

/* Choose Your Path */
.path-hero { position: relative; min-height: min(78dvh, 760px); border-radius: var(--r-xl); overflow: hidden; isolation: isolate; display: flex; flex-direction: column; justify-content: space-between; padding: 22px 16px; border: 1px solid var(--line); }
.path-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.path-hero::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(10, 4, 30, .55) 0%, rgba(10, 4, 30, 0) 30%, rgba(10, 4, 30, .2) 55%, rgba(10, 4, 30, .9) 100%); }
.path-top { text-align: center; }
.path-top .logo { font-size: var(--fs-3xl); }
.path-title { margin: 2px 0 0; font-size: var(--fs-xl); text-transform: uppercase; text-shadow: 0 2px 10px rgba(0, 0, 0, .8); }
.path-buttons { display: flex; flex-direction: column; gap: 14px; }
.path-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px; border-radius: var(--r-lg); text-decoration: none; color: #fff; text-align: center;
  background: linear-gradient(135deg, rgba(122, 44, 255, .92), rgba(214, 51, 160, .92)); border: 2px solid #ffd76a; box-shadow: 0 0 22px rgba(255, 120, 220, .55); }
.path-kicker { font-weight: var(--fw-heavy); text-transform: uppercase; font-size: var(--fs-md); }
.path-btn strong { font-size: var(--fs-xl); color: #ffd76a; text-transform: uppercase; }
.path-btn:focus-visible { outline: 3px solid #ffd23d; outline-offset: 3px; }

/* Static City Map */
.city-map-card { border-radius: var(--r-xl); overflow: hidden; border: 2px solid rgba(160, 100, 255, .6); box-shadow: var(--glow); background: #0b0a24; }
.city-map { position: relative; }
.city-map-art { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
.district-pin { position: absolute; width: 34px; height: 34px; min-height: 0; padding: 0; margin: -17px 0 0 -17px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(20, 10, 50, .85); border: 2px solid rgba(255, 255, 255, .4); color: #cfc3ff; }
.district-pin svg { width: 14px; height: 14px; }
.district-pin.open { background: radial-gradient(circle, #ffe9a0, #f5b335); border-color: #fff4c2; box-shadow: 0 0 16px #ffd23d; }
.you-pin { position: absolute; width: 46px; height: 46px; margin: -62px 0 0 -23px; border-radius: 50%; border: 2px solid #ff4fd8; box-shadow: 0 0 14px #ff4fd8; overflow: hidden; pointer-events: none; transition: left .3s ease, top .3s ease; }
.you-pin > * { width: 100%; height: 100%; }
.city-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; }
.city-footer .small { color: #ffd76a; }
.squad-chip { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 10px; border-radius: var(--r-sm); border: 1px solid var(--line); text-decoration: none; color: var(--text); }
@media (prefers-reduced-motion: reduce) { .you-pin { transition: none; } }

/* Leaderboard shields */
.rank-shield { display: inline-grid; place-items: center; width: 38px; height: 42px; font-weight: var(--fw-heavy); font-size: var(--fs-xl); color: #fff;
  clip-path: polygon(50% 0, 100% 15%, 100% 60%, 50% 100%, 0 60%, 0 15%); text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.shield-1 { background: linear-gradient(180deg, #ffe08a, #c98a12); }
.shield-2 { background: linear-gradient(180deg, #e9ecff, #8d93b8); }
.shield-3 { background: linear-gradient(180deg, #ffb27a, #b25a1e); }
.rank-row.top { border-width: 2px; }
.rank-row.top-1 { border-color: #ffd76a; box-shadow: 0 0 16px rgba(255, 215, 106, .45); }

/* Message reactions */
.reaction-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 6px; }
.reaction-count, .reaction-add, .reaction-choice { display: inline-flex; align-items: center; gap: 3px; min-height: 30px; padding: 2px 8px; border-radius: var(--r-pill); font-size: var(--fs-sm); background: rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.reaction-count svg, .reaction-add svg, .reaction-choice svg { width: 15px; height: 15px; }
.reaction-count.mine, .reaction-choice.mine { border-color: var(--pink); background: rgba(255, 79, 163, .25); }
.reaction-picker { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
.reaction-choice { width: 38px; height: 38px; justify-content: center; padding: 0; }

/* Co-op Case puzzles */
.puzzle-card { border: 2px solid rgba(61, 214, 255, .5); }
.cipher-text { font-size: var(--fs-2xl); letter-spacing: .25em; text-align: center; margin: 4px 0; color: #7fe7ff; font-family: ui-monospace, monospace; }
.timeline-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.timeline-item { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; padding: 8px; border-radius: var(--r-sm); background: rgba(0, 0, 0, .25); }
.timeline-step { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #3dd6ff; color: #071a2b; font-weight: var(--fw-heavy); }
.timeline-moves { display: flex; gap: 4px; }
.timeline-moves button { width: 36px; padding: 0; }
.puzzle-choice { text-align: left; }
.puzzle-photo { width: 100%; border-radius: var(--r-sm); aspect-ratio: 16 / 9; object-fit: cover; }
.puzzle-hints { margin: 0; padding-left: 18px; color: #ffd76a; }
.bonus-clue { border: 1px solid #ffd76a; border-radius: var(--r-sm); padding: 8px; }

/* Season Pass */
.pass-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.pass-tier { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-radius: var(--r-sm); text-align: center; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.pass-tier.reached { border-color: #ffd76a; }
.pass-tier svg { width: 16px; height: 16px; }
.pass-track { display: flex; flex-direction: column; gap: 6px; }
.pass-track.premium .pass-tier.reached { border-color: #d17dff; box-shadow: 0 0 10px rgba(209, 125, 255, .4); }

/* QR codes (Bakong KHQR and the admin authenticator setup): always black on white so phones can read them. */
.qr-box { background: #fff; padding: 8px; border-radius: var(--r-sm); width: min(260px, 100%); margin: 0 auto; }
.qr-box svg { display: block; width: 100%; height: auto; }
.chat-name { display: block; font-size: var(--fs-xs); }

/* Chat bubbles (group chat, Match Chat): white text on purple, separate from the story's speech bubble. */
.chat-list .bubble { max-width: 85%; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: var(--surface-2); color: #fff; font-weight: var(--fw-medium); }
.chat-list .bubble.mine { align-self: flex-end; border-radius: 14px 14px 4px 14px; background: #7a2d9c; color: #fff; }
.chat-list .bubble .chat-name { color: #e4d4ff; font-weight: var(--fw-bold); }
.chat-list .bubble .linkish { color: #ffd6f5; }
.group-chat .quick-replies { display: flex; flex-wrap: wrap; gap: 6px; }
.group-chat .quick-replies button { width: auto; flex: 0 1 auto; padding: 6px 12px; min-height: 36px; font-size: var(--fs-sm); border-radius: var(--r-pill); }
.group-chat form.row { display: flex; gap: 8px; align-items: center; }
.group-chat form.row input { flex: 1 1 auto; min-width: 0; }
.group-chat form.row button { flex: 0 0 auto; width: auto; padding: 10px 18px; }
.plan-toggle { width: 100%; justify-content: center; border: 1px dashed rgba(217, 184, 255, .7); background: rgba(122, 45, 156, .35); color: #fff; font-weight: var(--fw-bold); }
.plan-toggle.open { border-style: solid; background: rgba(18, 6, 46, .6); }

/* Persona collection: higher ranks shine brighter, Legendary most of all. */
.tile.owned { position: relative; }
.tile.mastery-gold { box-shadow: 0 0 14px rgba(255, 210, 61, .35); }
.tile.mastery-legendary { border-width: 2px; border-color: #ffd23d; box-shadow: 0 0 22px rgba(255, 190, 60, .6), inset 0 0 12px rgba(255, 210, 61, .25); animation: legend-glow 2.4s ease-in-out infinite alternate; }
@keyframes legend-glow { to { box-shadow: 0 0 34px rgba(255, 190, 60, .85), inset 0 0 16px rgba(255, 210, 61, .35); } }
@media (prefers-reduced-motion: reduce) { .tile.mastery-legendary { animation: none; } }
.legend-badge { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 1; padding: 3px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: var(--fw-heavy); color: #2a1600; background: linear-gradient(90deg, #ffd23d, #ffb13d); box-shadow: 0 2px 8px rgba(0, 0, 0, .4); white-space: nowrap; }
.legend-badge .ni { width: 1em; height: 1em; }
.share-collection { width: 100%; margin-top: 8px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.group-tile .mode-icon { position: relative; }
.unread-count { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: var(--r-pill); background: #ff3b5c; color: #fff; font-size: var(--fs-xs); font-weight: var(--fw-heavy); display: grid; place-items: center; }
.redeem-box summary { cursor: pointer; font-weight: var(--fw-bold); min-height: 44px; display: flex; align-items: center; }
.return-btn { font-size: var(--fs-xs); margin-top: 2px; }


/* ── Main Base (/mainpage): full-screen strategy-game hub, icons only ── */
body[data-route="/mainpage"] { overflow: hidden; }
body[data-route="/mainpage"] #app { max-width: none; padding: 0; }
.hq { position: fixed; inset: 0; z-index: 5; overflow: hidden; background: #07041a; color: #fff; }
.hq-view { position: absolute; inset: 0; overflow: auto; scrollbar-width: none; cursor: grab; overscroll-behavior: contain; }
.hq-view::-webkit-scrollbar { display: none; }
.hq-view.dragging { cursor: grabbing; }
.hq-world { position: relative; width: max(100vw, calc(100dvh * 4 / 3)); aspect-ratio: 4 / 3; }
.hq-world-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.hq-hud { position: absolute; inset: 0; pointer-events: none; }
.hq-hud > * { pointer-events: auto; }
.hq-spacer { flex: 1; }

/* Every feature: an icon button. The first tap shows its name, the second opens it. */
.hq-fn { position: relative; display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 0; min-height: 0; width: auto; border: 0; background: none; color: #fff; font: inherit; cursor: pointer; box-shadow: none; }
.hq-fn-icon { position: relative; display: grid; place-items: center; flex: none; transition: transform .15s, box-shadow .15s; }
.hq-fn:hover .hq-fn-icon { transform: scale(1.06); }
.hq-fn:focus-visible .hq-fn-icon { box-shadow: 0 0 0 3px #fff, 0 0 0 6px #7b3cff; }
.hq-badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: var(--r-pill); background: #ff2e55; color: #fff; font-size: var(--fs-xs); font-weight: var(--fw-heavy); display: grid; place-items: center; border: 2px solid #12062e; box-shadow: 0 0 8px rgba(255, 46, 85, .7); }

/* Buildings on the city */
.hq-building { position: absolute; transform: translate(-50%, -50%); }
.hq-building .hq-fn-icon { width: var(--pin, 54px); height: var(--pin, 54px); border-radius: 50%; background: radial-gradient(circle at 35% 30%, #b18aff, #4a1bb8 70%); border: 3px solid #f1e6ff; box-shadow: 0 0 20px rgba(170, 110, 255, .95), 0 6px 12px rgba(0, 0, 0, .55); }
.hq-building .ni { width: calc(var(--pin, 54px) * .52); height: calc(var(--pin, 54px) * .52); }

/* Top bar */
.hq-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 10px 10px 18px; padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(8, 3, 28, .95) 0%, rgba(8, 3, 28, .75) 60%, rgba(8, 3, 28, 0) 100%); }
.hq-player .hq-fn-icon { display: none; }
.hq-avatar { width: 52px; height: 52px; flex: none; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: #2a1170; border: 3px solid #ffd23d; box-shadow: 0 0 14px rgba(255, 210, 61, .7); }
.hq-avatar > * { width: 100%; height: 100%; }
.hq-avatar img { object-fit: cover; }
.hq-player-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hq-player-text strong { font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; text-shadow: 0 1px 3px #000; }
.hq-level { display: flex; align-items: center; gap: 6px; }
.hq-lv { font-size: var(--fs-xs); font-weight: var(--fw-heavy); padding: 1px 6px; border-radius: var(--r-xs); background: #ffd23d; color: #2a1600; white-space: nowrap; }
.hq-xp { display: block; width: 64px; height: 7px; border-radius: var(--r-pill); background: rgba(255, 255, 255, .18); overflow: hidden; }
.hq-xp > span { display: block; height: 100%; background: linear-gradient(90deg, #ffe066, #ff9a2e); }
.hq-res { min-height: 36px; padding: 4px 10px 4px 6px; border-radius: var(--r-pill); background: rgba(0, 0, 0, .55); border: 1px solid rgba(255, 210, 61, .6); font-size: var(--fs-sm); }
.hq-res .ni { color: #ffd23d; width: var(--icon-sm); height: var(--icon-sm); }
.hq-res-tier { display: none; }
.hq-sys { position: relative; display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: var(--r-sm); background: rgba(0, 0, 0, .55); border: 1px solid rgba(217, 184, 255, .5); color: #fff; font-size: var(--fs-md); padding: 0; min-height: 0; }

/* Events row */
.hq-events { position: absolute; top: calc(74px + env(safe-area-inset-top)); left: 0; right: 0; display: flex; gap: 8px; padding: 4px 10px; overflow-x: auto; scrollbar-width: none; }
.hq-events::-webkit-scrollbar { display: none; }
.hq-event { flex-direction: column; flex: 0 0 auto; gap: 3px; }
.hq-event .hq-fn-icon { width: 50px; height: 50px; border-radius: var(--r-md); color: #3a1d00;
  background: radial-gradient(circle at 35% 28%, #fff1b0, #f2b233 55%, #9a5a00); border: 2px solid #fff0b8; box-shadow: 0 4px 10px rgba(0, 0, 0, .55), 0 0 12px rgba(255, 190, 60, .45); }
.hq-event .ni { width: var(--icon-md); height: var(--icon-md); }
.hq-event.hot .hq-fn-icon { color: #fff; background: radial-gradient(circle at 35% 28%, #ffb3c0, #e8173e 55%, #7a0018); border-color: #ffc8d2; animation: hq-pulse 1.6s ease-in-out infinite; }
@keyframes hq-pulse { 50% { box-shadow: 0 4px 10px rgba(0, 0, 0, .55), 0 0 24px rgba(255, 40, 80, .9); } }
.hq-event-sub { font-size: var(--fs-xs); font-weight: var(--fw-heavy); padding: 1px 5px; border-radius: var(--r-xs); background: #c4163a; }

/* Left: quest and news */
.hq-left { position: absolute; top: calc(150px + env(safe-area-inset-top)); left: 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.hq-quest { flex-direction: column; gap: 3px; }
.hq-quest .hq-fn-icon { width: 60px; height: 60px; border-radius: var(--r-md); color: #ffd23d; background: linear-gradient(135deg, #9a5f0a, #4a1e86); border: 2px solid #ffd23d; box-shadow: 0 0 16px rgba(255, 190, 60, .55), 0 6px 14px rgba(0, 0, 0, .5); }
.hq-quest .ni { width: var(--icon-lg); height: var(--icon-lg); }
.hq-quest-chip { font-size: var(--fs-xs); font-weight: var(--fw-heavy); padding: 1px 7px; border-radius: var(--r-sm); background: #ffd23d; color: #2a1600; }
.hq-notice .hq-fn-icon, .hq-side-btn .hq-fn-icon { width: 48px; height: 48px; border-radius: var(--r-md); color: #ffd23d; background: linear-gradient(180deg, rgba(56, 28, 132, .96), rgba(18, 8, 52, .96)); border: 1px solid rgba(217, 184, 255, .65); box-shadow: 0 4px 10px rgba(0, 0, 0, .5); }
.hq-notice .ni, .hq-side-btn .ni { width: var(--icon-md); height: var(--icon-md); }
.hq-side-btn .hq-fn-icon { color: #fff; }

/* Right: live event and side buttons */
.hq-right { position: absolute; top: calc(150px + env(safe-area-inset-top)); right: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.hq-alert .hq-fn-icon { width: 54px; height: 54px; border-radius: var(--r-md); color: #fff; background: radial-gradient(circle at 35% 28%, #ff8aa0, #c4103a 60%, #5a0018); border: 2px solid #ffc8d2; animation: hq-pulse 1.6s ease-in-out infinite; }
.hq-alert .ni { width: var(--icon-lg); height: var(--icon-lg); }

/* Bottom: command bar and Battle */
.hq-bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; gap: 8px; padding: 30px 10px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(8, 3, 28, .97) 0%, rgba(8, 3, 28, .8) 60%, rgba(8, 3, 28, 0) 100%); }
.hq-dock { flex: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; justify-items: center; }
.hq-dock-btn .hq-fn-icon { width: 46px; height: 46px; border-radius: var(--r-md); color: #ffd23d; background: linear-gradient(180deg, #4a2fa8, #1d0f62); border: 2px solid rgba(255, 210, 61, .7); box-shadow: 0 4px 10px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .25); }
.hq-dock-btn .ni { width: var(--icon-md); height: var(--icon-md); }
.hq-battle .hq-fn-icon { width: 76px; height: 76px; border-radius: 50%; color: #3a1d00;
  background: radial-gradient(circle at 35% 28%, #fff4c0, #ffbe3d 55%, #d06a00); border: 3px solid #fff4c8; box-shadow: 0 0 26px rgba(255, 170, 40, .85), 0 8px 16px rgba(0, 0, 0, .55); animation: hq-glow 2.4s ease-in-out infinite; }
.hq-battle .ni { width: var(--icon-xl); height: var(--icon-xl); }
@keyframes hq-glow { 50% { box-shadow: 0 0 40px rgba(255, 170, 40, 1), 0 8px 16px rgba(0, 0, 0, .55); } }

/* More: a sheet of icons over the city */
.hq-more { position: fixed; inset: 0; z-index: 6; display: flex; align-items: flex-end; justify-content: center; background: rgba(4, 2, 16, .6); }
.hq-more[hidden] { display: none; }
.hq-more-panel { width: min(560px, 100%); padding: 12px 14px calc(18px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; background: linear-gradient(180deg, #2a1170, #12062e); border: 1px solid rgba(217, 184, 255, .5); }
.hq-more-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: var(--fs-lg); }
.hq-more-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; justify-items: center; }
.hq-more-item .hq-fn-icon { width: 54px; height: 54px; border-radius: var(--r-md); color: #ffd23d; background: rgba(255, 255, 255, .08); border: 1px solid rgba(217, 184, 255, .35); }
.hq-more-item .ni { width: var(--icon-md); height: var(--icon-md); }

/* The pop-up: a feature opened over the city */
.hq-pop { position: fixed; inset: 0; z-index: 7; display: flex; align-items: flex-end; justify-content: center; background: rgba(4, 2, 16, .65); }
.hq-pop[hidden] { display: none; }
.hq-pop-panel { display: flex; flex-direction: column; width: 100%; height: 94dvh; border-radius: 22px 22px 0 0; overflow: hidden;
  background: linear-gradient(rgba(18, 6, 46, .55), rgba(18, 6, 46, .92)), url("/art/gen/bg-city.webp") center top / cover var(--bg); border: 2px solid #ffd23d; border-bottom: 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, .6); }
.hq-pop-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: linear-gradient(180deg, #3a1a94, #1d0c5a); border-bottom: 1px solid rgba(255, 210, 61, .55); }
.hq-pop-head .hq-sys[hidden] { display: none; }
.hq-pop-head .hq-sys .ni { transform: scaleX(-1); }
.hq-pop-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); background: #ffd23d; color: #2a1600; }
.hq-pop-title { font-size: var(--fs-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hq-pop-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 16px; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: reduce) { .hq-event.hot .hq-fn-icon, .hq-alert .hq-fn-icon, .hq-battle .hq-fn-icon { animation: none; } }

/* Tablets and computers: a larger HUD and a centred pop-up window. */
@media (min-width: 900px) {
  .hq-res-tier { display: inline-flex; }
  .hq-player-text strong { max-width: 220px; font-size: var(--fs-md); }
  .hq-avatar { width: 64px; height: 64px; }
  .hq-xp { width: 120px; }
  .hq-events { justify-content: center; top: calc(16px + env(safe-area-inset-top)); left: 330px; right: 330px; flex-wrap: wrap; gap: 12px; }
  .hq-event .hq-fn-icon { width: 60px; height: 60px; }
  .hq-left { top: 116px; left: 18px; }
  .hq-right { top: 116px; right: 18px; }
  .hq-dock { flex: 0 1 auto; margin: 0 auto; gap: 16px; }
  .hq-dock-btn .hq-fn-icon { width: 60px; height: 60px; }
  .hq-battle { position: absolute; right: 22px; bottom: 16px; }
  .hq-battle .hq-fn-icon { width: 96px; height: 96px; }
  .hq-battle .ni { width: var(--icon-2xl); height: var(--icon-2xl); }
  .hq-pop { align-items: center; }
  .hq-pop-panel { width: min(760px, 94vw); height: 88vh; border-radius: var(--r-xl); border-bottom: 2px solid #ffd23d; }
}

/* Main Base background: the island is fitted between the HUD (views/base.js) and sits on a
   glowing backdrop made from the same city, with slow fog and light. */
.hq-stage { position: relative; overflow: hidden; }
.hq-world { position: absolute; width: auto; aspect-ratio: auto; }
.hq-world-art { -webkit-mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent), linear-gradient(180deg, transparent, #000 10%, #000 88%, transparent); -webkit-mask-composite: source-in; mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent), linear-gradient(180deg, transparent, #000 10%, #000 88%, transparent); mask-composite: intersect; }
.hq-backdrop { position: absolute; inset: 0; overflow: hidden; pointer-events: none;
  background: radial-gradient(ellipse at 50% 35%, #2a1470 0%, #140838 45%, #06031a 100%); }
.hq-backdrop-art { position: absolute; inset: -8%; background: center / cover no-repeat; filter: blur(26px) saturate(1.3) brightness(.42); transform: scale(1.15); opacity: .9; }
.hq-backdrop-glow { position: absolute; inset: 0;
  background: radial-gradient(circle at 18% 22%, rgba(123, 60, 255, .35), transparent 38%), radial-gradient(circle at 82% 30%, rgba(40, 200, 255, .25), transparent 40%), radial-gradient(circle at 50% 90%, rgba(255, 60, 170, .22), transparent 45%);
  animation: hq-breathe 9s ease-in-out infinite alternate; }
.hq-fog { position: absolute; inset: -20% -40%; opacity: .35;
  background: radial-gradient(ellipse 30% 12% at 30% 60%, rgba(180, 160, 255, .35), transparent 70%), radial-gradient(ellipse 25% 10% at 70% 40%, rgba(120, 220, 255, .28), transparent 70%), radial-gradient(ellipse 35% 12% at 55% 80%, rgba(255, 140, 220, .22), transparent 70%);
  animation: hq-drift 40s linear infinite alternate; }
.hq-stars { position: absolute; inset: 0; opacity: .55;
  background-image: radial-gradient(1.5px 1.5px at 12% 18%, #fff, transparent), radial-gradient(1px 1px at 28% 8%, #cfe8ff, transparent), radial-gradient(1.5px 1.5px at 46% 14%, #fff, transparent), radial-gradient(1px 1px at 64% 6%, #ffd9f5, transparent), radial-gradient(1.5px 1.5px at 78% 16%, #fff, transparent), radial-gradient(1px 1px at 90% 9%, #cfe8ff, transparent), radial-gradient(1px 1px at 8% 34%, #fff, transparent), radial-gradient(1px 1px at 94% 38%, #fff, transparent);
  animation: hq-twinkle 5s ease-in-out infinite alternate; }
@keyframes hq-breathe { to { opacity: .6; transform: scale(1.06); } }
@keyframes hq-drift { to { transform: translateX(18%); } }
@keyframes hq-twinkle { to { opacity: .25; } }
/* Each building sits on a soft beam of light, so it reads as a place, not a sticker. */
.hq-building::before { content: ''; position: absolute; left: 50%; top: 50%; width: 120%; height: 120%; transform: translate(-50%, -30%); border-radius: 50%; pointer-events: none;
  background: radial-gradient(ellipse at 50% 60%, rgba(170, 110, 255, .55), transparent 65%); animation: hq-breathe 3.2s ease-in-out infinite alternate; }
@media (prefers-reduced-motion: reduce) { .hq-backdrop-glow, .hq-fog, .hq-stars, .hq-building::before { animation: none; } }
body.reduced-motion .hq-backdrop-glow, body.reduced-motion .hq-fog, body.reduced-motion .hq-stars { animation: none; }
/* Short screens (a phone turned sideways): the events move up into the top bar, so the city
   keeps most of the height. */
@media (max-height: 520px) and (orientation: landscape) {
  .hq-top { padding-bottom: 8px; }
  .hq-events { top: calc(10px + env(safe-area-inset-top)); left: 50%; right: auto; transform: translateX(-50%); max-width: 40vw; }
  .hq-event .hq-fn-icon { width: 42px; height: 42px; }
  .hq-left, .hq-right { top: calc(74px + env(safe-area-inset-top)); gap: 6px; }
  .hq-quest .hq-fn-icon { width: 46px; height: 46px; }
  .hq-notice .hq-fn-icon, .hq-side-btn .hq-fn-icon { width: 40px; height: 40px; }
  .hq-bottom { padding-top: 14px; }
  .hq-dock { max-width: 420px; margin: 0 auto; }
  .hq-dock-btn .hq-fn-icon { width: 40px; height: 40px; }
  .hq-battle .hq-fn-icon { width: 62px; height: 62px; }
  .hq-res-tier { display: none; }
}
/* A dark pool the colour of the night sea under the island, so the picture blends into the backdrop. */
.hq-backdrop::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse 46% 52% at 50% 52%, rgba(9, 8, 30, .97) 0%, rgba(9, 8, 30, .85) 55%, rgba(9, 8, 30, 0) 100%); }
/* Names under the building and bottom-bar icons. */
.hq-building, .hq-dock-btn { flex-direction: column; gap: 3px; }
.hq-building { transform: translate(-50%, calc(var(--pin, 54px) / -2)); }
.hq-fn-label { font-size: var(--fs-xs); font-weight: var(--fw-heavy); line-height: 1.1; white-space: nowrap; text-shadow: 0 1px 2px #000, 0 0 6px #000; }
.hq-building .hq-fn-label { padding: 2px 8px; border-radius: var(--r-sm); background: rgba(10, 4, 30, .82); border: 1px solid rgba(217, 184, 255, .55); font-size: clamp(var(--fs-xs), calc(var(--pin, 54px) * .25), var(--fs-sm)); }
.hq-dock-btn .hq-fn-label { max-width: 72px; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 900px) { .hq-fn-label { font-size: var(--fs-xs); } }

/* Bottom-bar names wrap onto two short lines instead of touching their neighbours. */
.hq-dock-btn { min-width: 0; }
.hq-dock-btn .hq-fn-label { max-width: 100%; white-space: normal; text-align: center; overflow-wrap: anywhere; }

/* ORBIT widget on the Main Base: in the open space above the city on phones, under the quest on
   larger screens. */
.hq-orbit { position: absolute; top: calc(150px + env(safe-area-inset-top)); left: 84px; right: 84px; max-width: 320px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: var(--r-lg);
  background: linear-gradient(160deg, rgba(60, 26, 150, .94), rgba(16, 7, 48, .94)); border: 1px solid rgba(120, 220, 255, .6); box-shadow: 0 0 20px rgba(80, 200, 255, .35), 0 8px 18px rgba(0, 0, 0, .5); }
.hq-orbit-head { display: flex; align-items: center; gap: 6px; color: #8fe6ff; }
.hq-orbit-head .ni { width: var(--icon-sm); height: var(--icon-sm); }
.hq-orbit-close { width: 32px; height: 32px; min-height: 0; padding: 0; border-radius: var(--r-sm); background: rgba(0, 0, 0, .3); border: 1px solid rgba(217, 184, 255, .4); color: #fff; font-size: var(--fs-sm); }
.hq-orbit-say { margin: 0; font-size: var(--fs-md); line-height: 1.35; }
.hq-orbit-next { margin: 0; font-size: var(--fs-sm); color: #ffd23d; font-weight: var(--fw-bold); }
.hq-orbit-go { width: 100%; letter-spacing: .06em; }
.hq-orbit-quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.hq-orbit-quick button { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 64px; padding: 8px 4px; width: auto; border-radius: var(--r-md); font-size: var(--fs-xs); font-weight: var(--fw-bold); }
.hq-orbit-quick .ni { width: var(--icon-md); height: var(--icon-md); color: #ffd23d; }
@media (min-width: 900px) { .hq-orbit { top: 206px; left: 18px; right: auto; width: 300px; margin: 0; } }
@media (max-height: 520px) and (orientation: landscape) { .hq-orbit { display: none; } }

/* Every Main Base icon has its name under it (your picture and Coins show your name and number). */
.hq-fn:not(.hq-player):not(.hq-res) { flex-direction: column; gap: 3px; }
.hq-sysbtn .hq-fn-icon { width: 40px; height: 40px; border-radius: var(--r-sm); background: rgba(0, 0, 0, .55); border: 1px solid rgba(217, 184, 255, .5); }
.hq-sysbtn .ni { width: var(--icon-sm); height: var(--icon-sm); }
.hq-fn-label { max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
.hq-top { align-items: flex-start; }
.hq-events { top: calc(78px + env(safe-area-inset-top)); }
.hq-left, .hq-right { top: calc(176px + env(safe-area-inset-top)); gap: 8px; }
.hq-orbit { top: calc(176px + env(safe-area-inset-top)); }
.hq-notice .hq-fn-icon, .hq-side-btn .hq-fn-icon { width: 44px; height: 44px; }
@media (min-width: 900px) {
  .hq-events { top: calc(14px + env(safe-area-inset-top)); }
  .hq-left, .hq-right { top: 124px; }
  .hq-orbit { top: 228px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .hq-events { top: calc(8px + env(safe-area-inset-top)); }
  .hq-left, .hq-right { top: calc(78px + env(safe-area-inset-top)); }
  .hq-side-btn .hq-fn-icon, .hq-notice .hq-fn-icon { width: 36px; height: 36px; }
  .hq-right .hq-fn-label, .hq-left .hq-fn-label { display: none; }
}
.hq-building .hq-fn-label { max-width: none; }
/* Phones held upright: the side buttons sit in two columns, so the city gets more height. */
@media (max-width: 699px) and (orientation: portrait) {
  .hq-right { display: grid; grid-template-columns: repeat(2, auto); justify-items: center; column-gap: 6px; row-gap: 6px; direction: rtl; }
  .hq-right > * { direction: ltr; }
  .hq-orbit { left: 84px; right: 124px; }
  .hq-orbit-quick button { min-height: 56px; padding: 6px 2px; }
}

/* The bars are see-through: only their buttons take taps, so a building under an empty part of a bar still opens. */
.hq-top, .hq-events, .hq-bottom, .hq-dock { pointer-events: none; }
.hq-top > *, .hq-events > *, .hq-bottom > *, .hq-dock > * { pointer-events: auto; }
.hq-bottom > .hq-dock { pointer-events: none; }
.hq-top > .hq-spacer { pointer-events: none; }
/* Short phones held upright: a smaller ORBIT card leaves more of the city in view. */
@media (max-width: 699px) and (orientation: portrait) and (max-height: 760px) {
  .hq-orbit { gap: 4px; padding: 8px 10px; }
  .hq-orbit-head .hq-orbit-close { width: 28px; height: 28px; }
  .hq-orbit-say { font-size: var(--fs-sm); line-height: 1.3; }
  .hq-orbit-next { font-size: var(--fs-xs); }
  .hq-orbit-go { min-height: 40px; padding-top: 6px; padding-bottom: 6px; }
  .hq-orbit-quick button { min-height: 48px; padding: 4px 2px; }
}
/* Admin: reconciliation table. */
.admin-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.admin-table th, .admin-table td { padding: 6px 8px; border-bottom: 1px solid rgba(217, 184, 255, .2); text-align: right; }
.admin-table th:first-child, .admin-table td:first-child { text-align: left; }
.admin-table tbody tr:last-child td { font-weight: var(--fw-bold); }
/* Group chat: pinned message, notices and moderator tools. */
.chat-pinned { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); background: rgba(255, 210, 61, .12); border: 1px solid rgba(255, 210, 61, .45); }
.chat-pinned .ni { flex: none; width: var(--icon-sm); height: var(--icon-sm); color: #ffd23d; }
.chat-pinned .small { flex: 1; }
.chat-notice { margin: 0; color: #ffd23d; }
.chat-mod { align-items: center; gap: 6px; }
.chat-tools { margin-top: 4px; }
.chat-tools summary { cursor: pointer; font-size: var(--fs-xs); color: var(--muted, #b9a8d9); }
.chat-tools .row { gap: 6px; margin-top: 6px; }
/* Admin console: a standard layout with a top bar and a grouped side menu (a drawer on phones). */
body.admin main { max-width: 1280px; }
.admin-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 0; background: var(--bg, #12062e); }
.admin-brand { font-size: var(--fs-lg); }
.admin-menu-btn { width: 44px; min-height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.admin-ic { width: var(--icon-sm); height: var(--icon-sm); flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.admin-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 18px; align-items: start; }
.admin-nav { position: sticky; top: 64px; display: flex; flex-direction: column; gap: 14px; padding: 12px; border-radius: var(--r-md); background: rgba(18, 6, 46, .82); border: 1px solid rgba(150, 100, 255, .35); max-height: calc(100vh - 80px); overflow-y: auto; }
.admin-nav-group { display: flex; flex-direction: column; gap: 2px; }
.admin-nav-title { margin: 0 0 4px; padding: 0 10px; font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.admin-nav-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); text-align: left; box-shadow: none; }
.admin-nav-item:hover { background: rgba(150, 100, 255, .18); }
.admin-nav-item.selected { background: #efe6ff; color: #1c0f3f; font-weight: var(--fw-bold); }
.admin-page-title { margin: 0; font-size: var(--fs-2xl); }
.admin-main { min-width: 0; }
.admin-modules td:nth-child(2), .admin-modules td:nth-child(3) { text-align: right; white-space: nowrap; }
@media (min-width: 900px) { .admin-menu-btn { display: none; } }
@media (max-width: 899px) {
  .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .admin-nav { display: none; position: fixed; inset: 60px 12px auto 12px; z-index: 20; max-height: calc(100vh - 80px); box-shadow: 0 12px 40px rgba(0, 0, 0, .6); background: #1a0b40; }
  .admin-nav.open { display: flex; }
  .admin-who { display: none; }
}
.admin .cc-input { width: 4em; text-transform: uppercase; }
.admin-top button { width: auto; flex: none; }
/* Accessories: a real-looking person wearing each one, big enough to see the detail. */
.shop-art:has(.item-worn) { width: 100%; height: auto; aspect-ratio: 1; overflow: hidden; }
.item-worn { display: block; }
.try-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; align-items: end; }
.try-pair figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.try-photo { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-md); }
.try-pair .avatar-figure, .try-pair svg { max-width: 100%; height: auto; }
/* Phones get an 800px background (35 KB) instead of the 1920px one (122 KB). */
@media (max-width: 820px) {
  body { background-image: linear-gradient(rgba(18, 6, 46, .55), rgba(18, 6, 46, .9)), url("/art/gen/bg-city-sm.webp"); }
}
/* Thumb-friendly: every control is at least 44px in both directions (Apple HIG 44pt; Material 48dp). */
.group-chat .quick-replies button { min-height: 44px; }
.district-pin { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
.style-row input[type="range"] { min-height: 44px; }
label.menu-row { cursor: pointer; }
.wallet-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; }
.icon-btn.eye { width: 44px; }
.hq-res { min-height: 44px; }
.hq-sysbtn .hq-fn-icon { width: 44px; height: 44px; }
.hq-orbit-close, .hq-orbit-head .hq-orbit-close { width: 44px; height: 44px; }
.hq-orbit-go { min-height: 44px; }
a.chip.balance { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; }
.chat-tools summary { display: flex; align-items: center; min-height: 44px; }
.linkish { min-height: 44px; }
.welcome-links .linkish { min-height: 44px; }
.small-pill { min-height: 44px; }
/* Privacy Policy, Terms and Data deletion pages: plain, readable text. */
.legal { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; line-height: 1.6; }
.legal h1 { font-size: var(--fs-3xl); margin: 12px 0 4px; }
.legal h2 { font-size: var(--fs-xl); margin: 24px 0 8px; }
.legal li { margin: 6px 0; }
.legal a:not(.btn) { color: #d9b8ff; }
.legal-nav { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 8px 0; border-bottom: 1px solid rgba(217, 184, 255, .25); }
.legal-nav a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; font-weight: var(--fw-bold); }
.legal-km { margin-top: 28px; padding: 14px 16px; border-radius: var(--r-md); background: rgba(18, 6, 46, .7); }
.legal-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.legal-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); }
