﻿/* Pixel Heroes — an adventurer's camp at night: dark carved wood, brass trim, parchment, hard pixel bevels.
   No soft glows, no rounded cards: every frame is a 2px ink outline with a light top-left bevel, a dark
   bottom-right bevel and notched corners, the way a 16-bit RPG menu is drawn. */
:root {
  --ink: #0d0907; --wood0: #160e09; --wood1: #22160e; --wood2: #322015; --wood3: #4a311f; --wood4: #6b4a2e;
  --brass-d: #6e4a16; --brass: #c8902e; --brass-l: #f0c860; --cream: #f2e4c2; --dim: #b8a07c; --mute: #7d6850;
  --parch: #e6d3a3; --parch-d: #b89d68; --night: #0b0d16;
  --gold: #ffd45e; --good: #7fd65a; --bad: #e85a44; --cool: #7fd6ff; --accent: var(--brass);
  --notice-dot-size: 16px; --notice-count-size: 24px; --notice-ring: 0 0 0 1px #fff1c590, 0 0 8px #ffc85d70;
  --r0: #b8bcc8; --r1: #5fd35f; --r2: #4aa3ff; --r3: #b25cff; --r4: #ffa02e; --r5: #ff4a6e; --uq: #ffb347;
  --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px); --sa-r: env(safe-area-inset-right, 0px); --sa-t: env(safe-area-inset-top, 0px);
  --notch: polygon(3px 0, calc(100% - 3px) 0, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 0 calc(100% - 3px), 0 3px);
  --notch-s: polygon(2px 0, calc(100% - 2px) 0, 100% 2px, 100% calc(100% - 2px), calc(100% - 2px) 100%, 2px 100%, 0 calc(100% - 2px), 0 2px);
  --bevel: inset 2px 2px 0 rgba(255, 220, 160, 0.13), inset -2px -2px 0 rgba(0, 0, 0, 0.45);
  --bevel-in: inset 2px 2px 0 rgba(0, 0, 0, 0.5), inset -2px -2px 0 rgba(255, 220, 160, 0.08);
  font-family: "Sarabun", "Kanit", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, sans-serif;
  line-height: 1.35; -webkit-font-smoothing: antialiased;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; color: var(--cream); overflow: hidden; overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; }
input, textarea { font: inherit; color: inherit; user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; border-radius: 0; }
[hidden] { display: none !important; }
.num, .tb-gold, .sumgrid b, .power b { font-variant-numeric: tabular-nums; }
/* pixel icons */
.pi { display: inline-block; width: 1.5em; height: 1.5em; flex: none; vertical-align: -0.35em; background: var(--ico) center / contain no-repeat; image-rendering: pixelated; }
img { image-rendering: pixelated; }

