/* Star Me Up — starlit plum night, gold starlight, coral accents. */
:root {
  --night: #150f2e;
  --night-2: #1d1640;
  --panel: #241c4d;
  --panel-2: #2e2560;
  --line: #3e3478;
  --ink: #f6f1ff;
  --muted: #b3a8dd;
  --dim: #7d72ad;
  --gold: #ffd36e;
  --gold-ink: #3a2500;
  --coral: #ff8fb8;
  --mint: #7ef0c2;
  --danger: #ff7a7a;
  --r3: #7cc4ff;
  --r4: #c79bff;
  --r5: #ffd36e;
  --display: "Mitr", "Leelawadee UI", Tahoma, system-ui, sans-serif;
  --body: "IBM Plex Sans Thai", "Leelawadee UI", Tahoma, system-ui, sans-serif;
  --radius: 14px;
  --toph: 64px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--night); color: var(--ink); font: 15px/1.55 var(--body); overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; margin: 0; line-height: 1.25; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- starry sky behind everything ---------- */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(900px 520px at 80% -10%, #3a2470 0%, transparent 65%), radial-gradient(800px 500px at -10% 100%, #3b1d4f 0%, transparent 60%), var(--night); }
#stars { width: 100%; height: 100%; display: block; }

/* ---------- art with graceful fallback ---------- */
.artbox { position: relative; overflow: hidden; background: var(--panel); }
.artbox > img.art { width: 100%; height: 100%; object-fit: cover; display: block; }
.artbox .fallback { position: absolute; inset: 0; display: none; place-items: center; text-align: center; }
.artbox.noart .fallback { display: grid; }
.fallback .glyph { font-family: var(--display); font-size: 2.6em; line-height: 1; color: #ffffffd0; text-shadow: 0 2px 12px #0008; }
.fallback .glyph small { display: block; font-size: .32em; margin-top: .3em; color: #ffffffa0; letter-spacing: .04em; }
.cls-tank    { background: linear-gradient(160deg, #3c5aa8, #1e2858); }
.cls-warrior { background: linear-gradient(160deg, #b8475a, #4a1838); }
.cls-mage    { background: linear-gradient(160deg, #7a54d8, #2b1860); }
.cls-ranger  { background: linear-gradient(160deg, #2f9a86, #143a44); }
.cls-healer  { background: linear-gradient(160deg, #d9a24a, #5a3418); }
.cls-normal  { background: linear-gradient(160deg, #4b3f6e, #1b1530); }
.cls-boss    { background: linear-gradient(160deg, #8a2050, #24081c); }

/* ---------- title ---------- */
.title { position: fixed; inset: 0; z-index: 5; display: grid; place-items: end center; padding: 24px 16px calc(32px + env(safe-area-inset-bottom)); overflow-y: auto; }
.title-art { position: fixed; inset: 0; background: transparent; }
.title-art img { opacity: .9; }
.title-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, #150f2e00 30%, #150f2ecc 70%, var(--night) 100%); }
.title-art.noart::after { background: none; }
.title-in { position: relative; width: min(420px, 100%); display: grid; gap: 14px; justify-items: center; text-align: center; }
.logo { display: grid; line-height: .95; font-family: var(--display); font-weight: 600; letter-spacing: .04em; }
.logo span { font-size: clamp(3.2rem, 13vw, 5.2rem); color: var(--gold); text-shadow: 0 0 28px #ffd36e88, 0 4px 0 #b9862d; }
.logo em { font-style: normal; font-size: clamp(1.6rem, 6vw, 2.4rem); color: var(--ink); letter-spacing: .32em; margin-right: -.32em; }
.tag { color: var(--muted); max-width: 32ch; }
.title-card { width: 100%; display: grid; padding: 18px; border-radius: 18px; background: #1d1640d9; border: 1px solid var(--line); backdrop-filter: blur(8px); box-shadow: 0 18px 50px #0009; }
.title-card > div { display: grid; gap: 10px; }
.title-card label { text-align: left; font-size: .85rem; color: var(--muted); }
input { padding: 11px 13px; border-radius: 11px; border: 1px solid var(--line); background: var(--night); color: var(--ink); font: inherit; width: 100%; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 11px; padding: 9px 16px; font-weight: 500; text-decoration: none; transition: transform .08s, filter .15s, border-color .15s; }
.btn:hover:not(:disabled) { border-color: var(--gold); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; }
.btn.primary { background: linear-gradient(180deg, #ffe08f, #f5b94a); color: var(--gold-ink); border-color: #ffe08f; font-family: var(--display); box-shadow: 0 4px 0 #a8731f, 0 8px 22px #f5b94a40; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.primary:active:not(:disabled) { box-shadow: 0 2px 0 #a8731f; transform: translateY(2px); }
.btn.coral { background: linear-gradient(180deg, #ffb0cd, #ff7aa8); color: #3d0a20; border-color: #ffc4d9; font-family: var(--display); box-shadow: 0 4px 0 #b4446c; }
.btn.ghost { background: transparent; }
.btn.big { padding: 13px 20px; font-size: 1.1rem; }
.btn.sm { padding: 5px 11px; font-size: .85rem; border-radius: 9px; }
.btn small { font-family: var(--body); font-weight: 500; opacity: .8; }
.iconbtn { width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; font-size: 1.05rem; }
.iconbtn:hover { border-color: var(--gold); }

/* ---------- top bar & tabs ---------- */
.game { position: relative; z-index: 1; min-height: 100dvh; }
.top { position: sticky; top: 0; z-index: 20; background: #150f2ee6; backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.brand { font-family: var(--display); font-weight: 600; letter-spacing: .08em; white-space: nowrap; color: var(--ink); }
.brand b { color: var(--gold); font-weight: 600; }
.tabs { display: flex; gap: 4px; margin-right: auto; }
.tabs button { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 8px 14px; border-radius: 10px; color: var(--muted); font-family: var(--display); }
.tabs button i { font-style: normal; font-size: 1.05rem; }
.tabs button:hover { color: var(--ink); background: var(--panel); }
.tabs button[aria-current="page"] { color: var(--gold-ink); background: var(--gold); }
.wallet { display: flex; align-items: center; gap: 8px; }
.cur { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-family: var(--display); }
.cur b { font-weight: 500; min-width: 4ch; text-align: right; }
.cur.bump { animation: bump .4s; }
@keyframes bump { 40% { transform: scale(1.12); border-color: var(--gold); } }
.ico { display: inline-block; flex: none; }
.ico.crystal { width: 12px; height: 15px; background: linear-gradient(160deg, #e6f6ff, #7cc4ff 50%, #8a6cff); clip-path: polygon(50% 0, 100% 35%, 50% 100%, 0 35%); }
.ico.gold { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff5c4, #f5b94a 60%, #a8731f); }

main#view { position: relative; max-width: 1120px; margin: 0 auto; padding: 20px 16px 40px; outline: none; }

@media (max-width: 760px) {
  .top { backdrop-filter: none; background: #150f2ef7; } /* a backdrop-filter would trap the fixed tab bar inside the header */
  .top-in { gap: 8px; padding: 8px 12px; }
  .brand { margin-right: auto; font-size: .95rem; }
  .tabs { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; margin: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; background: #150f2ef2; backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
  .tabs button { flex: 1; flex-direction: column; gap: 0; padding: 6px 4px; font-size: .75rem; }
  .tabs button i { font-size: 1.25rem; }
  .cur { padding: 4px 9px; font-size: .9rem; }
  main#view { padding: 14px 12px calc(90px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) { .brand { display: none; } .wallet { margin-left: auto; } }

/* ---------- shared blocks ---------- */
.head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.head h2 { font-size: 1.5rem; }
.head p { color: var(--muted); }
.panel { background: #241c4dcc; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 12px; font-size: .85rem; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--night); border-color: var(--ink); }
.stars { letter-spacing: -.08em; white-space: nowrap; }
.r3 { --rc: var(--r3); } .r4 { --rc: var(--r4); } .r5 { --rc: var(--r5); }
.rtext { color: var(--rc); }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; }

/* ---------- hero card ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
@media (max-width: 480px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 8px; } }
.card { position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; border-radius: 14px; }
.card .frame { position: relative; border-radius: 14px; overflow: hidden; aspect-ratio: 2 / 3; border: 2px solid var(--rc); box-shadow: 0 0 0 1px #0006, 0 8px 20px #0007; }
.card.r5 .frame { box-shadow: 0 0 0 1px #0006, 0 0 22px #ffd36e55, 0 8px 20px #0007; }
.card .frame .artbox { position: absolute; inset: 0; }
.card .frame::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 50%, #0c0820ee 100%); pointer-events: none; }
.card .meta { position: absolute; z-index: 1; left: 8px; right: 8px; bottom: 7px; display: grid; gap: 0; }
.card .meta b { font-family: var(--display); font-weight: 500; font-size: 1rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta span { font-size: .75rem; color: #ffffffc0; display: flex; justify-content: space-between; gap: 4px; }
.card .badge { position: absolute; z-index: 1; top: 6px; left: 6px; padding: 1px 7px; border-radius: 999px; background: #0c0820cc; font-size: .72rem; color: var(--rc); font-family: var(--display); }
.card .cls { position: absolute; z-index: 1; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #0c0820cc; font-size: .8rem; }
.card .inteam { position: absolute; z-index: 1; top: 34px; right: 6px; padding: 1px 6px; border-radius: 6px; background: var(--mint); color: #05261a; font-size: .68rem; font-weight: 600; }
.card.locked .frame { border-color: var(--line); filter: grayscale(1) brightness(.45); }
button.card:hover .frame { transform: translateY(-2px); }
.card .frame { transition: transform .15s; }

/* ---------- home ---------- */
.hero-banner { position: relative; border-radius: 20px; overflow: hidden; min-height: 260px; display: grid; align-items: end; border: 1px solid var(--line); }
.hero-banner > .artbox { position: absolute; inset: 0; background: linear-gradient(135deg, #3a2470, #1d1640 60%, #4a1f45); }
.hero-banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, #150f2ef0 0%, #150f2e99 45%, transparent 80%); }
.hero-banner .in { position: relative; z-index: 1; padding: 24px; display: grid; gap: 10px; max-width: 460px; }
.hero-banner h2 { font-size: 1.8rem; }
.hero-banner p { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat small { display: block; color: var(--muted); font-size: .8rem; }
.stat b { font-family: var(--display); font-weight: 500; font-size: 1.4rem; }
.teamrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.slot { aspect-ratio: 2 / 3; border-radius: 14px; border: 2px dashed var(--line); display: grid; place-items: center; color: var(--dim); background: #1d164080; font-size: .85rem; text-align: center; padding: 6px; }
button.slot:hover { border-color: var(--gold); color: var(--ink); }

/* ---------- summon ---------- */
.banner { position: relative; border-radius: 20px; overflow: hidden; border: 1px solid var(--line); min-height: 340px; display: grid; }
.banner > .artbox { position: absolute; inset: 0; background: radial-gradient(circle at 50% 40%, #6b46c8 0%, #2b1860 45%, #150f2e 80%); }
.banner > .artbox.noart::before { content: ""; position: absolute; left: 50%; top: 42%; width: 240px; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; border: 2px solid #ffd36e66; box-shadow: 0 0 60px #ffd36e44, inset 0 0 40px #ffd36e33; animation: spin 40s linear infinite; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, #150f2ef2 100%); }
.banner .in { position: relative; z-index: 1; align-self: end; padding: 20px; display: grid; gap: 12px; }
.banner h2 { font-size: 1.7rem; }
.banner .feat { display: flex; gap: 8px; flex-wrap: wrap; }
.banner .feat span { padding: 3px 10px; border-radius: 999px; background: #0c0820b3; border: 1px solid var(--line); font-size: .82rem; }
.pullrow { display: flex; gap: 10px; flex-wrap: wrap; }
.pullrow .btn { flex: 1 1 180px; flex-direction: column; gap: 0; }
.pity { display: grid; gap: 6px; }
.bar { height: 8px; border-radius: 99px; background: #ffffff14; overflow: hidden; }
.bar > s { display: block; height: 100%; background: linear-gradient(90deg, var(--coral), var(--gold)); text-decoration: none; transition: width .3s; }
.rates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.rates div { text-align: center; padding: 8px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.rates b { display: block; font-family: var(--display); font-weight: 500; }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }

/* summon reveal */
.reveal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 40%, #3a2470f2, #0c0820fa 70%); overflow-y: auto; }
.reveal .in { width: min(820px, 100%); display: grid; gap: 18px; justify-items: center; }
.reveal h2 { font-size: 1.4rem; text-align: center; }
.reveal .grid { width: 100%; grid-template-columns: repeat(5, 1fr); }
.reveal.one .grid { grid-template-columns: minmax(0, 220px); justify-content: center; }
@media (max-width: 560px) { .reveal .grid { grid-template-columns: repeat(3, 1fr); } }
.reveal .card { opacity: 0; animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) forwards; animation-delay: calc(var(--i) * 110ms + 450ms); }
.reveal .card.r5 { animation-name: pop5; }
.reveal .card .new { position: absolute; z-index: 2; bottom: -8px; left: 50%; transform: translateX(-50%); padding: 1px 9px; border-radius: 999px; background: var(--coral); color: #3d0a20; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.reveal .card .new.dup { background: var(--panel-2); color: var(--gold); border: 1px solid var(--gold); }
@keyframes pop { from { opacity: 0; transform: translateY(30px) scale(.7) rotateY(80deg); } to { opacity: 1; transform: none; } }
@keyframes pop5 { 0% { opacity: 0; transform: scale(.4); filter: brightness(4); } 60% { opacity: 1; transform: scale(1.08); filter: brightness(1.8); } 100% { opacity: 1; transform: none; filter: none; } }
.meteor { position: fixed; z-index: 71; top: -40px; left: 70%; width: 4px; height: 160px; border-radius: 4px; background: linear-gradient(180deg, transparent, var(--mc, #fff)); transform: rotate(35deg); animation: fall .55s ease-in forwards; pointer-events: none; }
@keyframes fall { to { transform: translate(-60vw, 110vh) rotate(35deg); opacity: 0; } }

/* ---------- heroes ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* hero sheet */
.layer { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: #0c0820cc; backdrop-filter: blur(4px); }
.sheet { position: relative; width: min(760px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--night-2); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 60px #000b; }
.sheet.narrow { width: min(440px, 100%); padding: 20px; display: grid; gap: 12px; }
.sheet .x { position: absolute; z-index: 2; top: 10px; right: 10px; }
.hsheet { display: grid; grid-template-columns: 300px 1fr; }
.hsheet .artbox { aspect-ratio: 2 / 3; border-radius: 20px 0 0 20px; }
.hsheet .body { padding: 22px; display: grid; gap: 14px; align-content: start; }
.hsheet h2 { font-size: 1.6rem; }
.hsheet .sub { color: var(--muted); }
@media (max-width: 640px) {
  .hsheet { grid-template-columns: 1fr; }
  .hsheet .artbox { aspect-ratio: 4 / 3; border-radius: 20px 20px 0 0; }
  .hsheet .artbox img { object-position: 50% 18%; }
}
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.statgrid div { background: var(--panel); border-radius: 10px; padding: 8px; text-align: center; }
.statgrid small { display: block; color: var(--muted); font-size: .75rem; }
.statgrid b { font-family: var(--display); font-weight: 500; }
.statgrid .up { color: var(--mint); font-size: .75rem; display: block; }
.awk { display: flex; gap: 4px; font-size: 1.1rem; }
.awk i { font-style: normal; color: var(--dim); }
.awk i.on { color: var(--gold); text-shadow: 0 0 8px #ffd36e99; }
.skill { background: var(--panel); border-radius: 12px; padding: 10px 12px; font-size: .9rem; color: var(--muted); }
.skill b { color: var(--ink); font-weight: 500; }

/* ---------- tower ---------- */
.foes { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.foe { width: 92px; text-align: center; font-size: .78rem; color: var(--muted); }
.foe .artbox { width: 92px; aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--line); margin-bottom: 4px; }
.foe.boss .artbox { border-color: var(--coral); box-shadow: 0 0 18px #ff8fb855; }
.foe .fallback .glyph { font-size: 1.6rem; }
.compare { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; color: var(--muted); }
.compare b { color: var(--ink); font-family: var(--display); font-weight: 500; }
.compare .warn { color: var(--danger); }
.reward { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.reward span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- battle ---------- */
.battle { position: fixed; inset: 0; z-index: 80; display: grid; grid-template-rows: auto 1fr auto 1fr auto; gap: 10px; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); background: var(--night); overflow: hidden; }
.battle > .artbox { position: absolute; inset: 0; z-index: 0; background: linear-gradient(180deg, #2b1d5c, #150f2e); }
.battle > .artbox img { opacity: .55; }
.battle > *:not(.artbox) { position: relative; z-index: 1; }
.bhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bhead h2 { font-size: 1.1rem; }
.bhead .row { display: flex; gap: 6px; }
.side { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; }
.unit { position: relative; width: clamp(72px, 20vw, 120px); display: grid; gap: 4px; transition: transform .18s, opacity .4s, filter .4s; }
.unit .artbox { border-radius: 12px; border: 2px solid var(--line); }
.unit.hero .artbox { aspect-ratio: 3 / 4; border-color: var(--rc, var(--line)); }
.unit.hero .artbox img { object-position: 50% 15%; }
.unit.foe2 .artbox { aspect-ratio: 1; }
.unit.boss { width: clamp(110px, 30vw, 170px); }
.unit.boss .artbox { border-color: var(--coral); }
.unit .nm { font-size: .72rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.unit .hp { height: 7px; border-radius: 9px; background: #0008; overflow: hidden; }
.unit .hp s { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #3fd49a, var(--mint)); transition: width .3s; text-decoration: none; }
.unit.enemy .hp s { background: linear-gradient(90deg, #ff5f7e, var(--coral)); }
.unit .en { display: flex; gap: 3px; justify-content: center; }
.unit .en i { width: 6px; height: 6px; border-radius: 50%; background: #ffffff25; }
.unit .en i.on { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.unit.act { transform: translateY(-10px) scale(1.06); z-index: 3; }
.unit.enemy.act { transform: translateY(10px) scale(1.06); }
.unit.hit { animation: shake .3s; }
.unit.dead { opacity: .25; filter: grayscale(1); }
.unit.guard .artbox { box-shadow: 0 0 0 3px #7cc4ff, 0 0 16px #7cc4ff99; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.float { position: absolute; z-index: 4; left: 50%; top: 30%; transform: translateX(-50%); font-family: var(--display); font-weight: 600; font-size: 1.25rem; color: #fff; text-shadow: 0 2px 0 #000, 0 0 10px #000; pointer-events: none; animation: floatup .9s ease-out forwards; white-space: nowrap; }
.float.crit { color: var(--gold); font-size: 1.55rem; }
.float.heal { color: var(--mint); }
@keyframes floatup { from { opacity: 1; transform: translate(-50%, 0) scale(1.2); } to { opacity: 0; transform: translate(-50%, -40px) scale(1); } }
.blog { text-align: center; min-height: 1.6em; font-family: var(--display); color: var(--ink); text-shadow: 0 2px 8px #000; }
.blog small { color: var(--muted); margin-right: 8px; font-family: var(--body); }
.bresult { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: #0c0820b3; }
.bresult .sheet { padding: 24px; display: grid; gap: 14px; text-align: center; width: min(400px, 100%); }
.bresult h2 { font-size: 2rem; }
.bresult.win h2 { color: var(--gold); }
.bresult.lose h2 { color: var(--danger); }
.bresult .reward { justify-content: center; font-size: 1.05rem; }
.bresult .tips { color: var(--muted); font-size: .9rem; text-align: left; margin: 0; padding-left: 1.2em; }

/* ---------- toast ---------- */
.toast { position: fixed; z-index: 99; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--gold); box-shadow: 0 10px 30px #0009; text-align: center; }
@media (max-width: 760px) { .toast { bottom: calc(86px + env(safe-area-inset-bottom)); } }

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

/* ---------- base (lobby) ---------- */
.basehead { display: flex; justify-content: space-between; align-items: end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.basehead h2 { font-size: 1.7rem; }
.basehead p { color: var(--muted); font-size: .9rem; }
.basewrap { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .basewrap { grid-template-columns: 1fr; } }
.side-col { display: grid; gap: 16px; }
.fno { position: absolute !important; left: 0; top: 0; bottom: 0; width: 42px; display: grid; place-items: center; background: #0c0820b3; border-right: 1px solid var(--line); font-family: var(--display); color: var(--gold); font-size: .9rem; }
.fin { display: grid; gap: 3px; min-width: 0; }
.fin b { font-family: var(--display); font-weight: 500; font-size: 1.05rem; }
.fin b small { color: var(--gold); font-family: var(--body); font-size: .8rem; }
.fpend { font-size: .85rem; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.fin .bar { width: min(220px, 100%); height: 5px; }
.crew { display: flex; gap: 4px; }
.ava { position: relative; display: block; width: 44px; height: 44px; border-radius: 50%; overflow: hidden; border: 2px solid var(--rc, var(--line)); background: var(--panel); flex: none; }
.ava .artbox { position: absolute; inset: 0; }
.ava .artbox img { object-position: 50% 12%; transform: scale(1.6); transform-origin: 50% 10%; }
.ava .fallback .glyph { font-size: 1rem; }
.ava.empty { display: grid; place-items: center; border-style: dashed; color: var(--dim); background: #0c082080; font-size: 1.1rem; }
.avarow { display: flex; flex-wrap: wrap; gap: 10px; }
.avabtn { display: grid; justify-items: center; gap: 3px; width: 64px; padding: 0; border: 0; background: none; color: var(--muted); font-size: .72rem; text-align: center; }
.avabtn .ava { width: 52px; height: 52px; }
.avabtn:hover .ava { border-color: var(--gold); }
.avabtn small { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 8px; }
.up { color: var(--mint); font-size: .8rem; }
.inteam.job { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); }
@media (max-width: 480px) { .ava { width: 36px; height: 36px; } }

/* room sheet */
.rsheet { display: grid; }
.rsheet > .artbox { aspect-ratio: 16 / 7; border-radius: 20px 20px 0 0; background: linear-gradient(135deg, #3a2470, #1d1640); }
.rsheet > .artbox .fallback .glyph { font-size: 3.4rem; opacity: .5; }
.rsheet .body { padding: 18px 20px 22px; display: grid; gap: 14px; }
.rsheet h2 { font-size: 1.4rem; }
.rsheet .sub { color: var(--muted); font-size: .9rem; }
.buildlist { display: grid; gap: 8px; }
.buildopt { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); text-align: left; }
.buildopt:hover:not(:disabled) { border-color: var(--gold); }
.buildopt:disabled { opacity: .5; }
.buildopt .bi { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 1.4rem; background: var(--night); }
.buildopt b { display: block; font-family: var(--display); font-weight: 500; }
.buildopt small { color: var(--muted); font-size: .8rem; }

/* featured hero on the summon banner */
.featcard { position: absolute; z-index: 1; right: 18px; top: 18px; width: clamp(110px, 22%, 170px); }
.featcard .card.locked .frame { filter: none; border-color: var(--r5); }
@media (max-width: 560px) { .featcard { width: 96px; right: 12px; top: 12px; } }

/* ---------- death, souls, morale ---------- */
.ico.soul { width: 12px; height: 14px; border-radius: 50% 50% 45% 45%; background: radial-gradient(circle at 40% 35%, #ffffff, #9ff3ff 40%, #5b7bff 75%); box-shadow: 0 0 6px #9ff3ffaa; }
.cur.sm { padding: 2px 9px; font-size: .85rem; }
.card .status { position: absolute; z-index: 1; bottom: 44px; right: 6px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #0c0820d9; font-size: .8rem; }
.card .status.hurt { box-shadow: 0 0 0 1px var(--coral); }
.mtag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-family: var(--display); font-weight: 500; font-size: .9rem; background: var(--panel-2); border: 1px solid var(--line); }
.mtag.m-boss { color: var(--coral); border-color: #ff8fb877; }
.mtag.m-survive { color: var(--r3); } .mtag.m-escort { color: var(--mint); }
.odds { display: flex; align-items: baseline; gap: 10px; margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: var(--night); border: 1px solid var(--line); }
.odds b { font-family: var(--display); font-size: 1.7rem; font-weight: 500; }
.odds span:last-child { margin-left: auto; font-family: var(--display); }
.odds.safe b, .odds.safe span:last-child { color: var(--mint); }
.odds.ok b, .odds.ok span:last-child { color: var(--gold); }
.odds.risky b, .odds.risky span:last-child { color: var(--coral); }
.odds.deadly { border-color: var(--danger); } .odds.deadly b, .odds.deadly span:last-child { color: var(--danger); }
.toggle { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-size: .88rem; color: var(--ink); cursor: pointer; }
.toggle input { width: auto; margin-top: 4px; accent-color: var(--gold); }
.toggle small { color: var(--muted); }
.moralelist { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: .82rem; color: var(--muted); }
.mood { font-weight: 500; }
.mood.m0, .mood.m1 { color: var(--danger); } .mood.m2 { color: var(--gold); } .mood.m3, .mood.m4 { color: var(--mint); }
.vipfoe .artbox { border-color: var(--mint) !important; }
.unit.vip { width: clamp(64px, 16vw, 96px); }
.unit.vip .artbox { aspect-ratio: 1; border-color: var(--mint); }
.memorial { border-color: #5a4c8f; }
.graves { display: grid; gap: 8px; }
.grave { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: var(--night); }
.grave .ava { filter: grayscale(1) brightness(.8); }
.grave b { display: block; font-family: var(--display); font-weight: 500; }
.grave small { color: var(--muted); font-size: .78rem; }
.reviving { font-size: .78rem; color: #9ff3ff; text-align: right; }
.dead-list { display: flex; justify-content: center; gap: 12px; }
.dead-list > span { display: grid; justify-items: center; gap: 4px; font-size: .8rem; color: var(--muted); }
.dead-list .ava { width: 60px; height: 60px; filter: grayscale(1); }
@media (max-width: 760px) { .cur.souls { display: none; } }

/* ---------- unique heroes: commoner grades, shards, fusion ---------- */
.s1 { --rc: #9aa3b5; } .s2 { --rc: #7ee0a8; } .s6 { --rc: #ff8fb8; }
.card.s6 .frame { box-shadow: 0 0 0 1px #0006, 0 0 22px #ff8fb866, 0 8px 20px #0007; }
.ico.shard { width: 11px; height: 15px; background: linear-gradient(160deg, #fff3c4, #ffb86e 50%, #ff7aa8); clip-path: polygon(50% 0, 100% 40%, 70% 100%, 30% 100%, 0 40%); }
.rates small { display: block; color: var(--dim); font-size: .72rem; }
.banner .pity { margin-top: 4px; }
.banner .pity small { color: var(--muted); }
.avabtn.picked .ava { border-color: var(--danger); box-shadow: 0 0 0 3px #ff7a7a55; }
.avabtn.picked small { color: var(--danger); }
@media (max-width: 760px) { .cur.shards { display: none; } }
/* keep the guide-star card clear of the banner text */
.featcard { width: clamp(84px, 16%, 120px); }
.banner:has(.featcard) { min-height: 470px; }
@media (max-width: 560px) { .banner:has(.featcard) { min-height: 430px; } }

/* ---------- equipment, forge, daily dungeon ---------- */
.ico.ore { width: 14px; height: 12px; background: linear-gradient(150deg, #e0e6ff, #7b88c9 55%, #3d4677); clip-path: polygon(20% 0, 80% 0, 100% 55%, 70% 100%, 25% 100%, 0 50%); }
.wallet .cur { padding-inline: 10px; } .wallet .cur b { min-width: 2.5ch; }
@media (max-width: 760px) { .cur.ore { display: none; } }
.gearrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gearslot { display: grid; gap: 1px; padding: 8px; border-radius: 10px; border: 1px dashed var(--line); background: var(--night); text-align: left; min-width: 0; }
.gearslot b { font-family: var(--display); font-weight: 500; }
.gearslot small { color: var(--muted); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gearslot:hover { border-color: var(--gold); }
.gearslot.gC, .item.gC { --gc: #b9b2d6; } .gearslot.gB, .item.gB { --gc: #7ee0a8; } .gearslot.gA, .item.gA { --gc: #c79bff; } .gearslot.gS, .item.gS { --gc: #ffd36e; }
.gearslot[class*=" g"] { border-style: solid; border-color: var(--gc); }
.gearslot[class*=" g"] b { color: var(--gc); }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 0 10px; min-width: 0; align-items: center; }
/* item pictures (art/items/<slot>-<grade>.webp); the slot's icon shows until the picture exists */
.itemico { display: block; width: 40px; aspect-ratio: 1; flex: none; border: 1px solid color-mix(in srgb, var(--gc, #b9b2d6) 55%, transparent); background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--gc, #b9b2d6) 26%, transparent), #05081a 72%); }
.itemico > img.art { object-fit: contain; padding: 2px; }
.itemico .fallback { font-size: 1.05rem; color: var(--gc, #b9b2d6); }
.itemico.lg { width: 72px; } .itemico.lg .fallback { font-size: 1.8rem; }
.itemico.gC { --gc: #b9b2d6; } .itemico.gB { --gc: #7ee0a8; } .itemico.gA { --gc: #c79bff; } .itemico.gS { --gc: #ffd36e; }
.itemico.gS { box-shadow: 0 0 10px #ffd36e55; }
.item > .itemico { grid-row: 1 / span 3; align-self: start; }
.itemhead { display: flex; gap: 14px; align-items: center; } .itemhead h2 { margin: 0; }
.gearslot.has { grid-template-columns: 34px 1fr; gap: 1px 8px; align-items: center; }
.gearslot.has > .itemico { width: 34px; grid-row: 1 / span 2; }
.item b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item i { font-style: normal; font-family: var(--display); color: var(--gc); grid-row: span 2; align-self: center; font-size: 1.3rem; }
.item small { color: var(--muted); font-size: .78rem; }
.itemlist { display: grid; gap: 6px; max-height: 320px; overflow-y: auto; }
/* options ("ออฟ") on items */
.item .opts { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 3px; font-style: normal; font-size: .76rem; color: color-mix(in srgb, var(--gc, #b9b2d6) 75%, #fff); }
.item .opts span { white-space: nowrap; }
.rowbtns { display: flex; gap: 6px; align-items: center; }
.rowbtns .wearer { color: var(--muted); font-size: .76rem; max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gearslot .dots { margin-left: 5px; font-size: .55rem; letter-spacing: 1px; vertical-align: middle; opacity: .85; }
.optlist { display: grid; gap: 6px; }
.optrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 42px; padding: 6px 10px; border: 1px solid var(--line); background: var(--night); }
.optrow.empty { border-style: dashed; color: var(--dim); }
.optrow.locked { border-color: var(--gold); }
.optrow.fresh { animation: optIn .5s ease-out; }
@keyframes optIn { from { background: color-mix(in srgb, var(--gold) 35%, transparent); transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .optrow.fresh { animation: none; } }
.itemrow.dropped { grid-template-columns: auto 1fr; text-align: left; width: 100%; }
.droptag { font-family: var(--display); font-size: .78rem; letter-spacing: .08em; color: var(--gold); }
.itemrow { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--night); border-left: 3px solid var(--gc, var(--line)); }
.itemrow:has(.gS) { --gc: #ffd36e; } .itemrow:has(.gA) { --gc: #c79bff; } .itemrow:has(.gB) { --gc: #7ee0a8; } .itemrow:has(.gC) { --gc: #b9b2d6; }
.forge { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: #0c082066; border: 1px solid var(--line); }
.odds-row { display: flex; gap: 12px; flex-wrap: wrap; font-family: var(--display); font-size: .9rem; }
.dailygrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 700px) { .dailygrid { grid-template-columns: 1fr; } }
.dtier { display: grid; gap: 8px; padding: 14px; border-radius: 14px; background: var(--night); border: 1px solid var(--line); }
.dtier b { font-family: var(--display); font-weight: 500; font-size: 1.15rem; }
.dtier small { color: var(--muted); font-size: .82rem; }
.dtier.locked { opacity: .55; }
.weekrow { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; font-size: .82rem; color: var(--dim); }
.weekrow span { padding: 3px 8px; border-radius: 8px; background: var(--night); }
.weekrow span.on { background: var(--gold); color: var(--gold-ink); }

/* ---------- backup & guide ---------- */
.title-card { gap: 10px; }
.codebox { width: 100%; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--night); color: var(--ink); font: .78rem/1.4 ui-monospace, Menlo, monospace; word-break: break-all; resize: vertical; }
input[type=file] { padding: 8px; font-size: .85rem; }
.guide { margin-bottom: 16px; border-color: #ffd36e66; background: linear-gradient(135deg, #2e2560cc, #241c4dcc); }
.guide h3 small { color: var(--muted); font-family: var(--body); font-size: .85rem; margin-left: 6px; }
.gsteps { display: flex; gap: 6px; margin-bottom: 10px; }
.gsteps i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: .75rem; background: var(--night); color: var(--dim); border: 1px solid var(--line); }
.gsteps i.done { background: #7ef0c233; color: var(--mint); border-color: #7ef0c266; }
.gsteps i.cur { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.gnow { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.gnow b { font-family: var(--display); font-weight: 500; font-size: 1.05rem; }
.gact { display: flex; align-items: center; gap: 12px; }

/* ---------- goals & records ---------- */
.bonus { margin: 8px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--night); border: 1px dashed var(--line); font-size: .88rem; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.bonus .reward { margin-left: auto; font-size: .82rem; gap: 8px; }
.bonus.secret { border-color: #c79bff88; color: #d9c4ff; }
.bonus.done { border-style: solid; border-color: #7ef0c266; color: var(--mint); }
.lore { display: grid; gap: 10px; max-height: 60dvh; overflow-y: auto; }
.lore article { padding: 10px 12px; border-radius: 12px; background: var(--night); border-left: 3px solid var(--gold); }
.lore article b { font-family: var(--display); font-weight: 500; }
.lore article p { color: var(--muted); font-size: .9rem; margin-top: 4px; line-height: 1.6; }
.lore article.locked { border-left-color: var(--line); color: var(--dim); }

/* ---------- cloud sea ---------- */
.seawrap { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .seawrap { grid-template-columns: 1fr; } }
.ship { position: absolute; z-index: 2; transform: translate(-50%, -50%); font-style: normal; font-size: clamp(12px, 2vw, 20px); filter: drop-shadow(0 2px 3px #000); pointer-events: none; transition: left 1s linear, top 1s linear; }
.ship.back { transform: translate(-50%, -50%) scaleX(-1); }
.voy { display: grid; gap: 1px; padding: 8px 10px; border-radius: 10px; background: var(--night); margin-bottom: 6px; }
.voy b { font-family: var(--display); font-weight: 500; }
.voy span { color: var(--gold); font-size: .85rem; }
.voy small { color: var(--muted); font-size: .78rem; }
.sealog { display: grid; gap: 6px; max-height: 280px; overflow-y: auto; font-size: .85rem; }
.sealog p { margin: 0; padding: 6px 8px; border-radius: 8px; background: var(--night); }
.sealog p.win { border-left: 3px solid var(--mint); } .sealog p.lose { border-left: 3px solid var(--danger); }
.sealog small { color: var(--dim); margin-right: 4px; }
.avabtn.chosen .ava { border-color: var(--gold); box-shadow: 0 0 0 3px #ffd36e55; }
.avabtn.chosen small { color: var(--gold); }
@media (max-width: 760px) { .tabs button { font-size: .68rem; } }
/* five tabs plus five currencies: give the header room at medium widths */
@media (max-width: 1180px) and (min-width: 761px) { .brand { display: none; } .tabs button { padding: 8px 10px; } .tabs button i { display: none; } .wallet { gap: 5px; } .cur { padding: 4px 8px; } }

/* ---------- sign-in ---------- */
#signin { display: grid; gap: 10px; justify-items: center; }
/* Google's button is a light-mode iframe; inside our dark page the browser would paint a white box behind it unless its
   container is light too. */
#gbtn { min-height: 44px; color-scheme: light; display: flex; justify-content: center; }
#devLogin { display: grid; gap: 8px; width: 100%; padding-top: 10px; border-top: 1px dashed var(--line); }
#devLogin label { text-align: left; font-size: .85rem; color: var(--muted); }
.panel.nodock { margin-bottom: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-color: var(--gold); }

/* ---------- world chat & rankings ---------- */
.chatdock { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
@media (max-width: 760px) { .chatdock { bottom: calc(84px + env(safe-area-inset-bottom)); right: 10px; } }
.chatpill { position: relative; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--gold); background: #150f2ef0; color: var(--ink); font-family: var(--display); box-shadow: 0 6px 18px #0009; }
.chatpill:hover { background: var(--gold); color: var(--gold-ink); }
.chatpill .unread { position: absolute; top: -6px; right: -6px; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--coral); color: #3d0a20; font-size: .72rem; font-weight: 600; }
.chatbox { width: min(360px, calc(100vw - 20px)); height: min(440px, 60dvh); display: flex; flex-direction: column; border-radius: 16px; background: #1d1640f5; border: 1px solid var(--gold); box-shadow: 0 12px 34px #000b; overflow: hidden; }
.chatbox header { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.chatbox header .iconbtn { width: 30px; height: 30px; }
.chatlist { flex: 1; overflow-y: auto; padding: 8px 10px; display: grid; align-content: start; gap: 5px; font-size: .86rem; overflow-wrap: anywhere; }
.cm { margin: 0; }
.cm b { color: var(--gold); font-weight: 600; margin-right: 2px; }
.cm.me b { color: var(--mint); }
.cm.sys { color: #ffd98a; padding: 4px 8px; border-radius: 8px; background: #ffd36e14; }
.cm.sys b { color: var(--coral); }
#chatForm { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
#chatForm input { flex: 1; min-width: 0; padding: 7px 10px; }
/* Private chat: the conversation list, and the bar naming who you're talking to. */
.chtab .unread { margin-left: 5px; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--coral); color: #2a0513; font-size: .7rem; }
.dmbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); min-width: 0; }
.dmbar b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dmrow { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; width: 100%; padding: 7px 8px; border: 0; border-radius: 4px; background: #ffffff08; color: var(--ink); text-align: left; font: inherit; }
.dmrow:hover, .dmrow:focus-visible { background: #5fe1ff1f; }
.dmrow b { color: var(--sys, var(--gold)); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dmrow small { color: var(--muted); }
.dmrow span { grid-column: 1; color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dmrow .unread { grid-column: 2; grid-row: 1 / span 2; align-self: center; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--coral); color: #2a0513; font-size: .72rem; font-weight: 600; text-align: center; }
.dmrow.new span:not(.unread) { color: var(--ink); }
.chatlist .empty { margin: 0; color: var(--muted); font-size: .82rem; }
.ranklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 55dvh; overflow-y: auto; }
.ranklist li { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--night); }
.ranklist li.me { box-shadow: inset 0 0 0 1px var(--gold); background: #ffd36e14; }
.ranklist .rk { font-family: var(--display); color: var(--gold); text-align: center; }
.ranklist li:nth-child(n+4) .rk { color: var(--muted); }
.ranklist .rn b { display: block; font-family: var(--display); font-weight: 500; }
.ranklist .rn small { color: var(--muted); font-size: .78rem; }
.ranklist .rv { font-family: var(--display); }

/* ---------- tower floor picker ---------- */
.floorpick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.floorpick .now { font-family: var(--display); font-size: 2.4rem; line-height: 1; min-width: 3ch; text-align: center; }
.floorpick .now small { display: block; font-size: .8rem; color: var(--muted); }

/* ---------- screen change ---------- */
#view.enter > * { animation: viewin .32s ease-out both; }
#view.enter > *:nth-child(2) { animation-delay: .05s; }
#view.enter > *:nth-child(n+3) { animation-delay: .1s; }
@keyframes viewin { from { opacity: 0; transform: translateY(10px); } }

/* ---------- base scene: a floating keep you can pan and zoom ---------- */
.keep { position: relative; height: clamp(440px, 70dvh, 740px); overflow: hidden; border-radius: 20px; border: 1px solid var(--line); container-type: inline-size; user-select: none; -webkit-user-select: none; touch-action: pan-y;
  background: linear-gradient(180deg, #0f0a26cc 0%, #231859cc 46%, #4b2a79cc 80%, #8a4a8ecc 100%); }
.keep.pannable { cursor: grab; touch-action: none; }
.keep.dragging { cursor: grabbing; }
@media (max-width: 860px) { .keep { height: min(66dvh, 600px); min-height: 380px; } }
.keep-sky, .keep-front { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.keep-front { z-index: 3; }
/* the painted sky: a little larger than the view so it can drift a few pixels as the camera pans */
.keep-bg { position: absolute; left: -28px; top: -28px; width: calc(100% + 56px); height: calc(100% + 56px); object-fit: cover; object-position: 50% 45%;
  translate: clamp(-24px, calc(var(--px, 0px) * .04), 24px) clamp(-24px, calc(var(--py, 0px) * .04), 24px); animation: skyin .6s ease-out both; }
@keyframes skyin { from { opacity: 0; } }
@media (max-aspect-ratio: 3/4) { .keep-bg { object-position: 96% 45%; } } /* tall phones: show the moon's side of the picture */
.keep-sky.has-art .moon, .keep-sky.has-art .isle { display: none; }
.keep-sky.has-art .cloud { opacity: .1; }
.keep-sky.has-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, #04050d73 0, #04050d00 20%, #04050d00 70%, #04050d8c 100%); }
.keep-sky > i, .keep-front > i { position: absolute; display: block; }
.moon { top: 7%; right: 11%; width: 84px; height: 84px; border-radius: 50%; background: radial-gradient(circle at 38% 34%, #fffbe6, #ffe9a8 55%, #f3c56a); box-shadow: 0 0 40px 10px #ffd36e44, 0 0 120px 40px #c79bff33; translate: calc(var(--px, 0px) * .03) calc(var(--py, 0px) * .03); animation: glow 6s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 54px 16px #ffd36e55, 0 0 150px 56px #c79bff40; } }
.comet { top: 6%; left: 70%; width: 90px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, #fff, transparent); opacity: 0; rotate: -24deg; animation: comet 13s linear infinite; }
@keyframes comet { 0%, 88% { opacity: 0; transform: translateX(0); } 90% { opacity: 1; } 100% { opacity: 0; transform: translateX(-320px); } }
.cloud { left: 0; width: 240px; height: 64px; border-radius: 50%; filter: blur(3px);
  background: radial-gradient(ellipse 34% 60% at 28% 60%, #fff 0, transparent 70%), radial-gradient(ellipse 30% 76% at 52% 44%, #fff 0, transparent 70%), radial-gradient(ellipse 36% 54% at 74% 64%, #fff 0, transparent 70%);
  animation: cloud var(--t, 90s) linear var(--dl, 0s) infinite; }
@keyframes cloud { from { transform: translateX(-260px); } to { transform: translateX(100cqw); } }
.cloud.far { opacity: .16; scale: .7; translate: calc(var(--px, 0px) * .06) calc(var(--py, 0px) * .06); }
.cloud.mid { opacity: .26; translate: calc(var(--px, 0px) * .14) calc(var(--py, 0px) * .14); }
.cloud.near { opacity: .3; scale: 1.7; filter: blur(7px); translate: calc(var(--px, 0px) * .3) calc(var(--py, 0px) * .3); }
.c1 { top: 12%; --t: 150s; --dl: -40s; } .c2 { top: 34%; --t: 190s; --dl: -120s; }
.c3 { top: 56%; --t: 100s; --dl: -70s; } .c4 { top: 22%; --t: 120s; --dl: -15s; }
.c5 { bottom: 2%; --t: 70s; --dl: -30s; } .c6 { bottom: -4%; --t: 86s; --dl: -62s; }
.isle { width: 54px; height: 36px; background: linear-gradient(180deg, #4f8f8a 0 16%, #3d3274 16%, #1b1440); clip-path: polygon(0 12%, 100% 12%, 82% 46%, 60% 62%, 48% 100%, 34% 60%, 12% 44%); opacity: .55; animation: bob 9s ease-in-out infinite alternate; }
.i1 { top: 30%; left: 7%; translate: calc(var(--px, 0px) * .1) calc(var(--py, 0px) * .1); }
.i2 { top: 58%; right: 5%; scale: .7; animation-duration: 12s; translate: calc(var(--px, 0px) * .08) calc(var(--py, 0px) * .08); }
@keyframes bob { from { transform: translateY(-5px); } to { transform: translateY(5px); } }

.keep-world { position: absolute; left: 0; top: 0; width: 400px; transform-origin: 0 0; will-change: transform; z-index: 1; }
.keep-bob { padding: 16px 0 8px; animation: bob 7s ease-in-out infinite alternate; }
.spire { position: relative; height: 86px; }
.spire::before { content: ""; position: absolute; left: 50%; bottom: 0; width: 340px; height: 58px; translate: -50% 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); background: linear-gradient(180deg, #6a58b8, #3a2f78 70%, #2a2060); }
.spire::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 340px; height: 7px; translate: -50% 0; background: #ffd36e; opacity: .5; border-radius: 3px; }
.spire .star { position: absolute; left: 50%; top: 8px; translate: -50% 0; font-style: normal; font-size: 1.5rem; line-height: 1; color: var(--gold); text-shadow: 0 0 12px var(--gold), 0 0 30px #ffd36e99; animation: twinkle 2.6s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .75; scale: .92; } to { opacity: 1; scale: 1.12; } }
.spire .beam { position: absolute; left: 50%; top: 20px; width: 300px; height: 300px; translate: -50% -50%; border-radius: 50%; background: conic-gradient(from 0deg, #ffd36e33, transparent 9%, transparent 50%, #ffd36e22 54%, transparent 62%); animation: turn 16s linear infinite; pointer-events: none; mask: radial-gradient(circle, #000 0, transparent 68%); -webkit-mask: radial-gradient(circle, #000 0, transparent 68%); }
@keyframes turn { to { rotate: 360deg; } }
.spire .flag { position: absolute; left: calc(50% + 2px); top: 30px; width: 30px; height: 16px; background: linear-gradient(90deg, #ff8fb8, #ffb86e); clip-path: polygon(0 0, 100% 18%, 72% 50%, 100% 82%, 0 100%); transform-origin: 0 50%; animation: wave 2.2s ease-in-out infinite alternate; z-index: 1; }
@keyframes wave { from { transform: skewY(-7deg) scaleX(.94); } to { transform: skewY(7deg) scaleX(1.04); } }

.tower { position: relative; width: 312px; margin: 0 auto; display: grid; border-left: 7px solid #4a3d86; border-right: 7px solid #4a3d86; background: #171034; box-shadow: 0 0 44px #c79bff22; }
.deck { --rh: #c79bff; position: relative; display: block; width: 100%; height: 120px; padding: 8px 44px 0 46px; overflow: hidden; border: 0; border-top: 5px solid #5a4a9a; background: none; color: var(--ink); text-align: left; }
.room-hall { --rh: #ffd36e; } .room-mine { --rh: #f5b94a; } .room-observatory { --rh: #7cc4ff; } .room-training { --rh: #ff8f7a; }
.room-shrine { --rh: #ff8fb8; } .room-forge { --rh: #ff9a4a; } .room-dock { --rh: #7ef0c2; } .room-dorm { --rh: #c79bff; }
.deck > .artbox { position: absolute; inset: 0; background: linear-gradient(180deg, color-mix(in srgb, var(--rh) 26%, #1d1640) 0%, #1b1440 58%, #120c2b 100%); }
.deck > .artbox img { object-position: 50% 55%; }
.deck > .artbox .fallback { justify-items: end; align-items: end; padding: 0 14px 30px 0; }
.deck > .artbox .fallback .glyph { font-size: 2.9rem; line-height: 1; opacity: .34; filter: drop-shadow(0 0 12px var(--rh)); }
.deck::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, #120c2be6 0%, #120c2b99 48%, transparent 100%), linear-gradient(0deg, #0c0820cc 0, transparent 26px); }
.deck > *:not(.artbox) { position: relative; z-index: 1; }
.deck .fno { width: 36px; font-size: .8rem; }
.deck .fin b { font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck .fpend { font-size: .78rem; }
.deck .fin .bar { width: 150px; height: 4px; }
button.deck:hover > .artbox, button.deck:focus-visible > .artbox { filter: brightness(1.25); }
button.deck:hover, button.deck:focus-visible { box-shadow: inset 0 0 0 2px var(--gold); outline: none; }
.deck-lights { position: absolute !important; inset: 0; pointer-events: none; }
.deck-lights i { position: absolute; top: 0; width: 1px; height: 12px; background: #ffffff44; }
.deck-lights i::after { content: ""; position: absolute; left: -3px; top: 11px; width: 7px; height: 7px; border-radius: 50%; background: var(--rh); box-shadow: 0 0 10px 3px color-mix(in srgb, var(--rh) 70%, transparent); animation: flicker 3.4s ease-in-out infinite alternate; }
.deck-lights i:nth-child(1) { left: 44%; } .deck-lights i:nth-child(2) { left: 66%; height: 18px; } .deck-lights i:nth-child(3) { left: 86%; }
.deck-lights i:nth-child(2)::after { top: 17px; animation-delay: -1.2s; } .deck-lights i:nth-child(3)::after { animation-delay: -2.3s; }
@keyframes flicker { 0% { opacity: .55; } 45% { opacity: 1; } 60% { opacity: .7; } 100% { opacity: .95; } }
.deck.working::before { content: ""; position: absolute; z-index: 1; top: 0; bottom: 0; left: 0; width: 70px; background: linear-gradient(100deg, transparent, color-mix(in srgb, var(--rh) 30%, transparent), transparent); animation: sheen 5.5s ease-in-out infinite; pointer-events: none; }
@keyframes sheen { 0%, 55% { transform: translateX(-90px); } 100% { transform: translateX(330px); } }
.crewtag { position: absolute !important; top: 8px; right: 8px; padding: 1px 8px; border-radius: 999px; background: #0c0820cc; border: 1px solid var(--line); font-size: .7rem; color: var(--muted); }
.crewtag::before { content: "♟ "; color: var(--rh); }
.ready { position: absolute !important; right: 10px; top: 36px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #0c0820e6; border: 2px solid var(--gold); color: var(--gold); box-shadow: 0 0 14px #ffd36e88; animation: bounce 1s ease-in-out infinite alternate; }
@keyframes bounce { from { transform: translateY(2px); } to { transform: translateY(-5px); } }
.deck.ghost { height: 72px; padding: 0 12px; display: grid; place-items: center; text-align: center; border: 2px dashed var(--gold); border-bottom: 0; background: repeating-linear-gradient(135deg, #ffd36e14 0 12px, transparent 12px 24px); animation: ghost 2.4s ease-in-out infinite alternate; }
.deck.ghost::after { display: none; }
.deck.ghost .fin { justify-items: center; }
.deck.ghost b { color: var(--gold); }
.deck.ghost.locked { border-color: var(--line); opacity: .7; animation: none; background: repeating-linear-gradient(135deg, #ffffff0a 0 12px, transparent 12px 24px); }
.deck.ghost.locked b { color: var(--muted); }
@keyframes ghost { from { box-shadow: inset 0 0 0 0 #ffd36e00; } to { box-shadow: inset 0 0 26px 0 #ffd36e44; } }

.lane { position: absolute !important; left: 40px; right: 6px; bottom: 4px; height: 40px; container-type: inline-size; pointer-events: none; }
.spr { position: absolute; bottom: 0; left: calc(var(--a) * 1%); width: 26px; height: 38px; padding: 0; border: 0; background: none; animation: stroll var(--t) linear var(--dl) infinite; }
.spr::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: -3px; height: 5px; border-radius: 50%; background: #0008; }
.spr-in { position: absolute; inset: 0; z-index: 1; display: grid; justify-items: center; align-content: end; padding-bottom: 4px; animation: hop .46s ease-in-out infinite alternate; }
.spr .ava { width: 24px; height: 24px; border-width: 2px; z-index: 1; }
.spr-body { position: relative; display: block; width: 14px; height: 9px; margin-top: -3px; border-radius: 5px 5px 3px 3px; background: var(--hue); box-shadow: inset 0 -3px 0 #0003; }
.spr-body::before, .spr-body::after { content: ""; position: absolute; bottom: -4px; width: 4px; height: 5px; border-radius: 0 0 2px 2px; background: #2a2050; animation: leg .46s ease-in-out infinite alternate; }
.spr-body::before { left: 2px; } .spr-body::after { right: 2px; animation-direction: alternate-reverse; }
.spr-tag { position: absolute; top: -4px; right: -8px; z-index: 2; font-style: normal; font-size: .7rem; }
.spr.hurt { animation: none; }
.spr.hurt .spr-in { animation: none; filter: saturate(.5); }
.spr.hurt .spr-body::before, .spr.hurt .spr-body::after { animation: none; }
button.spr { pointer-events: auto; cursor: pointer; }
button.spr:hover .ava, button.spr:focus-visible .ava { border-color: var(--gold); box-shadow: 0 0 10px var(--gold); }
@keyframes stroll {
  0%, 5% { transform: translateX(0) scaleX(1); }
  45% { transform: translateX(calc(var(--w) * 1cqw)) scaleX(1); }
  50%, 55% { transform: translateX(calc(var(--w) * 1cqw)) scaleX(-1); }
  95% { transform: translateX(0) scaleX(-1); }
  100% { transform: translateX(0) scaleX(1); }
}
@keyframes hop { from { transform: translateY(0); } to { transform: translateY(-2px); } }
@keyframes leg { from { transform: translateY(0); } to { transform: translateY(-2px); } }

/* walkers on an island (main.js roamer): they go out along --dx/--dy and come back mirrored */
.spr.roam { bottom: auto; width: 30px; height: 44px; animation-name: roam; }
.spr.roam .ava { width: 28px; height: 28px; }
.spr.roam .spr-body { width: 16px; height: 11px; }
.spr.roam.talking { z-index: 300 !important; }
@keyframes roam {
  0%, 5% { translate: 0 0; scale: 1 1; }
  45% { translate: var(--dx) var(--dy); scale: 1 1; }
  50%, 55% { translate: var(--dx) var(--dy); scale: -1 1; }
  95% { translate: 0 0; scale: -1 1; }
  100% { translate: 0 0; scale: 1 1; }
}
.rock { position: relative; height: 200px; }
.rock svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 18px 24px #0009); }
.rock .xtal path { fill: url(#xtalFill); filter: drop-shadow(0 0 6px #ffb86e); animation: flicker 4.5s ease-in-out infinite alternate; }
.dust { position: absolute; top: 62%; width: 3px; height: 3px; border-radius: 50%; background: #ffe9b0; box-shadow: 0 0 8px #ffd36e; opacity: 0; animation: dust 4.6s linear infinite; }
.dust.d1 { left: 30%; } .dust.d2 { left: 51%; top: 86%; animation-delay: -1.7s; } .dust.d3 { left: 68%; animation-delay: -3.1s; }
@keyframes dust { 0% { opacity: 0; transform: translateY(0); } 15% { opacity: .9; } 100% { opacity: 0; transform: translateY(70px); } }

.keep-ui { position: absolute; z-index: 4; right: 10px; top: 10px; display: grid; gap: 6px; }
.keep-ui .iconbtn { width: 36px; height: 36px; background: #0c0820cc; backdrop-filter: blur(6px); font-family: var(--display); }
.keep-hint { position: absolute; z-index: 4; left: 10px; bottom: 8px; max-width: calc(100% - 20px); padding: 2px 10px; border-radius: 999px; background: #0c0820b3; color: var(--muted); font-size: .72rem; pointer-events: none; }

/* ---------- tower: the climbing path ---------- */
.towerview { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-areas: "detail map" "detail team"; gap: 16px; align-items: start; }
.t-map { grid-area: map; } .t-detail { grid-area: detail; } .t-team { grid-area: team; }
@media (max-width: 760px) { .towerview { grid-template-columns: minmax(0, 1fr); grid-template-areas: "map" "detail" "team"; } }
.tmap { position: relative; aspect-ratio: 5 / 6; margin-top: 12px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line);
  background: repeating-linear-gradient(0deg, #ffffff07 0 1px, transparent 1px 34px), linear-gradient(180deg, #33246e 0%, #1d1640 55%, #120c2b 100%); }
@media (max-width: 760px) { .tmap { aspect-ratio: 4 / 5; } }
.tmap > .artbox { position: absolute; inset: 0; background: none; opacity: .3; }
.tmap > .artbox img { animation: drift 34s ease-in-out infinite alternate; }
.tmap::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 40%, #0c0820cc 100%); }
.tmap-fx { position: absolute; inset: 0; pointer-events: none; }
.tmap-fx i { position: absolute; display: block; }
.tmap-fx .win { width: 26px; height: 42px; border-radius: 13px 13px 3px 3px; background: linear-gradient(180deg, #7cc4ff66, #c79bff22); box-shadow: 0 0 22px #7cc4ff55; animation: flicker 5s ease-in-out infinite alternate; }
.win.w1 { left: 8%; top: 52%; } .win.w2 { right: 9%; top: 26%; animation-delay: -2s; } .win.w3 { left: 46%; top: 6%; scale: .8; animation-delay: -3.4s; }
.tmap-fx .mote { bottom: 0; width: 3px; height: 3px; border-radius: 50%; background: #ffe9b0; box-shadow: 0 0 8px #ffd36e; opacity: 0; animation: rise 9s linear infinite; }
.mote.m1 { left: 14%; } .mote.m2 { left: 36%; animation-delay: -3s; } .mote.m3 { left: 58%; animation-delay: -5.5s; } .mote.m4 { left: 78%; animation-delay: -1.6s; } .mote.m5 { left: 90%; animation-delay: -7s; }
@keyframes rise { 0% { opacity: 0; transform: translate(0, 0); } 12% { opacity: .9; } 100% { opacity: 0; transform: translate(18px, -440px); } }
@keyframes drift { from { transform: scale(1.04); } to { transform: scale(1.12) translate(-1.5%, -1%); } }
.tpath { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.tpath path { fill: none; stroke: #ffffff59; stroke-width: 5px; stroke-linecap: round; stroke-dasharray: 1 10; }
.tpath path.open { stroke: #ffd36ecc; animation: march 1.2s linear infinite; }
.tpath path.done { stroke: #7ef0c2aa; stroke-dasharray: none; stroke-width: 4px; }
@keyframes march { to { stroke-dashoffset: -11; } }
.tnode { position: absolute; z-index: 2; width: 42px; height: 42px; padding: 0; translate: -50% -50%; border-radius: 50%; border: 2px solid var(--line); background: var(--panel-2); color: var(--muted); font-family: var(--display); font-size: .9rem; display: grid; place-items: center; box-shadow: 0 4px 0 #0c0820, 0 8px 14px #0008; transition: transform .12s; }
.tnode b { font-weight: 500; }
.tnode:not(:disabled):hover { transform: translateY(-2px); border-color: var(--gold); }
.tnode:not(:disabled):active { transform: translateY(2px); box-shadow: 0 2px 0 #0c0820; }
.tnode.done { border-color: var(--mint); color: var(--mint); background: #1c3550; }
.tnode.boss { width: 50px; height: 50px; border-color: var(--coral); border-radius: 16px; background: #4a1838; color: #ffd0e0; }
.tnode.boss.done { background: #1c3550; color: var(--mint); }
.tnode .crown { position: absolute; top: -13px; left: 50%; translate: -50% 0; font-style: normal; font-size: .8rem; color: var(--coral); text-shadow: 0 0 8px var(--coral); }
.tnode .pip { position: absolute; top: -2px; right: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.tnode.cur { background: var(--gold); color: var(--gold-ink); border-color: #fff3c4; }
.tnode.cur::after { content: ""; position: absolute; inset: -7px; border-radius: inherit; border: 2px solid var(--gold); animation: ring 1.4s ease-out infinite; pointer-events: none; }
@keyframes ring { from { opacity: .9; transform: scale(.85); } to { opacity: 0; transform: scale(1.3); } }
.tnode.locked { opacity: .8; border-style: dashed; box-shadow: none; background: #1d1640; color: var(--dim); }
.tgate { position: absolute; z-index: 2; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); background: #0c0820cc; color: var(--muted); font-size: .74rem; font-family: var(--display); }
.tgate.up { top: 8px; right: 8px; } .tgate.down { bottom: 8px; left: 8px; }
button.tgate:not(:disabled) { color: var(--gold); border-color: #ffd36e88; }
button.tgate:not(:disabled):hover { background: #ffd36e22; }
button.tgate:disabled { opacity: .5; }
.tgate.summit { color: var(--gold); }
.tparty { --hop: 300ms; position: absolute; z-index: 3; display: flex; justify-content: center; translate: -50% calc(-100% - 16px); pointer-events: none; transition: left var(--hop) linear, top var(--hop) linear; animation: bob 1.6s ease-in-out infinite alternate; filter: drop-shadow(0 4px 4px #000a); }
.tparty .ava { width: 24px; height: 24px; border-width: 2px; margin-left: -8px; }
.tparty .ava:first-of-type { margin-left: 0; }
.tparty .pennant { position: absolute; left: 50%; bottom: 100%; width: 2px; height: 12px; background: #fff3c4; }
.tparty .pennant::after { content: ""; position: absolute; left: 2px; top: 0; width: 13px; height: 9px; background: var(--coral); clip-path: polygon(0 0, 100% 50%, 0 100%); transform-origin: 0 50%; animation: wave 1.2s ease-in-out infinite alternate; }
.tparty.empty .pennant { position: relative; left: auto; bottom: auto; }
.tparty.walking { animation: hop .22s ease-in-out infinite alternate; }
.tparty.flip { scale: -1 1; }

/* ---------- ambient motion on other screens ---------- */
.banner > .artbox img, .title-art img { animation: drift 32s ease-in-out infinite alternate; }
.motes { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.motes .mote { position: absolute; bottom: -8px; left: var(--x); width: var(--sz); height: var(--sz); border-radius: 50%; background: #ffe9b0; box-shadow: 0 0 8px #ffd36e; opacity: 0; animation: rise var(--d) linear var(--dl) infinite; }
.motes .sigil { position: absolute; left: 50%; top: 36%; width: min(64%, 280px); aspect-ratio: 1; translate: -50% -50%; border-radius: 50%; border: 1px dashed #ffd36e66; box-shadow: inset 0 0 40px #ffd36e22, 0 0 50px #c79bff33; animation: turn 48s linear infinite; }
.motes .sigil::before { content: ""; position: absolute; inset: 14%; border-radius: 50%; border: 1px solid #c79bff55; border-left-color: transparent; border-right-color: transparent; animation: turn 20s linear infinite reverse; }
@keyframes seadrift { from { transform: translateX(-4%); } to { transform: translateX(4%); } }
.ship { animation: shipbob 2.4s ease-in-out infinite alternate; }
@keyframes shipbob { from { margin-top: -2px; } to { margin-top: 2px; } }

@media (prefers-reduced-motion: reduce) {
  .keep *, .keep *::before, .keep *::after, .tmap *, .tmap *::before, .tmap *::after, .motes *, .motes *::before,
  .banner > .artbox img, .title-art img, .ship, .tile.islet, #view.enter > * { animation: none !important; }
  .comet, .dust, .mote { display: none; }
}

/* ---------- game frame: a floating HUD over the base, a back bar on every other screen ---------- */
.top-in { max-width: none; gap: 10px; }
.wallet { margin-left: auto; }
.plate, .backbtn, .screen-name, .dock { display: none; }
.backbtn { align-items: center; gap: 6px; padding: 7px 14px 7px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-family: var(--display); white-space: nowrap; }
.backbtn i { font-style: normal; font-size: 1.25rem; line-height: 1; color: var(--gold); }
.backbtn:hover { border-color: var(--gold); }
.screen-name { min-width: 0; font-family: var(--display); font-weight: 500; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body:not([data-view="home"]) .backbtn { display: inline-flex; }
body:not([data-view="home"]) .screen-name { display: block; }
@media (max-width: 760px) { main#view { padding-bottom: calc(72px + env(safe-area-inset-bottom)); } }
@media (max-width: 420px) { .screen-name { display: none !important; } }

body[data-view="home"] { overflow: hidden; }
body[data-view="home"] .top { position: fixed; left: 0; right: 0; top: 0; background: none; border: 0; backdrop-filter: none; pointer-events: none; }
body[data-view="home"] .top-in { padding: 10px 12px; }
body[data-view="home"] .top-in > * { pointer-events: auto; }
body[data-view="home"] .cur, body[data-view="home"] .wallet .iconbtn { background: #0c0820cc; }
body[data-view="home"] .plate { display: flex; }
.plate { align-items: center; gap: 8px; min-width: 0; max-width: 270px; padding: 5px 14px 5px 6px; border-radius: 999px; border: 1px solid #ffd36e88; background: #0c0820cc; text-align: left; }
.plate:hover { border-color: var(--gold); }
.plate-star { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(180deg, #ffe08f, #f5b94a); color: var(--gold-ink); font-style: normal; box-shadow: 0 0 12px #ffd36e66; }
.plate-txt { display: grid; min-width: 0; line-height: 1.2; }
.plate-txt b { font-family: var(--display); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plate-txt small { color: var(--muted); font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body[data-view="home"] main#view { max-width: none; padding: 0; }
body[data-view="home"] .keep { position: fixed; inset: 0; height: auto; min-height: 0; border: 0; border-radius: 0; }

body[data-view="home"] .dock { display: flex; }
.dock { position: fixed; z-index: 30; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); gap: 8px; align-items: stretch; }
.dock button { display: grid; justify-items: center; align-content: center; gap: 2px; min-width: 78px; padding: 8px 10px; border-radius: 16px; border: 1px solid var(--line); background: #150f2eea; color: var(--ink); font-family: var(--display); font-size: .82rem; box-shadow: 0 4px 0 #0c0820, 0 10px 20px #0008; transition: transform .08s, border-color .15s; }
.dock button i { font-style: normal; font-size: 1.5rem; line-height: 1.1; }
.dock button:hover { border-color: var(--gold); transform: translateY(-2px); }
.dock button:active { transform: translateY(2px); box-shadow: 0 2px 0 #0c0820; }
.dock button.main { min-width: 136px; background: linear-gradient(180deg, #ffe08f, #f5b94a); color: var(--gold-ink); border-color: #ffe08f; box-shadow: 0 4px 0 #a8731f, 0 10px 22px #f5b94a40; }
.dock button.main:active { box-shadow: 0 2px 0 #a8731f; }
.dock button.hot { border-color: var(--coral); animation: hot 1s ease-in-out infinite alternate; }
@keyframes hot { to { box-shadow: 0 4px 0 #0c0820, 0 0 22px 4px #ff8fb888; } }
@media (max-width: 760px) {
  .dock { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .dock button { flex: 1; min-width: 0; padding: 7px 4px; font-size: .72rem; }
  .dock button.main { flex: 1.6; min-width: 0; }
}

.hud { position: absolute; z-index: 4; }
.rail { top: 66px; display: grid; gap: 8px; justify-items: start; }
.rail.left { left: 12px; }
.rail.right { right: 12px; justify-items: end; }
.railbtn { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 44px; max-width: 240px; padding: 0 14px 0 8px; border-radius: 999px; border: 1px solid var(--line); background: #0c0820cc; color: var(--ink); font-size: .85rem; }
.railbtn i { flex: none; width: 28px; height: 28px; display: grid; place-items: center; font-style: normal; font-size: 1.15rem; }
.railbtn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.railbtn:hover { border-color: var(--gold); }
.railbtn.quest { border-color: #ffd36e88; }
.railbtn.quest.claim { background: var(--gold); color: var(--gold-ink); border-color: #fff3c4; animation: bounce 1s ease-in-out infinite alternate; }
.railbtn .dot { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center; background: var(--coral); color: #3d0a20; font-size: .72rem; font-weight: 600; }
.rail.right .railbtn { flex-direction: row-reverse; padding: 0 8px 0 14px; }
.rail.right .railbtn .dot { right: auto; left: -5px; }
.rail .keep-ui { position: static; margin-top: 10px; }
@media (max-width: 760px) {
  .rail { top: 60px; }
  .railbtn, .rail.right .railbtn { width: 44px; padding: 0; justify-content: center; }
  .railbtn span { display: none; }
}
.hud.collect { right: 14px; bottom: calc(96px + env(safe-area-inset-bottom)); animation: bounce 1.1s ease-in-out infinite alternate; }
@media (max-width: 760px) { .hud.collect { right: 8px; bottom: calc(82px + env(safe-area-inset-bottom)); } }
body[data-view="home"] .keep-hint { left: 50%; bottom: auto; top: 66px; translate: -50% 0; max-width: calc(100% - 132px); border-radius: 12px; text-align: center; animation: hintout .6s ease-in 6s forwards; }
@keyframes hintout { to { opacity: 0; visibility: hidden; } }

.chatdock { right: auto; left: 14px; align-items: flex-start; }
@media (max-width: 760px) {
  .chatdock { right: auto; left: 10px; bottom: calc(16px + env(safe-area-inset-bottom)); }
  body[data-view="home"] .chatdock { bottom: calc(82px + env(safe-area-inset-bottom)); }
}

/* ---------- mailbox ---------- */
.maillist { display: grid; gap: 8px; max-height: 52dvh; overflow-y: auto; }
.mail { padding: 10px 12px; border-radius: 12px; background: var(--night); border: 1px solid var(--line); }
.mail header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 2px; }
.mail header b { font-family: var(--display); font-weight: 500; }
.mail header small { color: var(--dim); font-size: .75rem; white-space: nowrap; }
.mail p { font-size: .88rem; color: var(--muted); }
.mail.win header b { color: var(--mint); }
.mail.lose header b { color: var(--danger); }
.mail.new { border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold); }

/* ---------- the system's voice: cold windows and notices ---------- */
:root { --sys: #8fd8ff; --paper: #fffdf4; --inkline: #1a1030; }
.sheet { border-color: #8fd8ff66; border-radius: 14px; background: linear-gradient(180deg, #1b1c4c 0, var(--night-2) 110px); box-shadow: 0 0 0 1px #0c0820, 0 0 30px #8fd8ff22, 0 24px 60px #000b; }
.sys-tag { justify-self: start; padding-right: 44px; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .7rem; letter-spacing: .14em; color: var(--sys); text-shadow: 0 0 8px #8fd8ff66; }
.sysline { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .82rem; color: var(--sys); }
.toast { border-color: #8fd8ff99; border-radius: 6px; background: #12143af2; box-shadow: 0 0 22px #8fd8ff33, 0 10px 30px #0009; }
.toast::before { content: "◈ "; color: var(--sys); }

/* ---------- the heroes' voice: paper bubbles ---------- */
.saybox { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; text-align: left; margin-top: 10px; }
.saybox p { position: relative; padding: 6px 12px 7px; border-radius: 12px; background: var(--paper); color: #23183f; border: 2px solid var(--inkline); box-shadow: 3px 3px 0 #0c082099; font-size: .9rem; line-height: 1.4; }
.saybox p::before { content: ""; position: absolute; left: -9px; top: 50%; translate: 0 -50%; border: 6px solid transparent; border-right-color: var(--inkline); border-left: 0; }
.saybox p b { display: block; font-family: var(--display); font-weight: 500; font-size: .72rem; color: #6a4fb0; }
.bub { position: absolute; z-index: 6; bottom: 100%; left: -4px; margin-bottom: 5px; width: max-content; max-width: 150px; padding: 3px 8px 4px; border-radius: 10px; background: var(--paper); color: #23183f; border: 2px solid var(--inkline); box-shadow: 2px 2px 0 #0c082099; font-family: var(--body); font-size: .7rem; font-weight: 500; line-height: 1.3; text-align: left; white-space: normal; pointer-events: none; }
.bub::after { content: ""; position: absolute; left: 12px; top: 100%; border: 5px solid transparent; border-top-color: var(--inkline); border-bottom: 0; }
.spr .bub { animation: unflip var(--t) linear var(--dl) infinite; }
.spr.far .bub { left: auto; right: -4px; }
.spr.far .bub::after { left: auto; right: 12px; }
.spr.hurt .bub { animation: none; }
@keyframes unflip { 0%, 47% { scale: 1 1; } 50%, 97% { scale: -1 1; } 100% { scale: 1 1; } }

/* ---------- battle stage: the team walks in, fights side-on, big moves cut across like a comic panel ---------- */
.battle.stage { grid-template-rows: auto minmax(0, 1fr) auto auto; }
.bfield { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 3vw; min-height: 0; padding: 0 2vw 5vh; }
.bfield::before { content: ""; position: absolute; left: -14px; right: -14px; bottom: 0; height: 46%; background: radial-gradient(ellipse 70% 100% at 50% 100%, #0c0820d9, transparent 72%); pointer-events: none; }
.bside { position: relative; display: grid; grid-template-columns: repeat(2, auto); gap: 18px 12px; justify-content: center; align-content: center; transition: transform 1.25s cubic-bezier(.25, .6, .35, 1), opacity .5s; }
.bside > .unit:nth-child(odd) { translate: 0 16px; }
.battle.pre .bside.heroes { transform: translateX(-75vw); transition: none; }
.battle.pre .bside.foes, .battle.walk .bside.foes { opacity: 0; }
.battle.walk .bside.foes { transition-delay: .8s; opacity: 1; }
.stage .unit { width: clamp(64px, 17vw, 104px); justify-items: center; gap: 3px; }
.stage .unit .hp { width: 100%; height: 6px; }
.stage .unit .nm { width: 100%; font-size: .68rem; }
.fig { position: relative; display: grid; justify-items: center; width: 100%; margin-top: 2px; transition: transform .35s, filter .35s; animation: breathe 2.4s ease-in-out infinite alternate; }
.fig::after { content: ""; position: absolute; left: 14%; right: 14%; bottom: -7px; height: 9px; border-radius: 50%; background: #000a; z-index: -1; }
@keyframes breathe { from { translate: 0 0; } to { translate: 0 -3px; } }
.stage .hero .fig .ava { width: clamp(46px, 12vw, 72px); height: clamp(46px, 12vw, 72px); border-width: 3px; z-index: 1; }
.stage .hero .ava .artbox { border: 0; border-radius: 0; aspect-ratio: auto; }
.stage .hero .fig .spr-body { width: 54%; height: clamp(14px, 3.4vw, 22px); margin-top: -7px; border-radius: 9px 9px 5px 5px; }
.stage .spr-body::before, .stage .spr-body::after { width: 26%; height: 8px; bottom: -7px; animation: none; }
.stage.walk .hero .spr-body::before, .stage.walk .hero .spr-body::after { animation: leg .2s ease-in-out infinite alternate; }
.stage.walk .hero .spr-body::after { animation-direction: alternate-reverse; }
.stage.walk .hero .fig { animation: hop .2s ease-in-out infinite alternate; }
.stage .enemy .fig .artbox { width: 100%; aspect-ratio: 1; border-radius: 40% 40% 30% 30%; }
.stage .unit.boss { width: clamp(110px, 30vw, 170px); grid-column: span 2; justify-self: center; translate: 0 0; }
.stage .unit.vip .fig .ava { width: clamp(38px, 10vw, 56px); height: clamp(38px, 10vw, 56px); border-color: var(--mint); }
.stage .unit.hero.act { transform: translateX(28px) scale(1.08); }
.stage .unit.enemy.act { transform: translateX(-28px) scale(1.08); }
.stage .unit.hit .fig { animation: flash .3s ease-out, breathe 2.4s ease-in-out infinite alternate; }
@keyframes flash { 0%, 55% { filter: brightness(2.3) saturate(.4); } 100% { filter: none; } }
.battle.stage > .bresult { position: absolute; inset: 0; z-index: 8; }
.stage .unit.dead { opacity: 1; filter: none; }
.stage .unit.dead .fig { animation: none; filter: grayscale(1) brightness(.6); }
.stage .unit.hero.dead .fig { transform: rotate(82deg) translate(12px, 6px); }
.stage .unit.enemy.dead .fig { transform: scale(.55); opacity: .2; }
.stage .unit.dead .hp, .stage .unit.dead .en { opacity: .3; }
.stage .unit .bub { left: 50%; translate: -50% 0; bottom: calc(100% - 22px); font-size: .76rem; }
.stage .unit .bub::after { left: 50%; translate: -50% 0; }
.bcap { position: absolute; z-index: 4; left: 50%; top: 3%; translate: -50% 0; width: max-content; max-width: min(88%, 460px); padding: 7px 14px 8px; background: var(--paper); color: #23183f; border: 2px solid var(--inkline); box-shadow: 4px 4px 0 #0c0820; font-size: .92rem; line-height: 1.4; transition: opacity .4s, translate .4s; }
.bcap small { display: block; font-family: var(--display); font-size: .72rem; color: #6a4fb0; }
.bcap.gone { opacity: 0; translate: -50% -12px; }
.bsys { min-height: 1.5em; text-align: center; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .8rem; color: var(--sys); text-shadow: 0 0 10px #8fd8ff66, 0 2px 6px #000; }
.bsys.ping { animation: ping .5s ease-out; }
@keyframes ping { from { opacity: 0; letter-spacing: .3em; } }
.cutin { position: absolute; z-index: 7; left: -20px; right: -20px; top: 30%; height: min(34%, 190px); display: flex; align-items: center; gap: 4vw; padding: 0 8vw; overflow: hidden; transform: skewY(-5deg); border-top: 4px solid var(--inkline); border-bottom: 4px solid var(--inkline); box-shadow: 0 0 0 2px var(--paper), 0 14px 40px #000c; animation: cutin .34s cubic-bezier(.2, .9, .3, 1);
  background: repeating-linear-gradient(100deg, #ffffff1f 0 2px, transparent 2px 22px), linear-gradient(90deg, #5b3fd0, #2b1860); }
.cutin.foe { flex-direction: row-reverse; background: repeating-linear-gradient(80deg, #ffffff1f 0 2px, transparent 2px 22px), linear-gradient(270deg, #b02a5c, #3a0c24); }
.cutin .pic { flex: none; height: 130%; aspect-ratio: 1; }
.cutin .pic .artbox { width: 100%; height: 100%; background: none; }
.cutin .pic .artbox img { object-position: 50% 14%; }
.cutin .txt { display: grid; transform: skewY(5deg); min-width: 0; }
.cutin .txt b { font-family: var(--display); font-weight: 600; font-style: italic; font-size: clamp(1.4rem, 6vw, 2.6rem); line-height: 1.15; color: #fff; text-shadow: 3px 3px 0 var(--inkline), 0 0 24px #ffd36e88; }
.cutin .txt small { font-size: clamp(.85rem, 3vw, 1.1rem); color: #ffe9b0; text-shadow: 2px 2px 0 var(--inkline); }
@keyframes cutin { from { opacity: 0; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0 0 0 0); } }
.bresult .sheet .sys-tag { justify-self: center; padding: 0; }
.bresult .saybox { margin-top: 0; }
.bresult.death { background: #050308e6; animation: dusk 1.2s ease-out; }
.bresult.death .sheet { border-color: #ff7a7a88; box-shadow: 0 0 0 1px #0c0820, 0 0 40px #ff7a7a22, 0 24px 60px #000b; }
.bresult.death .dead-list .ava { animation: fadegrey 1.6s ease-out both; }
@keyframes dusk { from { background: #05030800; } }
@keyframes fadegrey { from { filter: none; } to { filter: grayscale(1); } }
@media (prefers-reduced-motion: reduce) {
  .fig, .cutin, .bsys.ping, .bresult.death, .bresult.death .dead-list .ava, .spr .bub { animation: none !important; }
  .bside { transition: none; }
}

/* ---------- summoning scene: the circle answers, then each arrival steps out of the light ---------- */
.reveal.scene { --glow: #7cc4ff; display: grid; grid-template-rows: minmax(0, 1fr) auto; place-items: center; gap: 14px; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); overflow: hidden; background: radial-gradient(circle at 50% 62%, color-mix(in srgb, var(--glow) 26%, #1a1040) 0, #0c0820 58%, #05030c 100%); cursor: pointer; }
.rit { position: absolute; left: 50%; bottom: 14%; width: min(78vw, 440px); aspect-ratio: 1; translate: -50% 38%; pointer-events: none; }
.rit-floor { position: absolute; inset: 0; transform: perspective(700px) rotateX(66deg); }
.ring { position: absolute; border-radius: 50%; border: 2px solid var(--glow); box-shadow: 0 0 26px var(--glow), inset 0 0 26px color-mix(in srgb, var(--glow) 50%, transparent); }
.ring.r1 { inset: 0; border-style: dashed; animation: turn 18s linear infinite; }
.ring.r2 { inset: 13%; border-width: 3px; border-left-color: transparent; border-right-color: transparent; animation: turn 7s linear infinite reverse; }
.ring.r3 { inset: 30%; background: radial-gradient(circle, color-mix(in srgb, var(--glow) 60%, transparent), transparent 70%); animation: glowbeat 1.3s ease-in-out infinite alternate; }
@keyframes glowbeat { from { opacity: .5; scale: .9; } to { opacity: 1; scale: 1.08; } }
.pillar { position: absolute; left: 50%; bottom: 50%; width: 30%; height: 150vh; translate: -50% 0; transform-origin: 50% 100%; background: linear-gradient(0deg, color-mix(in srgb, var(--glow) 80%, #fff) 0, color-mix(in srgb, var(--glow) 40%, transparent) 30%, transparent 85%); filter: blur(6px); opacity: .0; }
.ritual .pillar { animation: pillar 2.1s ease-in forwards; }
/* The light starts plain blue and only takes the colour of the best arrival near the end. */
.ritual { animation: tell 2.1s linear; }
@keyframes tell { 0%, 62% { --glow: #7cc4ff; } }
@keyframes pillar { 0% { opacity: 0; scale: .2 0; } 55% { opacity: .55; scale: .5 1; } 82% { opacity: .9; scale: 1 1; } 100% { opacity: 1; scale: 3.4 1; } }
.arrive .pillar { opacity: .28; scale: .8 1; }
.arrive .rit { opacity: .8; }
.rcap { position: relative; z-index: 2; align-self: start; margin-top: 12vh; max-width: min(88%, 460px); padding: 8px 14px; background: var(--paper); color: #23183f; border: 2px solid var(--inkline); box-shadow: 4px 4px 0 #0c0820; font-size: .95rem; line-height: 1.45; }
.rbar { position: relative; z-index: 3; display: flex; gap: 10px; justify-content: center; align-items: center; width: min(420px, 100%); }
.rbar .btn.primary { flex: 1; }
.rpanel { position: relative; z-index: 2; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: stretch; width: min(720px, 100%); max-height: 100%; border: 3px solid var(--inkline); outline: 3px solid var(--paper); box-shadow: 8px 8px 0 #05030c, 0 0 60px color-mix(in srgb, var(--glow) 40%, transparent); overflow: hidden; cursor: pointer;
  background: radial-gradient(circle at 1px 1px, #ffffff14 1px, transparent 1.5px) 0 0 / 9px 9px, linear-gradient(150deg, color-mix(in srgb, var(--glow) 34%, #1d1640), #150f2e 70%); }
.rfig { position: relative; min-height: 0; overflow: hidden; border-right: 3px solid var(--inkline); background: repeating-conic-gradient(from 0deg at 50% 60%, color-mix(in srgb, var(--glow) 30%, transparent) 0 4deg, transparent 4deg 12deg); }
.rfig .artbox { width: 100%; height: 100%; aspect-ratio: 3 / 4; background: none; }
.rfig .artbox img { object-position: 50% 14%; transition: filter .45s ease-out; }
.rfig .artbox .fallback .glyph { font-size: 4rem; transition: filter .45s ease-out; }
.rfig::after { content: ""; position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.rpanel:not(.shade) .rfig::after { animation: flashout .55s ease-out; }
@keyframes flashout { from { opacity: .95; } to { opacity: 0; } }
.rpanel.shade .rfig .artbox img, .rpanel.shade .rfig .artbox .fallback .glyph { filter: brightness(0); }
.rpanel.shade .rfig .artbox { animation: stepout .6s ease-out both; }
@keyframes stepout { from { transform: translateY(8%) scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.rinfo { display: grid; align-content: center; gap: 8px; padding: 18px; min-width: 0; transition: opacity .35s .1s, translate .35s .1s; }
.rinfo h2 { text-align: left; font-size: clamp(1.5rem, 5vw, 2.3rem); text-shadow: 3px 3px 0 var(--inkline); }
.rmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: .9rem; }
.rmeta .rtext { font-size: 1.1rem; letter-spacing: .05em; text-shadow: 0 0 10px var(--rc); }
.rnote { padding: 1px 9px; border-radius: 999px; background: var(--coral); color: #3d0a20; font-size: .72rem; font-weight: 600; }
.rsay { position: relative; margin-top: 6px; padding: 8px 12px 9px; border-radius: 14px; background: var(--paper); color: #23183f; border: 2px solid var(--inkline); box-shadow: 3px 3px 0 #0c082099; font-size: .98rem; line-height: 1.45; }
.rsay::before { content: ""; position: absolute; left: -10px; top: 18px; border: 7px solid transparent; border-right-color: var(--inkline); border-left: 0; }
.rpanel.shade .rinfo { opacity: 0; translate: 14px 0; }
.tier5 .rpanel { outline-color: var(--gold); }
.tier5 .rfig { background: repeating-conic-gradient(from 0deg at 50% 60%, #ffd36e66 0 4deg, transparent 4deg 12deg); }
.tier5 .rinfo h2 { color: var(--gold); }
@media (max-width: 620px) {
  .rpanel { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .rfig { border-right: 0; border-bottom: 3px solid var(--inkline); min-height: 34dvh; }
  .rfig .artbox { aspect-ratio: auto; position: absolute; inset: 0; }
  .rinfo { padding: 12px 14px 14px; gap: 6px; }
  .rsay::before { left: 22px; top: -10px; border: 7px solid transparent; border-bottom-color: var(--inkline); border-top: 0; }
  .rcap { margin-top: 9vh; }
}
@property --glow { syntax: "<color>"; inherits: true; initial-value: #7cc4ff; }
@media (prefers-reduced-motion: reduce) {
  .reveal.scene, .reveal.scene *, .reveal.scene *::after { animation: none !important; transition: none !important; }
  .ritual .pillar { opacity: .8; scale: 1 1; }
}

/* ---------- hero page: a status window, with the hero's own words over the portrait ---------- */
.hsheet.status { grid-template-columns: minmax(0, 320px) minmax(0, 1fr); }
.hport { position: relative; display: grid; min-height: 100%; border-right: 3px solid var(--inkline); overflow: hidden;
  background: radial-gradient(circle at 1px 1px, #ffffff14 1px, transparent 1.5px) 0 0 / 9px 9px, linear-gradient(160deg, color-mix(in srgb, var(--rc, #7cc4ff) 36%, #1d1640), #150f2e 75%); }
.hsheet.status .hport .artbox { width: 100%; height: 100%; aspect-ratio: 2 / 3; border-radius: 0; background: none; }
.hnav { position: absolute; z-index: 2; left: 10px; right: 10px; top: 10px; display: flex; justify-content: space-between; align-items: center; font-family: var(--display); font-size: .85rem; color: var(--ink); text-shadow: 0 2px 6px #000; }
.hnav .iconbtn { background: #0c0820cc; font-size: 1.3rem; }
.hquote { position: absolute; z-index: 2; left: 12px; right: 12px; bottom: 12px; padding: 8px 12px 9px; border-radius: 14px; background: var(--paper); color: #23183f; border: 2px solid var(--inkline); box-shadow: 3px 3px 0 #0c082099; font-size: .92rem; line-height: 1.45; }
.hquote::before { content: ""; position: absolute; left: 26px; top: -10px; border: 7px solid transparent; border-bottom-color: var(--inkline); border-top: 0; }
.hsheet.status .body { gap: 12px; }
.hsheet.status .body .sys-tag { padding-right: 44px; }
.hline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.vitals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.vital { display: grid; gap: 3px; align-content: start; padding: 8px 10px; border-radius: 8px; background: #0c082080; border: 1px solid #8fd8ff33; }
.vital small { color: var(--muted); font-size: .72rem; }
.vital b { font-family: var(--display); font-weight: 500; font-size: 1.05rem; white-space: nowrap; }
.vital b i { font-style: normal; color: var(--dim); font-size: .85rem; }
.vital .bar { height: 5px; }
.vital.mood .bar > s { background: currentColor; }
.hsheet.status .statgrid div, .hsheet.status .skill { background: #0c082080; border: 1px solid #8fd8ff22; }
@media (max-width: 640px) {
  .hsheet.status { grid-template-columns: minmax(0, 1fr); }
  .hport { border-right: 0; border-bottom: 3px solid var(--inkline); min-height: 0; }
  .hsheet.status .hport .artbox { aspect-ratio: 4 / 3; }
  .hsheet.status .body { padding: 16px; }
  .hnav { right: 58px; }
}

/* ---------- roster ---------- */
.squad { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; border-color: #8fd8ff44; }
.squad-info { display: grid; line-height: 1.25; }
.squad-info small { color: var(--muted); font-size: .78rem; }
.squad-info b { font-family: var(--display); font-weight: 500; font-size: 1.25rem; color: var(--gold); }
.squad .avarow { flex: 1; min-width: 0; }
.cmood { position: absolute; z-index: 1; left: 8px; right: 8px; bottom: 3px; height: 3px; border-radius: 3px; background: #ffffff22; overflow: hidden; }
.cmood s { display: block; height: 100%; background: currentColor; }
.cmood.m0, .cmood.m1 { color: var(--danger); } .cmood.m2 { color: var(--gold); } .cmood.m3, .cmood.m4 { color: var(--mint); }
.grid.roster .card .meta { bottom: 10px; }
.grid.roster button.card:hover .frame { transform: translateY(-4px) rotate(-1deg); box-shadow: 0 0 0 1px #0006, 0 0 20px color-mix(in srgb, var(--rc) 60%, transparent), 0 12px 24px #0009; }

/* ---------- cloud sea: a drawn map of floating islands you can pan and zoom ---------- */
.seamap { position: relative; height: clamp(420px, 70dvh, 760px); overflow: hidden; border-radius: 18px; border: 1px solid var(--line); background: #0d1630; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.seamap.dragging { cursor: grabbing; }
@media (max-width: 900px) { .seamap { height: min(62dvh, 560px); min-height: 360px; } }
.sea-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; container-type: inline-size;
  background: radial-gradient(circle at 1px 1px, #ffffff0f 1px, transparent 1.5px) 0 0 / 64px 64px, radial-gradient(circle at 50% 50%, #8a3f8e 0%, #4a2f8a 24%, #2a4288 56%, #17285a 100%); }
.sea-world::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5; background: radial-gradient(ellipse 150px 44px at 22% 30%, #ffffff3d, transparent 70%), radial-gradient(ellipse 190px 52px at 70% 16%, #ffffff33, transparent 70%), radial-gradient(ellipse 170px 46px at 42% 74%, #ffffff33, transparent 70%), radial-gradient(ellipse 130px 38px at 86% 62%, #ffffff2e, transparent 70%), radial-gradient(ellipse 110px 34px at 8% 86%, #ffffff29, transparent 70%); background-size: 620px 460px; }
.sea-world::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px 40px #070b1ecc; }
.sea-world .cloud { position: absolute; display: block; opacity: .2; scale: 2.2; filter: blur(6px); z-index: 3; pointer-events: none; }
.sea-world .s1 { top: 8%; --t: 160s; --dl: -30s; } .sea-world .s2 { top: 27%; --t: 210s; --dl: -140s; } .sea-world .s3 { top: 49%; --t: 130s; --dl: -80s; }
.sea-world .s4 { top: 68%; --t: 190s; --dl: -20s; } .sea-world .s5 { top: 86%; --t: 150s; --dl: -110s; }
.sea-routes { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.sea-routes line { stroke: #ffd36ecc; stroke-width: 2px; stroke-dasharray: 6 7; stroke-linecap: round; animation: march 1.4s linear infinite; }
.sea-routes line.back { stroke: #7ef0c2aa; animation-direction: reverse; }
.tile.islet { --turf: #4fb39a; position: absolute; z-index: 2; width: 64px; height: 64px; padding: 0; border: 0; background: none; display: grid; justify-items: center; align-content: center; color: var(--ink); cursor: pointer; animation: bob 5s ease-in-out var(--d, 0s) infinite alternate; transition: scale .15s, filter .15s; }
.isle-ico { position: relative; z-index: 1; font-style: normal; font-size: 27px; line-height: 1; filter: drop-shadow(0 2px 2px #000a); }
.isle-rock { display: block; width: 54px; height: 25px; margin-top: -8px; background: linear-gradient(180deg, var(--turf) 0 30%, #4a3d86 30%, #1b1440 100%); clip-path: polygon(0 0, 100% 0, 86% 44%, 62% 60%, 50% 100%, 36% 58%, 14% 44%); filter: drop-shadow(0 4px 4px #0009); }
.tile.islet small { position: absolute; top: calc(100% - 7px); left: 50%; translate: -50% 0; display: none; padding: 0 7px; border-radius: 999px; background: #0c0820cc; white-space: nowrap; font-size: 12px; line-height: 1.5; color: var(--ink); pointer-events: none; }
.tile.islet.home small, .tile.islet.boss small, .tile.islet.ai small, .tile.islet.player small, .tile.islet:hover small, .tile.islet:focus-visible small { display: block; }
.tile.islet:hover, .tile.islet:focus-visible { scale: 1.18; z-index: 4; filter: drop-shadow(0 0 8px var(--gold)); outline: none; }
.tile.islet.home { --turf: #ffd36e; z-index: 3; }
.tile.islet.home::before, .tile.islet.boss::before, .tile.islet.ruin.mine::before, .tile.islet.player::before { content: ""; position: absolute; left: 50%; top: 60%; width: 76px; height: 30px; translate: -50% -50%; border-radius: 50%; border: 2px solid var(--ring, var(--gold)); box-shadow: 0 0 14px var(--ring, var(--gold)); animation: glowbeat 1.6s ease-in-out infinite alternate; pointer-events: none; }
.tile.islet.home small { color: var(--gold); }
.tile.islet.ai { --turf: #7cc4ff; }
.tile.islet.player { --turf: #8fd8ff; --ring: #8fd8ff; }
.tile.islet.player.shielded { opacity: .7; }
.tile.islet.ruin { --turf: #b3a8dd; }
.tile.islet.ruin.mine { --turf: #7ef0c2; --ring: #7ef0c2; }
.tile.islet.ruin.taken { --turf: #ff8fb8; }
.tile.islet.camp { --turf: #ff8f7a; }
.tile.islet.camp.spent { opacity: .45; }
.tile.islet.boss { --turf: #ff5f7e; --ring: #ff5f7e; z-index: 3; }
.tile.islet.boss .isle-ico { font-size: 40px; }
.tile.islet.boss small { color: var(--coral); }
.sea-world .ship { z-index: 5; font-size: 28px; }
.sea-ui { right: 10px; top: 10px; }
.sea-ui .keep-ui { position: static; }
@media (prefers-reduced-motion: reduce) { .sea-world *, .sea-world *::before { animation: none !important; } }

/* ---------- the game's own icons ---------- */
.gi { display: block; width: 1.3em; height: 1.3em; flex: none; }
.dock button i .gi { width: 26px; height: 26px; }
.railbtn i .gi { width: 22px; height: 22px; }
.keep-ui .iconbtn .gi, #menuBtn .gi { width: 20px; height: 20px; }
.plate-star .gi { width: 20px; height: 20px; }
.backbtn i .gi { width: 18px; height: 18px; }
.chatpill { display: inline-flex; align-items: center; gap: 6px; }
.chatpill i .gi { width: 18px; height: 18px; }
.btn .gi { width: 18px; height: 18px; }
.sea-ui [data-zoom="home"] { color: var(--gold); }

/* ---------- prologue: comic panels ---------- */
.reveal.prologue { background: #05030c; }
.ppanel { position: relative; z-index: 2; width: min(680px, 100%); aspect-ratio: 4 / 3; max-height: 100%; overflow: hidden; border: 3px solid var(--inkline); outline: 3px solid var(--paper); box-shadow: 8px 8px 0 #000; background: #12143a; animation: panelin .45s ease-out; }
@keyframes panelin { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.ppanel > .artbox { position: absolute; inset: 0; }
.ppanel > .artbox img { animation: drift 20s ease-in-out infinite alternate; }
.pcap { position: absolute; left: 14px; bottom: 14px; max-width: min(84%, 460px); padding: 8px 14px 9px; background: var(--paper); color: #23183f; border: 2px solid var(--inkline); box-shadow: 4px 4px 0 #0c0820; font-size: 1rem; line-height: 1.5; }
.ppanel.sys { display: grid; place-items: center; background: repeating-linear-gradient(0deg, #8fd8ff0a 0 1px, transparent 1px 4px), radial-gradient(circle at 50% 40%, #16224e, #070a1c 75%); }
.psys { display: grid; gap: 10px; padding: 20px; }
.psys .sysline { font-size: clamp(.85rem, 2.6vw, 1.05rem); }
.psys .sysline.warn { color: var(--danger); }
.ppanel.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 4%; padding-right: 5%; background: radial-gradient(circle at 1px 1px, #ffffff14 1px, transparent 1.5px) 0 0 / 9px 9px, linear-gradient(150deg, #33246e, #150f2e 70%); }
.pfig { height: 100%; min-height: 0; border-right: 3px solid var(--inkline); overflow: hidden; }
.pfig .artbox { width: 100%; height: 100%; background: none; }
.pfig .artbox img { object-position: 50% 14%; }
.pcount { color: var(--dim); font-size: .78rem; min-width: 3ch; }
@media (max-width: 620px) {
  .ppanel { aspect-ratio: 3 / 4; }
  .ppanel.hero { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; padding: 0 0 14px; }
  .ppanel.hero .rsay { margin: 14px 14px 0; }
  .ppanel.hero .rsay::before { left: 22px; top: -10px; border: 7px solid transparent; border-bottom-color: var(--inkline); border-top: 0; }
  .pfig { border-right: 0; border-bottom: 3px solid var(--inkline); }
}

/* ---------- drawn icons standing in for emoji inside text ---------- */
.gi.em { display: inline-block; width: 1.1em; height: 1.1em; vertical-align: -0.18em; }
.isle-ico { color: color-mix(in srgb, var(--turf, #fff) 55%, #fff); }
.tile.islet.boss .isle-ico, .tile.islet.camp .isle-ico { color: color-mix(in srgb, var(--turf) 75%, #fff); }
.deck > .artbox .fallback .glyph .gi.em { color: var(--rh); }

/* ---------- tower exploration: walk the floor room by room before the fight ---------- */
/* Each room shows art/tower/<id>.webp when it exists; until then it is drawn here in the room's own colour. */
.battle.explore { grid-template-rows: auto minmax(0, 1fr) auto; background: #07051a; }
.xview { position: relative; min-height: 0; align-self: center; height: min(100%, 120vw); overflow: hidden; border-radius: 14px; border: 3px solid var(--inkline); outline: 2px solid #ffffff1f; background: #0c0820; }
.xstrip { position: absolute; left: 0; top: 0; height: 100%; transition: transform 1.2s cubic-bezier(.4, .1, .3, 1); will-change: transform; }
.xroom { --hue: #8f84d8; position: absolute; top: 0; bottom: 0; overflow: hidden; border-right: 8px solid #05030c;
  background: linear-gradient(180deg, color-mix(in srgb, var(--hue) 30%, #1d1640) 0%, color-mix(in srgb, var(--hue) 12%, #150f2e) 62%, #0a0718 62%, color-mix(in srgb, var(--hue) 14%, #1a1238) 100%); }
.xroom::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 62%; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(90deg, transparent 0 11%, #0000003d 11% 13.5%, transparent 13.5% 25%), radial-gradient(ellipse 60% 70% at 50% 40%, color-mix(in srgb, var(--hue) 34%, transparent), transparent 70%); }
.xroom::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(0deg, #05030ccc 0, transparent 30%), radial-gradient(ellipse at 50% 50%, transparent 55%, #05030cb3 100%); }
.xroom > .artbox { position: absolute; inset: 0; background: none; }
.xroom > .artbox:not(.noart) { z-index: 1; }
.xroom > .artbox .fallback { align-content: start; padding-top: 12%; }
.xroom > .artbox .fallback .glyph { font-size: clamp(3rem, 13vw, 6.5rem); line-height: 1; color: var(--hue); opacity: .32; filter: drop-shadow(0 0 18px var(--hue)); }
.xdoor { position: absolute; z-index: 1; bottom: 38%; width: 9%; height: 38%; border-radius: 999px 999px 0 0; background: #05030c; box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--hue) 50%, #000), 0 0 22px color-mix(in srgb, var(--hue) 40%, transparent); }
.xdoor.in { left: -4.5%; } .xdoor.out { right: -4.5%; }
.xname { position: absolute; z-index: 2; left: 14px; top: 12px; padding: 2px 12px; border-radius: 999px; background: #0c0820cc; border: 1px solid color-mix(in srgb, var(--hue) 60%, transparent); font-family: var(--display); font-size: .85rem; color: var(--ink); }
.xfoes { position: absolute; z-index: 2; right: 9%; bottom: 25%; display: flex; align-items: flex-end; gap: 6px; }
.xfoe { display: block; width: clamp(46px, 11vw, 78px); filter: brightness(.12) drop-shadow(0 0 8px #ff5f7e); transition: filter .9s .5s; }
.xfoe.boss { width: clamp(80px, 20vw, 140px); }
.xfoe .artbox { width: 100%; aspect-ratio: 1; border-radius: 40% 40% 30% 30%; background: #05030c; }
.battle.contact .xfoe { filter: brightness(.75) drop-shadow(0 0 10px #ff5f7e); }
.xparty { position: absolute; z-index: 3; bottom: 24%; display: flex; gap: 2px; translate: -50% 0; transition: left 1.2s cubic-bezier(.4, .1, .3, 1); }
.xhero { position: relative; display: grid; justify-items: center; width: clamp(38px, 9vw, 58px); }
.xhero::after { content: ""; position: absolute; left: 12%; right: 12%; bottom: -8px; height: 8px; border-radius: 50%; background: #000a; z-index: -1; }
.xhero .ava { width: clamp(34px, 8vw, 52px); height: clamp(34px, 8vw, 52px); border-width: 2px; z-index: 1; }
.xhero .spr-body { width: 56%; height: clamp(11px, 2.6vw, 17px); margin-top: -5px; border-radius: 8px 8px 4px 4px; }
.xhero .spr-body::before, .xhero .spr-body::after { width: 26%; height: 7px; bottom: -6px; animation: none; }
.xparty.walking .xhero { animation: hop .22s ease-in-out infinite alternate; animation-delay: calc(var(--i) * -.08s); }
.xparty.walking .spr-body::before { animation: leg .22s ease-in-out infinite alternate; }
.xparty.walking .spr-body::after { animation: leg .22s ease-in-out infinite alternate-reverse; }
.xhero .bub { left: 50%; translate: -50% 0; bottom: calc(100% + 6px); font-size: .78rem; max-width: 170px; }
.xhero .bub::after { left: 50%; translate: -50% 0; }
.battle.explore .bcap { top: 50px; }
.xbar { display: grid; gap: 8px; justify-items: center; }
.xbar .pullrow { width: min(480px, 100%); }
.xbar .pullrow .btn { flex: 1; }
@media (prefers-reduced-motion: reduce) { .xstrip, .xparty, .xfoe { transition: none; } .xparty.walking .xhero, .xparty.walking .spr-body::before, .xparty.walking .spr-body::after { animation: none; } }
/* A real room picture has its own doorways, so the drawn ones step aside. */
.xroom:has(> .artbox:not(.noart)) .xdoor { display: none; }

/* ---------- exploration: what the walk has cost and found so far ---------- */
.xhud { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 16px; width: min(560px, 100%); }
.xhpbox { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 200px; }
.xhpbox small { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.xhpbox .bar { flex: 1; height: 8px; }
.xhpbox .bar > s { background: linear-gradient(90deg, #3fd49a, var(--mint)); }
.xhpbox .bar.low > s { background: linear-gradient(90deg, #ff5f7e, var(--coral)); }
.xhpbox b { font-family: var(--display); font-weight: 500; min-width: 4ch; text-align: right; }
.xhud .reward { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; }
.xhud .reward small { color: var(--muted); font-size: .78rem; }
.xbar .pullrow { width: min(620px, 100%); justify-content: center; }
.xbar .pullrow .btn { flex: 1 1 auto; }
