/* Legend of MapleStory – one stylesheet for every screen.
   The look follows MapleStory on PC: navy windows with steel-blue edges and a glossy
   blue title bar, orange "OK" buttons, glossy HP/MP bars and a gold for rewards.
   Two themes: dark (default) and light (html[data-theme="light"]), chosen in Settings.
   Sections: 1 tokens · 2 base · 3 controls · 4 start screens · 5 item picker
             6 game HUD · 7 touch controls · 8 menu sheet · 9 pop-ups · 10 MapleStory skin · 11 screen sizes */

/* ---- 1. Tokens ----------------------------------------------------------------- */
:root {
  --radius: 14px;
  --radius-small: 9px;
  --font: system-ui, -apple-system, 'Segoe UI', 'Leelawadee UI', 'Noto Sans Thai', 'Sarabun', Tahoma, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --bar: 0px;                      /* height of the bottom menu bar on phones held upright */
}

/* Colours (dark theme). The game scene's floating controls, the message feed and the passive
   tree's star map stay dark in both themes, so they carry these values too. */
:root, .tree-modal, .feed, .actions, .pad-left {
  color-scheme: dark;
  --bg-0: #0c1627;          /* wells: inputs, icon boxes */
  --bg-1: #14223a;          /* window body */
  --bg-2: #1b2c49;          /* panels and rows inside a window */
  --bg-3: #26406a;          /* raised: plain buttons, active tabs */
  --bg-hover: #2f4d7d;
  --sel: #1f3a63;           /* a chosen / worn / current row */
  --line: rgba(150, 185, 235, 0.16);
  --line-strong: rgba(160, 195, 245, 0.32);
  --glass: rgba(15, 28, 50, 0.74);
  --glass-strong: rgba(14, 25, 45, 0.95);
  --text: #f1f5fc;
  --muted: #9db0cb;
  --placeholder: #627592;
  --accent: #5cc4ff;
  --accent-strong: #2d86df;
  --on-accent: #ffffff;
  --good: #6bd49a;
  --gold: #ffc847;
  --gem: #8fd3ff;
  --bad: #ef7676;
  --hp: #ff5d6c;
  --mp: #4fa4ff;
  --xp: #ffd84a;
  /* MapleStory window parts */
  --win-top: #1a2c4b;
  --win-bottom: #121f36;
  --win-edge: #4f6f9f;
  --win-shine: rgba(255, 255, 255, 0.10);
  --title-bar: linear-gradient(180deg, #3d6aa8 0%, #2a4e83 52%, #213f6c 100%);
  --title-text: #ffffff;
  --btn-top: #35588c;
  --btn-bottom: #26416b;
  --btn-edge: #5b7fb4;
  --btn-text: #eef4ff;
  --ok-top: #ffd65a;
  --ok-bottom: #f39a14;
  --ok-edge: #c26a00;
  --ok-text: #ffffff;
  --ok-shadow: #9a4f00;
  --frame-0: #4a5f80;       /* an item slot's frame before its rarity colours it */
  --stage: linear-gradient(180deg, #24406a, #172a47 70%);
  --page-glow-1: #20406e;
  --page-glow-2: #1b3557;
  --tree-bg: #0d1626;
  --scene-bg: #0b1424;
  --evade: #e3c04f;
  --agility: #58c47b;
  --skill: #e8655f;
  --lifesteal: #e2574c;
  --reflect: #a66be0;
  --regen: #5fc46b;
  --gcoin: #ff9bd2;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Light theme: MapleStory's pale windows with a blue title bar. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg-0: #f4f8fd;
  --bg-1: #fbfdff;
  --bg-2: #eaf1fa;
  --bg-3: #d7e4f4;
  --bg-hover: #c8daf0;
  --sel: #d9e9fb;
  --line: rgba(35, 70, 125, 0.15);
  --line-strong: rgba(35, 70, 125, 0.3);
  --glass: rgba(248, 251, 255, 0.84);
  --glass-strong: rgba(248, 251, 255, 0.97);
  --text: #18263c;
  --muted: #586b86;
  --placeholder: #94a3b8;
  --accent: #1a78d1;
  --accent-strong: #1f7fd9;
  --good: #198a52;
  --gold: #b9780a;
  --gem: #1f86c7;
  --bad: #d14343;
  --hp: #f0465a;
  --mp: #2f8ff0;
  --xp: #f4c21c;
  --evade: #b88f0f;
  --agility: #2f9a55;
  --skill: #d0453f;
  --lifesteal: #c93a30;
  --reflect: #8a4fc4;
  --regen: #3a9a47;
  --gcoin: #d0478f;
  --win-top: #ffffff;
  --win-bottom: #eef4fb;
  --win-edge: #8fa8cc;
  --win-shine: rgba(255, 255, 255, 0.9);
  --title-bar: linear-gradient(180deg, #6ea6ec 0%, #4a86d6 52%, #3b74c4 100%);
  --btn-top: #ffffff;
  --btn-bottom: #dde8f5;
  --btn-edge: #9fb6d6;
  --btn-text: #1c2c45;
  --frame-0: #a9bad2;
  --stage: linear-gradient(180deg, #d9e8fa, #f1f6fd 70%);
  --page-glow-1: #cfe1f7;
  --page-glow-2: #d8e6f5;
  --tree-bg: #0d1626;
  --scene-bg: #cfe0f2;
  --shadow: 0 10px 28px rgba(30, 60, 110, 0.18);
}

/* ---- 2. Base ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* No pinch- or double-tap zoom: the game is laid out for the screen as it is, and zooming in blurs the pixel art. */
html { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: radial-gradient(1200px 700px at 15% -10%, var(--page-glow-1) 0%, transparent 60%), radial-gradient(900px 600px at 100% 110%, var(--page-glow-2) 0%, transparent 55%), var(--bg-0);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.2px; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; opacity: 0.45; }
img { display: block; max-width: 100%; image-rendering: pixelated; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 8px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 12px; }
.icon-sheet { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- 3. Controls ---------------------------------------------------------------- */
.glass { background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 11px;
  background: var(--bg-3); border: 1px solid var(--line); font-weight: 600; white-space: nowrap;
  transition: background 0.15s, transform 0.05s, border-color 0.15s;
}
.btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--line-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--accent-strong); border-color: transparent; color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: #4fa2f3; }
.btn.gold { background: #c99a3a; border-color: transparent; color: #1c1404; }
.btn.gold:hover:not(:disabled) { background: #d9ab4b; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--bg-2); color: var(--text); }
.btn.small { min-height: 32px; padding: 4px 11px; border-radius: 9px; font-size: 12.5px; }
.btn.wide { width: 100%; }
.btn .icon { width: 16px; height: 16px; }
.btn small { font-weight: 500; opacity: 0.85; }
.round {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; flex: none;
  color: var(--text); transition: background 0.15s, transform 0.05s;
}
.round:hover { background-color: color-mix(in srgb, var(--bg-hover) 75%, transparent); }
.round:active { transform: scale(0.95); }
.segmented { display: inline-flex; padding: 3px; gap: 3px; border-radius: 11px; background: var(--bg-0); border: 1px solid var(--line); }
.segmented button { padding: 6px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 13px; }
.segmented button.active { background: var(--bg-3); color: var(--text); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.chip b { color: var(--text); }
.gold-chip i, .gem-chip i, .coin i { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25); flex: none; }
.gem-chip i, .coin.gem i { background: var(--gem); border-radius: 2px; transform: rotate(45deg); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chips button { padding: 5px 12px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.chips button.active { background: var(--accent-strong); border-color: transparent; color: var(--on-accent); }
.weapon-filter-label { display: flex; align-items: center; padding: 0 3px; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.weapon-filter-select { width: auto; min-width: 150px; min-height: 34px; flex: 1 1 190px; padding: 5px 10px; font-size: 12.5px; }
.weapon-filter-note { flex-basis: 100%; color: var(--muted); font-size: 11px; }
.npc-shop-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; flex-basis: 100%; }
.shop-currency-filter { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-0); }
.shop-currency-choice { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; cursor: pointer; }
.shop-currency-choice input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.shop-currency-choice span { white-space: nowrap; }
.currency-gold { color: var(--gold); }
.currency-gems { color: var(--gem); }
.currency-gcoin { color: var(--gcoin); }
.npc-shop-filters .weapon-filter-label { display: grid; gap: 3px; padding: 0; white-space: normal; }
.npc-shop-filters .weapon-filter-select { width: 100%; min-width: 0; }
.npc-shop-filters .weapon-filter-note { grid-column: 1 / -1; }
.npc-shop-page { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 2px 2px; color: var(--muted); font-size: 11.5px; }
.npc-shop-page > span { display: flex; gap: 6px; }
.npc-shop-page .btn { min-height: 30px; }
.attr-chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; border: 1px solid currentColor; white-space: nowrap; }
.attr-chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.attr-chip.evade, .attr-evade { color: var(--evade); }
.attr-chip.agility, .attr-agility { color: var(--agility); }
.attr-chip.skill, .attr-skill { color: var(--skill); }
.attr-chip.lifesteal, .attr-lifesteal { color: var(--lifesteal); }
.attr-chip.reflect, .attr-reflect { color: var(--reflect); }
.attr-chip.regen, .attr-regen { color: var(--regen); }
.attr-chip.none { color: var(--muted); }
.note { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-small); background: var(--bg-2); border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.note b { color: var(--text); }
.empty-note { padding: 22px 12px; text-align: center; color: var(--muted); font-size: 13px; grid-column: 1 / -1; }

.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px;
  background: var(--bg-0); border: 1px solid var(--line-strong); color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; font: inherit; }

.toast {
  position: fixed; left: 50%; top: calc(14px + var(--safe-top)); z-index: 90; transform: translate(-50%, -140%);
  max-width: min(92vw, 460px); padding: 10px 16px; border-radius: 12px; text-align: center;
  background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  opacity: 0; transition: transform 0.25s, opacity 0.25s; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---- 4. Start screens: sign in, choose a hero, create a hero --------------------- */
.screen { min-height: 100%; display: grid; place-items: center; padding: calc(20px + var(--safe-top)) 16px calc(20px + var(--safe-bottom)); }
.card { width: min(100%, 420px); padding: 24px; border-radius: 20px; background: var(--bg-1); border: 1px solid var(--line); box-shadow: var(--shadow); }
.auth-card { display: grid; gap: 14px; text-align: center; }
.auth-card .form { text-align: left; }
.auth-actions { display: flex; justify-content: center; gap: 18px; margin-top: -6px; }
.auth-actions button { color: var(--accent); font-size: 12.5px; }
.brand { display: grid; justify-items: center; gap: 8px; }
.brand-mark { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: linear-gradient(160deg, #3f95ec, #7fd1ff); color: #fff; font-size: 26px; }
.auth-language { display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-size: 12px; }
.auth-language .segmented button { min-width: 62px; padding: 5px 10px; font-size: 12px; }
.auth-tabs { justify-self: center; }

.lobby-card { width: min(100%, 860px); display: grid; gap: 14px; justify-items: center; text-align: center; }
.lobby-slots { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.lobby-slot {
  display: grid; justify-items: center; align-content: end; gap: 4px; min-height: 250px; padding: 14px 10px;
  border-radius: 16px; background: var(--bg-2); border: 1px solid var(--line); transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.lobby-slot:hover { border-color: var(--accent); transform: translateY(-2px); background: var(--sel); }
.lobby-entry { position: relative; min-width: 0; }
.lobby-entry .lobby-slot { width: 100%; }
.lobby-delete { position: absolute; top: 7px; right: 7px; z-index: 1; padding: 4px 8px; border-radius: 8px; color: var(--bad); background: var(--bg-0); border: 1px solid var(--line); font-size: 11px; }
.account-card { text-align: left; }
.account-card h2 { text-align: center; }
.account-card #accountSummary { text-align: center; overflow-wrap: anywhere; }
.account-form { max-height: 70vh; overflow-y: auto; padding: 2px; }
.account-credentials { display: grid; gap: 10px; }
.lobby-slot.empty { align-content: center; border-style: dashed; color: var(--muted); }
.lobby-slot b { font-size: 15px; }
.lobby-slot small { color: var(--muted); }
.lobby-plus { font-size: 34px; line-height: 1; color: var(--accent); }
.lobby-play { margin-top: 6px; padding: 5px 16px; border-radius: 99px; background: var(--accent-strong); color: #fff; font-weight: 700; font-size: 12.5px; }
.avatar-canvas { width: 130px; height: 150px; image-rendering: pixelated; }

.create-card { width: min(100%, 980px); display: grid; gap: 14px; }
.creator-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.creator-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.creator-preview { display: grid; gap: 10px; justify-items: center; }
.preview-stage { width: 100%; display: grid; justify-items: center; gap: 4px; padding: 16px 10px 12px; border-radius: 16px; background: var(--stage); border: 1px solid var(--line); }
.preview-stage b { font-size: 14px; }
.creator-picked { width: 100%; display: grid; gap: 6px; max-height: 250px; overflow: auto; }
.picked-item { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.picked-item span { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 8px; background: var(--bg-0); }
.picked-item img { max-width: 30px; max-height: 30px; }
.picked-item small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.2; }
.picked-item b { display: block; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.creator-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }

/* ---- 5. Item picker (character creator) ------------------------------------------- */
.creator-options { min-width: 0; display: grid; gap: 10px; }
.picker-slots { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.picker-slot { flex: none; padding: 6px 13px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 13px; }
.picker-slot.worn { color: var(--text); }
.picker-slot.worn::after { content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--good); vertical-align: middle; }
.picker-slot.active { background: var(--accent-strong); border-color: transparent; color: var(--on-accent); }
.picker-tools { display: flex; gap: 8px; }
.picker-kind { max-width: 190px; }
.picker-colors { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.picker-colors small { color: var(--muted); margin-right: 2px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; background: var(--swatch); border: 2px solid var(--bg-1); box-shadow: 0 0 0 1px var(--line-strong); }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; max-height: 370px; overflow: auto; padding: 2px; align-content: start; }
.picker-item { display: grid; justify-items: center; gap: 4px; padding: 8px 4px 6px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.picker-item:hover { border-color: var(--line-strong); }
.picker-item.selected { border-color: var(--accent); background: var(--sel); }
.picker-item b { width: 100%; font-size: 11.5px; font-weight: 600; line-height: 1.25; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.creator-item-icon { display: grid; place-items: center; width: 44px; height: 44px; font-size: 20px; color: var(--muted); }
.creator-item-icon img { max-width: 42px; max-height: 42px; }
.picker-foot { display: flex; align-items: center; justify-content: flex-start; color: var(--muted); font-size: 12.5px; min-height: 24px; }

/* ---- 6. Game: full-screen scene with the HUD floating over it --------------------- */
/* `clip` (not just `hidden`): nothing may scroll the game sideways – the closed menu waits off-screen to the right. */
.game { position: fixed; inset: 0; overflow: hidden; overflow: clip; background: var(--scene-bg); user-select: none; -webkit-user-select: none; touch-action: none; }
.scene { position: absolute; inset: 0; }
.scene canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; position: absolute; }
/* Groups that only lay their buttons out must not swallow taps meant for the scene behind them. */
.hud-right, .hud-toggles, .hud-menu, .hud-wallet, .pad-left, .actions, .skill-row, .potion-row, .town-row { pointer-events: none; }
.hud-right button, .hud-toggles > *, .pad-left > *, .skill-row > *, .potion-row > *, .town-row > * { pointer-events: auto; }

.hud-me { left: calc(10px + var(--safe-left)); top: calc(10px + var(--safe-top)); display: flex; align-items: center; gap: 10px; width: 250px; padding: 8px 12px 8px 8px; border-radius: 16px; }
.lv-badge { display: grid; place-items: center; align-content: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--bg-3); border: 2px solid var(--accent); line-height: 1; }
.lv-badge small { font-size: 9px; color: var(--muted); font-weight: 700; }
.lv-badge b { font-size: 17px; }
.me-bars { flex: 1; min-width: 0; display: grid; gap: 3px; }
.me-name { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.me-name b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.me-name .attr-chip { flex: none; }
.bar { position: relative; height: 11px; border-radius: 99px; background: rgba(0, 0, 0, 0.45); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 99px; transition: width 0.2s; }
.bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 9px; font-weight: 700; line-height: 1; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.7); }
.bar.hp i { background: linear-gradient(90deg, #d85757, var(--hp)); }
.bar.mp i { background: linear-gradient(90deg, #3f86d6, var(--mp)); }
.bar.xp { height: 7px; }
.bar.xp i { background: var(--xp); }
.bar.xp span { font-size: 0; }

.hud-floor { left: 50%; top: calc(10px + var(--safe-top)); transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 99px; }
.hud-floor .round { background: var(--bg-3); }
.hud-floor .round.ready { background: var(--accent-strong); color: #fff; animation: pulse 1.4s infinite; }
.hud-floor .round:disabled { opacity: 0.35; }
.floor-info { display: grid; justify-items: center; min-width: 150px; padding: 0 8px; line-height: 1.2; }
.floor-info b { font-size: 14.5px; }
.floor-info b.boss { color: var(--gold); }
.floor-info small { color: var(--muted); font-size: 11px; }
.floor-progress { position: relative; display: block; width: 100%; height: 10px; margin-top: 3px; border-radius: 99px; background: rgba(0, 0, 0, 0.45); overflow: hidden; }
.floor-progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--good); border-radius: 99px; transition: width 0.2s; }
.floor-progress.boss i { background: var(--bad); }
.floor-progress em { position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-size: 9px; font-weight: 700; line-height: 1; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.7); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(108, 182, 255, 0.55); } 50% { box-shadow: 0 0 0 7px rgba(108, 182, 255, 0); } }

.hud-right { right: calc(10px + var(--safe-right)); top: calc(10px + var(--safe-top)); display: grid; justify-items: end; gap: 8px; }
.hud-wallet { display: flex; align-items: center; gap: 6px; }
.coin { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 99px; font-weight: 700; font-size: 13px; }
.hud-wallet .round { width: 34px; height: 34px; }
.hud-wallet .icon { width: 17px; height: 17px; }
.hud-wallet #guideButton { width: 30px; height: 30px; }
.hud-wallet #guideButton .icon { width: 15px; height: 15px; }
.hud-menu { display: flex; gap: 6px; }
/* Eight buttons in a row need room: on narrower screens they stand in two rows of four. */
@media (max-width: 1120px) { .hud-menu { flex-wrap: wrap; justify-content: flex-end; max-width: 202px; } }
.menu-btn { display: grid; justify-items: center; gap: 2px; width: 46px; }
.menu-btn .round { position: relative; width: 42px; height: 42px; }
.menu-btn small { font-size: 10.5px; font-weight: 600; color: #dbe4f0; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9); white-space: nowrap; }
.menu-btn.active .round { background: var(--accent-strong); border-color: transparent; }
.dot { position: absolute; top: 1px; right: 1px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); border: 2px solid var(--bg-1); }

.hud-toggles { left: calc(10px + var(--safe-left)); top: calc(114px + var(--safe-top)); display: flex; gap: 6px; flex-wrap: wrap; max-width: 330px; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 99px; font-size: 11.5px; font-weight: 600; color: var(--text); }
.pill b { color: var(--good); }
.pill.off b { color: var(--muted); }
.pill .icon { width: 14px; height: 14px; }
#autoToggle i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(107, 212, 154, 0.2); }
#autoToggle.off i { background: var(--muted); box-shadow: none; }
.pill.net { color: var(--good); }
.pill.net.offline { color: var(--gold); }

/* Messages sit over the soil under the floor the hero walks on, beside the chat button. */
.feed { left: calc(64px + var(--safe-left)); bottom: calc(14px + var(--safe-bottom)); width: min(340px, 44vw); display: grid; gap: 3px; pointer-events: none; }
.has-touch .feed { left: calc(170px + var(--safe-left)); }
.feed-line { justify-self: start; max-width: 100%; padding: 3px 9px; border-radius: 9px; background: rgba(10, 15, 23, 0.55); font-size: 12px; line-height: 1.35; overflow-wrap: anywhere; transition: opacity 1.2s; }
.feed-line.old { opacity: 0.35; }
.feed-line b { font-weight: 700; }
.feed-line i { font-style: normal; color: var(--muted); }
.feed-line em { font-style: normal; color: var(--gold); }
.feed-line span { color: var(--good); }
.feed-line.chat-world i { color: var(--gold); }
.feed-line.chat-guild i { color: var(--good); }

.announcement-marquee { z-index: 18; top: 28vh; left: 50%; transform: translateX(-50%); width: min(92vw, 760px); overflow: hidden; padding: 9px 0; border: 1px solid rgba(255, 213, 107, 0.58); border-radius: 14px; background: rgba(10, 19, 36, 0.88); box-shadow: 0 5px 18px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.12); pointer-events: none !important; }
.announcement-marquee-track { width: 100%; overflow: hidden; white-space: nowrap; }
.announcement-marquee-track span { display: inline-block; min-width: max-content; padding-left: 100%; color: var(--gold); font-size: 15px; font-weight: 750; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9); animation: announcement-scroll var(--announcement-duration, 16s) linear 1 both; }
@keyframes announcement-scroll { from { transform: translateX(0); } to { transform: translateX(-100%); } }

.chat-window { position: absolute; left: calc(12px + var(--safe-left)); bottom: calc(66px + var(--safe-bottom) + var(--bar)); z-index: 8; display: flex; flex-direction: column; gap: 8px; width: min(430px, calc(100vw - 24px - var(--safe-left) - var(--safe-right))); height: min(430px, 62vh); padding: 10px; border-radius: 16px; background: color-mix(in srgb, var(--bg-1) 50%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); pointer-events: auto; }
.chat-head { display: flex; align-items: center; justify-content: space-between; min-height: 28px; }
.chat-head .round { width: 28px; height: 28px; font-size: 22px; line-height: 1; }
.chat-tabs { display: flex; gap: 3px; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.chat-tabs button { flex: none; padding: 6px 9px; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 650; }
.chat-tabs button.active { background: var(--accent-strong); color: #fff; }
.chat-messages { flex: 1; min-height: 80px; overflow: auto; display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 8px; border: 1px solid rgba(154, 190, 240, 0.35); border-radius: 10px; background: rgba(7, 12, 21, 0.62); box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.35); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); scrollbar-width: thin; }
.chat-empty { margin: auto; color: #c4d0e0; font-size: 12px; text-align: center; }
.chat-entry { display: flex; align-items: baseline; gap: 6px; min-width: 0; padding: 4px 5px; border-radius: 6px; font-size: 12.5px; line-height: 1.45; overflow-wrap: anywhere; }
.chat-entry + .chat-entry { border-top: 1px solid rgba(255, 255, 255, 0.075); }
.chat-entry small { flex: none; color: #b8c5d7; font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chat-entry b { flex: none; color: #7fd0ff; }
.chat-entry .chat-whisper-sender { flex: none; padding: 0; border: 0; background: transparent; color: #7fd0ff; font: inherit; font-weight: 700; cursor: pointer; }
.chat-entry .chat-whisper-sender:hover, .chat-entry .chat-whisper-sender:focus-visible { color: #fff; text-decoration: underline; }
.chat-entry span { min-width: 0; color: #f4f7fc; white-space: pre-wrap; }
.chat-entry.chat-system b { color: #ffd56b; }
.chat-entry.chat-system.chat-announcement b { color: #ff9e70; }
.chat-entry.chat-guild b { color: #83e4aa; }
.chat-form { display: flex; gap: 6px; width: 100%; }
.chat-form input { min-height: 36px; min-width: 0; flex: 1; padding: 6px 10px; }
.chat-form button { flex: none; }

.scene-overlay { inset: 0; display: grid; place-items: center; background: rgba(6, 10, 16, 0.45); z-index: 6; }
.scene-overlay > div { display: grid; gap: 6px; justify-items: center; padding: 18px 26px; border-radius: 18px; text-align: center; max-width: 86vw; }
.scene-overlay b { font-size: 17px; }
.scene-overlay small { color: var(--muted); }
.scene-overlay .btn { margin-top: 8px; }

/* The market: the floor panel names it and offers the way back; fighting switches and the skill bar step aside. */
.town-info, #playerMarketButton, #peacePill, .town-row { display: none; }
.town-info { justify-items: center; min-width: 150px; padding: 0 8px; line-height: 1.25; }
.town-info b { font-size: 14.5px; color: var(--gold); }
.town-info small { color: var(--muted); font-size: 11px; }
.peace { color: var(--good); font-weight: 700; }
.in-town .town-info { display: grid; }
.in-town #playerMarketButton { display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 5px 10px; }
.in-town #peacePill { display: inline-flex; color: var(--good); }
.in-town .town-row { display: flex; }
.in-town .floor-info, .in-town #floorUp, .in-town #floorDown, .in-town #autoToggle, .in-town #climbToggle, .in-town .skill-row { display: none; }
.in-town #marketButton .round { background: var(--accent-strong); border-color: transparent; }
.party-hud { left: calc(18px + var(--safe-left)); top: calc(110px + var(--safe-top)); display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid rgba(208, 225, 249, 0.45); border-radius: 50%; color: #fff; cursor: pointer; }
.party-hud .icon { width: 17px; height: 17px; }
.party-hud-count { position: absolute; right: -7px; bottom: -6px; padding: 0 3px; border: 1px solid rgba(255, 255, 255, 0.45); border-radius: 99px; background: var(--accent-strong); color: #fff; font-size: 7px; font-style: normal; font-weight: 750; line-height: 1.3; white-space: nowrap; }
.party-hud:hover, .party-hud:focus-visible { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 213, 107, 0.22); }
.quest-pill { max-width: min(330px, 92vw); color: var(--gold); cursor: pointer; }
.quest-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quest-pill.ready { background: rgba(201, 154, 58, 0.9); border-color: transparent; color: #1c1404; animation: pulse 1.6s infinite; }

/* ---- 7. Touch controls: joystick on the left, potions and skills on the right ------ */
.pad-left { left: calc(14px + var(--safe-left)); bottom: calc(14px + var(--safe-bottom) + var(--bar)); display: grid; gap: 8px; justify-items: start; }
.stick-zone { display: none; width: 138px; height: 138px; place-items: center; touch-action: none; }
.has-touch .stick-zone { display: grid; }
.stick { position: relative; width: 112px; height: 112px; border-radius: 50%; background: rgba(14, 21, 32, 0.45); border: 1.5px solid rgba(255, 255, 255, 0.2); }
.stick::before, .stick::after { content: ''; position: absolute; left: 50%; width: 0; height: 0; border: 6px solid transparent; transform: translateX(-50%); opacity: 0.5; }
.stick::before { top: 5px; border-bottom-color: #fff; }
.stick::after { bottom: 5px; border-top-color: #fff; }
.stick i { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; background: rgba(233, 238, 247, 0.85); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4); }
.stick.active { border-color: var(--accent); }

.actions { right: calc(14px + var(--safe-right)); bottom: calc(16px + var(--safe-bottom) + var(--bar)); display: flex; align-items: flex-end; gap: 16px; }
.skill-row, .potion-row { display: flex; gap: 9px; align-items: flex-end; }
.potion-row { gap: 7px; }
.town-row { gap: 9px; align-items: flex-end; }
.town-row .act-wide { width: 54px; min-width: 54px; height: 54px; padding: 0; gap: 0; }
.town-row .act-wide .icon { position: static; width: 23px; height: 23px; }
.act-attack { border-color: var(--gold); }
/* Skill and potion buttons are squares with softly rounded corners, like item slots. */
.act {
  position: relative; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 12px; overflow: hidden;
  background: rgba(14, 21, 32, 0.72); border: 2px solid var(--element, rgba(255, 255, 255, 0.25)); color: #fff; touch-action: none;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: transform 0.06s;
}
.act span { font-size: 22px; line-height: 1; }
.act small { position: absolute; right: 7px; bottom: 3px; font-size: 9px; font-weight: 700; color: #cfd9e6; }
.act.pressed { transform: scale(0.92); }
.act.empty { border-width: 1px; border-color: rgba(255, 255, 255, 0.16); background: rgba(14, 21, 32, 0.3); backdrop-filter: none; -webkit-backdrop-filter: none; }
.act.empty span { font-size: 13px; color: rgba(255, 255, 255, 0.4); font-weight: 700; }
.act.passive { opacity: 0.8; }
.act.passive small { right: 50%; transform: translateX(50%); color: var(--good); }
.act.no-mp { filter: saturate(0.2) brightness(0.75); }
.act .cd { position: absolute; inset: 0; border-radius: inherit; background: conic-gradient(rgba(6, 10, 16, 0.78) var(--cd, 0deg), transparent 0); pointer-events: none; }
.act .skill-icon { width: 100%; height: 100%; border: 0; border-radius: 0; background: none; }
.act .skill-icon img { background: none; }
/* Potion slots: a little smaller than skills; green for HP, blue for MP, gold for buffs. */
.act-potion { width: 46px; height: 46px; border-radius: 10px; border-color: var(--pot, rgba(255, 255, 255, 0.25)); }
.act-potion.kind-hp { --pot: #e06a6a; } .act-potion.kind-mp { --pot: #5aa8f2; } .act-potion.kind-both { --pot: #c58be8; } .act-potion.kind-buff { --pot: var(--gold); }
.act-potion.empty { cursor: pointer; }
.act-potion.empty .icon { width: 18px; height: 18px; color: rgba(255, 255, 255, 0.4); }
.act-potion .qty { position: absolute; left: 4px; bottom: 1px; font-size: 10px; font-weight: 800; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.act-potion small { right: 4px; bottom: 1px; }
.act-potion .auto { position: absolute; left: 0; right: 0; top: 0; font-style: normal; font-size: 7.5px; font-weight: 800; line-height: 1.5; text-align: center; background: rgba(107, 212, 154, 0.85); color: #06210f; }
.act-potion.none { filter: saturate(0.15) brightness(0.7); }
.potion-art { position: relative; display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 8px; background: color-mix(in srgb, var(--pot, #e06a6a) 26%, var(--bg-0)); }
.potion-art.kind-hp { --pot: #e06a6a; } .potion-art.kind-mp { --pot: #5aa8f2; } .potion-art.kind-both { --pot: #c58be8; } .potion-art.kind-buff { --pot: var(--gold); }
.potion-art i { font-style: normal; font-size: 10px; font-weight: 800; color: var(--pot, #fff); }
.potion-art img { position: absolute; inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); object-fit: contain; image-rendering: pixelated; background: var(--bg-0); border-radius: 6px; }
.act-potion .potion-art { width: 100%; height: 100%; border-radius: 0; background: color-mix(in srgb, var(--pot) 22%, transparent); }
.act-potion .potion-art img { background: none; inset: 5px; width: calc(100% - 10px); height: calc(100% - 10px); }
.item-row > .potion-art { width: 42px; height: 42px; border-radius: 10px; }
/* The market's buttons: talk (to whoever is in reach), a harmless attack, and jump. */
.act-wide { position: relative; display: inline-flex; justify-content: center; gap: 6px; width: auto; min-width: 104px; height: 54px; padding: 0 14px; border-radius: 14px; font-weight: 700; font-size: 13px; }
.act-wide span { font-size: 13px; }
.act-wide .icon { position: absolute; left: 12px; width: 18px; height: 18px; }
.act-jump { border-color: var(--accent); }
.act-talk { border-color: var(--gold); max-width: 190px; }
.act-talk span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-talk:disabled { border-color: rgba(255, 255, 255, 0.16); opacity: 0.55; }
#chatButton { position: relative; }

/* ---- 8. Menu sheet ----------------------------------------------------------------- */
.sheet {
  position: absolute; z-index: 10; top: 0; right: 0; bottom: 0; width: min(430px, 100vw); display: flex; flex-direction: column;
  background: var(--glass-strong); border-left: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: -18px 0 40px rgba(0, 0, 0, 0.35); transform: translateX(105%); transition: transform 0.22s ease, visibility 0s linear 0.22s; user-select: text; -webkit-user-select: text; touch-action: pan-y;
  visibility: hidden;      /* while closed: out of reach of the Tab key and of screen readers */
}
.sheet.open { transform: none; visibility: visible; transition: transform 0.22s ease; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-top)) 10px 8px 12px; border-bottom: 1px solid var(--line); }
.sheet-tabs { flex: 1; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.sheet-tabs button { position: relative; display: grid; place-items: center; flex: 1 1 42px; min-width: 30px; max-width: 46px; height: 38px; border-radius: 10px; color: var(--muted); }
.sheet-tabs button.active { background: var(--bg-3); color: var(--accent); }
.sheet-body { flex: 1; overflow-y: auto; padding: 14px 14px calc(22px + var(--safe-bottom)); overscroll-behavior: contain; }
.tab-view { display: none; }
.tab-view.active { display: block; }
.view-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.view-title h2, .view-title h3 { flex: 1; }
.view-title.sub { margin-top: 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 9px 10px; border-radius: var(--radius-small); background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.stat small { display: block; color: var(--muted); font-size: 11.5px; }
.stat b { font-size: 16px; }
.stat.wide { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.item-list { display: grid; gap: 7px; }
.item-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.item-row.equipped { border-color: var(--accent); background: var(--sel); }
.item-row.locked { opacity: 0.6; }
.item-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 10px; background: var(--bg-0); color: var(--muted); font-size: 18px; }
.item-icon img { max-width: 36px; max-height: 36px; }
.item-text { flex: 1; min-width: 0; }
.item-text b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.item-text b em { font-style: normal; font-weight: 600; color: var(--muted); font-size: 12px; margin-left: 4px; }
.item-text small { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; }
.item-text small .plus { color: var(--good); font-weight: 600; }
.item-side { display: grid; justify-items: end; gap: 4px; flex: none; }
.price { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.price::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }
.price.gems::before { background: var(--gem); border-radius: 2px; transform: rotate(45deg); }
.price.short { color: var(--bad); }
.tag { display: inline-block; padding: 0 7px; border-radius: 99px; background: var(--bg-3); color: var(--muted); font-size: 11px; font-weight: 600; }
.tag.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

/* Pets: the one that is out on a small stage, then every kind as a card (picture box, name, facts, status). */
.pet-view { display: block; width: 72px; height: 66px; image-rendering: pixelated; }
.pet-stage-box { padding: 12px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); }
.pet-stage { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 12px; align-items: center; }
.pet-stage-art, .pet-art { position: relative; overflow: hidden; border: 1px solid var(--line); }
.pet-stage-art { height: 118px; border-radius: 12px; background: linear-gradient(180deg, transparent 78%, color-mix(in srgb, var(--good) 30%, var(--bg-2)) 78%), var(--stage); }
/* Pets at their real size (the picture is 72 × 66 art pixels): enlarged pixel art looks broken. */
.pet-stage-art .pet-view, .pet-art .pet-view { position: absolute; left: 50%; width: 72px; height: 66px; margin-left: -36px; }
.pet-stage-art .pet-view { bottom: 0; }
.pet-stage-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pet-stage-name b { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pet-meter { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; gap: 6px; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.pet-meter .bar { height: 13px; }
.bar.closeness i { background: linear-gradient(90deg, #d86f9c, #ffa9c8); }
.bar.fullness i { background: linear-gradient(90deg, #c98f2e, var(--gold)); }
.bar.fullness.low i { background: var(--bad); }
.pet-bonus { display: block; margin-top: 7px; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.pet-bonus b { color: var(--good); }
.bad { color: var(--bad); }
.pet-say { margin-top: 10px; padding: 7px 11px; min-height: 34px; border-radius: 10px; background: var(--bg-0); border: 1px solid var(--line); font-size: 12.5px; }
.pet-say.quiet { color: var(--muted); }
.pet-buttons, .pet-commands { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.pet-buttons .btn b { color: var(--muted); }
.pet-buttons .btn.on b { color: var(--good); }
.pet-commands > small { color: var(--muted); font-size: 11.5px; margin-right: 2px; }
.pet-command { padding: 5px 13px; border-radius: 99px; background: var(--bg-0); border: 1px solid var(--line-strong); font-size: 12.5px; font-weight: 600; }
.pet-command:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pet-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pet-card { display: grid; align-content: start; gap: 1px; padding: 8px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.pet-card.owned { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.pet-card.active { border-color: var(--accent); background: var(--sel); }
.pet-art { height: 92px; margin-bottom: 5px; border-radius: 9px; background: var(--bg-0); }
.pet-art .pet-view { bottom: -4px; }
.pet-card:not(.owned) .pet-view { opacity: 0.7; }
.pet-card > b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pet-card small { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.pet-card small b { color: var(--text); }
.pet-card small i { font-style: normal; white-space: nowrap; }
.pet-status { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pet-status.own { color: var(--good); font-weight: 600; }
.pet-status.sale { color: var(--gold); font-weight: 600; }
.pet-status .price { color: var(--text); font-size: 11.5px; }
.pet-status .price.short { color: var(--bad); }
.pet-card-foot { display: flex; align-items: center; min-height: 32px; margin-top: 5px; }
button.stat.wide { width: 100%; text-align: left; cursor: pointer; }
button.stat.wide:hover { border-color: var(--line-strong); }
.dot.bad { background: var(--bad); }

.train-list { display: grid; gap: 7px; }
.train-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.train-row.main { border-color: currentColor; }
.train-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 50%; background: var(--bg-0); border: 1.5px solid currentColor; font-size: 11px; font-weight: 800; }
.train-icon.atk { color: #ff9a8a; } .train-icon.hp { color: var(--hp); } .train-icon.def { color: #9bb4d1; }
.train-row .item-text small b { display: inline; color: var(--text); font-size: 12px; }
.train-row .btn { display: grid; gap: 0; line-height: 1.2; min-width: 86px; padding: 5px 10px; }
.train-row .btn small { font-size: 11px; }

.triangle-box { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; align-items: center; margin-bottom: 10px; padding: 10px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.triangle svg { display: block; width: 100%; height: auto; }
.triangle text { font: 700 11px var(--font); fill: var(--text); }
.triangle .node { stroke-width: 2; fill: var(--bg-0); }
.triangle .node.mine { stroke-width: 4; }
.triangle .arrow { fill: none; stroke: var(--muted); stroke-width: 1.6; }
/* The element cycle (skills): a ring of four plus the Holy/Dark pair. */
.element-box { grid-template-columns: minmax(150px, 210px) minmax(0, 1fr); margin-top: 8px; }
.element-cycle .arrow { stroke-width: 2.2; }
.element-cycle .el-icon { font-size: 13px; font-weight: 400; }
.element-cycle .el-name { font-size: 9px; font-weight: 700; }
.element-cycle .halo { opacity: 0.22; }
@media (max-width: 420px) { .element-box { grid-template-columns: 1fr; } .element-cycle svg { max-width: 230px; margin: 0 auto; } }

/* Skills: the job line, the six elements, the five attack slots and the book of skills. */
.job-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 6px; }
.job-line > i { font-style: normal; color: var(--muted); }
.job-step { padding: 3px 10px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); font-size: 12.5px; font-weight: 700; color: var(--muted); }
.job-step.active { background: var(--bg-3); border-color: var(--accent); color: var(--text); }
.job-step.locked { border-style: dashed; font-weight: 600; }
.job-line .btn { margin-left: auto; }
.skill-elements { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.element { display: grid; justify-items: center; gap: 0; padding: 7px 2px 6px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 0; }
.element span { font-size: 19px; line-height: 1.25; }
.element b { font-size: 11.5px; white-space: nowrap; }
.element small { color: var(--muted); font-size: 10.5px; }
.element.on { background: color-mix(in srgb, var(--el) 20%, var(--bg-2)); border-color: var(--el); opacity: 1; }
.element.on small { color: var(--el); font-weight: 700; }
.element:disabled:not(.on) { opacity: 0.5; }
/* The "learn this element for real?" window. */
.element-confirm { width: min(100%, 360px); justify-items: center; gap: 10px; border-color: color-mix(in srgb, var(--el, var(--accent)) 55%, var(--line)); }
.element-confirm h2, .element-confirm p { margin: 0; }
.element-confirm-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; font-size: 32px; line-height: 1; background: color-mix(in srgb, var(--el) 22%, var(--bg-2)); border: 2px solid var(--el); box-shadow: 0 0 22px color-mix(in srgb, var(--el) 35%, transparent); }
.element-confirm-cost { font-size: 14px; }
.element-confirm-cost b { color: var(--el); font-size: 16px; }
.element-confirm-cost small { color: var(--muted); font-size: 12px; }
.element-warn { width: 100%; padding: 8px 10px; border-radius: var(--radius-small); background: color-mix(in srgb, var(--bad) 12%, var(--bg-2)); border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--line)); color: var(--bad); font-size: 12.5px; }
.confirm-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-top: 2px; }
.el-badge { display: inline-grid; place-items: center; width: 18px; height: 18px; margin: 0 2px; border-radius: 50%; background: color-mix(in srgb, var(--el) 25%, var(--bg-0)); border: 1px solid var(--el); font-size: 10px; vertical-align: 1px; }
.el-tag { display: inline-flex; align-items: center; gap: 2px; padding: 0 5px; border-radius: 99px; background: var(--bg-0); border: 1px solid var(--line-strong); font-size: 10.5px; line-height: 1.5; white-space: nowrap; }
.el-tag small { font-size: 10px; font-weight: 700; color: var(--muted); }
.el-tag.weak { border-color: rgba(107, 212, 154, 0.7); } .el-tag.weak small { color: var(--good); }
.el-tag.own { border-color: var(--el); background: color-mix(in srgb, var(--el) 18%, var(--bg-0)); } .el-tag.own small { color: var(--text); }
.el-tag.strong, .el-tag.immune { border-color: rgba(239, 118, 118, 0.6); } .el-tag.strong small, .el-tag.immune small { color: var(--bad); }
.skill-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.slot { position: relative; display: grid; justify-items: center; align-content: start; gap: 2px; padding: 16px 2px 5px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line-strong); min-width: 0; min-height: 96px; text-align: center; cursor: pointer; }
.slot.empty { border-style: dashed; align-content: center; padding-top: 5px; color: var(--muted); }
.slot.target { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(108, 182, 255, 0.2); }
.slot > b { width: 100%; padding: 0 2px; font-size: 10.5px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot > small { font-size: 11px; }
.slot-key { position: absolute; left: 6px; top: 2px; font-size: 10px; color: var(--muted); font-weight: 700; }
.slot-mode { width: calc(100% - 4px); padding: 1px 2px; border-radius: 7px; background: var(--bg-0); border: 1px solid var(--line); font-size: 10px; font-weight: 600; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-mode small { display: none; }
.slot-mode:disabled { opacity: 0.55; }
.slot-clear { position: absolute; right: 0; top: -2px; width: 22px; height: 22px; color: var(--muted); font-size: 15px; }
.skill-icon { position: relative; display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 9px; background: var(--bg-0); border: 1px solid var(--line-strong); overflow: hidden; }
.skill-icon i { font-style: normal; font-weight: 800; font-size: 16px; color: var(--muted); }
.skill-icon[data-kind="attack"] i { color: #ff9a8a; } .skill-icon[data-kind="buff"] i { color: var(--accent); } .skill-icon[data-kind="passive"] i { color: var(--good); }
.skill-icon img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; background: var(--bg-0); }
.skills-list { display: grid; gap: 7px; }
.skill-card { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.skill-card.learned { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.skill-card.loser { opacity: 0.6; }
.skill-text { flex: 1; min-width: 0; }
.skill-text > b { display: block; font-size: 13.5px; }
.skill-text > b em { float: right; font-style: normal; font-weight: 700; font-size: 12px; color: var(--muted); }
.skill-card.learned .skill-text > b em { color: var(--accent); }
.skill-text small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.skill-text small.now { color: var(--good); }
.tag.kind { background: var(--bg-0); }
.tag.off { background: rgba(239, 118, 118, 0.15); color: var(--bad); }
.skill-buttons { display: grid; gap: 4px; justify-items: stretch; flex: none; min-width: 58px; }
.skill-buttons .btn { padding: 4px 8px; }
.skill-buttons .tag { text-align: center; }
.btn.danger { background: var(--bad); border-color: transparent; color: #1b0808; }

/* Tower: the floors of a zone, then the monster book. */
.tower-modes { display: flex; margin-bottom: 10px; }
.tower-modes button { flex: 1; }
.tower-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 0; }
.tower-nav b { font-size: 13px; text-align: center; }
.tower-list { display: grid; gap: 6px; }
.tower-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.tower-row.here { border-color: var(--accent); background: var(--sel); }
.tower-row.locked { opacity: 0.6; }
.tower-number { position: relative; display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--bg-0); border: 1.5px solid var(--line-strong); font-weight: 800; font-size: 13px; }
.tower-number i { position: absolute; right: -3px; bottom: -3px; display: grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--good); color: #0b1a12; font-style: normal; font-size: 10px; }
.tower-row.boss .tower-number { border-color: var(--gold); color: var(--gold); }
.tower-info { flex: 1; min-width: 0; }
.tower-info > small { display: block; color: var(--muted); font-size: 11.5px; }
.tower-row.boss .tower-info > small { color: var(--gold); font-weight: 700; }
.tower-info .good { color: var(--good); }
.tower-mobs { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; }
.tower-mob { display: inline-grid; grid-template-columns: 28px auto; align-items: center; column-gap: 5px; font-size: 12px; min-width: 0; }
.tower-mob .mob-pic { grid-row: span 2; }
.tower-mob > small { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tower-mob > span:last-child { display: flex; flex-wrap: wrap; gap: 2px; }
.tower-mob .attr-chip { padding: 0 5px; font-size: 10px; border-width: 1px; }
.tower-mob .attr-chip.none { display: none; }
.mob-pic { display: grid; place-items: center; width: 28px; height: 28px; flex: none; }
/* Monster thumbnails are only ever made smaller: smooth shrinking keeps them whole (pixelated shrinking drops pixels). */
.mob-pic img { max-width: 100%; max-height: 100%; object-fit: contain; image-rendering: auto; }
.mob-pic.big { width: 56px; height: 56px; border-radius: 10px; background: var(--bg-0); }
.book-tools { display: flex; align-items: center; gap: 8px; }
.book-tools input { flex: 1; min-width: 0; }
.book-list { display: grid; gap: 7px; }
.book-card { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 4px 10px; padding: 8px 10px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); cursor: pointer; }
.book-card.boss { border-color: rgba(242, 201, 107, 0.5); }
.book-card.open { background: var(--sel); }
.book-card.unseen .mob-pic img { filter: brightness(0.25) saturate(0); }
.book-text { min-width: 0; }
.book-text > b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-text > b em { font-style: normal; font-size: 11px; color: var(--gold); }
.book-text > small { display: block; color: var(--muted); font-size: 11.5px; }
.book-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.book-tags .attr-chip { padding: 0 6px; font-size: 10.5px; }
.book-tags .attr-chip.none { display: none; }
.book-numbers { display: grid; justify-items: end; font-size: 11.5px; color: var(--muted); }
.book-numbers b { color: var(--text); }
.book-detail { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.book-detail div { display: grid; }
.book-detail div small { color: var(--muted); font-size: 10.5px; }
.book-detail div b { font-size: 13px; }
.book-detail p { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.book-detail > .btn, .book-detail > small { grid-column: 1 / -1; justify-self: start; }

/* Character: the job box and the long list of stats. */
.job-box { display: grid; gap: 8px; margin-bottom: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.job-now { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.job-now > span { display: grid; line-height: 1.25; }
.job-now > span small { color: var(--muted); font-size: 11px; }
.job-now > span b { font-size: 16px; color: var(--gold); }
.job-now > small { flex: 1; min-width: 90px; color: var(--muted); font-size: 11.5px; }
.job-next { display: grid; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.job-next small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.job-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.job-confirm { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px; border-radius: 99px; background: var(--bg-0); border: 1px solid var(--gold); font-size: 12.5px; }
.more-stats { margin-top: 8px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.more-stats summary { padding: 8px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-lines { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; padding: 0 12px 10px; }
.stat-lines div { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.stat-lines small { color: var(--muted); font-size: 12px; }
.stat .attr-chip + .attr-chip { margin-left: 3px; }
.me-styles { display: flex; gap: 4px; }
.me-styles .attr-chip { padding: 0 6px; font-size: 10.5px; }
.job-tag { flex: none; color: var(--gold); font-size: 11px; font-weight: 700; white-space: nowrap; }

/* G-Coin: the account's premium money, pink so it is never mistaken for Gold or Gems. */
.coin.gcoin { border: 1px solid color-mix(in srgb, var(--gcoin) 45%, transparent); }
.coin.gcoin i, .gcoin-chip i { width: 10px; height: 10px; flex: none; background: var(--gcoin); border-radius: 3px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25); }
.coin.gcoin .icon { width: 13px; height: 13px; color: var(--gcoin); }
.gcoin-chip { cursor: pointer; border-color: color-mix(in srgb, var(--gcoin) 45%, transparent); color: var(--gcoin); font-weight: 700; }
.gcoin-text { color: var(--gcoin); }
.price.gcoin::before { background: var(--gcoin); border-radius: 3px; }
.item-row.premium { border-color: color-mix(in srgb, var(--gcoin) 40%, transparent); background: linear-gradient(90deg, color-mix(in srgb, var(--gcoin) 9%, var(--bg-2)), var(--bg-2) 60%); }
.item-text small .option { color: var(--gcoin); font-weight: 600; }
.item-row.premium .item-text small .plus, .item-row.premium .item-text small .option,
.item-text small .premium-stat, .bag-pick small .premium-stat { color: var(--gcoin); font-weight: 700; }
.train-times { display: flex; margin: 8px 0 10px; }
.train-times button { flex: 1; }
.train-row.attr-lifesteal.main, .train-row.attr-reflect.main, .train-row.attr-regen.main, .train-row.attr-evade.main, .train-row.attr-agility.main, .train-row.attr-skill.main { border-color: currentColor; }
.train-row .item-text, .train-row .btn { color: var(--text); }
.train-row .train-icon { color: inherit; font-size: 10px; text-align: center; line-height: 1.1; }
.train-row:not([class*="attr-"]) .train-icon { font-size: 11px; }

.social-panel { min-width: 0; }

/* Job tests: the list of tasks (character view and the instructor's window). */
.quest-tasks { list-style: none; display: grid; gap: 4px; margin: 6px 0; padding: 0; }
.quest-tasks li { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 9px; background: var(--bg-0); border: 1px solid var(--line); font-size: 12.5px; }
.quest-tasks li span { color: var(--muted); }
.quest-tasks li b { font-size: 12px; white-space: nowrap; }
.quest-tasks li.done { border-color: rgba(107, 212, 154, 0.5); }
.quest-tasks li.done span, .quest-tasks li.done b { color: var(--good); }

/* ---- 9. Pop-ups -------------------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(5, 8, 13, 0.6); backdrop-filter: blur(3px); }
.modal-card { position: relative; display: grid; gap: 12px; width: min(100%, 440px); max-height: 90vh; overflow: auto; text-align: center; }
.modal-card.wide-card { width: min(100%, 560px); text-align: left; }
.modal-close { position: absolute; right: 10px; top: 10px; color: var(--muted); }
.guide-card { gap: 8px; }
.guide-title { display: flex; align-items: center; gap: 8px; padding-right: 36px; }
.guide-title .icon { color: var(--accent); }
.guide-intro { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); color: var(--muted); font-size: 13px; line-height: 1.5; }
.guide-body { display: grid; gap: 8px; }
.guide-start { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 10%, var(--bg-2)); border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--line)); }
.guide-start h3 { margin: 0 0 5px; font-size: 13.5px; color: var(--accent); }
.guide-start ol, .guide-topic-body ul { display: grid; gap: 5px; margin: 0; padding-left: 20px; font-size: 12.5px; line-height: 1.48; }
.guide-topic { padding: 0 11px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.guide-topic summary { padding: 10px 0; cursor: pointer; font-size: 13px; font-weight: 700; }
.guide-topic[open] summary { color: var(--accent); }
.guide-topic-body { padding: 0 0 10px; font-size: 12.5px; line-height: 1.48; }
.guide-topic-body p { margin: 8px 0 0; }
.guide-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.guide-controls > div { display: grid; gap: 2px; padding: 7px 9px; border-radius: 8px; background: var(--bg-1); }
.guide-controls b { font-size: 12px; }
.guide-controls span, .guide-note { color: var(--muted); font-size: 11.5px; }
.guide-note { line-height: 1.45; }
.guide-damage-key { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.guide-damage-item { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 6px 8px; border-radius: 8px; background: var(--bg-1); font-size: 11.5px; }
.guide-damage-item i { width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--damage); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); }
.guide-damage-item span { min-width: 0; }
.egg-buttons { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.gem-text { color: var(--gem); }
.egg-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.egg-card { display: grid; justify-items: center; gap: 1px; padding: 6px 4px 8px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); font-size: 12px; }
.egg-card small { color: var(--muted); font-size: 11px; }
.egg-card.new { border-color: var(--gold); box-shadow: 0 0 14px rgba(242, 201, 107, 0.25); }
.egg-card.new small { color: var(--gold); font-weight: 700; }
.offline-rewards { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.offline-rewards div { display: grid; padding: 10px 6px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.offline-rewards i { font-style: normal; color: var(--gold); }
.offline-rewards b { font-size: 16px; }
.offline-rewards small { color: var(--muted); font-size: 11.5px; }
.guild-head { display: flex; align-items: center; gap: 10px; }
.guild-head div { flex: 1; }
.guild-head small { display: block; color: var(--muted); }
.guild-donate { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0; color: var(--muted); font-size: 12.5px; }
.guild-create { display: flex; gap: 8px; margin-bottom: 12px; }
.guild-emblem { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 11px; border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line)); background: linear-gradient(145deg, color-mix(in srgb, var(--gold) 16%, var(--bg-2)), var(--bg-0)); }
.guild-emblem img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.guild-emblem.large { width: 50px; height: 50px; border-radius: 14px; }
.guild-emblem-form { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); font-size: 12px; }
.guild-emblem-form:has(.guild-icon-picker.open) .guild-emblem-field { flex: 1 0 100%; }
.guild-emblem-form:has(.guild-icon-picker.open) > button { margin-left: auto; }
.guild-emblem-field, .guild-create-emblem { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; min-width: 0; color: var(--muted); }
.guild-emblem-field { flex: 1; }
.guild-create-emblem { flex: 0 1 170px; }
.guild-create-emblem:has(.guild-icon-picker.open) { flex: 1 0 100%; }
.guild-icon-picker { display: contents; }
.guild-icon-picker-trigger { grid-column: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 76px; height: 40px; padding: 4px 8px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--bg-0); color: var(--text); cursor: pointer; }
.guild-icon-picker-trigger [data-guild-emblem-current] { width: 26px; height: 26px; object-fit: contain; }
.guild-icon-picker-caret { color: var(--muted); font-size: 12px; }
.guild-icon-picker-grid { display: none; grid-column: 1 / -1; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; max-height: min(248px, 38vh); overflow-y: auto; align-content: start; padding: 6px; border-radius: 10px; background: var(--bg-0); border: 1px solid var(--line-strong); scrollbar-width: thin; }
.guild-icon-picker.open .guild-icon-picker-grid { display: grid; }
.guild-icon-picker-grid button { display: grid; place-items: center; min-width: 0; aspect-ratio: 1; padding: 0; border: 1px solid transparent; border-radius: 7px; background: var(--bg-2); font-family: inherit; font-size: 20px; line-height: 1; cursor: pointer; }
.guild-icon-picker-grid img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.guild-icon-picker-grid button:hover, .guild-icon-picker-grid button.selected { background: color-mix(in srgb, var(--gold) 18%, var(--bg-2)); border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); }
.guild-create { flex-wrap: wrap; }
.guild-subtabs { display: flex; width: 100%; margin: 12px 0 6px; }
.guild-subtabs button { flex: 1; }
.guild-subcontent { min-width: 0; }
.social-tabs { display: flex; width: 100%; margin-bottom: 10px; }
.social-tabs button { flex: 1; }
.social-content { display: grid; gap: 8px; min-width: 0; }
.social-content h3 { margin: 5px 0 0; font-size: 13px; }
.guild-list { display: grid; gap: 6px; margin: 8px 0 12px; }
.guild-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); font-size: 13px; }
.guild-row b { flex: 1; min-width: 0; }
.guild-row small { color: var(--muted); }
.guild-row span { color: var(--muted); font-size: 12.5px; }
.guild-row .presence-dot { width: 8px; height: 8px; padding: 0; flex: none; border-radius: 50%; background: #6f7c8e; }
.guild-row .presence-dot.online, .presence-dot.online { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 14%, transparent); }
.friend-add { display: flex; gap: 7px; }
.friend-add input { min-width: 0; flex: 1; }
.friend-list { display: grid; gap: 6px; }
.friend-row, .friend-request, .party-member { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 7px 8px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.friend-row { display: grid; grid-template-columns: 8px minmax(80px, 1fr) auto auto; }
.friend-request > div, .friend-info { display: grid; min-width: 0; flex: 1; }
.friend-info b, .friend-request b, .party-member b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.friend-info small, .friend-request small, .party-member small { color: var(--muted); font-size: 11px; }
.presence-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: #6f7c8e; }
.friend-request { flex-wrap: wrap; }
.friend-request .btn, .friend-row .btn { padding: 5px 7px; font-size: 11px; }
.party-card { display: grid; gap: 6px; padding: 9px; border-radius: 11px; background: color-mix(in srgb, var(--accent) 8%, var(--bg-2)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); }
.party-card > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.party-members { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 5px; }
.party-member { display: grid; gap: 2px; }
.party-member.leader b { color: var(--gold); }
.party-member-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.party-member-actions .btn { padding: 4px 6px; font-size: 10px; }
.party-modal-card { width: min(100%, 600px); max-height: min(86vh, 720px); }
.party-modal-card > header { display: grid; gap: 2px; padding-right: 36px; }
.party-modal-card h2 { margin: 0; color: var(--gold); }
.party-content { display: grid; gap: 12px; min-height: 90px; overflow-y: auto; }
.party-content > section { display: grid; gap: 7px; }
.party-content h3 { margin: 0; font-size: 13px; }
.party-content .party-card { margin: 0; }
.party-invite-list { display: grid; gap: 5px; }
.party-invite-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; padding: 7px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); }
.party-invite-row > div { display: grid; min-width: 0; gap: 2px; }
.party-invite-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.party-invite-row small { color: var(--muted); font-size: 11px; }
.party-invite-actions { display: flex; flex: none; gap: 5px; }

/* The bag: worn slots around the hero on the left, a grid of everything owned on the right. */
.bag-modal { padding: 12px; }
.bag-shell { display: flex; flex-direction: column; width: min(100%, 940px); height: min(94vh, 620px); border-radius: 18px; background: var(--bg-1); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.bag-head { position: relative; display: flex; align-items: center; gap: 8px; padding: 10px 56px 10px 16px; border-bottom: 1px solid var(--line); }
.bag-head h2 { margin-right: auto; }
.bag-head .modal-close { top: 6px; }
.bag-mode-nav { flex: none; padding: 8px 12px 0; }
.bag-mode-nav .bag-modes { display: flex; width: min(100%, 460px); margin: 0 auto; }
.bag-body { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); min-height: 0; flex: 1; }
.bag-left { display: grid; align-content: start; gap: 10px; padding: 12px; border-right: 1px solid var(--line); overflow-y: auto; }
.bag-modes { display: flex; }
.bag-modes button { flex: 1; }
.bag-pets-body { grid-column: 1 / -1; min-width: 0; min-height: 0; padding: 12px; overflow-y: auto; }
.bag-pets-body .pet-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.bag-doll { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.doll-slots { display: grid; grid-template-columns: repeat(2, 52px); gap: 6px; align-content: start; }
.doll-slot-wrap { position: relative; width: 100%; aspect-ratio: 1; }
.doll-slot-wrap > .cell { width: 100%; height: 100%; }
.doll-fashion-check { position: absolute; z-index: 2; top: 5px; right: 5px; display: grid; place-items: center; width: 16px; height: 16px; padding: 0; border: 0; border-radius: 4px; background: rgba(8, 15, 26, .94); cursor: pointer; }
.doll-fashion-check input { appearance: none; display: grid; place-items: center; width: 12px; height: 12px; min-height: 0; margin: 0; padding: 0; border: 1px solid var(--line-strong); border-radius: 3px; background: var(--bg-0); cursor: pointer; }
.doll-fashion-check input:checked { border-color: var(--accent); background: var(--accent); }
.doll-fashion-check input:checked::after { content: '✓'; color: #071321; font-size: 10px; font-weight: 900; line-height: 1; }
.doll-mid { display: grid; justify-items: center; align-content: center; gap: 1px; min-width: 0; text-align: center; }
.doll-mid small { color: var(--muted); font-size: 11.5px; }
.doll-mid > b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doll-mid .avatar-canvas { width: min(100%, 150px); height: 136px; }   /* the character is fitted inside (preview.js) */
.doll-power { padding: 2px 12px; border-radius: 99px; background: var(--bg-0); border: 1px solid var(--line-strong); color: var(--gold); font-size: 12.5px; }
.bag-right { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.bag-cats { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.bag-cats button { display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px; border-radius: 10px 10px 0 0; color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; border-bottom: 2px solid transparent; }
.bag-cats button .icon { width: 17px; height: 17px; }
.bag-cats button b { font-size: 11px; color: var(--muted); }
.bag-cats button.active { color: var(--text); background: var(--bg-2); border-bottom-color: var(--accent); }
.bag-cats button.active b { color: var(--accent); }
.bag-grid { flex: 1; min-height: 120px; display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 7px; align-content: start; padding: 10px; overflow-y: auto; }
.cell { position: relative; display: grid; place-items: center; aspect-ratio: 1; min-width: 0; border-radius: 10px; background: var(--bg-2); border: 2px solid var(--frame, var(--frame-0)); overflow: hidden; }
.cell img { max-width: 78%; max-height: 78%; }
.cell > span:not(.potion-art) { color: var(--muted); }
.cell.t-fine { --frame: #58c47b; } .cell.t-rare { --frame: #5aa8f2; } .cell.t-epic { --frame: #a66be0; } .cell.t-gcoin { --frame: var(--gcoin); background: color-mix(in srgb, var(--gcoin) 10%, var(--bg-2)); }
.cell.potion { --frame: #7a8aa3; }
.cell.picked { box-shadow: 0 0 0 2px var(--accent); background: var(--sel); }
.cell.worn { background: color-mix(in srgb, var(--frame, var(--frame-0)) 16%, var(--bg-2)); }
.cell > i { position: absolute; left: 0; top: 0; padding: 0 5px; border-radius: 0 0 7px 0; background: var(--frame, var(--frame-0)); color: #0b111a; font-style: normal; font-size: 9.5px; font-weight: 800; line-height: 1.5; }
.cell > em { position: absolute; left: 0; right: 0; bottom: 0; font-style: normal; font-size: 9px; font-weight: 700; line-height: 1.45; text-align: center; background: rgba(6, 10, 16, 0.72); color: #dbe4f0; }
.cell > b { position: absolute; right: 3px; bottom: 1px; font-size: 10.5px; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.cell.potion > em { left: auto; right: 0; top: 0; bottom: auto; padding: 0 4px; border-radius: 0 0 0 6px; background: rgba(107, 212, 154, 0.85); color: #06210f; }
.cell .potion-art { width: 74%; height: 74%; }
.cell.doll.empty { border-style: dashed; border-color: var(--line-strong); background: var(--bg-0); }
.cell.doll.empty small { padding: 0 2px; color: var(--placeholder); font-size: 9.5px; line-height: 1.15; text-align: center; overflow-wrap: anywhere; }
.bag-detail { display: none; position: absolute; z-index: 5; top: 54px; right: 12px; width: min(370px, calc(100% - 24px)); max-height: min(70vh, 500px); overflow: auto; border: 1px solid var(--win-edge); border-radius: 16px; background: linear-gradient(180deg, var(--win-top), var(--win-bottom)); box-shadow: 0 16px 42px rgba(0, 0, 0, 0.48), inset 0 1px 0 var(--win-shine); }
.bag-detail.open { display: block; }
.item-preview-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 11px; padding: 12px; background: var(--title-bar); color: var(--title-text); border-bottom: 1px solid var(--win-edge); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22); }
.item-preview-icon { display: grid; place-items: center; width: 58px; height: 58px; flex: none; border-radius: 12px; background: rgba(8, 15, 26, 0.72); border: 1px solid rgba(210, 229, 255, 0.35); }
.item-preview-icon .cell { width: 50px; height: 50px; background: var(--bg-2); }
.item-preview-icon .cell.potion { width: 48px; height: 48px; background: transparent; border: 0; }
.item-preview-head > div { min-width: 0; flex: 1; }
.item-preview-head h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.item-preview-head small { display: block; margin-top: 2px; color: rgba(255, 255, 255, 0.78); font-size: 11.5px; }
.item-preview-close { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 8px; color: rgba(255, 255, 255, 0.75); font-size: 23px; line-height: 1; }
.item-preview-close:hover { color: #fff; background: rgba(255, 255, 255, 0.14); }
.item-preview-body { display: grid; gap: 8px; padding: 12px 14px 8px; }
.item-preview-meta { display: flex; justify-content: flex-end; color: var(--muted); font-size: 11.5px; }
.item-equipped { color: var(--good); font-weight: 700; }
.item-preview-stats { display: grid; gap: 5px; }
.item-preview-stats h4 { margin: 0 0 2px; padding-bottom: 5px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11.5px; font-weight: 650; }
.item-preview-stat { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--text); font-size: 12.5px; }
.item-preview-stat b { color: var(--good); text-align: right; }
.item-preview-stat.requirement { color: var(--muted); font-size: 11.5px; }
.item-preview-stat.requirement b { color: var(--text); }
.item-preview-muted { color: var(--muted); font-size: 12px; line-height: 1.45; }
.item-preview-description { padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.5; }
.item-preview-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 12px; border-top: 1px solid var(--line); background: rgba(0, 0, 0, 0.12); }
.item-preview-actions .btn { flex: 1 1 auto; }
.bag-pick { display: flex; align-items: center; gap: 10px; }
.bag-pick > .cell { width: 46px; flex: none; }
.bag-pick > div { min-width: 0; display: grid; gap: 1px; }
.bag-pick b { font-size: 13.5px; }
.bag-pick b em { font-style: normal; color: var(--muted); font-size: 12px; }
.bag-pick small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.bag-pick small .plus, .bag-pick small.plus { color: var(--good); font-weight: 600; }
.bag-pick small .option { color: var(--gcoin); font-weight: 600; }
.tier-fine { color: #58c47b; } .tier-rare { color: #5aa8f2; } .tier-epic { color: #a66be0; } .tier-gcoin { color: var(--gcoin); }
.potion-auto { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 4px; }
.potion-auto .btn.small { min-height: 28px; padding: 2px 9px; }
.bag-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px calc(8px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--bg-2); }
.bag-foot .chip .icon { width: 14px; height: 14px; }
.bag-trash { display: inline-flex; align-items: center; gap: 5px; border: 1px solid color-mix(in srgb, #ef6473 55%, var(--line)); background: color-mix(in srgb, #ef6473 16%, var(--bg-2)); color: #ffb4bc; }
.bag-trash .icon { width: 15px; height: 15px; }
.bag-trash:disabled { opacity: .45; cursor: not-allowed; }
.appearance-only { cursor: default; }
.potion-slot-tools { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 2px 0 8px; border-bottom: 1px solid var(--line); }
.potion-slot-tools > small { color: var(--muted); font-size: 11.5px; }
.potion-slot-tools > div { display: flex; gap: 6px; }
.potion-slot { width: 48px; min-height: 48px; aspect-ratio: 1; }
.potion-slot > small { position: absolute; right: 3px; bottom: 1px; font-size: 9px; color: var(--muted); }
.bag-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px; }
.bag-actions .btn.small { min-width: 74px; }

/* Talking to an NPC in the market. */
.npc-card { position: relative; max-height: 88vh; grid-template-rows: auto auto auto minmax(0, 1fr); overflow: hidden; }
.npc-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; padding-right: 40px; }
.npc-head h2 { color: var(--gold); }
.npc-purse { display: flex; gap: 5px; margin-left: auto; }
.npc-say { padding: 8px 12px; border-radius: 12px 12px 12px 2px; background: var(--bg-2); border: 1px solid var(--line); font-size: 13px; }
.npc-card .chips { margin: 0; align-items: center; }
.npc-body { overflow-y: auto; min-height: 80px; padding-right: 2px; }
.stylist-layout { display: grid; grid-template-columns: minmax(150px, 200px) minmax(0, 1fr); gap: 12px; align-items: start; }
.stylist-showcase { position: sticky; top: 0; display: grid; gap: 10px; justify-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); text-align: center; }
.stylist-preview { display: grid; place-items: center; width: 100%; min-height: 190px; border-radius: 12px; background: var(--bg-0); }
.stylist-preview .avatar-canvas { width: 180px; height: 180px; }
.stylist-note { color: var(--muted); font-size: 12px; }
.stylist-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.stylist-picker { min-width: 0; }
.stylist-picker .picker-grid { max-height: min(54vh, 450px); }
.npc-item-preview { position: absolute; z-index: 5; right: 10px; bottom: 10px; width: min(330px, calc(100% - 20px)); max-height: min(58vh, 440px); overflow: auto; border: 1px solid var(--win-edge); border-radius: 12px; background: var(--win-bottom); box-shadow: var(--shadow); pointer-events: none; }
.npc-item-preview .item-preview-head { position: sticky; top: 0; }
.npc-item-preview .item-preview-icon .item-icon { width: 50px; height: 50px; background: transparent; }
.npc-item-preview .item-preview-icon .item-icon img { max-width: 48px; max-height: 48px; }
.npc-shop-preview-icon { width: 50px; height: 50px; object-fit: contain; }
.npc-item-preview .item-preview-body { gap: 7px; }
.npc-body .item-row[data-shop-preview] { cursor: help; }
.npc-body .item-row[data-shop-preview]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.quest-box { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.quest-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.quest-head b { font-size: 15px; }
.quest-buttons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* The passive tree: a full-window map with tool buttons and two fold-away panels. */
.tree-modal { display: block; padding: 0; }
.tree-modal.hidden { display: none; }
.tree-shell { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--tree-bg); }
.tree-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: calc(8px + var(--safe-top)) calc(54px + var(--safe-right)) 8px calc(14px + var(--safe-left)); border-bottom: 1px solid var(--line); }
.tree-head h2 { font-size: 17px; margin-right: auto; }
.tree-head .modal-close { top: calc(8px + var(--safe-top)); right: calc(10px + var(--safe-right)); }
.skill-window-tabs { flex: none; }
.tree-window-tabs { margin: 8px calc(14px + var(--safe-left)) 0; width: auto; }
.tree-body { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#treeCanvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.tree-tools { position: absolute; left: calc(10px + var(--safe-left)); bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 20px); }
.tree-tools .btn { background: var(--glass-strong); }
.tree-panel { position: absolute; right: calc(10px + var(--safe-right)); top: 10px; width: 226px; max-height: calc(100% - 70px); overflow: auto; padding: 10px 12px; border-radius: 12px; background: var(--glass-strong); border: 1px solid var(--line); }
.tree-panel.legend { top: auto; bottom: 54px; right: auto; left: calc(10px + var(--safe-left)); width: 250px; }
.tree-panel.folded { display: none; }
.tree-panel h3 { font-size: 13px; margin-bottom: 6px; }
.tree-counts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 8px; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.tree-counts span { display: flex; align-items: center; gap: 5px; }
.tree-counts i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.tree-counts b { margin-left: auto; color: var(--text); }
.tree-bonuses { display: grid; gap: 0; }
.tree-bonuses div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.tree-bonuses small { color: var(--muted); }
.tree-bonuses b { color: var(--good); }
.tree-bonuses .minus b { color: var(--bad); }
.tree-legend { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.tree-legend div { display: flex; align-items: center; gap: 8px; }
.tree-legend hr { border: 0; border-top: 1px solid var(--line); width: 100%; }
.tree-legend .dot { position: static; border: 0; width: 10px; height: 10px; }
.shape { width: 14px; height: 14px; flex: none; border: 2px solid var(--muted); border-radius: 50%; }
.shape.notable { border-radius: 3px; width: 16px; height: 16px; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); background: var(--muted); }
.shape.keystone { border-radius: 0; transform: rotate(45deg); }
.shape.owned { background: var(--gold); border-color: #fff3c4; }
.shape.open { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108, 182, 255, 0.25); }
.tree-node { position: absolute; left: 50%; bottom: 54px; transform: translateX(-50%); display: grid; gap: 4px; width: min(300px, calc(100% - 20px)); padding: 12px 14px; border-radius: 14px; background: var(--glass-strong); border: 1px solid var(--line-strong); box-shadow: var(--shadow); text-align: center; }
.tree-node > b { font-size: 15px; }
.tree-node > small { color: var(--muted); font-size: 11.5px; }
.tree-node .tag, .tree-node .btn { justify-self: center; }
.tree-node p { font-size: 13.5px; color: var(--good); line-height: 1.5; }
.tree-node-close { position: absolute; right: 4px; top: 4px; width: 26px; height: 26px; color: var(--muted); }
.tree-foot { padding: 6px 14px calc(8px + var(--safe-bottom)); border-top: 1px solid var(--line); text-align: center; }

/* Topping up G-Coin. */
.topup-packages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.topup-pack { display: grid; justify-items: center; gap: 1px; padding: 12px 6px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.topup-pack:hover { border-color: var(--gcoin); }
.topup-pack b { font-size: 19px; }
.topup-pack small { color: var(--muted); font-size: 11.5px; }
.topup-pack small em { font-style: normal; color: var(--good); }
.topup-pack span { margin-top: 5px; padding: 2px 12px; border-radius: 99px; background: var(--bg-0); font-weight: 700; font-size: 13px; }
.topup-pay { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; }
.qr-box { display: grid; justify-items: center; gap: 6px; }
.qr-box canvas { width: 220px; height: 220px; border-radius: 10px; background: #fff; image-rendering: pixelated; }
.qr-box small { color: var(--muted); font-size: 11.5px; }
.topup-detail { display: grid; gap: 1px; }
.topup-detail small { color: var(--muted); font-size: 11.5px; margin-top: 5px; }
.topup-detail b { font-size: 14.5px; overflow-wrap: anywhere; }
.topup-amount { font-size: 26px !important; color: var(--gold); line-height: 1.1; }
.topup-amount span { font-size: 13px; color: var(--muted); }
.topup-detail .btn { justify-self: start; margin-top: 10px; }
.topup-history { display: grid; gap: 5px; }
.topup-history div { display: grid; grid-template-columns: 76px 1fr 1fr auto; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); font-size: 12.5px; }
.bar.xp.full i { background: var(--good); }


/* ---- 10. MapleStory skin ------------------------------------------------------------ */
/* Everything above sets layout; this part gives it the MapleStory PC look in both themes. */
.tree-modal, .feed, .actions, .pad-left { color: var(--text); }

/* Windows: a body that fades darker downwards, a steel edge, a thin shine along the top,
   and a strip of the blue title bar across the top of cards and pop-ups. */
.card, .modal-card {
  background: var(--title-bar) top / 100% 5px no-repeat, linear-gradient(180deg, var(--win-top), var(--win-bottom));
  border: 1px solid var(--win-edge);
  box-shadow: var(--shadow), inset 0 1px 0 var(--win-shine);
}
.bag-shell, .sheet {
  background: linear-gradient(180deg, var(--win-top), var(--win-bottom));
  border-color: var(--win-edge);
}
.sheet { box-shadow: -14px 0 36px rgba(0, 0, 0, 0.35), inset 1px 0 0 var(--win-shine); }
.tree-panel, .tree-tools .btn { border-color: var(--win-edge); }

/* Title bars: glossy blue with white writing, as on MapleStory's windows. */
.sheet-head, .bag-head, .tree-head {
  background: var(--title-bar); color: var(--title-text);
  border-bottom: 1px solid var(--win-edge); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.bag-head h2, .tree-head h2 { color: var(--title-text); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35); }
.sheet-head .round, .bag-head .modal-close, .tree-head .modal-close { color: var(--title-text); }
.sheet-tabs button { color: rgba(255, 255, 255, 0.72); }
.sheet-tabs button:hover { color: #fff; background: rgba(255, 255, 255, 0.12); }
.sheet-tabs button.active { background: rgba(255, 255, 255, 0.22); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4); }
.tree-head input { background: rgba(255, 255, 255, 0.92); color: #18263c; border-color: rgba(255, 255, 255, 0.6); }

/* Buttons: steel-blue for ordinary ones, MapleStory's orange "OK" for the main action. */
.btn {
  background: linear-gradient(180deg, var(--btn-top), var(--btn-bottom));
  border: 1px solid var(--btn-edge); color: var(--btn-text);
  box-shadow: inset 0 1px 0 var(--win-shine);
}
.btn:hover:not(:disabled) { background: linear-gradient(180deg, color-mix(in srgb, var(--btn-top) 82%, #ffffff), var(--btn-bottom)); border-color: var(--accent); }
.btn.primary, .lobby-play {
  background: linear-gradient(180deg, var(--ok-top), var(--ok-bottom));
  border: 1px solid var(--ok-edge); color: var(--ok-text);
  text-shadow: 0 1px 0 var(--ok-shadow), 0 0 2px var(--ok-shadow);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 1px 2px rgba(0, 0, 0, 0.25);
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #ffe07a, #f7a72a); border-color: var(--ok-edge); }
.btn.gold { background: linear-gradient(180deg, #ffe892, #e2aa2a); border-color: #a87400; color: #3a2500; text-shadow: none; }
.btn.gold:hover:not(:disabled) { background: linear-gradient(180deg, #fff0b0, #ebb63a); border-color: #a87400; }
.btn.danger { background: linear-gradient(180deg, #ff8f86, #d8463d); border-color: #9c2620; color: #fff; text-shadow: 0 1px 0 #7a1712; }
.btn.danger:hover:not(:disabled) { background: linear-gradient(180deg, #ffa39b, #e2554b); border-color: #9c2620; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); text-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: var(--bg-2); border-color: transparent; color: var(--text); }
/* Selected tabs and chips: the title bar's blue. */
.segmented { background: var(--bg-0); border-color: var(--line-strong); }
.segmented button.active, .chips button.active, .picker-slot.active {
  background: var(--title-bar); color: #fff; border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}
.bag-cats button.active { color: var(--accent); }

/* The HUD over the scene: navy (or pale) glass with a steel edge. */
.glass { border-color: var(--line-strong); box-shadow: inset 0 1px 0 var(--win-shine), 0 4px 14px rgba(0, 0, 0, 0.22); }
/* The level, in MapleStory's gold. */
.lv-badge {
  background: radial-gradient(circle at 50% 30%, #fff1a8 0%, #ffcf45 45%, #e8920f 100%);
  border: 2px solid #fff5cf; color: #4a2700; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), inset 0 -2px 0 rgba(150, 70, 0, 0.35);
}
.lv-badge small { color: #7a4600; }
.lv-badge b { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6); }
/* Glossy bars on a dark track (dark in both themes, like the game's own). */
.bar, .floor-progress { background: #0a1120; border: 1px solid rgba(0, 0, 0, 0.45); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6); }
.bar span, .floor-progress em { color: #fff; }
.bar i::after, .floor-progress i::after { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 45%; border-radius: 99px 99px 0 0; background: rgba(255, 255, 255, 0.3); }
.bar.hp i { background: linear-gradient(180deg, #ff9a9a, #ee3a50 60%, #c8243a); }
.bar.mp i { background: linear-gradient(180deg, #9bd0ff, #3b8ff0 60%, #2066c4); }
.bar.xp i { background: linear-gradient(180deg, #fff3a0, #f7cc1e 60%, #d9a30a); }
.floor-progress i { background: linear-gradient(180deg, #a8f0c4, #3fbf74 60%, #2a9a59); }
.floor-progress.boss i { background: linear-gradient(180deg, #ffb0a8, #e5483f 60%, #b82c25); }
/* The main menu: MapleStory's orange buttons; the open one turns blue. */
.menu-btn .round {
  border-radius: 12px; border: 1px solid #c26a00; color: #5a2f00;
  background: linear-gradient(180deg, #ffe07a 0%, #ffbf3a 45%, #f29a12 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), inset 0 -2px 0 rgba(160, 80, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.menu-btn .round .icon { stroke-width: 2.1; }
.menu-btn:hover .round { filter: brightness(1.08); }
.menu-btn.active .round, .in-town #marketButton .round {
  background: var(--title-bar); border-color: #18355e; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3);
}
.menu-btn .dot { border-color: #fff5cf; }

/* GM gift inbox */
#mailButton { position: relative; }
.mail-card { width: min(100%, 680px); }
.mail-head { display: flex; justify-content: space-between; align-items: end; gap: 14px; padding-right: 38px; }
.mail-head h2 { margin: 0 0 3px; }
.mail-head label { display: grid; gap: 4px; min-width: min(220px, 45%); color: var(--muted); font-size: 12px; font-weight: 600; }
.mail-head select { min-height: 34px; padding: 5px 9px; }
.mail-list { display: grid; gap: 8px; max-height: min(62vh, 560px); overflow: auto; }
.mail-entry { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); }
.mail-entry.claimed { opacity: .68; }
.mail-entry-icon { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: 10px; background: var(--bg-0); }
.mail-entry-icon img { max-width: 42px; max-height: 42px; object-fit: contain; }
.mail-entry-copy { display: grid; gap: 3px; min-width: 0; flex: 1; }
.mail-entry-copy small, .mail-date { color: var(--muted); font-size: 11.5px; }
.mail-entry-copy p { margin: 0; overflow-wrap: anywhere; }
.mail-state { display: flex; align-items: center; gap: 5px; flex: none; }
.mail-state .btn.small { min-height: 28px; }
@media (max-width: 700px) {
  .mail-head { align-items: stretch; flex-direction: column; padding-right: 38px; }
  .mail-head label { min-width: 0; }
  .mail-entry { align-items: flex-start; flex-wrap: wrap; }
  .mail-state { margin-left: 58px; }
}

/* Player market listings use account G-Coin and remain in escrow while the seller plays elsewhere. */
.player-market-card { width: min(100%, 820px); max-height: min(88vh, 780px); overflow-y: auto; }
.player-market-head { padding-right: 38px; }
.player-market-head h2 { margin: 0 0 3px; }
.player-market-columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.player-market-section { display: grid; align-content: start; gap: 8px; min-width: 0; }
.player-market-section h3 { margin: 2px 0; font-size: 14px; }
.player-market-tools { display: grid; gap: 7px; }
.player-market-tools input { min-height: 34px; padding: 5px 9px; }
.player-market-filters { display: flex; gap: 5px; overflow-x: auto; padding: 1px 0 3px; scrollbar-width: thin; }
.player-market-filter { display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 5px 8px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 11px; }
.player-market-filter.active { background: var(--accent-strong); border-color: transparent; color: #fff; }
.player-market-filter small { opacity: .8; font-variant-numeric: tabular-nums; }
.player-market-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-content: start; gap: 7px; }
#playerMarketOwnListings { max-height: min(24vh, 190px); overflow: auto; }
.player-market-entry { display: grid; justify-items: center; align-content: start; gap: 5px; min-width: 0; padding: 7px 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); text-align: center; }
.player-market-entry { cursor: help; }
.player-market-entry.preview-active, .player-market-entry:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.player-market-entry > img, .player-market-entry > .player-market-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; background: var(--bg-0); object-fit: contain; }
.player-market-copy { display: grid; justify-items: center; gap: 2px; width: 100%; min-width: 0; }
.player-market-copy b { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.player-market-copy small { display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 9.5px; }
.player-market-price { color: var(--gold); font-weight: 750; white-space: normal; overflow-wrap: anywhere; font-size: 10px; }
.player-market-entry .btn { width: 100%; min-height: 27px; padding: 4px 5px; font-size: 10.5px; }
.player-market-pager { display: flex; align-items: center; justify-content: center; gap: 12px; }
.player-market-pager .btn { min-width: 34px; height: 30px; padding: 0 7px; font-size: 19px; line-height: 1; }
.player-market-pager small { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.player-market-form { display: grid; gap: 7px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-1); }
.player-market-form label { display: grid; gap: 4px; font-size: 11.5px; color: var(--muted); }
.player-market-form select, .player-market-form input { min-height: 34px; padding: 5px 8px; }
.player-market-form .wide { width: 100%; }
.player-market-item-preview { display: flex; align-items: center; gap: 9px; min-height: 50px; padding: 6px 8px; border-radius: 9px; background: var(--bg-2); }
.player-market-selected-image { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 8px; background: var(--bg-0); }
.player-market-selected-image img { max-width: 38px; max-height: 38px; object-fit: contain; }
.player-market-item-preview > span:last-child { display: grid; gap: 2px; min-width: 0; }
.player-market-item-preview b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.player-market-item-preview small { color: var(--muted); font-size: 10px; }
.player-market-preview { position: fixed; z-index: 70; width: min(330px, calc(100vw - 20px)); max-height: min(58vh, 440px); overflow: auto; border: 1px solid var(--win-edge); border-radius: 12px; background: var(--win-bottom); box-shadow: var(--shadow); pointer-events: none; text-align: left; }
.player-market-preview .item-preview-head { position: sticky; top: 0; }
.player-market-preview .item-preview-icon > img { max-width: 50px; max-height: 50px; object-fit: contain; }
.player-market-preview .item-preview-icon > .player-market-icon { display: grid; place-items: center; width: 48px; height: 48px; color: var(--muted); }
.player-market-preview .item-preview-body { gap: 7px; }
.player-market-preview .item-preview-stat b { max-width: 62%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-market-preview-price { color: var(--gold); }
@media (max-width: 700px) {
  #playerMarketOwnListings { max-height: 18vh; }
}
/* Skill and potion slots: dark quick-slots with a steel frame. */
.act { background: rgba(10, 19, 36, 0.78); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 2px 6px rgba(0, 0, 0, 0.3); }
.act:not(.empty):not(.act-potion):not(.act-wide) { border-color: var(--element, #7b9bcc); }
.hud-floor .round.ready { background: linear-gradient(180deg, var(--ok-top), var(--ok-bottom)); color: #fff; }
/* Rows and panels inside windows: a faint shine like MapleStory's inner boxes. */
.item-row, .stat, .train-row, .skill-card, .pet-card, .tower-row, .book-card, .triangle-box, .lobby-slot, .picker-item, .note, .slot { box-shadow: inset 0 1px 0 var(--win-shine); }
/* The element tags and the element cycle read in either theme. */
.el-tag { background: var(--bg-0); }
.triangle .node { fill: var(--bg-1); }
/* Effects off (Settings): no pulsing glows either. */
.no-effects .hud-floor .round.ready, .no-effects .quest-pill.ready { animation: none; }
/* World chat hidden (Settings). */
.hide-world-chat .feed-line.chat-world { display: none; }

/* The settings window. */
.settings-card { width: min(100%, 520px); gap: 6px; }
.settings-title { display: flex; align-items: center; gap: 8px; }
.settings-title .icon { color: var(--accent); }
.settings-body { display: grid; gap: 12px; }
.set-group { display: grid; gap: 6px; }
.set-group h3 { font-size: 12.5px; color: var(--accent); text-transform: none; letter-spacing: 0.2px; padding-bottom: 2px; border-bottom: 1px solid var(--line); }
.set-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--win-shine); }
.set-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.set-text b { font-size: 13.5px; }
.set-text small { color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.set-row .segmented { flex: none; }
.set-row .segmented button { padding: 5px 11px; font-size: 12.5px; }
.switch { position: relative; flex: none; width: 46px; height: 26px; border-radius: 99px; background: var(--bg-0); border: 1px solid var(--line-strong); transition: background 0.15s; }
.switch i { position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.switch.on { background: linear-gradient(180deg, var(--ok-top), var(--ok-bottom)); border-color: var(--ok-edge); }
.switch.on i { transform: translateX(20px); background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); }
.settings-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.settings-foot small { margin-right: auto; }
.lobby-foot { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
@media (max-width: 520px) {
  .set-row.choice { flex-wrap: wrap; }
  .set-row.choice .segmented { width: 100%; }
  .set-row.choice .segmented button { flex: 1; }
}

/* ---- 11. Screen sizes -------------------------------------------------------------- */
/* Phones held upright: the menu becomes a bar along the bottom, the floor panel drops under the name. */
@media (max-width: 720px) and (orientation: portrait) {
  :root { --bar: calc(58px + var(--safe-bottom)); }
  .bag-detail { position: fixed; top: 50%; right: auto; left: 50%; transform: translate(-50%, -50%); width: min(380px, calc(100vw - 24px)); max-height: min(78vh, 540px); }
  .hud-me { width: min(236px, 60vw); padding: 6px 10px 6px 6px; }
  .lv-badge { padding: 2px 7px; }
  .hud-floor { top: calc(116px + var(--safe-top)); }
  .hud-toggles { top: calc(180px + var(--safe-top)); max-width: 96vw; }
  .feed, .has-touch .feed { left: calc(10px + var(--safe-left)); top: calc(288px + var(--safe-top)); bottom: auto; width: min(330px, 80vw); }
  .hud-right { left: 0; right: 0; top: 0; bottom: 0; display: block; }
  .hud-wallet { position: absolute; right: calc(8px + var(--safe-right)); top: calc(10px + var(--safe-top)); display: grid; grid-template-columns: auto auto; gap: 5px; justify-items: end; }
  .hud-wallet .coin { grid-column: 1; height: 30px; padding: 0 10px; font-size: 12.5px; }
  .hud-wallet .round { grid-column: 2; width: 30px; height: 30px; }
  .hud-wallet #fullscreenToggle { grid-row: 1; }
  .hud-wallet #toLobby { grid-row: 2; }
  .hud-wallet .coin.gcoin { grid-row: 3; }
  .hud-wallet #mailButton { grid-column: 2; grid-row: 3; }
  .hud-wallet #guideButton { grid-column: 1; grid-row: 4; }
  .hud-wallet #settingsButton { grid-column: 2; grid-row: 4; }
  .hud-menu { position: absolute; left: 0; right: 0; bottom: 0; height: var(--bar); padding: 5px 4px var(--safe-bottom); justify-content: space-around; gap: 0; background: var(--glass-strong); border-top: 1px solid var(--line); pointer-events: auto; }
  .hud-menu { touch-action: manipulation; flex-wrap: nowrap; max-width: none; }
  .menu-btn { width: auto; flex: 1; }
  .menu-btn .round { width: 32px; height: 32px; background: none; border-color: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .menu-btn.active .round { background: var(--accent-strong); }
  .menu-btn small { font-size: 10px; text-shadow: none; color: var(--muted); }
  .actions { flex-direction: column; gap: 8px; }
  .skill-row { display: grid; grid-template-columns: repeat(3, auto); justify-content: end; }
  .act { width: 50px; height: 50px; }
  .act-potion { width: 42px; height: 42px; }
  .act-wide { height: 50px; min-width: 104px; padding: 0 12px; }
  .hud-floor { max-width: 96vw; }
  .chat-window { bottom: calc(68px + var(--safe-bottom) + var(--bar)); width: min(430px, calc(100vw - 20px - var(--safe-left) - var(--safe-right))); height: min(420px, 58vh); }
  .chat-tabs button { padding: 6px 8px; }
  .bag-modal { padding: 0; place-items: end center; }
  .bag-shell { width: 100%; height: auto; max-height: 92vh; border-radius: 18px 18px 0 0; }
  .bag-mode-nav { padding: 6px 8px 0; }
  .bag-body { display: block; overflow-y: auto; }
  .bag-left { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .bag-pets-body { padding: 8px; overflow: visible; }
  .bag-right { min-height: 300px; }
  .bag-grid { overflow: visible; grid-template-columns: repeat(5, 1fr); }
  .doll-slots { grid-template-columns: repeat(2, 46px); gap: 5px; }
  .doll-mid .avatar-canvas { width: min(100%, 140px); height: 120px; }
  .npc-purse { margin-left: 0; width: 100%; }
  .bag-cats { padding: 6px 6px 0; }
  .bag-cats button { flex: 1; justify-content: center; padding: 7px 4px; }
  .bag-cats button span { display: none; }
  .bag-cats button.active span { display: inline; }
  .act-talk { max-width: 132px; }
  .sheet { top: auto; left: 0; width: 100%; height: min(74vh, 640px); border-left: 0; border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; transform: translateY(105%); box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.4); }
  .sheet-head { padding-top: 8px; }
  .lobby-slots { grid-template-columns: repeat(2, 1fr); }
  .lobby-slot { min-height: 215px; }
  .creator-layout { grid-template-columns: 1fr; }
  .stylist-layout { grid-template-columns: 1fr; }
  .stylist-showcase { position: static; grid-template-columns: 120px minmax(0, 1fr); justify-items: stretch; text-align: left; }
  .stylist-preview { grid-row: span 2; min-height: 120px; }
  .stylist-preview .avatar-canvas { width: 120px; height: 120px; }
  .stylist-note, .stylist-actions { align-self: center; justify-content: flex-start; }
  .stylist-picker .picker-grid { max-height: 300px; }
  .creator-preview { grid-template-columns: 150px minmax(0, 1fr); align-items: start; justify-items: stretch; }
  .creator-preview .preview-anims { grid-column: 1; justify-self: center; }
  .creator-picked { grid-column: 2; grid-row: 1 / span 2; max-height: 228px; }
  .preview-stage { padding: 8px 4px; }
  .picker-grid { max-height: 300px; }
  .creator-form { grid-template-columns: 1fr; }
  .card { padding: 18px 14px; }
  .skill-elements { grid-template-columns: repeat(3, 1fr); }
  .book-detail { grid-template-columns: repeat(3, 1fr); }
  .topup-pay { grid-template-columns: 1fr; justify-items: center; }
  .topup-detail { justify-items: center; text-align: center; }
  .topup-detail .btn { justify-self: center; }
  .topup-packages { grid-template-columns: repeat(2, 1fr); }
  .tree-head input { width: 110px; }
  .tree-panel { width: 200px; }
  .tree-tools { right: 10px; }
  .tree-node { bottom: 96px; }
  .menu-btn small { font-size: 9.5px; }
}

/* Short screens (phones held sideways): tighten the top of the HUD. */
@media (max-height: 480px) {
  .hud-me { width: 216px; padding: 5px 10px 5px 5px; }
  .lv-badge { padding: 2px 7px; }
  .hud-toggles { top: calc(128px + var(--safe-top)); max-width: 440px; }
  .feed-line:nth-last-child(n+4) { display: none; }
  .menu-btn small { display: none; }
  .menu-btn { width: 40px; }
  .menu-btn .round { width: 38px; height: 38px; }
  .floor-info { min-width: 124px; }
  .act { width: 50px; height: 50px; }
  .act-potion { width: 42px; height: 42px; }
  .act-wide { height: 50px; }
  .bag-shell { height: 98vh; }
  .doll-slots { grid-template-columns: repeat(2, 40px); gap: 4px; }
  .doll-mid .avatar-canvas { width: min(100%, 120px); height: 96px; }
  .bag-left { gap: 6px; padding: 8px 10px; }
  .stick-zone { width: 124px; height: 124px; }
  .stick { width: 104px; height: 104px; }
  .sheet { width: min(400px, 60vw); }
}
@media (max-width: 900px) and (orientation: landscape) {
  .hud-floor { left: 46%; }
  .pill .icon { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