/* ---------------------------------------------------------------- loader */
#loader { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--night); transition: opacity .5s; }
#loader.out { opacity: 0; pointer-events: none; }
.ld-wrap { width: min(440px, 88vw); text-align: center; }
.ld-logo { font: 900 clamp(38px, 11vw, 64px)/0.95 "Kanit", "Arial Black", sans-serif; letter-spacing: 3px; color: var(--brass-l); text-shadow: 3px 3px 0 var(--brass-d), 6px 6px 0 var(--ink); }
.ld-sub { margin: 16px 0 22px; color: var(--dim); letter-spacing: 2px; font-size: 14px; }
.ld-bar { height: 16px; border: 2px solid var(--ink); background: var(--wood0); padding: 2px; box-shadow: 0 0 0 2px var(--brass-d); }
.ld-bar i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--brass-l) 0 6px, var(--brass) 6px 8px); transition: width .15s; }
.ld-step { margin-top: 10px; font-size: 15px; color: var(--dim); min-height: 18px; }
.ld-list { margin-top: 10px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-height: 70px; overflow: hidden; }
.ld-list span { font-size: 12px; padding: 1px 6px; border: 1px solid var(--wood3); color: var(--mute); }
.ld-list span.ok { color: var(--good); border-color: #3a5a2a; }
.ld-err { margin-top: 14px; color: var(--bad); font-size: 15px; }

/* ---------------------------------------------------------------- stage */
#app { position: fixed; inset: 0; display: grid; place-items: center; }
#stage { position: relative; width: 100vw; height: 100vh; height: 100dvh; background: #000; }
#app.mode-mmo #stage { width: 100vw; height: 100vh; height: 100dvh; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; touch-action: none; }
#hud { position: absolute; left: 0; right: 0; top: 0; pointer-events: none; height: 100%; }
#pad { z-index: 2; }
#hud > * { pointer-events: none; }
#hud button, #team, #skills, #joy { pointer-events: auto; }
.screen { position: absolute; inset: 0; z-index: 4; }

/* ---------------------------------------------------------------- shared frames and buttons */
.btn, .tb-btn, .lb-btn, .chip, .slotbtn, .keybtn, .m-x, .herotab, .boon, .card, .sk, .lb-hero, .hcard, .mapc, .quest, .skillrow, .slot, .it, .codex-card, .detail, .sumgrid div, select, .imptext {
  border: 2px solid var(--ink); clip-path: var(--notch-s);
}
.btn { padding: 8px 12px; background: var(--wood4); box-shadow: var(--bevel); font-weight: 700; font-size: 15px; white-space: nowrap; color: var(--cream); text-shadow: 1px 1px 0 var(--ink); }
.btn:active { transform: translateY(1px); box-shadow: var(--bevel-in); }
.btn.pri { background: var(--brass); color: var(--wood0); text-shadow: 1px 1px 0 var(--brass-l); box-shadow: inset 2px 2px 0 var(--brass-l), inset -2px -2px 0 var(--brass-d); }
.btn.good { background: #4e8a3a; box-shadow: inset 2px 2px 0 #8fd06a, inset -2px -2px 0 #24401a; }
.btn.bad { background: #973526; box-shadow: inset 2px 2px 0 #d86a4a, inset -2px -2px 0 #44150e; }
.btn.ghost { background: var(--wood1); color: var(--dim); }
.btn.big { padding: 12px 18px; font-size: 16px; }
.btn[disabled] { opacity: .45; pointer-events: none; filter: grayscale(.6); }
.chip { padding: 5px 10px; background: var(--wood0); box-shadow: var(--bevel-in); font-size: 14px; color: var(--dim); }
.chip.on { background: var(--brass); color: var(--wood0); font-weight: 700; box-shadow: inset 2px 2px 0 var(--brass-l), inset -2px -2px 0 var(--brass-d); }
.chip.heat.on { background: #a8302a; color: var(--cream); box-shadow: inset 2px 2px 0 #e06048, inset -2px -2px 0 #4a1010; }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sp { flex: 1; }
.dim { color: var(--dim); } .gold { color: var(--gold); } .good { color: var(--good); } .bad { color: var(--bad); }
.note { font-size: 14px; color: var(--dim); line-height: 1.55; }
h4 { margin: 14px 0 6px; font-size: 14px; color: var(--brass-l); letter-spacing: 2px; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
h4::after { content: ""; flex: 1; height: 2px; background: repeating-linear-gradient(90deg, var(--brass-d) 0 4px, transparent 4px 6px); }
.pbar { height: 10px; background: var(--wood0); border: 2px solid var(--ink); min-width: 60px; }
.pbar i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--rc) 0 6px, color-mix(in srgb, var(--rc) 70%, #000) 6px 7px); }
select { background: var(--wood0); color: var(--cream); padding: 6px; font: inherit; font-size: 15px; }
button:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.lb-btn:focus-visible, .sk:focus-visible, .card:focus-visible, .boon:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------------------------------------------------------------- in-run HUD */
#topbar { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: calc(4px + var(--sa-t)) calc(6px + var(--sa-r)) 4px calc(6px + var(--sa-l)); background: linear-gradient(rgba(13, 9, 7, .85), rgba(13, 9, 7, 0)); font-size: clamp(10px, 1.7vw, 14px); }
.tb-stage { display: flex; flex-direction: column; line-height: 1.1; min-width: 70px; text-shadow: 1px 1px 0 var(--ink); }
.tb-stage b { font-size: 1.15em; color: var(--brass-l); }
.tb-stage span { color: var(--dim); font-size: .85em; white-space: nowrap; }
.tb-stage em.bt { font-style: normal; color: var(--gold); }
.tb-prog { position: relative; flex: 1; height: 14px; max-width: 280px; background: var(--wood0); border: 2px solid var(--ink); box-shadow: 0 0 0 1px var(--brass-d); }
.tb-prog i { position: absolute; inset: 0 auto 0 0; width: 0; background: repeating-linear-gradient(90deg, var(--good) 0 5px, #4e9a3a 5px 6px); transition: width .2s; }
.tb-prog em { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: .8em; text-shadow: 1px 1px 0 var(--ink); }
.tb-gold { margin-left: auto; padding: 2px 8px; background: var(--wood0); border: 2px solid var(--ink); box-shadow: 0 0 0 1px var(--brass-d); color: var(--gold); white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.tb-gold .pi { width: 1.2em; height: 1.2em; }
.tb-btn { position: relative; display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; min-height: 28px; font-size: .95em; font-weight: 700; background: var(--wood2); box-shadow: var(--bevel); text-shadow: 1px 1px 0 var(--ink); }
.tb-btn:active { box-shadow: var(--bevel-in); }
.tb-btn.on { background: #3e6e2e; box-shadow: inset 2px 2px 0 #8fd06a, inset -2px -2px 0 #1e3416; }
.dot, .it .nw {
  position: absolute; top: 2px; right: 2px; width: var(--notice-dot-size); height: var(--notice-dot-size);
  border: 2px solid var(--ink); border-radius: 50%; background: var(--gold); box-shadow: var(--notice-ring); pointer-events: none;
}
.dot { display: none; }
.dot.on { display: block; }
.tb-btn .dot.mail-count, .fr-alert, .fr-cnt, #pv-chat .chat-fold.has-unread::after {
  min-width: var(--notice-count-size); height: var(--notice-count-size); padding: 0 5px;
  place-items: center; border: 2px solid var(--ink); border-radius: 999px; font: 800 14px/1 "Kanit", sans-serif;
  font-variant-numeric: tabular-nums; font-style: normal; text-shadow: none; white-space: nowrap;
}
@keyframes blink { 50% { background: var(--gold); } }

/* the guardian's bar: a dark iron frame with gold corners, a blood-red fill with a moving sheen over a pale damage
   trail, phase notches, a % readout; it slams in on arrival, jolts on hits and burns when the guardian rages */
#boss { position: absolute; left: 50%; top: calc(34px + var(--sa-t)); transform: translateX(-50%); width: min(70%, 440px); text-align: center; font-size: clamp(10px, 1.6vw, 13px); font-weight: 700; color: var(--cream); text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink); --bb: #ff3a2a; }
#boss .bb-head { display: flex; align-items: center; justify-content: center; gap: 8px; }
#slimehunt-hint { position: absolute; top: calc(92px + var(--sa-t)); left: 50%; transform: translateX(-50%); max-width: 84%; padding: 4px 10px; background: #201727ee; border: 1px solid #b58f53; color: #fff1c4; font: 600 13px/1.35 "Kanit", sans-serif; text-align: center; white-space: nowrap; }
#boss-name { letter-spacing: .5px; color: #ffe6c8; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 0 0 8px rgba(255, 60, 40, .55); }
#boss .bb-sk { width: 9px; height: 9px; flex: none; background: linear-gradient(135deg, #ffd27a, var(--bb) 60%, #6a0a08); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
#boss .bar { position: relative; height: 16px; margin-top: 4px; background: linear-gradient(#1a0a0c, #2a1014); border: 2px solid #0a0406; box-shadow: 0 0 0 2px #5a4a3a, 0 0 0 3px #0a0406, 0 3px 10px rgba(0, 0, 0, .6), 0 0 18px rgba(255, 40, 30, .25); overflow: visible; }
#boss .bar::before, #boss .bar::after { content: ""; position: absolute; top: -6px; width: 8px; height: 24px; background: linear-gradient(var(--brass-l), var(--brass) 50%, var(--brass-d)); border: 2px solid #0a0406; z-index: 3; }
#boss .bar::before { left: -9px; clip-path: polygon(0 50%, 100% 0, 100% 100%); }
#boss .bar::after { right: -9px; clip-path: polygon(0 0, 100% 50%, 0 100%); }
#boss .bar i { position: absolute; left: 0; top: 0; display: block; height: 100%; width: 100%; }
#boss #boss-trail { background: linear-gradient(#fff6d8, #ffd27a); opacity: .9; }
#boss #boss-fill { background: linear-gradient(#ff7a5a 0 18%, #e0281c 18% 60%, #8a0c10 60%); transition: width .08s; overflow: hidden; }
#boss #boss-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, #0000 30%, rgba(255, 255, 255, .45) 45%, #0000 60%) 0 0/220% 100%; animation: bb-sheen 2.2s linear infinite; }
#boss-marks i { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: #ffe070; box-shadow: 0 0 0 1px #0a0406; z-index: 2; }
#boss-marks i.past { background: #5a4a3a; }
#boss-pct { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font: 900 11px/1 system-ui, sans-serif; font-style: normal; color: #fff; text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000; z-index: 2; }
#boss.enter { animation: bb-enter .55s cubic-bezier(.2, 1.6, .4, 1); }
#boss.enter #boss-fill { animation: bb-fill .9s ease-out; }
#boss.hit .bar { animation: bb-jolt .16s steps(4); }
#boss.low #boss-fill { background: linear-gradient(#ffb07a 0 18%, #ff3a1a 18% 60%, #b01008 60%); }
#boss.low .bar { box-shadow: 0 0 0 2px #5a4a3a, 0 0 0 3px #0a0406, 0 0 22px rgba(255, 60, 20, .6); }
#boss.rage .bar { box-shadow: 0 0 0 2px #ff3a2a, 0 0 0 3px #0a0406, 0 0 26px rgba(255, 30, 20, .85); animation: bb-rage .5s ease-in-out infinite alternate; }
#boss.rage #boss-name { color: #ffb0a0; }
@keyframes bb-sheen { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@keyframes bb-enter { 0% { transform: translateX(-50%) scale(1.6); opacity: 0; } 60% { opacity: 1; } 100% { transform: translateX(-50%) scale(1); } }
@keyframes bb-fill { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes bb-jolt { 0% { transform: translate(2px, -1px); } 25% { transform: translate(-2px, 1px); } 50% { transform: translate(1px, 1px); } 75% { transform: translate(-1px, 0); } 100% { transform: none; } }
@keyframes bb-rage { from { filter: brightness(1); } to { filter: brightness(1.35); } }
@media (prefers-reduced-motion: reduce) { #boss.enter, #boss.hit .bar, #boss #boss-fill::after, #boss.rage .bar { animation: none; } }
#banner { position: absolute; left: 0; right: 0; top: 28%; text-align: center; font: 900 clamp(18px, 5vw, 38px)/1.1 "Kanit", "Arial Black", sans-serif; color: var(--brass-l); letter-spacing: 2px; text-shadow: 3px 3px 0 var(--brass-d), 5px 5px 0 var(--ink); opacity: 0; transform: translateY(-8px); transition: opacity .2s steps(3), transform .2s steps(3); }
#banner.show { opacity: 1; transform: none; }
#banner small { display: block; margin-top: 8px; font: 700 clamp(11px, 2vw, 16px)/1.3 inherit; font-family: inherit; color: var(--cream); letter-spacing: 0; text-shadow: 2px 2px 0 var(--ink); }

/* the hit counter: big, chunky, with a fuse that burns down */
#combo { position: absolute; right: calc(18px + var(--sa-r)); top: 28%; display: grid; justify-items: end; gap: 3px; line-height: 1; opacity: 0; transition: opacity .15s; }
#combo.on { opacity: 1; }
#combo b { font: 900 clamp(26px, 6vw, 46px)/1 "Kanit", "Arial Black", sans-serif; color: var(--brass-l); text-shadow: 3px 3px 0 var(--brass-d), 5px 5px 0 var(--ink); }
#combo span { font: 900 clamp(10px, 1.8vw, 14px)/1 "Kanit", "Arial Black", sans-serif; letter-spacing: 3px; color: var(--cream); text-shadow: 2px 2px 0 var(--ink); margin-top: 6px; }
#combo em { font-style: normal; font-weight: 800; font-size: clamp(11px, 2vw, 16px); color: var(--gold); text-shadow: 2px 2px 0 var(--ink); margin-top: 3px; min-height: 1.2em; }
#combo i { display: block; width: clamp(60px, 12vw, 110px); height: 6px; margin-top: 4px; background: var(--wood0); border: 2px solid var(--ink); }
#combo i::after { content: ""; display: block; height: 100%; width: var(--t, 100%); background: var(--brass-l); }
#combo.pop b { animation: pop .18s steps(3); }
#combo.hot b { color: #ff9a3a; }
#combo.fire b { color: #ff5a3a; }
@keyframes pop { 0% { transform: scale(1.35); } 100% { transform: none; } }
#combo small { font-size: clamp(9px, 1.5vw, 12px); color: var(--dim); text-shadow: 1px 1px 0 var(--ink); margin-top: 3px; }

/* team cards */
#team { position: absolute; z-index: 3; left: calc(6px + var(--sa-l)); top: calc(40px + var(--sa-t)); display: flex; flex-direction: column; gap: 4px; }
.card { position: relative; display: flex; align-items: center; gap: 6px; width: clamp(96px, 17vw, 156px); padding: 3px 6px 3px 3px; background: rgba(34, 22, 14, .92); box-shadow: var(--bevel); text-align: left; overflow: hidden; }
.card.active { background: var(--wood3); box-shadow: inset 0 0 0 2px var(--cc), var(--bevel); }
.card.down { filter: grayscale(1) brightness(.6); }
.hero-ico { width: 30px; height: 30px; flex: none; background: var(--wood0); border: 2px solid var(--ink); }
.card .nm { font-size: clamp(9px, 1.5vw, 12px); font-weight: 700; line-height: 1.1; white-space: nowrap; text-shadow: 1px 1px 0 var(--ink); }
.card .nm small { color: var(--dim); font-weight: 400; }
.card .hp { height: 6px; margin-top: 3px; background: var(--wood0); border: 1px solid var(--ink); }
.card .hp i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--good) 0 4px, #4e9a3a 4px 5px); }
.card .hp i.low { background: repeating-linear-gradient(90deg, var(--bad) 0 4px, #9a2a1a 4px 5px); }
.card .sw { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); transform-origin: bottom; pointer-events: none; }
.card kbd { position: absolute; right: 3px; top: 1px; font: 700 11px/1 monospace; color: var(--dim); }

/* controls */
#pad { position: absolute; left: 0; right: 0; bottom: 0; height: 46%; pointer-events: none; }
#joy { position: absolute; left: calc(14px + var(--sa-l)); bottom: calc(14px + var(--sa-b)); width: 132px; height: 132px; display: none; touch-action: none; }
#joy-base { position: absolute; inset: 14px; border-radius: 50%; border: 3px solid rgba(240, 200, 96, .35); background: rgba(13, 9, 7, .35); box-shadow: inset 0 0 0 3px rgba(13, 9, 7, .5); }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: var(--brass); border: 3px solid var(--ink); box-shadow: inset 4px 4px 0 var(--brass-l), inset -4px -4px 0 var(--brass-d); }
@media (pointer: coarse) { #joy { display: block; } }
#skills { position: absolute; right: calc(10px + var(--sa-r)); bottom: calc(10px + var(--sa-b)); display: grid; grid-template-columns: repeat(3, auto); gap: 8px; align-items: end; justify-items: end; pointer-events: auto; }
.sk { position: relative; width: clamp(54px, 9vw, 74px); height: clamp(54px, 9vw, 74px); background: var(--wood0); box-shadow: inset 0 0 0 2px var(--sc, var(--wood4)), var(--bevel-in); display: grid; place-items: center; padding: 0; overflow: hidden; touch-action: none; }
/* the skill being cast: its frame lights up while the wind-up runs (the bar itself is over the hero's head) */
.sk.casting { box-shadow: inset 0 0 0 2px var(--brass-l), 0 0 12px rgba(255, 212, 94, .75), var(--bevel-in); }
.sk .si { position: absolute; inset: 4px; background: var(--ico) center / cover no-repeat; image-rendering: pixelated; }
.sk:active { transform: translateY(2px); }
.sk .cd { position: absolute; inset: 0; background: rgba(0, 0, 0, .72); transform-origin: bottom; }
.sk .t { position: absolute; inset: 0; display: grid; place-items: center; font: 800 clamp(14px, 3vw, 20px) "Kanit", sans-serif; color: var(--cream); text-shadow: 2px 2px 0 var(--ink); }
.sk kbd { position: absolute; top: 3px; left: 5px; font: 700 12px monospace; color: var(--cream); text-shadow: 1px 1px 0 var(--ink); z-index: 1; }
.sk.ready { box-shadow: inset 0 0 0 2px var(--sc), inset 0 0 0 4px var(--ink), var(--bevel-in); }
.sk small { position: absolute; bottom: 2px; left: 0; right: 0; text-align: center; font-size: 11px; font-weight: 700; color: var(--cream); text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink); white-space: nowrap; z-index: 1; }
.sk.dodge { width: clamp(46px, 7vw, 60px); height: clamp(46px, 7vw, 60px); --sc: var(--cool); }
.sk.dodge .pi { width: 60%; height: 60%; }
.sk.s0 { grid-column: 3; grid-row: 2; } .sk.s1 { grid-column: 2; grid-row: 2; } .sk.s2 { grid-column: 3; grid-row: 1; } .sk.s3 { grid-column: 2; grid-row: 1; }
.sk.dodge { grid-column: 1; grid-row: 2; }
@media (pointer: fine) { .sk { width: clamp(48px, 6.4vw, 66px); height: clamp(48px, 6.4vw, 66px); } }
@media (pointer: coarse) { .sk kbd, .card kbd { display: none; } }
@media (max-height: 520px), (max-width: 520px) { .sk small { display: none; } }

/* toasts: a strip of wood with a brass edge; above the camp, the HUD and menus */
#toasts { position: fixed; z-index: 40; left: calc(8px + var(--sa-l)); bottom: calc(26% + var(--sa-b)); display: flex; flex-direction: column-reverse; gap: 3px; align-items: flex-start; max-width: min(60vw, 420px); font-size: clamp(10px, 1.5vw, 12px); pointer-events: none; }
.toast { padding: 4px 9px; background: rgba(22, 14, 9, .94); border: 2px solid var(--ink); border-left: 4px solid var(--c, var(--brass)); animation: toast 3.6s steps(24) forwards; text-shadow: 1px 1px 0 var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.toast.big { font-weight: 700; color: var(--c); background: var(--wood2); }
@keyframes toast { 0% { opacity: 0; transform: translateX(-10px); } 8%, 82% { opacity: 1; transform: none; } 100% { opacity: 0; } }
/* over a menu: a short stack in the bottom-right corner, clear of the title bar and the close button */
#app:has(#modal:not([hidden])) #toasts { top: auto; bottom: calc(12px + var(--sa-b)); left: auto; right: calc(12px + var(--sa-r)); align-items: flex-end; flex-direction: column-reverse; max-width: min(70vw, 380px); }

/* portrait phones: canvas on top, controls below it */
@media (orientation: portrait) {
  #stage { width: 100vw; height: 100vh; height: 100dvh; background: var(--wood0); }
  #view { height: 56.25vw; }
  #hud { height: 56.25vw; }
  #pad { top: 56.25vw; height: auto; bottom: 0; background: var(--wood1); border-top: 3px solid var(--ink); box-shadow: inset 0 3px 0 var(--brass-d); }
  #team { top: calc(56.25vw + 10px); left: 8px; right: 8px; flex-direction: row; gap: 6px; }
  .card { flex: 1; width: auto; min-width: 0; }
  .card .nm { font-size: 13px; }
  #toasts { bottom: calc(100dvh - 56.25vw + 8px); max-width: calc(100vw - 16px); }
  #combo { top: calc(30px + var(--sa-t)); right: 8px; }
  #combo b { font-size: 34px; }
  #side:not([hidden]) { display: flex; }
  #skills { bottom: calc(10px + var(--sa-b)); }
  #joy { bottom: calc(10px + var(--sa-b)); }
  .sk { width: 64px; height: 64px; }
  .tb-btn { padding: 3px 6px; font-size: 13px; }
  #topbar { gap: 4px; flex-wrap: wrap; }
  .lb-team { top: calc(56.25vw + 8px); left: 8px; right: 8px; flex-direction: row; }
  .lb-hero { flex: 1; width: auto; min-width: 0; flex-direction: column; text-align: center; gap: 2px; padding: 6px 4px; }
  .lb-hero .pw { margin: 0; text-align: center; }
  .lb-menu { left: 8px; right: 8px; width: auto; bottom: calc(12px + var(--sa-b)); }
  .lb-btn { padding: 7px 10px; }
  .lb-btn small { font-size: 12px; }
  #auth { align-content: start; padding-top: 12px; }
}
/* portrait run: what fills the space between the team cards and the controls */
#side { display: none; position: absolute; z-index: 3; left: 8px; right: 8px; top: calc(56.25vw + 66px); bottom: calc(158px + var(--sa-b)); flex-direction: column; gap: 5px; overflow: hidden; pointer-events: none; font-size: 14px; }
#side h5 { margin: 4px 0 0; font-size: 13px; color: var(--brass-l); letter-spacing: 1px; text-shadow: 1px 1px 0 var(--ink); }
.sd-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sd-stats div { display: flex; flex-direction: column; align-items: center; padding: 4px 2px; background: var(--wood0); box-shadow: var(--bevel-in); }
.sd-stats b { color: var(--gold); font-size: 14px; text-shadow: 1px 1px 0 var(--ink); white-space: nowrap; }
.sd-stats span { color: var(--dim); font-size: 12px; }
.sd-ev { padding: 3px 8px; background: #4a3a10; border: 2px solid var(--ink); color: var(--gold); display: flex; align-items: center; gap: 4px; }
.sd-ev .pi, .sd-q .pi { width: 14px; height: 14px; flex: none; }
.sd-boons { display: flex; flex-wrap: wrap; gap: 3px; } .sd-boons .chip { padding: 2px 6px; font-size: 12px; display: inline-flex; gap: 3px; align-items: center; } .sd-boons .pi { width: 12px; height: 12px; }
.sd-it { display: flex; align-items: center; gap: 6px; padding: 2px 6px 2px 2px; background: rgba(13, 9, 7, .55); border-left: 3px solid var(--rc); }
.sd-it img { width: 22px; height: 22px; image-rendering: pixelated; flex: none; }
.sd-it span { flex: 1; min-width: 0; color: var(--rc); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 1px 1px 0 var(--ink); }
.sd-it small { color: var(--dim); }
.sd-q { display: grid; grid-template-columns: auto 1fr 70px; gap: 6px; align-items: center; }
.sd-q span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-q .pbar { min-width: 0; height: 8px; }
.sd-rot { margin: auto 0 0; padding: 4px; border: 2px dashed var(--wood3); color: var(--mute); text-align: center; font-size: 13px; }
#side .note { margin: 0; }

/* ---------------------------------------------------------------- the menu window */
#modal { position: fixed; inset: 0; z-index: 30; background: rgba(5, 4, 8, .78); display: grid; place-items: center; padding: max(8px, var(--sa-t)) 8px max(8px, var(--sa-b)); touch-action: pan-y; }
.m-card { width: min(980px, 100%); max-height: calc(100vh - 16px); max-height: calc(100dvh - max(8px, var(--sa-t)) - max(8px, var(--sa-b))); display: flex; flex-direction: column; background: var(--wood1); border: 3px solid var(--ink); clip-path: var(--notch); box-shadow: inset 0 0 0 2px var(--brass-d), inset 0 0 0 4px var(--ink), inset 6px 6px 0 rgba(255, 220, 160, .05); }
.m-head { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: var(--wood3); border-bottom: 3px solid var(--ink); box-shadow: inset 0 2px 0 var(--wood4), inset 0 -2px 0 var(--brass-d); margin: 4px 4px 0; }
.m-head b { font-size: 18px; flex: 1; color: var(--brass-l); text-shadow: 2px 2px 0 var(--ink); letter-spacing: 1px; }
.m-head #m-gold { color: var(--gold); font-weight: 700; text-shadow: 1px 1px 0 var(--ink); display: flex; align-items: center; gap: 4px; }
.m-x { width: 34px; height: 34px; background: var(--wood4); box-shadow: var(--bevel); font-size: 16px; font-weight: 900; text-shadow: 1px 1px 0 var(--ink); }
.m-body { overflow: auto; padding: 10px 14px 16px; margin: 0 4px 4px; -webkit-overflow-scrolling: touch; touch-action: pan-y; min-height: 0; flex: 1 1 auto; scrollbar-color: var(--wood4) var(--wood0); }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl td { padding: 3px 6px; border-bottom: 1px dashed var(--wood3); }
.kbdlist { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kbdlist kbd { background: var(--wood0); border: 2px solid var(--ink); padding: 0 6px; font: 700 13px monospace; color: var(--parch); }
.cols { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 12px; }
@media (max-width: 700px) { .cols { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- auth */
#auth { display: grid; place-items: center; background: rgba(8, 6, 12, .7); overflow: auto; padding: 10px; }
.auth-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 9px; padding: 18px 18px 14px; background: var(--wood1); border: 3px solid var(--ink); clip-path: var(--notch); box-shadow: inset 0 0 0 2px var(--brass-d), inset 0 0 0 4px var(--ink); }
.auth-logo { text-align: center; font: 900 30px/1 "Kanit", "Arial Black", sans-serif; letter-spacing: 2px; color: var(--brass-l); text-shadow: 2px 2px 0 var(--brass-d), 4px 4px 0 var(--ink); margin-bottom: 4px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--wood0); border: 2px solid var(--ink); padding: 3px; gap: 3px; }
.auth-tabs button { padding: 7px; border: 0; background: none; color: var(--dim); font-weight: 700; }
.auth-tabs button.on { background: var(--brass); color: var(--wood0); box-shadow: inset 2px 2px 0 var(--brass-l), inset -2px -2px 0 var(--brass-d); }
.auth-card label { display: flex; flex-direction: column; gap: 4px; font-size: 15px; color: var(--dim); }
.auth-card input:not([type=checkbox]) { padding: 10px 12px; background: var(--wood0); border: 2px solid var(--ink); box-shadow: var(--bevel-in); font-size: 16px; outline: none; }
.auth-card input:focus { box-shadow: 0 0 0 2px var(--brass), var(--bevel-in); }
.auth-card label.check { flex-direction: row; align-items: center; gap: 8px; }
.auth-card label.check input { width: 18px; height: 18px; accent-color: var(--brass); }
.auth-err { min-height: 18px; color: var(--bad); font-size: 15px; }
.auth-note { margin: 2px 0 0; font-size: 13px; color: var(--mute); text-align: center; line-height: 1.5; }

/* ---------------------------------------------------------------- the camp */
#lobby { pointer-events: none; }
#lobby > * { pointer-events: auto; }
.lb-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: calc(6px + var(--sa-t)) calc(8px + var(--sa-r)) 6px calc(8px + var(--sa-l)); background: linear-gradient(rgba(13, 9, 7, .9), rgba(13, 9, 7, 0)); font-size: clamp(11px, 1.7vw, 14px); }
.lb-user { display: flex; align-items: center; gap: 8px; line-height: 1.15; text-shadow: 1px 1px 0 var(--ink); }
.lb-user b { color: var(--brass-l); }
.lb-user small { display: block; color: var(--dim); font-size: .85em; }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; font-weight: 900; background: var(--brass); color: var(--wood0); border: 2px solid var(--ink); box-shadow: inset 2px 2px 0 var(--brass-l), inset -2px -2px 0 var(--brass-d); clip-path: var(--notch-s); }
.lb-team { position: absolute; left: calc(8px + var(--sa-l)); top: calc(50px + var(--sa-t)); display: flex; flex-direction: column; gap: 6px; }
.lb-hero { display: flex; align-items: center; gap: 8px; width: clamp(150px, 24vw, 220px); padding: 5px 8px 5px 5px; background: rgba(34, 22, 14, .94); box-shadow: var(--bevel); text-align: left; }
.lb-hero.sel { background: var(--wood3); box-shadow: inset 0 0 0 2px var(--cc), var(--bevel); }
.lb-hero img { width: 40px; height: 40px; background: var(--wood0); border: 2px solid var(--ink); flex: none; }
.lb-hero b { display: block; font-size: 15px; text-shadow: 1px 1px 0 var(--ink); }
.lb-hero small { display: block; color: var(--dim); font-size: 13px; }
.lb-hero .pw { margin-left: auto; text-align: right; color: var(--gold); font-weight: 800; font-size: 14px; text-shadow: 1px 1px 0 var(--ink); }
.lb-menu { position: absolute; right: calc(8px + var(--sa-r)); bottom: calc(10px + var(--sa-b)); display: flex; flex-direction: column; gap: 6px; width: clamp(190px, 28vw, 270px); }
.lb-btn { position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 7px 12px 7px 8px; text-align: left; font-weight: 800; font-size: clamp(13px, 2vw, 16px); background: var(--wood2); box-shadow: var(--bevel); text-shadow: 1px 1px 0 var(--ink); }
.lb-btn .pi { grid-row: span 2; width: 32px; height: 32px; background-color: var(--wood0); border: 2px solid var(--ink); }
.lb-btn small { font-weight: 400; color: var(--dim); font-size: 13px; }
.lb-btn:active { transform: translateY(2px); box-shadow: var(--bevel-in); }
.lb-btn.go { background: var(--brass); color: var(--wood0); text-shadow: 1px 1px 0 var(--brass-l); box-shadow: inset 2px 2px 0 var(--brass-l), inset -2px -2px 0 var(--brass-d); }
.lb-btn.go small { color: var(--wood2); }
.lb-btn .dot { top: 4px; right: 4px; }
@media (max-height: 430px) and (orientation: landscape) { .lb-menu { gap: 4px; } .lb-btn { padding: 4px 10px 4px 6px; font-size: 15px; } .lb-btn .pi { width: 26px; height: 26px; } }

/* ---------------------------------------------------------------- maps */
.maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mapc { position: relative; padding: 0; overflow: hidden; background: var(--wood0); text-align: left; box-shadow: var(--bevel); }
.mapc img { display: block; width: 100%; aspect-ratio: 16/9; }
.mapc .mi { padding: 5px 7px 7px; font-size: 14px; line-height: 1.3; }
.mapc .mi b { font-size: 15px; display: block; color: var(--cream); }
.mapc.sel { box-shadow: inset 0 0 0 3px var(--brass-l); }
.mapc.lock img { filter: grayscale(1) brightness(.45); }
.mapc .lk { position: absolute; top: 6px; right: 6px; padding: 2px 6px; font-size: 13px; background: rgba(13, 9, 7, .85); border: 1px solid var(--ink); }
.mapc .tier { position: absolute; top: 6px; left: 6px; padding: 2px 6px; font-size: 13px; font-weight: 800; background: rgba(13, 9, 7, .85); border: 1px solid var(--ink); color: var(--gold); }
.mapdetail { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .mapdetail { grid-template-columns: 1fr; } }
.cps { display: flex; flex-wrap: wrap; gap: 5px; }
.checkpoint-summary {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 8px; padding: 8px 10px; border: 1px solid var(--menu-line); border-radius: 8px; background: #131e2f;
}
.checkpoint-summary > span, .checkpoint-option > span:first-child { display: grid; gap: 1px; min-width: 0; }
.checkpoint-summary b { color: #ffe3ad; font: 700 18px/1.2 "Kanit", sans-serif; }
.checkpoint-summary small, .checkpoint-map { color: #c3d1e2; }
.dlg-card.checkpoint-picker {
  width: min(430px, 100%); max-height: min(82dvh, 540px); display: flex; flex-direction: column;
  gap: 7px; text-align: start; overflow: hidden;
}
.checkpoint-picker h3 { margin: 0; line-height: 1.15; }
.checkpoint-picker .dlg-btns { margin-top: 0; }
.checkpoint-list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  padding: 2px; scrollbar-color: #6985a5 #141e30;
}
.checkpoint-option {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 5px 9px; text-align: start;
  background: #1f2c40; border: 1px solid #425970; border-radius: 6px; color: #f7eee1; font: inherit;
}
.checkpoint-option + .checkpoint-option { margin-top: 4px; }
.checkpoint-option[aria-pressed="true"] { border-color: #eac482; background: #39404b; color: #ffe3ad; }
.checkpoint-option:focus-visible { outline: 2px solid #c1f0ff; outline-offset: -2px; }
.checkpoint-option small, .checkpoint-level { color: #c7d4e3; font-size: 12px; }
.checkpoint-level { white-space: nowrap; }
.checkpoint-paging { display: flex; justify-content: space-between; align-items: center; gap: 5px; }
.checkpoint-paging .btn { white-space: normal; min-height: 40px; }
.checkpoint-picker .dlg-btns .btn { min-height: 42px; white-space: normal; }
.icons { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.icons img, img.ico { width: 32px; height: 32px; }

/* ---------------------------------------------------------------- bag */
.bag { display: grid; grid-template-columns: minmax(250px, 320px) 1fr; gap: 14px; align-items: start; }
@media (max-width: 760px) { .bag { grid-template-columns: 1fr; } }
.herotabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.herotab { display: flex; align-items: center; gap: 4px; padding: 3px 8px 3px 3px; background: var(--wood2); box-shadow: var(--bevel); font-size: 14px; font-weight: 700; }
.herotab img { width: 24px; height: 24px; }
.herotab.on { background: var(--wood3); box-shadow: inset 0 0 0 2px var(--cc), var(--bevel); }
/* the paper doll: armour down the left, weapon and jewellery down the right */
.doll { position: relative; display: grid; grid-template-columns: 58px 1fr 58px; grid-template-rows: repeat(4, 58px); grid-template-areas: "head body weapon" "chest body ring" "legs body neck" "feet body info"; gap: 6px; align-items: center; justify-items: center; padding: 10px; background: var(--wood0); border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px var(--wood3); clip-path: var(--notch); }
.doll .big { grid-area: body; width: 100%; max-width: 120px; }
.doll .info { grid-area: info; font-size: 12px; text-align: center; line-height: 1.25; color: var(--dim); }
.slot { position: relative; width: 56px; height: 56px; display: grid; place-items: center; background: var(--wood1); box-shadow: var(--bevel-in); font-size: 12px; color: var(--mute); text-align: center; line-height: 1.1; padding: 2px; }
.slot .pi { width: 26px; height: 26px; opacity: .35; filter: grayscale(1); }
.slot.has { background: color-mix(in srgb, var(--rc) 22%, var(--wood0)); box-shadow: inset 0 0 0 2px var(--rc), var(--bevel-in); }
.slot img { width: 42px; height: 42px; }
.slot small { position: absolute; bottom: 1px; right: 3px; font-size: 12px; color: var(--gold); font-weight: 800; text-shadow: 1px 1px 0 var(--ink); }
.slot.sel { box-shadow: inset 0 0 0 3px var(--cream); }
.power { margin: 10px 0 4px; display: flex; align-items: baseline; gap: 8px; }
.power b { font-size: 22px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; font-size: 15px; }
.stats div { display: flex; justify-content: space-between; gap: 6px; border-bottom: 1px dashed var(--wood3); padding: 1px 0; }
.sets { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.setline { font-size: 14px; padding: 5px 8px; background: var(--wood0); border-left: 3px solid var(--tc, var(--brass)); }
.setline b { color: var(--tc); }
.setline span { color: var(--mute); } .setline span.on { color: var(--good); font-weight: 700; }
.bagbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.cap { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--dim); }
.cap .pbar { width: 90px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 5px; }
.it { position: relative; aspect-ratio: 1; display: grid; place-items: center; padding: 0; background: color-mix(in srgb, var(--rc) 16%, var(--wood0)); box-shadow: inset 0 0 0 2px var(--rc), var(--bevel-in); }
.it img { width: 72%; height: 72%; }
.it.uq { box-shadow: inset 0 0 0 2px var(--uq), inset 0 0 0 4px var(--ink), var(--bevel-in); animation: uq 1.6s steps(2) infinite; }
@keyframes uq { 50% { box-shadow: inset 0 0 0 2px var(--cream), inset 0 0 0 4px var(--ink), var(--bevel-in); } }
.it.sel { box-shadow: inset 0 0 0 3px var(--cream), inset 0 0 0 5px var(--rc); }
.it.no img { opacity: .35; filter: grayscale(.7); }
.it small { position: absolute; font-size: 11px; line-height: 1; text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink); pointer-events: none; font-weight: 700; }
.it .lv { left: 4px; top: 4px; color: var(--cream); }
.it .pl { right: 4px; top: 4px; color: var(--gold); }
.it .lk { right: 3px; bottom: 3px; }
.it .lk .pi { width: 10px; height: 10px; }
.it .up { left: 4px; bottom: 3px; color: var(--good); font-weight: 900; font-size: 13px; }
.it .nw { --notice-dot-size: 14px; background: #ff785d; }
.it .rs { left: 50%; bottom: 3px; transform: translateX(-50%); color: var(--rc); font-size: 9px; letter-spacing: -1px; white-space: nowrap; }
.it .ck { position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; font-weight: 900; color: var(--cream); background: rgba(232, 90, 68, .45); text-shadow: 2px 2px 0 var(--ink); }
.it.empty { background: var(--wood1); box-shadow: var(--bevel-in); opacity: .5; }
.detail { margin-top: 10px; padding: 10px 12px; background: var(--wood0); box-shadow: inset 0 0 0 2px var(--rc), var(--bevel-in); }
.detail.uq { box-shadow: inset 0 0 0 2px var(--uq), inset 0 0 0 4px var(--ink); }
.detail .dh { display: flex; gap: 10px; align-items: center; }
.detail .dh img { width: 52px; height: 52px; background: var(--wood1); border: 2px solid var(--ink); }
.detail h3 { margin: 0 0 2px; color: var(--rc); font-size: 16px; text-shadow: 2px 2px 0 var(--ink); }
.detail.uq h3 { color: var(--uq); }
.detail .lore { font-style: italic; color: var(--parch-d); font-size: 14px; margin: 4px 0; }
.detail .ln { display: grid; grid-template-columns: 1fr auto 64px; gap: 6px; font-size: 15px; padding: 2px 0; border-bottom: 1px dashed var(--wood3); }
.detail .ln.aff span:first-child { color: var(--rc); }
.detail .ln em { font-style: normal; text-align: right; font-size: 14px; }
.detail .setinfo { margin-top: 6px; font-size: 14px; color: var(--dim); }
.sellbar { position: sticky; bottom: -16px; margin: 10px -14px -16px; padding: 8px 14px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--wood2); border-top: 3px solid var(--ink); }

/* ---------------------------------------------------------------- team */
.roster { display: flex; flex-direction: column; gap: 6px; }
.hcard { display: flex; gap: 8px; align-items: center; padding: 6px; background: var(--wood2); box-shadow: var(--bevel); text-align: left; }
.hcard.sel { background: var(--wood3); box-shadow: inset 0 0 0 2px var(--cc), var(--bevel); }
.hcard.locked { opacity: .6; }
.hcard img { width: 44px; height: 44px; background: var(--wood0); border: 2px solid var(--ink); flex: none; }
.hcard .meta { flex: 1; min-width: 0; font-size: 14px; line-height: 1.3; }
.hcard .meta b { font-size: 14px; }
.slots { display: flex; gap: 3px; }
.slotbtn { width: 28px; height: 28px; background: var(--wood0); box-shadow: var(--bevel-in); font-size: 14px; font-weight: 800; }
.slotbtn.on { background: var(--brass); color: var(--wood0); box-shadow: inset 2px 2px 0 var(--brass-l), inset -2px -2px 0 var(--brass-d); }
.skillrow { display: flex; align-items: center; gap: 8px; padding: 6px; background: var(--wood2); box-shadow: var(--bevel); margin-bottom: 5px; font-size: 14px; flex-wrap: wrap; }
.skillrow.eq { box-shadow: inset 0 0 0 2px var(--cc), var(--bevel); }
.skillrow .ic { width: 42px; height: 42px; flex: none; background: var(--ico) center / cover no-repeat var(--wood0); border: 2px solid var(--ink); image-rendering: pixelated; }
.skillrow .tx { flex: 1; min-width: 140px; line-height: 1.3; }
.skillrow .tx small { color: var(--dim); display: block; }
.row > img { width: 52px; height: 52px; background: var(--wood0); border: 2px solid var(--ink); }

/* ---------------------------------------------------------------- summary, quests, boons, codex, settings */
.summary { text-align: center; }
.summary h2 { margin: 4px 0 2px; font: 900 28px/1.1 "Kanit", "Arial Black", sans-serif; letter-spacing: 1px; text-shadow: 3px 3px 0 var(--ink); }
.sumgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; margin: 12px 0; }
.sumgrid div { padding: 8px; background: var(--wood0); box-shadow: var(--bevel-in); }
.sumgrid b { display: block; font-size: 20px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink); }
.sumgrid span { font-size: 14px; color: var(--dim); }
.defeat-recap { margin: 10px 0; padding: 8px 12px; background: var(--wood0); border-inline-start: 3px solid #ff7569; text-align: start; }
.defeat-recap h4, .defeat-recap p { margin: 4px 0; }
.account-summary-rewards { display: block; margin: 8px auto; }
.build-hero { margin: 10px 0; }
.build-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 10px; margin: 10px 0; }
.build-cards article { min-width: 0; padding: 12px; border: 1px solid var(--menu-line); border-radius: 9px; background: #162332; }
.build-cards article p { margin: 6px 0 10px; }
.build-cards article small, .evo-reveal small { display: block; color: var(--dim); }
.evo-option { display: grid; gap: 4px; margin-top: 9px; padding: 8px 10px; border-inline-start: 2px solid var(--evo); background: #0c1926; }
.evo-option b, .evo-reveal b { color: var(--evo); }
.evo-option .btn { justify-self: start; }
.evo-reveal { position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: center; gap: 13px; margin: 10px 0; padding: 22px; background: #101b2d; border: 1px solid var(--evo); border-radius: 12px; }
.evo-reveal::before, .evo-reveal::after { content: ""; position: absolute; pointer-events: none; inset: 50% auto auto 37px; width: 105px; height: 105px; border-radius: 50%; z-index: -1; animation: evo-surge 850ms ease-out both; }
.evo-reveal::before { background: radial-gradient(circle, var(--evo), transparent 65%); }
.evo-reveal::after { border: 2px dashed var(--evo); animation-delay: 75ms; }
@keyframes evo-surge { from { transform: translate(-50%, -50%) scale(.15) rotate(-50deg); opacity: 1; } to { transform: translate(-50%, -50%) scale(2.3) rotate(60deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .evo-reveal::before, .evo-reveal::after { animation: none; opacity: .25; } }
.loot { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.loot .it { width: 50px; }
.summary .col { display: flex; flex-direction: column; gap: 8px; width: min(320px, 100%); margin: 12px auto 0; }
.quest { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 6px; background: var(--wood2); box-shadow: var(--bevel); }
.quest.done { box-shadow: inset 0 0 0 2px var(--good), var(--bevel); }
.quest.claimed { opacity: .55; }
.quest.bonus { background: var(--wood1); box-shadow: inset 0 0 0 2px var(--brass), var(--bevel); }
.quest .ic { width: 38px; height: 38px; flex: none; display: grid; place-items: center; background: var(--wood0); border: 2px solid var(--ink); }
.quest .ic .pi { width: 26px; height: 26px; }
.quest .tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 15px; }
.quest .pbar { min-width: 80px; }
.boons { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 6px 0 4px; }
.boon { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 10px; text-align: center; background: var(--wood2); box-shadow: inset 0 0 0 2px var(--brass), inset 0 0 0 4px var(--ink), var(--bevel); }
.boon:active, .boon:hover { background: var(--wood3); }
.boon .pi { width: 40px; height: 40px; }
.boon b { font-size: 16px; color: var(--brass-l); text-shadow: 2px 2px 0 var(--ink); }
.boon small { font-size: 14px; color: var(--cream); line-height: 1.4; }
.boonlist { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.boonlist .chip .pi { width: 1.2em; height: 1.2em; }
.codex-tabs { margin-bottom: 8px; }
.codex { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.codex-card { padding: 8px; background: var(--wood2); box-shadow: var(--bevel); display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; font-size: 14px; }
.codex-card img { width: 64px; height: 64px; background: var(--wood0); border: 2px solid var(--ink); object-fit: contain; }
.codex-card b { font-size: 15px; }
.codex-card.locked { opacity: .6; }
.codex-card.boss { grid-column: 1 / -1; flex-direction: row; text-align: left; align-items: flex-start; gap: 12px; box-shadow: inset 0 0 0 2px var(--bc, var(--bad)), var(--bevel); }
.codex-card.boss img { width: 96px; height: 96px; }
.codex-card.boss .bt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.codex-card.boss ul { margin: 2px 0; padding-left: 18px; color: var(--dim); }
.codex-card .uqline { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.codex-card .uqline img { width: 34px; height: 34px; }
.setrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 4px 0; }
.setrow > span { min-width: 110px; font-size: 15px; }
.binds { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr) minmax(80px, 110px)); gap: 4px 10px; font-size: 14px; }
.binds span { align-self: center; color: var(--dim); }
.keybtn { padding: 4px 8px; min-height: 30px; background: var(--wood0); box-shadow: var(--bevel-in); font: 700 14px monospace; text-align: center; color: var(--parch); }
.keybtn.wait { background: var(--brass); color: var(--wood0); animation: blink 1s steps(2) infinite; }
.imptext { display: block; width: 100%; min-height: 64px; margin: 8px 0 6px; padding: 8px; background: var(--wood0); box-shadow: var(--bevel-in); font-size: 13px; resize: vertical; touch-action: auto; }
.warnbox { padding: 8px 10px; margin-bottom: 8px; border: 2px solid var(--bad); background: #3a1410; color: #ffd0c8; font-size: 15px; }
.help p { margin: 6px 0; font-size: 14px; line-height: 1.6; }
.help ul { margin: 6px 0 10px; padding-left: 20px; font-size: 15px; line-height: 1.75; }
.help b { color: var(--brass-l); }

/* ---------------------------------------------------------------- online, titles, materials, forge, ranking, admin */
.auth-mode { text-align: center; font-size: 14px; color: var(--mute); padding: 3px 0; border: 2px dashed var(--wood3); }
.auth-mode.on { color: var(--good); border-color: #3a5a2a; }
.ptitle { display: block; font-style: normal; font-size: .8em; color: var(--gold); text-shadow: 1px 1px 0 var(--ink); }
td .ptitle { display: inline; }
.sync { font-size: 13px; padding: 2px 7px; border: 2px solid var(--ink); background: #2e4a20; color: var(--good); white-space: nowrap; }
.sync.warn { background: #4a3a10; color: var(--gold); } .sync.bad { background: #4a1a12; color: #ffb0a0; }
.lb-top { flex-wrap: wrap; row-gap: 4px; }
.lb-top .tb-btn { min-width: 32px; justify-content: center; }
.tb-btn.admin { background: #5a3a10; box-shadow: inset 2px 2px 0 var(--brass), inset -2px -2px 0 var(--brass-d); }
@media (max-width: 520px) { .lb-top .tb-btn { padding: 2px 5px; min-height: 26px; } .lb-top .tb-gold { padding: 2px 5px; } }
.mats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.mat { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px 2px 4px; background: var(--wood0); border: 2px solid var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.mat .pi { width: 18px; height: 18px; }
.mat.sm { padding: 0 4px 0 2px; border-width: 1px; font-size: 13px; background: transparent; }
.mat.sm .pi { width: 14px; height: 14px; }
.mat.short { color: var(--bad); }
.forge { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.forge .btn { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; white-space: normal; text-align: left; }
.board td { padding: 5px 8px; }
.board .rk { width: 48px; font-weight: 900; color: var(--dim); white-space: nowrap; }
.board .rk .pi { width: 14px; height: 14px; margin-right: 2px; }
.board .vl { text-align: right; white-space: nowrap; color: var(--gold); font-weight: 700; }
.board tr.me { background: rgba(240, 200, 96, .12); outline: 2px solid var(--brass-d); }
.board-podium { display: flex; align-items: end; justify-content: center; gap: clamp(5px, 1.5vw, 14px); margin: 12px 0 16px; }
.board-place {
  --medal: #e2ad73; --plinth: #714931;
  position: relative; flex: 1 1 0; min-width: 0; max-width: 196px; overflow: hidden;
  display: grid; justify-items: center; gap: 4px; padding: 8px clamp(4px, 1vw, 10px);
  border: 1px solid color-mix(in srgb, var(--medal) 60%, #22273d); border-radius: 10px 10px 5px 5px;
  background: radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--medal) 21%, #17233c), #111626 65%);
  color: var(--cream); text-align: center;
}
.board-place.place-1 { order: 2; --medal: #ffdc82; --plinth: #7c571f; }
.board-place.place-2 { order: 1; --medal: #cbdcf4; --plinth: #495678; }
.board-place.place-3 { order: 3; }
.board-place.me { box-shadow: inset 0 0 0 2px var(--medal); }
.board-medal {
  display: inline-flex; align-items: center; gap: 3px; color: var(--medal);
  font: 800 17px/1 "Kanit", sans-serif; text-shadow: 0 2px #0e1322;
}
.board-medal .pi { width: 16px; height: 16px; }
.board-stage { width: 100%; height: clamp(66px, 19vw, 132px); position: relative; display: grid; place-items: end center; padding-bottom: 10px; }
.place-1 .board-stage { height: clamp(82px, 23vw, 153px); }
.board-stage .board-figure { width: min(100%, clamp(62px, 17vw, 116px)); }
.board-period, .board-paging { margin: 8px 0; }
.board-paging { justify-content: center; }
.place-1 .board-figure { width: min(100%, clamp(74px, 20vw, 136px)); }
.board-stage > .pi { align-self: center; opacity: .5; }
.board-plinth {
  position: absolute; inset: auto 9% 0; height: 14px; border-radius: 50% 50% 24% 24%;
  background: linear-gradient(var(--medal) 1px, var(--plinth) 3px, #090c17);
  box-shadow: 0 3px 8px #070a13;
}
.board-caption { width: 100%; display: grid; gap: 2px; min-width: 0; }
.board-caption > :not(strong) { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.board-caption b { font: 700 clamp(13px, 3vw, 18px)/1.25 "Kanit", sans-serif; }
.board-caption small, .board-caption em { font-size: 11px; color: var(--dim); }
.board-caption strong { font-size: clamp(11px, 2.6vw, 14px); line-height: 1.25; color: var(--medal); overflow-wrap: anywhere; }
.board th:first-child { width: 1%; white-space: nowrap; }
.board-player-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; }
.board-profile { font-size: 11px; min-height: 26px; padding: 2px 6px; }
.board-caption > .board-profile { justify-self: center; max-width: 100%; }
@media (max-width: 540px) {
  .board td, .board th { padding-inline: 5px; }
  .board .vl { white-space: normal; overflow-wrap: anywhere; }
}
.adm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 10px; margin-bottom: 8px; }
.adm-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 14px; color: var(--dim); }
.adm-grid label.check { flex-direction: row; align-items: center; }
.adm-num, .adm-search, details.pw input { background: var(--wood0); color: var(--cream); border: 2px solid var(--ink); box-shadow: var(--bevel-in); padding: 6px; font-size: 15px; }
.adm-search { flex: 1; min-width: 140px; }
.adm-cols { display: grid; grid-template-columns: minmax(200px, 300px) 1fr; gap: 12px; margin-top: 8px; }
@media (max-width: 700px) { .adm-cols { grid-template-columns: 1fr; } }
.adm-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow: auto; }
.adm-user { text-align: left; padding: 6px 8px; background: var(--wood2); border: 2px solid var(--ink); box-shadow: var(--bevel); }
.adm-user.on { box-shadow: inset 0 0 0 2px var(--brass-l), var(--bevel); }
.adm-user small { display: block; font-size: 13px; }
.adm-detail { min-width: 0; }
.warnbox .sel { user-select: text; -webkit-user-select: text; font-family: monospace; }
details.pw { margin: 6px 0; font-size: 15px; }
details.pw summary { cursor: pointer; color: var(--brass-l); }
details.pw .row { margin-top: 6px; }

/* ---------------------------------------------------------------- v6: news, labels, bag panes, outfits, tips */
.lb-news { position: absolute; left: calc(clamp(150px, 24vw, 220px) + 20px + var(--sa-l)); right: calc(8px + var(--sa-r)); top: calc(50px + var(--sa-t)); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 14px; }
.lb-news > div { max-width: 460px; }
.lb-news > div { display: flex; align-items: center; gap: 6px; padding: 4px 8px; background: rgba(22, 14, 9, .92); border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px var(--brass-d); text-shadow: 1px 1px 0 var(--ink); }
.lb-news > div.ev { background: #4a3a10; color: var(--gold); }
.lb-news .pi { width: 16px; height: 16px; flex: none; }
.lb-news span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.lb-news b { white-space: nowrap; }

.lb-top .tb-btn.lbl { gap: 4px; }
.lb-top .tb-btn.lbl small { font-size: 13px; font-weight: 700; color: var(--cream); }
@media (max-width: 900px) { .lb-top .tb-btn.lbl { flex-direction: column; gap: 0; padding: 2px 5px; line-height: 1; } .lb-top .tb-btn.lbl small { font-size: 11px; color: var(--dim); } .lb-top .tb-btn.lbl .pi { width: 16px; height: 16px; } }
button.sync { cursor: pointer; font-family: inherit; font-weight: 700; }
.sync.bad { animation: blink 1s steps(2) infinite; }
.bagtabs { display: none; gap: 6px; margin-bottom: 8px; }
.bagtabs .chip { flex: 1; display: inline-flex; justify-content: center; align-items: center; gap: 6px; padding: 7px 10px; font-size: 15px; }
.bagtabs .pi { width: 16px; height: 16px; }
@media (max-width: 760px) {
  .bagtabs { display: flex; }
  .bag.pane-bag > div:first-child, .bag.pane-gear > div:last-child { display: none; }
}
.outfits { display: flex; flex-wrap: wrap; gap: 6px; }
.outfits .of { display: inline-flex; }
.outfits .of .chip:first-child { min-width: 64px; }
.outfits .of .chip + .chip { margin-left: 2px; font-size: 13px; padding: 5px 7px; }
.btn.salv { background: #2f4a5a; box-shadow: inset 2px 2px 0 #6a98b0, inset -2px -2px 0 #16242c; }
.tip { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 8px 10px; background: #2c2410; border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--brass-d); font-size: 15px; line-height: 1.45; }
.tip > .pi { width: 20px; height: 20px; flex: none; }
.tip span { flex: 1; }
.tip .chip { flex: none; }
@media (max-width: 520px) { .tip { flex-wrap: wrap; } .tip .chip { margin-left: auto; } }

/* portrait camp: these must come after the camp's base rules above (they used to be overridden by them) */
@media (orientation: portrait) {
  .lb-team { top: calc(56.25vw + 8px); left: 8px; right: 8px; flex-direction: row; }
  .lb-hero { flex: 1; width: auto; min-width: 0; flex-direction: column; text-align: center; gap: 2px; padding: 6px 4px; }
  .lb-hero .pw { margin: 0; text-align: center; }
  .lb-menu { left: 8px; right: 8px; width: auto; bottom: calc(12px + var(--sa-b)); }
  .lb-news { left: 8px; right: 8px; top: calc(56.25vw + 128px); align-items: stretch; }
  .lb-news > div { max-width: none; }
  .lb-top { flex-wrap: wrap; row-gap: 4px; }
  .tb-stage em.bt { display: none; }   /* the panel under the team shows the event */
}

/* ---- PvP 1v1 */
.lb-btn.pvp { background: #4a0e1c; color: #ffd8dc; box-shadow: inset 2px 2px 0 #8a1a30, inset -2px -2px 0 #24060e; }
.lb-btn.pvp small { color: #ff9aa8; }
#hud.pvp #btn-auto, #hud.pvp #btn-walk, #hud.pvp [data-m="bag"] { display: none; }
#hud.pvp #boss { border-color: #ff3048; }
.pvp-code { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px; margin: 8px 0; background: var(--wood0); border: 2px solid var(--ink); }
.pvp-code b { font-size: 46px; letter-spacing: 10px; color: var(--brass-l, #ffd45e); font-family: ui-monospace, monospace; }
.pvp-go { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.pvp-go input { width: 7.5em; font: inherit; font-size: 18px; letter-spacing: 4px; text-transform: uppercase; padding: 6px 8px; background: var(--wood0); color: inherit; border: 2px solid var(--ink); }
.pvp-res { text-align: center; padding: 18px; margin-bottom: 8px; border: 2px solid var(--ink); background: var(--wood0); }
.pvp-res h2 { margin: 0 0 4px; font-size: 40px; }
.pvp-res.win h2 { color: #6dffa0; } .pvp-res.lose h2 { color: #ff6a5a; } .pvp-res.draw h2 { color: #ffd45e; }
.pvp-roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }

/* ---------------------------------------------------------------- v7: item popup over the bag */
#ipop { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; padding: max(10px, var(--sa-t)) 10px max(10px, var(--sa-b)); background: rgba(5, 4, 8, .62); touch-action: pan-y; }
@keyframes ipfade { from { opacity: 0; } }
.ip-card { position: relative; width: min(460px, 100%); max-height: calc(100dvh - 20px); display: flex; flex-direction: column; margin: 0; padding: 0; background: var(--wood1); border: 3px solid var(--ink); clip-path: var(--notch);
  box-shadow: inset 0 0 0 2px var(--rc), inset 0 0 0 4px var(--ink), inset 0 0 0 6px color-mix(in srgb, var(--rc) 25%, var(--wood1)); }
.ip-card.uq { box-shadow: inset 0 0 0 2px var(--uq), inset 0 0 0 4px var(--ink), inset 0 0 0 6px #5a3a10; }
@keyframes ippop { from { transform: translateY(14px) scale(.96); opacity: 0; } }
.ip-head { display: flex; gap: 10px; align-items: center; padding: 12px 12px 8px 14px; background: linear-gradient(color-mix(in srgb, var(--rc) 22%, var(--wood2)), var(--wood1)); border-bottom: 2px solid var(--ink); margin: 6px 6px 0; }
.ip-ico { position: relative; flex: none; width: 60px; height: 60px; display: grid; place-items: center; background: color-mix(in srgb, var(--rc) 18%, var(--wood0)); border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--rc); }
.ip-ico img { width: 48px; height: 48px; }
.ip-ico small { position: absolute; right: 2px; top: 1px; font-size: 13px; font-weight: 900; color: var(--gold); text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink); }
.ip-tt { flex: 1; min-width: 0; }
.ip-tt h3 { margin: 0 0 3px; font-size: 17px; line-height: 1.25; color: var(--rc); text-shadow: 2px 2px 0 var(--ink); }
.ip-card.uq .ip-tt h3 { color: var(--uq); }
.ip-tt h3 .pl { color: var(--gold); }
.ip-tt .dim { font-size: 14px; }
.ip-x { flex: none; align-self: flex-start; }
.ip-tabs { display: flex; gap: 4px; padding: 8px 10px 0; margin: 0 6px; }
.ip-tabs .chip { flex: 1; display: inline-flex; justify-content: center; align-items: center; gap: 4px; padding: 7px 6px; font-size: 15px; }
.ip-tabs .pi { width: 16px; height: 16px; }
.ip-body { overflow: auto; padding: 10px 14px 14px; margin: 0 6px 6px; min-height: 0; flex: 1 1 auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; scrollbar-color: var(--wood4) var(--wood0); }
.ip-body .verdict { margin: 0 0 6px; font-size: 15px; }
.ip-body .ln { display: grid; grid-template-columns: 1fr auto 64px; gap: 6px; font-size: 15px; padding: 3px 0; border-bottom: 1px dashed var(--wood3); }
.ip-body .ln.aff span:first-child { color: var(--rc); }
.ip-body .ln em { font-style: normal; text-align: right; font-size: 14px; }
.ip-body .lore { font-style: italic; color: var(--parch-d); font-size: 14px; margin: 0 0 6px; }
.ip-body .setinfo { margin-top: 8px; font-size: 14px; color: var(--dim); line-height: 1.5; }
.ip-acts { margin-top: 12px; }
.ip-acts .btn { flex: 1 1 auto; justify-content: center; display: inline-flex; align-items: center; gap: 4px; }
.ip-card.fx-up { animation: fxup .5s steps(5); }
.ip-card.fx-down, .ip-card.fx-keep { animation: fxshake .35s steps(6); }
.ip-card.fx-break { animation: fxbreak .6s steps(8); }
.ip-card.fx-saved { animation: fxsaved .5s steps(5); }
@keyframes fxup { 0%, 100% { filter: none; } 30% { filter: brightness(1.8) sepia(.5); } }
@keyframes fxshake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes fxbreak { 0%, 100% { transform: none; filter: none; } 15% { transform: translate(-8px, 2px) rotate(-1deg); filter: brightness(2) saturate(0); } 30% { transform: translate(8px, -2px) rotate(1deg); filter: hue-rotate(-30deg) saturate(3); } 50% { transform: translate(-5px, 1px); } 70% { transform: translate(4px, 0); } }
@keyframes fxsaved { 0%, 100% { filter: none; } 30% { filter: brightness(1.5) hue-rotate(160deg); } }
@keyframes ipsheet { from { transform: translateY(40%); opacity: .3; } }
@media (max-width: 560px), (orientation: portrait) and (pointer: coarse) {
  /* phones: a bottom sheet, thumb-reachable */
  #ipop { place-items: end center; padding: 0; }
  .ip-card { width: 100%; max-height: min(88dvh, calc(100dvh - 24px)); clip-path: none; border-bottom: 0; padding-bottom: var(--sa-b); }
  .ip-acts .btn { padding: 11px 10px; }
}
@media (max-height: 460px) and (orientation: landscape) { .ip-card { width: min(640px, 100%); } .ip-head { padding: 6px 10px 6px 12px; } .ip-ico { width: 46px; height: 46px; } .ip-ico img { width: 36px; height: 36px; } }

/* enhance tab */
.enh-plus { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px; margin-bottom: 8px; background: var(--wood0); border: 2px solid var(--ink); box-shadow: var(--bevel-in); flex-wrap: wrap; }
.enh-plus span { font: 900 30px/1 "Kanit", "Arial Black", sans-serif; text-shadow: 2px 2px 0 var(--ink); }
.enh-plus .from { color: var(--dim); } .enh-plus .to { color: var(--gold); } .enh-plus .arr { font-size: 18px; color: var(--brass); animation: blink 1s steps(2) infinite; }
.enh-plus small { flex-basis: 100%; text-align: center; color: var(--dim); font-size: 14px; }
.enh-res { text-align: center; font-weight: 900; padding: 6px; margin-bottom: 8px; border: 2px solid var(--ink); font-size: 15px; text-shadow: 1px 1px 0 var(--ink); animation: ippop .2s steps(3); }
.enh-res.r-up { background: #2e5a20; color: #d8ffb0; } .enh-res.r-keep { background: var(--wood3); color: var(--cream); }
.enh-res.r-down { background: #5a4410; color: var(--gold); } .enh-res.r-break { background: #6a1810; color: #ffd0c0; } .enh-res.r-saved { background: #183a5a; color: #c0ecff; }
.obar { display: flex; height: 16px; background: var(--wood0); border: 2px solid var(--ink); overflow: hidden; }
.obar i { display: block; height: 100%; }
.obar .ok { background: repeating-linear-gradient(90deg, #6ad04a 0 6px, #4ea83a 6px 7px); }
.obar .keep { background: repeating-linear-gradient(90deg, #8a7a6a 0 6px, #6a5a4a 6px 7px); }
.obar .down { background: repeating-linear-gradient(90deg, #e0b040 0 6px, #b08820 6px 7px); }
.obar .brk { background: repeating-linear-gradient(90deg, #e8503a 0 6px, #b0301e 6px 7px); }
.olegend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 5px 0 8px; font-size: 14px; font-weight: 700; }
.warn { color: #f0c040; } .cool { color: var(--cool); }
.enh-cost { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; font-size: 15px; }
.enh-cost .mat.sm { font-size: 15px; padding: 2px 6px; border-width: 2px; background: var(--wood0); }
.enh-charms { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.charm { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 6px 8px; text-align: left; background: var(--wood0); border: 2px solid var(--ink); clip-path: var(--notch-s); box-shadow: var(--bevel-in); }
.charm .pi { grid-row: span 2; width: 26px; height: 26px; }
.charm b { font-size: 15px; } .charm small { font-size: 13px; color: var(--dim); }
.charm.on { background: #2a3a5a; box-shadow: inset 0 0 0 2px var(--cool), var(--bevel); }
.charm.on b::after { content: " \2713"; color: var(--good); }
.charm[disabled] { opacity: .45; }
.enh-go { flex: 1; justify-content: center; display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 380px) { .enh-charms { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- shop */
.shop-hero { padding: 10px 12px; margin-bottom: 4px; background: linear-gradient(90deg, #3a2410, var(--wood0)); border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--brass-d); }
.sh-sign { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sh-sign > .pi { width: 36px; height: 36px; }
.sh-sign b { display: block; font-size: 18px; color: var(--brass-l); text-shadow: 2px 2px 0 var(--ink); }
.sh-sign small { color: var(--dim); font-size: 14px; }
.shop-hero .mats { margin: 0; }
.shopgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; }
.shopc { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; background: var(--wood2); border: 2px solid var(--ink); clip-path: var(--notch-s); box-shadow: var(--bevel); }
.shopc.rare { background: linear-gradient(90deg, #1a2a48, var(--wood2)); box-shadow: inset 0 0 0 2px #4a8ad0, var(--bevel); }
.shopc.box { background: linear-gradient(90deg, #3a2a10, var(--wood2)); }
.sc-ico { width: 42px; height: 42px; display: grid; place-items: center; background: var(--wood0); border: 2px solid var(--ink); }
.sc-ico .pi { width: 32px; height: 32px; }
.sc-tx { min-width: 0; } .sc-tx b { display: block; font-size: 14px; text-shadow: 1px 1px 0 var(--ink); } .sc-tx small { display: block; font-size: 13px; color: var(--dim); line-height: 1.4; }
.shopc .btn { display: inline-flex; align-items: center; gap: 4px; }
.shopc .tag { position: absolute; right: 6px; top: 3px; font-size: 11px; font-weight: 900; color: var(--gold); text-shadow: 1px 1px 0 var(--ink); letter-spacing: 1px; }
@media (max-width: 420px) { .shopgrid { grid-template-columns: 1fr; } .shopc { grid-template-columns: auto 1fr; } .shopc .btn { grid-column: 1 / -1; justify-content: center; } }

/* ---------------------------------------------------------------- v7: a grander camp */
.lb-vig { position: absolute; inset: 0; pointer-events: none !important; background: radial-gradient(ellipse 75% 70% at 52% 62%, transparent 55%, rgba(4, 2, 12, .55) 100%), linear-gradient(transparent 70%, rgba(6, 3, 2, .45)); }
.lb-crest { position: absolute; left: 50%; top: calc(48px + var(--sa-t)); transform: translateX(-50%); text-align: center; pointer-events: none !important; white-space: nowrap; }
.lb-crest b { display: block; font: 900 clamp(22px, 4.4vw, 46px)/1 "Kanit", "Arial Black", sans-serif; letter-spacing: .12em; color: var(--brass-l);
  text-shadow: 0 -2px 0 #fff4c0, 3px 3px 0 var(--brass-d), 5px 5px 0 var(--ink), 0 0 18px rgba(255, 170, 60, .55); animation: crest 4s ease-in-out infinite; }
.lb-crest small { display: inline-block; margin-top: 6px; padding: 2px 14px; font-size: clamp(10px, 1.4vw, 13px); letter-spacing: .3em; color: var(--parch); background: rgba(13, 9, 7, .65); border-top: 2px solid var(--brass-d); border-bottom: 2px solid var(--brass-d); text-shadow: 1px 1px 0 var(--ink); }
@keyframes crest { 50% { text-shadow: 0 -2px 0 #fff4c0, 3px 3px 0 var(--brass-d), 5px 5px 0 var(--ink), 0 0 28px rgba(255, 190, 80, .8); } }
.lb-top { background: linear-gradient(rgba(10, 6, 16, .95), rgba(10, 6, 16, .6) 70%, rgba(10, 6, 16, 0)); }
.lb-hero { position: relative; background: linear-gradient(90deg, color-mix(in srgb, var(--cc) 22%, #1a1018), rgba(26, 16, 12, .94) 60%); box-shadow: inset 3px 0 0 var(--cc), var(--bevel); transition: transform .12s; }
.lb-hero:hover { transform: translateX(3px); }
.lb-hero.sel { background: linear-gradient(90deg, color-mix(in srgb, var(--cc) 40%, #1a1018), var(--wood3) 70%); box-shadow: inset 0 0 0 2px var(--cc), inset 5px 0 0 var(--cc), var(--bevel); }
.lb-btn { background: linear-gradient(var(--wood3), var(--wood2) 45%, #26170e); box-shadow: inset 2px 2px 0 rgba(255, 220, 160, .16), inset -2px -2px 0 rgba(0, 0, 0, .5), inset 0 0 0 4px rgba(200, 144, 46, .12); overflow: hidden; transition: transform .1s, filter .1s; }
.lb-btn::before, .lb-btn::after { content: ""; position: absolute; width: 4px; height: 4px; background: var(--brass); box-shadow: inset -1px -1px 0 var(--brass-d); top: 5px; pointer-events: none; }
.lb-btn::before { left: 5px; } .lb-btn::after { right: 5px; bottom: 5px; top: auto; }
.lb-btn:hover { filter: brightness(1.15); transform: translateX(-3px); }
.lb-btn .pi { background-color: #0d0806; box-shadow: inset 0 0 0 1px var(--brass-d); }
.lb-btn.go { padding-top: 10px; padding-bottom: 10px; font-size: clamp(15px, 2.3vw, 19px); background: linear-gradient(#ffd870, var(--brass) 55%, #a06a1e); box-shadow: inset 2px 2px 0 #fff0b0, inset -2px -2px 0 var(--brass-d), 0 0 16px rgba(255, 180, 60, .45); animation: gopulse 2.4s ease-in-out infinite; }
.lb-btn.go .pi { width: 36px; height: 36px; }
.lb-btn.go > small { color: #4a2c08; }
.lb-btn.go::before { top: 0; bottom: 0; left: -40%; width: 30%; height: auto; background: linear-gradient(100deg, transparent, rgba(255, 255, 230, .55), transparent); box-shadow: none; animation: shine 3.2s ease-in-out infinite; }
.lb-btn.go::after { display: none; }
@keyframes gopulse { 50% { box-shadow: inset 2px 2px 0 #fff0b0, inset -2px -2px 0 var(--brass-d), 0 0 26px rgba(255, 190, 70, .8); } }
@keyframes shine { 0%, 55% { left: -40%; } 100% { left: 130%; } }
.lb-btn.shop { background: linear-gradient(#3c5a2a, #24401a 60%, #1a2e12); }
.lb-btn.shop small { color: #b8e09a; }
@media (orientation: portrait) {
  .lb-crest { top: calc(34px + var(--sa-t)); }
  .lb-crest b { font-size: clamp(18px, 6vw, 28px); }
  .lb-crest small { display: none; }
  .lb-vig { bottom: auto; height: 56.25vw; }
}
@media (max-height: 430px) and (orientation: landscape) { .lb-crest small { display: none; } .lb-crest b { font-size: 20px; } .lb-btn.go { padding-top: 5px; padding-bottom: 5px; } .lb-btn.go .pi { width: 28px; height: 28px; } }
@media (prefers-reduced-motion: reduce) { .lb-btn.go, .lb-btn.go::before, .lb-crest b { animation: none; } }

/* portrait camp: the crest sits in the gap between the team cards and the menu (tall phones only) */
@media (orientation: portrait) {
  .lb-crest { top: calc(56.25vw + 118px); }
  .lb-crest small { display: inline-block; }
  .lb-news { top: calc(56.25vw + 200px); }
}
@media (orientation: portrait) and (max-height: 760px) { .lb-crest { display: none; } .lb-news { top: calc(56.25vw + 128px); } }
@media (max-height: 460px) and (orientation: landscape) {
  .enh-plus { padding: 4px; margin-bottom: 6px; } .enh-plus span { font-size: 22px; } .enh-plus small { display: none; }
  .ip-tabs { padding-top: 4px; } .ip-tabs .chip { padding: 5px; }
  .ip-body { padding: 6px 12px 10px; }
}

/* portrait camp: the scene only fills the top 16:9 band, so the space under it gets a campfire-lit ground instead of flat black */
@media (orientation: portrait) {
  #lobby { background:
    radial-gradient(ellipse 90% 38% at 50% calc(56.25vw + 4px), rgba(255, 140, 50, .22), transparent 70%),
    radial-gradient(ellipse 120% 60% at 50% 100%, rgba(120, 60, 180, .16), transparent 70%),
    linear-gradient(transparent calc(56.25vw - 2px), #1c0f0a calc(56.25vw - 2px), #140b10 60%, #0b0710); }
  #lobby::before { content: ""; position: absolute; left: 0; right: 0; top: calc(56.25vw - 2px); height: 4px; pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--brass-d) 15%, var(--brass) 50%, var(--brass-d) 85%, transparent); opacity: .7; }
}

/* ---------------------------------------------------------------- elements: the guardian's break gauge, element chips */
#boss .brk { height: 4px; margin: 2px auto 0; width: 70%; background: var(--wood0); border: 1px solid var(--ink); }
#boss .brk i { display: block; height: 100%; width: 0; background: #e0b030; transition: width .15s; }
#boss.broken .brk i { background: #fff; animation: blink .2s steps(2) infinite; }
#boss.broken #boss-name::after { content: " · เสียหลัก!"; color: #ffe070; }
.elchip { display: inline-flex; align-items: center; gap: 3px; padding: 0 6px; font-size: 13px; font-weight: 800; color: var(--ink); background: var(--el); border: 1px solid var(--ink); text-shadow: none; }
.eld { display: inline-block; width: 7px; height: 7px; margin-right: 3px; background: var(--el); border: 1px solid var(--ink); vertical-align: 1px; }
#team .card.counter { animation: counter .35s steps(2) infinite; }
#team .card.counter::after { content: "คอมโบ!"; position: absolute; top: 0; right: 0; padding: 0 4px; font-size: 12px; font-weight: 900; color: var(--ink); background: #ffe070; border: 1px solid var(--ink); white-space: nowrap; }
@keyframes counter { 50% { box-shadow: 0 0 0 2px #ffe070, 0 0 14px #ffe070; } }

/* ---------------------------------------------------------------- awakening and talents */
.stars { display: inline-flex; gap: 2px; vertical-align: -2px; }
.star { width: 13px; height: 13px; background: var(--wood0); clip-path: polygon(50% 0, 62% 35%, 100% 38%, 70% 60%, 80% 100%, 50% 77%, 20% 100%, 30% 60%, 0 38%, 38% 35%); }
.star.on { background: var(--gold); }
.buyn { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.buyn .btn.sm { padding: 4px 7px; font-size: 13px; }
@media (max-width: 420px) { .buyn { grid-column: 1 / -1; justify-content: center; } }

/* ---------------------------------------------------------------- daily dungeon, login streak */
.daily { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; padding: 8px; margin-bottom: 10px; background: linear-gradient(90deg, #3a1a50, var(--wood2)); box-shadow: inset 0 0 0 2px #9a6cff, var(--bevel); }
.daily img { width: 120px; aspect-ratio: 16 / 9; object-fit: cover; image-rendering: pixelated; border: 2px solid var(--ink); }
.daily .dtx { display: grid; gap: 4px; min-width: 0; } .daily .dtx > b { font-size: 15px; color: #e0c8ff; }
.daily .row { gap: 4px; flex-wrap: wrap; }
.dmark { font-size: 13px; padding: 0 5px; border: 1px solid var(--ink); background: var(--wood0); color: var(--dim); }
.dmark.got { background: #1f5a2a; color: #b8ffc8; }
@media (max-width: 640px) { .daily { grid-template-columns: 1fr; } .daily img { width: 100%; } }
.login { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.lday { padding: 5px 4px; text-align: center; background: var(--wood1); box-shadow: var(--bevel); }
.lday b { display: block; font-size: 14px; } .lday small { display: block; font-size: 12px; color: var(--dim); line-height: 1.3; }
.lday.got { opacity: .55; } .lday.got b::after { content: " ✓"; color: var(--good, #6dffa0); }
.lday.now { box-shadow: inset 0 0 0 2px var(--gold), 0 0 12px rgba(255, 212, 94, .4); }
.lday:last-child { background: linear-gradient(#4a3410, var(--wood1)); }
@media (max-width: 560px) { .login { grid-template-columns: repeat(4, 1fr); } }

/* ---------------------------------------------------------------- the item popup: smooth open, quiet redraws, a soft close */
#ipop.opening { animation: ipfade .18s ease-out; }
#ipop.opening .ip-card { animation: ippop2 .24s cubic-bezier(.2, .9, .3, 1.12) both; }
@keyframes ippop2 { from { transform: translateY(18px) scale(.94); opacity: 0; } 60% { opacity: 1; } }
#ipop.swapping .ip-body { animation: ipbody .16s ease-out; }
@keyframes ipbody { from { opacity: 0; transform: translateY(4px); } }
#ipop.closing { animation: ipfadeout .15s ease-in forwards; pointer-events: none; }
#ipop.closing .ip-card { animation: ipout .15s ease-in forwards; }
@keyframes ipfadeout { to { opacity: 0; } }
@keyframes ipout { to { transform: translateY(12px) scale(.96); opacity: 0; } }
@media (max-width: 560px), (orientation: portrait) and (pointer: coarse) {
  #ipop.opening .ip-card { animation: ipsheet2 .28s cubic-bezier(.2, .8, .2, 1) both; }
  #ipop.closing .ip-card { animation: ipsheetout .16s ease-in forwards; }
}
@keyframes ipsheet2 { from { transform: translateY(100%); } }
@keyframes ipsheetout { to { transform: translateY(100%); } }
.ip-card { will-change: transform, opacity; }
@media (prefers-reduced-motion: reduce) { #ipop.opening, #ipop.opening .ip-card, #ipop.swapping .ip-body, #ipop.closing, #ipop.closing .ip-card { animation-duration: .01ms; } }
/* shop cards: icon + text on top, the buy buttons on their own row (room for ×5 / ×10 and bigger text) */
.shopgrid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.shopc { grid-template-columns: auto 1fr; align-items: start; }
.shopc .buyn { grid-column: 1 / -1; justify-content: flex-end; }
.shopc .sc-tx small { line-height: 1.45; }

/* ================================================================ v2: type, layout and the MMO world
   Kanit for anything read at a glance (titles, buttons, numbers), Sarabun for running text; both are self-hosted
   (web/fonts.css), so Thai looks the same, clear and even, on every device. */
.btn, .tb-btn, .lb-btn, .chip, .m-head b, #banner, .card .nm, .lb-hero b, .lb-user b, .tb-stage b, .tb-gold b, .auth-tabs button, .boon b, h2, h3, h4, h5 { font-family: "Kanit", "Sarabun", sans-serif; }
.btn, .tb-btn { font-weight: 600; letter-spacing: .1px; }
.lb-btn { font-weight: 600; }
#banner { font-weight: 800; }
#banner small { font-family: "Sarabun", sans-serif; font-weight: 700; }
.toast { font-family: "Sarabun", sans-serif; font-weight: 600; font-size: 1.05em; }
.m-body { font-size: 15.5px; line-height: 1.5; }

/* ---- the camp, tidied: profile left, a compact icon bar right, one clear column of places to go */
.lb-top .tb-btn.lbl small { font-family: "Kanit", sans-serif; font-weight: 400; }
.lb-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: clamp(240px, 33vw, 330px); }
.lb-menu .lb-btn { grid-template-columns: auto 1fr; padding: 6px 8px; font-size: clamp(12px, 1.7vw, 14.5px); }
.lb-menu .lb-btn small { font-size: 11.5px; line-height: 1.25; }
.lb-menu .lb-btn .pi { width: 26px; height: 26px; }
.lb-menu .lb-btn.go, .lb-menu .lb-btn.mmo, .lb-menu .lb-btn.pvp { grid-column: 1 / -1; font-size: clamp(14px, 2vw, 17px); padding: 8px 12px 8px 8px; }
.lb-menu .lb-btn.go .pi, .lb-menu .lb-btn.mmo .pi, .lb-menu .lb-btn.pvp .pi { width: 32px; height: 32px; }
.lb-btn.mmo { background: linear-gradient(135deg, #1e3a6a, #2a5a9a); box-shadow: inset 2px 2px 0 #6aa8ff, inset -2px -2px 0 #0e1e3a; color: #eaf4ff; }
.lb-btn.mmo small { color: #b8d4ff; }
.lb-btn.pvp { background: linear-gradient(135deg, #5a1a24, #8a2a34); box-shadow: inset 2px 2px 0 #ff8a9a, inset -2px -2px 0 #2a0a10; }
.lb-btn .live { position: absolute; right: 8px; top: 6px; font: 600 11px/1 "Kanit", sans-serif; font-style: normal; color: #7dff9a; background: rgba(0, 0, 0, .45); padding: 3px 6px 3px 14px; border: 1px solid #0a1a10; }
.lb-btn .live::before { content: ""; position: absolute; left: 5px; top: 50%; width: 6px; height: 6px; margin-top: -3px; background: #7dff9a; border-radius: 50%; animation: live 1.2s ease-in-out infinite; }
@keyframes live { 50% { opacity: .25; } }
@media (max-width: 760px), (max-height: 420px) { .lb-top .tb-btn.lbl small { display: none; } .lb-top .tb-btn.lbl { padding: 3px 6px; } }

/* ---- touch controls: in the side margins of a wide phone, a big attack button with the skills in an arc */
@media (pointer: coarse) {
  #pad { position: fixed; left: 0; right: 0; bottom: 0; height: 60%; }
  #joy { left: calc(10px + var(--sa-l)); bottom: calc(10px + var(--sa-b)); width: 140px; height: 140px; }
  #skills { display: block; width: 250px; height: 210px; right: calc(4px + var(--sa-r)); bottom: calc(4px + var(--sa-b)); pointer-events: none; }
  #skills .sk { position: absolute; width: 58px; height: 58px; border-radius: 50%; clip-path: none; pointer-events: auto; }
  #skills .sk .si { inset: 5px; border-radius: 50%; }
  #skills .sk .cd { border-radius: 50%; }
  #skills .sk.s0 { right: 120px; bottom: 28px; } #skills .sk.s1 { right: 108px; bottom: 82px; } #skills .sk.s2 { right: 72px; bottom: 120px; } #skills .sk.s3 { right: 22px; bottom: 132px; }
  #skills .sk.dodge { width: 74px; height: 74px; right: 18px; bottom: 18px; }
  #pad.mmo #skills .sk.dodge { width: 50px; height: 50px; right: 186px; bottom: 6px; }
  #skills .sk.atk { width: 88px; height: 88px; right: 14px; bottom: 14px; }
  .sk small { display: none; }
  #toasts { left: calc(8px + var(--sa-l)); bottom: calc(160px + var(--sa-b)); max-width: min(46vw, 360px); }
}
.sk.atk { --sc: #ffd45e; background: radial-gradient(circle at 40% 35%, #6a4a2a, #2a180e 70%); }
.sk.atk .pi { width: 58%; height: 58%; }
.sk.atk.held { box-shadow: inset 0 0 0 3px #fff4b0, 0 0 14px rgba(255, 212, 94, .8); }
@media (pointer: fine) { #pad.mmo #skills { grid-template-columns: repeat(6, auto); } #pad.mmo #skills .sk { grid-column: auto; grid-row: auto; } }

/* ---- the MMO world HUD */
#mmo { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
#mmo button, #mmo input, #chat, #mm-mini { pointer-events: auto; }
#hud.mmo #topbar, #hud.mmo #side { display: none; }
#hud.mmo #team { top: calc(8px + var(--sa-t)); }
#hud.mmo #boss { top: calc(10px + var(--sa-t)); }
#mm-top { position: absolute; right: calc(6px + var(--sa-r)); top: calc(6px + var(--sa-t)); display: grid; grid-template-columns: auto auto; gap: 4px 6px; justify-items: end; align-items: start; }
.mm-card { grid-column: 1; text-align: right; line-height: 1.15; text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink); }
.mm-card b { display: block; font: 600 clamp(12px, 1.8vw, 16px)/1.15 "Kanit", sans-serif; color: var(--brass-l); }
.mm-card span { display: inline-block; margin-top: 2px; font: 600 11px/1 "Kanit", sans-serif; padding: 2px 6px; color: #10080a; background: var(--dc, #7fd65a); }
.mm-card small { display: block; margin-top: 3px; font-size: 11.5px; color: var(--cream); }
#mm-guide-open { position: relative; grid-column: 2; grid-row: 1 / span 2; padding: 0; border: 0; background: #000; cursor: pointer; }
#mm-guide-open:not(:disabled):is(:hover, :focus-visible) { outline: 2px solid #6ce5fc; outline-offset: 2px; }
#mm-guide-open span { position: absolute; right: 2px; bottom: 2px; padding: 0 4px; color: #d3f9ff; background: #0c222ce8; font: 600 10px/1.35 "Kanit", sans-serif; }
#mm-guide-open:disabled { cursor: default; }
#mm-guide-open:disabled span { display: none; }
#mm-mini { display: block; width: clamp(92px, 15vw, 132px); height: auto; aspect-ratio: 4 / 3; image-rendering: pixelated; border: 2px solid var(--ink); box-shadow: 0 0 0 2px var(--brass-d), 0 3px 8px rgba(0, 0, 0, .5); background: #000; }
#mm-boss-time { display: block; color: #ffd394; }
#mm-boss-time[hidden], #mm-guide-stop[hidden] { display: none; }
#mm-guide-stop { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; max-width: min(280px, 50vw); min-height: 28px; padding: 2px 7px; border: 1px solid #367688; color: #c9f7ff; background: #10232a; text-align: left; cursor: pointer; }
#mm-guide-stop span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#mm-guide-stop b { font-size: 17px; }
.mm-btns { grid-column: 1 / -1; display: flex; gap: 4px; }
.mm-btns .tb-btn { font-size: 13px; min-height: 30px; }
#mm-tags { position: absolute; inset: 0; overflow: hidden; }
.mtag { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; font: 600 clamp(9px, 1.25vw, 12px)/1.1 "Kanit", sans-serif; color: #fff; text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000; text-align: center; }
.mtag small { font-weight: 400; color: #c8d4ff; margin-left: 3px; }
.mtag.gm { color: var(--gold); }
.mtag.me { color: #9affb0; }
.mtag.boss { color: #ff8a7a; font-size: clamp(10px, 1.5vw, 14px); }
.mtag.elite { color: #ffd45e; }
.mtag .bub { display: block; margin: 0 auto 3px; max-width: 180px; width: max-content; white-space: normal; padding: 4px 8px; font: 500 12px/1.3 "Sarabun", sans-serif; color: #1a1020; text-shadow: none; background: #fffaf0; border: 2px solid #1a1020; border-radius: 8px; box-shadow: 2px 2px 0 rgba(0, 0, 0, .35); }
.mtag.portal { color: #a8ecff; font-weight: 400; }
#chat { position: absolute; left: calc(6px + var(--sa-l)); bottom: calc(6px + var(--sa-b)); width: min(36%, 340px); display: flex; flex-direction: column; background: rgba(10, 7, 6, .62); border: 2px solid rgba(13, 9, 7, .9); box-shadow: 0 0 0 1px rgba(110, 74, 22, .7); font-size: 13px; }
.chat-tabs { display: flex; gap: 2px; padding: 2px; background: rgba(13, 9, 7, .8); }
.chat-tabs button { padding: 2px 10px; font: 600 12px/1.4 "Kanit", sans-serif; color: var(--dim); background: transparent; border: 0; }
.chat-tabs button.on { color: var(--cream); background: var(--wood3); }
.chat-tabs .chat-fold { margin-left: auto; }
#chat-log { height: clamp(70px, 18vh, 150px); overflow-y: auto; padding: 3px 6px; line-height: 1.35; user-select: text; -webkit-user-select: text; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: thin; }
#chat-log p { margin: 0 0 1px; word-break: break-word; text-shadow: 1px 1px 0 #000; }
#chat-log b { font-family: "Kanit", sans-serif; font-weight: 600; color: #8ac8ff; }
#chat-log .gm b { color: var(--gold); }
#chat-log .me b { color: #9affb0; }
#chat-log .sys { color: #ffd45e; }
#chat-log .fish-catch { color: #95f0ce; }
.tb-btn.has-mail { color: #ffe4a2; border-color: #bf8c51; box-shadow: 0 0 8px #d7a25c55; }
.tb-btn .dot.mail-count.on { display: grid; top: -6px; right: -4px; width: auto; background: #ffd47c; color: #392010; }
.lb-top #lb-mail:has(#lb-maildot.on) {
  background: linear-gradient(#7b3a35, #451f32);
  border-color: #ffce72;
  color: #fff1c8;
  box-shadow: inset 0 0 0 1px #ffdd9e70, 0 0 0 1px #ffbf6e, 0 0 10px #f2a151a0;
  animation: mailbox-pulse 1.8s ease-in-out infinite;
}
.lb-top #lb-mail:has(#lb-maildot.on) small { color: #fff4ca; font-weight: 700; }
#lb-mail #lb-maildot.on {
  display: grid; place-items: center; top: -5px; right: -5px; min-width: 21px;
  width: auto; height: 21px; padding: 0 3px; border: 2px solid #fff2bb;
  border-radius: 11px; background: #bb2446; color: #fffaf0;
  box-shadow: 0 1px 4px #2c0e19; font: 800 12px/1 "Kanit", sans-serif;
}
#lb-maildot.on:empty::before { content: "!"; }
@keyframes mailbox-pulse {
  50% { box-shadow: inset 0 0 0 1px #fff1b5, 0 0 0 2px #ffe294, 0 0 15px #ffc56fe0; }
}
@media (prefers-reduced-motion: reduce) {
  .lb-top #lb-mail:has(#lb-maildot.on) { animation: none; }
}
.lb-top #lb-mail.calm-mail:has(#lb-maildot.on) { animation: none; }
.mail-alert {
  position: fixed; z-index: 42; inset: 0; display: grid; place-items: center; pointer-events: none;
  padding: max(12px, var(--sa-t)) max(12px, var(--sa-r)) max(12px, var(--sa-b)) max(12px, var(--sa-l));
  background: radial-gradient(ellipse at center, #080717b8 0%, #08071775 37%, transparent 75%);
}
.mail-alert-panel {
  position: relative; isolation: isolate; overflow: hidden; pointer-events: auto;
  width: min(100%, 372px); border: 2px solid #ffe19b; color: #fff4cf;
  background: radial-gradient(ellipse at 50% 25%, #593245, #24152e 60%, #151121);
  box-shadow: 0 0 0 4px #37213e, 0 0 0 5px #ffcb7280, 0 0 46px #ffc77355, 0 16px 60px #08050de8;
  animation: mail-arrive .48s cubic-bezier(.2,.8,.15,1.15) both;
}
.mail-alert-sweep { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(103deg, transparent 38%, #ffebbe4a 49%, transparent 61%) no-repeat;
  background-size: 290% 100%; animation: mail-shine 1s .22s ease-out both;
}
.mail-alert-open { display: grid; justify-items: center; width: 100%; gap: 7px; padding: 19px 35px 17px; border: 0; background: transparent; color: inherit; text-align: center; }
.mail-alert-open:focus-visible { outline-offset: -5px; }
.mail-alert-open:hover .mail-alert-cta { background: #fff0b2; }
.mail-alert b { font: 800 clamp(23px, 5.2vw, 36px)/1.14 "Kanit", sans-serif; color: #fff0b9; text-shadow: 0 3px #321526, 0 0 16px #ffd26a70; }
.mail-alert small { color: #fff0ed; font-size: 14px; }
.mail-alert-cta { margin-top: 3px; min-height: 36px; padding: 6px 15px; border: 1px solid #fff1bf; background: #ffce73; color: #321524; font: 700 14px/1.5 "Kanit", sans-serif; }
.mail-alert-close { position: absolute; top: 1px; right: 1px; width: 42px; height: 42px; border: 0; color: #fff1db; background: transparent; font-size: 24px; }
.mail-alert-medallion { width: 70px; height: 57px; display: grid; place-items: center; position: relative; color: #ffe2a0; filter: drop-shadow(0 0 11px #ffd97e8a); }
.mail-alert-medallion::before, .mail-alert-medallion::after { content: "✦"; position: absolute; font-size: 18px; top: 1px; right: -8px; }
.mail-alert-medallion::after { left: -9px; right: auto; top: auto; bottom: 1px; font-size: 13px; }
.mail-envelope { --env-scale: 1; display: block; transform: translateY(1px) scale(var(--env-scale)) rotate(-8deg); width: 31px; height: 21px; position: relative; overflow: hidden; border: 2px solid #fff0ba; background: linear-gradient(#ebbc80,#a65b6d); box-shadow: 0 0 12px #ffcf8170; }
.mail-alert .mail-envelope { --env-scale: 1.65; animation: mail-envelope-arrive .75s .05s both; }
.field-mail .mail-envelope { --env-scale: .57; margin: 0 -4px; }
.mail-envelope::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: -12px; transform: rotate(45deg); border: 2px solid #ffe5aa; background: #e5a96b; }
.mail-envelope::after { content: ""; position: absolute; width: 6px; height: 6px; left: 10px; top: 7px; border-radius: 50%; background: #b52f5e; box-shadow: 0 0 0 1px #ffe8ae; }
.mail-alert-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@keyframes mail-arrive { from { opacity: 0; transform: translateY(-18px) scale(.82); } to { opacity: 1; transform: none; } }
@keyframes mail-shine { from { opacity: 1; background-position: 110% 0; } to { opacity: 0; background-position: -20% 0; } }
@keyframes mail-envelope-arrive { from { transform: translateY(-9px) scale(1.1) rotate(-27deg); } to { transform: translateY(1px) scale(var(--env-scale)) rotate(-8deg); } }
@media (prefers-reduced-motion: reduce) { .mail-alert-panel, .mail-alert .mail-envelope, .mail-alert-sweep { animation: none; } }
.mail-alert.calm-mail .mail-alert-panel, .mail-alert.calm-mail .mail-envelope, .mail-alert.calm-mail .mail-alert-sweep { animation: none; }

#chat-log .ann { color: #ff9a6a; font-weight: 700; }
#chat-log .m-ch { color: #b8f0c0; }
#chat-log .quiet { color: var(--mute); font-size: 12px; }
#chat-form { display: flex; gap: 3px; padding: 3px; }
#chat-in { flex: 1; min-width: 0; padding: 4px 7px; background: rgba(0, 0, 0, .55); border: 1px solid var(--wood4); font-size: 14px; }
#chat-in:focus { outline: 2px solid var(--brass); }
#chat-form .btn { padding: 2px 10px; font-size: 13px; }
#chat-commands { max-height: min(24vh, 160px); overflow: auto; background: var(--wood0); border-top: 1px solid var(--wood4); overscroll-behavior: contain; }
#chat-commands button { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; width: 100%; padding: 4px 7px; border: 0; background: transparent; color: var(--cream); text-align: left; overflow-wrap: anywhere; }
#chat-commands button:hover, #chat-commands [aria-selected="true"] { background: var(--wood3); }
#chat-commands small { color: var(--dim); }
#chat.fold #chat-log, #chat.fold #chat-form { display: none; }
#chat.fold #chat-commands { display: none; }
#app.mode-mmo #toasts { left: auto; right: calc(10px + var(--sa-r)); bottom: 34%; align-items: flex-end; }
@media (pointer: coarse) {
  #chat { bottom: calc(150px + var(--sa-b)); width: min(34%, 300px); font-size: 12px; }
  #chat-log { height: clamp(50px, 13vh, 96px); }
  #app.mode-mmo #toasts { left: auto; right: calc(8px + var(--sa-r)); bottom: calc(220px + var(--sa-b)); align-items: flex-end; }
  /* Keep MMO controls readable on short landscape screens and leave a clear play lane. */
  #mm-top { right: calc(8px + var(--sa-r)); top: calc(8px + var(--sa-t)); gap: 3px 5px; }
  #mm-mini { width: clamp(82px, 13vw, 112px); }
  #mm-top .mm-btns { flex-wrap: wrap; justify-content: flex-end; max-width: min(42vw, 250px); }
  #mm-top .mm-btns .tb-btn { min-width: 34px; min-height: 34px; padding: 3px 6px; }
  #mm-top .mm-card small { font-size: 10px; }
  #chat { width: min(30vw, 260px); max-width: calc(100vw - 190px); }
  #chat.fold { width: auto; min-width: 132px; }
  .chat-fold, .chat-tabs button, #chat-form .btn { min-height: 32px; }
  #chat-in { min-height: 34px; }
}

/* ---- the admin announcement: centre screen, impossible to miss, gone by itself */
#announce { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(0, 0, 0, .35), rgba(0, 0, 0, .65)); animation: an-fade .25s ease-out; pointer-events: auto; }
.an-card { position: relative; width: min(560px, 88vw); padding: 18px 22px 22px; text-align: center; background: linear-gradient(#3a2414, #22160e); border: 3px solid var(--ink); box-shadow: 0 0 0 3px var(--brass), 0 0 0 6px var(--ink), 0 0 40px rgba(255, 200, 80, .55), 0 10px 30px rgba(0, 0, 0, .7); animation: an-pop .5s cubic-bezier(.2, 1.6, .4, 1); overflow: hidden; }
.an-card::before { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 240, 180, .18) 45%, transparent 60%) 0 0 / 250% 100%; animation: an-shine 2.4s linear infinite; pointer-events: none; }
.an-head { display: flex; align-items: center; justify-content: center; gap: 10px; font: 800 clamp(18px, 3.4vw, 26px)/1.1 "Kanit", sans-serif; color: var(--brass-l); letter-spacing: .5px; text-shadow: 2px 2px 0 var(--brass-d), 4px 4px 0 var(--ink); }
.an-horn { width: 30px; height: 30px; background: var(--brass-l); clip-path: polygon(0 35%, 30% 35%, 85% 5%, 85% 95%, 30% 65%, 0 65%); filter: drop-shadow(2px 2px 0 var(--ink)); animation: an-horn .6s ease-in-out infinite alternate; }
#an-msg { margin: 14px 0 6px; font: 600 clamp(16px, 2.8vw, 22px)/1.45 "Sarabun", sans-serif; color: #fff8e6; text-shadow: 1px 1px 0 #000; word-break: break-word; user-select: text; -webkit-user-select: text; }
#an-by { display: block; margin-bottom: 14px; color: var(--dim); font-size: 13px; }
.an-bar { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--brass-l); transform-origin: left; }
@keyframes an-fade { from { opacity: 0; } }
@keyframes an-pop { 0% { transform: scale(.4) translateY(30px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes an-shine { from { background-position: 150% 0; } to { background-position: -150% 0; } }
@keyframes an-horn { to { transform: rotate(-12deg) scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .an-card, .an-card::before, .an-horn, #announce { animation: none; } }

/* ---- phones held upright: everything plays upright except the MMO world, which asks for the phone to be turned */
#rotate { display: none; }
@media (pointer: coarse) and (orientation: portrait) {
  #app.mode-mmo #rotate { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--night); color: var(--cream); text-align: center; padding: 20px; }
  #rotate b { font: 700 22px/1.2 "Kanit", sans-serif; color: var(--brass-l); }
  #rotate small { color: var(--cream); font-size: 16px; line-height: 1.5; }
  #rotate .btn { margin-top: 10px; padding: 12px 18px; font-size: 16px; }
  .rot-phone { width: 46px; height: 80px; border: 4px solid var(--brass-l); border-radius: 8px; position: relative; animation: rot 2s ease-in-out infinite; }
  .rot-phone::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--brass-l); }
}
@keyframes rot { 0%, 20% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

/* ---- the MMO map picker */
.mmo-maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.mmo-map { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; padding: 8px 10px; text-align: left; background: linear-gradient(135deg, var(--mc, #2a3a2a), var(--wood1)); box-shadow: var(--bevel); border: 2px solid var(--ink); clip-path: var(--notch-s); }
.mmo-map.sel { box-shadow: inset 0 0 0 2px var(--gold), var(--bevel); }
.mmo-map b { font: 600 15px/1.2 "Kanit", sans-serif; color: var(--cream); text-shadow: 1px 1px 0 var(--ink); }
.mmo-map .lv { font: 600 12px "Kanit", sans-serif; color: var(--gold); text-align: right; }
.mmo-map small { grid-column: 1 / -1; color: var(--dim); font-size: 12.5px; }
.mmo-map .who { grid-column: 1 / -1; display: flex; gap: 8px; font-size: 12px; color: #9affb0; }
.mmo-map .who .bossup { color: #ff8a7a; font-weight: 700; }
.mmo-map.low b::after { content: " · เลเวลยังไม่ถึง"; color: #ff8a7a; font-size: 11px; font-family: "Sarabun", sans-serif; }
.diffs { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.diffs .btn { flex: 1; min-width: 120px; text-align: center; white-space: normal; }
.diffs .btn small { display: block; font: 400 12px/1.3 "Sarabun", sans-serif; opacity: .9; }
.diffs .btn.sel { box-shadow: inset 0 0 0 2px var(--dc), var(--bevel); background: var(--wood3); color: var(--dc); }
.mmo-go { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }

/* ---- leaving the MMO world */
.mmo-leave { display: grid; gap: 14px; }
.lv-head { display: flex; align-items: center; gap: 16px; }
.lv-head h3 { margin: 0; font: 700 22px/1.2 "Kanit", sans-serif; color: var(--brass-l); text-shadow: 2px 2px 0 var(--ink); }
.lv-head p { margin: 4px 0 0; color: var(--dim); }
.lv-portal { position: relative; flex: none; width: 64px; height: 64px; border-radius: 50%; background: radial-gradient(circle, #e8faff 0 12%, #7ad8ff 30%, #1e4a8a 60%, transparent 72%); box-shadow: 0 0 24px rgba(122, 216, 255, .6); animation: lv-spin 3s linear infinite; }
.lv-portal::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; border: 3px dashed rgba(232, 250, 255, .8); }
@keyframes lv-spin { to { transform: rotate(360deg); } }
.lv-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.lv-stat { display: grid; justify-items: center; gap: 2px; padding: 10px 6px; background: var(--wood1); box-shadow: var(--bevel-in); border: 2px solid var(--ink); clip-path: var(--notch-s); animation: lv-pop .35s cubic-bezier(.2, 1.5, .4, 1) backwards; }
.lv-stat:nth-child(2) { animation-delay: .06s; } .lv-stat:nth-child(3) { animation-delay: .12s; } .lv-stat:nth-child(4) { animation-delay: .18s; } .lv-stat:nth-child(5) { animation-delay: .24s; }
.lv-stat .pi { width: 26px; height: 26px; }
.lv-stat b { font: 700 20px/1.1 "Kanit", sans-serif; color: var(--cream); }
.lv-stat small { color: var(--dim); font-size: 12.5px; }
@keyframes lv-pop { from { transform: scale(.6); opacity: 0; } }
.lv-note { margin: 0; text-align: center; }
.lv-btns { display: flex; gap: 10px; justify-content: center; }
.lv-btns .btn { min-width: 140px; font-size: 16px; padding: 10px 16px; }
.mm-zoom { display: inline-flex; align-items: center; gap: 2px; }
.mm-zoom .tb-btn { min-width: 30px; justify-content: center; font-size: 17px; line-height: 1; }
.mm-zoom b { min-width: 40px; text-align: center; font: 600 12px "Kanit", sans-serif; color: var(--cream); text-shadow: 1px 1px 0 var(--ink); }
@media (prefers-reduced-motion: reduce) { .lv-portal, .lv-stat { animation: none; } }

/* ---- the MMO's daily hunts */
.mm-quests { grid-column: 1 / -1; justify-self: end; display: grid; gap: 1px; max-width: min(320px, 44vw); padding: 4px 8px; text-align: right; font: 600 11.5px/1.35 "Sarabun", sans-serif; color: var(--cream); background: rgba(10, 7, 6, .58); border: 1px solid rgba(110, 74, 22, .7); cursor: pointer; }
.mm-quests span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 1px 1px 0 #000; }
.mm-quests b { color: var(--gold); font-family: "Kanit", sans-serif; font-weight: 600; }
.mm-quests .ready { color: #9affb0; animation: mq-blink 1s ease-in-out infinite; }
.mm-quests .done { color: var(--mute); text-decoration: line-through; }
@keyframes mq-blink { 50% { opacity: .55; } }
.mq-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 8px; background: var(--wood1); border: 2px solid var(--ink); box-shadow: var(--bevel-in); clip-path: var(--notch-s); }
.mq-row.ready { box-shadow: inset 0 0 0 2px #7dff9a, var(--bevel-in); }
.mq-row.done { opacity: .6; }
.mq-tx { flex: 1; min-width: 0; }
.mq-tx b { display: block; font: 600 15px/1.3 "Kanit", sans-serif; color: var(--cream); }
.mq-tx small { color: var(--dim); }
.mq-bar { position: relative; height: 14px; margin-top: 5px; background: var(--wood0); border: 1px solid var(--ink); }
.mq-bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#8fe06a, #4e9a3a); }
.mq-bar em { position: absolute; inset: 0; display: grid; place-items: center; font: 600 11px "Kanit", sans-serif; font-style: normal; text-shadow: 1px 1px 0 #000; }
.mq-ok { color: #7dff9a; font: 600 14px "Kanit", sans-serif; }
.mq-bonus { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: linear-gradient(90deg, #3a2a10, #22160e); border: 2px solid var(--brass-d); }
.mq-bonus span { flex: 1; }
.mq-bonus b { font: 700 16px "Kanit", sans-serif; color: var(--gold); }
.mq-bonus.done b { color: #7dff9a; }
.guide-header { display: flex; align-items: start; justify-content: space-between; gap: 10px; padding: 10px 12px; border-left: 3px solid #60cbd5; background: #182832; }
.guide-header h3 { margin: 0; color: #d5f7ff; }
.guide-header p { margin: 3px 0 0; color: #bad0d7; }
.guide-list { display: grid; gap: 6px; }
.guide-stop { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 10px; text-align: left; background: var(--wood1); color: var(--cream); border: 1px solid var(--brass-d); cursor: pointer; }
.guide-stop:is(:hover, :focus-visible, .active) { border-color: #6ce5fc; background: #192b32; }
.guide-stop b { display: block; font-weight: 700; }
.guide-stop small { display: block; color: var(--dim); line-height: 1.25; }
.guide-stop em { color: #8de3ef; font-style: normal; white-space: nowrap; }
@media (pointer: coarse) { .mm-quests { font-size: 10.5px; max-width: 40vw; } }

/* ---- townspeople, emotes */
.mtag.npc { color: #a8d8ff; }
.mtag .npc-say { pointer-events: auto; display: flex; align-items: center; gap: 6px; max-width: 220px; }
.npc-talk { pointer-events: auto; flex: none; padding: 2px 10px; font: 600 12px "Kanit", sans-serif; color: #1a1020; background: var(--gold); border: 2px solid #1a1020; border-radius: 6px; cursor: pointer; }
.mtag .emo { display: block; font-size: 22px; line-height: 1; margin: 0 auto 2px; animation: emo-pop .35s cubic-bezier(.2, 1.8, .4, 1); text-shadow: none; }
@keyframes emo-pop { from { transform: scale(.2); } }
#mm-tags .mtag { pointer-events: none; }
#mm-tags .mtag .npc-say, #mm-tags .npc-talk { pointer-events: auto; }
#mm-emotes { position: absolute; left: 0; bottom: calc(100% + 4px); display: none; gap: 3px; pointer-events: auto; }
#chat.emo #mm-emotes { display: flex; }
.chat-tabs .chat-emo { margin-left: auto; font-size: 13px; padding: 0 6px; }
.chat-tabs .chat-emo + .chat-fold { margin-left: 0; }
#mm-emotes button { width: 30px; height: 30px; padding: 0; font-size: 16px; line-height: 1; background: rgba(10, 7, 6, .62); border: 1px solid rgba(110, 74, 22, .7); border-radius: 50%; cursor: pointer; }
#mm-emotes button:active { transform: scale(.9); }

/* ---- the team screen */
.tm-stage { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px; background: radial-gradient(ellipse at 50% 100%, #4a3a24, transparent 70%), linear-gradient(#171a2c, #2a2016 70%, #1c130c); border: 2px solid var(--ink); box-shadow: var(--bevel-in); }
.tm-spot { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tm-spot.empty { align-items: center; justify-content: center; min-height: 150px; border: 2px dashed var(--wood4); }
.tm-fig { position: relative; display: grid; justify-items: center; gap: 1px; padding: 6px 4px; background: none; border: 2px solid transparent; color: var(--cream); cursor: pointer; font: inherit; line-height: 1.3; }
.tm-spot.on .tm-fig { border-color: var(--cc); background: color-mix(in srgb, var(--cc) 16%, transparent); }
.tm-fig em { position: absolute; left: 4px; top: 4px; padding: 0 6px; font: 600 12px "Kanit", sans-serif; background: var(--ink); color: var(--gold); }
.tm-fig b { font: 600 16px/1.3 "Kanit", sans-serif; text-shadow: 1px 1px 0 var(--ink); }
.tm-fig small { font-size: 13px; }
.tm-spr { width: clamp(84px, 15vw, 132px); aspect-ratio: 1; background: var(--spr) 0 0 / 200% 100% no-repeat; image-rendering: pixelated; animation: tm-idle 1.1s infinite; z-index: 1; }
@keyframes tm-idle { 0%, 49.9% { background-position: 0 0; } 50%, 100% { background-position: 100% 0; } }
.tm-floor { width: 78px; height: 14px; margin-top: -9px; border-radius: 50%; background: radial-gradient(ellipse, color-mix(in srgb, var(--cc) 60%, #000), transparent 70%); }
.tm-spot > .btn { font-size: 13px; padding: 8px 4px; justify-content: center; }
.tm-place-short { display: none; }
.tm-cur { text-align: center; font-size: 13px; color: var(--cc); padding: 7px 0; }
.tm-hint { margin: 6px 0; text-align: center; font-size: 14px; }
.tm-roster { display: flex; gap: 5px; overflow-x: auto; padding: 2px 2px 8px; touch-action: pan-x pan-y; scrollbar-color: var(--wood4) var(--wood0); }
.tm-pick { position: relative; flex: 0 0 78px; display: grid; justify-items: center; padding: 5px 2px; background: var(--wood2); border: 2px solid var(--ink); box-shadow: var(--bevel); color: var(--cream); cursor: pointer; font: inherit; line-height: 1.25; }
.tm-pick.sel { background: var(--wood3); border-color: var(--cc); }
.tm-pick img { width: 48px; height: 48px; image-rendering: pixelated; }
.tm-pick.locked img { filter: grayscale(1) brightness(.6); }
.tm-pick b { font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-pick small { font-size: 12px; color: var(--dim); }
.tm-pick em { position: absolute; right: 3px; top: 3px; min-width: 18px; font: 700 13px/18px "Kanit", sans-serif; text-align: center; background: var(--gold); color: var(--ink); }
.tm-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 8px; background: linear-gradient(90deg, color-mix(in srgb, var(--cc) 20%, var(--wood2)), var(--wood1)); border: 2px solid var(--ink); }
.tm-head img { width: 48px; height: 48px; image-rendering: pixelated; }
.tm-head .tx { flex: 1; min-width: 160px; }
.tm-head .tx b { font-size: 17px; }
.tm-head small { color: var(--dim); }
.tm-head .tx small b { font-size: inherit; }
.tm-tabs { display: flex; gap: 5px; margin: 8px 0; }
.tm-tabs .chip { flex: 1; padding: 9px 4px; text-align: center; }
.tm-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0 8px; }
.tm-slot { position: relative; display: grid; justify-items: center; gap: 3px; padding: 6px 3px; min-width: 0; background: var(--wood0); border: 2px solid var(--ink); color: var(--cream); cursor: pointer; font: inherit; }
.tm-slot.on { border-color: var(--gold); background: var(--wood3); }
.tm-slot em { position: absolute; left: 4px; top: 2px; font: 700 13px "Kanit", sans-serif; color: var(--gold); }
.tm-slot b { font-size: 12px; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
.tm-slot .ic, .tm-skill > .ic { width: 46px; height: 46px; background: var(--ico, none) center / cover no-repeat var(--wood0); border: 2px solid var(--ink); image-rendering: pixelated; }
.tm-skill { display: grid; grid-template-columns: auto minmax(0, 1fr) 132px 140px; gap: 10px; align-items: center; padding: 8px; margin-bottom: 6px; background: var(--wood2); border: 2px solid var(--ink); box-shadow: var(--bevel); }
.tm-skill.eq { border-color: var(--cc); }
.tm-skill.locked { opacity: .6; }
.tm-skill .tx b { font-size: 15px; }
.tm-skill .tx em { font-style: normal; font-size: 12px; padding: 0 6px; background: var(--cc); color: var(--ink); }
.tm-skill p { margin: 1px 0 4px; font-size: 13px; color: var(--dim); line-height: 1.35; }
.sk-facts { display: flex; flex-wrap: wrap; gap: 3px; }
.sk-facts span { padding: 0 6px; font-size: 12px; background: var(--wood0); color: var(--cream); }
.sk-dmg { display: grid; justify-items: center; text-align: center; padding: 4px; background: var(--wood0); color: #ff9a6a; }
.sk-dmg b { font: 700 22px/1.2 "Kanit", sans-serif; }
.sk-dmg span, .sk-dmg small { font-size: 12px; color: var(--dim); line-height: 1.3; }
.sk-dmg.heal { color: #7dff9a; }
.sk-dmg.shield { color: #8ad0ff; }
.sk-dmg.buff { color: var(--gold); }
.sk-dmg.buff b { font-size: 16px; }
.sk-acts { display: grid; gap: 4px; text-align: center; font-size: 13px; }
.sk-acts .btn { font-size: 13px; padding: 7px 6px; justify-content: center; }
@media (max-width: 640px) {
  .tm-skill { grid-template-columns: auto minmax(0, 1fr); }
  .tm-skill .sk-dmg, .tm-skill .sk-acts { grid-column: 1 / -1; }
  .tm-skill .sk-acts { grid-template-columns: 1fr 1fr; align-items: center; }
}
@media (max-height: 460px) and (orientation: landscape) { .tm-spr { width: 84px; } .tm-fig { padding: 2px; } }

/* ---- the game's own dialogs */
#dlg { position: fixed; inset: 0; z-index: 38; display: grid; place-items: center; padding: 10px; background: rgba(5, 4, 8, .7); animation: ipfade .15s ease-out; }
#dlg[hidden] { display: none; }
.dlg-card { width: min(380px, 100%); max-height: calc(100dvh - 20px); overflow: auto; padding: 16px; text-align: center; background: var(--wood1); border: 3px solid var(--ink); box-shadow: inset 0 0 0 2px var(--brass); animation: ippop .2s ease-out; }
.dlg-card h3 { margin: 0 0 8px; font-size: 20px; color: var(--gold); }
.dlg-card p { margin: 6px 0; }
.dlg-card.win { background: radial-gradient(circle at 50% 34%, #6a4a14, var(--wood1) 62%); }
.dlg-hero { width: 88px; height: 88px; image-rendering: pixelated; }
.dlg-big { font: 700 22px "Kanit", sans-serif; }
.dlg-rows div { display: grid; grid-template-columns: 1fr 70px 20px 70px; gap: 4px; padding: 3px 0; text-align: right; border-bottom: 1px dashed var(--wood3); }
.dlg-rows span { text-align: left; color: var(--dim); }
.dlg-rows i { font-style: normal; color: var(--mute); text-align: center; }
.dlg-need { display: flex; justify-content: space-between; margin-top: 6px; padding: 4px 8px; background: var(--wood0); }
.dlg-need.ok b { color: var(--good); }
.dlg-need.no b { color: var(--bad); }
.dlg-btns { display: flex; gap: 8px; margin-top: 12px; }
.dlg-btns .btn { flex: 1; justify-content: center; padding: 10px; }
@media (max-height: 460px) and (orientation: landscape) { .dlg-card { padding: 10px; } .dlg-hero { width: 56px; height: 56px; } }
@media (prefers-reduced-motion: reduce) { .tm-spr, #dlg, .dlg-card { animation: none; } }

/* ---- materials you can tap, and what the popup says about them */
button.mat { font: inherit; font-weight: 700; color: var(--cream); }
.mat.tap, .sc-ico.tap { cursor: pointer; }
.mat.tap:hover, .mat.tap:focus-visible { border-color: var(--brass-l); }
button.mat.short { color: var(--bad); }
.q { display: inline-grid; place-items: center; width: 15px; height: 15px; margin-left: 4px; font: 700 11px/1 "Kanit", sans-serif; font-style: normal; color: var(--ink); background: var(--brass-l); border-radius: 50%; }
.sc-ico.tap { position: relative; padding: 0; color: inherit; }
.sc-ico.tap .q { position: absolute; right: 2px; bottom: 2px; }
.enh-short { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.dlg-card.matinfo { width: min(460px, 100%); text-align: left; }
.matinfo h3 { text-align: center; }
.matinfo h4 { margin: 10px 0 4px; }
.mi-top { display: flex; align-items: center; justify-content: center; gap: 10px; }
.pi.mi-ico { width: 40px; height: 40px; }
.mi-src { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 4px; background: var(--wood2); border: 2px solid var(--ink); }
.mi-src > div { flex: 1; min-width: 0; }
.mi-src b, .mi-src small { display: block; }
.mi-src small { color: var(--dim); font-size: 13px; line-height: 1.35; }
.dlg-card.fail { box-shadow: inset 0 0 0 2px var(--bad); }
.dlg-card.fail h3 { color: var(--bad); }
.dlg-card.mail-space-dialog { border-color: #bd8051; background: #231b2b; }
.mail-space { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.mail-space > div { padding: 8px 5px; border: 1px solid #a76e53; border-radius: 6px; background: #382736; }
.mail-space b, .mail-space small { display: block; }
.mail-space b { font: 700 24px/1.1 "Kanit", sans-serif; color: #ffd18b; }
.mail-space small { color: #ffe8cd; }
.mail-space-dialog .dlg-btns .btn { min-height: 42px; }
.bag-pages { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; margin: 9px 0; }
.bag-page { display: grid; align-content: center; gap: 2px; min-width: 0; min-height: 45px; padding: 4px 2px; border: 1px solid #4a526c; border-radius: 7px; background: #20283d; color: #e2ebf8; }
.bag-page b { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 3px; font: 700 clamp(11px, 2.8vw, 14px)/1.2 "Kanit", sans-serif; }
.bag-page b .pi { width: 11px; height: 11px; }
.bag-page small { color: #c3c8df; font-size: clamp(10px, 2.4vw, 12px); white-space: nowrap; }
.bag-page.on { border-color: #80d4ff; background: #233953; }
.bag-page[data-act="buybag"]:not(:disabled) { border-color: #b99152; background: #413342; }
.bag-page[data-act="buybag"]:not(:disabled) small { color: #ffdc8e; }
.bag-page:disabled { opacity: .65; }
.bag-auto-loot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.bag-auto-loot label { display: grid; gap: 4px; min-width: 0; font-size: 12px; color: #d3daf0; }
.bag-auto-loot select { width: 100%; min-height: 39px; }
.dlg-card .sel { user-select: text; -webkit-user-select: text; }

.pvp-score { margin: 0; font: 800 30px "Kanit", sans-serif; }

/* ---- the team screen, made easy to read: bigger type, brighter text on the dark wood, nothing under 14px.
   Kanit (clear, even strokes) for names and numbers; Sarabun at 600 for sentences, since its thin 400 washes out on dark. */
.tm-skill, .tm-head, .tm-stage, .tm-roster, .tm-slots, .tm-hint, .tm-tabs, .dlg-card { font-family: "Sarabun", "Kanit", sans-serif; font-weight: 600; letter-spacing: 0; }
.tm-pane .note, .m-body .tm-hint, .tm-skill ~ .note { font-size: 15px; line-height: 1.6; color: #e6d6b4; }
.tm-hint { font-size: 16px; color: var(--cream); }
.tm-head .tx b { font: 600 20px/1.3 "Kanit", sans-serif; }
.tm-head small { display: block; margin-top: 3px; font-size: 15px; line-height: 1.5; color: #e6d6b4; }
.tm-head .gold, .tm-skill .gold { font-family: "Kanit", sans-serif; }
.tm-fig b { font-size: 18px; }
.tm-fig small { font-size: 15px; color: #e6d6b4; }
.tm-fig em { font-size: 14px; padding: 1px 8px; }
.tm-spot > .btn { font-size: 15px; padding: 10px 6px; }
.tm-cur { font-size: 15px; font-weight: 700; }
.tm-pick { flex-basis: 92px; padding: 6px 3px; }
.tm-pick b { font: 600 15px/1.3 "Kanit", sans-serif; }
.tm-pick small { font-size: 14px; color: #e6d6b4; }
.tm-pick em { font-size: 14px; min-width: 20px; }
.tm-tabs .chip { font: 600 16px/1.3 "Kanit", sans-serif; padding: 11px 4px; }
.tm-slot { padding: 8px 4px; }
.tm-slot b { font: 600 14px/1.35 "Kanit", sans-serif; }
.tm-slot em { font-size: 15px; }
.tm-skill { gap: 12px; padding: 12px; margin-bottom: 8px; }
.tm-skill .tx b { font: 600 18px/1.3 "Kanit", sans-serif; }
.tm-skill .tx em { font: 600 14px/1.5 "Kanit", sans-serif; padding: 0 8px; }
.tm-skill p { margin: 4px 0 8px; font-size: 16px; line-height: 1.55; color: #f2e4c2; }
.sk-facts { gap: 5px; }
.sk-facts span { padding: 3px 9px; font-size: 14.5px; line-height: 1.4; color: #f2e4c2; background: #2a1c12; border: 1px solid #5a4028; }
.sk-dmg { padding: 8px 6px; }
.sk-dmg b { font: 700 28px/1.15 "Kanit", sans-serif; }
.sk-dmg span, .sk-dmg small { font-size: 14px; line-height: 1.4; color: #e6d6b4; }
.sk-dmg.buff b { font-size: 20px; }
.sk-acts { font-size: 15px; gap: 6px; }
.sk-acts .btn { font-size: 15px; padding: 10px 8px; }
.sk-acts small { font-size: 14px; }
.tm-skill { grid-template-columns: auto minmax(0, 1fr) 150px 160px; }
.tm-slot .ic, .tm-skill > .ic { width: 52px; height: 52px; }
@media (max-width: 860px) { .tm-skill { grid-template-columns: auto minmax(0, 1fr); } .tm-skill .sk-dmg, .tm-skill .sk-acts { grid-column: 1 / -1; } .tm-skill .sk-acts { grid-template-columns: 1fr 1fr; align-items: center; } }
@media (max-height: 460px) and (orientation: landscape) { .tm-skill p { font-size: 15px; } .sk-dmg b { font-size: 24px; } }
.dlg-card p, .dlg-rows, .dlg-need { font-size: 16px; line-height: 1.55; }
.dlg-rows span { color: #e6d6b4; }
.dlg-card h3 { font-size: 22px; }
.dlg-btns .btn { font-size: 16px; }
.mi-src b { font-size: 16px; } .mi-src small { font-size: 14.5px; color: #e6d6b4; }
.tm-head .elchip { font: 600 14px/1.5 "Kanit", sans-serif; padding: 0 8px; }
.star { width: 16px; height: 16px; }
.tal b { font: 600 16px/1.3 "Kanit", sans-serif; } .tal small { font-size: 14px; color: #e6d6b4; } .tal em { font-size: 15px; }
.talbr h5 { font-size: 17px; }
.awk, .awk .dim { font-size: 15px; color: #f2e4c2; }
.stats { font-size: 16px; } .stats .dim { color: #e6d6b4; }

/* ---- the PvP result popup */
.dlg-card.pvpend { width: min(440px, 100%); }
.pe-big { margin: 4px 0 !important; font: 800 40px/1.2 "Kanit", sans-serif; }
.pvpend.win .pe-big { color: #6dffa0; text-shadow: 0 0 18px rgba(109, 255, 160, .5); }
.pvpend.lose .pe-big { color: #ff6a5a; }
.pvpend.draw .pe-big { color: var(--gold); }
.pvpend.win { background: radial-gradient(circle at 50% 18%, #1f5a34, var(--wood1) 62%); }
.pvpend.lose { background: radial-gradient(circle at 50% 18%, #5a2020, var(--wood1) 62%); }
.pe-score { display: flex; align-items: center; justify-content: center; gap: 10px; font: 600 16px "Kanit", sans-serif; }
.pe-score b { font-size: 38px; line-height: 1; }
.pe-score i { font-style: normal; font-size: 26px; color: var(--mute); }
.pe-score span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-score span:first-child { text-align: right; }
.pe-score span:last-child { text-align: left; }
.pe-note { margin: 10px 0 2px !important; min-height: 1.6em; }
.pe-hint { margin: 6px 0 0 !important; font-size: 13px !important; color: var(--dim); }
.pvpend .dlg-btns .btn { padding: 14px 10px; font-size: 18px; }

/* ---- the forge: what you have, what each action does, and what the last one did */
.forge-op { display: grid; gap: 3px; width: 100%; }
.forge-hint { font-size: 14px; line-height: 1.5; color: #e6d6b4; }
.forge-hint b { font-weight: 700; }
.fx-now { margin: 6px 0 8px; padding: 8px 10px; background: var(--wood0); border: 2px solid var(--ink); }
.fx-now > b { display: block; margin-bottom: 4px; font: 600 15px "Kanit", sans-serif; }
.fx-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.fx-chips .stat { padding: 1px 8px; font-size: 14px; background: #2a1c12; border: 1px solid #5a4028; }
.fx-chips .stat.aff { color: #d9a8ff; border-color: #6a3a9a; }
.mat.got { color: var(--good); }
.fxrep { margin: 6px 0 10px; padding: 8px 10px; border: 2px solid var(--ink); background: var(--wood0); box-shadow: inset 0 0 0 2px #2f6a3a; animation: ipfade .25s ease-out; }
.fxrep.no { box-shadow: inset 0 0 0 2px #7a3030; }
.fxrep > b { display: block; margin-bottom: 4px; font: 600 16px "Kanit", sans-serif; }
.fxrep.ok > b { color: var(--good); }
.fxrep.no > b { color: var(--bad); }
.fx-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.fx-lines { display: grid; gap: 2px; }
.fx-ln { display: grid; grid-template-columns: 1fr auto 18px auto auto; gap: 6px; align-items: center; padding: 2px 6px; font-size: 15px; background: #1c130c; }
.fx-ln i { font-style: normal; color: var(--mute); text-align: center; }
.fx-ln b { font-family: "Kanit", sans-serif; }
.fx-ln em { font-style: normal; min-width: 56px; text-align: right; font-weight: 700; }
.fx-ln em.new { color: var(--gold); } .fx-ln em.lost { color: var(--bad); }
.fx-ln.new { box-shadow: inset 3px 0 0 var(--gold); } .fx-ln.lost { box-shadow: inset 3px 0 0 var(--bad); } .fx-ln.up { box-shadow: inset 3px 0 0 var(--good); } .fx-ln.dn { box-shadow: inset 3px 0 0 #ff9a5a; }
.fx-gone { font-size: 18px; line-height: 1.6; }
.dlg-need .fx-chips { justify-content: flex-end; }

/* ---- the game played upright on a touch phone: the canvas is the top 16:9 band, the controls take the space below
   (these come after the touch layout above, which assumed the pad covers the lower part of a landscape screen) */
@media (pointer: coarse) and (orientation: portrait) {
  #pad { position: fixed; top: 56.25vw; left: 0; right: 0; bottom: 0; height: auto; }
  #joy { left: calc(10px + var(--sa-l)); bottom: calc(12px + var(--sa-b)); width: 130px; height: 130px; }
  #skills { right: calc(2px + var(--sa-r)); bottom: calc(6px + var(--sa-b)); width: 236px; height: 200px; }
  #side { bottom: calc(222px + var(--sa-b)); }
  #toasts { left: 8px; bottom: calc(100dvh - 56.25vw + 8px); max-width: calc(100vw - 16px); }
}

/* ---- the admin's name: crown, shimmering gold, sparks, a pulsing glow (PvP tags, MMO tags, chat) */
.gmfx { position: relative; display: inline-block; padding: 0 .2em; }
.gmfx::before { content: ""; position: absolute; inset: 15% -12% -25%; border-radius: 50%; background: radial-gradient(ellipse, rgba(255, 196, 70, .6), transparent 70%); filter: blur(5px); z-index: -1; animation: gm-pulse 1.9s ease-in-out infinite; }
.gm-name { background: linear-gradient(100deg, #ffd45e 0%, #fff6c8 18%, #ff9a3c 38%, #ffffff 52%, #ffd45e 72%, #ffe9a0 100%) 0 0 / 260% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; text-shadow: none; font-weight: 800;
  filter: drop-shadow(1px 0 0 #000) drop-shadow(-1px 0 0 #000) drop-shadow(0 1px 0 #000) drop-shadow(0 -1px 0 #000) drop-shadow(0 0 4px rgba(255, 170, 60, .9)); animation: gm-shine 2.4s linear infinite; }
.gm-crown { position: absolute; left: 50%; top: -1.2em; transform: translateX(-50%); font-style: normal; font-size: 1.1em; line-height: 1; color: #ffd45e; -webkit-text-fill-color: #ffd45e; text-shadow: 0 0 6px #ff9a3c, 1px 1px 0 #000, -1px 1px 0 #000; animation: gm-bob 1.5s ease-in-out infinite; }
.gm-spark { position: absolute; width: .55em; height: .55em; background: #fff; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); opacity: 0; animation: gm-twinkle 2.2s ease-in-out infinite; }
.gm-spark.a { left: -8%; top: 0; }
.gm-spark.b { right: -8%; bottom: -10%; animation-delay: 1.1s; }
@keyframes gm-shine { to { background-position: -260% 0; } }
@keyframes gm-pulse { 50% { opacity: .35; transform: scale(1.12); } }
@keyframes gm-bob { 50% { transform: translateX(-50%) translateY(-3px) rotate(5deg); } }
@keyframes gm-twinkle { 0%, 100% { opacity: 0; transform: scale(.3) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(90deg); } }
#chat-log .gm b.gm-name, #chat-log p.gm b { display: inline; }
@media (prefers-reduced-motion: reduce) { .gmfx::before, .gm-name, .gm-crown, .gm-spark { animation: none; } .gm-name { background-position: 20% 0; } .gm-spark { opacity: .8; } }

/* ---- PvP: name and health bar over each fighter */
#pv-tags { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
#hud:not(.pvp) #pv-tags { display: none; }
.pvt { position: absolute; transform: translate(-50%, -100%); display: grid; justify-items: center; gap: 2px; font-family: "Kanit", sans-serif; white-space: nowrap; }
.pvt[hidden] { display: none; }
.pvt-name { font: 600 clamp(11px, 1.5vw, 15px)/1.2 "Kanit", sans-serif; color: #9affb0; text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000; }
.pvt.foe .pvt-name { color: #ff9a8a; }
.pvt-name small { margin-left: 4px; font-weight: 400; font-size: .82em; color: #e8ecff; }
.pvt-bar { position: relative; width: clamp(78px, 15vw, 132px); height: clamp(8px, 1.3vw, 12px); background: #1a0c0c; border: 2px solid #000; box-shadow: 0 0 0 1px rgba(255, 255, 255, .25), 0 2px 4px rgba(0, 0, 0, .6); }
.pvt-bar i { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(#8fe06a, #3c9a3a); transition: width .18s ease-out; }
.pvt.foe .pvt-bar i { background: linear-gradient(#ff7a6a, #b8261e); }
.pvt.low .pvt-bar i { background: linear-gradient(#ffc04a, #d97010); animation: pvt-low .5s steps(2) infinite; }
.pvt-bar .sh { position: absolute; inset: 0 auto 0 0; z-index: 2; height: 35%; background: #8ad0ff; box-shadow: 0 1px 0 rgba(255, 255, 255, .5); }
.pvt-bar em { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; font: 600 clamp(7px, .95vw, 10px)/1 "Kanit", sans-serif; font-style: normal; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
.pvt-pips { display: flex; gap: 3px; }
.pvt-pips i { width: 8px; height: 8px; border-radius: 50%; border: 1px solid #000; background: #555; }
.pvt-pips i.on { background: #ffd45e; box-shadow: 0 0 4px #ffd45e; }
.pvt-pips i.bench { background: #6a8a6a; }
.pvt-pips i.ko { background: #3a1a1a; }
@keyframes pvt-low { 50% { filter: brightness(1.5); } }
@media (prefers-reduced-motion: reduce) { .pvt.low .pvt-bar i { animation: none; } }

/* ---- Sign in with Google */
.auth-google { display: grid; justify-items: center; gap: 8px; }
.auth-or { display: flex; align-items: center; gap: 8px; width: 100%; color: var(--mute); font-size: 14px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--wood3); }
#auth-gbtn, #set-gbtn { min-height: 40px; display: flex; justify-content: center; color-scheme: light; }
#set-gbtn { justify-content: flex-start; }
#auth-gcreate { width: 100%; justify-content: center; }

/* ---- chat: a log that follows the newest line, and the PvP panel */
.chat-new { position: absolute; right: 8px; bottom: 46px; z-index: 3; min-height: 32px; padding: 4px 10px; font: 700 14px "Kanit", sans-serif; color: #1a1020; background: var(--gold); border: 2px solid var(--ink); border-radius: 999px; cursor: pointer; pointer-events: auto; box-shadow: var(--notice-ring); }
.chat-new[hidden] { display: none; }
#pvp-ui { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
#pvp-ui[hidden] { display: none; }
#pv-chat { position: absolute; left: calc(6px + var(--sa-l)); bottom: calc(6px + var(--sa-b)); width: min(36%, 340px); display: flex; flex-direction: column; pointer-events: auto; background: rgba(10, 7, 6, .66); border: 2px solid rgba(13, 9, 7, .9); box-shadow: 0 0 0 1px rgba(110, 74, 22, .7); font-size: 13px; }
#pv-chat .chat-tabs b { padding: 2px 8px; font: 600 12px/1.4 "Kanit", sans-serif; color: var(--cream); }
#pv-log { height: clamp(60px, 16vh, 130px); overflow-y: auto; padding: 3px 6px; line-height: 1.35; user-select: text; -webkit-user-select: text; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: thin; }
#pv-log p { margin: 0 0 1px; word-break: break-word; text-shadow: 1px 1px 0 #000; }
#pv-log b { font-family: "Kanit", sans-serif; font-weight: 600; }
#pv-log .me b { color: #9affb0; } #pv-log .foe b { color: #ff9a8a; } #pv-log .gm b.gm-name { display: inline; } #pv-log .sys { color: #ffd45e; }
#pv-quick { display: flex; flex-wrap: wrap; gap: 3px; padding: 3px; }
#pv-quick button { padding: 2px 8px; font: 600 12px "Kanit", sans-serif; color: var(--cream); background: rgba(0, 0, 0, .45); border: 1px solid var(--wood4); cursor: pointer; }
#pv-quick button:active { background: var(--wood3); }
#pv-form { display: flex; gap: 3px; padding: 3px; }
#pv-in { flex: 1; min-width: 0; padding: 4px 7px; background: rgba(0, 0, 0, .55); border: 1px solid var(--wood4); font-size: 14px; }
#pv-in:focus { outline: 2px solid var(--brass); }
#pv-form .btn { padding: 2px 10px; font-size: 13px; }
#pv-chat.fold #pv-log, #pv-chat.fold #pv-quick, #pv-chat.fold #pv-form, #pv-chat.fold .chat-new { display: none; }
#pv-chat .chat-fold.has-unread { display: inline-flex; align-items: center; gap: 4px; }
#pv-chat .chat-fold.has-unread::after { content: attr(data-n); display: inline-grid; color: #1a1020; background: var(--gold); box-shadow: var(--notice-ring); }
.pvt .bub { display: block; margin: 0 auto 3px; max-width: 160px; width: max-content; white-space: normal; padding: 3px 8px; font: 600 12px/1.3 "Sarabun", sans-serif; color: #1a1020; text-shadow: none; background: #fffaf0; border: 2px solid #1a1020; border-radius: 8px; box-shadow: 2px 2px 0 rgba(0, 0, 0, .35); animation: emo-pop .25s ease-out; }
@media (pointer: coarse) {
  #pv-chat { bottom: calc(150px + var(--sa-b)); width: min(40%, 320px); }
  #pv-log { height: clamp(50px, 13vh, 96px); }
}
@media (pointer: coarse) and (orientation: portrait) {
  #pv-chat { left: 8px; right: 8px; width: auto; bottom: calc(224px + var(--sa-b)); }
}

.auth-ginfo { padding: 8px 10px; font-size: 14px; line-height: 1.5; color: var(--cream); background: #1f3a2a; border: 2px solid #3a8a5a; }
.auth-ginfo[hidden] { display: none; }
.auth-ginfo .linklike { margin-left: 4px; padding: 0; color: var(--gold); background: none; border: 0; text-decoration: underline; font: inherit; cursor: pointer; }

/* ---- friends: a button on the right edge that opens a centred pop-up with three tabs (รายชื่อ · เพิ่มเพื่อน · คำขอ).
   A pending request beats on the button itself: a red count badge and a warm red frame. */
#fr { position: absolute; right: 0; top: max(160px, 36%); z-index: 12; display: flex; align-items: flex-start; pointer-events: none; }
#fr[hidden] { display: none; }
#fr > * { pointer-events: auto; }
#fr-tab { position: relative; display: grid; justify-items: center; gap: 1px; padding: 8px 6px 7px; min-width: 48px; color: var(--cream); background: linear-gradient(#3a2a18, #22160e); border: 2px solid var(--ink); border-right: 0; box-shadow: inset 0 0 0 2px var(--brass-d), 0 3px 12px rgba(0, 0, 0, .55); cursor: pointer; font: 600 12px "Kanit", sans-serif; }
#fr-tab span { font-size: 20px; line-height: 1; }
#fr-tab small { font-size: 11px; color: var(--dim); letter-spacing: .5px; }
#fr-tab b { font: 800 12px/1 "Kanit", sans-serif; color: var(--gold); font-variant-numeric: tabular-nums; }
#fr-tab:hover { filter: brightness(1.15); }
#fr-tab.alert { background: linear-gradient(#7a2418, #44100a); box-shadow: inset 0 0 0 2px var(--bad), 0 0 16px rgba(255, 60, 40, .6); animation: fr-nudge .9s ease-in-out infinite; }
#fr-tab.alert small { color: #ffd0c8; }
.fr-alert { --notice-count-size: 28px; position: absolute; top: -14px; right: 2px; display: grid; color: #fff; background: #c3262b; box-shadow: var(--notice-ring); }
.fr-alert[hidden] { display: none; }
@keyframes fr-nudge { 50% { transform: translateX(-3px); } }
@media (prefers-reduced-motion: reduce) { #fr-tab.alert { animation: none; } }

/* the pop-up: centred, as tall as the screen it is on allows, never wider than the phone */
#fr-pop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: max(10px, var(--sa-t)) max(10px, var(--sa-r)) max(10px, var(--sa-b)) max(10px, var(--sa-l)); }
#fr-pop[hidden] { display: none; }
.fr-back { position: absolute; inset: 0; background: rgba(5, 4, 8, .74); }
.fr-card { position: relative; display: flex; flex-direction: column; width: min(460px, 100%); height: min(600px, 100%); max-height: 100%; background: var(--wood1); border: 3px solid var(--ink); clip-path: var(--notch); box-shadow: inset 0 0 0 2px var(--brass-d), inset 0 0 0 4px var(--ink), 0 16px 40px rgba(0, 0, 0, .65); font-family: "Sarabun", "Kanit", sans-serif; animation: fr-in .16s ease-out; }
@keyframes fr-in { from { opacity: 0; transform: scale(.94); } }
.fr-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--wood3); border-bottom: 3px solid var(--ink); box-shadow: inset 0 -2px 0 var(--brass-d); }
.fr-head b { font: 800 18px "Kanit", sans-serif; color: var(--brass-l); letter-spacing: 1px; text-shadow: 2px 2px 0 var(--ink); }
.fr-head small { flex: 1; font-size: 13px; color: var(--dim); }
.fr-x { width: 34px; height: 34px; flex: none; background: var(--wood4); border: 2px solid var(--ink); box-shadow: var(--bevel); font-size: 16px; font-weight: 900; text-shadow: 1px 1px 0 var(--ink); }
.fr-x:active { transform: translateY(1px); box-shadow: var(--bevel-in); }
.fr-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 4px; background: var(--wood0); border-bottom: 2px solid var(--ink); }
.fr-tb { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 9px 4px; border: 2px solid transparent; background: none; color: var(--dim); font: 700 14px "Kanit", sans-serif; white-space: nowrap; }
.fr-tb.on { color: var(--wood0); background: var(--brass); border-color: var(--ink); box-shadow: inset 2px 2px 0 var(--brass-l), inset -2px -2px 0 var(--brass-d); }
.fr-cnt { display: inline-grid; color: #fff; background: #c3262b; }
.fr-cnt[hidden] { display: none; }
.fr-tb.on .fr-cnt { color: var(--cream); background: #8a2416; }
.fr-body { flex: 1; min-height: 0; display: flex; }
.fr-pane { flex: 1; min-height: 0; display: none; flex-direction: column; }
.fr-pane.on { display: flex; }
.fr-pane[data-frp="list"], .fr-pane[data-frp="req"] { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
#fr-list, #fr-req { display: flex; flex-direction: column; }
.fr-pane h4:first-child { margin-top: 10px; }
.fr-pane h4 { margin: 10px 10px 4px; }
.fr-row { display: flex; align-items: center; gap: 5px; padding: 7px 10px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.fr-st { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #6a6a6a; }
.fr-row.on .fr-st { background: #4adf6a; box-shadow: 0 0 6px #4adf6a; }
.fr-row.off { opacity: .72; }
.fr-nm { flex: 1; min-width: 0; line-height: 1.25; cursor: pointer; }
.fr-nm b { display: block; font: 600 15px "Kanit", sans-serif; color: var(--cream); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-nm b em { margin-left: 5px; font-style: normal; font-weight: 400; font-size: 12px; color: var(--dim); }
.fr-nm small { display: block; font-size: 13px; color: #cdbb98; }
.fr-row.on .fr-nm small { color: #8ee8a0; }
.fr-row button { flex: none; min-width: 36px; min-height: 36px; padding: 0 8px; font-size: 14px; color: var(--cream); background: var(--wood2); border: 2px solid var(--ink); box-shadow: var(--bevel); cursor: pointer; }
.fr-row button:active { transform: translateY(1px); box-shadow: var(--bevel-in); }
.fr-row button:disabled { opacity: .35; cursor: default; }
.fr-row button.duel { color: #ffb0a0; background: #5a2020; }
.fr-row button.ok { color: #1a2a1a; background: #6dd68a; font-weight: 700; }
.fr-row.req { background: rgba(255, 212, 94, .1); }
.fr-row.out small { color: var(--dim); }
.fr-none { margin: 10px; font-size: 14px; color: var(--dim); }
#fr-add { display: flex; gap: 6px; padding: 10px; border-bottom: 2px solid var(--ink); background: var(--wood0); }
#fr-in { flex: 1; min-width: 0; padding: 9px 10px; font-size: 16px; background: rgba(0, 0, 0, .5); border: 2px solid var(--ink); box-shadow: var(--bevel-in); }
#fr-in:focus { outline: none; box-shadow: 0 0 0 2px var(--brass), var(--bevel-in); }
#fr-add .btn { padding: 7px 14px; font-size: 15px; }
.fr-hint { margin: 10px 12px; font-size: 14px; line-height: 1.6; color: var(--dim); }
/* phones and short windows: the pop-up takes the screen it has (no overflow), with bigger touch targets */
@media (max-width: 520px), (max-height: 560px) {
  .fr-card { width: 100%; height: 100%; }
  .fr-head { padding: 6px 8px; }
  .fr-head b { font-size: 16px; }
  .fr-tb { padding: 11px 3px; font-size: 13px; gap: 3px; }
}
@media (pointer: coarse) {
  .fr-x { width: 40px; height: 40px; }
  .fr-row { padding: 8px; }
  .fr-row button { min-width: 40px; min-height: 40px; }
  .fr-tb { padding: 11px 4px; font-size: 13.5px; }
}
@media (pointer: coarse) and (orientation: portrait) { #fr { top: calc(56.25vw - 40px); } }
.dlg-card.profile { width: min(420px, 100%); }
.pf-name { margin: 0 0 2px !important; font: 800 24px "Kanit", sans-serif; }
.pf-title { margin: 0 0 4px !important; color: var(--gold); font-size: 15px; }
.pf-live { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 8px !important; font-size: 15px; color: var(--dim); }
.pf-live i { width: 10px; height: 10px; border-radius: 50%; background: #6a6a6a; }
.pf-live.on { color: #8ee8a0; } .pf-live.on i { background: #4adf6a; box-shadow: 0 0 6px #4adf6a; }
.pf-team { display: flex; gap: 6px; justify-content: center; margin: 6px 0; }
.pf-hero { flex: 1; max-width: 120px; display: grid; justify-items: center; padding: 6px 4px; background: color-mix(in srgb, var(--cc) 16%, var(--wood0)); border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--cc); }
.pf-hero img { width: 52px; height: 52px; image-rendering: pixelated; }
.pf-hero b { font: 600 15px "Kanit", sans-serif; } .pf-hero small { font-size: 13px; color: var(--dim); } .pf-stars { font-size: 12px; color: var(--gold); letter-spacing: 1px; }
.pf-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 8px 0; }
.pf-stats div { display: grid; padding: 6px 2px; background: var(--wood0); border: 1px solid var(--wood3); }
.pf-stats b { font: 700 18px "Kanit", sans-serif; color: var(--gold); } .pf-stats span { font-size: 13px; color: var(--dim); }
.dlg-card.duelinv, .dlg-card.duelwait { background: radial-gradient(circle at 50% 12%, #5a2424, var(--wood1) 62%); box-shadow: inset 0 0 0 2px #c0504a; }
.di-who { margin: 2px 0 !important; font: 800 30px "Kanit", sans-serif; color: var(--gold); }

/* ---- the mailbox: the player's list, gift chips, the admin's list */
.mail-top { margin-bottom: 8px; align-items: center; }
.mail-empty { display: grid; justify-items: center; gap: 6px; padding: 30px 12px; text-align: center; color: var(--dim); }
.mail-empty .pi { width: 44px; height: 44px; opacity: .7; } .mail-empty b { font: 600 18px "Kanit", sans-serif; color: var(--cream); } .mail-empty small { font-size: 15px; line-height: 1.5; max-width: 34em; }
.mail { margin-bottom: 6px; background: var(--wood2); border: 2px solid var(--ink); box-shadow: var(--bevel); }
.mail.new { box-shadow: inset 0 0 0 2px var(--gold), var(--bevel); }
.mail.done { opacity: .82; }
.mail-hd { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; text-align: left; color: var(--cream); background: none; border: 0; cursor: pointer; font: inherit; }
.mail-ico .pi { width: 32px; height: 32px; }
.mail-tt { flex: 1; min-width: 0; display: grid; }
.mail-tt b { font: 600 17px/1.3 "Kanit", sans-serif; overflow: hidden; text-overflow: ellipsis; }
.mail-tt small { font-size: 14px; color: var(--dim); }
.mail-hd em { flex: none; padding: 2px 8px; font: 600 13px "Kanit", sans-serif; font-style: normal; border: 2px solid var(--ink); }
.mail-hd em.new { color: #1a1020; background: var(--gold); } .mail-hd em.gift { color: #1a1020; background: #ff9a6a; } .mail-hd em.got { color: #1a2a1a; background: #7dff9a; }
.mail-bd { padding: 4px 12px 12px; border-top: 1px dashed var(--wood4); }
.mail-bd > p { margin: 8px 0; font-size: 16px; line-height: 1.6; color: #f2e4c2; word-break: break-word; }
.mail-att { margin: 8px 0; padding: 8px 10px; background: var(--wood0); border: 2px solid var(--ink); }
.mail-att > b { display: block; margin-bottom: 4px; font: 600 15px "Kanit", sans-serif; color: var(--gold); }
.mail-att > div { display: flex; flex-wrap: wrap; gap: 5px; }
.mail-att .btn { margin-top: 8px; width: 100%; justify-content: center; }
.mail-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; font-size: 14.5px; color: var(--rc, var(--cream)); background: #2a1c12; border: 1px solid #5a4028; }
.mail-chip .pi { width: 16px; height: 16px; }
.mail-got { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin: 6px 0; }
.mail-items { max-height: 150px; overflow: auto; margin: 6px 0; padding: 6px 8px 6px 24px; text-align: left; font-size: 15px; background: var(--wood0); }
.mm-mail { position: relative; }
.adm-mail { margin-bottom: 8px; padding: 8px 10px; background: var(--wood2); border: 2px solid var(--ink); }
.adm-mail.done { opacity: .6; } .adm-mail.soon { box-shadow: inset 3px 0 0 #6aa8ff; } .adm-mail.live { box-shadow: inset 3px 0 0 #6dffa0; }
.am-hd { display: flex; align-items: center; gap: 8px; } .am-hd b { flex: 1; font: 600 16px "Kanit", sans-serif; }
.am-body { margin: 4px 0; font-size: 14px; color: var(--dim); white-space: pre-wrap; }

/* ---- tap a player in the MMO */
#mm-tags .mtag.pl { pointer-events: auto; cursor: pointer; padding: 2px 4px; }
#mm-tags .mtag.pl:hover { filter: brightness(1.3); }
.dlg-card.pcard { width: min(340px, 100%); }
.pc-acts { display: grid; gap: 6px; margin-top: 8px; }
.pc-acts .btn { justify-content: center; padding: 10px; }
.pc-state { padding: 8px; text-align: center; }

/* ================================================================ phones
   One clear block, last in the file so it wins over the older desktop rules that used to override the portrait ones
   (the narrow 240px menu, tall wrapping hero cards stacked over the buttons). */

/* ---- the camp held upright: the picture on top, then the team in one row, then the menu filling the rest */
@media (orientation: portrait) {
  .lb-crest { display: none; }
  .lb-team { top: calc(56.25vw + 6px); left: calc(8px + var(--sa-l)); right: calc(8px + var(--sa-r)); flex-direction: row; gap: 5px; }
  .lb-hero { flex: 1 1 0; min-width: 0; width: auto; display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 6px; row-gap: 1px; align-items: center; text-align: left; padding: 5px 6px 5px 9px; }
  .lb-hero img { grid-row: 1; grid-column: 1; width: 34px; height: 34px; }
  .lb-hero > div:not(.pw) { grid-row: 1; grid-column: 2; min-width: 0; }
  .lb-hero b { font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lb-hero small { font-size: 11.5px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lb-hero .pw { grid-row: 2; grid-column: 1 / -1; margin: 0; text-align: left; font-size: 13px; white-space: nowrap; }
  .lb-menu { left: calc(8px + var(--sa-l)); right: calc(8px + var(--sa-r)); width: auto; top: calc(56.25vw + 84px); bottom: calc(8px + var(--sa-b)); overflow-y: auto; align-content: start; grid-template-columns: 1fr 1fr; gap: 6px; scrollbar-width: none; }
  .lb-menu::-webkit-scrollbar { display: none; }
  .lb-menu .lb-btn { padding: 6px 8px; font-size: 14.5px; }
  .lb-menu .lb-btn small { font-size: 12px; line-height: 1.25; }
  .lb-menu .lb-btn.go, .lb-menu .lb-btn.mmo, .lb-menu .lb-btn.pvp { font-size: 16px; padding: 8px 10px 8px 8px; }
  .lb-news { top: auto; bottom: calc(100% - 56.25vw + 6px); left: calc(8px + var(--sa-l)); right: calc(8px + var(--sa-r)); align-items: stretch; }
  .lb-news > div { max-width: none; }
  #fr { top: 76px; }
}
/* a finger leaves no hover: buttons must not stay shifted after a tap */
@media (hover: none) { .lb-btn:hover, .lb-hero:hover { transform: none; filter: none; } .lb-btn:active { transform: translateY(2px); } }

/* ---- landscape phones: the menu column may not run off the bottom */
@media (max-height: 460px) and (orientation: landscape) {
  .lb-menu { top: calc(46px + var(--sa-t)); overflow-y: auto; align-content: end; scrollbar-width: none; }
  .lb-team { top: calc(46px + var(--sa-t)); }
  .lb-hero small { font-size: 12px; }
}

/* ---- every menu page on a narrow screen: full screen, text that wraps instead of pushing the page sideways */
@media (max-width: 700px) {
  #modal { padding: 0; place-items: stretch; }
  .m-card { width: 100%; height: 100dvh; max-height: 100dvh; clip-path: none; border-left: 0; border-right: 0; border-bottom: 0; padding-bottom: var(--sa-b); }
  .m-head { padding: calc(8px + var(--sa-t) * 0) 10px; margin: 0; }
  .m-head b { font-size: 17px; letter-spacing: 0; }
  .m-x { width: 40px; height: 40px; }
  .m-body { padding: 8px 10px calc(16px + var(--sa-b)); margin: 0; overflow-x: hidden; overflow-wrap: anywhere; }
  .btn { white-space: normal; min-height: 40px; }
  .chip { min-height: 36px; padding: 7px 11px; }
  .tb-btn { min-height: 34px; }
  .row { gap: 6px; }
  .row .btn, .row .chip { flex: 0 1 auto; }
  .tbl { font-size: 14px; } .tbl td { padding: 4px 4px; }
  .setrow { gap: 4px 8px; } .setrow > span { min-width: 0; flex: 1 0 100%; }
  .adm-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .adm-cols { grid-template-columns: 1fr; }
  .adm-list { max-height: 34vh; }
  .mapc .mi b { font-size: 14px; }
  .quest { flex-wrap: wrap; } .quest .tx { flex: 1 1 60%; } .quest .pbar { min-width: 60px; }
  .sumgrid { grid-template-columns: repeat(2, 1fr); }
  .tm-fig b { font-size: 16px; overflow-wrap: anywhere; }
  .tm-fig small { font-size: 13px; text-align: center; overflow-wrap: anywhere; }
  .tm-spot > .btn { font-size: 13px; padding: 8px 2px; }
  .tm-hint { font-size: 14px; }
  .tm-head .tx b { font-size: 18px; }
  .tm-skill p { font-size: 15px; }
  .sk-facts span { font-size: 13.5px; }
  .tm-tabs .chip { font-size: 14px; padding: 9px 2px; }
  .fr-row button { min-width: 36px; min-height: 36px; }
}
/* iOS zooms into any field under 16px when it is focused */
@media (pointer: coarse) { input:not([type=checkbox]):not([type=range]), textarea, select { font-size: 16px; } }

/* ---- very narrow (a small phone upright) */
@media (max-width: 380px) {
  .lb-hero b { font-size: 13px; }
  .lb-menu .lb-btn { font-size: 13.5px; }
  .lb-menu .lb-btn small { font-size: 11px; }
  .tm-stage { gap: 4px; padding: 6px 4px; }
  .tm-spr { width: 72px; }
}

/* ---- draggable HUD: each part carries its own saved offset (see hudlayout.js) */
#team, #mm-top, #chat, #joy { transform: translate(var(--hud-x, 0px), var(--hud-y, 0px)); }
[data-hud]:not(#team):not(#mm-top):not(#chat):not(#joy) { translate: var(--hud-x, 0px) var(--hud-y, 0px); }
#hudedit { position: fixed; z-index: 70; left: 50%; top: calc(6px + var(--sa-t)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 5px 9px; background: rgba(20, 13, 9, .95); border: 2px solid var(--ink); box-shadow: 0 0 0 2px var(--brass-d), 0 4px 14px rgba(0, 0, 0, .6); font-size: 12px; white-space: nowrap; }
#hudedit[hidden] { display: none; }
#hudedit b { font: 600 13px "Kanit", sans-serif; color: var(--brass-l); }
#hudedit small { color: var(--dim); font-size: 11px; }
#hudedit .sp { width: 4px; }
#hudedit .btn { padding: 3px 10px; font-size: 12px; }
#app.hud-edit [data-hud] { outline: 2px dashed rgba(255, 212, 94, .85); outline-offset: 2px; touch-action: none; cursor: grab; }
#app.hud-edit #skills { pointer-events: auto !important; z-index: 60; }
#app.hud-edit #skills .sk { pointer-events: auto !important; touch-action: none !important; user-select: none; -webkit-user-select: none; }
#app.hud-edit [data-hud] * { pointer-events: none; }
#app.hud-edit [data-hud] [data-hud] { pointer-events: auto; }
#app.hud-edit [data-hud].hud-grab { outline-color: #fff; filter: brightness(1.12); }
#app.hud-edit::after { content: ""; position: fixed; inset: 0; z-index: 41; background: rgba(0, 0, 0, .18); pointer-events: none; }

/* ---- phones held sideways: one tidy corner each, nothing stacked on top of anything */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 620px) {
  /* team: three small cards in a row, portrait + health only */
  #hud.mmo #team { top: calc(6px + var(--sa-t)); left: calc(6px + var(--sa-l)); flex-direction: row; gap: 3px; }
  #hud.mmo #team .card { width: 46px; height: 44px; padding: 2px; justify-content: center; gap: 0; }
  #hud.mmo #team .card .nm { display: none; }
  #hud.mmo #team .card .hero-ico { width: 30px; height: 30px; margin: 0 auto; }
  #hud.mmo #team .card .hp { position: absolute; left: 3px; right: 3px; bottom: 3px; height: 5px; margin: 0; }
  #hud.mmo #team .card kbd { display: none; }

  /* the map bar: small minimap, one wrapping row of buttons, a single scrolling quest line */
  #mm-top { gap: 2px 5px; }
  #mm-mini { width: 84px; }
  .mm-card b { font-size: 12px; }
  .mm-card span { font-size: 9.5px; padding: 1px 4px; }
  .mm-card small { display: none; }
  .mm-btns { flex-wrap: wrap; justify-content: flex-end; gap: 3px; max-width: 216px; margin-left: auto; }
  .mm-btns .tb-btn { min-height: 26px; padding: 2px 6px; font-size: 12px; }
  .mm-zoom .tb-btn { min-width: 26px; font-size: 14px; }
  .mm-zoom b { min-width: 32px; font-size: 10.5px; }
  .mm-quests { display: flex; gap: 10px; max-width: 44vw; padding: 2px 6px; font-size: 10px; overflow-x: auto; scrollbar-width: none; }
  .mm-quests span { flex: none; }
  .mm-quests::-webkit-scrollbar { display: none; }

  /* chat sits above the joystick, clear of the team cards and the skill pad */
  #chat { bottom: calc(128px + var(--sa-b)); width: min(46%, 250px); font-size: 11px; }
  #chat-log { height: 54px; }
  #chat-in { font-size: 12px; padding: 3px 6px; }
  #chat-form .btn { padding: 2px 8px; font-size: 12px; }
  #mm-emotes button { width: 26px; height: 26px; font-size: 14px; }

  /* skills: a 2-column pad instead of circles that overlap each other */
  #skills { display: grid; grid-template-columns: repeat(2, 52px); grid-auto-rows: 52px; gap: 7px; align-items: center; justify-items: center; width: auto; height: auto; pointer-events: none; }
  #skills .sk { position: relative; inset: auto; grid-column: auto; grid-row: auto; width: 52px; height: 52px; }
  #skills .sk.s0, #skills .sk.s1, #skills .sk.s2, #skills .sk.s3 { right: auto; bottom: auto; }
  #skills .sk.s2 { order: 1; } #skills .sk.s3 { order: 2; }
  #skills .sk.s0 { order: 3; } #skills .sk.s1 { order: 4; }
  #skills .sk.dodge, #pad.mmo #skills .sk.dodge { order: 5; width: 44px; height: 44px; right: auto; bottom: auto; }
  #skills .sk.atk { order: 6; width: 62px; height: 62px; }
  #skills .sk .t { font-size: 14px; }
  #joy { width: 118px; height: 118px; }
  #joy-knob { width: 46px; height: 46px; margin: -23px 0 0 -23px; }

  /* notices go to the top middle, where nothing else lives */
  #app:has(#hud.mmo) #toasts { top: calc(44px + var(--sa-t)); bottom: auto; left: 50%; right: auto; transform: translateX(-50%); align-items: center; max-width: 60vw; font-size: 10.5px; text-align: center; }
  #app:has(#hud.mmo) #toasts .toast { white-space: normal; }
  #fr { top: calc(120px + var(--sa-t)); }
  #fr-tab { padding: 6px 4px; min-width: 44px; }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 430px) {
  #mm-mini { width: 68px; }
  #mm-top { gap: 1px 4px; }
  .mm-btns .tb-btn { min-height: 23px; padding: 1px 5px; font-size: 11px; }
  .mm-quests { font-size: 9.5px; max-width: 40vw; }
  #chat { width: min(48%, 210px); bottom: calc(116px + var(--sa-b)); }
  #chat-log { height: 40px; }
  #skills { grid-template-columns: repeat(2, 46px); grid-auto-rows: 46px; gap: 5px; }
  #skills .sk { width: 46px; height: 46px; }
  #skills .sk.atk { width: 54px; height: 54px; }
  #skills .sk.dodge, #pad.mmo #skills .sk.dodge { width: 40px; height: 40px; }
  #joy { width: 104px; height: 104px; }
  #joy-knob { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
  #hud.mmo #team .card { width: 40px; height: 38px; }
  #hud.mmo #team .card .hero-ico { width: 25px; height: 25px; }
  #fr { top: calc(102px + var(--sa-t)); }
}

/* MMO on a sideways phone uses the whole viewport. Keep touch targets apart and
   place chat in the lane between the left joystick and the right skill cluster. */
@media (pointer: coarse) and (orientation: landscape) {
  #stage { width: 100vw; height: 100vh; height: 100dvh; }
  #app.mode-mmo #stage { width: 100vw; height: 100vh; height: 100dvh; }
  #hud.mmo #team { z-index: 6; }
  #mm-top, #chat { z-index: 7; }
  #mm-top .mm-btns .tb-btn,
  #mm-top .mm-zoom .tb-btn,
  #mm-top .mm-quests,
  #chat .chat-tabs button,
  #chat-form .btn { min-width: 36px; min-height: 36px; touch-action: manipulation; }
  #mm-top .mm-btns { max-width: min(42vw, 260px); }
  #chat { left: calc(126px + var(--sa-l)); right: auto; bottom: calc(8px + var(--sa-b)); width: min(30vw, 250px); max-width: calc(100vw - 290px); }
  #chat-log { height: clamp(40px, 12vh, 76px); }
  #chat.fold { width: auto; min-width: 142px; }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 430px) {
  #mm-top .mm-btns .tb-btn,
  #mm-top .mm-zoom .tb-btn,
  #chat .chat-tabs button,
  #chat-form .btn { min-width: 34px; min-height: 34px; }
  #chat { left: calc(112px + var(--sa-l)); width: min(30vw, 220px); max-width: calc(100vw - 260px); }
  #chat-log { height: 42px; }
}

/* Keep the MMO friends tab clear of the minimap/action controls at the right. */
@media (pointer: coarse) {
  #app.mode-mmo #fr { top: calc(6px + var(--sa-t)); right: auto; left: 50%; transform: translateX(-50%); flex-direction: column; align-items: center; }
  #app.mode-mmo #fr-tab { border: 2px solid var(--ink); }
}

/* in edit mode the whole bar is grabbable, not only its buttons */
#app.hud-edit #team, #app.hud-edit #mm-top, #app.hud-edit #skills { pointer-events: auto; }

/* Some iPads identify as a desktop pointer in Safari.  The app marks those
   devices with .touch-ui at boot so they get a full usable game area instead
   of the desktop's fixed 16:9 frame and oversized menu cards. */
#app.touch-ui { touch-action: none; }
#app.touch-ui #stage, #app.touch-ui #view, #app.touch-ui #pad, #app.touch-ui #joy, #app.touch-ui #skills .sk { touch-action: none; }
@media (orientation: landscape) {
  #app.touch-ui #stage { width: 100vw; height: 100vh; height: 100dvh; }
  #app.touch-ui #pad { position: fixed; left: 0; right: 0; bottom: 0; height: 60%; }
  #app.touch-ui #joy { left: calc(10px + var(--sa-l)); bottom: calc(10px + var(--sa-b)); width: 118px; height: 118px; }
  #app.touch-ui #joy-knob { width: 46px; height: 46px; margin: -23px 0 0 -23px; }
  #app.touch-ui #skills { display: grid; grid-template-columns: repeat(2, 52px); grid-auto-rows: 52px; gap: 7px; align-items: center; justify-items: center; width: auto; height: auto; right: calc(6px + var(--sa-r)); bottom: calc(6px + var(--sa-b)); pointer-events: none; }
  #app.touch-ui #skills .sk { position: relative; inset: auto; grid-column: auto; grid-row: auto; width: 52px; height: 52px; border-radius: 50%; clip-path: none; pointer-events: auto; }
  #app.touch-ui #skills .sk.s0, #app.touch-ui #skills .sk.s1, #app.touch-ui #skills .sk.s2, #app.touch-ui #skills .sk.s3 { right: auto; bottom: auto; }
  #app.touch-ui #skills .sk.s2 { order: 1; } #app.touch-ui #skills .sk.s3 { order: 2; }
  #app.touch-ui #skills .sk.s0 { order: 3; } #app.touch-ui #skills .sk.s1 { order: 4; }
  #app.touch-ui #skills .sk.dodge, #app.touch-ui #pad.mmo #skills .sk.dodge { order: 5; width: 44px; height: 44px; right: auto; bottom: auto; }
  #app.touch-ui #skills .sk.atk { order: 6; width: 62px; height: 62px; }
  #app.touch-ui #skills .sk small { display: none; }

  /* Lobby: retain the landscape composition but size it for a thumb-operated screen. */
  #app.touch-ui .lb-top { gap: 4px; padding: calc(4px + var(--sa-t)) calc(6px + var(--sa-r)) 4px calc(6px + var(--sa-l)); font-size: 11px; }
  #app.touch-ui .lb-user { gap: 5px; } #app.touch-ui .lb-avatar { width: 34px; height: 34px; }
  #app.touch-ui .lb-team { left: calc(6px + var(--sa-l)); top: calc(44px + var(--sa-t)); gap: 4px; }
  #app.touch-ui .lb-hero { width: min(30vw, 148px); min-height: 42px; padding: 4px 6px 4px 4px; gap: 5px; }
  #app.touch-ui .lb-hero img { width: 32px; height: 32px; }
  #app.touch-ui .lb-hero > div:not(.pw) { min-width: 0; flex: 1; } #app.touch-ui .lb-hero small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #app.touch-ui .lb-hero b { font-size: 13px; } #app.touch-ui .lb-hero small, #app.touch-ui .lb-hero .pw { font-size: 11px; }
  #app.touch-ui .lb-menu { right: calc(6px + var(--sa-r)); bottom: calc(6px + var(--sa-b)); width: min(42vw, 260px); gap: 4px; }
  #app.touch-ui .lb-menu .lb-btn { padding: 5px 7px; font-size: 12px; }
  #app.touch-ui .lb-menu .lb-btn small { font-size: 10px; } #app.touch-ui .lb-menu .lb-btn .pi { width: 23px; height: 23px; }
  /* the emoji tiles (pets, co-op) were wider than the drawn icons: the label wrapped / clipped in landscape */
  #app.touch-ui .lb-menu .lb-btn .lb-emo { width: 23px; font-size: 17px; }
  #app.touch-ui .lb-menu .lb-btn { white-space: nowrap; column-gap: 6px; }
  #app.touch-ui .lb-menu .lb-btn small { overflow: hidden; text-overflow: ellipsis; }
  #app.touch-ui .lb-menu .lb-btn.go, #app.touch-ui .lb-menu .lb-btn.mmo, #app.touch-ui .lb-menu .lb-btn.pvp { padding: 6px 8px; font-size: 14px; }
  #app.touch-ui .lb-menu .lb-btn.go .pi, #app.touch-ui .lb-menu .lb-btn.mmo .pi, #app.touch-ui .lb-menu .lb-btn.pvp .pi { width: 27px; height: 27px; }
  #app.touch-ui .lb-crest { top: calc(40px + var(--sa-t)); } #app.touch-ui .lb-crest b { font-size: clamp(18px, 4vw, 27px); }

  /* MMO: dedicate the sides to movement and attacks, leaving the centre visible. */
  #app.touch-ui.mode-mmo #stage { width: 100vw; height: 100vh; height: 100dvh; }
  #app.touch-ui #hud.mmo #team { top: calc(6px + var(--sa-t)); left: calc(6px + var(--sa-l)); flex-direction: row; gap: 3px; }
  #app.touch-ui #hud.mmo #team .card { width: 46px; height: 44px; padding: 2px; justify-content: center; gap: 0; }
  #app.touch-ui #hud.mmo #team .card .nm { display: none; } #app.touch-ui #hud.mmo #team .card .hero-ico { width: 30px; height: 30px; }
  #app.touch-ui #hud.mmo #team .card .hp { position: absolute; left: 3px; right: 3px; bottom: 3px; height: 5px; margin: 0; }
  #app.touch-ui #mm-top { gap: 2px 5px; } #app.touch-ui #mm-mini { width: 84px; }
  #app.touch-ui #mm-top .mm-btns { max-width: min(42vw, 260px); } #app.touch-ui #chat { left: calc(126px + var(--sa-l)); right: auto; bottom: calc(8px + var(--sa-b)); width: min(30vw, 250px); max-width: calc(100vw - 290px); }
  #app.touch-ui #chat-log { height: clamp(40px, 12vh, 76px); }
  #app.touch-ui.mode-mmo #fr { top: calc(6px + var(--sa-t)); right: auto; left: 50%; transform: translateX(-50%); flex-direction: column; align-items: center; }

  /* A modal must fit the visible Safari viewport, not the page's desktop width. */
  #app.touch-ui #modal { padding: 0; place-items: stretch; }
  #app.touch-ui .m-card { width: 100%; height: 100dvh; max-height: 100dvh; clip-path: none; border-left: 0; border-right: 0; border-bottom: 0; padding-bottom: var(--sa-b); }
  #app.touch-ui .m-head { padding: 8px 10px; margin: 0; } #app.touch-ui .m-head b { font-size: 17px; }
  #app.touch-ui .m-body { padding: 8px 10px calc(16px + var(--sa-b)); margin: 0; overflow-x: hidden; overflow-wrap: anywhere; font-size: 15px; }
}

/* ---------------------------------------------------------------- fishing: the beach screen, the reel and the tackle shop */
.fish-hud { display: inline-flex; align-items: center; gap: 3px; }
.fish-hud small { font-size: 10px; line-height: 1; }
.fish-hud[hidden] { display: none !important; }
.fish-hud.near { animation: fishnudge 1.7s ease-in-out infinite; }
.fish-hud.busy { box-shadow: inset 0 0 0 2px #ffd45e, 0 0 10px rgba(255, 200, 60, .5); }
@keyframes fishnudge { 50% { box-shadow: inset 0 0 0 2px #8dffd0, 0 0 12px rgba(120, 255, 210, .55); } }

#fish { position: fixed; inset: 0; z-index: 26; display: grid; place-items: center; padding: max(8px, var(--sa-t)) max(8px, var(--sa-r)) max(8px, var(--sa-b)) max(8px, var(--sa-l)); background: radial-gradient(ellipse 80% 70% at 50% 40%, rgba(12, 44, 58, .5), rgba(3, 10, 16, .84)); backdrop-filter: blur(4px); }
#fish[hidden] { display: none; }
.fish-card { width: min(680px, 100%); max-height: 100%; display: flex; flex-direction: column; color: var(--cream); background: linear-gradient(#123044, #0a1a26 55%, #08131c); border: 3px solid var(--ink); box-shadow: 0 0 0 3px var(--brass-d), 0 0 0 5px var(--ink), 0 24px 60px rgba(0, 0, 0, .65); clip-path: var(--notch); animation: fishin .18s steps(3); }
@keyframes fishin { from { transform: translateY(14px) scale(.985); opacity: .35; } }
.fish-head { position: relative; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 7px 10px; background: linear-gradient(#2b4e60, #16303f); border-bottom: 2px solid var(--ink); box-shadow: inset 0 1px 0 #7fc0d8, inset 0 -6px 12px rgba(0, 0, 0, .3); }
.fish-who { display: flex; gap: 8px; align-items: center; min-width: 0; }
.fish-logo { width: 38px; height: 38px; flex: none; display: grid; place-items: center; font-size: 23px; background: #0a1e2a; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #5a9ab0; }
.fish-who b { display: block; font: 600 17px/1.15 "Kanit", sans-serif; color: #ffe9a8; text-shadow: 2px 2px 0 var(--ink); white-space: nowrap; }
.fish-who small { display: block; font-size: 11.5px; color: #a8d0e0; }
.fish-tabs { display: flex; gap: 3px; margin-left: 4px; }
.fish-tabs button { padding: 6px 9px; font: 600 12.5px/1 "Kanit", sans-serif; color: #bfe0ea; background: #0c2432; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #2a5a70; cursor: pointer; }
.fish-tabs button:hover { color: #fff; background: #143a4c; }
.fish-tabs button.on { color: #1a1006; background: linear-gradient(#ffe38a, #d8a02e); box-shadow: inset 0 0 0 1px #fff0b0, 0 0 8px rgba(255, 200, 60, .35); text-shadow: none; }
.fish-gold { margin-left: auto; padding: 5px 8px; font: 700 14px "Kanit", sans-serif; color: #ffe070; background: #071a24; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #4a7a8a; white-space: nowrap; }
.fish-x { width: 36px; height: 36px; display: grid; place-items: center; font-size: 18px; font-weight: 900; color: #d8f0f8; background: #12303e; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #4a7a8a; cursor: pointer; }
.fish-x:hover { background: #7a2020; }
.fish-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 10px 12px 12px; overscroll-behavior: contain; }
.fish-pane { position: relative; }
.fish-pane[hidden], .fish-reel[hidden], .fish-result[hidden], .fish-pop[hidden], .fish-pop-bite[hidden], .fish-fightbar[hidden] { display: none !important; }
/* the reel minigame pops up over the world when a fish takes the bait: one small card, so a phone's thumb still
   reaches the bar. Holding anywhere on the card lifts the green bar (#fish-pop.reeling). */
#fish-pop { position: fixed; inset: 0; z-index: 27; display: grid; place-items: center; padding: max(8px, var(--sa-t)) max(8px, var(--sa-r)) max(8px, var(--sa-b)) max(8px, var(--sa-l)); background: radial-gradient(ellipse 80% 70% at 50% 50%, rgba(4, 18, 28, .42), rgba(2, 8, 12, .74)); animation: fishpopin .14s steps(3); }
#fish-pop[hidden] { display: none; }
@keyframes fishpopin { from { opacity: 0; } }
.fish-pop-card { width: min(360px, 100%); max-height: 100%; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 6px; padding: 9px; background: linear-gradient(#14384a, #0a1a26); border: 2px solid var(--ink); box-shadow: 0 0 0 2px var(--brass-d), 0 0 0 4px var(--ink), 0 16px 40px rgba(0, 0, 0, .6); touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#fish-pop.reeling .fish-pop-card { touch-action: none; }
.fish-side { display: flex; flex-direction: column; gap: 5px; flex: none; }
.fish-pop-bite { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding: 6px 4px 10px; }
.fish-bite-ico { width: 56px; height: 56px; flex: none; display: grid; place-items: center; font-size: 34px; background: radial-gradient(circle at 32% 28%, #2a6a80, #06141c); border: 2px solid var(--fc, #5fd0dc); box-shadow: 0 0 14px rgba(95, 208, 220, .35); animation: fishbitejump .42s steps(2) infinite; }
@keyframes fishbitejump { 50% { transform: translateY(-4px) rotate(-6deg); } }
.fish-bite-tx { flex: 1 1 170px; min-width: 0; }
.fish-bite-tx b { display: block; font: 900 17px/1.2 "Kanit", sans-serif; color: #ffe070; text-shadow: 2px 2px 0 var(--ink); }
.fish-bite-tx small { display: block; font-size: 12px; color: #bfe8f0; }
.fish-bite-bar { display: block; width: 100%; height: 8px; margin-top: 2px; background: #06141c; border: 1px solid var(--ink); }
.fish-bite-bar s { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ffd45e, #ff6a5a); }
.fish-pop-card .fish-fightbar { margin-top: 0; }
.fish-pop-card .fish-reel { margin-top: 0; gap: 7px; justify-content: center; align-items: stretch; }
.fish-pop-card .fish-track { width: 104px; }
.fish-pop-card .fish-track, .fish-pop-card .fish-gauge { height: clamp(150px, 30vh, 240px); }
.fish-pop-card .fish-gauge { width: 22px; }
.fish-pop-card .fish-reelpanel { flex: 1 1 150px; min-width: 130px; gap: 6px; }
.fish-pop-card .fish-reelhelp { font-size: 12px; line-height: 1.45; }
.fish-pop-card .fish-holdbtn { flex: none; align-self: flex-start; min-height: 44px; padding: 4px 9px; gap: 7px; font-size: 13px; }
.fish-holdbtn kbd { color: #4a3520; font: inherit; font-size: 10px; border: 1px solid currentColor; border-radius: 3px; padding: 1px 3px; }
.fish-pop-card.hauling .fish-holdbtn { transform: translateY(1px); filter: brightness(1.12); }
.fish-pop-card .fish-track.running { border-color: #cf8555; }
.fish-pop-card .fish-bar.streak { box-shadow: inset 0 0 0 2px #fff0a4, 0 0 10px #ffe98c; }
.fish-pop-card :focus-visible { outline: 2px solid #ffea94; outline-offset: 2px; }
.fish-foot:empty { display: none; }
@media (pointer: coarse) { .fish-holdbtn kbd { display: none; } }
.fish-topgear { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 7px; }
.fish-chip { padding: 4px 8px; font-size: 12.5px; color: #c8e8f0; background: #0b202c; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #2a5a70; }
.fish-chip b { color: #ffe070; }
.fish-lvchip { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; }
.fish-mini { display: inline-block; width: 54px; height: 7px; background: #06141c; border: 1px solid #2a5a70; }
.fish-mini s { display: block; height: 100%; background: linear-gradient(90deg, #5fd0dc, #4aa3ff); }

.fish-fightbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; padding: 5px 9px; font-size: 13px; color: #e8f8ff; background: #0a2230; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #2a5a70; }
.fish-fightbar[hidden] { display: none !important; }
.fish-fightname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fish-fighttime { flex: none; color: #ffe070; font: 700 13px "Kanit", sans-serif; font-variant-numeric: tabular-nums; }
.fish-reel { display: flex; flex-wrap: wrap; gap: 9px; align-items: stretch; margin-top: 8px; }
.fish-track { position: relative; width: 116px; height: 280px; flex: none; overflow: hidden; background: linear-gradient(#0a2a3a, #051a26); border: 2px solid var(--ink); box-shadow: var(--bevel-in); touch-action: none; cursor: pointer; }
.fish-track::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 30% 20%, rgba(80, 190, 210, .18), transparent 55%), repeating-linear-gradient(0deg, transparent 0 28px, rgba(140, 220, 235, .05) 28px 30px); }
.fish-bar { position: absolute; left: 14%; right: 14%; height: 23%; top: 50%; background: linear-gradient(rgba(150, 255, 180, .45), rgba(40, 190, 110, .55)); border: 2px solid #8dffb0; box-shadow: 0 0 12px rgba(80, 255, 160, .45), inset 0 0 0 2px rgba(0, 0, 0, .2); }
.fish-target { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); font-size: 26px; line-height: 1; filter: drop-shadow(0 2px 0 #001018); pointer-events: none; }
.fish-target.on { filter: drop-shadow(0 0 7px #fff) drop-shadow(0 2px 0 #001018); }
.fish-gauge { position: relative; width: 26px; height: 280px; flex: none; background: #071822; border: 2px solid var(--ink); box-shadow: var(--bevel-in); }
.fish-gauge i { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: linear-gradient(#ffe870, #e0a020); box-shadow: 0 0 8px rgba(255, 212, 94, .65); }
.fish-progbox.low i { background: linear-gradient(#ff8a7a, #c03030); box-shadow: 0 0 8px rgba(255, 90, 70, .6); }
.fish-progbox.full i { background: linear-gradient(#c8ff9a, #40c060); }
.fish-gauge span { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-90deg); font: 700 9px/1 "Kanit", sans-serif; letter-spacing: 2px; color: #d8f4ff; white-space: nowrap; pointer-events: none; }
.fish-reelpanel { flex: 1 1 190px; min-width: 170px; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.fish-reelhelp { font-size: 13px; line-height: 1.55; color: #b8dce8; }
.fish-reelhelp b { color: #ffe070; }
.fish-fightlegend { display: flex; gap: 12px; flex-wrap: wrap; font: 600 12px "Kanit", sans-serif; color: #8dffb0; }
.fish-fightlegend .warn { color: #ff8a7a; }
.fish-result { display: flex; gap: 12px; align-items: center; margin: 9px 0; padding: 11px; background: linear-gradient(90deg, #123a4c, #0c2230); border: 2px solid #2a7a8a; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .07); }
.fish-result.perfect { border-color: #ffd45e; box-shadow: inset 0 0 0 2px rgba(255, 212, 94, .3), 0 0 18px rgba(255, 200, 60, .22); }
.fish-result.fail { border-color: #7a4a4a; background: linear-gradient(90deg, #2e1a20, #1a1016); }
.fish-result.rare { border-color: #ffd45e; background: linear-gradient(90deg, #2c1e4a, #141026); box-shadow: inset 0 0 0 2px rgba(255, 212, 94, .25), 0 0 22px rgba(178, 92, 255, .28); animation: fishrareglow 1.8s ease-in-out infinite; }
@keyframes fishrareglow { 50% { box-shadow: inset 0 0 0 2px rgba(255, 212, 94, .42), 0 0 34px rgba(178, 92, 255, .5); } }
.fish-bigico { position: relative; width: 82px; height: 82px; flex: none; display: grid; place-items: center; font-size: 50px; background: radial-gradient(circle at 30% 25%, #2a6a80, #081a24); border: 2px solid var(--fc, #5fd0dc); box-shadow: inset 0 0 18px rgba(0, 0, 0, .6); }
.fish-rarestar { position: absolute; right: -7px; top: -9px; font-size: 18px; color: #ffd45e; text-shadow: 0 0 8px #ffb020, 2px 2px 0 #000; animation: fishstar 1.3s ease-in-out infinite; }
@keyframes fishstar { 50% { transform: translateY(-2px) scale(1.18); } }
.fish-caught { min-width: 0; }
.fish-rarecase { margin-top: 6px; padding: 5px 6px; background: rgba(255, 212, 94, .06); border: 1px dashed rgba(255, 212, 94, .45); }
.fish-rarecase-h { display: block; margin-bottom: 4px; font: 700 10.5px "Kanit", sans-serif; letter-spacing: .4px; color: #ffe070; }
.fish-rare-slot { display: flex; align-items: center; gap: 7px; padding: 5px 7px; background: #0a1622; border: 1px solid var(--fc, #5fd0dc); box-shadow: inset 0 0 10px rgba(0, 0, 0, .5), 0 0 8px rgba(255, 212, 94, .16); }
.fish-rare-ico { width: 34px; height: 34px; flex: none; display: grid; place-items: center; font-size: 22px; background: radial-gradient(circle at 35% 30%, #243a50, #060e16); border: 1px solid var(--fc, #5fd0dc); }
.fish-rare-slot b { display: block; font-size: 13px; color: #ffe9a8; }
.fish-rare-slot small { display: block; font-size: 11px; color: #a8c8d4; }
.fish-failico { width: 58px; text-align: center; font-size: 40px; }
.fish-caught h3, .fish-result h3 { margin: 1px 0 4px; font: 600 19px/1.2 "Kanit", sans-serif; color: var(--fc, #ffe9a8); text-shadow: 2px 2px 0 var(--ink); }
.fish-caught p, .fish-result p { margin: 2px 0; font-size: 13.5px; }
.fish-rar { display: inline-block; margin-bottom: 2px; padding: 1px 7px; font: 700 11px "Kanit", sans-serif; color: #07131a; background: var(--fc, #b8bcc8); border: 1px solid var(--ink); }
.fish-new { display: inline-block; padding: 1px 6px; margin-left: 4px; font: 700 11px "Kanit", sans-serif; color: #2a1a00; background: var(--gold); border: 1px solid var(--ink); vertical-align: 2px; }
.fish-small { color: #a8c8d4; font-size: 12px !important; }
.fish-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.fish-main { flex: 1; justify-content: center; min-height: 42px; font-size: 16px; }
.fish-hook { flex: none; justify-content: center; min-width: 44px; min-height: 44px; font-size: 15px; animation: fishpulse .5s steps(2) infinite; }
@keyframes fishpulse { 50% { filter: brightness(1.35); } }
.fish-holdbtn { flex: 1; justify-content: center; min-height: 46px; touch-action: none; user-select: none; -webkit-user-select: none; }
.fish-foot { margin-top: 7px; font-size: 11.5px; color: #8fb8c8; }
.fish-foot b { color: #ffe070; }
.fish-lead { margin: 0 0 8px; font-size: 13.5px; color: #c0e0ea; }
.fish-h { display: flex; align-items: baseline; gap: 7px; margin: 12px 0 6px; font: 600 16px "Kanit", sans-serif; color: #ffe9a8; text-shadow: 2px 2px 0 var(--ink); }
.fish-h small { font: 400 12px "Sarabun", sans-serif; color: #8fb8c8; text-shadow: none; }
.fish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 8px; }
.fish-item { display: flex; flex-direction: column; gap: 6px; padding: 9px 10px; background: linear-gradient(#183a4a, #0d2230); border: 2px solid var(--ink); box-shadow: var(--bevel); }
.fish-item.on { box-shadow: inset 0 0 0 2px var(--gold), var(--bevel); }
.fish-item.owned { box-shadow: inset 0 0 0 2px #2a7a8a, var(--bevel); }
.fish-item.premium { box-shadow: inset 0 0 0 2px #b06a1a, var(--bevel); }
.fish-premium { padding: 0 4px; font: 700 9.5px "Kanit", sans-serif; color: #2a1a00; background: #ffd45e; border: 1px solid var(--ink); vertical-align: 2px; }
.fish-itemtop { display: flex; gap: 8px; align-items: flex-start; }
.fish-itemico { width: 42px; height: 42px; flex: none; display: grid; place-items: center; font-size: 24px; background: #071a24; border: 2px solid var(--ink); }
.fish-item b { font-size: 14.5px; text-shadow: 1px 1px 0 var(--ink); }
.fish-item small { display: block; color: #a8c8d4; font-size: 12.5px; line-height: 1.4; }
.fish-have { color: #ffe070; font-size: 12px; }
.fish-stats { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: #b8dce8; }
.fish-stats b { color: #8dffb0; }
.fish-buyrow { display: flex; gap: 6px; flex-wrap: wrap; }
.fish-item .btn { font-size: 13px; }
.fish-tip { margin: 10px 0 0; padding: 8px 10px; font-size: 12.5px; line-height: 1.5; color: #c8e0e8; background: rgba(80, 180, 200, .08); border-left: 3px solid #4ab0c8; }
.fish-loghead { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 10px; background: linear-gradient(90deg, #14384a, #0b202c); border: 2px solid var(--ink); }
.fish-levelbox { flex: 1; min-width: 190px; }
.fish-levelbox > span { font-size: 13.5px; }
.fish-xp { height: 12px; margin: 4px 0; background: #06141c; border: 2px solid var(--ink); }
.fish-xp i { display: block; height: 100%; background: linear-gradient(90deg, #5fd0dc, #4aa3ff); }
.fish-levelbox small { font-size: 11.5px; color: #a8c8d4; }
.fish-logstat { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: #b8dce8; }
.fish-logstat b { color: #ffe070; }
.fish-log { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.fish-logrow { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: #0f2632; border-left: 3px solid var(--fc, #39525e); }
.fish-logrow.unknown { opacity: .55; border-left-color: #39525e; }
.fish-logico { width: 36px; flex: none; text-align: center; font-size: 23px; }
.fish-logtx { flex: 1; min-width: 0; }
.fish-logtx b { font-size: 14px; }
.fish-logtx small { display: block; font-size: 12px; color: #a8c8d4; }
.fish-logtx small b { color: #ffe070; }
.fish-logrow .btn { font-size: 12.5px; padding: 5px 8px; }
.fish-sold { font-size: 12px; color: #6a8a96; }
.fish-case { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 5px; }
.fish-slot { position: relative; display: flex; flex-direction: column; gap: 1px; padding: 7px 8px; background: #0d2532; border: 1px solid var(--fc, #39525e); border-left: 3px solid var(--fc, #39525e); }
.fish-slot.locked { opacity: .45; border-style: dashed; }
.fish-slot.got { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06), 0 0 10px rgba(0, 0, 0, .3); }
.fish-slot.new { animation: fishnewslot 1.1s ease-in-out 3; }
@keyframes fishnewslot { 50% { box-shadow: 0 0 16px var(--fc, #ffd45e); } }
.fish-slotico { font-size: 22px; line-height: 1.15; }
.fish-slot b { font-size: 13px; }
.fish-slot small { font-size: 11px; color: #9fc0cc; }

@media (max-width: 700px), (max-height: 620px) {
  #fish { padding: 0; grid-template-rows: minmax(0, 1fr); }
  .fish-card { width: 100%; height: 100%; max-height: none; min-height: 0; clip-path: none; border-width: 0; }
  .fish-head { gap: 5px; padding: 5px 6px calc(5px + var(--sa-t)); }
  .fish-logo { width: 32px; height: 32px; font-size: 19px; }
  .fish-who b { font-size: 15px; }
  .fish-who small { display: none; }
  .fish-tabs { order: 5; width: 100%; margin-left: 0; }
  .fish-tabs button { flex: 1; padding: 8px 2px; font-size: 12px; }
  .fish-gold { margin-left: auto; padding: 4px 6px; font-size: 13px; }
  .fish-x { width: 34px; height: 34px; }
  .fish-body { padding: 7px 8px calc(10px + var(--sa-b)); }
  #fish-pop { place-items: end center; padding: 0; background: linear-gradient(rgba(2, 8, 12, 0), rgba(2, 8, 12, .55) 45%, rgba(2, 8, 12, .85)); }
  .fish-pop-card { width: min(360px, 100%); max-height: 80vh; gap: 5px; padding: 7px 8px calc(8px + var(--sa-b)); border-width: 2px 0 0; box-shadow: 0 -6px 26px rgba(0, 0, 0, .65); }
  .fish-pop-card .fish-fightbar { font-size: 12.5px; padding: 4px 7px; }
  .fish-pop-card .fish-track { width: 92px; }
  .fish-pop-card .fish-track, .fish-pop-card .fish-gauge { height: clamp(140px, 32vh, 260px); }
  .fish-pop-card .fish-pop-bite { padding: 4px 2px 7px; gap: 7px; }
  .fish-pop-card .fish-reelpanel { flex: 1 1 110px; min-width: 104px; flex-direction: column; justify-content: center; gap: 6px; }
  .fish-pop-card .fish-reelhelp { font-size: 11.5px; line-height: 1.4; }
  .fish-pop-card .fish-fightlegend { flex-direction: column; gap: 1px; font-size: 11.5px; }
  .fish-grid { grid-template-columns: 1fr; }
  .fish-case { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fish-result { flex-wrap: wrap; }
  .fish-bigico { width: 64px; height: 64px; font-size: 40px; }
  .fish-caught h3 { font-size: 17px; }
  .fish-logrow { flex-wrap: wrap; }
  .fish-logrow .btn { margin-left: 44px; }
  .fish-main { min-height: 46px; }
}
/* short screens (a phone held sideways): the reel has to fit without scrolling, so the long help text goes and the
   bar, the legend and the button stay — the whole card is the hold target anyway */
@media (max-height: 560px) {
  .fish-pop-card { max-height: 88vh; }
  .fish-pop-card .fish-reelhelp, .fish-pop-card .fish-foot { display: none; }
  .fish-pop-card .fish-track, .fish-pop-card .fish-gauge { height: clamp(112px, 27vh, 210px); }
  .fish-pop-card .fish-pop-bite { padding: 2px 2px 6px; }
  .fish-pop-card .fish-bite-ico { width: 44px; height: 44px; font-size: 26px; }
  .fish-pop-card .fish-result { padding: 7px; gap: 8px; }
  .fish-pop-card .fish-bigico { width: 54px; height: 54px; font-size: 34px; }
  .fish-pop-card .fish-caught h3 { font-size: 16px; }
  .fish-pop-card .fish-foot { margin-top: 3px; font-size: 11px; }
}
@media (pointer: coarse) {
  .fish-tabs button { min-height: 40px; }
  .fish-item .btn { min-height: 38px; }
}
@media (prefers-reduced-motion: reduce) {
  .fish-card, .fish-bite-ico, .fish-hook, .fish-hud.near, .fish-result.rare, .fish-rarestar, .fish-slot.new, #fish-pop, .fish-pop-card { animation: none !important; }
}

/* ---------------------------------------------------------------- fishing: the book scrolls on every screen, painted fish */
#fish { grid-template-rows: minmax(0, 1fr); }
.fish-card { min-height: 0; max-height: 100%; position: relative; }
.fish-body { -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.fpic { position: relative; display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; line-height: 1; vertical-align: middle; }
.fpic img { position: absolute; inset: -12%; width: 124%; height: 124%; object-fit: contain; image-rendering: auto; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .55)); opacity: 0; transition: opacity .15s; }
.fpic.ok img { opacity: 1; }
.fpic.ok i { visibility: hidden; }
.fpic i { font-style: normal; }
.fpic.shadow img { filter: brightness(0) drop-shadow(0 0 1px rgba(140, 200, 220, .6)); opacity: .0; }
.fpic.shadow.ok img { opacity: .75; }
.fpic.shadow i { filter: brightness(0); }
.fish-logico .fpic, .fish-slotico .fpic { width: 40px; height: 40px; font-size: 22px; }
.fish-logico { width: 44px; }
.fish-logrow[data-fsh="info"], .fish-slot[data-fsh="info"] { cursor: pointer; }
.fish-logrow[data-fsh="info"]:hover, .fish-slot[data-fsh="info"]:hover { background: #143546; }
.fish-bigico .fpic { width: 1.5em; height: 1.5em; }
.fish-bite-ico .fpic { width: 46px; height: 46px; font-size: 30px; }
.fish-target .fpic.sm { width: 34px; height: 34px; font-size: 24px; }
.fish-rare-ico .fpic { width: 30px; height: 30px; }
.fish-desc { margin: 3px 0; font-size: 12.5px; color: #cfe8f0; font-style: italic; line-height: 1.45; }
.fish-info { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 12px; background: rgba(2, 10, 16, .78); backdrop-filter: blur(2px); animation: fishpopin .14s steps(3); }
.fish-info[hidden] { display: none; }
.fish-infocard { position: relative; width: min(380px, 100%); max-height: 100%; overflow: auto; overscroll-behavior: contain; padding: 14px 14px 12px; text-align: center; background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--fc) 28%, #12303f), #0a1a26 70%); border: 2px solid var(--ink); box-shadow: 0 0 0 2px var(--fc), 0 0 0 4px var(--ink), 0 0 34px color-mix(in srgb, var(--fc) 45%, transparent); }
.fish-infocard .fish-x { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; }
.fish-infoart { display: grid; place-items: center; height: 150px; margin: 2px auto 4px; }
.fish-infoart .fpic { width: 150px; height: 150px; font-size: 90px; }
.fish-infoart .fpic img { inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 0 14px color-mix(in srgb, var(--fc) 60%, transparent)) drop-shadow(0 3px 0 rgba(0, 0, 0, .6)); }
.fish-infoart.locked .fpic img { filter: brightness(0) drop-shadow(0 0 2px rgba(160, 220, 240, .7)); }
.fish-infocard h3 { margin: 2px 0 4px; font: 700 20px/1.2 "Kanit", sans-serif; color: #fff2c0; text-shadow: 2px 2px 0 var(--ink); }
.fish-infogrid { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin-top: 8px; padding: 8px 10px; text-align: left; font-size: 12.5px; background: rgba(0, 0, 0, .28); border: 1px solid rgba(255, 255, 255, .08); }
.fish-infogrid span { color: #9fc0cc; }
.fish-infogrid b { color: #ffe9a8; font-weight: 600; }

/* ---------------------------------------------------------------- pets: the wheel of fortune and the collection */
.ovl-pop { position: fixed; inset: 0; z-index: 28; display: grid; grid-template-rows: minmax(0, 1fr); place-items: center; padding: max(8px, var(--sa-t)) max(8px, var(--sa-r)) max(8px, var(--sa-b)) max(8px, var(--sa-l)); background: radial-gradient(ellipse 80% 70% at 50% 40%, rgba(40, 18, 70, .55), rgba(4, 4, 12, .9)); animation: ovlin .2s ease-out both; }
.ovl-pop[hidden] { display: none; }
@keyframes ovlin { from { opacity: 0; } }
@keyframes cardin { from { transform: translateY(16px) scale(.96); opacity: 0; } 60% { opacity: 1; } to { transform: none; opacity: 1; } }
.pet-card { position: relative; width: min(860px, 100%); max-height: 100%; min-height: 0; display: flex; flex-direction: column; color: var(--cream); background: radial-gradient(ellipse at 30% 0%, #2a1a4a, #120c22 55%, #0a0814); border: 3px solid var(--ink); box-shadow: 0 0 0 3px #a07cff, 0 0 0 5px var(--ink), 0 0 60px rgba(160, 110, 255, .35), 0 24px 60px rgba(0, 0, 0, .7); clip-path: var(--notch); animation: cardin .26s cubic-bezier(.2, .9, .3, 1.08) both; will-change: transform, opacity; }
.pet-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 7px 10px; background: linear-gradient(#3a2860, #1c1232); border-bottom: 2px solid var(--ink); box-shadow: inset 0 1px 0 #b89cff; }
.pet-who { display: flex; gap: 8px; align-items: center; min-width: 0; }
.pet-logo { width: 38px; height: 38px; display: grid; place-items: center; font-size: 22px; background: #160e2a; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #8a6acc; }
.pet-who b { display: block; font: 600 17px/1.15 "Kanit", sans-serif; color: #ffe9a8; text-shadow: 2px 2px 0 var(--ink); }
.pet-who small { display: block; font-size: 11.5px; color: #cbb8f0; }
.pet-tabs { display: flex; gap: 3px; }
.pet-tabs button { padding: 6px 10px; font: 600 12.5px/1 "Kanit", sans-serif; color: #d8c8ff; background: #1a1030; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #4a3480; cursor: pointer; }
.pet-tabs button.on { color: #1a1006; background: linear-gradient(#ffe38a, #d8a02e); box-shadow: inset 0 0 0 1px #fff0b0, 0 0 8px rgba(255, 200, 60, .35); }
.pet-wallet { margin-left: auto; display: flex; gap: 6px; }
.pet-wallet > span { padding: 5px 8px; font: 700 13.5px "Kanit", sans-serif; color: #ffe070; background: #0e0a1c; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #5a4490; white-space: nowrap; }
.pet-x { width: 36px; height: 36px; display: grid; place-items: center; font-size: 18px; font-weight: 900; color: #eee; background: #2a1a44; border: 2px solid var(--ink); cursor: pointer; }
.pet-x:hover { background: #7a2020; }
.pet-body { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 12px; }
.pet-wheelpane { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
.pet-wheelwrap { position: relative; width: min(400px, 86vw, 62vh); aspect-ratio: 1; flex: none; }
.pet-rays { position: absolute; inset: -9%; border-radius: 50%; background: repeating-conic-gradient(rgba(255, 220, 140, .14) 0 6deg, transparent 6deg 18deg); animation: petspin 24s linear infinite; mask: radial-gradient(circle, #000 52%, transparent 70%); -webkit-mask: radial-gradient(circle, #000 52%, transparent 70%); }
#pets.spinning .pet-rays { animation-duration: 3s; }
@keyframes petspin { to { transform: rotate(360deg); } }
.pet-wheel { position: absolute; inset: 0; border-radius: 50%; border: 5px solid #ffd45e; box-shadow: 0 0 0 4px var(--ink), 0 0 0 7px #7a4ad8, 0 0 40px rgba(255, 200, 90, .45), inset 0 0 50px rgba(0, 0, 0, .7); }
.pet-slot { position: absolute; inset: 0; transform: rotate(var(--a)); pointer-events: none; }
.pet-slotin { position: absolute; left: 50%; top: 3%; width: 23%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.pet-slotin img { width: 100%; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 0 6px var(--rc)) drop-shadow(0 2px 0 #000); }
.pet-slotin img.dim { filter: saturate(.6) brightness(.82) drop-shadow(0 2px 0 #000); }
.pet-slotin i { font: 700 9px/1 "Kanit", sans-serif; font-style: normal; color: var(--rc); text-shadow: 1px 1px 0 #000; white-space: nowrap; }
.pet-hub { position: absolute; left: 50%; top: 50%; width: 20%; aspect-ratio: 1; transform: translate(-50%, -50%); display: grid; place-items: center; font-size: clamp(18px, 4vw, 30px); border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff0a0, #d8902a 60%, #7a4a10); border: 3px solid var(--ink); box-shadow: 0 0 20px rgba(255, 210, 90, .7); }
.pet-pointer { position: absolute; left: 50%; top: -3%; z-index: 2; width: 0; height: 0; transform: translateX(-50%); border-left: 16px solid transparent; border-right: 16px solid transparent; border-top: 30px solid #ff4d6d; filter: drop-shadow(0 0 8px #ff4d6d) drop-shadow(0 3px 0 var(--ink)); }
#pets.spinning .pet-pointer { animation: petpoint .14s steps(2) infinite; }
@keyframes petpoint { 50% { transform: translateX(-50%) rotate(-12deg); } }
.pet-side { flex: 1 1 280px; min-width: 0; max-width: 380px; display: flex; flex-direction: column; gap: 9px; }
.pet-none { padding: 12px; text-align: center; color: #cbb8f0; background: rgba(0, 0, 0, .3); border: 1px dashed #5a4490; }
.pet-actcard { display: flex; gap: 10px; align-items: center; padding: 8px; background: linear-gradient(90deg, color-mix(in srgb, var(--rc) 22%, #160e2a), #0e0a1c); border: 2px solid var(--ink); box-shadow: 0 0 0 1px var(--rc), 0 0 14px color-mix(in srgb, var(--rc) 35%, transparent); }
.pet-actcard .pet-img { width: 70px; height: 70px; flex: none; }
.pet-actcard small { color: #cbb8f0; font-size: 11px; }
.pet-actcard b { display: block; font: 600 15px "Kanit", sans-serif; color: #fff2c0; }
.pet-img { object-fit: contain; filter: drop-shadow(0 0 8px var(--rc, #fff)) drop-shadow(0 2px 0 rgba(0, 0, 0, .6)); }
.pet-img.shadow { filter: brightness(0) drop-shadow(0 0 2px rgba(200, 180, 255, .7)); opacity: .8; }
.pet-stars { color: #ffd45e; font-size: 13px; letter-spacing: 1px; text-shadow: 0 0 6px rgba(255, 210, 90, .6); }
.pet-stars s { text-decoration: none; color: #3a3050; text-shadow: none; }
.pet-buffs { display: flex; flex-wrap: wrap; gap: 3px 8px; font-size: 11.5px; color: #cbb8f0; }
.pet-buffs b { color: #7affb0; }
.pet-buffs.big { justify-content: center; font-size: 13px; margin: 6px 0; }
.pet-odds { display: flex; flex-wrap: wrap; gap: 4px 10px; padding: 7px 9px; font-size: 12px; background: rgba(0, 0, 0, .3); border: 1px solid rgba(255, 255, 255, .08); }
.pet-odds > b { width: 100%; color: #ffe9a8; }
.pet-odds span { display: inline-flex; align-items: center; gap: 4px; color: #ddd; }
.pet-odds span i { width: 9px; height: 9px; background: var(--rc); box-shadow: 0 0 6px var(--rc); }
.pet-pity { font-size: 12px; color: #cbb8f0; }
.pet-pity i { display: block; height: 7px; margin-top: 3px; background: #0e0a1c; border: 1px solid var(--ink); }
.pet-pity s { display: block; height: 100%; background: linear-gradient(90deg, #b25cff, #ffa02e); }
.pet-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pet-spin { flex: 1 1 140px; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; font: 700 15px "Kanit", sans-serif; }
.pet-spin small { font-size: 11px; font-weight: 600; opacity: .9; }
.pet-spin.ten { background: linear-gradient(#c084ff, #7a3ad8); color: #fff; }
.pet-tip { margin: 0; font-size: 11.5px; color: #a898c8; line-height: 1.45; }
.pet-lead { margin: 0 0 8px; font-size: 13px; color: #cbb8f0; }
.pet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.pet-cell { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; color: var(--cream); background: radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--rc) 25%, #1a1030), #0e0a1c 70%); border: 2px solid var(--ink); box-shadow: 0 0 0 1px color-mix(in srgb, var(--rc) 60%, transparent); cursor: pointer; font: inherit; }
.pet-cell:hover { transform: translateY(-2px); box-shadow: 0 0 0 2px var(--rc), 0 0 16px color-mix(in srgb, var(--rc) 45%, transparent); }
.pet-cell.on { box-shadow: 0 0 0 2px #7affb0, 0 0 18px rgba(120, 255, 180, .45); }
.pet-cell .pet-img { width: 96px; height: 96px; }
.pet-cell i { font: 700 10.5px "Kanit", sans-serif; font-style: normal; color: var(--rc); }
.pet-cell b { font: 600 13px "Kanit", sans-serif; text-align: center; }
.pet-cell small { font-size: 11px; color: #887aa8; }
.pet-cell em { position: absolute; top: 4px; right: 4px; padding: 1px 5px; font: 700 10px "Kanit", sans-serif; font-style: normal; color: #062010; background: #7affb0; }
.pet-cell.locked { filter: saturate(.4); }
.pet-pop { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 12px; overflow: auto; background: rgba(4, 2, 10, .82); backdrop-filter: blur(3px); animation: fishpopin .18s steps(3); }
.pet-pop[hidden] { display: none; }
.pet-reveal { width: min(640px, 100%); text-align: center; }
.pet-reveal h3 { margin: 4px 0; font: 700 21px/1.2 "Kanit", sans-serif; color: #fff2c0; text-shadow: 2px 2px 0 var(--ink); }
.pet-rar { display: block; font: 700 13px "Kanit", sans-serif; font-style: normal; }
.pet-desc { margin: 4px auto; max-width: 440px; font-size: 13px; font-style: italic; color: #d8ccf4; line-height: 1.5; }
.pet-gotgrid { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.pet-got { position: relative; display: flex; flex-direction: column; align-items: center; animation: petgot .5s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: var(--d, 0s); }
@keyframes petgot { from { transform: scale(.2) rotate(-14deg); opacity: 0; } }
.pet-got .pet-img { position: relative; z-index: 1; width: 200px; height: 200px; filter: drop-shadow(0 0 18px var(--rc)) drop-shadow(0 3px 0 #000); }
.multi .pet-got .pet-img { width: 92px; height: 92px; }
.multi .pet-got { width: 112px; }
.pet-burst { position: absolute; left: 50%; top: 45%; width: 150%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--rc) 70%, #fff) 0 8%, color-mix(in srgb, var(--rc) 45%, transparent) 25%, transparent 62%), repeating-conic-gradient(color-mix(in srgb, var(--rc) 55%, transparent) 0 8deg, transparent 8deg 22deg); mask: radial-gradient(circle, #000 30%, transparent 68%); -webkit-mask: radial-gradient(circle, #000 30%, transparent 68%); animation: petburst 9s linear infinite; }
@keyframes petburst { to { transform: translate(-50%, -50%) rotate(360deg); } }
.pet-got.r0 .pet-burst, .pet-got.r1 .pet-burst { opacity: .55; }
.pet-got.r3 .pet-burst { animation-duration: 5s; width: 190%; }
.pet-got.r4 .pet-burst { animation: petburst 3.5s linear infinite, pethue 2s linear infinite; width: 220%; }
@keyframes pethue { to { filter: hue-rotate(360deg); } }
/* the burst spins behind the pet only: everything written under it sits on top, on a dark plate so it stays readable */
.pet-reveal > :not(.pet-got):not(.pet-gotgrid) { position: relative; z-index: 2; }
.pet-reveal .pet-desc, .pet-reveal .pet-buffs, .pet-reveal .pet-tip, .pet-reveal .pet-skill { background: rgba(8, 4, 18, .78); border-radius: 6px; padding: 4px 10px; width: fit-content; max-width: min(520px, 100%); margin-left: auto; margin-right: auto; box-shadow: 0 0 0 1px rgba(255, 255, 255, .06); }
.pet-reveal h3, .pet-reveal .pet-rar { text-shadow: 2px 2px 0 var(--ink), 0 0 8px #000, 0 0 14px #000; }
.pet-reveal.info .pet-got .pet-burst { width: 130%; top: 50%; }
.pet-reveal.info .pet-got.r3 .pet-burst, .pet-reveal.info .pet-got.r4 .pet-burst { width: 150%; }
.pet-gotx { position: relative; z-index: 2; }
.pet-reveal.info .pet-got .pet-img { width: 170px; height: 170px; }
.pet-pop.top4 { background: radial-gradient(circle at 50% 40%, rgba(255, 60, 120, .35), rgba(4, 2, 10, .9) 60%); }
.pet-pop.top3 { background: radial-gradient(circle at 50% 40%, rgba(255, 160, 46, .3), rgba(4, 2, 10, .88) 60%); }
.pet-gotx { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; }
.pet-gotx i { font: 700 11px "Kanit", sans-serif; font-style: normal; color: var(--rc); text-shadow: 1px 1px 0 #000; }
.pet-gotx b { font: 600 14px "Kanit", sans-serif; color: #fff2c0; text-shadow: 1px 1px 0 #000; }
.pet-gotx em { font: 700 11px "Kanit", sans-serif; font-style: normal; color: #ffd45e; }
.pet-gotx em.pet-new { color: #062010; background: #7affb0; padding: 0 5px; }
@media (max-width: 700px), (max-height: 620px) {
  .ovl-pop { padding: 0; }
  .pet-card, .coop-card { width: 100%; height: 100%; clip-path: none; border-width: 0; }
  .pet-who small { display: none; }
  .pet-tabs { order: 5; width: 100%; } .pet-tabs button { flex: 1; padding: 8px 2px; }
  .pet-wheelwrap { width: min(330px, 78vw, 52vh); }
  .pet-got .pet-img { width: 150px; height: 150px; }
  .pet-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .pet-cell .pet-img { width: 72px; height: 72px; }
}
@media (prefers-reduced-motion: reduce) { .pet-rays, .pet-burst, .pet-got, .pet-card, .ovl-pop { animation: none !important; } }

/* ---------------------------------------------------------------- co-op: party popup, invite card, arena strip, end card */
.lb-emo { grid-row: span 2; font-style: normal; font-size: 22px; width: 32px; text-align: center; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .5)); }
/* the name stays on one line (สัตว์เลี้ยง / Co-op); only the subtitle may wrap */
.lb-btn.pets, .lb-btn.coop { white-space: nowrap; } .lb-btn.pets small, .lb-btn.coop small { white-space: normal; }
.lb-btn.pets { background: linear-gradient(135deg, #3a1e6a, #7a3ad8); box-shadow: inset 2px 2px 0 #c89aff, inset -2px -2px 0 #1e0e3a; color: #f4eaff; }
.lb-btn.coop { background: linear-gradient(135deg, #6a1e1e, #c8401a); box-shadow: inset 2px 2px 0 #ffa07a, inset -2px -2px 0 #3a0e0e; color: #fff0ea; }
.coop-card { width: min(980px, 100%); box-shadow: 0 0 0 3px #ff7a3a, 0 0 0 5px var(--ink), 0 0 60px rgba(255, 90, 40, .3), 0 24px 60px rgba(0, 0, 0, .7); background: radial-gradient(ellipse at 20% 0%, #4a1a14, #1a0c0c 55%, #0c0808); }
.coop-head { background: linear-gradient(#5a2418, #2a100c); box-shadow: inset 0 1px 0 #ff9a6a; }
.coop-head .pet-x { margin-left: auto; }
.coop-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 760px) { .coop-grid { grid-template-columns: 1fr; } }
.coop-mode { display: flex; gap: 12px; align-items: flex-start; padding: 10px; background: rgba(0, 0, 0, .32); border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px rgba(255, 140, 80, .25); }
.coop-mode h3 { margin: 2px 0 4px; font: 700 19px/1.2 "Kanit", sans-serif; color: #ffe0b0; text-shadow: 2px 2px 0 var(--ink); }
.coop-mode p { margin: 4px 0; font-size: 13px; line-height: 1.5; color: #f0d8cc; }
.coop-mode .red { color: #ff5a4a; }
.coop-portrait { width: 132px; height: 132px; flex: none; object-fit: contain; filter: drop-shadow(0 0 18px rgba(255, 80, 20, .7)); animation: coopbreath 3s ease-in-out infinite; }
@keyframes coopbreath { 50% { transform: scale(1.04); filter: drop-shadow(0 0 28px rgba(255, 60, 20, .9)); } }
.coop-tag { display: inline-block; padding: 1px 6px; font: 700 11px "Kanit", sans-serif; font-style: normal; color: #1a0806; background: linear-gradient(#ffb070, #e0602a); }
.coop-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 5px 0; }
.coop-chips > span:not(.dim) { padding: 2px 6px; font-size: 11.5px; color: #ffd8c0; background: #2a1210; border: 1px solid #6a3020; }
.coop-chips .chip.on { color: #1a1006; background: linear-gradient(#ffe38a, #d8a02e); }
.coop-chips .chip { border-left: 3px solid var(--cc, #888); }
.coop-party { display: flex; flex-direction: column; gap: 7px; padding: 10px; background: rgba(0, 0, 0, .32); border: 2px solid var(--ink); }
.coop-party h4 { margin: 4px 0 0; font: 600 13px "Kanit", sans-serif; color: #ffd8b0; display: flex; align-items: center; gap: 6px; }
.coop-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.coop-row.end { justify-content: space-between; margin-top: 4px; }
.coop-row input { flex: 1 1 120px; min-width: 0; padding: 8px; font: 600 14px "Kanit", sans-serif; color: #fff; background: #120808; border: 2px solid var(--ink); box-shadow: inset 0 0 0 1px #6a3020; text-transform: none; }
#coop-code { text-transform: uppercase; letter-spacing: 3px; }
.coop-code { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 6px 9px; background: linear-gradient(90deg, #3a1610, #1a0a08); border: 2px solid var(--ink); }
.coop-code span { font-size: 12px; color: #d8b0a0; }
.coop-code b { font: 800 24px/1 "Kanit", sans-serif; letter-spacing: 5px; color: #ffe070; text-shadow: 0 0 10px rgba(255, 200, 80, .6), 2px 2px 0 var(--ink); }
.coop-code small { color: #d8b0a0; }
.coop-code em { margin-left: auto; font: 700 11px "Kanit", sans-serif; font-style: normal; color: #062010; background: #7affb0; padding: 1px 6px; }
.coop-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.coop-slot { display: flex; flex-direction: column; padding: 6px 8px; min-height: 52px; background: linear-gradient(90deg, color-mix(in srgb, var(--cc, #444) 25%, #1a0c0a), #120808); border: 2px solid var(--ink); border-left: 4px solid var(--cc, #444); }
.coop-slot b { font: 600 13.5px "Kanit", sans-serif; color: #fff2d8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coop-slot span { font-size: 12px; color: #f0d0c0; }
.coop-slot small { font-size: 11px; color: #c8a090; }
.coop-slot.me { box-shadow: 0 0 0 1px #7affb0; }
.coop-slot.empty { align-items: center; justify-content: center; opacity: .5; border-style: dashed; border-left-width: 2px; }
.coop-go { min-width: 150px; min-height: 44px; font: 800 15px "Kanit", sans-serif; background: linear-gradient(#ff9a4a, #d8401a); color: #fff; animation: coopgo 1.4s ease-in-out infinite; }
.coop-go:disabled { animation: none; }
@keyframes coopgo { 50% { box-shadow: 0 0 18px rgba(255, 120, 40, .8); } }
.coop-rankme { flex: none; display: flex; flex-direction: column; align-items: center; min-width: 120px; padding: 10px 8px; text-align: center; background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--tc) 35%, #1a0c0a), #0c0606 75%); border: 2px solid var(--ink); box-shadow: 0 0 0 2px var(--tc), 0 0 22px color-mix(in srgb, var(--tc) 45%, transparent); }
.coop-rankme i { font-size: 11px; font-style: normal; color: #d8b0a0; }
.coop-rankme b { font: 800 22px/1.2 "Kanit", sans-serif; color: var(--tc); text-shadow: 0 0 10px color-mix(in srgb, var(--tc) 60%, transparent), 2px 2px 0 var(--ink); }
.coop-rankme em { font: 700 13px "Kanit", sans-serif; font-style: normal; color: #ffe9a8; }
.coop-rankme small { font-size: 11px; color: #c8a090; }
.coop-board { margin: 6px 0 0; padding: 0; list-style: none; max-height: 190px; overflow: auto; font-size: 12.5px; }
.coop-board li { display: grid; grid-template-columns: 24px 1fr auto auto; gap: 6px; padding: 3px 6px; background: rgba(255, 255, 255, .03); }
.coop-board li:nth-child(odd) { background: rgba(255, 255, 255, .06); }
.coop-board li b { color: #ffd45e; } .coop-board li i { font-style: normal; } .coop-board li em { font-style: normal; color: #ffe9a8; }
.coop-mode.rank { align-items: stretch; }
.coop-inv { position: fixed; z-index: 40; left: 50%; top: max(12px, var(--sa-t)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; max-width: calc(100% - 24px); padding: 10px 12px; font-size: 14px; color: #fff0e0; background: linear-gradient(#5a2418, #2a100c); border: 2px solid var(--ink); box-shadow: 0 0 0 2px #ff7a3a, 0 10px 30px rgba(0, 0, 0, .6), 0 0 24px rgba(255, 110, 40, .45); animation: coopinv .3s cubic-bezier(.2, 1.6, .4, 1); }
.coop-inv[hidden] { display: none; }
.coop-inv span { display: flex; gap: 6px; }
@keyframes coopinv { from { transform: translate(-50%, -30px); opacity: 0; } }
.coop-hud { position: fixed; z-index: 15; left: 50%; top: calc(max(8px, var(--sa-t)) + 58px); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 5px 12px; font: 700 14px "Kanit", sans-serif; color: #fff0e0; background: rgba(30, 8, 6, .82); border: 2px solid var(--ink); box-shadow: 0 0 0 1px #ff7a3a, 0 0 18px rgba(255, 80, 30, .35); pointer-events: none; }
.coop-hud[hidden] { display: none; }
.coop-hud .red { color: #ff5a4a; animation: coopgo .6s steps(2) infinite; }
.coop-hud small { color: #d8b0a0; font-weight: 600; }
.coop-mtag { color: #ffd45e; }
.coop-count { font: 900 34px/1 "Kanit", sans-serif; color: #ffe070; text-shadow: 0 0 14px rgba(255, 140, 40, .9), 2px 2px 0 var(--ink); }
.coop-bhp { position: relative; display: block; width: 160px; height: 12px; background: #200806; border: 1px solid var(--ink); }
.coop-bhp s { display: block; height: 100%; background: linear-gradient(90deg, #ff3a1a, #ffb040); box-shadow: 0 0 8px rgba(255, 90, 30, .7); }
.coop-bhp em { position: absolute; inset: 0; display: grid; place-items: center; font: 700 9px "Kanit", sans-serif; font-style: normal; color: #fff; text-shadow: 1px 1px 0 #000; }
.coop-end { z-index: 41; }
.coop-endcard { width: min(440px, 100%); padding: 18px 16px 14px; text-align: center; color: #fff0e0; background: radial-gradient(ellipse at 50% 0%, #4a1a14, #140808 70%); border: 3px solid var(--ink); box-shadow: 0 0 0 3px #ffb040, 0 0 50px rgba(255, 140, 40, .45); animation: petgot .5s cubic-bezier(.2, 1.6, .4, 1); }
.coop-endcard.lose { box-shadow: 0 0 0 3px #6a6a7a, 0 0 30px rgba(0, 0, 0, .6); filter: saturate(.7); }
.coop-endcard h2 { margin: 4px 0; font: 800 26px/1.2 "Kanit", sans-serif; color: #ffe070; text-shadow: 0 0 16px rgba(255, 160, 40, .7), 3px 3px 0 var(--ink); }
.coop-endcard .coop-portrait { width: 110px; height: 110px; }
.coop-endcard .coop-rankme { margin: 8px auto; width: max-content; }
.coop-rew { display: flex; justify-content: center; gap: 14px; margin: 8px 0; font: 800 20px "Kanit", sans-serif; color: #ffe070; }
.fish-diff { color: #ffb040; letter-spacing: 1px; } .fish-diff s { text-decoration: none; color: #2a4450; }
.mtag-title { display: block; font: 700 9.5px/1.1 "Kanit", sans-serif; font-style: normal; color: #ffd45e; text-shadow: 0 0 6px rgba(255, 180, 60, .7), 1px 1px 0 #000; white-space: nowrap; }
.pet-skill { margin-top: 5px; padding: 5px 7px; font-size: 11.5px; color: #e8dcff; background: rgba(120, 80, 220, .18); border-left: 3px solid #b28cff; line-height: 1.4; text-align: left; } .pet-skill b { color: #ffe9a8; } .pet-skill small { color: #a898c8; }
.pet-skillbtn { position: absolute; z-index: 1; width: 48px; height: 48px; padding: 0; border-radius: 8px; background: radial-gradient(circle at 40% 35%, #392852, #100c20 74%); border: 1px solid var(--rc, #b28cff); box-shadow: inset 0 0 0 2px #090710, 0 2px 5px #000a; cursor: pointer; overflow: hidden; pointer-events: auto; }
.pet-skillbtn[hidden] { display: none; } .pet-skillbtn img { position: absolute; inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); object-fit: contain; filter: drop-shadow(0 0 4px var(--rc)); }
.pet-skillbtn i { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(rgba(0,0,0,.68) calc(var(--cd, 0) * 360deg), transparent 0); }
.pet-skillbtn b { position: absolute; inset: 0; display: grid; place-items: center; font: 800 18px "Kanit", sans-serif; color: #fff; text-shadow: 2px 2px 0 #000; }
.pet-skillbtn kbd { position: absolute; left: 4px; top: 2px; font: 700 12px "Kanit", sans-serif; color: #ffe9a8; text-shadow: 1px 1px 0 #000; }
.pet-skillbtn.ready { animation: petready 1.2s ease-in-out infinite; } @keyframes petready { 50% { box-shadow: inset 0 0 0 2px #090710, 0 0 9px var(--rc); } }
@media (pointer: coarse) { .pet-skillbtn kbd { display: none; } }
.coop-h { margin: 8px 0 2px; font: 600 13px "Kanit", sans-serif; color: #ffd8b0; }
.coop-ttl { display: block; font-size: 10px; color: #ffd45e; }
.coop-mode.boss .coop-portrait { filter: drop-shadow(0 0 18px var(--bc, #ff5a1a)); }
.coop-dm { display: flex; flex-direction: column; gap: 1px; min-width: 150px; }
.coop-dm i { position: relative; display: flex; justify-content: space-between; gap: 6px; padding: 0 4px; font: 600 10.5px/1.5 "Kanit", sans-serif; font-style: normal; background: linear-gradient(90deg, rgba(255, 110, 40, .45) var(--w), rgba(0, 0, 0, .35) var(--w)); }
.coop-dm b { font-weight: 600; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .coop-dm em { font-style: normal; color: #ffe9a8; }
.coop-hud { flex-wrap: wrap; justify-content: center; max-width: calc(100% - 24px); }
.coop-board li.dim { display: block; }
.coop-mode.dun { flex-direction: column; }
.coop-dunmap { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; font: 600 11.5px "Kanit", sans-serif; }
.coop-dunmap span { padding: 4px 7px; background: #2a1414; border: 1px solid #6a3020; color: #ffd8c0; }
.coop-dunmap span.r2 { border-color: #ff4a3a; color: #ff9a8a; } .coop-dunmap span.r4 { border-color: #c07aff; color: #e0c8ff; box-shadow: 0 0 10px rgba(180, 100, 255, .4); }
.coop-dunmap i { color: #a07060; font-style: normal; }
.fr-row button.party { color: #ffd8b0; }
.pet-body { overflow-x: hidden; }
.pet-wheelwrap { overflow: visible; contain: layout; }
@media (max-height: 520px), (max-width: 420px) { .pet-slotin i { display: none; } .pet-slotin { width: 21%; top: 4%; } }
@media (max-height: 520px) { .pet-wheelpane { flex-wrap: nowrap; } .pet-side { max-width: none; } .pet-spin { min-height: 44px; } }

/* the server-wide boss (co-op popup) and the party frame in the MMO */
.coop-gb { margin: 10px 0; padding: 8px 10px; background: rgba(20, 6, 6, .7); border: 2px solid #ff7a3a; box-shadow: 0 0 14px rgba(255, 110, 40, .25); }
.coop-gb.down { border-color: #6dffa0; box-shadow: 0 0 14px rgba(110, 255, 160, .25); }
.coop-gbh { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.coop-gbh small { color: var(--dim); }
.coop-gbbar { position: relative; display: block; height: 18px; margin: 6px 0; background: #1a0808; border: 2px solid var(--ink); }
.coop-gbbar s { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#ff5a3a, #a01818); transition: width .6s; }
.coop-gb.down .coop-gbbar s { background: #2a2a2a; }
.coop-gbbar em { position: absolute; inset: 0; display: grid; place-items: center; font: 700 11px "Kanit", sans-serif; font-style: normal; color: #fff; text-shadow: 1px 1px 0 #000; }
.coop-gb p { margin: 4px 0; font-size: 12.5px; }
.coop-hint { margin: 6px 0; padding: 6px 8px; font-size: 12px; background: rgba(90, 160, 255, .12); border-left: 3px solid #6ab8ff; color: #d8e8ff; }
.coop-gpts { margin: 6px 0; color: #ffd8b0; }
.coop-pf { position: fixed; z-index: 13; left: calc(8px + var(--sa-l, 0px)); top: calc(118px + var(--sa-t, 0px)); width: 170px; padding: 5px 6px; background: rgba(12, 8, 20, .82); border: 2px solid var(--ink); box-shadow: 0 0 0 1px #6ab8ff55; font-size: 11.5px; color: #e8e0ff; pointer-events: none; }
.coop-pf[hidden] { display: none; }
.coop-pft { display: block; margin-bottom: 3px; font: 700 11px "Kanit", sans-serif; color: #9ad8ff; }
.coop-pfm { margin: 3px 0; } .coop-pfm span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.coop-pfm i { display: block; height: 5px; margin: 2px 0; background: #2a1020; } .coop-pfm i s { display: block; height: 100%; background: #6dff8a; }
.coop-pfm small { color: var(--dim); font-size: 10.5px; } .coop-pfm.near small { color: #6dffa0; } .coop-pfm.far { opacity: .7; }
@media (pointer: coarse) { .coop-pf { top: auto; bottom: calc(150px + var(--sa-b, 0px)); width: 140px; font-size: 10.5px; } }

/* the main menus (shop, quests, bag, team, PvP, MMO, maps…) pop in like the pets and co-op popups */
#modal:not([hidden]) { animation: ovlin .18s ease-out both; }
#modal:not([hidden]) > .m-card { animation: cardin .26s cubic-bezier(.2, .9, .3, 1.08) both; }
@media (prefers-reduced-motion: reduce) { #modal, #modal > .m-card { animation: none !important; } }

/* Camp, field controls and menu surfaces share the same slate and amber palette. */
:root {
  --ink: #080b13; --wood0: #0e1420; --wood1: #151d2c; --wood2: #1b2637;
  --wood3: #263449; --wood4: #3b4c64; --night: #0a101b;
  --brass-d: #805d31; --brass: #edba73; --brass-l: #ffe0a7;
  --cream: #f4f0e9; --dim: #bac6d7; --mute: #8b9bb1; --gold: #ffcf81;
  --good: #87e0bd; --bad: #ff8b83; --cool: #7ed8db;
  --bevel: inset 0 1px 0 #ffffff12, 0 2px 5px #0004;
  --bevel-in: inset 0 2px 5px #0006;
  --menu-line: #52678580;
  --menu-ease: cubic-bezier(.2,.72,.26,1);
}

.btn, .tb-btn, .chip, .m-x, .lb-hero, .mapc, .hcard, .boon, select {
  clip-path: none;
  border: 1px solid var(--menu-line);
  border-radius: 8px;
  text-shadow: none;
}
.btn, .tb-btn { transition: background-color 150ms ease, border-color 150ms ease, transform 150ms var(--menu-ease); }
.btn { background: var(--wood3); }
.btn.pri { background: var(--brass); color: #21170e; text-shadow: none; box-shadow: inset 0 1px 0 #fff6, 0 4px 10px #0003; }
.btn.good { background: #266451; color: #effff9; box-shadow: var(--bevel); }
.btn.bad { background: #763c46; color: #fff4f1; box-shadow: var(--bevel); }
#app :is(button, select, input, textarea, a[href]):focus-visible {
  outline: 2px solid var(--cool);
  outline-offset: 2px;
}
#app :is(.m-x, .sk, .card):focus-visible { outline-offset: -2px; }
@media (hover: hover) {
  :is(.btn, .tb-btn, .camp-tile, .lb-hero):hover:not(:disabled) { border-color: var(--brass); }
}

#lobby {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(8px, 2vh, 24px);
  padding: max(14px, var(--sa-t)) max(22px, var(--sa-r)) max(16px, var(--sa-b)) max(22px, var(--sa-l));
}
#lobby .lb-vig {
  background: linear-gradient(90deg, #080e1b9c, transparent 45%), linear-gradient(0deg, #080d18 0%, #0b12213d 20%, transparent 34%);
}
#lobby .lb-top {
  position: relative; inset: auto; min-width: 0; width: 100%; max-width: 1180px;
  justify-self: center; padding: 0; flex-wrap: nowrap; gap: 10px; background: none;
}
.lb-user { min-width: 0; }
.lb-user > div { min-width: 0; }
.lb-user b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--cream); font-size: 16px; }
.lb-user .avatar { flex: none; border-radius: 9px; clip-path: none; background: #213449; box-shadow: none; color: var(--cool); border: 1px solid var(--menu-line); }
#lb-mail { position: relative; min-width: 42px; min-height: 42px; background: var(--wood1); }
.lb-social { display: flex; flex: none; align-items: center; gap: 5px; }
#lobby .lb-discord {
  min-height: 42px; padding-inline: 9px; border-radius: 7px;
  color: #f4f4ff; background: #3b459e; border: 1px solid #7f8aff; text-decoration: none;
}
#lobby .lb-discord:hover { background: #505dc6; }
.message-link { color: #a8dcff; text-decoration: underline; text-underline-offset: .16em; overflow-wrap: anywhere; }
.message-link:hover { color: #e4f4ff; }
.message-link:focus-visible, .lb-discord:focus-visible { outline: 2px solid #c7d5ff; outline-offset: 2px; }
@media (max-width: 480px) {
  #lobby .lb-top:has(.lb-social) { gap: 5px; }
  #lobby .lb-discord { padding-inline: 6px; font-size: 12px; }
}
.camp-brand { position: relative; align-self: start; justify-self: center; width: min(1180px, 100%); pointer-events: none !important; }
.camp-brand h1 {
  margin: 0; width: fit-content; color: var(--cream);
  font: 800 clamp(34px, 5.4vw, 82px)/.96 "Kanit", sans-serif; letter-spacing: -.035em;
  text-shadow: 0 4px 0 #111a29, 0 10px 28px #070a13;
}
.camp-brand span { display: block; margin-top: 7px; color: var(--brass-l); font: 600 clamp(14px, 1.8vw, 22px)/1.3 "Kanit", sans-serif; }
.camp-brand .patch-version { margin-left: .65em; color: #d9cbb8; font: 600 .72em/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.camp-dock { position: relative; width: min(1180px, 100%); justify-self: center; min-width: 0; display: grid; gap: 10px; }
.camp-news {
  position: relative; display: flex; align-items: center; gap: 8px; justify-self: start;
  max-width: 100%; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--menu-line);
  background: #151d2cea; color: var(--brass-l); text-align: left;
}
.camp-news span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camp-news span:has(.message-link) { white-space: normal; }
.camp-news-open { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0; background: transparent; color: inherit; }
#lobby .lb-team { position: static; display: grid; grid-template-columns: repeat(3, minmax(0, min(168px, 13vw))); gap: 8px; }
#lobby .lb-hero {
  width: 100%; min-width: 0; gap: 8px; padding: 6px;
  background: #172333ed; box-shadow: var(--bevel); border-bottom: 2px solid var(--cc);
}
#lobby .lb-hero.sel { background: var(--wood3); }
#lobby .lb-hero > div { min-width: 0; }
#lobby .lb-hero b { font-size: clamp(12px, 1.4vw, 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: none; }
#lobby .lb-hero img { width: 36px; height: 36px; border: 0; border-radius: 5px; background: #0c142280; }
#lobby .lb-hero small { font-size: 12px; }
.camp-nav { display: grid; grid-template-columns: 1.42fr repeat(3, 1fr); gap: 10px; }
.camp-nav:has(#lb-online[hidden]) { grid-template-columns: 1.42fr repeat(2, 1fr); }
.camp-tile, .hub-tile {
  position: relative; display: flex; align-items: center; gap: 12px; min-width: 0;
  border: 1px solid var(--menu-line); border-radius: 10px; padding: 12px;
  background: linear-gradient(145deg, #27374b, #182332 76%); box-shadow: var(--bevel);
  text-align: left; white-space: normal;
}
.camp-tile { min-height: 68px; transition: transform 170ms var(--menu-ease), border-color 170ms ease; }
.camp-tile:active, .hub-tile:active { transform: translateY(2px); }
.camp-tile.go {
  background: linear-gradient(125deg, #ffe0a3, #e6a963); border-color: #ffe4b4;
  color: #20170e; box-shadow: inset 0 1px 0 #fff8, 0 5px 18px #0005;
}
.camp-tile .pi, .hub-tile .pi { width: 30px; height: 30px; }
.camp-tile span, .hub-tile span { min-width: 0; }
.camp-tile b, .hub-tile b { display: block; font: 600 clamp(15px, 2vw, 21px)/1.2 "Kanit", sans-serif; }
.camp-tile small, .hub-tile small { display: block; margin-top: 3px; color: var(--dim); font: 400 13px/1.25 "Sarabun", sans-serif; }
.camp-tile.go small { color: #4b341f; }
.camp-tile .dot, .hub-tile .dot { top: 7px; right: 7px; }
.camp-tile:has(> .dot.on), .hub-tile:has(> .dot.on) { padding-inline-end: 27px; }

#modal, #dlg, #auth { background: #080d18ba; }
#modal .m-card, .dlg-card, .auth-card, .ip-card, .pet-card, .coop-card, .fish-card, .fr-card {
  border: 1px solid var(--menu-line); border-radius: 14px; clip-path: none;
  background: linear-gradient(150deg, #202e41, #121a29 46%, #0e1522);
  box-shadow: 0 20px 64px #0009, inset 0 1px 0 #ffffff13;
}
#modal .m-head {
  margin: 0; padding: 10px 14px; gap: 8px; border: 0; border-bottom: 1px solid var(--menu-line);
  background: #192435; box-shadow: none;
}
#modal .m-head b { color: var(--cream); font-size: 20px; letter-spacing: 0; text-shadow: none; }
#modal .m-x { min-width: 38px; min-height: 38px; padding: 0; font-size: 22px; color: var(--cream); background: var(--wood3); }
#modal .m-body { overscroll-behavior: contain; }
#modal:is([data-page="camp"], [data-page="loadout"], [data-page="onlinehub"], [data-page="fieldhub"], [data-page="pause"]) .m-card { width: min(620px, 100%); height: auto; }
.hub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.hub-tile { min-height: 54px; text-shadow: none; }
.hub-tile b { font-size: 16px; }
.hub-tile .pi { width: 24px; height: 24px; }
.camp-notice { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 10px; border-radius: 8px; background: var(--wood0); border: 1px solid var(--menu-line); overflow-wrap: anywhere; }
.camp-notice b { display: block; color: var(--gold); }
.pause-actions { margin-top: 12px; justify-content: space-between; }
.pause-loot { margin-top: 10px; padding: 7px; border: 1px solid var(--menu-line); border-radius: 8px; }
.pause-loot summary { cursor: pointer; }
#side .sd-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ld-bar { margin-top: 24px; border-radius: 5px; overflow: hidden; }
.ld-bar i { background: linear-gradient(90deg, #5abfc9, #eac480); }
.ld-list { display: none; }
.auth-card { padding: 22px; }
.auth-logo, .ld-logo { color: var(--cream); text-shadow: 0 3px 0 #43536b; }
.game-crest { object-fit: contain; border-radius: 22%; border: 1px solid #d6b15f; box-shadow: 0 3px 12px #070b19; }
.ld-logo .game-crest { display: block; margin: 0 auto 12px; }
.auth-logo { display: flex; justify-content: center; align-items: center; gap: 10px; }
.auth-logo .game-crest { width: clamp(32px, 12vw, 48px); height: auto; flex: none; }
.upgrade-ready { position: relative; }
.upgrade-ready > .dot { top: 2px; right: 2px; }
:is(.chip, .btn, .lb-hero).upgrade-ready { padding-inline-end: calc(var(--notice-dot-size) + 7px); }
.fashion-shop-link {
  width: 100%; min-height: 60px; margin: 8px 0 14px; padding: 9px 14px;
  display: flex; align-items: center; gap: 12px; text-align: start; border: 1px solid #b38b50; border-radius: 9px;
  background: linear-gradient(112deg, #47384d, #23293e 75%); color: #ffe7ad;
}
.fashion-shop-link > .pi { width: 30px; height: 30px; flex: none; }
.fashion-shop-link span { min-width: 0; flex: 1; }
.fashion-shop-link b, .fashion-shop-link small { display: block; line-height: 1.3; }
.fashion-shop-link b { font-size: 17px; }
.fashion-shop-link small { margin-top: 4px; color: #d1c9d1; }
.fashion-shop-link > i:last-child { font-size: 22px; font-style: normal; }
.fashion-panel { display: grid; gap: 11px; }
.fashion-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.fashion-tabs > button { min-height: 38px; }
.fashion-roster { display: flex; gap: 6px; overflow-x: auto; overscroll-behavior-inline: contain; padding: 3px; }
.fashion-hero {
  min-width: 72px; flex: 0 0 auto; display: grid; place-items: center; gap: 2px; white-space: nowrap;
  padding: 4px 8px; background: #1c2236; color: #e6dece; border: 1px solid #475775; border-radius: 6px;
}
.fashion-hero img { width: 37px; height: 37px; object-fit: contain; image-rendering: pixelated; }
.fashion-hero.on { border-color: #f4c574; background: #392f3f; }
.fashion-layout { display: grid; grid-template-columns: minmax(200px, .96fr) minmax(0, 1fr); align-items: start; gap: 14px; }
.fashion-preview { min-width: 0; border: 1px solid #515e78; border-radius: 10px; overflow: hidden; background: #1a2032; }
.fashion-stage {
  position: relative; display: grid; place-items: center; min-height: 120px;
  background: radial-gradient(ellipse at 50% 62%, color-mix(in srgb, var(--fashion-tone) 24%, #1b233e), #141a2d 63%, #111726);
}
.fashion-stage canvas { width: min(100%, 300px); height: auto; image-rendering: pixelated; }
.fashion-stage > span {
  position: absolute; bottom: 7px; right: 9px; padding: 2px 8px;
  background: #14192a; border: 1px solid #536382; border-radius: 999px; color: #e1e7f1; font-size: 12px;
}
.fashion-details { padding: 10px 12px 13px; }
.fashion-details b { color: var(--fashion-tone); font-size: 17px; }
.fashion-details p { margin: 3px 0 8px; color: #d6d9e6; font-size: 13px; line-height: 1.4; }
.fashion-details .btn { min-height: 38px; }
.fashion-catalog { min-width: 0; display: grid; align-content: start; gap: 8px; }
.fashion-cards { display: grid; gap: 6px; }
.fashion-card {
  display: grid; gap: 2px; text-align: start; min-width: 0; min-height: 48px; padding: 7px 10px;
  background: #1c2538; color: #f9ebd3; border: 1px solid #475775; border-inline-start: 3px solid var(--fashion-tone); border-radius: 6px;
}
.fashion-card.on { background: color-mix(in srgb, var(--fashion-tone) 20%, #20283d); border-color: var(--fashion-tone); }
.fashion-card small, .fashion-rank-note { color: var(--fashion-tone); }
.fashion-titles { display: grid; gap: 5px; border-top: 1px solid #48536b; padding-top: 7px; }
.fashion-titles .chip { color: var(--fashion-tone); }
.fashion-panel .note { margin: 1px 0; }
@media (max-width: 600px) {
  .fashion-layout { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .fashion-stage canvas { width: min(100%, 215px); }
  .fashion-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fashion-card { font-size: 12px; padding: 5px; min-height: 52px; }
  .fashion-card small { font-size: 11px; }
}

#topbar { background: linear-gradient(#0b1221f2, #0b122126); padding-bottom: 8px; }
#hud.pvp #topbar .tb-gold { display: none; }
.field-menu { min-width: 36px; justify-content: center; background: var(--wood2); }
.field-menu .dot { right: -3px; top: -3px; }
.discord-code-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.discord-code-row input { flex: 1 1 235px; min-width: 0; width: 100%; font: 14px monospace; }
.discord-code-row .btn { min-height: 40px; }
#lb-account-xp { display: block; padding: 0; border: 0; background: none; color: #aee6ff; font: inherit; font-size: .85em; text-align: left; cursor: pointer; }
.account-profile-label { display: flex; align-items: center; gap: 4px; }
.account-profile-label .dot { position: static; flex: none; }
.account-milestone { display: grid; grid-template-columns: 3.6em minmax(0, 1fr) auto; padding: 7px 0; border-top: 1px solid var(--wood3); }
#lobby progress { display: block; width: min(72px, 100%); height: 5px; accent-color: #73dcff; }
#lobby .lb-hero progress { accent-color: #90eab2; }
#app:not(.mode-run) :is(.run-bag, #run-loot) { display: none; }
#run-loot { position: absolute; left: 10px; bottom: 75px; display: flex; align-items: center; gap: 6px; max-width: min(65%, 340px); padding: 4px 8px; color: #fff0cd; background: #181d30eb; border: 1px solid #736044; border-radius: 6px; pointer-events: none; }
#run-loot[hidden] { display: none; }
#run-loot img { width: 26px; height: 26px; object-fit: contain; }
#run-loot span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#run-loot b { color: #ffd782; white-space: nowrap; }
.coop-pf { top: calc(160px + var(--sa-t, 0px)); }
@media (pointer: coarse) { .coop-pf { top: auto; bottom: calc(114px + var(--sa-b, 0px)); } }
@media (max-width: 480px) {
  .run-bag { font-size: 12px; white-space: nowrap; }
  .board-place { padding-inline: 3px; }
  .board-stage { height: clamp(49px, 18vw, 80px); }
  .place-1 .board-stage { height: clamp(59px, 21vw, 95px); }
}
.status-auto.on, #mm-auto.on { color: var(--cool); border-color: #69c6d3; }
.card, .mm-card, #chat, #pv-chat, #boss, #mm-mini { border-radius: 8px; }
#chat, #pv-chat { background: #0c1524e6; border-color: var(--menu-line); box-shadow: none; }
.chat-tabs { background: #1b293ce6; }
#boss .bar i, #st-fill { transition: width 115ms linear; }

#lobby:not([hidden]) .camp-brand,
#lobby:not([hidden]) .camp-dock { animation: camp-reveal .32s var(--menu-ease) both; }
#lobby:not([hidden]) .camp-dock { animation-delay: .06s; }
#modal:not([hidden]) > .m-card { animation: menu-reveal .22s var(--menu-ease) both; }
@keyframes camp-reveal { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes menu-reveal { from { opacity: 0; transform: translateY(9px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (orientation: portrait) and (max-width: 760px) {
  #lobby { grid-template-rows: auto minmax(54px, calc(56.25vw - 72px)) auto; align-content: start; padding: max(8px, var(--sa-t)) max(10px, var(--sa-r)) max(10px, var(--sa-b)) max(10px, var(--sa-l)); gap: 8px; overflow-y: auto; touch-action: pan-y; pointer-events: auto; }
  #lobby .lb-vig { background: linear-gradient(0deg, #0b1220 0%, transparent 24%); }
  .camp-brand h1 { font-size: clamp(32px, 10vw, 62px); }
  .camp-brand span { margin-top: 2px; }
  .camp-dock { padding: 8px; border-radius: 12px; border: 1px solid var(--menu-line); background: #131d2dec; }
  .camp-nav, .camp-nav:has(#lb-online[hidden]) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .camp-tile.go { grid-column: 1 / -1; }
  .camp-tile { min-height: 57px; padding: 8px; gap: 7px; }
  .camp-tile .pi { width: 23px; height: 23px; }
  .camp-tile small, .hub-tile small { font-size: 12px; }
  #lobby .lb-team { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  #lobby .lb-hero { gap: 4px; padding: 4px; }
  #lobby .lb-hero img { width: 26px; height: 26px; }
}
@media (orientation: landscape) and (max-height: 470px) {
  #lobby { padding-block: max(6px, var(--sa-t)) max(6px, var(--sa-b)); gap: 5px; }
  .camp-brand h1 { font-size: clamp(31px, 10vh, 53px); }
  .camp-brand span { font-size: 13px; margin-top: 2px; }
  .camp-dock, .camp-nav { gap: 6px; }
  .camp-tile { min-height: 47px; padding: 6px 8px; gap: 6px; }
  .camp-tile small { font-size: 11px; }
  .camp-tile .pi { width: 24px; height: 24px; }
  #lobby .lb-hero img { width: 26px; height: 26px; }
  #lobby .lb-hero { padding: 3px 6px; }
  .camp-news { padding: 3px 7px; font-size: 12px; }
}
@media (max-width: 620px), (pointer: coarse) {
  #app #modal { padding: max(6px, var(--sa-t)) max(6px, var(--sa-r)) max(6px, var(--sa-b)) max(6px, var(--sa-l)); place-items: center; }
  #app #modal .m-card { max-height: calc(100dvh - max(6px, var(--sa-t)) - max(6px, var(--sa-b))); padding-bottom: 0; }
  .hub-tile { gap: 7px; padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  #app .camp-brand, #app .camp-dock, #app #modal > .m-card { animation: none; }
  #app :is(.camp-tile, .btn, .tb-btn), #boss .bar i, #st-fill { transition: none; }
}

/* bigger tabs in the pets and co-op popups */
.pet-tabs { gap: 6px; }
.pet-tabs button { min-height: 44px; padding: 10px 18px; font: 700 16px/1 "Kanit", sans-serif; }
@media (max-width: 720px) { .pet-tabs button { min-height: 42px; padding: 9px 4px; font-size: 14.5px; } }
img.gear-art {
  image-rendering: auto;
  object-fit: contain;
  object-position: center;
  translate: var(--gear-x, 0%) var(--gear-y, 0%);
}
.evolved-art, :is(.it, .slot.has, .ip-ico):has(> .evolved-art), .ascend-forge, .ascend-picker, .ascend-scene {
  --evo-rainbow: conic-gradient(from 205deg, #ff789c, #ffca6e, #fbf177, #70f9bd, #78d6ff, #bc93ff, #ff789c);
}
img.evolved-art {
  box-sizing: border-box;
  border: 2px solid transparent;
  border-radius: 9px;
  background: linear-gradient(#161327, #101c2b) padding-box, var(--evo-rainbow) border-box;
}
:is(.it, .slot.has, .ip-ico):has(> .evolved-art) {
  border: 2px solid transparent;
  background: linear-gradient(#261c40, #101a2b) padding-box, var(--evo-rainbow) border-box;
  box-shadow: 0 0 9px #a55deb40, inset 0 0 0 1px #2a1a50;
  animation: none;
}
:is(.it, .slot.has, .ip-ico):has(> .evolved-art) > .evolved-art { border: 0; background: none; }
:is(.it, .slot.has).sel:has(> .evolved-art) { outline: 1px solid white; outline-offset: 1px; }
.evo-card .gear-art, .evo-hunts .gear-art { width: 43px; height: 43px; flex: 0 0 43px; }
.evo-hunts > section { margin-block: 14px; }
.evo-tag { display: inline-block; width: fit-content; padding: 1px 8px; border: 1px solid #a987d6; border-radius: 8px; color: #fae8ff; background: #342356; font-size: .78em; font-weight: 700; }
.ascend-forge {
  margin-top: 12px;
  padding: clamp(12px, 3vw, 22px);
  border: 1px solid transparent;
  border-radius: 14px;
  background: radial-gradient(ellipse at 80% 0%, #352354, #151b30 66%) padding-box, var(--evo-rainbow) border-box;
}
.ascend-forge h4 { margin: 0; color: #f1dbff; }
.ascend-forge p { max-width: 68ch; line-height: 1.5; }
.ascend-inputs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.ascend-inputs :is(label, .ascend-field) { display: grid; min-width: 0; gap: 5px; color: #eee0ff; }
.ascend-inputs select { width: 100%; min-height: 56px; padding: 4px 8px; border: 1px solid #8573a8; border-radius: 8px; background: #10162a; color: #fff2ff; font: inherit; }
.ascend-inputs select:disabled { opacity: .7; }
.ascend-primary, .ascend-pick-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px;
  min-width: 0; width: 100%; padding: 7px 10px; border: 1px solid #74628e; border-radius: 8px;
  background: #10162a; color: #fff2ff; font: inherit; text-align: start;
}
.ascend-primary { min-height: 56px; background: linear-gradient(115deg, #282140, #11162d 80%); border-color: #a288c9; }
.ascend-primary:disabled { opacity: .66; }
.ascend-primary:not(:disabled):hover, .ascend-pick-row:hover { border-color: #ddbcff; background: #30244b; }
.ascend-primary:focus-visible, .ascend-pick-row:focus-visible, #ascend-search:focus-visible { outline: 2px solid #efd4ff; outline-offset: -2px; }
.ascend-pick-icon {
  display: grid; place-items: center; width: 40px; aspect-ratio: 1; padding: 2px;
  border: 1px solid var(--rc, #a98fd1); border-radius: 8px; background: #171329;
}
.ascend-pick-icon img { display: block; width: 100%; height: 100%; }
.ascend-pick-copy { display: grid; gap: 2px; min-width: 0; }
.ascend-pick-copy b { overflow-wrap: anywhere; line-height: 1.25; }
.ascend-primary .ascend-pick-copy b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ascend-pick-copy small { color: #d5c8e9; font-size: .85em; line-height: 1.25; }
.ascend-pick-arrow { padding-inline: 2px; color: #efcfff; font-size: 1.4em; }
.dlg-card.ascend-picker {
  display: flex; flex-direction: column; gap: 12px; width: min(540px, 100%);
  max-height: min(78dvh, 580px); box-sizing: border-box; text-align: start;
  border: 2px solid transparent;
  background: linear-gradient(150deg, #302343, #13172a 60%) padding-box, var(--evo-rainbow) border-box;
  box-shadow: 0 12px 38px #0a041ab3;
}
.ascend-picker h3 { margin: 0; color: #f1dcff; }
#ascend-search {
  width: 100%; flex: 0 0 auto; min-height: 44px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid #8573a8; background: #14162d; color: #fff2ff; font: inherit; font-size: 16px;
}
#ascend-search::placeholder { color: #c6b5dd; }
.ascend-pick-list {
  display: grid; gap: 6px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  scrollbar-color: #8872a8 #17162b;
}
.ascend-pick-row { min-height: 62px; }
.ascend-pick-row .ascend-pick-icon { width: 46px; }
.ascend-pick-row[aria-pressed="true"] { border-color: #e6bcff; background: #37234e; }
.ascend-pick-rank { color: #ffe3a3; font-weight: 700; white-space: nowrap; }
.ascend-pick-rank span { color: #edd3ff; }
.ascend-pick-empty { padding: 10px; color: #e5d7f3; text-align: center; }
.ascend-picker .dlg-btns { flex: 0 0 auto; margin: 0; }
.ip-body .ascend-item-action { margin-block-start: 18px; }
.ascend-preview {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; align-items: center;
  margin-top: 14px; padding: 8px 10px; border: 1px solid #8063a2; border-radius: 9px; background: #181532;
}
.ascend-preview img { width: 56px; height: 56px; }
.ascend-preview small, .ascend-confirm small { display: block; color: #d5cae9; }
.ascend-preview em, .ascend-result em { color: #ffe791; font-style: normal; }
.dlg-card.ascend-dialog, .dlg-card.ascend-scene { width: min(480px, 100%); }
.ascend-confirm { display: grid; gap: 5px; grid-template-columns: repeat(3, minmax(0, 1fr)); padding-block: 8px; }
.ascend-confirm > div { min-width: 0; padding: 5px; border: 1px solid #645576; border-radius: 9px; overflow-wrap: anywhere; }
.ascend-confirm img { display: block; margin: 0 auto 7px; width: min(100%, 54px); aspect-ratio: 1; }
.dlg-card.ascend-scene {
  border: 2px solid transparent;
  background: linear-gradient(#1c142e, #100f22) padding-box, var(--evo-rainbow) border-box;
  box-shadow: 0 0 30px #aa55f378;
}
.ascend-scene h3 { color: #f5d9ff; }
.ascend-stage {
  --stage-ring: min(45vw, 168px);
  display: grid; place-items: center; position: relative; isolation: isolate; overflow: hidden;
  min-height: min(38dvh, 230px); border-radius: 11px;
  background: radial-gradient(ellipse at center, #7744a669, #211b3999 53%, #120e23 78%);
}
.ascend-stage > div { grid-area: 1 / 1; pointer-events: none; }
.ascend-orbit, .ascend-seal { width: var(--stage-ring); aspect-ratio: 1; border-radius: 50%; }
.ascend-orbit {
  border: 2px dashed #ce9cff;
  outline: 1px solid #fa7fff60; outline-offset: 8px;
  box-shadow: 0 0 26px #b653e694, inset 0 0 20px #aa65fa88;
  animation: ascend-orbit 1.55s cubic-bezier(.25,.68,.31,1) both;
}
.ascend-seal {
  background: var(--evo-rainbow);
  mask-image: radial-gradient(farthest-side, transparent 92%, #000 93%, #000 98%, transparent 99%);
  animation: ascend-seal 1.5s .46s ease-out both;
}
.ascend-flare {
  width: min(100%, 340px); height: 24px;
  background: radial-gradient(ellipse, #fff4d6a6, #dc83ff70 44%, transparent 72%);
  animation: ascend-flare .72s .56s ease-out both;
}
.ascend-shards i {
  position: absolute; top: calc(50% - 8px); left: calc(50% - 3px);
  width: 6px; height: 16px; border-radius: 3px;
  color: hsl(var(--hue) 95% 76%);
  background: currentColor; box-shadow: 0 0 9px currentColor;
  animation: ascend-shard 1.03s .65s ease-out both;
}
.ascend-award { z-index: 1; filter: drop-shadow(0 0 20px #bc6bffe0); animation: ascend-award 1.35s .43s cubic-bezier(.2,.7,.24,1) both; }
.ascend-award img { display: block; width: clamp(66px, 22vw, 112px); aspect-ratio: 1; border-width: 3px; }
.ascend-result { padding-block: 12px 4px; }
.ascend-result h4 { margin: 5px 0; color: #fdf1ff; font-size: 1.22em; }
.ascend-result small { color: #d9c9ed; }
@keyframes ascend-orbit { 0% { opacity: .1; transform: rotate(-150deg) scale(1.26); } 40% { opacity: 1; transform: rotate(65deg) scale(.6); } 100% { opacity: .55; transform: rotate(140deg) scale(1); } }
@keyframes ascend-seal { 0% { opacity: 0; transform: scale(.46) rotate(-30deg); } 37% { opacity: 1; } 100% { opacity: .86; transform: scale(1.09) rotate(75deg); } }
@keyframes ascend-flare { 0% { opacity: 0; transform: scaleX(.1); } 24% { opacity: 1; transform: scaleX(1); } 100% { opacity: 0; transform: scaleX(1.35); } }
@keyframes ascend-shard {
  0% { opacity: 0; transform: rotate(var(--angle)) translateY(-15px); }
  23% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--angle)) translateY(calc(var(--stage-ring) * -.65)) scale(.6); }
}
@keyframes ascend-award { 0% { opacity: 0; transform: scale(.45) rotate(-15deg); } 43% { opacity: 1; transform: scale(1.12) rotate(2deg); } 100% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .ascend-stage *, .ascend-scene { animation: none !important; }
  .ascend-flare, .ascend-shards { display: none; }
}
.it > .gear-art, .slot.has > .gear-art, .ip-ico > .gear-art, .trade-item > .gear-art {
  display: block;
  place-self: center;
}

.trade-intro { display: grid; gap: 8px; }
#modal[data-page="trade"] .m-card { width: min(790px, 100%); }
.trade-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.trade-controls select { flex: 1 1 180px; min-width: 0; min-height: 42px; padding: 6px 10px; background: #0e1823; border: 1px solid #517382; color: var(--cream); font-size: 16px; }
.fr-row button.fr-trade { color: #9df5ff; font-weight: 700; }
.trade-controls .btn { min-height: 42px; }
.trade-controls .pri { margin-inline-start: auto; }
.trade-offers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.trade-side { padding: 8px; min-width: 0; border: 1px solid #3b6578; background: #152b38; }
.trade-side h4, .trade-bag-head h4 { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 5px; margin: 0 0 6px; color: #e4f6fb; }
.trade-side h4 span { font-size: 12px; }
.trade-items { max-height: min(24vh, 210px); overflow: auto; touch-action: pan-y; }
.trade-item { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 8px; padding: 5px 6px; text-align: start; color: var(--cream); overflow-wrap: anywhere; }
.trade-item img { width: 48px; height: 48px; }
.trade-item b, .trade-item small { display: block; }
.trade-item small { color: #c2d5de; line-height: 1.35; }
.trade-bag-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.trade-bag-head select { min-height: 32px; }
.trade-bag { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; max-height: min(31vh, 240px); overflow: auto; }
.trade-bag .trade-item { border: 1px solid #486270; background: #14202d; cursor: pointer; }
.trade-bag .trade-item[aria-pressed="true"] { border-color: #79e6ed; background: #204350; }
.trade-bag .trade-item:focus-visible { outline: 2px solid #a2f5ff; outline-offset: -2px; }
.trade-note { margin: 8px 0; color: #fedb9f; }
#modal[data-page="trade"] .trade-note + .trade-controls { position: sticky; bottom: 0; z-index: 1; padding-block: 7px; background: #14202d; }
@media (max-width: 560px) {
  .trade-bag { grid-template-columns: minmax(0, 1fr); max-height: 27vh; }
  .trade-side .trade-item { grid-template-columns: 32px minmax(0, 1fr); padding-inline: 0; gap: 5px; }
  .trade-side .trade-item img { width: 32px; height: 32px; }
  .trade-controls .btn { flex: 1 1 auto; }
}
@media (max-width: 365px) {
  .trade-side .trade-item { grid-template-columns: minmax(0, 1fr); }
}

.trade-controls #trade-name {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; text-align: start;
}
.dlg-card.trade-picker {
  display: flex; flex-direction: column; gap: 10px; width: min(360px, 100%);
  max-height: min(78dvh, 475px); box-sizing: border-box; text-align: start;
  background: linear-gradient(150deg, #263a46, #121b28 72%);
}
.trade-picker h3 { margin: 0; }
#trade-friend-search {
  width: 100%; min-height: 42px; box-sizing: border-box; padding: 6px 12px;
  border: 1px solid #688393; border-radius: 8px; color: #fff3df; background: #101a25; font: inherit; font-size: 16px;
}
#trade-friend-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.trade-friend-row {
  width: 100%; min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  color: #f9ecd6; background: #223442; border: 1px solid #41596b; border-radius: 7px; font: inherit; text-align: start; cursor: pointer;
}
.trade-friend-row + .trade-friend-row { margin-top: 5px; }
.trade-friend-row[aria-pressed=true], .trade-friend-row:focus-visible { border-color: #e6be75; outline-offset: -3px; }
.trade-monogram { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 8px; background: #395262; color: #ffdf91; }
.trade-friend-info { display: grid; flex: 1; min-width: 0; }
.trade-friend-info b { overflow-wrap: anywhere; }
.trade-friend-info small { color: #c0c9d2; }
.trade-friend-info .online { color: #96e8bd; }

@media (orientation: portrait) and (max-width: 760px) {
  #app:is(.mode-run, .mode-lobby) {
    --portrait-scene: clamp(56.25vw, 48dvh, 95vw);
  }
  #app:is(.mode-run, .mode-lobby) #view,
  #app.mode-run #hud,
  #app.mode-lobby .lb-vig { height: var(--portrait-scene); }

  #app.mode-lobby #stage { touch-action: auto; }
  #app.mode-lobby #lobby {
    grid-template-rows: auto minmax(48px, calc(var(--portrait-scene) - 92px)) auto;
    background: linear-gradient(transparent calc(var(--portrait-scene) - 36px), #101827 var(--portrait-scene), #0b1220);
  }
  #app.mode-lobby #lobby::before { top: calc(var(--portrait-scene) - 2px); }
  #app.mode-lobby .camp-brand h1 { font-size: clamp(30px, 9vw, 52px); }
  #app.mode-lobby .camp-dock { padding: 6px; gap: 6px; }
  #app.mode-lobby .camp-nav { gap: 5px; }
  #app.mode-lobby .camp-nav .camp-tile { grid-column: auto; min-height: 46px; padding: 6px; }
  #app.mode-lobby .camp-nav .camp-tile.go:only-child { grid-column: 1 / -1; }
  #app.mode-lobby .camp-nav .camp-tile small { display: none; }
  #app.mode-lobby .camp-nav .camp-tile .pi { width: 22px; height: 22px; }

  #app.mode-run #pad { top: var(--portrait-scene); height: auto; background: linear-gradient(#172131, #101724); }
  #app.mode-run #team { top: calc(var(--portrait-scene) + 7px); }
  #app.mode-run #side { top: calc(var(--portrait-scene) + 66px); bottom: calc(125px + var(--sa-b)); }
  #app.mode-run #toasts { bottom: calc(100dvh - var(--portrait-scene) + 8px); }
}


#active-vitals {
  position: absolute; z-index: 4; pointer-events: none;
  left: 50%; bottom: calc(10px + var(--sa-b)); transform: translateX(-50%);
  display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 7px; align-items: center;
  width: min(290px, 27vw); box-sizing: border-box; padding: 5px 7px;
  background: linear-gradient(145deg, #24364a, #101823 68%);
  border: 1px solid #8d775a; border-radius: 6px; box-shadow: 0 2px 8px #05080caa;
}
#active-vitals[hidden] { display: none; }
.vitals-portrait {
  display: block; width: 34px; height: 34px; border: 1px solid var(--cc);
  border-radius: 4px; background: #121d29; image-rendering: pixelated;
}
.vitals-stats { display: grid; gap: 3px; min-width: 0; }
.vitals-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 12px/1.1 "Kanit", sans-serif; color: #fae8ce; }
#active-vitals .vital { height: 13px; border: 1px solid #654651; border-radius: 2px; position: relative; overflow: hidden; background: #14121e; }
#active-vitals .vital.mp { border-color: #506e92; background: #101a2d; }
#active-vitals .vital > i {
  position: absolute; inset: 0; transform-origin: left center;
  background: linear-gradient(#ff867b, #c73054 55%, #8c2147);
}
#active-vitals .vital.mp > i { background: linear-gradient(#94ebff, #357cdb 53%, #293c96); }
#active-vitals .vital > span {
  position: absolute; inset: 0 3px; display: flex; align-items: center; justify-content: space-between; gap: 2px;
  white-space: nowrap; color: #fff; font: 700 10px/1 system-ui, sans-serif; text-shadow: 0 1px 2px #020309, 0 0 3px #020309;
}
.sk .mp-cost {
  position: absolute; top: 3px; right: 3px; z-index: 1; border-radius: 2px; padding: 1px 2px;
  color: #e1f5ff; background: #0c1832e8; font: 700 9px/1 system-ui, sans-serif; white-space: nowrap;
}
.sk.low-mana .si { opacity: .44; }
.sk.low-mana .mp-cost { color: #ffe2d5; background: #632c47; }
@media (pointer: fine) and (max-width: 1260px) {
  #app:is(.mode-mmo, .mode-pvp) #active-vitals { bottom: calc(93px + var(--sa-b)); }
}
@media (max-width: 760px) and (orientation: portrait) {
  #active-vitals, #app:is(.mode-mmo, .mode-pvp) #active-vitals {
    bottom: calc(9px + var(--sa-b)); width: clamp(90px, calc(100vw - 250px), 154px);
    grid-template-columns: minmax(0, 1fr); padding: 4px;
  }
  .vitals-portrait { display: none; }
  .vitals-name { text-align: center; font-size: 11px; }
  #app.touch-ui #joy { width: 104px; height: 104px; }
  #app.touch-ui #skills {
    display: grid; grid-template-columns: repeat(2, 48px); grid-auto-rows: 48px; gap: 6px;
    align-items: center; justify-items: center; width: auto; height: auto;
    right: calc(6px + var(--sa-r)); bottom: calc(6px + var(--sa-b)); pointer-events: none;
  }
  #app.touch-ui #skills .sk,
  #app.touch-ui #pad.mmo #skills .sk.dodge {
    position: relative; inset: auto; grid-area: auto; width: 48px; height: 48px; pointer-events: auto;
  }
  #app.touch-ui #skills .sk.s0, #app.touch-ui #skills .sk.s1,
  #app.touch-ui #skills .sk.s2, #app.touch-ui #skills .sk.s3 { inset: auto; }
  #app.touch-ui #skills .sk.s2 { order: 1; } #app.touch-ui #skills .sk.s3 { order: 2; }
  #app.touch-ui #skills .sk.s0 { order: 3; } #app.touch-ui #skills .sk.s1 { order: 4; }
  #app.touch-ui #skills .sk.dodge { order: 5; }
  #app.touch-ui #skills .sk.atk { order: 6; }
  #app:not(.touch-ui) #active-vitals,
  #app.mode-mmo:not(.touch-ui) #active-vitals, #app.mode-pvp:not(.touch-ui) #active-vitals {
    bottom: calc(145px + var(--sa-b));
  }
}
@media (pointer: coarse), (max-width: 760px) {
  .sk .mp-cost { top: auto; bottom: 3px; right: 50%; transform: translateX(50%); }
}
@media (max-width: 760px) and (orientation: portrait) {
  #app.touch-ui #active-vitals {
    top: clamp(132px, 25dvh, 220px);
    bottom: auto;
    width: min(214px, 62vw);
    padding: 5px 7px;
  }
  #app.touch-ui.mode-run #active-vitals { top: calc(var(--portrait-scene) - 64px); }
}
@media (orientation: landscape) {
  #app.touch-ui #active-vitals {
    top: max(calc(108px + var(--sa-t)), 32dvh);
    bottom: auto;
    width: min(225px, 34vw);
  }
}

@media (max-width: 760px), (pointer: coarse) and (max-height: 520px) {
  #app #modal {
    padding: max(6px, var(--sa-t)) max(6px, var(--sa-r)) max(6px, var(--sa-b)) max(6px, var(--sa-l));
    place-items: center;
    touch-action: pan-x pan-y;
  }
  #app #modal .m-card {
    height: auto; min-height: 0; max-width: 100%;
    max-height: calc(100dvh - max(6px, var(--sa-t)) - max(6px, var(--sa-b)));
    overflow: hidden; padding: 0;
  }
  #app #modal .m-head { flex: 0 0 auto; padding: 5px 8px 5px 10px; gap: 6px; }
  #app #modal .m-head > b { min-width: 0; font-size: clamp(15px, 4.7vw, 18px); line-height: 1.25; overflow-wrap: anywhere; }
  #app #modal .m-x { flex: 0 0 44px; width: 44px; height: 44px; }
  #app #modal .m-body {
    min-width: 0; overflow-x: hidden; overflow-y: auto; overflow-wrap: anywhere;
    padding: 8px 9px 12px; margin: 0; touch-action: pan-x pan-y;
  }
  #app #modal .m-body :is(.btn, .chip) { min-height: 42px; white-space: normal; }
  #modal .bag { grid-template-columns: minmax(0, 1fr); }
  #modal .maps { grid-template-columns: repeat(auto-fit, minmax(min(100%, 132px), 1fr)); }
  #modal .shopgrid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
  #modal .shopc { grid-template-columns: auto minmax(0, 1fr); }
  #modal .shopc .buyn { flex-wrap: wrap; }
  #modal .mail-hd { gap: 6px; padding: 8px; }
  #modal .mail-hd em { padding-inline: 4px; }
  #modal .bagtabs { position: sticky; top: 0; z-index: 2; padding-block: 4px; background: #172132; }

  .tm-lineup {
    position: sticky; top: 0; z-index: 3; margin-bottom: 7px; padding: 4px;
    border: 1px solid #415771; border-radius: 8px; background: #172436;
  }
  .tm-stage { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 3px; border-radius: 6px; background: #111d2e; }
  .tm-spot { gap: 3px; }
  .tm-spot.empty { min-height: 80px; }
  .tm-fig { padding: 2px; width: 100%; min-width: 0; border-radius: 4px; gap: 0; }
  .tm-fig em { left: 2px; top: 2px; padding: 0 3px; font-size: 10px; }
  .tm-fig .tm-spr { width: min(100%, 44px); }
  .tm-fig .tm-floor { width: min(100%, 44px); height: 8px; margin-top: -6px; }
  .tm-fig b { max-width: 100%; font-size: 13px; line-height: 1.2; }
  .tm-fig small { font-size: 11px; }
  .tm-fig .tm-spot-power, .tm-spot-class, .tm-place-wide { display: none; }
  .tm-place-short { display: inline; }
  #modal .m-body .tm-spot .btn, .tm-cur { min-height: 42px; font-size: 12px; padding: 3px; }
  .tm-cur { display: grid; align-content: center; }
  .m-body .tm-hint { margin: 3px 0 0; font-size: 12px; line-height: 1.25; }
  .tm-content { min-width: 0; }
  .tm-roster { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 64px), 1fr)); overflow: visible; gap: 5px; }
  .tm-pick { min-width: 0; min-height: 65px; padding: 4px 2px; align-content: center; }
  .tm-pick img { width: 34px; height: 34px; }
  .tm-pick b { font-size: 12px; }
  .tm-pick small { font-size: 11px; }
  .tm-pick em { min-width: 16px; font-size: 11px; line-height: 16px; }
  .tm-head .tx { min-width: min(150px, 55%); }
  .tm-tabs { flex-wrap: wrap; }
  .tm-tabs .chip { flex: 1 1 auto; min-width: min(75px, 100%); }
  .tm-skill { gap: 6px; padding: 7px; }
  .tm-slot .ic, .tm-skill > .ic { width: 38px; height: 38px; }
  .tm-skill p { font-size: 14px; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  .tm-screen { display: grid; grid-template-columns: minmax(172px, 30%) minmax(0, 1fr); gap: 8px; align-items: start; }
}

/* Meadow expedition journal and in-run objective */
.expedition-journal { display: grid; gap: 12px; max-width: 760px; margin-inline: auto; }
.expedition-cover {
  min-height: clamp(168px, 32vw, 270px); display: grid; align-items: end; padding: clamp(12px, 3vw, 24px);
  border: 1px solid #668676; border-radius: 12px; overflow: hidden;
  background: linear-gradient(0deg, #0b1820f7 0%, #0b182081 42%, #0b182009 80%), var(--expedition-art) center 44% / cover, #172c28;
}
.expedition-cover small { color: #b5ead6; font-weight: 700; }
.expedition-cover h2 { margin: 2px 0 4px; color: #fff0bc; font-size: clamp(25px, 6vw, 38px); line-height: 1.15; }
.expedition-cover p { margin: 0; max-width: 42ch; color: #f2f6ec; }
.expedition-steps { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; padding: 0; margin: 0; }
.expedition-steps li, .expedition-reward { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border: 1px solid #395b57; border-radius: 8px; background: #182a2e; }
.expedition-steps .pi, .expedition-reward .pi { width: 22px; height: 22px; flex: none; color: #a7e3c2; }
.expedition-steps p { margin: 3px 0 0; color: #c9dbd6; font-size: 14px; line-height: 1.45; }
.expedition-reward { align-items: center; border-color: #716242; background: #302a20; }
.expedition-reward b, .expedition-reward small { display: block; color: #ffe2a0; }
#expedition-hud {
  position: absolute; z-index: 3; top: calc(88px + var(--sa-t)); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: min(88%, 320px); text-align: center; padding: 4px 10px;
  border: 1px solid #78bba0; border-radius: 7px; background: #102a2aeb; color: #dcffed; font-size: 13px; line-height: 1.3;
}
#expedition-hud.danger { background: #40291bee; border-color: #ffbf77; color: #ffe4ab; }
.expedition-summary { padding: 7px; background: #173232; color: #c8ffdf; border-radius: 7px; }
.summary-upgrades { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; text-align: start; }
.summary-upgrades article { min-width: 0; padding: 8px; border: 1px solid #3b5966; border-radius: 8px; background: #162631; }
.summary-upgrade-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.summary-upgrade-head > small { color: #a4f5c5; }
.summary-upgrade-compare { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; margin-block: 6px; }
.summary-upgrade-compare > div { display: grid; align-content: start; gap: 2px; padding: 5px; background: #0b1922; border-radius: 5px; overflow-wrap: anywhere; }
.summary-upgrade-compare img { width: 33px; height: 33px; }
.summary-upgrade-compare small { display: block; color: #c8d9df; }
.summary-upgrades .btn { width: 100%; min-height: 42px; }
.summary-actions { position: sticky; bottom: 0; z-index: 2; justify-content: center; padding: 6px; background: #14202e; border-top: 1px solid #324653; }
@media (max-width: 540px) {
  .expedition-steps, .summary-upgrades { grid-template-columns: minmax(0, 1fr); }
  .summary-actions .btn { flex: 1 1 auto; min-height: 44px; }
  #expedition-hud { top: calc(103px + var(--sa-t)); }
}

/* Awakening tree */
#modal[data-page="awakening"] .m-card { width: min(980px, 100%); }
.awakening-panel { display: grid; gap: 10px; color: #f1ebdf; }
.awakening-hero {
  display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid #465d6e;
  border-radius: 10px; background: radial-gradient(ellipse at 20% 20%, color-mix(in srgb, var(--hero-color) 20%, #12212d), #12212d 72%);
}
.awakening-hero img { flex: none; width: 52px; height: 52px; image-rendering: pixelated; border-radius: 9px; background: #111a27; }
.awakening-hero h3 { margin: 0; color: var(--hero-color); line-height: 1.1; }
.awakening-hero span { color: #dce1db; }
.awakening-hero .stars { display: flex; margin-top: 4px; }
.awakening-points { margin-inline-start: auto; text-align: center; padding: 4px 8px; align-self: center; white-space: nowrap; }
.awakening-points b, .awakening-points small { display: block; }
.awakening-points b { color: #ffe3a4; font-size: clamp(22px, 5vw, 34px); line-height: 1; }
.awakening-points small { color: #c3d4de; }
.awakening-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.awakening-controls .btn, .awakening-gear .btn { min-height: 42px; }
.awakening-controls > span, .awakening-help { color: #c1d6dd; font-size: 13px; }
.awakening-help { margin: 0; }
.awakening-root {
  display: flex; justify-content: center; align-items: center; gap: 6px; width: fit-content; margin-inline: auto;
  padding: 4px 13px; border: 1px solid #bd9a66; background: #302b35; border-radius: 999px; color: #ffe2a0; font-weight: 700;
}
.awakening-branches { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px 7px; position: relative; margin-top: 8px; }
.awakening-branches::before { content: ""; position: absolute; top: -10px; left: 12.5%; right: 12.5%; height: 1px; background: #887b8d; }
.awakening-branches::after { content: ""; position: absolute; top: -18px; left: 50%; height: 9px; border-left: 1px solid #887b8d; }
.awakening-branch {
  position: relative; min-width: 0; border: 1px solid color-mix(in srgb, var(--branch) 43%, #202c37);
  border-radius: 9px; background: linear-gradient(170deg, color-mix(in srgb, var(--branch) 14%, #172733), #101b27 75%);
}
.awakening-branch::before { content: ""; position: absolute; height: 10px; top: -11px; left: 50%; border-left: 1px solid var(--branch); }
.awakening-branch h4 { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; column-gap: 4px; margin: 0; padding: 6px 2px 3px; font-size: 14px; color: var(--branch); text-align: center; }
.awakening-branch h4 .pi { width: 15px; height: 15px; }
.awakening-branch h4 span { display: block; width: 100%; color: #b6c7d0; font-size: 11px; }
.awakening-nodes { position: relative; height: 308px; }
.awakening-link { position: absolute; width: 1px; background: #546575; pointer-events: none; }
.awakening-link.horizontal { height: 1px; }
.awakening-link.lit { background: color-mix(in srgb, var(--branch) 68%, #566379); }
.awakening-node {
  position: absolute; display: grid; justify-items: center; gap: 2px; width: 48%; min-width: 44px; padding: 0;
  transform: translate(-50%, -22px); text-align: center; color: #edf4f6; background: transparent; border: 0;
}
.awakening-disc {
  width: 44px; height: 44px; border: 1px solid var(--branch); border-radius: 50%; position: relative;
  display: grid; place-items: center; background: #223345; box-shadow: inset 0 0 0 3px #111d2a; color: var(--branch);
}
.awakening-disc .pi { width: 19px; height: 19px; translate: 0 -3px; }
.awakening-disc small { position: absolute; inset: auto 6px 2px; color: #e0edf0; background: #1b2832; border-radius: 8px; font-size: 10px; line-height: 1.1; }
.awakening-node b { min-width: 0; width: 100%; font-size: 12px; line-height: 1.15; text-shadow: 0 1px #0a1016, 0 0 5px #101b27; overflow-wrap: anywhere; }
.awakening-node.locked { color: #c0cbd2; }
.awakening-node.locked .awakening-disc { border-color: #627584; color: #98aab6; background: #1d2934; }
.awakening-node.ranked .awakening-disc { background: color-mix(in srgb, var(--branch) 43%, #16202d); }
.awakening-node.ready .awakening-disc, .awakening-node:focus-visible .awakening-disc { box-shadow: 0 0 8px color-mix(in srgb, var(--branch) 65%, transparent), inset 0 0 0 3px #1a2531; }
.awakening-node:focus-visible { outline: 2px solid #fcf4d5; border-radius: 8px; outline-offset: 1px; z-index: 1; }
.awakening-gear { padding: 8px; margin-block: 6px; border: 1px solid #5e593e; border-radius: 8px; background: #292820; }
.awakening-gear h4, .awakening-gear ul { margin: 0; }
.awakening-gear ul { padding-inline-start: 16px; margin-top: 4px; }
.awakening-gear li { font-size: 13px; line-height: 1.4; }
.dlg-card.awakening-detail { width: min(420px, 100%); }
.dlg-card .awakening-detail-meta { margin: 0 0 8px; color: #c4b4e9; }
.awakening-detail-effect { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.awakening-detail-effect div { display: grid; gap: 2px; border: 1px solid #466073; border-radius: 7px; padding: 6px 8px; background: #101d2b; }
.awakening-detail-effect small { color: #adc5d7; }
.awakening-detail-effect b { color: #ffe2a0; }
@media (max-width: 650px) {
  .awakening-branches { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .awakening-branches::before { left: 25%; right: 25%; }
  .awakening-branch:nth-child(n+3)::before { height: 5px; top: -6px; }
}

/* Equipment build options and encounter stats */
.build-matchup { display: grid; gap: 2px; margin-block: 8px; padding: 8px 10px; border: 1px solid #436077; border-radius: 8px; background: #142636; color: #d7eaf1; }
.build-matchup b { color: #ffdfa2; }
.build-matchup small, .build-enemy-aim { color: #a9dff0; }
.build-attune { padding: 8px; border: 1px solid #4e617d; border-radius: 8px; background: #202838; }
.build-attune > b { color: #c9d4ff; }
.build-attune .row { gap: 5px; margin-block: 4px; }
.build-attune .row .btn { min-height: 42px; }
.build-filters { gap: 5px; margin-bottom: 8px; }
.build-filters .chip { min-height: 34px; }
#boss-combat { display: inline-block; max-width: 100%; padding: 1px 5px; border-radius: 4px; background: #142031e0; color: #bce9ff; font-size: clamp(9px, 2.65vw, 12px); line-height: 1.15; }


/* Keep touch controls independent. Desktop uses a single combat dock. */
#pad { height: 100%; }
.combat-dock { display: contents; }
@media (orientation: landscape) {
  #app.touch-ui.mode-mmo #active-vitals {
    top: calc(56px + var(--sa-t));
    left: calc(8px + var(--sa-l));
    transform: none;
    width: clamp(142px, 23vw, 194px);
  }
}
@media (pointer: fine) {
  #app:not(.touch-ui) .combat-dock {
    position: absolute;
    bottom: calc(10px + var(--sa-b));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: clamp(4px, 1vw, 12px);
    max-width: calc(100vw - 20px);
    padding: 5px clamp(4px, 1vw, 10px);
    box-sizing: border-box;
    background:
      linear-gradient(122deg, #c8a363 0 8px, transparent 9px) top left / 27px 17px,
      linear-gradient(238deg, #c8a363 0 8px, transparent 9px) top right / 27px 17px,
      radial-gradient(ellipse at 12% 0%, #50405f, transparent 51%),
      repeating-linear-gradient(132deg, #b9b8fb08 0 1px, transparent 1px 5px),
      linear-gradient(#202639, #0b0d18);
    background-repeat: no-repeat;
    border: 2px solid #a27d4d;
    border-radius: 10px;
    box-shadow: 0 4px 14px #050611db, inset 0 0 0 1px #e1c79490, inset 0 0 0 4px #101126;
  }
  #app:not(.touch-ui) .combat-dock::before {
    content: "";
    position: absolute;
    inset: -4px 24% auto;
    height: 5px;
    background: linear-gradient(90deg, transparent, #b7915a 28%, #ffe5a1 50%, #b7915a 72%, transparent);
  }
  #app:not(.touch-ui):is(.mode-mmo, .mode-run, .mode-pvp) #active-vitals {
    position: static;
    transform: none;
    width: clamp(104px, 21vw, 230px);
    grid-template-columns: clamp(24px, 4vw, 44px) minmax(0, 1fr);
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  #app:not(.touch-ui) .vitals-portrait {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    box-shadow: 0 0 8px color-mix(in srgb, var(--cc) 45%, transparent);
  }
  #app:not(.touch-ui) #pad #skills {
    position: relative;
    inset: auto;
    display: flex;
    align-items: center;
    gap: clamp(2px, .65vw, 7px);
    pointer-events: none;
  }
  #app:not(.touch-ui) #pad #skills .sk {
    position: relative;
    inset: auto;
    width: clamp(28px, 9vw, 54px);
    height: clamp(28px, 9vw, 54px);
    border-radius: 6px;
    pointer-events: auto;
  }
}

#skills .pet-skillbtn { right: calc(100% + 6px); bottom: 0; }
#app.touch-ui #skills .pet-skillbtn kbd { display: none; }
#skills .pet-skillbtn:focus-visible { outline: 2px solid #fff1b3; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .pet-skillbtn.ready { animation: none; }
}
@media (pointer: fine) {
  #app:not(.touch-ui) #skills .pet-skillbtn {
    position: relative;
    inset: auto;
    width: clamp(28px, 9vw, 54px);
    height: clamp(28px, 9vw, 54px);
    flex: none;
  }
}

/* Expedition menus: cool enamel surfaces, warm highlights on progression actions. */
:root {
  --wood0: #0b1920; --wood1: #13252d; --wood2: #1a3039;
  --wood3: #27424b; --wood4: #385861; --menu-line: #52727b;
  --cream: #f4f4e9; --dim: #c4d7d6; --mute: #a5bbc0;
}
#modal .m-card, .dlg-card, .auth-card {
  background: linear-gradient(145deg, #233c45, #152932 48%, #101f28);
  border-color: var(--menu-line);
  box-shadow: inset 0 1px #a8dbd32e, 0 14px 44px #030a10aa;
}
#modal .m-head {
  background: linear-gradient(98deg, #274849, #192f3a 70%);
  border-bottom-color: #628784;
}
#modal .m-head b { color: #f8f4dc; line-height: 1.4; }
#modal .m-x { background: #19323c; border: 1px solid #799796; }
.camp-nav .camp-tile:not(.go), .hub-grid .hub-tile {
  background: linear-gradient(155deg, #29474e, #152c36);
  border-color: #587982;
}
.camp-nav .camp-tile.go, #modal .btn.pri {
  background: linear-gradient(160deg, #ffe19a, #e8b966);
  border-color: #f6d594; color: #292211; text-shadow: none;
}
.camp-nav .camp-tile.go small { color: #433620; }
#modal .mapc.sel { border-color: #ffe09b; box-shadow: inset 0 0 0 2px #ffe09b; }
#modal :is(button, select, input):focus-visible, .camp-nav button:focus-visible {
  outline: 3px solid #b0f4e4; outline-offset: -4px;
}
@media (pointer: coarse), (max-width: 600px) {
  #modal .m-x, #modal .btn, #modal select { min-height: 44px; }
  #modal .m-x { min-width: 44px; flex-shrink: 0; }
  #modal .m-head { padding-block: 4px; }
  #modal .m-body { scroll-padding-block: 12px; }
  #modal .btn { white-space: normal; line-height: 1.35; }
}

/* Nine-slice metalwork keeps the engraved corners intact as menus resize. */
:is(.m-card, .dlg-card, .auth-card, .ip-card, .pet-card, .coop-card, .fish-card, .fr-card, .camp-tile, .hub-tile) {
  position: relative;
  --inlay-size: 20px;
}
:is(.m-card, .dlg-card, .auth-card, .ip-card, .pet-card, .coop-card, .fish-card, .fr-card, .camp-tile, .hub-tile)::after {
  content: "";
  position: absolute;
  inset: 1px;
  z-index: 1;
  border: var(--inlay-size) solid transparent;
  border-image: url("img/ui/menu-inlay.svg") 24 / var(--inlay-size) round;
  pointer-events: none;
}
.camp-nav .camp-tile, .hub-grid .hub-tile { --inlay-size: 10px; }
@media (pointer: coarse), (max-width: 600px) {
  :is(.m-card, .dlg-card, .auth-card, .ip-card, .pet-card, .coop-card, .fish-card, .fr-card) {
    --inlay-size: 13px;
  }
}
