/* KM Quest · ระบบออกแบบ (Design System)
   theme-game  = โหมดนักเรียน (ผจญภัย โทนกลางคืน)
   theme-staff = โหมดครู/ผู้ดูแล/ผู้สังเกตการณ์ (สว่าง อ่านง่าย) */

:root {
  --font-display: 'Prompt', 'Sarabun', system-ui, sans-serif;
  --font-body: 'Sarabun', 'Prompt', system-ui, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --gold: #ffc53d;
  --gold-deep: #f59e0b;
  --xp: #34e0a1;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --info: #3b82f6;
  --realm: #7c6cff;
  --shadow: 0 10px 30px rgba(10, 12, 40, .18);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

.theme-game {
  --bg: #0c0e29;
  --bg2: #1a1446;
  --panel: rgba(255, 255, 255, .06);
  --panel-solid: #171a45;
  --panel-2: rgba(255, 255, 255, .1);
  --line: rgba(255, 255, 255, .12);
  --text: #eef0ff;
  --muted: #a3a7d9;
  --accent: #8b7bff;
  --accent-ink: #fff;
  --input: rgba(255, 255, 255, .08);
  color-scheme: dark;
}

.theme-staff {
  --bg: #f4f5fb;
  --bg2: #eef0fb;
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --panel-2: #f6f7fc;
  --line: #e4e6f2;
  --text: #1b1f3b;
  --muted: #6a6f93;
  --accent: #5b4cf0;
  --accent-ink: #fff;
  --input: #ffffff;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
html:has(> body.theme-game), html:has(> body.theme-live) { background: #0c0e29; }
.theme-game { background: var(--bg); }
.theme-game::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 108, 255, .35), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(236, 72, 153, .22), transparent 60%),
    radial-gradient(800px 600px at 50% 120%, rgba(52, 224, 161, .14), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.3; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h2 { font-size: clamp(1.25rem, 2.4vw, 1.55rem); }
h3 { font-size: 1.15rem; }
h4 { font-size: 1.02rem; }
p { margin: 0 0 .8em; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
code { font-family: ui-monospace, Consolas, monospace; background: var(--panel-2); padding: .1em .35em; border-radius: 6px; font-size: .9em; }

/* ---------- Layout ---------- */
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.wrap-narrow { width: min(760px, 100% - 32px); margin-inline: auto; }
.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 24px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 960px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-side { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 1.35rem; }
}

/* ---------- Card ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}
.theme-game .card { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.theme-staff .card { box-shadow: 0 1px 2px rgba(20, 24, 60, .04); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-glow { box-shadow: 0 0 0 1px color-mix(in srgb, var(--realm) 50%, transparent), 0 12px 40px color-mix(in srgb, var(--realm) 25%, transparent); }
.section-title { display: flex; align-items: center; gap: 10px; margin: 28px 0 12px; }
.section-title h2 { margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  --b: var(--panel-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 16px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--b); color: var(--text);
  font-family: var(--font-display); font-size: .95rem; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #ec4899)); border-color: transparent; color: var(--accent-ink); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn-realm { background: linear-gradient(135deg, var(--realm), color-mix(in srgb, var(--realm) 60%, #ffffff)); border-color: transparent; color: #fff; }
.btn-gold { background: linear-gradient(135deg, #ffd66b, var(--gold-deep)); color: #3a2400; border-color: transparent; }
.btn-ok { background: var(--ok); color: #fff; border-color: transparent; }
.btn-danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: .88rem; border-radius: 10px; }
.btn-lg { min-height: 52px; padding: 10px 24px; font-size: 1.05rem; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 42px; padding: 0; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label { font-family: var(--font-display); font-weight: 500; font-size: .92rem; }
.field .hint { color: var(--muted); font-size: .84rem; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=url], input[type=search],
input[type=datetime-local], input[type=date], input[type=time], input[type=tel], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--input); color: var(--text);
  font: inherit; font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input[type=file] { font: inherit; color: var(--muted); max-width: 100%; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: .95rem; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 16px; }
.pin-input { letter-spacing: .5em; text-align: center; font-size: 1.6rem !important; font-family: var(--font-display); }

/* ---------- Chips, badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-family: var(--font-display); font-weight: 500; white-space: nowrap; border: 1px solid transparent; }
.chip-ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: color-mix(in srgb, var(--ok) 70%, var(--text)); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.chip-warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: color-mix(in srgb, var(--warn) 75%, var(--text)); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.chip-bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: color-mix(in srgb, var(--bad) 75%, var(--text)); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.chip-info { background: color-mix(in srgb, var(--info) 16%, transparent); color: color-mix(in srgb, var(--info) 70%, var(--text)); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.chip-wait { background: color-mix(in srgb, #a855f7 16%, transparent); color: color-mix(in srgb, #a855f7 70%, var(--text)); border-color: color-mix(in srgb, #a855f7 35%, transparent); }
.chip-mute { background: var(--panel-2); color: var(--muted); border-color: var(--line); }
.chip-gold { background: color-mix(in srgb, var(--gold) 20%, transparent); color: color-mix(in srgb, var(--gold-deep) 80%, var(--text)); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.chip-realm { background: color-mix(in srgb, var(--realm) 20%, transparent); color: var(--text); border-color: color-mix(in srgb, var(--realm) 45%, transparent); }
.pill-num { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .75rem; font-weight: 700; font-family: var(--font-display); }

/* ---------- Progress ---------- */
.bar { position: relative; height: 10px; border-radius: 999px; background: var(--panel-2); overflow: hidden; border: 1px solid var(--line); }
.bar > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, var(--xp), #7cf5c8); transition: width .8s var(--ease); }
.bar.bar-realm > span { background: linear-gradient(90deg, var(--realm), color-mix(in srgb, var(--realm) 50%, #fff)); }
.bar.bar-gold > span { background: linear-gradient(90deg, #ffd66b, var(--gold-deep)); }
.bar.bar-hp { height: 22px; }
.bar.bar-hp > span { background: linear-gradient(90deg, #ff5d73, #ff9a5a); }
.bar.bar-lg { height: 14px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
table.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-family: var(--font-display); font-weight: 500; font-size: .85rem; color: var(--muted); background: var(--panel-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-compact th, .table-compact td { padding: 6px 8px; }
.table-sticky-first td:first-child, .table-sticky-first th:first-child { position: sticky; left: 0; background: var(--panel); z-index: 2; }
.table-sticky-first th:first-child { background: var(--panel-2); z-index: 3; }
.cell-input { width: 72px !important; min-height: 34px !important; padding: 4px 6px !important; text-align: center; border-radius: 8px !important; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 8px 14px; border-radius: 12px; font-family: var(--font-display); font-size: .92rem; color: var(--muted); border: 1px solid transparent; white-space: nowrap; background: none; cursor: pointer; }
.tab:hover { text-decoration: none; color: var(--text); background: var(--panel-2); }
.tab.is-active { background: var(--panel); color: var(--text); border-color: var(--line); box-shadow: 0 2px 8px rgba(0, 0, 0, .06); }

/* ---------- Alerts / flash / toast ---------- */
.alert { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); display: flex; gap: 10px; align-items: flex-start; }
.alert-ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.alert-error { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.alert-warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.alert-info { border-color: color-mix(in srgb, var(--info) 40%, transparent); background: color-mix(in srgb, var(--info) 10%, transparent); }
.flash-stack { display: grid; gap: 8px; margin: 12px 0; }
.toasts { position: fixed; z-index: 1000; right: 16px; bottom: 16px; display: grid; gap: 10px; width: min(360px, calc(100vw - 32px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--panel-solid); border: 1px solid var(--line); box-shadow: var(--shadow); animation: toast-in .35s var(--ease); }
.toast-icon { font-size: 1.6rem; line-height: 1; }
.toast-title { font-family: var(--font-display); font-weight: 600; }
.toast-body { color: var(--muted); font-size: .9rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 900; background: rgba(8, 10, 30, .6); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow); animation: pop .3s var(--ease); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty-icon { font-size: 2.6rem; margin-bottom: 6px; }
.empty-title { font-family: var(--font-display); color: var(--text); font-weight: 500; }

/* ---------- Stat tiles ---------- */
.stat { padding: 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { color: var(--muted); font-size: .85rem; font-family: var(--font-display); }
.stat-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: .82rem; }
.stat-icon { font-size: 1.3rem; }

/* ---------- Avatar ---------- */
.av { --av: 48px; position: relative; display: inline-block; width: var(--av); height: var(--av); flex: 0 0 var(--av); border-radius: 50%; }
.av svg { width: 100%; height: 100%; display: block; border-radius: 50%; }
.av-pet { position: absolute; right: -8%; bottom: -6%; font-size: calc(var(--av) * .36); line-height: 1; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); }
.av-frame-frame-silver svg { box-shadow: 0 0 0 3px #d9dde8, 0 0 0 5px #9aa1b8; }
.av-frame-frame-gold svg { box-shadow: 0 0 0 3px #ffd66b, 0 0 14px rgba(255, 197, 61, .7); }
.av-frame-frame-neon svg { box-shadow: 0 0 0 3px #a855f7, 0 0 16px #22d3ee, 0 0 26px rgba(168, 85, 247, .6); }
.av-frame-frame-rainbow::before { content: ""; position: absolute; inset: -4px; border-radius: 50%; background: conic-gradient(#ff5d73, #ffb020, #34e0a1, #3b82f6, #a855f7, #ff5d73); animation: spin 4s linear infinite; }
.av-frame-frame-rainbow svg { position: relative; }
.av-frame-frame-fire svg { box-shadow: 0 0 0 3px #ff7a2f, 0 0 12px #ff4d2e, 0 -6px 22px rgba(255, 122, 47, .8); animation: flicker 1.6s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes flicker { 50% { box-shadow: 0 0 0 3px #ffb020, 0 0 16px #ff4d2e, 0 -10px 26px rgba(255, 176, 32, .8); } }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-name { font-family: var(--font-display); font-weight: 500; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-sub { color: var(--muted); font-size: .8rem; line-height: 1.3; }

/* =========================================================================
   GAME (นักเรียน)
   ========================================================================= */
.hud { position: sticky; top: 0; z-index: 50; background: rgba(12, 14, 41, .75); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.hud-inner { display: flex; align-items: center; gap: 14px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, #8b7bff, #ec4899); box-shadow: 0 6px 16px rgba(139, 123, 255, .45); font-size: 1.1rem; }
.hud-nav { display: flex; gap: 4px; margin-left: 8px; }
.hud-nav a { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-family: var(--font-display); font-size: .93rem; }
.hud-nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.hud-nav a.is-active { color: var(--text); background: var(--panel-2); }
.hud-stats { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.hud-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-family: var(--font-display); font-weight: 600; font-size: .92rem; font-variant-numeric: tabular-nums; color: var(--text); }
.hud-pill:hover { text-decoration: none; }
.hud-pill.coins { color: var(--gold); }
.hud-pill.streak { color: #ff9a5a; }
.hud-bell { position: relative; }
.hud-bell .pill-num { position: absolute; top: -6px; right: -6px; }
.hud-me { display: flex; align-items: center; gap: 8px; color: var(--text); }
.hud-me:hover { text-decoration: none; }
.level-badge { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 7px; border-radius: 8px; background: linear-gradient(135deg, #8b7bff, #ec4899); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: .78rem; }
.game-main { padding: 22px 0 110px; }
.nav-bottom { display: none; }
@media (max-width: 860px) {
  .hud-nav { display: none; }
  .hud-me .who-name, .hud-pill.streak { display: none; }
  .nav-bottom { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 60; left: 10px; right: 10px; bottom: 10px; padding: 6px; border-radius: 20px; background: rgba(23, 26, 69, .92); backdrop-filter: blur(14px); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
  .nav-bottom a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 14px; color: var(--muted); font-family: var(--font-display); font-size: .72rem; }
  .nav-bottom a span:first-child { font-size: 1.3rem; line-height: 1.1; }
  .nav-bottom a.is-active { color: var(--text); background: var(--panel-2); }
  .nav-bottom a:hover { text-decoration: none; }
}

/* Player hero */
.hero { position: relative; overflow: hidden; padding: 22px; border-radius: var(--radius-lg); background: linear-gradient(135deg, rgba(139, 123, 255, .28), rgba(236, 72, 153, .16)), var(--panel); border: 1px solid var(--line); }
.hero::after { content: ""; position: absolute; inset: auto -60px -80px auto; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 197, 61, .25), transparent 70%); pointer-events: none; }
.hero-grid { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; position: relative; z-index: 1; }
.hero-name { font-size: clamp(1.3rem, 3vw, 1.8rem); margin: 0; }
.hero-title { color: var(--gold); font-family: var(--font-display); font-size: .95rem; }
.xp-line { display: flex; justify-content: space-between; font-size: .82rem; color: var(--muted); margin: 10px 0 4px; font-family: var(--font-display); }
@media (max-width: 520px) { .hero-grid { grid-template-columns: 1fr; justify-items: center; text-align: center; } }

/* Check-in box */
.checkin { display: flex; gap: 10px; align-items: center; }
.checkin input { max-width: 170px; }

/* Realm cards */
.realm-card { --realm: #7c6cff; position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: var(--radius-lg); color: var(--text); background: linear-gradient(160deg, color-mix(in srgb, var(--realm) 45%, transparent), rgba(255, 255, 255, .04) 60%), var(--panel); border: 1px solid color-mix(in srgb, var(--realm) 45%, transparent); transition: transform .2s var(--ease), box-shadow .2s var(--ease); min-height: 220px; }
.realm-card:hover { transform: translateY(-3px); box-shadow: 0 16px 40px color-mix(in srgb, var(--realm) 30%, transparent); text-decoration: none; }
.realm-icon { font-size: 2.6rem; line-height: 1; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); }
.realm-name { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }
.realm-course { color: var(--muted); font-size: .88rem; }
.realm-foot { margin-top: auto; display: grid; gap: 6px; }

/* Quest list items (upcoming) */
.quest-item { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); color: var(--text); }
.quest-item:hover { text-decoration: none; border-color: color-mix(in srgb, var(--realm) 60%, transparent); background: var(--panel-2); }
.quest-icon { flex: 0 0 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; background: color-mix(in srgb, var(--realm) 30%, transparent); border: 1px solid color-mix(in srgb, var(--realm) 50%, transparent); }
.quest-meta { color: var(--muted); font-size: .82rem; }

/* Realm map */
.realm-banner { --realm: #7c6cff; position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 24px; background: radial-gradient(600px 200px at 90% 0%, color-mix(in srgb, var(--realm) 50%, transparent), transparent 70%), linear-gradient(135deg, color-mix(in srgb, var(--realm) 30%, transparent), rgba(255, 255, 255, .03)), var(--panel); border: 1px solid color-mix(in srgb, var(--realm) 45%, transparent); }
.realm-banner .realm-icon { font-size: 3.2rem; }
.story { font-size: .98rem; color: color-mix(in srgb, var(--text) 85%, transparent); line-height: 1.75; }
.unit-block { position: relative; margin: 28px 0 8px; }
.unit-head { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 18px; background: linear-gradient(90deg, color-mix(in srgb, var(--realm) 26%, transparent), transparent); border: 1px solid color-mix(in srgb, var(--realm) 35%, transparent); }
.unit-no { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--realm); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; box-shadow: 0 6px 16px color-mix(in srgb, var(--realm) 45%, transparent); }
.unit-title { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; line-height: 1.3; }
.path { position: relative; display: grid; gap: 14px; padding: 18px 0 6px 0; }
.path::before { content: ""; position: absolute; left: 31px; top: 0; bottom: 0; width: 4px; border-radius: 4px; background: repeating-linear-gradient(180deg, color-mix(in srgb, var(--realm) 60%, transparent) 0 10px, transparent 10px 18px); }
.node { position: relative; display: grid; grid-template-columns: 66px 1fr auto; gap: 12px; align-items: center; color: var(--text); padding-right: 6px; }
.node:hover { text-decoration: none; }
.node-orb { position: relative; z-index: 1; width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; font-size: 1.7rem; background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--realm) 60%, #fff), var(--realm)); border: 4px solid color-mix(in srgb, var(--realm) 40%, #0c0e29); box-shadow: 0 8px 20px color-mix(in srgb, var(--realm) 40%, transparent), inset 0 -6px 0 rgba(0, 0, 0, .18); transition: transform .2s var(--ease); }
.node:hover .node-orb { transform: scale(1.07); }
.node-card { padding: 12px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); min-width: 0; transition: border-color .2s, background .2s; }
.node:hover .node-card { border-color: color-mix(in srgb, var(--realm) 55%, transparent); background: var(--panel-2); }
.node-title { font-family: var(--font-display); font-weight: 500; line-height: 1.35; }
.node-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.node.is-completed .node-orb { background: radial-gradient(circle at 35% 30%, #8ff5cc, #16b37a); border-color: #0f5c42; }
.node.is-completed .node-orb::after { content: "✓"; position: absolute; right: -4px; bottom: -4px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: #16b37a; font-size: .9rem; font-weight: 800; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.node.is-locked .node-orb, .node.is-upcoming .node-orb, .node.is-career .node-orb, .node.is-closed .node-orb { background: #2a2d5a; border-color: #1c1f47; filter: grayscale(.8); box-shadow: none; }
.node.is-locked .node-card, .node.is-upcoming .node-card, .node.is-career .node-card { opacity: .75; }
.node.is-submitted .node-orb { background: radial-gradient(circle at 35% 30%, #d8b4fe, #8b5cf6); }
.node.is-returned .node-orb, .node.is-overdue .node-orb { background: radial-gradient(circle at 35% 30%, #ffd08a, #f59e0b); animation: pulse 1.8s infinite; }
.node.is-available .node-orb, .node.is-in_progress .node-orb { animation: pulse 2.2s infinite; }
.node.is-side .node-orb { width: 54px; height: 54px; margin-left: 6px; font-size: 1.4rem; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--realm) 55%, transparent), 0 8px 20px color-mix(in srgb, var(--realm) 40%, transparent); } 50% { box-shadow: 0 0 0 10px transparent, 0 8px 20px color-mix(in srgb, var(--realm) 40%, transparent); } }
.boss-node { display: flex; gap: 14px; align-items: center; padding: 12px 14px; margin-left: 76px; border-radius: 16px; border: 1px dashed color-mix(in srgb, #ff5d73 55%, transparent); background: color-mix(in srgb, #ff5d73 10%, transparent); }
.boss-node .boss-icon { font-size: 2rem; }
@media (max-width: 520px) {
  .node { grid-template-columns: 54px 1fr; }
  .node > .node-reward { display: none; }
  .node-orb { width: 54px; height: 54px; font-size: 1.4rem; }
  .path::before { left: 25px; }
  .boss-node { margin-left: 0; }
}
.node-reward { display: grid; justify-items: end; gap: 2px; font-family: var(--font-display); font-size: .8rem; }
.xp-tag { color: var(--xp); font-weight: 600; }
.coin-tag { color: var(--gold); font-weight: 600; }

/* Career */
.career-card { --c: #7c6cff; position: relative; display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: 20px; border: 2px solid color-mix(in srgb, var(--c) 45%, transparent); background: linear-gradient(160deg, color-mix(in srgb, var(--c) 28%, transparent), transparent 70%), var(--panel); cursor: pointer; color: var(--text); transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.career-card:hover { transform: translateY(-3px); }
.career-card input { position: absolute; opacity: 0; pointer-events: none; }
.career-card:has(input:checked) { border-color: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent), 0 14px 30px color-mix(in srgb, var(--c) 30%, transparent); }
.career-icon { font-size: 2.3rem; line-height: 1; }
.career-name { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; }
.rank-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.rank-step { padding: 3px 9px; border-radius: 999px; font-size: .78rem; font-family: var(--font-display); background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.rank-step.is-on { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }

/* Character select */
.char-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
.char-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px; border-radius: 18px; background: var(--panel); border: 2px solid var(--line); cursor: pointer; text-align: center; transition: transform .2s var(--ease), border-color .2s; }
.char-card:hover { transform: translateY(-3px); }
.char-card input { position: absolute; opacity: 0; pointer-events: none; }
.char-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); background: var(--panel-2); }
.char-name { font-family: var(--font-display); font-weight: 600; }
.char-title { font-size: .8rem; color: var(--gold); font-family: var(--font-display); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { position: relative; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch:has(input:checked) { outline: 3px solid var(--accent); outline-offset: 2px; }
.opt-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.opt { position: relative; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: .88rem; font-family: var(--font-display); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt:has(input:checked) { background: var(--accent); color: #fff; border-color: transparent; }
.opt.is-locked { opacity: .45; cursor: not-allowed; }
.avatar-stage { display: grid; place-items: center; padding: 20px; border-radius: 24px; background: radial-gradient(circle at 50% 40%, rgba(139, 123, 255, .35), transparent 70%); }

/* Quest page */
.quest-hero { --realm: #7c6cff; padding: 22px; border-radius: var(--radius-lg); background: linear-gradient(135deg, color-mix(in srgb, var(--realm) 35%, transparent), rgba(255, 255, 255, .03)), var(--panel); border: 1px solid color-mix(in srgb, var(--realm) 45%, transparent); }
.quest-hero .quest-icon { flex-basis: 64px; height: 64px; font-size: 2rem; border-radius: 20px; }
.breadcrumb { display: flex; gap: 6px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.breadcrumb a { color: var(--muted); }
.content { line-height: 1.8; }
.content h4 { margin: 1.1em 0 .4em; color: var(--text); }
.content ul, .content ol { padding-left: 1.3em; margin: 0 0 .9em; }
.content li { margin: .2em 0; }
.content strong { color: var(--text); }
.story-box { position: relative; padding: 16px 18px 16px 52px; border-radius: 16px; background: color-mix(in srgb, var(--gold) 9%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); font-style: italic; }
.story-box::before { content: "📜"; position: absolute; left: 16px; top: 14px; font-size: 1.4rem; font-style: normal; }
.embed { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: #000; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.reward-row { display: flex; gap: 10px; flex-wrap: wrap; }
.reward { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); font-family: var(--font-display); font-size: .9rem; }
.rubric-list { display: grid; gap: 8px; }
.rubric-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.file-list { display: grid; gap: 6px; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-size: .88rem; color: var(--text); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feedback-box { padding: 14px; border-radius: 14px; background: color-mix(in srgb, var(--info) 10%, transparent); border: 1px solid color-mix(in srgb, var(--info) 35%, transparent); }
.dropzone { display: grid; place-items: center; gap: 6px; padding: 22px; border: 2px dashed var(--line); border-radius: 16px; text-align: center; cursor: pointer; color: var(--muted); transition: border-color .2s, background .2s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* Quiz */
.quiz-top { position: sticky; top: 64px; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px; background: rgba(23, 26, 69, .92); border: 1px solid var(--line); backdrop-filter: blur(10px); }
.quiz-timer { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; padding: 4px 12px; border-radius: 10px; background: var(--panel-2); }
.quiz-timer.is-low { background: var(--bad); color: #fff; animation: pulse-bad 1s infinite; }
@keyframes pulse-bad { 50% { opacity: .7; } }
.q-card { padding: 20px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); }
.q-no { font-family: var(--font-display); color: var(--muted); font-size: .88rem; }
.q-prompt { font-family: var(--font-display); font-size: 1.12rem; font-weight: 500; margin: 6px 0 14px; line-height: 1.5; white-space: pre-line; }
.q-options { display: grid; gap: 10px; }
.q-opt { position: relative; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--panel-2); border: 2px solid var(--line); cursor: pointer; transition: border-color .15s, background .15s, transform .15s; font-size: 1rem; text-align: left; color: var(--text); font-family: inherit; width: 100%; }
.q-opt:hover { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.q-opt.is-selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, transparent); }
.q-opt.is-removed { opacity: .3; text-decoration: line-through; pointer-events: none; }
.q-opt.is-correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 18%, transparent); }
.q-opt.is-wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 16%, transparent); }
.q-key { flex: 0 0 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--panel); font-family: var(--font-display); font-weight: 600; font-size: .9rem; }
.q-order-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.q-order-item .ord-btns { margin-left: auto; display: flex; gap: 6px; }
.q-dots { display: flex; gap: 6px; flex-wrap: wrap; }
.q-dot { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); font-family: var(--font-display); font-size: .85rem; cursor: pointer; color: var(--text); }
.q-dot.is-answered { background: color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
.q-dot.is-current { outline: 2px solid var(--gold); outline-offset: 1px; }
.result-hero { text-align: center; padding: 28px 18px; border-radius: 24px; background: radial-gradient(circle at 50% 0%, rgba(255, 197, 61, .3), transparent 70%), var(--panel); border: 1px solid var(--line); }
.result-score { font-family: var(--font-display); font-size: 3rem; font-weight: 700; line-height: 1.1; }
.detail-row { padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); }
.detail-row.is-wrong { border-left-color: var(--bad); }
.detail-row.is-partial { border-left-color: var(--warn); }

/* Raid */
.raid-stage { position: relative; text-align: center; padding: 24px 16px; border-radius: 28px; overflow: hidden; background: radial-gradient(circle at 50% 30%, rgba(255, 93, 115, .35), transparent 60%), linear-gradient(180deg, #2a0f2f, #120a28); border: 1px solid rgba(255, 93, 115, .35); }
.boss-sprite { font-size: clamp(5rem, 16vw, 9rem); line-height: 1; display: inline-block; animation: float 3s ease-in-out infinite; filter: drop-shadow(0 16px 20px rgba(0, 0, 0, .5)); }
.boss-sprite.is-hit { animation: hit .4s; }
.boss-sprite.is-dead { animation: none; filter: grayscale(1) opacity(.4); transform: rotate(-12deg) scale(.9); }
@keyframes float { 50% { transform: translateY(-10px); } }
@keyframes hit { 20% { transform: translateX(-10px) scale(.95); filter: brightness(2); } 60% { transform: translateX(8px); } }
.boss-name { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; margin-top: 6px; }
.hp-text { font-family: var(--font-display); font-variant-numeric: tabular-nums; font-size: .9rem; color: #ffd0d6; margin-top: 4px; }
.dmg-float { position: absolute; left: 50%; top: 30%; font-family: var(--font-display); font-weight: 800; font-size: 2rem; color: var(--gold); text-shadow: 0 3px 0 rgba(0, 0, 0, .4); pointer-events: none; animation: dmg 1s forwards; }
.dmg-float.crit { color: #ff5d73; font-size: 2.6rem; }
@keyframes dmg { to { transform: translate(-50%, -80px); opacity: 0; } }
.feed { display: grid; gap: 6px; font-size: .88rem; }
.feed-item { padding: 6px 10px; border-radius: 10px; background: var(--panel-2); animation: toast-in .3s; }

/* Leaderboard */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 12px; align-items: end; margin-bottom: 16px; }
.podium-slot { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 16px 8px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.podium-slot.p1 { padding-top: 24px; background: linear-gradient(180deg, rgba(255, 197, 61, .22), transparent), var(--panel); border-color: rgba(255, 197, 61, .5); }
.podium-slot.p2 { background: linear-gradient(180deg, rgba(210, 215, 235, .18), transparent), var(--panel); }
.podium-slot.p3 { background: linear-gradient(180deg, rgba(205, 127, 50, .2), transparent), var(--panel); }
.podium-medal { font-size: 1.8rem; line-height: 1; }
.podium-name { font-family: var(--font-display); font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-list { display: grid; gap: 8px; }
.lb-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.lb-row.is-me { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, var(--panel)); }
.lb-rank { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--muted); text-align: center; }
.lb-score { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Shop & items */
.item-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); text-align: center; align-items: center; }
.item-icon { font-size: 2.4rem; line-height: 1; width: 72px; height: 72px; display: grid; place-items: center; border-radius: 20px; background: var(--panel-2); }
.item-name { font-family: var(--font-display); font-weight: 600; }
.item-price { font-family: var(--font-display); color: var(--gold); font-weight: 700; }
.item-card.is-owned { border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.item-card.is-equipped { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 25%, transparent); }

/* Badges */
.badge-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
.badge-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 14px 8px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.badge-tile.is-locked { opacity: .35; filter: grayscale(1); }
.badge-icon { font-size: 2rem; line-height: 1; }
.badge-name { font-family: var(--font-display); font-size: .85rem; font-weight: 500; line-height: 1.3; }
.rarity-rare { border-color: rgba(59, 130, 246, .55); }
.rarity-epic { border-color: rgba(168, 85, 247, .6); box-shadow: 0 0 16px rgba(168, 85, 247, .2); }
.rarity-legendary { border-color: rgba(255, 197, 61, .7); box-shadow: 0 0 20px rgba(255, 197, 61, .3); }

/* Celebrate overlay */
.celebrate { position: fixed; inset: 0; z-index: 950; display: grid; place-items: center; background: rgba(8, 10, 30, .7); animation: fade .25s; padding: 16px; }
.celebrate-card { text-align: center; padding: 28px 24px; border-radius: 28px; background: radial-gradient(circle at 50% 0%, rgba(255, 197, 61, .35), transparent 70%), var(--panel-solid); border: 1px solid rgba(255, 197, 61, .5); max-width: 420px; animation: pop .45s var(--ease); }
.celebrate-icon { font-size: 4rem; line-height: 1; animation: float 2.5s ease-in-out infinite; }
.confetti { position: fixed; top: -12px; width: 10px; height: 14px; z-index: 960; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* Landing / auth */
.landing { min-height: 100vh; display: grid; align-items: center; padding: 32px 0; }
.landing-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 28px; align-items: center; }
@media (max-width: 900px) { .landing-grid { grid-template-columns: 1fr; } .landing-grid > .auth-card { order: -1; } .landing { align-items: start; padding-top: 16px; } }
.landing h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.15; margin-bottom: 14px; }
.gradient-text { background: linear-gradient(90deg, #ffd66b, #ff8fb1, #a99bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-card { padding: 26px; border-radius: 28px; background: var(--panel-solid); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.realm-strip { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 22px; }
@media (max-width: 600px) { .realm-strip { grid-template-columns: 1fr; } }
.mini-realm { padding: 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--panel); }
.feature-list { display: grid; gap: 10px; margin: 18px 0; padding: 0; list-style: none; }
.feature-list li { display: flex; gap: 10px; align-items: flex-start; }
.feature-list li span:first-child { font-size: 1.2rem; }
.role-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 14px; background: var(--panel-2); margin-bottom: 16px; }
.role-toggle button { border: 0; background: none; padding: 9px; border-radius: 10px; font-family: var(--font-display); color: var(--muted); cursor: pointer; font-size: .95rem; }
.role-toggle button.is-active { background: var(--accent); color: #fff; }

/* =========================================================================
   STAFF (ครู/ผู้ดูแล)
   ========================================================================= */
.staff-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px; background: #161a3a; color: #dfe2ff; display: flex; flex-direction: column; gap: 6px; }
.sidebar .brand { color: #fff; padding: 4px 8px 14px; }
.side-label { font-family: var(--font-display); font-size: .72rem; letter-spacing: .06em; color: #8c91c7; text-transform: uppercase; padding: 12px 10px 4px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: #c9ccf2; font-family: var(--font-display); font-size: .93rem; }
.side-link:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.side-link.is-active { background: linear-gradient(135deg, #5b4cf0, #8b5cf6); color: #fff; box-shadow: 0 6px 16px rgba(91, 76, 240, .35); }
.side-link .ico { width: 22px; text-align: center; }
.side-link .pill-num { margin-left: auto; }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .1); }
.staff-top { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.staff-main { padding: 22px 24px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-sub { color: var(--muted); margin-top: 2px; }
.menu-toggle { display: none; }
@media (max-width: 980px) {
  .staff-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 80; left: 0; width: 270px; transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: 10px 0 30px rgba(0, 0, 0, .3); }
  .sidebar.is-open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .staff-main { padding: 16px 16px 60px; }
  .staff-top { padding: 10px 16px; }
}
.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--accent)); }
.course-card { --c: #5b4cf0; display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--c); color: var(--text); }
.course-card:hover { text-decoration: none; box-shadow: var(--shadow); }
.section-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-family: var(--font-display); font-size: .88rem; }
.section-chip:hover { text-decoration: none; border-color: var(--accent); }
.timeline { display: grid; gap: 10px; }
.timeline-item { display: grid; grid-template-columns: 86px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.timeline-item.is-now { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.timeline-time { font-family: var(--font-display); font-weight: 600; font-size: .9rem; }
@media (max-width: 600px) { .timeline-item { grid-template-columns: 1fr; } }
.unit-row { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.unit-row + .unit-row { margin-top: 14px; }
.unit-row-head { display: flex; gap: 12px; align-items: center; padding: 14px 16px; background: var(--panel-2); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.quest-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.quest-row:last-child { border-bottom: 0; }
.quest-row .quest-icon { flex-basis: 36px; height: 36px; font-size: 1.1rem; border-radius: 10px; background: var(--panel-2); border-color: var(--line); }
@media (max-width: 700px) { .quest-row { grid-template-columns: 36px 1fr; } .quest-row > :last-child { grid-column: 1 / -1; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.chart-bars { display: grid; gap: 8px; }
.chart-row { display: grid; grid-template-columns: minmax(80px, 160px) 1fr 60px; gap: 10px; align-items: center; font-size: .88rem; }
.chart-row .bar { height: 14px; }
.chart-row .bar > span { background: linear-gradient(90deg, var(--accent), #a78bfa); }
.dist { display: flex; align-items: stretch; gap: 6px; height: 170px; padding-top: 6px; }
.dist-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; }
.dist-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.dist-bar { width: 100%; border-radius: 8px 8px 2px 2px; background: linear-gradient(180deg, #8b5cf6, #5b4cf0); min-height: 2px; }
.dist-label { font-size: .75rem; color: var(--muted); font-family: var(--font-display); }
.dist-val { font-size: .75rem; font-family: var(--font-display); font-weight: 600; }
.q-editor { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--panel-2); }
.q-editor + .q-editor { margin-top: 12px; }
.opt-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; margin-top: 6px; }
.student-mini { display: flex; align-items: center; gap: 8px; }
.risk { color: var(--bad); font-weight: 600; }
.score-cell { font-variant-numeric: tabular-nums; }
.score-cell.is-missing { color: var(--bad); }
.score-cell.is-late { color: var(--warn); }

/* Projector (live) */
.theme-live { --bg: #0a0c24; --bg2: #151241; --text: #fff; --muted: #b7bbe8; --panel: rgba(255, 255, 255, .07); --panel-solid: #171a45; --panel-2: rgba(255, 255, 255, .12); --line: rgba(255, 255, 255, .14); --accent: #8b7bff; --accent-ink: #fff; --input: rgba(255, 255, 255, .08); color-scheme: dark; background: radial-gradient(1000px 600px at 20% 0%, rgba(124, 108, 255, .35), transparent 60%), #0a0c24; min-height: 100vh; }
.theme-live .tab { color: var(--muted); }
.theme-live .tab.is-active { background: var(--panel-2); color: #fff; }
.live-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; min-height: calc(100vh - 90px); padding: 20px; }
@media (max-width: 1000px) { .live-grid { grid-template-columns: 1fr; } }
.live-code { font-family: var(--font-display); font-weight: 700; font-size: clamp(5rem, 16vw, 12rem); letter-spacing: .12em; line-height: 1; text-align: center; background: linear-gradient(90deg, #ffd66b, #ff8fb1, #a99bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.live-bar { display: flex; gap: 10px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.picker-name { font-family: var(--font-display); font-size: clamp(2rem, 6vw, 4rem); font-weight: 700; text-align: center; min-height: 1.3em; }
.big-timer { font-family: var(--font-display); font-size: clamp(3rem, 10vw, 7rem); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.checked-wall { display: flex; flex-wrap: wrap; gap: 8px; }
.checked-wall .av { animation: pop .4s var(--ease); }

/* Print (บัตรเข้าระบบ) */
.cards-print { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.login-card { border: 1.5px dashed #999; border-radius: 12px; padding: 12px; color: #111; background: #fff; break-inside: avoid; font-size: 13px; }
.login-card .lc-code { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: .05em; }
@media print {
  .no-print, .sidebar, .staff-top, .hud, .nav-bottom { display: none !important; }
  body { background: #fff !important; color: #000; }
  .staff-shell { display: block; }
  .staff-main { padding: 0; }
  .cards-print { grid-template-columns: repeat(3, 1fr); }
}

/* Utilities */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-sm { gap: 6px !important; }
.w-full { width: 100%; }
.text-ok { color: var(--ok); }
.text-bad { color: var(--bad); }
.text-warn { color: var(--warn); }
.text-gold { color: var(--gold); }
.text-xp { color: var(--xp); }
.big-emoji { font-size: 2.2rem; line-height: 1; }
.divider-dot::before { content: "·"; margin: 0 6px; color: var(--muted); }
.pager { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager span { padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.pager .is-active { background: var(--accent); color: #fff; border-color: transparent; }
details.disclosure { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
details.disclosure > summary { cursor: pointer; padding: 12px 16px; font-family: var(--font-display); font-weight: 500; list-style: none; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "▾"; float: right; color: var(--muted); }
details.disclosure[open] > summary::after { content: "▴"; }
details.disclosure > .disclosure-body { padding: 0 16px 16px; }
.skip-link { position: absolute; left: -999px; top: 8px; padding: 8px 12px; background: var(--accent); color: #fff; border-radius: 8px; z-index: 1000; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* หน่วยการเรียนรู้แบบพับได้ */
details.unit-block > summary { list-style: none; cursor: pointer; }
details.unit-block > summary::-webkit-details-marker { display: none; }
.unit-caret { color: var(--muted); font-size: 1.1rem; transition: transform .2s var(--ease); }
details.unit-block[open] .unit-caret { transform: rotate(180deg); }
details.unit-block:not([open]) .unit-head { opacity: .85; }
details.unit-block:not([open]) .unit-head:hover { opacity: 1; }
details > summary.btn { list-style: none; }
details > summary.btn::-webkit-details-marker { display: none; }
.side-link.is-active .muted { color: rgba(255, 255, 255, .85); }

/* ประลองปัญญา */
.bt-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.bt-opt { display: flex; align-items: center; gap: 12px; padding: 16px; min-height: 84px; border: 0; border-radius: 16px; color: #fff; font-family: var(--font-display); font-size: 1.05rem; font-weight: 500; text-align: left; cursor: pointer; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .22); transition: transform .12s var(--ease), opacity .2s, outline .1s; }
.bt-opt:active { transform: scale(.97); }
.bt-opt.is-picked { outline: 4px solid #fff; outline-offset: 2px; }
.bt-opt.is-dim { opacity: .28; }
.bt-opt.is-correct { outline: 6px solid #fff; box-shadow: 0 0 30px rgba(255, 255, 255, .45), inset 0 -6px 0 rgba(0, 0, 0, .22); }
.bt-shape { font-size: 1.6rem; line-height: 1; }
.bt-count { font-size: 1.5rem; font-weight: 700; background: rgba(0, 0, 0, .25); padding: 2px 12px; border-radius: 999px; }
.bt-big .bt-opt { min-height: 110px; font-size: clamp(1.1rem, 2.2vw, 1.8rem); padding: 20px 24px; }
.bt-big .bt-shape { font-size: 2.2rem; }
.bt-prompt { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.4rem, 3vw, 2.4rem); line-height: 1.35; text-align: center; padding: 0 12px; }
.bt-timer { --p: 100%; flex: 0 0 110px; width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--gold) var(--p), rgba(255, 255, 255, .12) 0); font-family: var(--font-display); font-weight: 700; font-size: 2.6rem; position: relative; }
.bt-timer::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--bg); }
.bt-timer > span { position: relative; }
.bt-timer.is-ready { background: conic-gradient(#22c55e 100%, transparent 0); }
.bt-timebar { height: 12px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.bt-timebar > span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--xp), var(--gold)); transition: width .15s linear; }
.bt-timebar > span.is-low { background: var(--bad); }
.bt-me { padding: 10px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); font-family: var(--font-display); }
@media (max-width: 520px) { .bt-options { grid-template-columns: 1fr; } .bt-opt { min-height: 64px; } }

/* หอเกียรติยศ */
.showcase-thumb { display: block; margin: -18px -18px 0; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.showcase-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s var(--ease); }
.showcase-thumb:hover img { transform: scale(1.04); }
.react-btn.is-on { background: color-mix(in srgb, var(--gold) 25%, transparent); border-color: var(--gold); }

/* ---------- โลกออนไลน์ (เมืองกลาง) ---------- */
.world-head { flex-wrap: wrap; gap: 8px; }
.world-scroll { overflow-x: auto; border-radius: 22px; -webkit-overflow-scrolling: touch; box-shadow: 0 18px 40px rgba(0,0,0,.35); }
.world-map { position: relative; width: 100%; min-width: 760px; aspect-ratio: 1000 / 640; border-radius: 22px; overflow: hidden; cursor: pointer; user-select: none; -webkit-user-select: none; outline: none; touch-action: manipulation; }
.world-map:focus-visible { box-shadow: inset 0 0 0 3px #fbbf24; }
.world-ground { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.world-deco span { position: absolute; transform: translate(-50%, -50%); font-size: 30px; pointer-events: none; filter: drop-shadow(0 4px 4px rgba(0,0,0,.3)); }
.w-place { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; padding: 0; cursor: pointer; color: #fff; z-index: 5; font: inherit; }
.w-place-icon { font-size: 44px; line-height: 1; filter: drop-shadow(0 6px 8px rgba(0,0,0,.4)); transition: transform .2s; }
.w-place:hover .w-place-icon, .w-place:focus-visible .w-place-icon { transform: translateY(-4px) scale(1.08); }
.w-place-label { font: 600 12px/1.3 Prompt, sans-serif; background: rgba(10,12,40,.76); padding: 3px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid rgba(255,255,255,.2); }
.w-gate .w-place-icon { font-size: 50px; padding: 8px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--pc, #8b7bff) 75%, transparent) 0%, transparent 70%); }
.w-gate .w-place-label { border-color: var(--pc, #8b7bff); }
.w-fountain { pointer-events: auto; }
.w-fountain .w-place-icon { font-size: 36px; }
.w-boss .w-place-icon { font-size: 66px; }
.w-boss.is-live .w-place-icon { animation: w-boss 1.8s ease-in-out infinite; }
@keyframes w-boss { 50% { transform: scale(1.08) rotate(-4deg); } }
.w-bossbar { width: 100px; height: 9px; background: rgba(0,0,0,.5); border-radius: 999px; overflow: hidden; border: 1px solid rgba(255,255,255,.4); }
.w-bossbar span { display: block; height: 100%; background: linear-gradient(90deg, #ef4444, #f97316); transition: width .6s; }
.w-bossbar.is-done span { background: #64748b; }
.w-bossbar-lg { width: 100%; height: 14px; }
.w-player { position: absolute; transform: translate(-50%, -100%); transition-property: left, top; transition-timing-function: linear; display: flex; flex-direction: column; align-items: center; }
.w-av { width: 48px; height: 48px; }
.w-av svg { width: 100%; height: 100%; display: block; border-radius: 50%; box-shadow: 0 4px 10px rgba(0,0,0,.4); }
.w-player.face-left .w-av { transform: scaleX(-1); }
.w-player.is-walking .w-av { animation: w-bob .32s ease-in-out infinite; }
@keyframes w-bob { 50% { translate: 0 -4px; } }
.w-player.is-me .w-av svg { box-shadow: 0 0 0 3px #fbbf24, 0 4px 10px rgba(0,0,0,.4); }
.w-player.is-gm .w-av svg { box-shadow: 0 0 0 3px #e879f9, 0 4px 10px rgba(0,0,0,.4); }
.w-tag { margin-top: 3px; font: 600 11px/1.25 Prompt, sans-serif; color: #fff; background: rgba(10,12,40,.8); padding: 2px 8px; border-radius: 999px; white-space: nowrap; display: flex; gap: 5px; align-items: center; }
.w-tag.is-me { background: #b45309; }
.w-tag.is-gm { background: linear-gradient(90deg, #7c3aed, #db2777); }
.w-lv { opacity: .85; font-size: 10px; }
.w-pet { position: absolute; left: -12px; top: 22px; font-size: 18px; }
.w-bubble { position: absolute; bottom: 100%; margin-bottom: 6px; background: #fff; color: #111827; font: 600 12px/1.3 Prompt, sans-serif; padding: 4px 10px; border-radius: 12px; white-space: nowrap; box-shadow: 0 6px 16px rgba(0,0,0,.3); animation: w-pop .25s ease-out; }
.w-bubble::after { content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #fff; }
@keyframes w-pop { from { transform: scale(.6); opacity: 0; } }
.w-player.is-leaving { opacity: 0; transition: opacity .5s; }
.world-emotes { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
.w-emote { gap: 6px; }
.world-panel { display: grid; gap: 10px; }
.world-hint { display: none; text-align: center; }
@media (max-width: 800px) { .world-hint { display: block; } }
.world-card-bar { margin-top: 6px; }
@media (max-width: 640px) {
  .w-emote-text { display: none; }
  .w-emote { font-size: 1.2rem; padding: 6px 10px; }
  .world-panel { position: sticky; bottom: 84px; z-index: 40; box-shadow: 0 -8px 30px rgba(0,0,0,.45); }
}
@media (prefers-reduced-motion: reduce) {
  .w-player, .w-bossbar span { transition-duration: 0ms !important; }
  .w-boss.is-live .w-place-icon, .w-player.is-walking .w-av { animation: none; }
}

/* ---------- ภารกิจประจำวัน ---------- */
.mission-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 14px; background: var(--panel-2); color: inherit; text-decoration: none; transition: transform .15s; }
.mission-row:hover { transform: translateX(3px); }
.mission-row .grow { display: grid; gap: 4px; min-width: 0; }
.mission-icon { font-size: 1.5rem; width: 2rem; text-align: center; }
.mission-label { font-weight: 600; font-size: .92rem; }
.mission-row.is-done { opacity: .7; }
.mission-row.is-done .mission-label { text-decoration: line-through; }

/* ---------- ตกปลาความรู้ ---------- */
.pond-scene { position: relative; height: 150px; border-radius: 18px; overflow: hidden; background: linear-gradient(180deg, #7dd3fc 0%, #0ea5e9 45%, #0369a1 100%); }
.pond-scene::before { content: ''; position: absolute; inset: 0 0 auto; height: 40%; background: linear-gradient(180deg, #bae6fd, transparent); opacity: .5; }
.pond-rod { position: absolute; left: 8%; top: 8%; font-size: 46px; transform-origin: bottom left; transition: transform .4s; }
.pond-bobber { position: absolute; left: 55%; top: 44%; font-size: 18px; opacity: 0; }
.pond-fish { position: absolute; font-size: 26px; opacity: .55; animation: pond-swim 9s linear infinite; }
.pond-fish.f1 { top: 62%; animation-duration: 11s; }
.pond-fish.f2 { top: 76%; animation-duration: 8s; animation-delay: -3s; }
.pond-fish.f3 { top: 68%; animation-duration: 14s; animation-delay: -6s; }
@keyframes pond-swim { from { left: -10%; } to { left: 105%; } }
.pond-scene.is-casting .pond-rod { transform: rotate(35deg); }
.pond-scene.is-casting .pond-bobber, .pond-scene.is-bite .pond-bobber { opacity: 1; }
.pond-scene.is-casting .pond-bobber { animation: bob-drop .9s ease-out; }
.pond-scene.is-bite .pond-bobber { animation: bob-bite .35s ease-in-out infinite; }
@keyframes bob-drop { from { left: 14%; top: 5%; } to { left: 55%; top: 44%; } }
@keyframes bob-bite { 50% { transform: translateY(8px); } }
.fish-catch { display: grid; gap: 6px; justify-items: center; text-align: center; padding: 14px; border-radius: 16px; background: var(--panel-2); }
.fish-catch-emoji { font-size: 4.2rem; line-height: 1; animation: fish-jump .6s ease-out; }
@keyframes fish-jump { 0% { transform: translateY(40px) scale(.4); opacity: 0; } 70% { transform: translateY(-10px) scale(1.15); } }
.fish-catch.rarity-epic { box-shadow: 0 0 0 2px #f59e0b inset; }
.fish-catch.rarity-legendary { box-shadow: 0 0 0 2px #ef4444 inset, 0 0 30px rgba(239,68,68,.35); }
.fish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.fish-cell { display: grid; justify-items: center; gap: 4px; padding: 10px 6px; border-radius: 14px; background: var(--panel-2); text-align: center; border: 1px solid var(--line); transition: transform .2s, box-shadow .2s; }
.fish-emoji { font-size: 2.2rem; line-height: 1.1; }
.fish-name { font-size: .8rem; font-weight: 600; }
.fish-cell.is-unknown .fish-emoji { filter: grayscale(1); opacity: .45; }
.fish-cell.rarity-epic:not(.is-unknown) { border-color: #f59e0b; }
.fish-cell.rarity-legendary:not(.is-unknown) { border-color: #ef4444; box-shadow: 0 0 16px rgba(239,68,68,.3); }
.fish-cell.is-fresh { transform: scale(1.08); box-shadow: 0 0 0 3px #fbbf24; }
@media (prefers-reduced-motion: reduce) { .pond-fish, .fish-catch-emoji, .pond-scene .pond-bobber { animation: none !important; } }

/* ---------- โลกออนไลน์: ตัวละครแบบมีตัว บ้าน ชาวบ้าน มอนสเตอร์ ---------- */
.w-char { position: absolute; transform: translate(-50%, -100%); transition-property: left, top; transition-timing-function: linear; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.w-char .w-av { order: 1; width: 40px; height: 40px; position: relative; z-index: 2; }
.w-char .w-body { order: 2; }
.w-char .w-tag { order: 3; }
.w-char .w-bubble { order: 0; }
.w-char .w-av svg { width: 100%; height: 100%; display: block; border-radius: 50%; box-shadow: 0 3px 8px rgba(0,0,0,.35); }
.w-body { position: relative; width: 26px; height: 24px; margin-top: -5px; z-index: 1; }
.w-torso { position: absolute; left: 3px; top: 0; width: 20px; height: 14px; border-radius: 8px 8px 4px 4px; background: var(--oc); }
.w-arm { position: absolute; top: 2px; width: 6px; height: 12px; border-radius: 3px; background: var(--oc); filter: brightness(.82); transform-origin: 50% 2px; }
.w-arm.l { left: -2px; }
.w-arm.r { right: -2px; }
.w-leg { position: absolute; top: 12px; width: 7px; height: 12px; border-radius: 3px; background: #334155; transform-origin: 50% 1px; }
.w-leg.l { left: 6px; }
.w-leg.r { right: 6px; }
.w-shadow { position: absolute; bottom: 14px; left: 50%; width: 30px; height: 8px; margin-left: -15px; border-radius: 50%; background: rgba(0,0,0,.25); z-index: 0; }
.w-char.is-walking .w-leg.l, .w-char.is-walking .w-arm.r { animation: w-swing .36s ease-in-out infinite alternate; }
.w-char.is-walking .w-leg.r, .w-char.is-walking .w-arm.l { animation: w-swing .36s ease-in-out infinite alternate-reverse; }
.w-char.is-walking .w-av { animation: w-bob .36s ease-in-out infinite; }
@keyframes w-swing { from { transform: rotate(28deg); } to { transform: rotate(-28deg); } }
.w-char.face-left .w-av, .w-char.face-left .w-body { transform: scaleX(-1); }
.w-char.is-me .w-av svg { box-shadow: 0 0 0 3px #fbbf24, 0 3px 8px rgba(0,0,0,.35); }
.w-char.is-gm .w-av svg { box-shadow: 0 0 0 3px #e879f9, 0 3px 8px rgba(0,0,0,.35); }
.w-char.is-attack .w-arm.r { animation: w-swing .12s linear 3 alternate; }
.w-char.is-away { opacity: .6; pointer-events: none; } /* คนที่พักอยู่ไม่บัง NPC/หีบ/มอนสเตอร์ */
.w-char.is-away .w-av::after { content: "💤"; position: absolute; right: -12px; top: -8px; font-size: 16px; animation: w-bob 1.6s ease-in-out infinite; }
.w-char.is-leaving { opacity: 0; transition: opacity .5s; }
.w-tag.is-npc { background: #166534; }
.w-npc .w-av svg { box-shadow: 0 0 0 2px #86efac, 0 3px 8px rgba(0,0,0,.35); }
.w-npc-face { width: 56px; height: 56px; flex: none; }
.w-npc-face svg { width: 100%; height: 100%; border-radius: 50%; }
.w-npc-line { font-size: 1rem; line-height: 1.6; }

.w-house { position: relative; width: 78px; height: 66px; filter: drop-shadow(0 6px 6px rgba(0,0,0,.35)); transition: transform .2s; }
.w-roof { position: absolute; top: 0; left: -6px; right: -6px; height: 30px; background: var(--roof, #b45309); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.w-wall { position: absolute; top: 28px; left: 4px; right: 4px; bottom: 0; background: var(--wall, #fef3c7); border-radius: 0 0 6px 6px; }
.w-door { position: absolute; bottom: 0; left: 50%; width: 16px; height: 22px; margin-left: -8px; background: #7c4a1e; border-radius: 8px 8px 0 0; }
.w-win { position: absolute; top: 7px; left: 7px; width: 13px; height: 11px; background: #93c5fd; border: 2px solid #fff; border-radius: 2px; }
.w-sign { position: absolute; top: 3px; right: 5px; font-size: 17px; line-height: 1; }
.w-place:hover .w-house, .w-place:hover .w-castle, .w-place:hover .w-cave { transform: translateY(-3px) scale(1.04); }
.w-cottage { position: absolute; transform: translate(-50%, -50%); width: 44px; height: 38px; z-index: 4; pointer-events: none; filter: drop-shadow(0 4px 4px rgba(0,0,0,.3)); opacity: .95; }
.w-cottage .w-roof { height: 19px; left: -4px; right: -4px; }
.w-cottage .w-wall { top: 17px; left: 3px; right: 3px; background: #fde7c7; }
.w-cottage .w-win { top: 5px; left: 50%; margin-left: -6px; width: 10px; height: 9px; }
.w-castle { position: relative; width: 112px; height: 86px; filter: drop-shadow(0 8px 8px rgba(0,0,0,.4)); transition: transform .2s; }
.w-tower { position: absolute; bottom: 0; width: 26px; height: 68px; background: #cbd5e1; border-radius: 3px 3px 0 0; }
.w-tower::before { content: ""; position: absolute; top: -18px; left: -4px; right: -4px; height: 20px; background: var(--pc); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.w-tower.l { left: 0; }
.w-tower.r { right: 0; }
.w-keep { position: absolute; bottom: 0; left: 20px; right: 20px; height: 56px; background: #e2e8f0; border-top: 6px dashed #94a3b8; }
.w-keep .w-sign { top: 6px; left: 50%; right: auto; transform: translateX(-50%); font-size: 24px; }
.w-arch { position: absolute; bottom: 0; left: 50%; width: 28px; height: 30px; margin-left: -14px; background: var(--pc); border-radius: 14px 14px 0 0; box-shadow: inset 0 0 0 3px rgba(255,255,255,.35); }
.w-cave { position: relative; width: 124px; height: 86px; transition: transform .2s; }
.w-cave::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 100%, #78716c 0 55%, #57534e 56% 62%, transparent 63%); }
.w-cave-mouth { position: absolute; bottom: 0; left: 50%; width: 62px; height: 46px; margin-left: -31px; background: #1c1917; border-radius: 31px 31px 0 0; }
.w-cave-boss { position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); font-size: 46px; line-height: 1; }
.w-boss.is-live .w-cave-boss { animation: w-boss 1.8s ease-in-out infinite; }
.w-dock { position: relative; width: 72px; height: 22px; background: repeating-linear-gradient(90deg, #a16207 0 10px, #854d0e 10px 12px); border-radius: 4px; box-shadow: 0 4px 6px rgba(0,0,0,.3); }
.w-dock .w-sign { top: -24px; left: 50%; right: auto; transform: translateX(-50%); font-size: 24px; }

.w-monster { position: absolute; transform: translate(-50%, -100%); transition-property: left, top; transition-timing-function: ease-in-out; display: flex; flex-direction: column; align-items: center; gap: 1px; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
.w-mon-emoji { font-size: 30px; line-height: 1; filter: drop-shadow(0 4px 3px rgba(0,0,0,.4)); animation: mon-bob 1.1s ease-in-out infinite; }
.w-monster.is-elite .w-mon-emoji { font-size: 40px; }
.w-mon-hp { width: 34px; height: 5px; background: rgba(0,0,0,.45); border-radius: 3px; overflow: hidden; }
.w-mon-hp span { display: block; height: 100%; width: 100%; background: #ef4444; }
.w-mon-name { font: 600 10px/1.3 Prompt, sans-serif; color: #fee2e2; background: rgba(127,29,29,.85); padding: 1px 6px; border-radius: 999px; white-space: nowrap; }
.w-monster .w-bubble { order: -1; }
.w-monster.is-target .w-mon-emoji { animation: mon-shake .25s linear infinite; }
.w-monster.is-dead { animation: mon-fade .6s ease-in forwards; pointer-events: none; }
.w-monster.is-dead .w-mon-px { animation: mon-die .6s ease-in forwards; }
@keyframes mon-fade { to { opacity: 0; } }
.w-monster.is-dead .w-mon-hp span { width: 0; transition: width .3s; }
@keyframes mon-bob { 50% { transform: translateY(-4px) scale(1.05, .95); } }
@keyframes mon-shake { 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
@keyframes mon-die { to { transform: translateY(-40%) scale(.3) rotate(40deg); } }
.w-float { position: absolute; transform: translate(-50%, -100%); font: 700 16px Prompt, sans-serif; color: #fde047; text-shadow: 0 2px 4px rgba(0,0,0,.6); z-index: 2000; pointer-events: none; animation: float-up 1.4s ease-out forwards; }
@keyframes float-up { to { opacity: 0; transform: translate(-50%, -260%); } }
@media (prefers-reduced-motion: reduce) {
  .w-char, .w-monster { transition-duration: 0ms !important; }
  .w-mon-emoji, .w-char.is-walking .w-leg, .w-char.is-walking .w-arm, .w-char.is-walking .w-av { animation: none !important; }
}

/* ---------- แนะนำนักเรียนใหม่ ---------- */
.sticky-actions { position: sticky; bottom: 12px; z-index: 30; padding: 10px; border-radius: 18px; background: var(--panel-solid, #1b1d45); box-shadow: 0 -6px 24px rgba(0,0,0,.35); }
@media (max-width: 900px) { .sticky-actions { bottom: 84px; } }
.next-badge { display: inline-block; margin-bottom: 4px; padding: 2px 10px; border-radius: 999px; background: #fbbf24; color: #3b2600; font: 700 12px/1.4 Prompt, sans-serif; animation: next-pulse 1.4s ease-in-out infinite; }
.node.is-next .node-orb { box-shadow: 0 0 0 4px #fbbf24, 0 0 24px rgba(251,191,36,.6); }
@keyframes next-pulse { 50% { transform: translateX(4px); } }
.mission-row.is-next { box-shadow: 0 0 0 2px #fbbf24 inset; }
.w-tut { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 16px; background: rgba(5,6,20,.7); }
.w-tut-card { max-width: 420px; width: 100%; display: grid; gap: 12px; padding: 20px; border-radius: 22px; background: var(--panel-solid, #1b1d45); border: 1px solid rgba(255,255,255,.12); box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: w-pop .25s ease-out; }
.w-tut-card .w-npc-face { width: 64px; height: 64px; }
.w-tut-big { font-size: 2.6rem; text-align: center; line-height: 1.2; }
.w-tut-dots { display: flex; gap: 6px; justify-content: center; }
.w-tut-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.25); }
.w-tut-dots span.on { background: #fbbf24; }
@media (prefers-reduced-motion: reduce) { .next-badge { animation: none; } }

/* ---------- โลก MMO: กล้อง โซน ประตูวาร์ป อุปกรณ์ การต่อสู้ ภารกิจ NPC ---------- */
.world-scroll { height: min(72vh, 900px); overflow: auto; overscroll-behavior: contain; }
.world-map { width: max(1100px, 100%); min-width: 0; }
.zone-forest .world-deco span { font-size: 38px; }
.zone-cave .world-deco span { font-size: 30px; filter: drop-shadow(0 0 8px rgba(168,85,247,.7)); }
.world-stats { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 8px 14px; border-radius: 14px; background: var(--panel-2); color: inherit; text-decoration: none; font-size: .9rem; font-weight: 600; }
.w-portal { z-index: 6; }
.w-portal-ring { display: grid; place-items: center; width: 70px; height: 70px; border-radius: 50%; font-size: 40px; background: radial-gradient(circle, rgba(167,139,250,.9) 0%, rgba(59,130,246,.55) 45%, transparent 70%); box-shadow: 0 0 30px rgba(129,140,248,.8); animation: portal-spin 3s linear infinite; }
.w-portal.is-locked .w-portal-ring { background: radial-gradient(circle, rgba(100,116,139,.8) 0%, transparent 70%); box-shadow: none; animation: none; font-size: 30px; }
@keyframes portal-spin { to { transform: rotate(360deg); } }
.w-mark { position: absolute; top: -34px; left: 50%; transform: translateX(-50%); font-size: 26px; font-weight: 800; line-height: 1; color: #fde047; text-shadow: 0 2px 4px rgba(0,0,0,.6); animation: w-bob 1s ease-in-out infinite; z-index: 5; }
.w-mark.is-ready { color: #fbbf24; filter: drop-shadow(0 0 6px #fbbf24); }
.w-char .w-mark { order: 0; }
.w-weapon { position: absolute; right: -14px; top: -4px; font-size: 18px; transform-origin: 20% 80%; transform: rotate(-20deg); z-index: 3; }
.w-armor { position: absolute; left: -12px; top: 2px; font-size: 14px; z-index: 3; }
.w-char.is-attack .w-weapon { animation: w-slash .15s linear 3 alternate; }
@keyframes w-slash { from { transform: rotate(-60deg); } to { transform: rotate(40deg); } }
.w-monster.is-hit .w-mon-emoji { animation: mon-hit .35s ease-out; }
@keyframes mon-hit { 30% { transform: translateX(6px) scale(.9); filter: brightness(2); } }
.w-float.is-crit { color: #f97316; font-size: 22px; }
.w-float.is-hurt { color: #f87171; }
.fight-hud { display: grid; gap: 6px; padding: 10px; border-radius: 14px; background: var(--panel-2); }
.fight-hearts { font-size: 1.1rem; letter-spacing: 2px; }
.fight-note { padding: 8px 12px; border-radius: 12px; font-size: .9rem; font-weight: 600; }
.fight-note.is-good { background: rgba(34,197,94,.18); color: #86efac; }
.fight-note.is-bad { background: rgba(239,68,68,.18); color: #fecaca; }
.npc-quest { display: grid; gap: 6px; padding: 10px 12px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.npc-quest.is-ready { border-color: #fbbf24; box-shadow: 0 0 0 1px #fbbf24 inset; }
.npc-quest .bar span { background: linear-gradient(90deg, #22c55e, #86efac); }
@media (max-width: 640px) { .world-scroll { height: 62vh; } }
@media (prefers-reduced-motion: reduce) { .w-portal-ring, .w-mark { animation: none !important; } }
/* แผงข้อมูล/ต่อสู้ลอยเหนือแผนที่ ให้เห็นทันทีโดยไม่ต้องเลื่อน */
.world-panel { background: var(--panel-solid, #1b1d45); position: fixed; right: 16px; bottom: 16px; width: min(440px, calc(100vw - 32px)); max-height: min(78vh, 720px); overflow: auto; z-index: 2500; box-shadow: 0 20px 50px rgba(0,0,0,.55); border: 1px solid rgba(255,255,255,.14); animation: w-pop .2s ease-out; }
@media (max-width: 640px) { .world-panel { left: 8px; right: 8px; width: auto; bottom: 80px; max-height: 64vh; } }

/* ---------- ปาร์ตี้ล่ามอนสเตอร์ยักษ์ ---------- */
.w-giant { position: absolute; transform: translate(-50%, -100%); z-index: 7; display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: #fff; }
.w-giant-emoji { font-size: 78px; line-height: 1; filter: drop-shadow(0 10px 10px rgba(0,0,0,.45)); animation: giant-breathe 2.4s ease-in-out infinite; }
@keyframes giant-breathe { 50% { transform: scale(1.06, .96) translateY(2px); } }
.w-giant-badge { font: 700 11px/1.3 Prompt, sans-serif; padding: 2px 10px; border-radius: 999px; background: #7c3aed; white-space: nowrap; }
.w-giant.is-calling .w-giant-badge { background: #f59e0b; color: #3b2600; animation: next-pulse 1.2s ease-in-out infinite; }
.party-members { display: grid; gap: 6px; }
.party-member { display: flex; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 12px; background: var(--panel-2); }
.party-member .w-npc-face { width: 40px; height: 40px; }
.party-member.is-me { box-shadow: 0 0 0 2px #fbbf24 inset; }
.party-member.is-down { opacity: .5; }
.party-log { display: grid; gap: 2px; padding: 8px 10px; border-radius: 12px; background: rgba(0,0,0,.25); max-height: 120px; overflow: auto; }

/* ---------- เอฟเฟกต์ อนิเมชัน และบรรยากาศ ---------- */
.w-fx, .w-ambient { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.w-fx { z-index: 2000; }
.w-ambient { z-index: 1600; }
.fx { position: absolute; transform: translate(-50%, -50%); pointer-events: none; }
.fx-slash { width: 74px; height: 74px; border-radius: 50%; border-top: 6px solid #fff; border-right: 6px solid transparent; filter: drop-shadow(0 0 8px #fde047); animation: fx-slash .38s ease-out forwards; }
.fx-slash.is-crit { width: 104px; height: 104px; border-top-color: #fed7aa; filter: drop-shadow(0 0 12px #f97316); }
@keyframes fx-slash { from { transform: translate(-50%, -50%) rotate(-120deg) scale(.6); opacity: 1; } to { transform: translate(-50%, -50%) rotate(40deg) scale(1.15); opacity: 0; } }
.fx-spark { width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 8px currentColor; animation: fx-spark .6s ease-out forwards; }
@keyframes fx-spark { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2); opacity: 0; } }
.fx-shard { font-size: 16px; animation: fx-shard .8s ease-out forwards; }
@keyframes fx-shard { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 40px)) rotate(200deg) scale(.4); opacity: 0; } }
.fx-poof { font-size: 44px; animation: fx-poof .7s ease-out forwards; }
@keyframes fx-poof { from { transform: translate(-50%, -50%) scale(.4); opacity: 1; } to { transform: translate(-50%, -80%) scale(1.8); opacity: 0; } }
.fx-dust { width: 14px; height: 8px; margin-top: -4px; border-radius: 50%; background: rgba(230, 220, 190, .7); animation: fx-dust .6s ease-out forwards; }
@keyframes fx-dust { to { transform: translate(-50%, -80%) scale(2.4); opacity: 0; } }

.world-map.is-shake { animation: map-shake .35s linear; }
.world-map.is-shake-strong { animation: map-shake-strong .45s linear; }
@keyframes map-shake { 20% { transform: translate(-3px, 1px); } 40% { transform: translate(3px, -1px); } 60% { transform: translate(-2px, 1px); } 80% { transform: translate(2px, 0); } }
@keyframes map-shake-strong { 15% { transform: translate(-7px, 3px); } 30% { transform: translate(6px, -4px); } 45% { transform: translate(-5px, 2px); } 60% { transform: translate(4px, -2px); } 80% { transform: translate(-2px, 1px); } }
.world-map.is-hurt { box-shadow: inset 0 0 90px 20px rgba(239, 68, 68, .55); transition: box-shadow .1s; }
.world-map.is-warp { animation: map-warp .45s ease-in forwards; }
@keyframes map-warp { to { transform: scale(1.03); } }
.w-char.is-knock .w-av, .w-char.is-knock .w-body { animation: knock .35s ease-out; }
@keyframes knock { 30% { transform: translateX(-8px); filter: brightness(1.6) sepia(1) hue-rotate(-40deg) saturate(4); } }
.w-giant.is-hit .w-giant-emoji { animation: mon-hit .35s ease-out; }
.w-char:not(.is-walking) .w-av { animation: w-breathe 3.2s ease-in-out infinite; }
@keyframes w-breathe { 50% { transform: translateY(-1.5px) scale(1.02); } }
.w-char.face-left:not(.is-walking) .w-av { animation: none; transform: scaleX(-1); }

/* บรรยากาศประจำโซน */
.fx-leaf, .fx-flutter, .fx-firefly, .fx-sparkle { position: absolute; font-size: 18px; animation-iteration-count: infinite; animation-timing-function: linear; }
.fx-leaf { animation-name: amb-leaf; opacity: .85; }
@keyframes amb-leaf { 0% { transform: translate(-60px, -40px) rotate(0); opacity: 0; } 10% { opacity: .9; } 100% { transform: translate(220px, 160px) rotate(540deg); opacity: 0; } }
.fx-flutter { font-size: 16px; animation-name: amb-flutter; animation-timing-function: ease-in-out; }
@keyframes amb-flutter { 0%, 100% { transform: translate(0, 0) scaleX(1); } 25% { transform: translate(60px, -30px) scaleX(-1); } 50% { transform: translate(120px, 10px) scaleX(1); } 75% { transform: translate(50px, 40px) scaleX(-1); } }
.fx-firefly { width: 6px; height: 6px; border-radius: 50%; background: #fef08a; box-shadow: 0 0 10px 4px rgba(254, 240, 138, .7); animation-name: amb-firefly; animation-timing-function: ease-in-out; }
@keyframes amb-firefly { 0%, 100% { transform: translate(0, 0); opacity: .2; } 30% { opacity: 1; } 50% { transform: translate(40px, -30px); opacity: .5; } 70% { opacity: 1; } 85% { transform: translate(-20px, 20px); } }
.fx-sparkle { font-size: 14px; animation-name: amb-sparkle; animation-timing-function: ease-in-out; }
@keyframes amb-sparkle { 0%, 100% { transform: scale(.2) rotate(0); opacity: 0; } 50% { transform: scale(1.1) rotate(90deg); opacity: 1; } }

/* กลางวัน/กลางคืน */
.world-map::before { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 1500; transition: background .6s; }
.world-map.tod-night::before { background: radial-gradient(circle at 50% 50%, rgba(20, 30, 90, .25), rgba(8, 12, 45, .55)); }
.world-map.tod-dusk::before { background: linear-gradient(180deg, rgba(255, 120, 60, .22), rgba(120, 40, 120, .18)); }
.world-map.tod-dawn::before { background: linear-gradient(180deg, rgba(255, 190, 150, .2), rgba(120, 160, 255, .1)); }
.world-map.tod-night .w-win { background: #fde68a; box-shadow: 0 0 12px 3px rgba(251, 191, 36, .8); }
.world-map.tod-night .w-portal-ring { box-shadow: 0 0 40px 6px rgba(129, 140, 248, .9); }
@media (prefers-reduced-motion: reduce) {
  .world-map.is-shake, .world-map.is-shake-strong, .w-char .w-av { animation: none !important; }
}

/* ---------- ภาพพิกเซลอาร์ต (Kenney CC0) ---------- */
.px { display: inline-block; background-repeat: no-repeat; image-rendering: pixelated; image-rendering: crisp-edges; flex: none; }
.px-town { background-image: url("../img/pixel/town.png"); }
.px-dun { background-image: url("../img/pixel/dungeon.png"); }
.px-grid { display: grid; line-height: 0; }
.world-map { width: max(1400px, 100%); background: #3f9a5a; isolation: isolate; }
.w-ground-px { position: absolute; left: 0; top: 0; image-rendering: pixelated; pointer-events: none; }
.w-decor { position: absolute; inset: 0; pointer-events: none; }
.w-deco-px { position: absolute; transform: translate(-50%, -85%); filter: drop-shadow(0 5px 3px rgba(0, 0, 0, .3)); }

.w-house-px, .w-castle-px, .w-dock-px { position: relative; filter: drop-shadow(0 8px 6px rgba(0, 0, 0, .35)); transition: transform .2s; }
.w-place:hover .w-house-px, .w-place:hover .w-castle-px, .w-place:hover .w-dock-px { transform: translateY(-3px); }
.w-sign-px { position: absolute; top: -10px; right: -10px; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: #fff7e0; border: 3px solid #7c4a1e; font-size: 18px; line-height: 1; box-shadow: 0 3px 0 #5b3514; }
.w-flag { position: absolute; top: -30px; left: 50%; transform: translateX(-50%); display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--pc); border: 3px solid #fff; font-size: 20px; box-shadow: 0 3px 8px rgba(0, 0, 0, .4); }
.w-cottage-px { position: absolute; transform: translate(-50%, -60%); pointer-events: none; filter: drop-shadow(0 6px 4px rgba(0, 0, 0, .3)); }
.w-fountain-px { filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .35)); }

/* ตัวละครพิกเซล */
.w-char .w-sprite { order: 1; position: relative; width: 48px; height: 48px; z-index: 2; }
.w-char .w-spr { display: block; transform-origin: 50% 100%; }
.w-gear-weapon { position: absolute; right: -12px; top: 16px; transform-origin: 30% 80%; transform: rotate(-25deg); }
.w-gear-armor { position: absolute; left: -10px; top: 20px; }
.w-char.is-walking .w-spr { animation: spr-hop .3s steps(2) infinite; }
.w-char:not(.is-walking) .w-spr { animation: spr-idle 1.8s steps(2) infinite; }
@keyframes spr-hop { 0% { transform: translateY(0) rotate(4deg); } 50% { transform: translateY(-5px) rotate(-4deg); } 100% { transform: translateY(0) rotate(4deg); } }
@keyframes spr-idle { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.93); } }
.w-char.face-left .w-sprite { transform: scaleX(-1); }
.w-char .w-shadow { bottom: auto; top: 40px; width: 34px; height: 10px; margin-left: -17px; }
.w-char.is-me .w-shadow { background: rgba(251, 191, 36, .45); box-shadow: 0 0 0 2px #fbbf24; }
.w-char.is-gm .w-shadow { background: rgba(232, 121, 249, .45); box-shadow: 0 0 0 2px #e879f9; }
.w-npc .w-shadow { background: rgba(134, 239, 172, .35); box-shadow: 0 0 0 2px #86efac; }
.w-char.is-attack .w-gear-weapon { animation: w-slash .15s linear 3 alternate; }
.w-char.is-knock .w-sprite { animation: knock .35s ease-out; }
.w-char.is-away .w-sprite::after { content: "💤"; position: absolute; right: -14px; top: -10px; font-size: 16px; }
.w-tag-face { display: inline-block; width: 16px; height: 16px; border-radius: 50%; overflow: hidden; flex: none; }
.w-tag-face svg { width: 100%; height: 100%; display: block; }

/* มอนสเตอร์พิกเซล */
.w-mon-px { filter: drop-shadow(0 5px 3px rgba(0, 0, 0, .4)); }
.w-giant-px { filter: drop-shadow(0 12px 8px rgba(0, 0, 0, .45)); }
.w-giant-crown { order: -1; font-size: 34px; line-height: 1; margin-bottom: -26px; z-index: 2; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .5)); }
@media (prefers-reduced-motion: reduce) { .w-char .w-spr { animation: none !important; } }

/* ---------- หน้าจอปลดล็อก PIN (แบบมือถือ) ---------- */
.lock { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px 16px 28px; background: radial-gradient(120% 80% at 50% 0%, #4c3fbf 0%, #1a1650 55%, #0b0a24 100%); color: #fff; }
.lock-inner { width: min(360px, 100%); display: grid; justify-items: center; gap: 12px; text-align: center; }
.lock-top { display: grid; gap: 2px; }
.lock-time { font: 300 3.2rem/1 Prompt, sans-serif; letter-spacing: 1px; }
.lock-date { font-size: .9rem; opacity: .75; }
.lock-who { display: grid; justify-items: center; gap: 6px; margin-top: 6px; }
.lock-who .av { box-shadow: 0 0 0 4px rgba(255, 255, 255, .25), 0 10px 30px rgba(0, 0, 0, .4); border-radius: 50%; }
.lock-name { font: 600 1.15rem/1.3 Prompt, sans-serif; }
.lock-id { opacity: .6; }
.lock-title { font: 600 1.05rem/1.4 Prompt, sans-serif; margin-top: 4px; }
.lock-hint { opacity: .75; min-height: 1.4em; }
.lock-dots { display: flex; gap: 16px; margin: 6px 0 8px; }
.lock-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .85); transition: background .12s, transform .12s; }
.lock-dots span.is-on { background: #fff; transform: scale(1.1); }
.lock.is-shake .lock-dots { animation: lock-shake .45s ease-in-out; }
.lock.is-shake .lock-dots span { border-color: #fca5a5; }
@keyframes lock-shake { 15%, 55% { transform: translateX(-12px); } 35%, 75% { transform: translateX(12px); } 90% { transform: translateX(-4px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px 26px; justify-content: center; margin-top: 4px; }
.key { width: 76px; height: 76px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .14); color: #fff; font: 400 1.9rem/1 Prompt, sans-serif; cursor: pointer; transition: background .12s, transform .08s; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.key:hover { background: rgba(255, 255, 255, .22); }
.key:active, .key.is-press { background: rgba(255, 255, 255, .45); transform: scale(.94); }
.key-fn { background: transparent; font-size: 1.5rem; }
.key-blank { width: 76px; height: 76px; background: transparent !important; }
.lock.is-busy .keypad { opacity: .5; pointer-events: none; }
.lock-remember { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 14px; opacity: .8; }
.lock-idcard { display: grid; gap: 6px; margin-bottom: 12px; text-align: left; }
.lock-idcard input { background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .3); color: #fff; text-align: center; letter-spacing: 3px; }
.lock-foot { margin: 0; opacity: .8; }
.lock-link { background: none; border: 0; color: #c7d2fe; font: inherit; font-size: .9rem; cursor: pointer; text-decoration: underline; }
.lock .flash-stack { width: 100%; }
@media (max-height: 700px) { .lock-time { font-size: 2.4rem; } .key, .key-blank { width: 64px; height: 64px; } .keypad { grid-template-columns: repeat(3, 64px); gap: 12px 22px; } }

/* ---------- ปุ่มเพลง/เสียง ---------- */
[data-music-toggle].is-off, [data-sfx-toggle][aria-pressed="false"] { opacity: .6; text-decoration: line-through; }

/* =====================================================================
   โลกแบบเต็มจอ (เกม) · HUD ลอย · หน้าต่างภายในเกม
   ===================================================================== */
body.is-fullgame { overflow: hidden; background: #0b0a1e; overscroll-behavior: none; }
.game-full { position: fixed; inset: 0; }
.game-full > .flash-stack { position: fixed; z-index: 3500; top: 86px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 24px)); }
.gs { position: absolute; inset: 0; overflow: hidden; animation: gs-in .7s ease-out; --gold-a: #f5d487; --gold-b: #b8863b; --wood: #2b1d12; }
@keyframes gs-in { from { filter: brightness(0); } to { filter: none; } }

/* กรอบแบบเกม RPG */
.gs-frame, .gw-win {
  background: linear-gradient(180deg, rgba(40, 30, 72, .94), rgba(22, 17, 44, .95));
  border: 2px solid var(--gold-b, #b8863b);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 226, 150, .25), inset 0 2px 0 rgba(255, 255, 255, .08), 0 0 0 2px rgba(20, 12, 4, .85), 0 12px 32px rgba(0, 0, 0, .5);
  color: #f3eefe;
}

.gs .world-scroll { position: absolute; inset: 0; height: auto; border-radius: 0; box-shadow: none; overflow: auto; scrollbar-width: none; }
.gs .world-scroll::-webkit-scrollbar { display: none; }
.gs .world-map { border-radius: 0; width: max(1600px, 100vw); min-height: 100vh; min-height: 100dvh; aspect-ratio: auto; height: max(1024px, 100vh, calc(max(1600px, 100vw) * .64)); }
.gs-vignette { position: absolute; inset: 0; pointer-events: none; z-index: 5; background: radial-gradient(ellipse at 50% 50%, transparent 58%, rgba(5, 4, 20, .55) 100%); }

/* ผู้เล่น (ซ้ายบน) */
.gs-me { position: absolute; z-index: 20; top: 12px; left: 12px; display: flex; gap: 12px; align-items: center; padding: 10px 14px 10px 10px; min-width: 300px; text-align: left; cursor: pointer; font: inherit; transition: transform .15s; }
.gs-me:hover { transform: translateY(-1px); }
.gs-me .av { flex: none; border-radius: 50%; box-shadow: 0 0 0 3px var(--gold-b), 0 0 0 5px rgba(20, 12, 4, .8); }
.gs-me-info { display: grid; gap: 3px; min-width: 0; flex: 1; }
.gs-me-name { font: 600 1rem/1.2 var(--font-display, Prompt), sans-serif; display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.gs-name-text { overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.gs-me-title { color: var(--gold-a); opacity: .9; }
.gs-xp { position: relative; display: block; height: 14px; border-radius: 7px; background: rgba(0, 0, 0, .45); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); overflow: hidden; }
.gs-xp > span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #22d3ee, #818cf8, #c084fc); border-radius: 7px; transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.gs-xp > span::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent); animation: gs-shine 2.6s linear infinite; }
@keyframes gs-shine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.gs-xp em { position: relative; display: block; text-align: center; font: 600 .68rem/14px Prompt, sans-serif; font-style: normal; text-shadow: 0 1px 2px #000; }
.gs-me-row { display: flex; gap: 12px; font-size: .88rem; }
.gs-me-row b { font-weight: 700; display: inline-block; }
.gs-me-row > span { position: relative; }
.is-bump { animation: gs-bump .5s ease-out; }
@keyframes gs-bump { 40% { transform: scale(1.5); color: #fde047; } }
.gs-gain { position: absolute; left: 50%; top: -4px; transform: translateX(-50%); color: #fde047; font-weight: 700; font-size: .85rem; white-space: nowrap; text-shadow: 0 1px 3px #000; pointer-events: none; animation: gs-gain 1.6s ease-out forwards; z-index: 2; }
@keyframes gs-gain { from { opacity: 0; transform: translate(-50%, 6px); } 20% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -26px); } }

/* ชื่อโซน (กลางบน) */
.gs-zone { position: absolute; z-index: 20; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; align-items: center; padding: 7px 16px; border-radius: 999px; white-space: nowrap; font-size: .9rem; }
.gs-zone-name { font: 600 1.05rem Prompt, sans-serif; color: var(--gold-a); }
.gs-zone-online { opacity: .85; }

/* ขวาบน: ปุ่มระบบ + แผนที่ย่อ */
.gs-corner { position: absolute; z-index: 20; top: 12px; right: 12px; display: grid; gap: 8px; justify-items: end; }
.gs-sys { display: flex; gap: 6px; }
.gs-btn { height: 36px; min-width: 36px; padding: 0 10px; border-radius: 9px; border: 2px solid var(--gold-b); background: linear-gradient(180deg, #3a2d66, #221a44); color: #fff; font: 500 .85rem Prompt, sans-serif; cursor: pointer; box-shadow: 0 0 0 2px rgba(20, 12, 4, .85), 0 4px 10px rgba(0, 0, 0, .35); transition: transform .1s, filter .15s; }
.gs-btn:hover { filter: brightness(1.2); }
.gs-btn:active { transform: translateY(1px); }
.gs-btn.is-on { background: linear-gradient(180deg, #7c5a1c, #4a3310); }
.gs-btn[aria-pressed="false"], .gs-btn.is-off { opacity: .6; text-decoration: none; }
.gs-minimap { padding: 5px; line-height: 0; }
.gs-minimap canvas { width: 200px; height: 128px; border-radius: 7px; cursor: crosshair; image-rendering: pixelated; }

/* แถบคำสั่ง (ล่าง) */
.gs-bar { position: absolute; z-index: 20; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; align-items: center; padding: 7px; max-width: calc(100vw - 24px); overflow-x: auto; scrollbar-width: none; }
.gs-bar::-webkit-scrollbar { display: none; }
.gs-slot { position: relative; flex: none; width: 70px; height: 62px; display: grid; place-items: center; align-content: center; gap: 2px; border-radius: 10px; border: 2px solid rgba(245, 212, 135, .35); background: linear-gradient(180deg, rgba(255, 255, 255, .1), rgba(0, 0, 0, .25)); color: #fff; font: inherit; cursor: pointer; text-decoration: none; transition: transform .12s, border-color .15s, background .15s; }
.gs-slot:hover { border-color: var(--gold-a); background: linear-gradient(180deg, rgba(245, 212, 135, .25), rgba(0, 0, 0, .2)); transform: translateY(-3px); }
.gs-slot:active, .gs-slot.is-press { transform: translateY(1px) scale(.96); }
.gs-ico { font-size: 1.45rem; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .5)); }
.gs-lbl { font-size: .68rem; line-height: 1.1; white-space: nowrap; opacity: .92; }
.gs-slot kbd { position: absolute; top: 2px; left: 4px; font: 600 .6rem monospace; color: var(--gold-a); opacity: .8; background: none; border: 0; padding: 0; }
.gs-badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #ef4444; color: #fff; font: 700 .7rem/20px Prompt, sans-serif; box-shadow: 0 0 0 2px #1b1433; }
.gs-badge:empty { display: none; }
.gs-sep { width: 2px; align-self: stretch; margin: 4px 2px; background: rgba(245, 212, 135, .3); }
.gs-leave { border-color: rgba(248, 113, 113, .4); }
.gs-leave:hover { border-color: #f87171; background: linear-gradient(180deg, rgba(248, 113, 113, .25), rgba(0, 0, 0, .2)); }

/* อีโมต (ลอยเหนือแถบคำสั่ง) */
.gs .world-emotes { position: absolute; z-index: 21; bottom: 94px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); padding: 10px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; animation: w-pop .18s ease-out; }
.gs .world-emotes[hidden] { display: none; }

/* แผงข้อมูล/ต่อสู้ (ขวา) */
body.is-fullgame .world-panel { position: absolute; z-index: 25; top: 196px; right: 12px; bottom: auto; width: min(420px, calc(100vw - 24px)); max-height: calc(100vh - 300px); max-height: calc(100dvh - 300px); padding: 16px; background: linear-gradient(180deg, rgba(40, 30, 72, .96), rgba(22, 17, 44, .97)); border: 2px solid #b8863b; }
body.is-fullgame .world-panel h3 { color: #f5d487; }

/* ป้ายชื่อโซนตอนเข้า */
.gs-banner { position: absolute; z-index: 30; left: 50%; top: 24%; transform: translateX(-50%); text-align: center; pointer-events: none; animation: gs-banner 3.6s ease-in-out forwards; }
.gs-banner-icon { font-size: 3.2rem; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .6)); }
.gs-banner-name { font: 700 clamp(2rem, 5vw, 3.4rem)/1.1 Prompt, sans-serif; color: #fde68a; letter-spacing: 2px; text-shadow: 0 0 20px rgba(251, 191, 36, .6), 0 3px 0 #7c4a03, 0 6px 16px rgba(0, 0, 0, .7); }
.gs-banner-desc { margin-top: 6px; font-size: 1.05rem; color: #fff; text-shadow: 0 2px 6px #000; }
.gs-banner::before, .gs-banner::after { content: ""; display: block; height: 2px; margin: 8px auto; width: 70%; background: linear-gradient(90deg, transparent, #f5d487, transparent); }
@keyframes gs-banner { 0% { opacity: 0; transform: translate(-50%, 16px) scale(.96); } 15%, 75% { opacity: 1; transform: translate(-50%, 0) scale(1); } 100% { opacity: 0; transform: translate(-50%, -10px); } }

/* จุดหมายที่คลิก */
.fx-target { width: 34px; height: 16px; margin: -8px 0 0 -17px; border-radius: 50%; border: 3px solid #fde047; box-shadow: 0 0 10px rgba(253, 224, 71, .8); animation: fx-target .65s ease-out forwards; }
@keyframes fx-target { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.w-char.is-me::before { content: ""; position: absolute; left: 50%; top: 34px; width: 46px; height: 18px; margin-left: -23px; border-radius: 50%; background: radial-gradient(closest-side, rgba(253, 224, 71, .35), transparent); animation: w-aura 1.8s ease-in-out infinite; pointer-events: none; }
@keyframes w-aura { 50% { transform: scale(1.25); opacity: .6; } }

/* ---------- หน้าต่างภายในเกม ---------- */
.gw { position: fixed; inset: 0; z-index: 4000; display: grid; place-items: center; padding: 14px; }
.gw[hidden] { display: none; }
.gw-backdrop { position: absolute; inset: 0; background: rgba(6, 4, 20, .55); backdrop-filter: blur(3px); opacity: 0; transition: opacity .18s; }
.gw-win { --gold-b: #b8863b; position: relative; display: flex; flex-direction: column; width: min(1100px, 100%); height: min(88vh, 920px); height: min(88dvh, 920px); overflow: hidden; transform: scale(.92) translateY(14px); opacity: 0; transition: transform .2s cubic-bezier(.2, .9, .3, 1.2), opacity .18s; }
.gw.is-in .gw-backdrop { opacity: 1; }
.gw.is-in .gw-win { transform: none; opacity: 1; }
.gw-bar { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: linear-gradient(180deg, #5b3f14, #3a270b); border-bottom: 2px solid #b8863b; }
.gw-title { flex: 1; font: 600 1.05rem Prompt, sans-serif; color: #fde68a; text-shadow: 0 2px 0 rgba(0, 0, 0, .5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gw-btn { width: 34px; height: 34px; flex: none; border-radius: 8px; border: 2px solid #b8863b; background: linear-gradient(180deg, #3a2d66, #221a44); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer; }
.gw-btn:hover { filter: brightness(1.25); }
.gw-close:hover { background: linear-gradient(180deg, #b91c1c, #7f1d1d); }
.gw-btn[hidden] { display: none; }
.gw-body { position: relative; flex: 1; background: #0c0e29; }
.gw-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0c0e29; }
.gw-loading { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; justify-items: center; gap: 8px; color: #c7c2e8; background: #0c0e29; }
.gw-loading[hidden] { display: none; }
.gw-spin { font-size: 2rem; animation: gw-spin 1s linear infinite; }
@keyframes gw-spin { to { transform: rotate(360deg); } }
body.gw-open .gs-bar, body.gw-open .gs-me, body.gw-open .gs-corner { filter: brightness(.6); }
body.is-fullgame .toasts { z-index: 5000; bottom: 96px; }

/* หน้าที่แสดงในหน้าต่างเกม */
body.is-embed .game-main { padding: 16px 0 30px; }
body.is-embed .wrap { max-width: 100%; }
body.is-embed.theme-staff .staff-shell { display: block; }
body.is-embed.theme-staff .sidebar, body.is-embed.theme-staff .staff-top { display: none; }
.embed-close { display: grid; place-items: center; gap: 8px; min-height: 50vh; text-align: center; }
.embed-close-icon { font-size: 3rem; animation: gw-spin 2s linear infinite; }

/* มือถือ/จอเล็ก */
@media (hover: none) { .gs-slot kbd { display: none; } }
@media (max-width: 760px) {
  .gs-me { min-width: 0; max-width: calc(100vw - 150px); padding: 6px 10px 6px 6px; gap: 8px; }
  .gs-me .av { --av: 42px !important; }
  .gs-me-title { display: none; }
  .gs-name-text { max-width: 110px; }
  .gs-me-row { gap: 8px; font-size: .78rem; }
  .gs-zone { top: auto; bottom: 86px; font-size: .8rem; padding: 5px 12px; }
  .gs-zone-name { font-size: .9rem; }
  .gs-minimap canvas { width: 116px; height: 74px; }
  .gs-sys { display: grid; grid-template-columns: repeat(2, auto); justify-content: end; }
  .gs-btn { height: 32px; font-size: .75rem; padding: 0 7px; }
  .gs-bar { left: 6px; right: 6px; bottom: 6px; transform: none; max-width: none; }
  .gs-slot { width: 58px; height: 56px; }
  .gs .world-emotes { bottom: 128px; }
  body.is-fullgame .world-panel { top: auto; bottom: 76px; left: 8px; right: 8px; width: auto; max-height: 60vh; }
  .gw { padding: 0; }
  .gw-win { width: 100%; height: 100%; border-radius: 0; }
  body.is-fullgame .toasts { bottom: 140px; }
}
@media (prefers-reduced-motion: reduce) {
  .gs, .gs-banner, .gs-xp > span::after, .w-char.is-me::before { animation: none !important; }
}

/* ---------- ตัวละครพิกเซล 4 ทิศ (sprite.js) ---------- */
.w-char.has-hero .w-sprite { width: 60px; height: 96px; }
.w-hero { width: 60px; height: 96px; background-repeat: no-repeat; background-size: 240px 384px; image-rendering: pixelated; background-position-x: 0; background-position-y: calc(var(--row, 0) * -96px); transform-origin: 50% 88%; }
.w-char[data-dir="left"] .w-hero { --row: 1; }
.w-char[data-dir="right"] .w-hero { --row: 2; }
.w-char[data-dir="up"] .w-hero { --row: 3; }
.w-char.has-hero.is-walking .w-hero { animation: hero-walk .52s steps(4) infinite; }
.w-char.has-hero:not(.is-walking) .w-hero { animation: hero-idle 2.4s ease-in-out infinite; }
@keyframes hero-walk { from { background-position-x: 0; } to { background-position-x: -240px; } }
@keyframes hero-idle { 50% { transform: scaleY(.97); } }
.w-char.has-hero.face-left .w-sprite, .w-char.has-hero.face-left:not(.is-walking) .w-av { transform: none; }
.w-char.has-hero .w-shadow { top: 82px; width: 32px; height: 10px; margin-left: -16px; }
.w-char.has-hero.is-me::before { top: 78px; }
.w-char.has-hero .w-bubble { bottom: calc(100% - 26px); }
.w-char.has-hero .w-mark { top: -4px; }
.w-char.has-hero .w-tag { margin-top: -6px; }
.w-char.is-lunge .w-sprite, .w-monster.is-lunge .w-mon-px { animation: lunge .38s ease-out; }
@keyframes lunge { 35% { transform: translate(var(--lx, 0), var(--ly, 0)); } }

/* สัตว์เลี้ยงเดินตาม */
.w-petf { position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform; transition: opacity .5s; }
.w-petf > span { position: absolute; left: -14px; top: -30px; display: block; font-size: 26px; line-height: 1; filter: drop-shadow(0 4px 2px rgba(0, 0, 0, .35)); animation: pet-idle 2s ease-in-out infinite; }
.w-petf.face-right > span { scale: -1 1; }
.w-petf.is-moving > span { animation: pet-hop .34s ease-in-out infinite; }
.w-petf.is-leaving { opacity: 0; }
@keyframes pet-idle { 50% { transform: translateY(-3px); } }
@keyframes pet-hop { 50% { transform: translateY(-9px) rotate(-6deg); } }

/* เลเวลอัป */
.fx-pillar { width: 80px; height: 300px; border-radius: 40px 40px 0 0; background: linear-gradient(to top, rgba(253, 224, 71, .95), rgba(255, 255, 255, .6) 40%, rgba(253, 224, 71, 0)); filter: blur(3px); mix-blend-mode: screen; animation: fx-pillar 1.6s ease-out forwards; }
@keyframes fx-pillar { 0% { opacity: 0; transform: translate(-50%, -100%) scaleX(.2); } 20% { opacity: 1; transform: translate(-50%, -100%) scaleX(1); } 100% { opacity: 0; transform: translate(-50%, -100%) scaleX(1.4); } }
.fx-lvtext { white-space: nowrap; font: 800 1.6rem Prompt, sans-serif; color: #fde047; letter-spacing: 1px; text-shadow: 0 3px 0 #92400e, 0 0 18px rgba(253, 224, 71, .8); animation: fx-lvtext 2.2s ease-out forwards; }
@keyframes fx-lvtext { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 25% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -120%); } }
.fx-coin { font-size: 20px; animation: fx-coin .9s cubic-bezier(.2, .8, .4, 1) forwards; }
@keyframes fx-coin { 0% { transform: translate(-50%, -50%); opacity: 1; } 60% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))); opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 30px)); opacity: 0; } }

/* หีบสมบัติ */
.w-chest { position: absolute; transform: translate(-50%, -100%); width: 54px; height: 48px; padding: 0; border: 0; background: none; cursor: pointer; }
.w-chest-img { display: block; width: 54px; height: 48px; background-size: 54px 48px; background-repeat: no-repeat; image-rendering: pixelated; filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .4)); transform-origin: 50% 100%; }
.w-chest:not(.is-open):not(.is-lost) .w-chest-img { animation: chest-bob 2.4s ease-in-out infinite; }
.w-chest:not(.is-open):not(.is-lost)::after { content: "✨"; position: absolute; top: -12px; right: -8px; font-size: 18px; animation: chest-twinkle 1.6s ease-in-out infinite; }
.w-chest:hover .w-chest-img { filter: drop-shadow(0 0 8px #fde047); }
.w-chest.is-open { opacity: .8; }
.w-chest.is-lost .w-chest-img { filter: grayscale(1) brightness(.7); }
.w-chest.is-shake .w-chest-img { animation: chest-shake .2s linear 4; }
@keyframes chest-bob { 50% { transform: translateY(-3px); } }
@keyframes chest-twinkle { 50% { opacity: .2; transform: scale(.6) rotate(20deg); } }
@keyframes chest-shake { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
.gs-chest-chip, .gs-wx { font-size: .85rem; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .3); }
.gs-chest-chip.is-done { color: #86efac; }

/* สภาพอากาศ */
.w-weather { position: absolute; inset: 0; z-index: 6; pointer-events: none; overflow: hidden; }
.w-weather-rain { background: rgba(20, 30, 70, .16); }
.w-weather-fog { background: rgba(200, 210, 230, .06); }
.w-weather-sunny { background: linear-gradient(115deg, rgba(255, 240, 180, .14), transparent 35%, rgba(255, 240, 180, .08) 60%, transparent 85%); }
.wx-rain { position: absolute; top: -20px; width: 2px; height: 20px; background: linear-gradient(transparent, rgba(190, 215, 255, .8)); transform: rotate(12deg); animation: wx-rain linear infinite; }
@keyframes wx-rain { to { transform: translate(-60px, 110vh) rotate(12deg); } }
.wx-petal { position: absolute; top: -30px; animation: wx-petal linear infinite; }
@keyframes wx-petal { to { transform: translate(-40vw, 110vh) rotate(600deg); } }
.wx-fog { position: absolute; width: 70vw; height: 42vh; border-radius: 50%; background: radial-gradient(closest-side, rgba(225, 232, 245, .38), transparent); filter: blur(8px); animation: wx-fog ease-in-out infinite alternate; }
@keyframes wx-fog { from { transform: translateX(-25vw); } to { transform: translateX(35vw); } }
.wx-cloud { position: absolute; left: 0; width: 42vw; height: 28vh; border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 0, 30, .2), transparent); filter: blur(10px); animation: wx-cloud linear infinite; }
@keyframes wx-cloud { from { transform: translateX(-50vw); } to { transform: translateX(120vw); } }
.wx-drip { position: absolute; top: 0; width: 3px; height: 10px; border-radius: 2px; background: rgba(125, 211, 252, .85); animation: wx-drip ease-in infinite; }
@keyframes wx-drip { 0%, 55% { transform: translateY(0); opacity: 0; } 60% { opacity: 1; } 100% { transform: translateY(70vh); opacity: .1; } }
.wx-fly { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #fef08a; box-shadow: 0 0 10px 3px rgba(254, 240, 138, .8); animation: wx-fly ease-in-out infinite alternate; }
@keyframes wx-fly { 50% { opacity: .2; } to { transform: translate(40px, -30px); } }
@media (prefers-reduced-motion: reduce) {
  .w-char.has-hero .w-hero, .w-petf > span, .w-chest .w-chest-img, .w-chest::after { animation: none !important; }
}

/* =====================================================================
   ธีมเกม RPG สำหรับทุกหน้าของนักเรียน (กรอบทอง ปุ่มเกม หัวข้อสีทอง)
   ===================================================================== */
.theme-game {
  --rpg-gold: #f5d487;
  --rpg-gold-b: #b8863b;
  --rpg-edge: rgba(20, 12, 4, .85);
  --rpg-panel: linear-gradient(180deg, rgba(40, 30, 72, .92), rgba(22, 17, 44, .94));
  --panel-solid: #1f1840;
  --accent: #a78bfa;
}
.theme-game::before {
  background:
    radial-gradient(1000px 520px at 50% -10%, rgba(124, 92, 255, .28), transparent 65%),
    radial-gradient(700px 400px at 100% 100%, rgba(245, 212, 135, .10), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0 2px, transparent 2px 24px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .025) 0 2px, transparent 2px 24px),
    linear-gradient(180deg, #120d2b 0%, #0b0920 100%);
}
.theme-game h1, .theme-game h2 { color: #fde68a; text-shadow: 0 2px 0 rgba(0, 0, 0, .55); letter-spacing: .2px; }
.theme-game h3 { color: #fef3c7; }

/* การ์ด = หน้าต่างเกม */
.theme-game .card, .theme-game .hero, .theme-game .stat, .theme-game .table-wrap, .theme-game details.disclosure, .theme-game .modal, .theme-game .celebrate-card, .theme-game .toast, .theme-game .auth-card {
  background: var(--rpg-panel);
  border: 2px solid var(--rpg-gold-b);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 226, 150, .22), inset 0 2px 0 rgba(255, 255, 255, .06), 0 0 0 2px var(--rpg-edge), 0 10px 26px rgba(0, 0, 0, .4);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.theme-game .hero { background: radial-gradient(600px 240px at 90% 0%, rgba(245, 212, 135, .16), transparent 70%), var(--rpg-panel); }
.theme-game .realm-card { border: 2px solid color-mix(in srgb, var(--realm) 70%, #b8863b); border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12), 0 0 0 2px var(--rpg-edge), 0 10px 26px rgba(0, 0, 0, .4); }
.theme-game .card-glow { box-shadow: inset 0 0 0 1px rgba(255, 226, 150, .22), 0 0 0 2px var(--rpg-edge), 0 0 26px color-mix(in srgb, var(--realm) 45%, transparent); }
.theme-game .table th { background: rgba(0, 0, 0, .25); color: var(--rpg-gold); }
.theme-game .table-sticky-first td:first-child { background: #1d1638; }

/* ปุ่มเกม */
.theme-game .btn {
  border: 2px solid var(--rpg-gold-b);
  border-radius: 10px;
  background: linear-gradient(180deg, #3d2f6b, #231a47);
  color: #fff;
  box-shadow: 0 0 0 2px var(--rpg-edge), 0 3px 0 #0b0720, inset 0 1px 0 rgba(255, 255, 255, .15);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .4);
}
.theme-game .btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.theme-game .btn:active { transform: translateY(2px); box-shadow: 0 0 0 2px var(--rpg-edge), 0 1px 0 #0b0720; }
.theme-game .btn-primary, .theme-game .btn-gold {
  background: linear-gradient(180deg, #fde68a, #f59e0b 55%, #d97706);
  color: #3a2200;
  border-color: #7c4a03;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
  box-shadow: 0 0 0 2px var(--rpg-edge), 0 3px 0 #5b3303, inset 0 1px 0 rgba(255, 255, 255, .5);
}
.theme-game .btn-realm { background: linear-gradient(180deg, color-mix(in srgb, var(--realm) 80%, #fff), var(--realm)); border-color: color-mix(in srgb, var(--realm) 60%, #000); }
.theme-game .btn-ok { background: linear-gradient(180deg, #4ade80, #16a34a); border-color: #14532d; }
.theme-game .btn-danger { background: linear-gradient(180deg, #f87171, #dc2626); border-color: #7f1d1d; }
.theme-game .btn-ghost { background: rgba(0, 0, 0, .2); border-color: rgba(245, 212, 135, .35); box-shadow: none; }

/* ช่องกรอก แถบ แท็บ */
.theme-game input[type=text], .theme-game input[type=password], .theme-game input[type=number], .theme-game input[type=search], .theme-game input[type=url], .theme-game select, .theme-game textarea {
  background: rgba(8, 6, 24, .6); border: 2px solid rgba(245, 212, 135, .3); border-radius: 10px;
}
.theme-game input:focus, .theme-game select:focus, .theme-game textarea:focus { border-color: var(--rpg-gold); box-shadow: 0 0 0 3px rgba(245, 212, 135, .2); }
.theme-game .bar { height: 12px; border-radius: 4px; border: 2px solid #0b0720; background: rgba(0, 0, 0, .45); box-shadow: 0 0 0 1px rgba(245, 212, 135, .3); }
.theme-game .bar > span { border-radius: 2px; }
.theme-game .tab.is-active { background: linear-gradient(180deg, rgba(245, 212, 135, .25), rgba(245, 212, 135, .08)); border-color: var(--rpg-gold-b); color: #fde68a; }
.theme-game .level-badge { font-family: 'Press Start 2P', var(--font-display); font-size: .55rem; padding: 4px 6px; border-radius: 4px; background: linear-gradient(180deg, #a78bfa, #6d28d9); box-shadow: 0 0 0 2px var(--rpg-edge); }
.theme-game .celebrate-card { border-color: #f5d487; }

/* แถบเมนูบน = แถบเกม */
.theme-game .hud { background: linear-gradient(180deg, #2a1d4d, #1a1236); border-bottom: 2px solid var(--rpg-gold-b); box-shadow: 0 2px 0 var(--rpg-edge), 0 8px 20px rgba(0, 0, 0, .35); backdrop-filter: none; }
.theme-game .brand { font-family: 'Press Start 2P', var(--font-display); font-size: .78rem; color: #fde68a; text-shadow: 0 2px 0 #7c4a03; letter-spacing: 1px; }
.theme-game .brand-mark { border-radius: 8px; background: linear-gradient(180deg, #fde68a, #d97706); box-shadow: 0 0 0 2px var(--rpg-edge); }
.theme-game .hud-nav a { border: 2px solid transparent; }
.theme-game .hud-nav a.is-active, .theme-game .hud-nav a:hover { background: rgba(245, 212, 135, .12); border-color: rgba(245, 212, 135, .4); color: #fde68a; }
.theme-game .hud-nav a.nav-play { background: linear-gradient(180deg, #fde68a, #f59e0b 55%, #d97706); color: #3a2200; border-color: #7c4a03; font-weight: 700; box-shadow: 0 0 0 2px var(--rpg-edge); }
.theme-game .hud-nav a.nav-play:hover { filter: brightness(1.1); color: #3a2200; }
.theme-game .hud-pill { background: rgba(0, 0, 0, .3); border: 2px solid rgba(245, 212, 135, .35); }
.theme-game .nav-bottom { background: linear-gradient(180deg, #2a1d4d, #1a1236); border-top: 2px solid var(--rpg-gold-b); }
.theme-game .nav-bottom a.nav-play span:first-child { display: inline-grid; place-items: center; width: 40px; height: 40px; margin-top: -14px; border-radius: 50%; background: linear-gradient(180deg, #fde68a, #d97706); box-shadow: 0 0 0 3px #1a1236, 0 0 0 5px var(--rpg-gold-b); }
.theme-game .av svg { image-rendering: pixelated; }

/* =====================================================================
   หน้าเปิดเกม (เข้าสู่ระบบ) และหน้าใส่ PIN
   ===================================================================== */
.ts { position: relative; min-height: 100vh; min-height: 100dvh; overflow: hidden; background: #0b0a1e; }
.ts-bg { position: fixed; inset: 0; z-index: 0; image-rendering: pixelated; }
.ts-clouds { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.ts-clouds .wx-cloud:nth-child(1) { top: 8%; animation-duration: 70s; animation-delay: -10s; }
.ts-clouds .wx-cloud:nth-child(2) { top: 40%; animation-duration: 90s; animation-delay: -50s; }
.ts-clouds .wx-cloud:nth-child(3) { top: 70%; animation-duration: 80s; animation-delay: -30s; }
.ts-shade { position: fixed; inset: 0; z-index: 2; pointer-events: none; background: radial-gradient(ellipse 60% 70% at 50% 42%, rgba(10, 8, 30, .62), rgba(10, 8, 30, .15) 75%, rgba(10, 8, 30, .45)); }
.ts-walker { position: absolute; z-index: 3; left: -80px; pointer-events: none; animation: ts-walk-right 26s linear infinite; }
.ts-walker.go-left { animation-name: ts-walk-left; }
@keyframes ts-walk-right { from { left: -80px; } to { left: calc(100% + 80px); } }
@keyframes ts-walk-left { from { left: calc(100% + 80px); } to { left: -80px; } }
.ts-walker .ts-pet { position: absolute; top: 58px; font-size: 24px; animation: pet-hop .34s ease-in-out infinite; }
.ts-walker.go-right .ts-pet { left: -40px; scale: -1 1; }
.ts-walker.go-left .ts-pet { left: 22px; }
.ts-slime { position: absolute; z-index: 3; width: 48px; height: 48px; background: url(../img/pixel/dungeon.png) no-repeat; background-size: 576px 528px; background-position: 0 -432px; image-rendering: pixelated; animation: ts-slime 1.4s ease-in-out infinite; }
@keyframes ts-slime { 0%, 100% { transform: translateY(0) scale(1.1, .9); } 50% { transform: translateY(-14px) scale(.95, 1.05); } }
.ts-inner { position: relative; z-index: 5; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 28px 16px 24px; }
.ts-logo { text-align: center; }
.ts-swords { font-size: 2.6rem; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .5)); animation: float 3s ease-in-out infinite; }
.ts-title { margin: 6px 0 0; font-family: 'Press Start 2P', var(--font-display); font-size: clamp(2rem, 6.5vw, 4rem); line-height: 1.1; letter-spacing: 4px; color: #fde68a; text-shadow: 0 4px 0 #b45309, 0 8px 0 #5b3303, 0 0 30px rgba(251, 191, 36, .45), 0 14px 24px rgba(0, 0, 0, .6); }
.ts-title span:last-child { color: #fff7d6; }
.ts-sub { margin-top: 12px; font: 700 clamp(1.1rem, 2.6vw, 1.5rem) Prompt, sans-serif; color: #fff; text-shadow: 0 2px 0 #3b0764, 0 4px 12px rgba(0, 0, 0, .7); }
.ts-term { margin-top: 6px; display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: .85rem; color: #fde68a; background: rgba(0, 0, 0, .45); border: 1px solid rgba(245, 212, 135, .45); }
.ts-card { width: min(420px, 100%); padding: 22px; }
.ts-card .role-toggle { background: rgba(0, 0, 0, .35); border: 2px solid rgba(245, 212, 135, .25); }
.ts-card .role-toggle button.is-active { background: linear-gradient(180deg, #a78bfa, #6d28d9); box-shadow: 0 0 0 2px var(--rpg-edge); }
.ts-start { font-size: 1.15rem; letter-spacing: .5px; animation: ts-pulse 2.2s ease-in-out infinite; }
@keyframes ts-pulse { 50% { box-shadow: 0 0 0 2px var(--rpg-edge), 0 3px 0 #5b3303, 0 0 22px rgba(251, 191, 36, .65); } }
.ts-realms { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: min(900px, 100%); }
.ts-realm { display: flex; gap: 10px; align-items: center; padding: 8px 14px 8px 10px; border-radius: 10px; background: rgba(15, 10, 35, .78); border: 2px solid color-mix(in srgb, var(--c) 70%, #b8863b); box-shadow: 0 0 0 2px var(--rpg-edge); }
.ts-realm-icon { font-size: 1.6rem; }
.ts-realm-text { display: grid; line-height: 1.25; }
.ts-realm-text strong { font-family: Prompt, sans-serif; font-size: .92rem; color: #fff; }
.ts-realm-text small { color: #c9c3ea; font-size: .75rem; }
.ts-features { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ts-features li { padding: 4px 12px; border-radius: 999px; font-size: .85rem; color: #fff; background: rgba(0, 0, 0, .45); border: 1px solid rgba(255, 255, 255, .15); }
.ts-foot { margin: 0; font-size: .78rem; color: rgba(255, 255, 255, .6); text-shadow: 0 1px 2px #000; }
@media (max-width: 600px) { .ts-features, .ts-realms { display: none; } .ts-inner { justify-content: flex-start; padding-top: 22px; } }

/* หน้าใส่ PIN ในกรอบเกม */
.lock.ts { background: #0b0a1e; display: grid; place-items: center; }
.lock .lock-card { position: relative; z-index: 5; width: min(380px, calc(100vw - 24px)); padding: 18px 18px 16px; background: var(--rpg-panel); border: 2px solid #b8863b; border-radius: 14px; box-shadow: inset 0 0 0 1px rgba(255, 226, 150, .22), 0 0 0 2px rgba(20, 12, 4, .85), 0 20px 50px rgba(0, 0, 0, .6); }
.lock .lock-time { font-family: 'Press Start 2P', monospace; font-size: 1.6rem; color: #fde68a; text-shadow: 0 3px 0 #7c4a03; }
.lock .lock-date { font-size: .8rem; }
.lock-hero { display: block; width: 60px; height: 96px; margin: -6px auto -8px; position: relative; }
.lock-hero .w-char { position: static; transform: none; display: block; }
.lock-hero .w-sprite { position: relative; }
.lock-name { color: #fde68a; }
.lock .key { background: linear-gradient(180deg, #3d2f6b, #231a47); border: 2px solid #b8863b; box-shadow: 0 0 0 2px rgba(20, 12, 4, .85), 0 3px 0 #0b0720; font-family: 'Press Start 2P', monospace; font-size: 1.1rem; }
.lock .key:hover { filter: brightness(1.2); background: linear-gradient(180deg, #4b3a82, #2b2057); }
.lock .key:active, .lock .key.is-press { transform: translateY(2px); background: linear-gradient(180deg, #fde68a, #d97706); color: #3a2200; }
.lock .key-fn { background: transparent; border-color: transparent; box-shadow: none; font-family: inherit; }
.lock .lock-dots span { border-radius: 3px; border-color: #f5d487; transform: rotate(45deg); width: 14px; height: 14px; }
.lock .lock-dots span.is-on { background: #fde68a; box-shadow: 0 0 10px rgba(253, 230, 138, .8); transform: rotate(45deg) scale(1.1); }
.lock .keypad { grid-template-columns: repeat(3, 64px); gap: 12px 22px; }
.lock .key, .lock .key-blank { width: 64px; height: 64px; }
@media (max-height: 760px) { .lock .lock-top { display: none; } }
.lock-hero .w-sprite, .lock-hero .w-hero { display: block; }
.lock .key-blank { background: none; border: 0; box-shadow: none; }
.lock .lock-card { background: linear-gradient(180deg, #2a2050, #16112e); }

/* เวทีตัวละคร (หน้าสร้าง/แต่งตัวละคร) */
.avatar-stage { gap: 10px; }
.hero-stage { display: flex; align-items: center; gap: 10px; }
.hs-floor { position: relative; width: 170px; height: 176px; border-radius: 12px; border: 2px solid #b8863b; box-shadow: 0 0 0 2px rgba(20, 12, 4, .85), inset 0 -30px 40px rgba(0, 0, 0, .25); background: repeating-conic-gradient(#46a35f 0 25%, #3f9a5a 0 50%) 0 0 / 24px 24px; overflow: hidden; }
.hs-floor .w-char { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); }
.hs-floor .w-sprite { width: 90px; height: 144px; }
.hs-floor .w-hero { width: 90px; height: 144px; background-size: 360px 576px; background-position-y: calc(var(--row, 0) * -144px); }
.hs-floor .w-char.is-walking .w-hero { animation: hs-walk .6s steps(4) infinite; }
@keyframes hs-walk { from { background-position-x: 0; } to { background-position-x: -360px; } }
.hs-floor .w-shadow { top: 124px; width: 46px; height: 12px; margin-left: -23px; }
.hs-rot { width: 38px; height: 38px; border-radius: 50%; border: 2px solid #b8863b; background: linear-gradient(180deg, #3d2f6b, #231a47); color: #fde68a; font-size: 1.2rem; cursor: pointer; box-shadow: 0 0 0 2px rgba(20, 12, 4, .85); }
.hs-rot:hover { filter: brightness(1.2); }
.stage-portrait { display: flex; align-items: center; gap: 8px; }

/* ---------- คำถามจับคู่ / เติมคำ ---------- */
.q-match-row { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: var(--panel-2); border: 2px solid transparent; }
.q-match-row + .q-match-row { margin-top: 8px; }
.q-match-row.is-done { border-color: rgba(52, 224, 161, .45); }
.q-match-left { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.q-match-rights { display: flex; flex-wrap: wrap; gap: 6px; }
.q-chip { padding: 6px 12px; border-radius: 999px; border: 2px solid rgba(245, 212, 135, .35); background: rgba(0, 0, 0, .25); color: var(--text); font: inherit; font-size: .92rem; cursor: pointer; transition: transform .1s, background .15s; }
.q-chip:hover { transform: translateY(-1px); border-color: #f5d487; }
.q-chip.is-selected { background: linear-gradient(180deg, #fde68a, #f59e0b); color: #3a2200; border-color: #7c4a03; font-weight: 700; }
.q-chip.is-used { opacity: .4; }
.q-fill-sentence { line-height: 2.4; }
.q-blank { display: inline-block; min-width: 88px; margin: 0 4px; padding: 2px 12px; border: 0; border-bottom: 3px dashed #f5d487; border-radius: 6px; background: rgba(245, 212, 135, .08); color: #fde68a; font: inherit; font-weight: 700; cursor: pointer; }
.q-blank.is-filled { border-bottom-style: solid; background: rgba(245, 212, 135, .2); }
.q-bank { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 600px) { .q-match-row { grid-template-columns: 1fr; } }

/* ---------- บทเรียนในโลก ---------- */
.w-mark.is-study { color: #fff; font-size: 24px; }
.study-course { margin-top: 10px; padding: 12px; border-radius: 12px; background: rgba(0, 0, 0, .25); border: 2px solid color-mix(in srgb, var(--c, #8b7bff) 55%, #b8863b); display: grid; gap: 6px; }
.study-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 12px; border-radius: 10px; border: 2px solid rgba(245, 212, 135, .25); background: rgba(255, 255, 255, .05); color: #fff; font: inherit; text-align: left; cursor: pointer; transition: transform .1s, border-color .15s; }
.study-item:hover { transform: translateX(3px); border-color: #f5d487; }
.study-item.is-next { border-color: #f5d487; background: linear-gradient(90deg, rgba(245, 212, 135, .18), rgba(255, 255, 255, .04)); }
.study-ico { font-size: 1.5rem; }
.study-text { display: grid; flex: 1; min-width: 0; }
.study-text small { color: #c9c3ea; }
.study-go { color: #fde68a; font-weight: 700; white-space: nowrap; }
.lesson-book { position: fixed; inset: 0; z-index: 3200; display: grid; place-items: center; padding: 14px; background: rgba(6, 4, 20, .6); backdrop-filter: blur(3px); animation: fade .2s; }
.lesson-card { width: min(760px, 100%); max-height: min(88vh, 860px); display: flex; flex-direction: column; overflow: hidden; animation: w-pop .22s ease-out; }
.lesson-head { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: linear-gradient(180deg, #5b3f14, #3a270b); border-bottom: 2px solid #b8863b; }
.lesson-head h3 { color: #fde68a; }
.lesson-head .w-npc-face { width: 52px; height: 52px; flex: none; }
.lesson-body { flex: 1; overflow: auto; padding: 18px 22px; font-size: 1.08rem; line-height: 1.75; background: linear-gradient(180deg, rgba(255, 248, 225, .05), transparent); }
.lesson-content h4 { color: #fde68a; }
.lesson-content li + li { margin-top: 6px; }
.lesson-story { font-style: italic; color: #fef3c7; font-size: 1.12rem; }
.lesson-video { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; border: 2px solid #b8863b; }
.lesson-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lesson-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 2px solid rgba(184, 134, 59, .6); background: rgba(0, 0, 0, .25); }
.lesson-done-icon { font-size: 3.4rem; text-align: center; animation: float 3s ease-in-out infinite; }
@media (max-width: 600px) { .lesson-book { padding: 0; } .lesson-card { max-height: 100vh; height: 100%; border-radius: 0; } .lesson-body { padding: 14px; font-size: 1rem; } }

body.is-fullgame .toasts { right: auto; left: 12px; }
/* ตัวละครของเราไม่บังการคลิกหีบ/อาคาร/มอนสเตอร์ที่อยู่ข้างหลัง */
.w-char.is-me { pointer-events: none; }

/* ---------- ห้องภายใน / แมพใหม่ ---------- */
.gs .world-map.is-indoor { width: 100vw; height: 100vh; height: 100dvh; min-height: 0; }
.w-furniture { display: block; font-size: 52px; line-height: 1; filter: drop-shadow(0 6px 4px rgba(0, 0, 0, .45)); transition: transform .15s; }
.w-place:hover .w-furniture { transform: translateY(-4px) scale(1.06); }
.w-exit { transform: translate(-50%, -100%); }
.w-exit-mat { display: block; font-size: 34px; animation: w-bob 1.6s ease-in-out infinite; }
.w-home-px { filter: drop-shadow(0 0 10px rgba(253, 224, 71, .55)); }
.w-deco-emoji { position: absolute; transform: translate(-50%, -100%); font-size: 40px; line-height: 1; pointer-events: none; filter: drop-shadow(0 6px 3px rgba(0, 0, 0, .3)); }
.zone-snow .w-deco-px { filter: saturate(.35) brightness(1.3) drop-shadow(0 4px 2px rgba(0, 0, 0, .25)); }
.wx-snow { position: absolute; top: -20px; color: #fff; text-shadow: 0 0 6px rgba(255, 255, 255, .8); animation: wx-snow linear infinite; }
@keyframes wx-snow { to { transform: translate(40px, 110vh) rotate(360deg); } }
.w-weather-snow { background: rgba(226, 232, 240, .1); }
/* ม่านเปลี่ยนแมพ: เปิดเมื่อแมพใหม่วาดเสร็จ · ปิดก่อนออกจากแมพ (ใช้ opacity อย่างเดียว เบาเครื่อง) */
.gs-curtain { position: fixed; inset: 0; z-index: 6000; background: #07060f; pointer-events: none; opacity: 1; transition: opacity .35s ease-out; will-change: opacity; }
.gs-curtain.is-off { opacity: 0; }
.gs.is-leaving .gs-curtain { opacity: 1; transition: opacity .3s ease-in; }


/* =====================================================================
   ฉากต่อสู้แบบ RPG
   ===================================================================== */
.bt { position: fixed; inset: 0; z-index: 3150; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px; background: rgba(5, 4, 20, .72); backdrop-filter: blur(2px); opacity: 0; transition: opacity .2s; }
.bt.is-in { opacity: 1; }
.bt-stage { position: relative; width: min(920px, 100%); height: min(46vh, 400px); min-height: 260px; border-radius: 14px; overflow: hidden; border: 3px solid #b8863b; box-shadow: 0 0 0 3px rgba(20, 12, 4, .9), 0 18px 50px rgba(0, 0, 0, .6); background: linear-gradient(180deg, #60a5fa 0%, #bfdbfe 52%, #6fbf5a 52%, #3f8f3a 100%); transform: scale(.94); transition: transform .25s cubic-bezier(.2, .9, .3, 1.2); }
.bt.is-in .bt-stage { transform: none; }
.bt-meadow .bt-stage { background: linear-gradient(180deg, #7dd3fc 0%, #e0f2fe 52%, #86d16b 52%, #4d8f3a 100%); }
.bt-forest .bt-stage { background: linear-gradient(180deg, #14532d 0%, #166534 50%, #2f6b3a 50%, #123522 100%); }
.bt-cave .bt-stage { background: linear-gradient(180deg, #1e1b4b 0%, #4c1d95 52%, #4c3f6b 52%, #1b1530 100%); }
.bt-beach .bt-stage { background: linear-gradient(180deg, #38bdf8 0%, #bae6fd 44%, #22d3ee 44%, #67e8f9 52%, #f3e2b3 52%, #d9c18a 100%); }
.bt-snow .bt-stage { background: linear-gradient(180deg, #94a3b8 0%, #e2e8f0 52%, #f8fafc 52%, #cbd5e1 100%); }
.bt-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 48%; background: repeating-linear-gradient(90deg, rgba(0, 0, 0, .05) 0 24px, transparent 24px 48px), radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, .12), transparent 60%); pointer-events: none; }
.bt-top { position: absolute; z-index: 5; top: 10px; left: 12px; right: 56px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.bt-side { min-width: 0; padding: 6px 12px; border-radius: 10px; background: rgba(12, 8, 30, .78); border: 2px solid rgba(245, 212, 135, .5); color: #fff; }
.bt-side.is-mon { text-align: right; min-width: 200px; }
.bt-name { font: 700 .95rem Prompt, sans-serif; color: #fde68a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-hearts { font-size: 1.15rem; letter-spacing: 1px; }
.bt-vs { align-self: center; font: 800 1.4rem 'Press Start 2P', monospace; color: #fde047; text-shadow: 0 3px 0 #b45309, 0 0 16px rgba(251, 191, 36, .7); }
.bt-hpbar { position: relative; height: 14px; margin-top: 4px; border-radius: 4px; background: rgba(0, 0, 0, .5); border: 2px solid #0b0720; overflow: hidden; }
.bt-hpbar span { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #ef4444, #f97316); transition: width .45s ease-out; }
.bt-hp-text { font-size: .78rem; opacity: .85; }
.bt-streak { position: absolute; z-index: 5; left: 50%; bottom: 10px; transform: translateX(-50%); padding: 4px 14px; border-radius: 999px; background: rgba(234, 88, 12, .85); color: #fff; font-weight: 700; font-size: .85rem; animation: w-bob 1s ease-in-out infinite; }
.bt-flee { position: absolute; z-index: 6; top: 10px; right: 10px; }
.bt .bt-hero { position: absolute; left: 22%; top: auto; bottom: 12%; transform: translateX(-50%) scale(1.7); transform-origin: 50% 100%; transition: none; cursor: default; }
.bt .bt-hero .w-sprite { width: 60px; height: 96px; }
.bt-mon { position: absolute; right: 22%; bottom: 13%; transform: translateX(50%); display: grid; justify-items: center; }
.bt-mon .bt-mon-px { display: block; transform: scaleX(-1); animation: bt-idle 1.6s ease-in-out infinite; filter: drop-shadow(0 8px 6px rgba(0, 0, 0, .35)); }
.bt-shadow { width: 90px; height: 16px; margin-top: -8px; border-radius: 50%; background: rgba(0, 0, 0, .28); }
.bt-mon.is-big .bt-shadow { width: 120px; }
@keyframes bt-idle { 50% { translate: 0 -6px; } }
.bt-hero.bt-attack { animation: bt-dash .52s cubic-bezier(.3, .7, .4, 1); }
@keyframes bt-dash { 45% { transform: translateX(calc(-50% + var(--dash, 200px))) scale(1.7); } 55% { transform: translateX(calc(-50% + var(--dash, 200px))) scale(1.7) rotate(8deg); } }
.bt-mon.bt-attack-l { animation: bt-dash-l .52s cubic-bezier(.3, .7, .4, 1); }
@keyframes bt-dash-l { 45%, 55% { transform: translateX(calc(50% + var(--dash, -200px))); } }
.bt-mon.bt-hit .bt-mon-px { animation: bt-hit .42s linear; }
@keyframes bt-hit { 0%, 40%, 80% { filter: brightness(3) saturate(0); } 20%, 60% { translate: 10px 0; } 100% { translate: 0 0; } }
.bt-hero.bt-hurt { animation: bt-hurt .48s linear; }
@keyframes bt-hurt { 0%, 50% { filter: brightness(1.2) sepia(1) hue-rotate(-40deg) saturate(6); } 25%, 75% { transform: translateX(calc(-50% - 12px)) scale(1.7); } }
.bt-mon.bt-dead .bt-mon-px, .bt-mon.is-gone .bt-mon-px { animation: bt-dead .9s ease-in forwards; }
@keyframes bt-dead { 30% { filter: brightness(4); } 100% { opacity: 0; transform: scaleX(-1) scale(.2) rotate(180deg); } }
.bt-hero.bt-faint { animation: bt-faint .9s ease-in forwards; }
@keyframes bt-faint { to { transform: translateX(-50%) scale(1.7) rotate(-90deg); opacity: .5; } }
.bt.bt-shake .bt-stage { animation: map-shake .35s linear; }
.bt-float { position: absolute; z-index: 7; transform: translate(-50%, -50%); font: 800 1.6rem Prompt, sans-serif; color: #fff; text-shadow: 0 3px 0 #000, 0 0 12px rgba(0, 0, 0, .6); white-space: nowrap; pointer-events: none; animation: bt-float 1.1s ease-out forwards; }
.bt-float.is-crit { color: #fb923c; font-size: 2.1rem; }
.bt-float.is-hurt { color: #f87171; }
@keyframes bt-float { 0% { opacity: 0; transform: translate(-50%, 0) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -40px) scale(1.2); } 100% { opacity: 0; transform: translate(-50%, -90px) scale(1); } }
.bt-box { width: min(920px, 100%); max-height: 44vh; overflow: auto; padding: 14px 16px; display: grid; gap: 10px; }
.bt-help { font-size: .85rem; color: #c9c3ea; }
.bt-note { padding: 8px 12px; border-radius: 10px; font-weight: 700; }
.bt-note.is-good { background: rgba(34, 197, 94, .18); color: #86efac; }
.bt-note.is-bad { background: rgba(239, 68, 68, .18); color: #fca5a5; }
.bt-answer { padding: 8px 12px; border-radius: 10px; background: rgba(245, 212, 135, .12); border: 1px solid rgba(245, 212, 135, .4); }
.bt .q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bt .q-opt { position: relative; padding: 14px 14px 14px 46px; font-size: 1.05rem; text-align: left; border-radius: 12px; border: 2px solid rgba(245, 212, 135, .35); background: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(0, 0, 0, .2)); color: #fff; cursor: pointer; transition: transform .1s, border-color .15s; }
.bt .q-opt:hover:not(:disabled) { transform: translateY(-2px); border-color: #f5d487; }
.bt .q-opt:disabled { opacity: .6; }
.bt-key { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; background: #f5d487; color: #3a2200; font: 700 .8rem 'Press Start 2P', monospace; }
.bt-result { display: flex; gap: 12px; align-items: center; }
.bt-result-icon { font-size: 2.6rem; animation: float 2.5s ease-in-out infinite; }
.bt-result h3 { color: #fde68a; }
.bt-loot { display: flex; flex-wrap: wrap; gap: 8px; }
.bt-loot span { padding: 6px 12px; border-radius: 999px; background: rgba(245, 212, 135, .15); border: 1px solid rgba(245, 212, 135, .45); font-weight: 700; }
.fly-coin { position: fixed; z-index: 5200; font-size: 22px; pointer-events: none; transition: transform .75s cubic-bezier(.5, -0.3, .7, .5), opacity .75s; }
@media (max-width: 640px) {
  .bt { padding: 6px; justify-content: flex-start; }
  .bt-stage { height: 34vh; min-height: 220px; }
  .bt .bt-hero { transform: translateX(-50%) scale(1.2); left: 20%; }
  .bt .q-options { grid-template-columns: 1fr; }
  .bt-side.is-mon { min-width: 0; }
  .bt-box { max-height: 58vh; }
}
@media (prefers-reduced-motion: reduce) { .bt-mon .bt-mon-px, .bt-streak { animation: none; } }

/* ---------- เป้าหมาย + ลูกศรนำทาง ---------- */
.gs-track { position: absolute; z-index: 20; top: 148px; left: 12px; width: 300px; padding: 8px; display: grid; gap: 4px; }
.gs-track-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 2px; font: 700 .9rem Prompt, sans-serif; color: #fde68a; }
.gs-track-row { display: flex; gap: 8px; align-items: center; width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid transparent; background: rgba(0, 0, 0, .25); color: #fff; font: inherit; font-size: .86rem; text-align: left; cursor: pointer; }
.gs-track-row:hover { border-color: rgba(245, 212, 135, .6); background: rgba(245, 212, 135, .1); }
.gs-track-row.is-on { border-color: #f5d487; background: linear-gradient(90deg, rgba(245, 212, 135, .25), rgba(0, 0, 0, .2)); }
.gs-track-ico { flex: none; }
.gs-track-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-track-go { color: #fde68a; font-weight: 700; }
.gs-track-row.is-on .gs-track-go { animation: w-bob 1s ease-in-out infinite; }
.gs-arrow { position: absolute; z-index: 9000; width: 0; height: 0; margin-top: -40px; pointer-events: none; }
.gs-arrow span { position: absolute; left: -12px; top: -12px; display: block; width: 24px; text-align: center; font-size: 22px; color: #fde047; text-shadow: 0 0 8px rgba(253, 224, 71, .9), 0 2px 0 #7c4a03; transform: rotate(var(--ang, 0rad)) translateX(58px); transform-origin: 12px 12px; }
.gs-goal-ring { position: absolute; z-index: 5; width: 64px; height: 26px; margin: -13px 0 0 -32px; border-radius: 50%; border: 3px solid #fde047; box-shadow: 0 0 14px rgba(253, 224, 71, .8); pointer-events: none; animation: goal-ring 1.4s ease-in-out infinite; }
@keyframes goal-ring { 50% { transform: scale(1.25); opacity: .6; } }
@media (max-width: 760px) { .gs-track { top: auto; bottom: 128px; left: 6px; width: min(260px, calc(100vw - 150px)); } .gs-track-head .small { display: none; } }

/* ---------- ตั้งค่า ---------- */
.set-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; }
.set-row input[type=range] { width: 100%; accent-color: #f5d487; }
.set-val { min-width: 44px; text-align: right; font-weight: 700; color: #fde68a; }
.set-keys { display: grid; gap: 4px; padding: 10px; border-radius: 10px; background: rgba(0, 0, 0, .25); }

/* ---------- บทสนทนา NPC ---------- */
.npc-talk { display: flex; gap: 12px; align-items: flex-start; }
.npc-talk-face { width: 72px !important; height: 72px !important; flex: none; border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 2px #b8863b; }
.npc-talk-body { min-width: 0; flex: 1; }
.npc-talk-name { font: 700 1.05rem Prompt, sans-serif; color: #fde68a; }
.w-npc-line { margin-top: 6px; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(245, 212, 135, .25); cursor: pointer; min-height: 2.6em; }
.w-npc-line.is-typing::after { content: "▌"; animation: blink .7s steps(1) infinite; color: #fde68a; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- โหมดกราฟิกประหยัด ---------- */
body.gfx-low .w-weather, body.gfx-low .w-ambient, body.gfx-low .gs-vignette, body.gfx-low .world-map::before { display: none !important; }
body.gfx-low .w-char .w-hero, body.gfx-low .w-petf > span, body.gfx-low .w-chest .w-chest-img, body.gfx-low .w-chest::after, body.gfx-low .gs-xp > span::after, body.gfx-low .w-mark, body.gfx-low .w-portal-ring { animation: none !important; }
body.gfx-low .w-char.has-hero.is-walking .w-hero { animation: hero-walk .52s steps(4) infinite !important; }
body.gfx-low .gw-backdrop, body.gfx-low .bt, body.gfx-low .lesson-book { backdrop-filter: none !important; }
.gs-track { grid-template-columns: minmax(0, 1fr); width: 280px; }
.gs-track-head { width: 100%; border: 0; background: none; color: #fde68a; cursor: pointer; }
.gs-track.is-min .gs-track-row:nth-of-type(n+3) { display: none; }
.gs-track-row { min-width: 0; }

/* ---------- แต้ม ปลดล็อก สวน หมู่บ้าน ---------- */
.gs-ap { color: #c4b5fd; cursor: pointer; }
.gs-ap b { color: #ddd6fe; }
.gs-rank { color: #fde68a; font-weight: 700; }
.ul-rule { display: grid; gap: 2px; padding: 8px 12px; border-radius: 10px; background: rgba(139, 92, 246, .15); border: 1px solid rgba(196, 181, 253, .4); }
.ul-group { display: grid; gap: 8px; padding: 10px; border-radius: 12px; background: rgba(0, 0, 0, .25); border: 1px solid rgba(245, 212, 135, .25); }
.ul-owned { display: flex; gap: 6px; flex-wrap: wrap; }
.ul-pip { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: rgba(255, 255, 255, .06); filter: grayscale(1); opacity: .45; font-size: 1.2rem; }
.ul-pip.is-on { filter: none; opacity: 1; background: rgba(245, 212, 135, .2); box-shadow: 0 0 0 2px #b8863b; }
.ul-next { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; background: linear-gradient(90deg, rgba(245, 212, 135, .15), transparent); }
.ul-next-icon { font-size: 2rem; }
.ul-score { display: grid; justify-items: center; gap: 2px; padding: 12px; border-radius: 12px; text-align: center; }
.ul-score strong { font: 800 2rem Prompt, sans-serif; }
.ul-score.is-pass { background: rgba(34, 197, 94, .15); color: #bbf7d0; }
.ul-score.is-fail { background: rgba(239, 68, 68, .15); color: #fecaca; }
.ul-review { padding: 8px 10px; border-radius: 8px; margin-top: 6px; background: rgba(255, 255, 255, .05); }
.ul-review.is-bad { border-left: 4px solid #ef4444; }
.ul-review.is-ok { border-left: 4px solid #22c55e; }
.ul-test .q-opt { position: relative; padding-left: 46px; }
.w-tut-dots span.done { background: #86efac; }
.bt-loot .is-ap { background: rgba(139, 92, 246, .25); border-color: rgba(196, 181, 253, .6); }
.farm-plot { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: rgba(0, 0, 0, .25); border: 1px solid rgba(134, 239, 172, .25); }
.farm-plot.is-ready { border-color: #86efac; box-shadow: 0 0 12px rgba(134, 239, 172, .35); }
.farm-slot { font-size: 2rem; width: 48px; text-align: center; }
.farm-seeds { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.vh { position: relative; display: grid; justify-items: center; }
.vh-level { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); font-size: .7rem; color: #fde047; text-shadow: 0 1px 2px #000; white-space: nowrap; }
.vh-garden { display: block; margin-top: -6px; font-size: 14px; letter-spacing: 2px; }
.vh-lv5 { position: relative; }
.w-place.is-mine .vh { filter: drop-shadow(0 0 10px rgba(253, 224, 71, .8)); }
.w-place.is-mine .w-place-label { background: linear-gradient(180deg, #fde68a, #d97706); color: #3a2200; }
/* ศึกหมู่บ้านประจำเดือน */
.wm-season-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.wm-season-list li { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) minmax(60px, 1.2fr) auto; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; background: rgba(255, 255, 255, .04); }
.wm-season-list li.is-mine { outline: 2px solid #f5c542; }
.wm-season-place { text-align: center; font-weight: 700; }
.wm-season-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wm-season-bar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.wm-season-bar > span { display: block; height: 100%; background: linear-gradient(90deg, #34d399, #f5c542); }
.wm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.wm-card { position: relative; overflow: hidden; border-radius: 14px; border: 2px solid color-mix(in srgb, var(--c) 60%, #b8863b); background: linear-gradient(180deg, rgba(40, 30, 72, .92), rgba(22, 17, 44, .94)); box-shadow: 0 0 0 2px rgba(20, 12, 4, .85); }
.wm-card.is-mine { box-shadow: 0 0 0 2px rgba(20, 12, 4, .85), 0 0 22px rgba(253, 224, 71, .45); border-color: #f5d487; }
.wm-rank { position: absolute; top: 8px; left: 8px; z-index: 2; padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, .55); color: #fde68a; font: 700 .8rem 'Press Start 2P', monospace; }
.wm-scene { height: 86px; display: flex; flex-wrap: wrap; align-content: flex-end; justify-content: center; gap: 2px; padding: 8px; background: linear-gradient(180deg, #7dd3fc 0%, #bae6fd 45%, #6fbf5a 45%, #3f8f3a 100%); font-size: 20px; }
.wm-body { display: grid; gap: 6px; padding: 12px; }
.wm-stage { font-weight: 700; color: #fde68a; }
.wm-stats { display: flex; gap: 12px; }

/* ---------- โต๊ะประดิษฐ์ ---------- */
.craft-bag { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border-radius: 10px; background: rgba(0, 0, 0, .25); }
.craft-mat { display: inline-flex; gap: 4px; align-items: center; padding: 4px 8px; border-radius: 8px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(245, 212, 135, .3); }
.craft-mat span { font-size: 1.2rem; }
.craft-row { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, .04); }
.craft-row.is-can { background: linear-gradient(90deg, rgba(134, 239, 172, .15), transparent); }
.craft-need { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: .85rem; }
.craft-need .ok { color: #86efac; }
.craft-need .miss { color: #fca5a5; }
.bt-loot .is-mat { background: rgba(34, 197, 94, .2); border-color: rgba(134, 239, 172, .6); }

/* ---------- โหมดเรียน ---------- */
.gs-focus { position: absolute; z-index: 21; top: 64px; left: 50%; transform: translateX(-50%); display: grid; gap: 2px; max-width: min(620px, calc(100vw - 24px)); padding: 8px 16px; border-radius: 12px; text-align: center; background: linear-gradient(180deg, rgba(234, 179, 8, .95), rgba(180, 83, 9, .95)); color: #1c1003; border: 2px solid #fde68a; box-shadow: 0 0 0 2px rgba(20, 12, 4, .85), 0 8px 20px rgba(0, 0, 0, .4); font-size: .85rem; }
.gs-focus strong { font-size: 1rem; }
@media (max-width: 760px) { .gs-focus { top: auto; bottom: 170px; } }

/* ---------- สกิลต่อสู้ · เทศกาล · มอนสเตอร์ทองคำ/ดุ ---------- */
.bt-skillbar { width: min(920px, 100%); display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px 6px; }
.bt-energy-label { color: #fde047; font-weight: 700; font-size: .85rem; }
.bt-skills { margin-left: auto; }
.bt-energy { display: flex; gap: 4px; }
.bt-pip { width: 18px; height: 10px; border-radius: 3px; background: rgba(15, 23, 42, .7); border: 1px solid rgba(250, 204, 21, .5); }
.bt-pip.is-on { background: linear-gradient(180deg, #fde047, #f59e0b); box-shadow: 0 0 8px rgba(250, 204, 21, .8); }
.bt-skills { display: flex; gap: 6px; }
.bt-skill { position: relative; display: grid; justify-items: center; gap: 1px; min-width: 64px; padding: 6px 6px 4px; border-radius: 10px; border: 2px solid #6b4f1d; background: linear-gradient(180deg, #2a1f3d, #1a1328); color: #e2e8f0; font: inherit; font-size: .7rem; cursor: pointer; opacity: .55; transition: transform .12s, opacity .12s; }
.bt-skill .bt-key { position: absolute; top: -8px; left: -6px; }
.bt-skill-icon { font-size: 1.4rem; line-height: 1.1; }
.bt-skill-cost { color: #fde047; font-weight: 700; }
.bt-skill.is-ready { opacity: 1; border-color: #fbbf24; box-shadow: 0 0 12px rgba(251, 191, 36, .55); }
.bt-skill.is-ready:hover { transform: translateY(-3px); }
.bt-skill.is-active { opacity: 1; border-color: #4ade80; box-shadow: 0 0 14px rgba(74, 222, 128, .8); }
.bt-skill.is-locked { filter: grayscale(1); }
.bt-float.is-heal { color: #4ade80; }
.bt-float.is-buff { color: #fde047; }
.bt-hero.bt-buff-double { filter: drop-shadow(0 0 10px rgba(248, 113, 113, .95)); }
.bt-hero.bt-buff-shield { filter: drop-shadow(0 0 12px rgba(96, 165, 250, .95)); }
.bt.bt-ult .bt-stage { animation: bt-ult .7s ease-out; }
@keyframes bt-ult { 0% { filter: brightness(1); } 30% { filter: brightness(2.2) saturate(1.8) hue-rotate(-20deg); } 100% { filter: brightness(1); } }
@media (max-width: 700px) { .bt-skill { min-width: 52px; } .bt-skill-name { display: none; } }
.gs-event { padding: 2px 10px; border-radius: 999px; background: linear-gradient(180deg, #f59e0b, #b45309); color: #fff8e1; font-weight: 700; font-size: .8rem; white-space: nowrap; box-shadow: 0 0 10px rgba(245, 158, 11, .5); cursor: help; }
.w-monster.is-golden .w-mon-px { filter: sepia(1) saturate(5) hue-rotate(5deg) brightness(1.35) drop-shadow(0 0 10px rgba(253, 224, 71, .95)) !important; }
.w-monster.is-golden .w-mon-name { color: #fde047; }
.w-monster.is-aggro .w-mon-name::before { content: "😠 "; }
.w-monster.is-near::after { content: "␣ Space ฟัน"; position: absolute; left: 50%; top: -30px; transform: translateX(-50%); padding: 2px 8px; border-radius: 6px; background: rgba(15, 10, 30, .85); color: #fde047; font-size: .72rem; font-weight: 700; white-space: nowrap; pointer-events: none; animation: w-bob 1s ease-in-out infinite; }
.gs .world-emotes { width: min(760px, calc(100vw - 24px)); }

/* ---------- ต่อสู้แบบแอ็กชัน ---------- */
.gs-action { position: absolute; z-index: 20; left: 12px; bottom: 12px; display: grid; gap: 6px; padding: 8px 10px; }
.gs-action.is-low { box-shadow: 0 0 0 2px rgba(20, 12, 4, .85), 0 0 18px rgba(239, 68, 68, .8); }
.ga-stats { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ga-hearts { font-size: 1rem; letter-spacing: 1px; white-space: nowrap; }
.ga-energy { display: flex; align-items: center; gap: 3px; }
.ga-en-label { color: #fde047; font-size: .85rem; margin-right: 2px; }
.ga-btns { display: flex; gap: 6px; margin-top: 8px; }
.ga-btn { position: relative; display: grid; justify-items: center; gap: 1px; min-width: 58px; padding: 6px 5px 4px; border-radius: 10px; border: 2px solid #6b4f1d; background: linear-gradient(180deg, #2a1f3d, #1a1328); color: #e2e8f0; font: inherit; font-size: .68rem; cursor: pointer; opacity: .6; transition: transform .12s, opacity .12s; }
.ga-btn .bt-key { position: absolute; top: -8px; left: -6px; }
.ga-btn.ga-swing, .ga-btn.is-ready { opacity: 1; border-color: #fbbf24; box-shadow: 0 0 10px rgba(251, 191, 36, .45); }
.ga-btn:hover { transform: translateY(-3px); }
.ga-btn.is-locked { filter: grayscale(1); }
.ga-ico { font-size: 1.35rem; line-height: 1.1; }
.ga-cost { color: #fde047; font-weight: 700; }
@media (max-width: 1760px) { .gs-action { bottom: 104px; } }
@media (max-width: 760px) { .gs-action { bottom: 150px; left: 6px; } .ga-name { display: none; } .ga-btn { min-width: 44px; } }
.w-slash { position: absolute; z-index: 1400; width: calc(var(--r) * 2); height: calc(var(--r) * 2); margin: calc(var(--r) * -1) 0 0 calc(var(--r) * -1); transform: translateY(-14px) rotate(var(--a)); border-radius: 50%; pointer-events: none;
  background: conic-gradient(from 20deg, transparent 0 250deg, rgba(255, 255, 255, .0) 250deg, rgba(255, 255, 255, .85) 320deg, rgba(253, 224, 71, .55) 350deg, transparent 360deg);
  -webkit-mask: radial-gradient(circle, transparent 52%, #000 56%, #000 70%, transparent 74%); mask: radial-gradient(circle, transparent 52%, #000 56%, #000 70%, transparent 74%);
  animation: w-slash .3s ease-out forwards; }
.w-slash.is-spin { background: conic-gradient(rgba(255, 255, 255, .8), rgba(147, 197, 253, .6), rgba(255, 255, 255, .8)); animation: w-spin .4s ease-out forwards; }
.w-slash.is-ult { background: radial-gradient(circle, rgba(253, 224, 71, .0) 40%, rgba(249, 115, 22, .8) 60%, rgba(239, 68, 68, .0) 75%); -webkit-mask: none; mask: none; animation: w-ult .42s ease-out forwards; }
@keyframes w-slash { from { opacity: 1; transform: translateY(-14px) rotate(calc(var(--a) - 60deg)); } to { opacity: 0; transform: translateY(-14px) rotate(calc(var(--a) + 40deg)); } }
@keyframes w-spin { from { opacity: 1; transform: translateY(-14px) rotate(0) scale(.6); } to { opacity: 0; transform: translateY(-14px) rotate(360deg) scale(1.1); } }
@keyframes w-ult { from { opacity: 1; transform: translateY(-14px) scale(.2); } to { opacity: 0; transform: translateY(-14px) scale(1.2); } }
.w-char.is-swing .w-sprite { animation: w-swing .28s ease-out; }
@keyframes w-swing { 0% { transform: rotate(0); } 40% { transform: rotate(-12deg) scale(1.08); } 100% { transform: rotate(0); } }
.w-char.is-hurt .w-sprite { animation: w-hurtflash .5s steps(2) 2; }
@keyframes w-hurtflash { 50% { filter: brightness(2.2) saturate(0) sepia(1) hue-rotate(-40deg); opacity: .6; } }
.w-char.is-shield .w-sprite { filter: drop-shadow(0 0 10px rgba(96, 165, 250, .95)) drop-shadow(0 0 4px #fff); }
.w-char.is-faint .w-sprite { transform: rotate(90deg); opacity: .6; transition: transform .3s; }
.w-monster.is-hit .w-mon-px { animation: w-monhit .25s steps(2); }
@keyframes w-monhit { 50% { filter: brightness(3) saturate(0); transform: scale(1.12); } }
.w-float.is-dmg { color: #fff; text-shadow: 0 2px 0 #7f1d1d, 0 0 6px #000; font-weight: 800; }
.w-float.is-heal { color: #4ade80; }
.w-float.is-buff { color: #93c5fd; }
.w-float.is-loot { color: #fde047; font-weight: 800; white-space: nowrap; }
.w-float.is-mat { color: #c4b5fd; white-space: nowrap; }

/* ---------- พฤติกรรมมอนสเตอร์ · วงเตือน · กลิ้งหลบ · คอมโบ ---------- */
.w-warn { position: absolute; z-index: 5; transform: translate(-50%, -50%); border-radius: 50%; pointer-events: none; border: 2px solid rgba(239, 68, 68, .9); background: rgba(239, 68, 68, .12); }
.w-warn::after { content: ""; position: absolute; inset: 50%; border-radius: 50%; background: rgba(239, 68, 68, .55); animation: w-warn-grow var(--ms) linear forwards; }
@keyframes w-warn-grow { to { inset: 0; } }
.w-warn-line { position: absolute; z-index: 5; height: 34px; margin-top: -30px; transform-origin: 0 50%; transform: rotate(var(--ang)); border-radius: 17px; pointer-events: none; border: 2px dashed rgba(239, 68, 68, .9); background: linear-gradient(90deg, rgba(239, 68, 68, .5), rgba(239, 68, 68, .1)); animation: w-warn-line var(--ms) linear forwards; }
@keyframes w-warn-line { from { opacity: .4; } to { opacity: 1; background: rgba(239, 68, 68, .55); } }
.w-monster.is-windup .w-mon-px { animation: w-windup .18s steps(2) infinite; }
@keyframes w-windup { 50% { filter: brightness(1.8) sepia(1) saturate(6) hue-rotate(-30deg); transform: scale(1.08); } }
.w-monster.is-stun .w-mon-px { animation: w-stun .5s ease-in-out infinite; filter: grayscale(.4); }
.w-monster.is-stun::before { content: "💫"; position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 16px; animation: w-bob .6s ease-in-out infinite; }
@keyframes w-stun { 50% { transform: rotate(-8deg); } }
.w-monster.is-phase { opacity: .3; }
.w-monster.is-hop .w-mon-px { animation: w-hop .32s ease-out; }
@keyframes w-hop { 50% { transform: translateY(-14px) scaleY(1.08); } }
.w-char.is-roll .w-sprite { animation: w-roll .3s linear; }
@keyframes w-roll { to { transform: rotate(360deg) scale(.9); } }
.w-slash.is-c3 { background: conic-gradient(from 0deg, transparent 0 200deg, rgba(253, 224, 71, .9) 300deg, rgba(249, 115, 22, .7) 350deg, transparent 360deg); }
@media (prefers-reduced-motion: reduce) { .w-warn::after, .w-monster.is-windup .w-mon-px, .w-monster.is-stun .w-mon-px, .w-char.is-roll .w-sprite { animation: none; } }

/* ---------- ตีบวกอุปกรณ์ ---------- */
.craft-tabs { display: flex; gap: 6px; margin-bottom: 4px; }
.forge-rarity { margin-left: 6px; font-size: .7rem; background: transparent; border: 1px solid; }
.forge-row strong { text-shadow: 0 1px 0 rgba(0, 0, 0, .35); }

/* ---------- เหมืองปริศนา ---------- */
.gs-mine { position: absolute; z-index: 21; top: 64px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; align-items: center; padding: 6px 16px; font-size: .9rem; white-space: nowrap; }
.gs-mine strong { color: #fde047; }
.w-ladder { z-index: 6; }
.w-ladder-icon { font-size: 44px; filter: drop-shadow(0 0 10px rgba(253, 224, 71, .9)); animation: w-bob 1.2s ease-in-out infinite; }
.w-monster.is-boss .w-mon-name { color: #fbbf24; font-weight: 800; }
.w-monster.is-boss .w-mon-hp { width: 70px; height: 7px; }
.zone-mine .w-deco-px { filter: brightness(.8) saturate(.8) drop-shadow(0 5px 3px rgba(0, 0, 0, .5)); }


@media (prefers-reduced-motion: reduce) { .gs-curtain { transition: none; } }

/* เปิดหน้าต่างในเกมอยู่: หยุดแอนิเมชันของโลกด้านหลัง ให้เครื่องเรนเดอร์หน้าต่างได้ลื่น */
body.gw-open .world-map *, body.gw-open .world-map { animation-play-state: paused !important; }

/* =====================================================================
   จัดระเบียบหน้าจอเกม (v2.17)
   ซ้ายบน: การ์ดตัวละคร (HP/MP/XP) + เป้าหมาย · กลางบน: ชื่อโซน · ขวาบน: ระบบ + แผนที่ย่อ
   กลางล่าง: แถบสกิล (เหนือ) + เมนู · ซ้ายล่าง: แจ้งเตือน
   ===================================================================== */
.gs-bar2 { position: relative; display: block; height: 15px; border-radius: 4px; background: rgba(0, 0, 0, .55); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); overflow: hidden; }
.gs-bar2 > span { position: absolute; inset: 0 auto 0 0; border-radius: 4px; transition: width .25s ease-out; }
.gs-hp > span { background: linear-gradient(180deg, #f87171, #b91c1c); }
.gs-mp > span { background: linear-gradient(180deg, #60a5fa, #1d4ed8); }
.gs-bar2 em { position: relative; display: flex; justify-content: space-between; padding: 0 6px; font: 600 .66rem/15px Prompt, sans-serif; font-style: normal; text-shadow: 0 1px 2px #000; }
.gs-bar2 em b { letter-spacing: .5px; }
.gs-xp { height: 10px; }
.gs-xp em { font-size: .58rem; line-height: 10px; }
.gs.is-lowhp .gs-vignette { box-shadow: inset 0 0 120px 30px rgba(220, 38, 38, .55); animation: gs-lowhp 1s ease-in-out infinite; }
@keyframes gs-lowhp { 50% { opacity: .55; } }
.gs.is-lowhp .gs-hp > span { animation: gs-lowhp .6s ease-in-out infinite; }
/* แถบสกิล: กลางล่าง เหนือเมนู */
.gs-action { left: 50% !important; right: auto; bottom: 92px !important; transform: translateX(-50%); padding: 6px 8px; }
.ga-btns { margin-top: 6px; align-items: flex-end; }
.ga-sep { width: 2px; align-self: stretch; margin: 6px 2px 2px; background: rgba(245, 212, 135, .3); }
.ga-btn { min-width: 56px; }
@media (max-width: 760px) { .gs-action { bottom: 128px !important; max-width: calc(100vw - 12px); } .ga-btn { min-width: 42px; } }
/* แจ้งเตือน: ซ้ายล่าง เหนือเมนู */
body.is-fullgame .toasts { left: 12px; right: auto; bottom: 96px; }
@media (max-width: 1100px) { body.is-fullgame .toasts { bottom: 200px; } }
/* เป้าหมายอยู่ใต้การ์ดตัวละครเสมอ */
.gs-track { top: 166px; }
/* มือถือ: การ์ดตัวละคร + เป้าหมาย (บน) · ชื่อโซนซ่อน (มีป้ายตอนเข้าแมพ) · สกิลเหนือเมนูด้านล่าง */
@media (max-width: 760px) {
  .gs-zone { display: none; }
  .gs-track { top: 136px; bottom: auto; left: 6px; width: min(240px, calc(100vw - 150px)); }
  .gs-action { bottom: 74px !important; }
  .ga-btn { min-width: 40px; padding: 4px 3px 3px; }
  .ga-cost { font-size: .6rem; }
  .gs-mine { top: 136px; left: auto; right: 6px; transform: none; font-size: .75rem; }
  body.is-fullgame .toasts { bottom: 150px; }
}

/* =====================================================================
   ฉากมีชีวิต (v2.18): ต้นไม้ไหว เสาไฟ คบเพลิง เงาเมฆ นก ปลา ควัน ประกายน้ำ
   ใช้ transform/opacity เท่านั้น (เบาเครื่อง) · ปิดในโหมดกราฟิกประหยัด
   ===================================================================== */
.w-tree { transform-origin: 50% 90%; animation: w-sway 4s ease-in-out infinite; }
@keyframes w-sway { 0%, 100% { rotate: -1.2deg; } 50% { rotate: 1.4deg; } }
.w-lamp { width: 18px; height: 64px; }
.w-lamp-post { position: absolute; left: 7px; bottom: 0; width: 4px; height: 52px; background: linear-gradient(90deg, #1f2937, #4b5563); border-radius: 2px; box-shadow: 0 0 0 1px #111827; }
.w-lamp-post::after { content: ""; position: absolute; left: -5px; bottom: -2px; width: 14px; height: 5px; border-radius: 2px; background: #374151; }
.w-lamp-head { position: absolute; left: 2px; top: 0; width: 14px; height: 14px; border-radius: 4px 4px 2px 2px; background: #fde68a; box-shadow: 0 0 0 2px #1f2937, inset 0 -3px 0 #f59e0b; }
.w-lamp-glow { position: absolute; left: -46px; top: -40px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, rgba(253, 224, 71, .55), rgba(253, 224, 71, 0) 70%); opacity: 0; transition: opacity 1s; pointer-events: none; }
.tod-dusk .w-lamp-glow { opacity: .55; }
.tod-night .w-lamp-glow, .tod-dawn .w-lamp-glow { opacity: 1; animation: w-flicker 3s ease-in-out infinite; }
.w-torch { overflow: visible; animation: w-flicker 1.4s ease-in-out infinite; }
.w-torch-glow { position: absolute; left: 50%; top: 30%; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%; background: radial-gradient(circle, rgba(251, 146, 60, .45), rgba(251, 146, 60, 0) 65%); pointer-events: none; }
@keyframes w-flicker { 0%, 100% { opacity: 1; } 40% { opacity: .82; } 60% { opacity: .95; } 75% { opacity: .78; } }
.w-life { position: absolute; inset: 0; pointer-events: none; z-index: 1300; overflow: hidden; }
.w-cloudshade { position: absolute; left: -30%; width: 34%; height: 26%; border-radius: 50%; background: radial-gradient(ellipse, rgba(15, 23, 42, .16), rgba(15, 23, 42, 0) 68%); animation: w-cloudmove linear infinite; }
@keyframes w-cloudmove { to { transform: translateX(400%); } }
.w-glint { position: absolute; width: 10px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .85); animation: w-glint 3.2s ease-in-out infinite; }
@keyframes w-glint { 0%, 100% { opacity: 0; transform: scaleX(.4); } 50% { opacity: .9; transform: scaleX(1); } }
.w-splash { position: absolute; width: 30px; height: 12px; margin: -6px 0 0 -15px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .8); animation: w-ripple 1.3s ease-out forwards; }
@keyframes w-ripple { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.8); opacity: 0; } }
.w-fish { position: absolute; left: 6px; top: -14px; font-size: 14px; animation: w-fishjump .9s ease-out forwards; }
@keyframes w-fishjump { 0% { transform: translateY(8px) rotate(-40deg); opacity: 0; } 30% { opacity: 1; } 50% { transform: translate(8px, -16px) rotate(0); } 100% { transform: translate(16px, 8px) rotate(50deg); opacity: 0; } }
.w-smoke { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: rgba(226, 232, 240, .55); animation: w-smoke 3.3s ease-out infinite; }
@keyframes w-smoke { from { transform: translate(0, 0) scale(.5); opacity: .7; } to { transform: translate(14px, -46px) scale(1.8); opacity: 0; } }
.w-flock { position: absolute; left: -10%; display: flex; animation: w-flock linear forwards; }
.w-flock.is-left { left: auto; right: -10%; animation-name: w-flock-l; }
.w-flock.is-left .w-bird { scale: -1 1; }
@keyframes w-flock { to { transform: translate(130vw, -14vh); } }
@keyframes w-flock-l { to { transform: translate(-130vw, -14vh); } }
.w-bird { position: relative; width: 14px; height: 8px; animation: w-flap .45s steps(2) infinite; }
.w-bird::before, .w-bird::after { content: ""; position: absolute; top: 3px; width: 7px; height: 2px; background: #1f2937; border-radius: 1px; }
.w-bird::before { left: 0; transform: rotate(25deg); transform-origin: 100% 50%; }
.w-bird::after { right: 0; transform: rotate(-25deg); transform-origin: 0 50%; }
@keyframes w-flap { 50% { transform: scaleY(-1); } }
.tod-night .w-cloudshade, .tod-night .w-flock { display: none; }
body.gfx-low .w-life, body.gfx-low .w-lamp-glow, body.gfx-low .w-torch-glow { display: none !important; }
body.gfx-low .w-tree, body.gfx-low .w-torch { animation: none !important; }
@media (prefers-reduced-motion: reduce) { .w-tree, .w-torch, .w-lamp-glow { animation: none !important; } }

/* ---------- ตลาดนัด · กังหันลม · สัตว์ (v2.19) ---------- */
.w-stall { width: 96px; height: 78px; transform: translate(-50%, -88%); }
.w-stall-awn { position: absolute; left: 0; top: 0; width: 96px; height: 26px; border-radius: 4px 4px 10px 10px; background: repeating-linear-gradient(90deg, var(--awn) 0 12px, #fff7ed 12px 24px); box-shadow: 0 0 0 2px #3b2412, 0 4px 0 rgba(0, 0, 0, .25); }
.w-stall-table { position: absolute; left: 6px; top: 38px; width: 84px; height: 22px; border-radius: 3px; background: linear-gradient(180deg, #b45309, #78350f); box-shadow: 0 0 0 2px #3b2412; display: grid; place-items: center; }
.w-stall-table span { position: relative; top: -12px; font-size: 15px; letter-spacing: -2px; }
.w-stall-legs { position: absolute; left: 10px; top: 24px; width: 76px; height: 54px; border-left: 4px solid #5b3a1a; border-right: 4px solid #5b3a1a; }
.w-mill { width: 90px; height: 130px; transform: translate(-50%, -92%); }
.w-mill-body { position: absolute; left: 25px; top: 40px; width: 40px; height: 90px; background: linear-gradient(90deg, #e7e5e4, #a8a29e); clip-path: polygon(20% 0, 80% 0, 100% 100%, 0 100%); }
.w-mill-door { position: absolute; left: 38px; top: 104px; width: 14px; height: 26px; border-radius: 7px 7px 0 0; background: #78350f; }
.w-mill-blades { position: absolute; left: 45px; top: 44px; width: 0; height: 0; animation: w-mill 6s linear infinite; }
.w-mill-blades i { position: absolute; left: -5px; top: -44px; width: 10px; height: 44px; background: repeating-linear-gradient(0deg, #fef3c7 0 6px, #92400e 6px 8px); border: 2px solid #5b3a1a; transform-origin: 50% 100%; }
.w-mill-blades i:nth-child(2) { rotate: 90deg; } .w-mill-blades i:nth-child(3) { rotate: 180deg; } .w-mill-blades i:nth-child(4) { rotate: 270deg; }
.w-mill-blades::after { content: ""; position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%; background: #3b2412; }
@keyframes w-mill { to { rotate: 360deg; } }
.w-critter { position: absolute; transform: translate(-50%, -100%); background: none; border: 0; padding: 0; pointer-events: none; font-size: 32px; line-height: 1; filter: drop-shadow(0 4px 2px rgba(0, 0, 0, .3)); will-change: transform; }
.w-critter-sp { display: inline-block; }
.w-critter-sp.is-flip { scale: -1 1; }
.w-critter.is-walk .w-critter-sp { animation: w-critter-hop .35s ease-in-out infinite; }
.w-critter:not(.is-walk) .w-critter-sp { animation: w-critter-idle 2.6s ease-in-out infinite; }
.w-critter.is-swim { font-size: 22px; filter: drop-shadow(0 2px 0 rgba(255, 255, 255, .5)); }
.w-critter.is-swim .w-critter-sp { animation: w-critter-float 2s ease-in-out infinite; }
@keyframes w-critter-hop { 50% { transform: translateY(-4px); } }
@keyframes w-critter-idle { 0%, 70%, 100% { transform: none; } 80% { transform: translateY(2px) rotate(-6deg); } 90% { transform: none; } }
@keyframes w-critter-float { 50% { transform: translateY(-2px) rotate(3deg); } }
.fx-heart { position: absolute; transform: translate(-50%, -100%); font-size: 18px; pointer-events: none; z-index: 2000; animation: float-up 1s ease-out forwards; }
body.gfx-low .w-mill-blades, body.gfx-low .w-critter-sp { animation: none !important; }

/* =====================================================================
   ไม่บังตัวเกม (v2.20)
   หน้าต่างเมนูเป็นลิ้นชักด้านขวา (เห็นโลกด้านซ้าย ไม่เบลอ คลิกฝั่งซ้ายเพื่อปิด)
   แผงข้อมูลแคบลง · เป้าหมายซ่อนระหว่างเปิดแผง · อีโมตเป็นป๊อปอัปเล็กมุมขวาล่าง
   ===================================================================== */
@media (min-width: 761px) {
  .gw { justify-items: end; align-items: stretch; padding: 14px 14px 96px; }
  .gw-win { width: min(780px, 62vw); height: auto; transform: translateX(48px); }
  .gw-backdrop { background: linear-gradient(90deg, rgba(6, 4, 20, 0) 0%, rgba(6, 4, 20, .08) 30%, rgba(6, 4, 20, .4) 100%); backdrop-filter: none; cursor: w-resize; }
  body.gw-open .gs-bar, body.gw-open .gs-me, body.gw-open .gs-corner { filter: none; }
  body.is-fullgame .world-panel { width: min(360px, calc(100vw - 24px)); max-height: calc(100vh - 330px); max-height: calc(100dvh - 330px); padding: 12px 14px; }
  .gs .world-emotes { z-index: 30; left: auto; right: 12px; transform: none; bottom: 96px; width: min(430px, calc(100vw - 24px)); display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 8px; }
  .gs .world-emotes .w-emote { justify-content: flex-start; padding: 4px 6px; font-size: .72rem; min-height: 0; }
}
.gs:has(.world-panel:not([hidden])) .gs-track { display: none; }
.world-map { transition: translate .35s ease-out; }

/* ---------- สมุดผจญภัย (v2.22) ---------- */
.adv-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.adv-tabs .tab { font-size: .74rem; padding: 4px 8px; }
.adv-weekly .btn, .adv-weekly .chip { margin-top: 6px; }
.adv-beast { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.adv-mon { display: grid; justify-items: center; gap: 1px; padding: 6px 4px; border-radius: 10px; border: 1px solid rgba(245, 212, 135, .3); background: rgba(0, 0, 0, .2); text-align: center; font-size: .72rem; }
.adv-mon.is-unknown { opacity: .5; }
.adv-mon-emoji { font-size: 1.5rem; }
.adv-tier { font-size: .66rem; color: #fde047; }
.adv-cal { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.adv-day { display: grid; justify-items: center; gap: 2px; padding: 6px 4px; border-radius: 10px; border: 2px solid rgba(245, 212, 135, .25); background: rgba(0, 0, 0, .2); text-align: center; }
.adv-day.is-done { opacity: .55; border-color: #22c55e; }
.adv-day.is-today { border-color: #fbbf24; box-shadow: 0 0 12px rgba(251, 191, 36, .6); animation: w-bob 1.6s ease-in-out infinite; }
.adv-day-icon { font-size: 1.4rem; }
.adv-day-label { font-size: .62rem; line-height: 1.2; }
.gs-badge.is-gift { background: #f59e0b; animation: w-bob 1.2s ease-in-out infinite; }
.w-bolt { position: absolute; z-index: 1400; height: 10px; width: var(--len); margin-top: -18px; transform-origin: 0 50%; transform: rotate(var(--a)); border-radius: 6px; pointer-events: none;
  background: linear-gradient(90deg, rgba(251, 146, 60, 0), #fb923c 60%, #fde047); box-shadow: 0 0 12px #f97316; animation: w-bolt .34s ease-out forwards; }
@keyframes w-bolt { from { clip-path: inset(0 100% 0 0); opacity: 1; } 60% { clip-path: inset(0 0 0 0); opacity: 1; } to { clip-path: inset(0 0 0 70%); opacity: 0; } }

/* ---------- บอสประจำโซน (v2.22) ---------- */
.gs-bossbar { position: absolute; z-index: 22; top: 64px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 24px)); padding: 6px 12px 8px; display: grid; gap: 4px; text-align: center; }
.gs-bossbar[hidden] { display: none; }
.gs-bossbar strong { color: #fca5a5; font-size: .9rem; }
.gs-bosshp { position: relative; height: 14px; border-radius: 4px; background: rgba(0, 0, 0, .6); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .2); overflow: hidden; }
.gs-bossfill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(180deg, #ef4444, #7f1d1d); transition: width .2s; }
.gs-bosshp em { position: relative; display: block; text-align: center; font: 700 .66rem/14px Prompt, sans-serif; font-style: normal; text-shadow: 0 1px 2px #000; }
.w-monster.is-zoneboss .w-mon-name { color: #fca5a5; font-weight: 800; }
.w-monster.is-zoneboss .w-mon-px { filter: drop-shadow(0 0 10px rgba(239, 68, 68, .8)); }
.w-monster.is-enraged .w-mon-px { animation: w-windup .4s steps(2) infinite; }

/* ---------- ฝึกเล่น · จอยสติก · แจ้งปัญหา (v2.23) ---------- */
.gs-coach { position: absolute; z-index: 23; top: 64px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); padding: 8px 12px 10px; display: grid; gap: 6px; border-color: #fbbf24; box-shadow: 0 0 0 2px rgba(20, 12, 4, .85), 0 0 22px rgba(251, 191, 36, .45); animation: w-pop .2s ease-out; }
.gs-coach-head { display: flex; align-items: center; gap: 10px; }
.gs-coach-head strong { color: #fde047; font-size: .9rem; }
.gs-coach-dots { display: flex; gap: 4px; flex: 1; }
.gs-coach-dots i { width: 14px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .2); }
.gs-coach-dots i.is-done { background: #22c55e; }
.gs-coach-dots i.is-on { background: #fbbf24; }
.gs-coach-skip { background: none; border: 0; color: #cbd5e1; font: inherit; font-size: .75rem; text-decoration: underline; cursor: pointer; }
.gs-coach-body { display: flex; gap: 10px; align-items: center; font-size: .92rem; }
.gs-coach-icon { font-size: 1.8rem; animation: w-bob 1.2s ease-in-out infinite; }
.gs-joy { position: absolute; z-index: 24; left: 14px; bottom: 170px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .14), rgba(255, 255, 255, .05) 70%); border: 2px solid rgba(245, 212, 135, .5); touch-action: none; }
.gs-joy-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fde68a, #b8863b); box-shadow: 0 4px 10px rgba(0, 0, 0, .5); pointer-events: none; }
@media (min-width: 761px) { .gs-joy { bottom: 110px; } }
.set-fb textarea { width: 100%; min-height: 70px; }
@media (max-width: 760px) { .gs-coach { top: auto; bottom: 300px; } }

/* ---------- อาคารส่วนกลางของหมู่บ้าน (v2.24) ---------- */
.vb { display: grid; justify-items: center; }
.vb-icon { font-size: 44px; line-height: 1; filter: drop-shadow(0 6px 4px rgba(0, 0, 0, .4)); }
.vb-2 .vb-icon { font-size: 54px; } .vb-3 .vb-icon { font-size: 64px; filter: drop-shadow(0 0 12px rgba(253, 224, 71, .8)); }
.w-place.is-unbuilt { opacity: .6; }
.world-map.is-decorating .w-furniture-place { cursor: grab; outline: 2px dashed rgba(253, 224, 71, .7); outline-offset: 4px; border-radius: 10px; touch-action: none; }
.world-map.is-decorating .w-furniture-place.is-dragging { cursor: grabbing; z-index: 3000 !important; transform: translate(-50%, -50%) scale(1.1); }

/* ---------- ความรู้ในเกม (v2.25) ---------- */
.w-scroll { position: absolute; z-index: 1200; transform: translate(-50%, -100%); background: none; border: 0; padding: 0; font-size: 30px; cursor: pointer; filter: drop-shadow(0 0 10px rgba(253, 224, 71, .9)); animation: w-bob 1.2s ease-in-out infinite; }
.w-weak { position: absolute; top: -34px; right: -18px; z-index: 5; border: 2px solid #fde047; border-radius: 50%; width: 38px; height: 38px; background: rgba(30, 20, 60, .85); font-size: 20px; cursor: pointer; box-shadow: 0 0 14px rgba(253, 224, 71, .9); animation: w-bob .9s ease-in-out infinite; }
.ga-wisdom { font-size: .72rem; color: #a7f3d0; text-align: center; padding: 2px 6px; border-radius: 6px; background: rgba(16, 185, 129, .18); }
.ga-wisdom.is-hint { color: #cbd5e1; background: rgba(255, 255, 255, .06); }

/* ---------- ภาพรวมเกม (ครู) ---------- */
.ov-days { display: flex; gap: 6px; align-items: flex-end; height: 120px; margin-top: 6px; }
.ov-day { flex: 1; display: grid; justify-items: center; gap: 2px; height: 100%; grid-template-rows: 1fr auto; }
.ov-bar { width: 70%; height: 100%; display: flex; flex-direction: column-reverse; border-radius: 4px; background: rgba(255, 255, 255, .05); overflow: hidden; }
.ov-bar .is-learn { background: #34d399; } .ov-bar .is-play { background: #f59e0b; }
.ov-lv { display: grid; grid-template-columns: 52px 1fr 32px; gap: 6px; align-items: center; margin-top: 4px; }


/* 📕 เนื้อเรื่องหลัก */
.story-ch.is-locked { opacity: .55; }
.story-ch.is-done { border-color: rgba(52, 211, 153, .5); }
.story-ch.is-ready { border-color: #f5c542; box-shadow: 0 0 0 2px rgba(245, 197, 66, .25); }
.story-text { margin: 4px 0; font-style: italic; opacity: .9; }
.story-goals { display: grid; gap: 4px; margin: 4px 0 6px; }
.story-goals .is-ok { color: #6ee7b7; }

/* 🎊 เทศกาลตามปฏิทิน */
.gs-event.is-cal { background: linear-gradient(90deg, rgba(244, 114, 182, .35), rgba(245, 197, 66, .35)); }
.w-festive { position: absolute; transform: translate(-50%, -100%); font-size: clamp(16px, 2.2vw, 26px); pointer-events: none; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .35)); animation: wFestive 3s ease-in-out infinite; }
@keyframes wFestive { 0%, 100% { transform: translate(-50%, -100%); } 50% { transform: translate(-50%, -112%); } }
@media (prefers-reduced-motion: reduce) { .w-festive { animation: none; } }

/* มอนสเตอร์หลายเฟรม: หันซ้าย/ขวา · เดินเตาะแตะ 2 จังหวะ · หายใจตอนยืน · ตัวบินลอยขึ้นลง (ไม่ทับท่าโจมตี/โดนตี) */
.w-monster .w-mon-px { --fx: 1; scale: var(--fx) 1; }
.w-monster.face-left .w-mon-px { --fx: -1; }
.w-monster:is(.is-hit, .is-windup, .is-stun, .is-hop, .is-target, .is-lunge, .is-dead, .is-enraged) .w-mon-px { scale: var(--fx) 1; }
.w-monster.is-walking:not(.is-hit, .is-windup, .is-stun, .is-hop, .is-target, .is-lunge, .is-dead, .is-enraged, .is-flier) .w-mon-px { animation: mon-waddle .36s steps(2) infinite; }
.w-monster:not(.is-walking, .is-hit, .is-windup, .is-stun, .is-hop, .is-target, .is-lunge, .is-dead, .is-enraged, .is-flier) .w-mon-px { animation: mon-breathe 1.6s steps(2) infinite; }
.w-monster.is-flier:not(.is-hit, .is-windup, .is-stun, .is-target, .is-lunge, .is-dead) .w-mon-px { animation: mon-hover 1.1s ease-in-out infinite; }
@keyframes mon-waddle { 0% { rotate: -7deg; translate: 0 0; } 100% { rotate: 7deg; translate: 0 -3px; } }
@keyframes mon-breathe { 0%, 100% { scale: var(--fx) 1; } 50% { scale: calc(var(--fx) * 1.04) .93; } }
@keyframes mon-hover { 0%, 100% { translate: 0 0; } 50% { translate: 0 -7px; } }
@media (prefers-reduced-motion: reduce) { .w-monster:not(.is-hit, .is-windup, .is-stun, .is-enraged) .w-mon-px { animation: none !important; } }

/* =====================================================================
   HUD มือถือ v3 (v2.29) — กฎชุดสุดท้ายที่ใช้จริงบนจอเล็ก (แนวตั้ง ≤760px หรือแนวนอนเตี้ย ≤500px)
   การ์ดตัวละครเล็ก · ปุ่มระบบเหลือ ⛶ ⚙️ · แถบคำสั่ง 5 ช่อง + ☰ เพิ่มเติม
   จอยสติกซ้ายล่าง · ปุ่มฟันกลมใหญ่ขวาล่าง สกิลเรียงโค้งรอบนิ้วโป้ง
   ===================================================================== */
.gs-more { display: none; }
@media (max-width: 760px), (max-height: 500px) {
  /* การ์ดตัวละคร */
  .gs-me { top: 6px; left: 6px; min-width: 0; width: min(214px, calc(100vw - 132px)); max-width: none; padding: 5px 8px 5px 5px; gap: 7px; align-items: flex-start; }
  .gs-me .av { --av: 38px !important; }
  .gs-me-info { gap: 3px; min-width: 0; flex: 1; }
  .gs-me-name { font-size: .8rem; }
  .gs-name-text { max-width: 96px; }
  .gs-me-title { display: none; }
  .gs-bar2 { height: 11px; }
  .gs-bar2 em { font-size: .56rem; line-height: 11px; padding: 0 4px; }
  .gs-xp { height: 4px; }
  .gs-xp em { display: none; }
  .gs-me-row { gap: 8px; font-size: .7rem; }
  .gs-me-row > span:nth-child(2), .gs-me-row > span:nth-child(4) { display: none; }
  /* มุมขวาบน: ปุ่มระบบ + แผนที่ย่อ */
  .gs-corner { top: 6px; right: 6px; gap: 4px; }
  .gs-sys { display: flex; justify-content: flex-end; gap: 4px; }
  .gs-sys [data-music-toggle], .gs-sys [data-sfx-toggle], .gs-sys [data-tutorial] { display: none; }
  .gs-btn { width: 36px; height: 36px; padding: 0; font-size: .95rem; justify-content: center; }
  .gs-minimap canvas { width: 108px; height: 69px; }
  .gs-zone { display: none; }
  /* เป้าหมาย: ใต้การ์ด แคบ ๆ */
  .gs-track { top: 98px !important; bottom: auto !important; left: 6px; width: min(214px, calc(100vw - 132px)) !important; padding: 5px; font-size: .74rem; }
  .gs-track-head .small { display: none; }
  /* แถบคำสั่ง: 5 ช่องหลัก · ☰ กางเมนูรองขึ้นด้านบน */
  .gs-bar { left: 6px; right: 6px; bottom: 6px; transform: none; max-width: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; padding: 5px; overflow: visible; }
  .gs-bar .gs-sep, .gs-bar .is-sec { display: none; }
  .gs-bar.is-more .is-sec { display: grid; }
  .gs-bar.is-more { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .gs-more { display: grid; order: 99; }
  .gs-bar.is-more .gs-more { border-color: #fbbf24; background: rgba(251, 191, 36, .2); }
  .gs-bar:not(.is-more):has(.is-sec [data-hud-unread]:not([hidden])) .gs-more::after { content: ""; position: absolute; top: -3px; right: -3px; width: 12px; height: 12px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 2px #1b1433; }
  .gs-slot { width: auto; height: 52px; }
  .gs-slot .gs-ico { font-size: 1.25rem; }
  .gs-slot .gs-lbl { font-size: .6rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  /* ปุ่มต่อสู้: วงโค้งขวาล่าง */
  .gs-action { left: auto !important; right: 8px !important; bottom: 80px !important; transform: none !important; padding: 0 !important; background: none !important; border: 0 !important; box-shadow: none !important; max-width: none !important; display: block; }
  .gs-action::before, .gs-action::after { display: none !important; }
  .gs-action .ga-btns { position: relative; width: 210px; height: 210px; margin: 0; display: block; pointer-events: none; }
  .gs-action .ga-btns > * { pointer-events: auto; }
  .gs-action .ga-sep, .gs-action .ga-name, .gs-action .bt-key { display: none; }
  .gs-action .ga-btn { position: absolute; min-width: 0; width: 46px; height: 46px; padding: 0; border-radius: 50%; place-content: center; opacity: .92; box-shadow: 0 3px 8px rgba(0, 0, 0, .45); }
  .gs-action .ga-btn .ga-ico { font-size: 1.15rem; line-height: 1; }
  .gs-action .ga-cost { position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%); padding: 0 4px; border-radius: 6px; background: rgba(15, 10, 30, .9); font-size: .52rem; white-space: nowrap; }
  .gs-action .ga-btns > .ga-btn:nth-child(1) { right: 0; bottom: 0; width: 70px; height: 70px; border-width: 3px; border-color: #fbbf24; background: radial-gradient(circle at 35% 30%, #7c3aed, #3b1d6e); }
  .gs-action .ga-btns > .ga-btn:nth-child(1) .ga-ico { font-size: 1.9rem; }
  /* วงใน r=88: กลิ้ง Q E · วงนอก r=150: R T (ไม่ทับกัน) */
  .gs-action .ga-btns > .ga-btn:nth-child(2) { right: 100px; bottom: 12px; }
  .gs-action .ga-btns > .ga-btn:nth-child(4) { right: 74px; bottom: 74px; }
  .gs-action .ga-btns > .ga-btn:nth-child(5) { right: 12px; bottom: 100px; }
  .gs-action .ga-btns > .ga-btn:nth-child(6) { right: 151px; bottom: 69px; }
  .gs-action .ga-btns > .ga-btn:nth-child(7) { right: 69px; bottom: 151px; }
  .gs-action .ga-btn:active { transform: scale(.9); }
  .gs-action .ga-wisdom { position: absolute; right: 0; bottom: 214px; max-width: 160px; font-size: .62rem; }
  .gs:has(.gs-bar.is-more) .gs-joy, .gs:has(.gs-bar.is-more) .gs-action { display: none !important; }
  .gs-action .ga-wisdom.is-hint { display: none; }
  /* จอยสติก ซ้ายล่างเหนือแถบคำสั่ง */
  .gs-joy { left: 14px; bottom: 82px !important; width: 116px; height: 116px; }
  /* สิ่งที่ลอยอยู่กลางจอ */
  body.is-fullgame .toasts { top: 172px; bottom: auto !important; left: 6px; right: auto; width: min(300px, calc(100vw - 12px)); }
  .gs-coach { top: 172px !important; bottom: auto !important; }
  .gs-focus { top: 172px !important; bottom: auto !important; }
  .gs-mine { top: 120px !important; right: 6px; left: auto; transform: none; }
  .gs .world-emotes { bottom: 70px; }
  body.is-fullgame .world-panel { top: auto; bottom: 68px; left: 6px; right: 6px; width: auto; max-height: calc(100% - 180px); }
}
/* แนวนอนเตี้ย (มือถือตะแคง): เป้าหมายพับ ชิดซ้าย · แผงขึ้นเต็มความสูง */
@media (max-height: 500px) {
  .gs-track { width: 200px !important; max-height: 112px; overflow: hidden; }
  .gs-joy { bottom: 70px !important; width: 104px; height: 104px; }
  .gs-bar { left: 50%; right: auto; transform: translateX(-50%); width: min(420px, calc(100vw - 340px)); }
  body.is-fullgame .world-panel { top: 6px; bottom: 6px; left: auto; right: 6px; width: min(420px, 60vw); max-height: none; }
  body.is-fullgame .toasts { top: auto; bottom: 70px !important; left: 130px; }
}

/* =====================================================================
   🎒 กระเป๋าในเกม (v2.29): ช่องสวมใส่ · ตารางไอเทมกรอบสีตามความหายาก · รายละเอียด + เทียบค่าพลัง
   ===================================================================== */
.world-panel.is-bag { width: min(440px, calc(100vw - 16px)); }
.bag-stats { display: flex; justify-content: space-around; gap: 6px; padding: 6px; border-radius: 10px; background: rgba(0, 0, 0, .3); font-size: .85rem; }
.bag-stats b { color: #fde047; }
.bag-slots { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.bag-slot { display: grid; justify-items: center; gap: 2px; }
.bag-slot-lbl { font-size: .58rem; color: #cbd5e1; white-space: nowrap; }
.bag-tabs { flex-wrap: wrap; }
.bag-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.bag-cell { --rc: #9ca3af; position: relative; aspect-ratio: 1; width: 100%; display: grid; place-items: center; padding: 0; border-radius: 10px; border: 2px solid var(--rc); background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--rc) 28%, #1e1533), #140e24 75%); color: #fff; font: inherit; cursor: pointer; transition: transform .1s, box-shadow .15s; }
.bag-cell.is-empty { --rc: rgba(245, 212, 135, .18); background: rgba(0, 0, 0, .25); cursor: default; }
.bag-cell.is-empty .bag-ico { opacity: .35; filter: grayscale(1); }
.bag-cell:not(.is-empty):hover { transform: translateY(-2px); }
.bag-cell.r-epic, .bag-cell.r-legend { box-shadow: 0 0 10px color-mix(in srgb, var(--rc) 55%, transparent); }
.bag-cell.r-legend::before { content: ""; position: absolute; inset: -2px; border-radius: 10px; background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%) 0 0 / 250% 100%; animation: bag-shine 2.8s linear infinite; pointer-events: none; }
@keyframes bag-shine { to { background-position: -250% 0; } }
.bag-cell.is-sel { outline: 3px solid #fff; outline-offset: 1px; }
.bag-ico { font-size: clamp(1.3rem, 6vw, 1.7rem); line-height: 1; }
.bag-plus { position: absolute; top: 2px; left: 4px; font: 800 .62rem Prompt, sans-serif; color: #fde047; text-shadow: 0 1px 2px #000; }
.bag-qty { position: absolute; bottom: 1px; right: 4px; font: 700 .62rem Prompt, sans-serif; text-shadow: 0 1px 2px #000; }
.bag-on { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; background: #22c55e; font-size: .65rem; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px #1b1433; }
.bag-detail { --rc: #9ca3af; display: grid; gap: 6px; padding: 10px; border-radius: 12px; border: 2px solid var(--rc); background: linear-gradient(180deg, color-mix(in srgb, var(--rc) 16%, #1e1533), #150f27); animation: bag-pop .18s ease-out; }
@keyframes bag-pop { from { transform: translateY(6px); opacity: 0; } }
.bag-detail-head { display: flex; gap: 10px; align-items: center; }
.bag-detail-ico { font-size: 2.2rem; }
.bag-detail-name { color: var(--rc); font-size: 1.05rem; }
.bag-stat-list { display: grid; gap: 3px; }
.bag-stat { display: flex; gap: 8px; align-items: center; font-size: .85rem; }
.bag-stat > span:first-child { flex: 1; }
.bag-stat .is-up { color: #4ade80; font-weight: 700; }
.bag-stat .is-down { color: #f87171; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .bag-cell.r-legend::before, .bag-detail { animation: none; } }

/* หน้าต่างในเกม (iframe): หัวหน้ากะทัดรัด ไม่ซ้ำกับ HUD · เนื้อหาหลักขึ้นมาก่อน */
body.is-embed .hero.hero-hud { display: none; }
body.is-embed .hero { padding: 10px 14px; }
body.is-embed .hero::after { display: none; }
body.is-embed .hero .hero-title, body.is-embed .hero p.muted { display: none; }
body.is-embed .hero-name { font-size: 1.1rem; }
body.is-embed .hero-grid { gap: 12px; }
body.is-embed .hero .av { --av: 56px !important; }
body.is-embed .hero .stat { min-width: 0 !important; padding: 6px 10px; }
body.is-embed .hero .stat-sub { display: none; }
body.is-embed .game-main .wrap { padding-top: 10px; }

/* 💫 หน้าจอหมดแรง */
.gs.is-fainted .world-scroll { filter: grayscale(.85) brightness(.6); transition: filter .5s; }
.gs-faint { position: absolute; inset: 0; z-index: 4000; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 16px; text-align: center; background: radial-gradient(circle, rgba(60, 10, 20, .35), rgba(10, 5, 20, .75)); animation: gsFaintIn .35s ease-out; pointer-events: none; }
.gs-faint.is-out { opacity: 0; transition: opacity .35s; }
.gs-faint-title { font: 800 clamp(2rem, 9vw, 3.6rem)/1 var(--font-display, Prompt), sans-serif; color: #fecaca; text-shadow: 0 4px 0 #450a0a, 0 0 24px rgba(248, 113, 113, .6); animation: gsFaintTitle .6s cubic-bezier(.2, 1.6, .4, 1); }
.gs-faint-sub { color: #e2e8f0; font-size: .95rem; }
.gs-faint-bar { width: min(260px, 70vw); height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.gs-faint-bar > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #86efac, #22c55e); animation: gsFaintBar 2.3s linear forwards; }
.gs-faint-tip { max-width: 420px; padding: 8px 12px; border-radius: 10px; background: rgba(15, 10, 30, .8); border: 1px solid rgba(245, 212, 135, .35); color: #fde68a; font-size: .85rem; }
@keyframes gsFaintIn { from { opacity: 0; } }
@keyframes gsFaintTitle { from { transform: scale(1.6); opacity: 0; } }
@keyframes gsFaintBar { to { width: 100%; } }
@media (prefers-reduced-motion: reduce) { .gs-faint, .gs-faint-title { animation: none; } }

/* 🌋 ภูเขาไฟ */
.zone-volcano .w-deco-px { filter: sepia(.6) saturate(1.4) brightness(.8) drop-shadow(0 4px 2px rgba(0, 0, 0, .35)); }
.wx-ember { position: absolute; bottom: -10px; width: 4px; height: 4px; border-radius: 50%; background: #fdba74; box-shadow: 0 0 8px 2px rgba(249, 115, 22, .85); animation: wx-ember linear infinite; }
@keyframes wx-ember { 0% { transform: translate(0, 0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(30px, -105vh); opacity: 0; } }

/* 🛒 ร้านค้าในเกม (ใช้กรอบเดียวกับกระเป๋า) */
.shop-head { justify-content: space-between; align-items: center; padding: 6px 10px; }
.shop-cell { aspect-ratio: auto; height: auto; min-height: 76px; padding: 8px 2px 4px; align-content: start; gap: 4px; }
.shop-price { font: 700 .62rem Prompt, sans-serif; color: #fde047; white-space: nowrap; }
.shop-cell.is-owned .shop-price { color: #86efac; }
.shop-cell.is-locked, .shop-cell.is-poor { filter: grayscale(.55) brightness(.8); }
.shop-cell.is-poor .shop-price { color: #fca5a5; }
.shop-lock { position: absolute; top: 2px; left: 4px; font: 700 .58rem Prompt, sans-serif; }
.btn.is-armed { animation: shop-arm .6s ease-in-out infinite alternate; box-shadow: 0 0 0 3px rgba(253, 224, 71, .5); }
@keyframes shop-arm { to { box-shadow: 0 0 0 6px rgba(253, 224, 71, .15); } }
@media (prefers-reduced-motion: reduce) { .btn.is-armed { animation: none; } }
.shop-name { max-width: 100%; padding: 0 3px; font-size: .56rem; line-height: 1.2; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ⭐ ฉากเลเวลอัป */
.gs-lvup { position: absolute; left: 50%; top: 42%; z-index: 3900; width: min(380px, 92vw); transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 6px; padding: 14px 26px; text-align: center; pointer-events: none; animation: gsLvIn .55s cubic-bezier(.2, 1.5, .4, 1); }
.gs-lvup::before { content: ""; position: absolute; inset: -20px -10px; z-index: -1; border-radius: 24px; background: radial-gradient(ellipse at 50% 40%, rgba(15, 10, 30, .9), rgba(15, 10, 30, .55) 65%, rgba(15, 10, 30, 0) 100%); }
.gs-lvup.is-out { opacity: 0; transform: translate(-50%, -60%); transition: opacity .45s, transform .45s; }
.gs-lvup-kicker { font: 800 clamp(1rem, 4vw, 1.4rem) var(--font-display, Prompt), sans-serif; letter-spacing: 4px; color: #fde68a; text-shadow: 0 2px 0 #92400e; }
.gs-lvup-lv { font: 900 clamp(3rem, 14vw, 5rem)/1 var(--font-display, Prompt), sans-serif; background: linear-gradient(180deg, #fff7ad, #fbbf24 55%, #d97706); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 4px 0 #78350f) drop-shadow(0 0 18px rgba(251, 191, 36, .7)); }
.gs-lvup-sub { color: #e2e8f0; font-size: .9rem; }
.gs-lvup-unlock { padding: 4px 12px; border-radius: 999px; background: rgba(34, 197, 94, .22); border: 1px solid rgba(134, 239, 172, .55); color: #bbf7d0; font-size: .85rem; font-weight: 600; animation: gsLvIn .5s .4s backwards; }
@keyframes gsLvIn { from { opacity: 0; transform: translate(-50%, -50%) scale(.4); } }
.gs-lvup-unlock { animation-name: gsLvPop; }
@keyframes gsLvPop { from { opacity: 0; transform: translateY(8px); } }
.w-char.is-lvup::before { content: ""; position: absolute; left: 50%; bottom: 0; width: 70px; height: 220px; transform: translateX(-50%); border-radius: 40px 40px 0 0; background: linear-gradient(0deg, rgba(253, 224, 71, .75), rgba(253, 224, 71, 0)); animation: gsPillar 2.4s ease-out forwards; pointer-events: none; z-index: -1; }
@keyframes gsPillar { 0% { opacity: 0; transform: translateX(-50%) scaleY(.1); } 20% { opacity: 1; transform: translateX(-50%) scaleY(1); } 100% { opacity: 0; transform: translateX(-50%) scaleY(1.1); } }
@media (prefers-reduced-motion: reduce) { .gs-lvup, .gs-lvup-unlock, .w-char.is-lvup::before { animation: none; } }

/* 🎁 การ์ดของดรอป */
.gs-loot { --rc: #fbbf24; position: absolute; left: 50%; top: 40%; z-index: 3950; width: min(320px, 90vw); transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 6px; padding: 18px 16px 14px; border-radius: 18px; border: 3px solid var(--rc); background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--rc) 30%, #1e1533), #120c22 70%); box-shadow: 0 0 0 3px rgba(0, 0, 0, .5), 0 0 40px color-mix(in srgb, var(--rc) 50%, transparent); text-align: center; animation: gsLootIn .5s cubic-bezier(.2, 1.5, .4, 1); overflow: hidden; }
.gs-loot.is-out { opacity: 0; transform: translate(-50%, -40%) scale(.9); transition: opacity .4s, transform .4s; }
.gs-loot-beam { position: absolute; inset: -60% -20%; z-index: -1; background: conic-gradient(from 0deg, transparent 0 20deg, color-mix(in srgb, var(--rc) 35%, transparent) 30deg, transparent 40deg 110deg, color-mix(in srgb, var(--rc) 35%, transparent) 120deg, transparent 130deg 200deg, color-mix(in srgb, var(--rc) 35%, transparent) 210deg, transparent 220deg 290deg, color-mix(in srgb, var(--rc) 35%, transparent) 300deg, transparent 310deg); animation: gsLootSpin 6s linear infinite; }
.gs-loot-kicker { font: 800 .8rem var(--font-display, Prompt), sans-serif; letter-spacing: 2px; color: var(--rc); text-transform: uppercase; }
.gs-loot-ico { font-size: 3.4rem; line-height: 1.1; filter: drop-shadow(0 0 14px var(--rc)); animation: gsLootBob 1.6s ease-in-out infinite; }
.gs-loot-name { font-size: 1.15rem; color: #fff; }
.gs-loot-desc { color: #cbd5e1; }
.gs-loot.is-big .gs-loot-name { color: var(--rc); text-shadow: 0 0 12px color-mix(in srgb, var(--rc) 60%, transparent); }
@keyframes gsLootIn { from { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(-8deg); } }
@keyframes gsLootSpin { to { transform: rotate(360deg); } }
@keyframes gsLootBob { 50% { transform: translateY(-6px) scale(1.05); } }
@media (prefers-reduced-motion: reduce) { .gs-loot, .gs-loot-beam, .gs-loot-ico { animation: none; } }

/* 👑 ฉากเปิดตัวบอส */
.gs-bossintro { position: absolute; inset: 0; z-index: 3800; pointer-events: none; }
.gs-bi-bar { position: absolute; left: 0; right: 0; height: 13%; background: #000; animation: gsBiBar .45s ease-out; }
.gs-bi-bar.is-top { top: 0; transform-origin: top; }
.gs-bi-bar.is-bottom { bottom: 0; transform-origin: bottom; }
.gs-bi-text { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); display: grid; justify-items: center; gap: 4px; padding: 14px; background: linear-gradient(90deg, transparent, rgba(30, 5, 10, .85) 20%, rgba(30, 5, 10, .85) 80%, transparent); text-align: center; animation: gsBiText .6s .15s cubic-bezier(.2, 1.4, .4, 1) backwards; }
.gs-bi-kicker { font: 700 .85rem var(--font-display, Prompt), sans-serif; letter-spacing: 3px; color: #fca5a5; }
.gs-bi-name { font: 900 clamp(1.8rem, 8vw, 3rem)/1.1 var(--font-display, Prompt), sans-serif; color: #fff; text-shadow: 0 3px 0 #7f1d1d, 0 0 20px rgba(239, 68, 68, .8); }
.gs-bi-tip { font-size: .8rem; color: #fde68a; }
.gs-bossintro.is-out { opacity: 0; transition: opacity .45s; }
@keyframes gsBiBar { from { transform: scaleY(0); } }
@keyframes gsBiText { from { opacity: 0; transform: translateY(-50%) scaleX(.2); } }
@media (prefers-reduced-motion: reduce) { .gs-bi-bar, .gs-bi-text { animation: none; } }

/* 🐾 ความสามารถสัตว์เลี้ยง */
.pet-perk { padding: 5px 10px; border-radius: 8px; background: rgba(168, 85, 247, .18); border: 1px solid rgba(216, 180, 254, .45); color: #e9d5ff; font-size: .8rem; font-weight: 600; }
.pet-perk.is-active { text-align: center; }

/* ★ มอนสเตอร์หัวหน้า (ออร่าสีตามความสามารถ) */
.w-monster.has-affix::before { content: ""; position: absolute; left: 50%; bottom: 2px; width: 84px; height: 26px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(ellipse, color-mix(in srgb, var(--aff) 70%, transparent), transparent 70%); animation: affPulse 1.2s ease-in-out infinite; pointer-events: none; z-index: -1; }
.w-monster.has-affix .w-mon-px { filter: drop-shadow(0 0 6px var(--aff)) drop-shadow(0 0 2px var(--aff)) !important; }
.w-monster.has-affix .w-mon-name { color: var(--aff); font-weight: 800; }
@keyframes affPulse { 50% { opacity: .45; transform: translateX(-50%) scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .w-monster.has-affix::before { animation: none; } }

/* 🗺️ เดินทางด่วน */
.travel-list { display: grid; gap: 6px; }
.travel-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; border: 2px solid rgba(245, 212, 135, .35); background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(0, 0, 0, .2)); color: #fff; font: inherit; text-align: left; cursor: pointer; }
.travel-row:not(:disabled):hover { border-color: #fbbf24; transform: translateX(2px); }
.travel-ico { font-size: 1.6rem; text-align: center; }
.travel-name { display: grid; }
.travel-state { font-size: .8rem; font-weight: 700; color: #fde047; white-space: nowrap; }
.travel-row.is-here { border-color: #22c55e; background: rgba(34, 197, 94, .15); cursor: default; }
.travel-row.is-here .travel-state { color: #86efac; }
.travel-row.is-locked, .travel-row.is-unseen { opacity: .55; cursor: not-allowed; }
.travel-row.is-locked .travel-state, .travel-row.is-unseen .travel-state { color: #cbd5e1; }

/* 📡 สัญญาณหลุด */
.gs-net { position: absolute; left: 50%; top: 8px; z-index: 4500; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 999px; background: rgba(127, 29, 29, .92); border: 2px solid #fca5a5; color: #fff; font-size: .85rem; font-weight: 600; box-shadow: 0 6px 18px rgba(0, 0, 0, .45); white-space: nowrap; max-width: calc(100vw - 16px); overflow: hidden; text-overflow: ellipsis; }
.gs-net-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #fca5a5; animation: gsNet 1s ease-in-out infinite; }
@keyframes gsNet { 50% { opacity: .2; } }

/* 🏅 สมุดเหรียญตรา */
.badge-book { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.badge-card { --rc: #cbd5e1; display: grid; justify-items: center; align-content: start; gap: 3px; padding: 10px 8px; border-radius: 12px; border: 2px solid color-mix(in srgb, var(--rc) 35%, transparent); background: rgba(0, 0, 0, .25); text-align: center; }
.badge-card:not(.is-have) .badge-ico { filter: grayscale(1) brightness(.6); }
.badge-card.is-have { border-color: var(--rc); background: radial-gradient(circle at 50% 20%, color-mix(in srgb, var(--rc) 22%, #1e1533), #150f27 80%); box-shadow: 0 0 10px color-mix(in srgb, var(--rc) 35%, transparent); }
.badge-ico { font-size: 2rem; line-height: 1.1; }
.badge-name { font-size: .82rem; color: var(--rc); }
.badge-desc { font-size: .66rem; color: #cbd5e1; }
.badge-got { font-size: .7rem; font-weight: 700; color: #86efac; }
.badge-got.is-manual { color: #fde68a; }
.badge-prog { width: 100%; display: grid; gap: 2px; justify-items: center; }
.badge-prog .bar { width: 100%; }

/* มือถือ: ระหว่างฝึกเล่น กล่องฝึกเล่นอยู่ใต้การ์ดตัวละคร (ซ่อนเป้าหมายชั่วคราว) · แจ้งเตือนเลื่อนลงไม่ทับ */
@media (max-width: 760px), (max-height: 500px) {
  .gs:has(.gs-coach) .gs-track { display: none !important; }
  .gs-coach { top: 100px !important; left: 6px !important; right: 6px !important; width: auto !important; max-width: none !important; transform: none !important; }
  body.is-fullgame:has(.gs-coach) .toasts { top: 210px !important; }
}

/* แท็บเล็ต/แล็ปท็อปจอเล็ก: แถบชื่อโซนไม่ทับการ์ดตัวละครและแผนที่ย่อ */
@media (min-width: 761px) and (max-width: 1260px) and (min-height: 501px) {
  .gs-zone { left: 324px !important; right: 318px !important; transform: none !important; width: auto !important; max-width: none !important; justify-content: center; flex-wrap: wrap; gap: 6px; font-size: .78rem; padding: 6px 10px; }
  .gs-zone .gs-zone-online, .gs-zone .gs-event.is-cal, .gs-zone .chip { display: none; }
}
@media (min-width: 761px) and (max-width: 999px) and (min-height: 501px) {
  .gs-zone { display: none !important; }
}
@media (min-width: 761px) and (min-height: 501px) and (max-height: 700px) { .gs-track { max-height: 180px; overflow: hidden; } }

/* ★ ขั้นสกิล */
.ga-rank { position: absolute; top: -9px; right: -4px; z-index: 2; padding: 0 3px; border-radius: 6px; background: rgba(15, 10, 30, .9); color: #fde047; font-size: .55rem; line-height: 1.4; letter-spacing: -1px; text-shadow: 0 0 4px rgba(253, 224, 71, .7); pointer-events: none; }
.ga-rank:empty { display: none; }

/* 📰 มีอะไรใหม่ */
.news-list { display: grid; gap: 6px; }
.news-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(245, 212, 135, .25); font-size: .88rem; }
.news-ico { flex: none; width: 28px; font-size: 1.3rem; text-align: center; }

/* 🔠 ขนาดตัวอักษร (ตั้งค่าใน ⚙️) */
/* มือถือ + หน้าเว็บทั่วไป: ขยายทั้งหน้า · โลกเกมบนจอใหญ่: HUD คงขนาด (กันทับกัน) ขยายเฉพาะเนื้อหาในแผง */
html.fs-lg:not(:has(body.is-fullgame)) { font-size: 112.5%; }
html.fs-xl:not(:has(body.is-fullgame)) { font-size: 125%; }
@media (max-width: 760px), (max-height: 500px) {
  html.fs-lg { font-size: 112.5%; }
  html.fs-xl { font-size: 125%; }
}
@media (min-width: 761px) and (min-height: 501px) {
  html.fs-lg body.is-fullgame .world-panel > * { zoom: 1.12; }
  html.fs-xl body.is-fullgame .world-panel > * { zoom: 1.25; }
}

/* 🏆 ปลดล็อกเหรียญตรา */
.gs-ach { --rc: #fbbf24; position: absolute; left: 50%; top: 70px; z-index: 4200; width: min(380px, 94vw); transform: translateX(-50%); display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-radius: 16px; border: 2px solid var(--rc); background: linear-gradient(135deg, color-mix(in srgb, var(--rc) 30%, #1e1533), #120c22 70%); box-shadow: 0 10px 30px rgba(0, 0, 0, .55), 0 0 22px color-mix(in srgb, var(--rc) 45%, transparent); cursor: pointer; animation: gsAchIn .55s cubic-bezier(.2, 1.4, .4, 1); overflow: hidden; }
.gs-ach::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, .28) 50%, transparent 65%) -100% 0 / 220% 100% no-repeat; animation: gsAchShine 1.4s .4s ease-out; pointer-events: none; }
.gs-ach.is-out { opacity: 0; transform: translate(-50%, -30px); transition: opacity .4s, transform .4s; }
.gs-ach-ico { flex: none; font-size: 2.4rem; filter: drop-shadow(0 0 10px var(--rc)); animation: gsLootBob 1.6s ease-in-out infinite; }
.gs-ach-kicker { font: 800 .72rem var(--font-display, Prompt), sans-serif; letter-spacing: 1px; color: var(--rc); }
.gs-ach-name { display: block; font-size: 1.05rem; color: #fff; }
.gs-ach-desc { font-size: .75rem; color: #cbd5e1; }
@keyframes gsAchIn { from { opacity: 0; transform: translate(-50%, -80px) scale(.9); } }
@keyframes gsAchShine { to { background-position: 200% 0; } }
@media (max-width: 760px) { .gs-ach { top: 104px; } }
@media (prefers-reduced-motion: reduce) { .gs-ach, .gs-ach::after, .gs-ach-ico { animation: none; } }

/* 🧭 หน้าโหลดระหว่างเปลี่ยนแมพ */
.gs-curtain { display: grid; place-items: center; }
.gs-curtain-inner { display: grid; justify-items: center; gap: 12px; padding: 20px; text-align: center; opacity: 0; transition: opacity .25s .15s; }
.gs.is-leaving .gs-curtain-inner { opacity: 1; }
.gs-curtain-dest { font: 700 1.15rem var(--font-display, Prompt), sans-serif; color: #fde68a; }
.gs-curtain-bar { width: min(240px, 60vw); height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.gs-curtain-bar > span { display: block; width: 40%; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #fbbf24, #f472b6); animation: gsLoadBar 1s ease-in-out infinite; }
.gs-curtain-tip { max-width: 420px; color: #cbd5e1; font-size: .88rem; }
@keyframes gsLoadBar { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* 📬 กล่องจดหมาย */
.mail-list { display: grid; gap: 6px; }
.mail-item { position: relative; display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 9px 12px; border-radius: 12px; border: 1px solid rgba(245, 212, 135, .2); background: rgba(255, 255, 255, .04); color: #e2e8f0; font: inherit; text-align: left; }
button.mail-item { cursor: pointer; }
button.mail-item:hover { border-color: #fbbf24; }
.mail-item.is-new { background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .55); }
.mail-ico { flex: none; font-size: 1.4rem; line-height: 1.2; }
.mail-body { display: grid; gap: 2px; min-width: 0; }
.mail-body strong { font-size: .88rem; }
.mail-ago { font-size: .68rem; color: #94a3b8; }
.mail-dot { position: absolute; top: 10px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 2px #1b1433; }

/* ⚡ หลบจังหวะพอดี */
.gs.is-perfect .world-scroll { animation: gsPerfect .65s ease-out; }
.gs.is-perfect::after { content: ""; position: absolute; inset: 0; z-index: 3700; pointer-events: none; background: radial-gradient(circle, transparent 40%, rgba(56, 189, 248, .35)); animation: gsPerfectV .65s ease-out forwards; }
@keyframes gsPerfect { 0% { filter: saturate(.2) brightness(1.25) hue-rotate(160deg); } 100% { filter: none; } }
@keyframes gsPerfectV { from { opacity: 1; } to { opacity: 0; } }
.w-float.is-perfect, .is-perfect.w-float { color: #7dd3fc; font-size: 1.15rem; font-weight: 900; text-shadow: 0 0 10px rgba(56, 189, 248, .9), 0 2px 0 #0c4a6e; }
@media (prefers-reduced-motion: reduce) { .gs.is-perfect .world-scroll, .gs.is-perfect::after { animation: none; } }

/* 🔗 ตัวนับตีต่อเนื่อง */
.gs-chain { position: absolute; right: 16px; top: 42%; z-index: 3600; display: grid; justify-items: end; pointer-events: none; font-family: var(--font-display, Prompt), sans-serif; text-shadow: 0 3px 0 rgba(0, 0, 0, .55); }
.gs-chain b { font-size: 2.6rem; line-height: 1; color: #fff; }
.gs-chain span { font-size: .78rem; font-weight: 800; letter-spacing: 2px; color: #fde68a; }
.gs-chain.is-warm b { color: #fde047; }
.gs-chain.is-hot b { color: #fb923c; text-shadow: 0 0 14px rgba(249, 115, 22, .8), 0 3px 0 rgba(0, 0, 0, .55); }
.gs-chain.is-pop b { animation: gsChainPop .25s cubic-bezier(.2, 1.8, .4, 1); }
.gs-chain.is-out { opacity: 0; transition: opacity .35s; }
@keyframes gsChainPop { from { transform: scale(1.5); } }
@media (max-width: 760px) { .gs-chain { right: 10px; top: 34%; } .gs-chain b { font-size: 2rem; } }
@media (prefers-reduced-motion: reduce) { .gs-chain.is-pop b { animation: none; } }

/* 🐾 เลเวลสัตว์เลี้ยง */
.pet-lv { display: grid; gap: 4px; padding: 6px 10px; border-radius: 8px; background: rgba(244, 114, 182, .12); border: 1px solid rgba(249, 168, 212, .4); }
.pet-lv .bar > span { background: linear-gradient(90deg, #f472b6, #c084fc); }

/* 🌠 ฝนดาวตก */
.w-meteor { position: absolute; transform: translate(-50%, -100%); width: 44px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; animation: wMeteorFall .9s cubic-bezier(.4, 0, .9, .6) backwards; }
.w-meteor-core { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; filter: drop-shadow(0 0 10px #fde047) drop-shadow(0 0 4px #fff); animation: wMeteorGlow 1.4s ease-in-out infinite; }
.w-meteor-trail { position: absolute; left: 50%; bottom: 60%; width: 6px; height: 0; border-radius: 3px; background: linear-gradient(0deg, rgba(253, 224, 71, .9), transparent); transform: translateX(-50%) rotate(25deg); transform-origin: bottom; animation: wMeteorTrail .9s ease-out backwards; animation-delay: inherit; pointer-events: none; }
.w-meteor::after { content: ""; position: absolute; left: 50%; bottom: -4px; width: 46px; height: 14px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(ellipse, rgba(253, 224, 71, .55), transparent 70%); animation: wMeteorGlow 1.4s ease-in-out infinite; }
@keyframes wMeteorFall { from { transform: translate(120%, -900%) scale(.6); opacity: 0; } 70% { opacity: 1; } }
@keyframes wMeteorTrail { 0% { height: 160px; opacity: 1; } 100% { height: 0; opacity: 0; } }
@keyframes wMeteorGlow { 50% { transform: scale(1.12); opacity: .8; } }
@media (prefers-reduced-motion: reduce) { .w-meteor, .w-meteor-core, .w-meteor-trail, .w-meteor::after { animation: none; } }

/* ลูกสไลม์ที่แตกตัว: ตัวเล็กลง */
.w-monster.is-mini .w-mon-px { zoom: .6; }

/* ❄️ หนาวสั่น · 🔥 ไฟลุก */
.w-char.is-chilled .w-sprite { filter: hue-rotate(180deg) saturate(1.6) brightness(1.15) drop-shadow(0 0 6px #7dd3fc); }
.w-char.is-burning::after { content: "🔥"; position: absolute; left: 50%; bottom: 58%; transform: translateX(-50%); font-size: 18px; pointer-events: none; animation: wBurn .5s ease-in-out infinite alternate; }
@keyframes wBurn { to { transform: translateX(-50%) translateY(-4px) scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .w-char.is-burning::after { animation: none; } }

.ga-wisdom.is-food { background: rgba(251, 146, 60, .18); color: #fed7aa; }
@media (max-width: 760px), (max-height: 500px) { .gs-action .ga-wisdom.is-food { bottom: 240px; } }

/* 💰 ก็อบลินขนสมบัติ */
.w-monster.is-goblin .w-mon-name { color: #fde047; font-weight: 800; }
.w-monster.is-goblin::before { content: ""; position: absolute; left: 50%; bottom: 2px; width: 70px; height: 22px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(ellipse, rgba(253, 224, 71, .6), transparent 70%); animation: affPulse 1s ease-in-out infinite; pointer-events: none; z-index: -1; }

/* 🐎 พาหนะ */
.w-char.is-riding .w-hero { translate: 0 -18px; }
.w-char.is-riding:has(.w-mount.is-px) .w-hero { translate: 0 -34px; }
.w-mount { position: absolute; left: 50%; bottom: 4px; font-size: 46px; line-height: 1; translate: -50% 0; z-index: 3; pointer-events: none; filter: drop-shadow(0 4px 2px rgba(0, 0, 0, .35)); }
.w-char[data-dir="right"] .w-mount { scale: -1 1; }
.w-char.is-riding.is-walking .w-mount { animation: mount-gallop .36s ease-in-out infinite; }
@keyframes mount-gallop { 50% { translate: -50% -5px; } }
.w-char.is-riding .w-tag { margin-top: -2px; }

/* 🎨 ภาพพิกเซล (pixelart.js) แทนอีโมจิ */
.w-petf.is-px > span.w-petpx { left: -16px; top: -36px; width: 32px; height: 36px; background-size: 100% 100%; image-rendering: pixelated; font-size: 0; }
.w-mount.is-px { width: 78px; height: 66px; bottom: 2px; background-size: 100% 100%; image-rendering: pixelated; font-size: 0; }
.w-char[data-dir="right"] .w-mount.is-px { scale: -1 1; }
.w-critter-sp.is-px { width: 32px; height: 36px; background-size: 100% 100%; image-rendering: pixelated; vertical-align: bottom; }
.bag-ico.is-px, .bag-detail-ico.is-px, .gs-loot-ico.is-px { display: inline-grid; place-items: center; }
.bag-ico.is-px img { width: clamp(28px, 7vw, 36px); height: auto; image-rendering: pixelated; }
.bag-detail-ico.is-px img { width: 48px; height: auto; image-rendering: pixelated; }
.gs-loot-ico.is-px img { width: 72px; height: auto; image-rendering: pixelated; }

.ul-next-icon.is-px img, .farm-slot.is-px img { width: 40px; height: auto; image-rendering: pixelated; }
.ul-next-icon.is-px, .farm-slot.is-px { display: grid; place-items: center; }
.craft-ico.is-px img { width: 22px; height: auto; image-rendering: pixelated; vertical-align: middle; }
img.px-inline { width: 18px; height: 18px; image-rendering: pixelated; vertical-align: -4px; margin-right: 2px; }
.craft-reward { color: #fde68a; }
.craft-row > .btn { flex-shrink: 0; white-space: nowrap; }
.craft-row > .grow { min-width: 0; }
.ul-next-icon.is-px, .farm-slot.is-px { flex: 0 0 44px; width: 44px; }
.w-furniture.is-px { display: block; font-size: 0; background-size: 100% 100%; image-rendering: pixelated; filter: drop-shadow(0 6px 3px rgba(0, 0, 0, .35)); }
.w-deco-emoji.is-px { font-size: 0; background-size: 100% 100%; image-rendering: pixelated; }
.gs-ico.is-px, .ga-ico.is-px { display: inline-grid; place-items: center; }
.gs-ico.is-px img.px-ui { width: 28px; height: 28px; image-rendering: pixelated; }
.ga-ico.is-px img.px-ui { width: 26px; height: 26px; image-rendering: pixelated; }
@media (max-width: 760px) { .gs-ico.is-px img.px-ui { width: 24px; height: 24px; } .ga-ico.is-px img.px-ui { width: 22px; height: 22px; } .gs-action .ga-btns > .ga-btn:nth-child(1) .ga-ico.is-px img.px-ui { width: 32px; height: 32px; } }

/* 🌌 บทนำต่างโลก */
.gs-intro { position: absolute; inset: 0; z-index: 9000; display: grid; place-items: center; align-content: center; gap: 18px; padding: 24px 16px; background: radial-gradient(ellipse at 50% 30%, #1e1b4b, #05030f 70%); color: #f8fafc; cursor: pointer; animation: introIn .8s ease-out; transition: background 1.2s; }
.gs-intro[data-scene="light"] { background: radial-gradient(circle at 50% 40%, #fef9c3 0%, #fbbf24 25%, #7c2d12 60%, #0b0618 100%); }
.gs-intro[data-scene="goddess"] { background: radial-gradient(circle at 50% 35%, #fde68a 0%, #c084fc 30%, #312e81 65%, #0b0618 100%); }
.gs-intro[data-scene="wake"] { background: radial-gradient(circle at 50% 40%, #bbf7d0, #166534 55%, #052e16 100%); }
.gs-intro.is-out { opacity: 0; transition: opacity .7s; pointer-events: none; }
.gs-intro-stars { position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(2px 2px at 20% 30%, #fff, transparent), radial-gradient(2px 2px at 70% 20%, #fde68a, transparent), radial-gradient(1.5px 1.5px at 40% 70%, #fff, transparent), radial-gradient(2px 2px at 85% 60%, #c4b5fd, transparent), radial-gradient(1.5px 1.5px at 10% 80%, #fff, transparent), radial-gradient(1.5px 1.5px at 55% 45%, #fff, transparent); animation: introTwinkle 3s ease-in-out infinite alternate; }
.gs-intro-art { min-height: 192px; display: grid; place-items: end center; position: relative; }
.gs-intro-goddess { width: 120px; height: 192px; background-size: 480px 768px; background-position: 0 0; image-rendering: pixelated; filter: drop-shadow(0 0 24px #fde68a); animation: introFloat 3s ease-in-out infinite; }
.gs-intro-box { position: relative; max-width: min(640px, 100%); padding: 16px 20px; border-radius: 14px; border: 2px solid rgba(253, 224, 71, .55); background: rgba(10, 6, 30, .82); box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.gs-intro-who { font-weight: 800; color: #fde047; margin-bottom: 4px; }
.gs-intro-text { margin: 0; font-size: 1.12rem; line-height: 1.7; min-height: 3.4em; }
.gs-intro-hint { margin-top: 6px; font-size: .78rem; color: #c4b5fd; text-align: right; animation: introBlink 1.4s ease-in-out infinite; }
.gs-intro-skip { position: absolute; top: 14px; right: 14px; }
@keyframes introIn { from { opacity: 0; } }
@keyframes introFloat { 50% { transform: translateY(-8px); } }
@keyframes introTwinkle { to { opacity: .45; } }
@keyframes introBlink { 50% { opacity: .35; } }

/* 🙏 พิธีรับพร */
.gs-bless { position: absolute; inset: 0; z-index: 8500; display: grid; place-items: center; align-content: center; gap: 14px; padding: 20px 16px; text-align: center; color: #f8fafc; background: radial-gradient(circle at 50% 40%, rgba(253, 230, 138, .55), rgba(76, 29, 149, .88) 45%, rgba(5, 3, 15, .95) 80%); animation: introIn .6s ease-out; overflow: auto; }
.gs-bless.is-out { opacity: 0; transition: opacity .5s; }
.gs-bless-rays { position: absolute; inset: -40%; pointer-events: none; background: repeating-conic-gradient(from 0deg, rgba(253, 224, 71, .16) 0 8deg, transparent 8deg 20deg); animation: blessSpin 18s linear infinite; }
.gs-bless > *:not(.gs-bless-rays) { position: relative; }
.gs-bless-title { font-size: 1.35rem; font-weight: 800; color: #fde047; text-shadow: 0 2px 8px rgba(0, 0, 0, .6); }
.gs-bless-sub { color: #e9d5ff; }
.gs-bless-cards { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.gs-bless-card { width: 104px; padding: 14px 6px; border-radius: 14px; display: grid; gap: 6px; justify-items: center; font-weight: 700; background: rgba(15, 10, 40, .85); border: 2px solid rgba(196, 181, 253, .35); transition: transform .12s, box-shadow .12s, opacity .4s; }
.gs-bless-card.is-on { transform: translateY(-6px) scale(1.06); border-color: #fde047; box-shadow: 0 0 26px rgba(253, 224, 71, .8); }
.gs-bless-card.is-pick { transform: translateY(-10px) scale(1.15); }
.gs-bless-card.is-off { opacity: .35; }
.gs-bless-ico { font-size: 2.2rem; line-height: 1; }
.gs-bless-result { display: grid; gap: 6px; justify-items: center; max-width: 560px; padding: 14px 18px; border-radius: 14px; background: rgba(10, 6, 30, .8); border: 2px solid rgba(253, 224, 71, .55); animation: introIn .5s ease-out; }
.gs-bless-big { font-size: 3.4rem; line-height: 1; animation: introFloat 2.4s ease-in-out infinite; }
.gs-bless-name { font-size: 1.5rem; font-weight: 800; color: #fde047; }
.gs-bless-line { margin: 4px 0; color: #fef3c7; font-style: italic; line-height: 1.6; }
.gs-bless-gift { font-weight: 700; color: #86efac; }
@keyframes blessSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .gs-bless-rays, .gs-intro-stars, .gs-intro-goddess, .gs-bless-big { animation: none; } }
.gs-bless { background: radial-gradient(circle at 50% 40%, rgba(253, 230, 138, .6), rgba(76, 29, 149, .95) 45%, #05030f 80%); }
.gs-bless-ico.is-px img { width: 48px; height: 48px; image-rendering: pixelated; }
.gs-bless-big.is-px img { width: 80px; height: 80px; image-rendering: pixelated; }

/* 🎁 ของขวัญเลเวล */
.gs-gift { position: absolute; inset: 0; z-index: 8400; display: grid; place-items: center; padding: 16px; background: rgba(5, 3, 15, .72); animation: introIn .4s ease-out; }
.gs-gift.is-out { opacity: 0; transition: opacity .4s; }
.gs-gift-card { display: grid; gap: 10px; justify-items: center; width: min(420px, 100%); padding: 18px 20px; border-radius: 16px; text-align: center; color: #f8fafc; background: radial-gradient(circle at 50% 20%, #3b2a6b, #140e24 75%); border: 2px solid rgba(253, 224, 71, .6); box-shadow: 0 0 40px rgba(253, 224, 71, .25); }
.gs-gift.is-big .gs-gift-card { border-color: #fde047; box-shadow: 0 0 60px rgba(253, 224, 71, .55); background: radial-gradient(circle at 50% 20%, #7c3aed, #1e1145 75%); }
.gs-gift-kicker { font-weight: 800; color: #fde047; font-size: 1.1rem; }
.gs-gift-chest { width: 108px; height: 96px; background-size: 100% 100%; image-rendering: pixelated; animation: giftShake 1.2s ease-in-out infinite; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .5)); }
.gs-gift.is-big .gs-gift-chest { width: 144px; height: 128px; }
.gs-gift-chest.is-open { animation: introFloat 2.4s ease-in-out infinite; filter: drop-shadow(0 0 22px #fde047); }
.gs-gift-items { display: grid; gap: 6px; justify-items: start; width: 100%; padding: 10px 12px; border-radius: 12px; background: rgba(0, 0, 0, .3); animation: introIn .4s ease-out; }
.gs-gift-row { font-weight: 700; }
.gs-gift-row.is-item, .gs-gift-row.is-book { color: #fde047; }
.gs-gift-hint { color: #c4b5fd; }
.gs-gift-note { color: #e9d5ff; }
@keyframes giftShake { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-6deg); } 80% { transform: rotate(6deg); } 90% { transform: rotate(-3deg); } }
/* 📚 ตำราสกิล */
.book-row .book-btns { display: grid; gap: 4px; flex-shrink: 0; }
.book-hero { display: flex; gap: 10px; align-items: center; }
.book-step { font-weight: 700; color: #fde68a; }
.ga-btn.is-learn { border-color: #60a5fa; box-shadow: 0 0 12px rgba(96, 165, 250, .6); animation: learnGlow 1.6s ease-in-out infinite; }
@keyframes learnGlow { 50% { box-shadow: 0 0 22px rgba(96, 165, 250, .95); } }
.bt-note.is-good { color: #86efac; font-weight: 700; }

/* ---------- v2.59 ✨ เลื่อนขั้นอาชีพ + 🌟 ออร่าเกียรติยศ ---------- */
.gs-bless.is-ascend .gs-asc-card { width: min(220px, 42vw); padding: 16px 10px; text-align: center; }
.gs-bless.is-ascend .gs-asc-card.is-pick { transform: translateY(-6px) scale(1.05); border-color: #fde047; box-shadow: 0 0 26px rgba(253, 224, 71, .8); }
.gs-bless.is-ascend .gs-asc-card.is-off { opacity: .35; }
.gs-asc-desc { font-weight: 400; line-height: 1.45; color: #e9e3ff; }
.gs-asc-later { margin-top: 10px; background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .25); }
.adv-sub { margin: 14px 0 4px; font-size: 1rem; }
.w-aura { position: absolute; left: 50%; top: 64px; width: 78px; height: 30px; margin-left: -39px; border-radius: 50%; pointer-events: none; z-index: -1; animation: auraPulse 2.4s ease-in-out infinite; }
.w-char:not(.has-hero) .w-aura { top: 28px; }
.w-aura.is-t1 { background: radial-gradient(closest-side, rgba(253, 224, 71, .85), rgba(250, 204, 21, .35) 65%, transparent); box-shadow: 0 0 0 2px rgba(253, 224, 71, .9), 0 0 16px rgba(253, 224, 71, .7); }
.w-aura.is-t2 { background: radial-gradient(closest-side, rgba(216, 180, 254, .9), rgba(139, 92, 246, .4) 65%, transparent); box-shadow: 0 0 0 2px rgba(192, 132, 252, .95), 0 0 20px rgba(168, 85, 247, .8); }
.w-aura.is-t3 { background: conic-gradient(from 0deg, #f87171, #fbbf24, #4ade80, #38bdf8, #a78bfa, #f472b6, #f87171); box-shadow: 0 0 0 2px rgba(255, 255, 255, .75), 0 0 20px rgba(250, 204, 21, .75); animation: auraPulse 2.4s ease-in-out infinite, auraHue 4s linear infinite; }
/* ลำแสงหลังตัวละคร (Lv15+) */
.w-aura.is-t2::before, .w-aura.is-t3::before { content: ""; position: absolute; left: 50%; bottom: 50%; width: 46px; height: 90px; margin-left: -23px; border-radius: 50% 50% 0 0; background: linear-gradient(to top, rgba(216, 180, 254, .55), transparent); filter: blur(3px); }
.w-aura.is-t3::before { background: linear-gradient(to top, rgba(255, 255, 255, .6), rgba(253, 224, 71, .25) 60%, transparent); }
.w-aura.is-t2::after, .w-aura.is-t3::after { content: ""; position: absolute; left: 50%; bottom: 12px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: #fff; box-shadow: -22px -6px 0 #f5d0fe, 20px -14px 0 #fde047, -10px -26px 0 #fff, 14px -36px 0 #c4b5fd; animation: auraRise 2.2s linear infinite; }
@keyframes auraPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes auraHue { to { filter: hue-rotate(360deg); } }
@keyframes auraRise { from { transform: translateY(0); opacity: .9; } to { transform: translateY(-34px); opacity: 0; } }
body.gfx-low .w-aura, .reduce-motion .w-aura { animation: none; }
body.gfx-low .w-aura::after { display: none; }

/* ---------- 🚨 ต้องช่วยดูแล (หน้าห้องเรียนของครู) ---------- */
.watch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.watch-group { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; background: var(--panel-2); }
.watch-group.has { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.watch-group summary { display: flex; gap: 8px; align-items: center; cursor: pointer; list-style: none; }
.watch-group summary::-webkit-details-marker { display: none; }
.watch-ico { font-size: 1.4rem; }
.watch-n { font-size: 1.4rem; font-weight: 800; min-width: 2ch; text-align: right; color: var(--muted); }
.watch-group.has .watch-n { color: color-mix(in srgb, var(--warn) 80%, var(--text)); }
.watch-list { margin: 8px 0 0; padding-left: 18px; max-height: 220px; overflow: auto; font-size: .92rem; }
.watch-list li { margin: 2px 0; }
.d-block { display: block; }
