@font-face {
  font-family: 'Kanit';
  font-weight: 400;
  font-display: swap;
  src: url('fonts/kanit-400-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: 'Kanit';
  font-weight: 400;
  font-display: swap;
  src: url('fonts/kanit-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Kanit';
  font-weight: 600;
  font-display: swap;
  src: url('fonts/kanit-600-thai.woff2') format('woff2');
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}
@font-face {
  font-family: 'Kanit';
  font-weight: 600;
  font-display: swap;
  src: url('fonts/kanit-600-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --lacquer: #160d0b;
  --lacquer-2: #24140f;
  --gold: #d4af37;
  --gold-soft: #f3d98b;
  --red: #b91c1c;
  --text: #f6ecd9;
  --muted: #b9a88c;
  --hp: #e5383b;
  --sp: #3a86ff;
  --exp: #f7b801;
  --jexp: #2ec4b6;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0706;
  color: var(--text);
  font-family: 'Kanit', Tahoma, system-ui, sans-serif;
  font-size: 14px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
button, input { font-family: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#scene.hover-enemy { cursor: crosshair; }
#scene.hover-npc { cursor: help; }
#scene.hover-item { cursor: grab; }

/* ---------- Labels over entities ---------- */
#labels, #float-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.lbl {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -100%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  white-space: nowrap;
  will-change: transform;
}
.lbl .nm {
  font-size: 12px; line-height: 1.1;
  text-shadow: 0 0 3px #000, 0 0 3px #000, 1px 1px 0 #000;
}
.lbl.player .nm { color: #fff; }
.lbl.bot .nm { color: #bde0fe; }
.lbl.bot.remote .nm { color: #c8f7dc; }
.lbl.npc .nm {
  color: #ffe066; font-size: 13px; font-weight: 600;
  padding: 2px 8px; border-radius: 4px;
  background: rgba(20, 11, 8, 0.72); border: 1px solid rgba(212, 175, 55, 0.55);
  text-shadow: 0 0 3px #000, 1px 1px 0 #000;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.lbl.npc.focus .nm { border-color: var(--gold); box-shadow: 0 0 10px rgba(255, 209, 102, 0.55); }
.lbl .npc-role {
  display: flex; align-items: center; gap: 3px;
  padding: 1px 7px 1px 5px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600; line-height: 1.5; color: #1a0f0a;
  background: var(--role); border: 1px solid #000;
  box-shadow: 0 0 8px color-mix(in srgb, var(--role) 60%, transparent);
}
.lbl .npc-role svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.lbl .npc-talk {
  font-size: 11px; font-weight: 600; color: #fff8e1;
  padding: 2px 8px; border-radius: 4px; margin-bottom: 1px;
  background: rgba(110, 10, 10, 0.88); border: 1px solid var(--gold);
  animation: bob 1.2s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .lbl .npc-talk, .lbl .quest-mark { animation: none; } }
.lbl.mon .nm { color: #ffb4a2; }
.lbl.mon.boss .nm { color: #ff4d6d; font-weight: 600; font-size: 14px; }
.lbl .guild { font-size: 10px; color: var(--gold-soft); text-shadow: 0 0 3px #000; }
.lbl .mini { width: 46px; height: 5px; background: #200; border: 1px solid #000; }
.lbl .mini > b { display: block; height: 100%; background: var(--hp); }
.lbl .mini.sp > b { background: var(--sp); }
.lbl .mon-hp { width: 56px; height: 5px; background: #200; border: 1px solid #000; }
.lbl .mon-hp > b { display: block; height: 100%; background: #ff7b00; }
.lbl .quest-mark {
  font-size: 22px; font-weight: 600; color: #ffd60a;
  text-shadow: 0 0 6px #ff9e00, 0 0 2px #000;
  animation: bob 1.2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-5px); } }
.lbl .bubble {
  max-width: 220px; white-space: normal; text-align: center;
  background: rgba(255, 250, 235, 0.95); color: #1a0f0a;
  border: 2px solid var(--gold); border-radius: 10px;
  padding: 3px 8px; font-size: 12px; margin-bottom: 4px;
}
.lbl .vend {
  background: linear-gradient(#fff6d6, #f5d77a); color: #3b1d0a;
  border: 2px solid #8a5a12; border-radius: 4px;
  padding: 2px 8px; font-size: 11px; font-weight: 600; margin-bottom: 2px;
}

.float {
  position: absolute; left: 0; top: 0;
  font-weight: 600; font-size: 22px;
  color: #fff;
  -webkit-text-stroke: 1px #000;
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
  animation: floatUp 0.95s cubic-bezier(.2,.8,.3,1) forwards;
}
.float.player-hit { color: #ff4d4d; font-size: 20px; }
.float.crit { color: #ffd60a; font-size: 30px; }
.float.heal { color: #7bf1a8; }
.float.sp { color: #8ecae6; }
.float.miss { color: #ddd; font-size: 16px; }
.float.lvup { color: #ffd60a; font-size: 30px; animation-duration: 2s; }
.float.exp { color: #f7b801; font-size: 14px; }
@keyframes floatUp {
  0% { transform: translate(-50%, 0) scale(0.6); opacity: 0; }
  15% { transform: translate(-50%, -18px) scale(1.25); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), -70px) scale(1); opacity: 0; }
}

/* ---------- Window chrome (Thai lacquer + gold) ---------- */
.win {
  position: fixed;
  background: linear-gradient(180deg, rgba(36, 20, 15, 0.94), rgba(18, 10, 8, 0.94));
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(243, 217, 139, 0.15), 0 8px 24px rgba(0, 0, 0, 0.5);
}

.basic-info { left: 12px; top: 12px; width: 250px; padding: 10px 12px; }
.bi-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.bi-name { font-weight: 600; font-size: 16px; color: var(--gold-soft); }
.bi-class { font-size: 12px; color: var(--muted); }
.bi-lv { text-align: right; font-size: 12px; color: var(--muted); }
.bi-lv b { color: var(--text); font-size: 14px; }
.bi-foot { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--muted); }
.bi-foot b { color: var(--gold-soft); }
#bi-buffs { display: flex; gap: 4px; }
.buff-chip { background: #3a2410; border: 1px solid var(--gold); color: var(--gold-soft); border-radius: 4px; padding: 0 4px; font-size: 11px; }

.bar {
  position: relative; height: 15px; margin: 3px 0;
  background: #0b0605; border: 1px solid #000; border-radius: 3px; overflow: hidden;
}
.bar > span { display: block; height: 100%; width: 0; transition: width 0.15s; }
.bar.hp > span { background: linear-gradient(#ff6b6b, var(--hp) 60%, #9d0208); }
.bar.sp > span { background: linear-gradient(#73a9ff, var(--sp) 60%, #023e8a); }
.bar.exp > span { background: linear-gradient(#ffe066, var(--exp)); }
.bar.jexp > span { background: linear-gradient(#80ffdb, var(--jexp)); }
.bar em {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-style: normal; font-size: 11px; text-shadow: 1px 1px 0 #000;
}
.bar i { position: absolute; left: 5px; top: 0; font-style: normal; font-size: 10px; line-height: 15px; color: rgba(255,255,255,0.75); text-shadow: 1px 1px 0 #000; }
.bar.small { height: 10px; }

#zone-banner {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  font-size: 26px; font-weight: 600; color: var(--gold-soft);
  text-shadow: 0 0 10px #000, 2px 2px 0 #000;
  opacity: 0; transition: opacity 0.6s; pointer-events: none; text-align: center;
}
#zone-banner.show { opacity: 1; }
#zone-banner small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }
#announce {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(120, 10, 10, 0.85); border: 1px solid var(--gold); border-radius: 6px;
  padding: 4px 16px; color: #ffe066; font-weight: 600;
  opacity: 0; transition: opacity 0.4s; pointer-events: none; max-width: 70vw; text-align: center;
}
#announce.show { opacity: 1; }

.target-frame { top: 120px; left: 50%; transform: translateX(-50%); width: 240px; padding: 6px 10px; text-align: center; }
.tf-name { font-weight: 600; color: #ffb4a2; margin-bottom: 4px; }
.tf-name small { color: var(--muted); font-weight: 400; }

.minimap-wrap { right: 12px; top: 12px; padding: 6px; width: 194px; }
.mm-head, .mm-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 0 2px 4px; gap: 6px; }
.mm-head span:first-child { color: var(--gold-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-foot { padding: 4px 2px 0; }
#minimap { display: block; width: 180px; height: 180px; border: 1px solid #000; border-radius: 4px; cursor: pointer; image-rendering: auto; }

.menu-bar {
  position: fixed; right: 12px; top: 296px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; width: 194px;
}
.mi { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mi.sm { width: 14px; height: 14px; }
.mb-btn {
  --accent: var(--gold-soft);
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  aspect-ratio: 1; padding: 4px 2px 3px; cursor: pointer;
  background: radial-gradient(circle at 50% 30%, #3e2216, #170c09 75%); color: var(--accent);
  border: 1px solid #6b4a1d; border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.08), 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.mb-btn .mi { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 45%, transparent)); transition: transform 0.15s ease; }
.mb-label { font-size: 10px; line-height: 1; color: var(--muted); white-space: nowrap; }
.mb-btn kbd { position: absolute; top: 2px; right: 2px; font-size: 8.5px; line-height: 1.2; padding: 0 3px; border-color: rgba(107, 74, 29, 0.8); background: rgba(0, 0, 0, 0.45); }
.mb-btn:hover, .mb-btn:focus-visible { border-color: var(--accent); outline: none; transform: translateY(-1px); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent), 0 0 12px color-mix(in srgb, var(--accent) 35%, transparent); }
.mb-btn:hover .mi, .mb-btn:focus-visible .mi { transform: scale(1.1); }
.mb-btn:hover .mb-label, .mb-btn:focus-visible .mb-label { color: var(--text); }
.mb-btn:active { transform: translateY(0) scale(0.96); }
.mb-btn[aria-pressed='true'] { border-color: var(--accent); background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--accent) 28%, #2a160f), #170c09 80%); }
.mb-btn[aria-pressed='true'] .mb-label { color: var(--text); }
#btn-music .mi-slash { display: none; }
#btn-music[aria-pressed='false'] { color: var(--muted); }
#btn-music[aria-pressed='false'] .mi-slash { display: inline; stroke: #ff6b6b; }
#btn-music[aria-pressed='false'] .mi { filter: none; }
kbd { font-family: inherit; font-size: 10px; color: var(--muted); border: 1px solid #6b4a1d; border-radius: 3px; padding: 0 4px; }

.hotbar {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 6px;
  background: linear-gradient(180deg, rgba(36, 20, 15, 0.94), rgba(18, 10, 8, 0.94));
  border: 1px solid var(--gold); border-radius: var(--radius);
}
.slot {
  position: relative; width: 54px; height: 54px;
  background: radial-gradient(circle at 50% 35%, #4a2a18, #1a0e0a);
  border: 1px solid #7a5a22; border-radius: 6px;
  color: var(--text); cursor: pointer; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; overflow: hidden;
}
.slot:hover { border-color: var(--gold); }
.slot.locked { opacity: 0.4; }
.slot .key { position: absolute; top: 1px; left: 4px; font-size: 10px; color: var(--gold-soft); font-weight: 400; }
.slot .cnt { position: absolute; bottom: 1px; right: 4px; font-size: 10px; }
.slot .lv { position: absolute; bottom: 1px; left: 4px; font-size: 9px; color: var(--muted); font-weight: 400; }
.slot .sp-cost { position: absolute; top: 1px; right: 4px; font-size: 9px; color: #8ecae6; font-weight: 400; }
.slot .cd {
  position: absolute; inset: 0; background: rgba(0,0,0,0.65);
  transform-origin: bottom; transform: scaleY(0);
}
.slot .gem { width: 18px; height: 18px; transform: rotate(45deg); border: 1px solid #000; border-radius: 3px; }
.slot.sep { width: 2px; background: var(--gold); border: none; opacity: 0.4; cursor: default; }

.chat { left: 12px; bottom: 12px; width: min(420px, 40vw); display: flex; flex-direction: column; }
.chat-tabs { display: flex; gap: 2px; padding: 4px 6px 0; font-size: 11px; }
.chat-tabs span { padding: 1px 8px; border-radius: 4px 4px 0 0; color: var(--muted); }
.chat-tabs .active { background: rgba(212, 175, 55, 0.2); color: var(--gold-soft); }
.chat-log { height: 150px; overflow-y: auto; padding: 4px 8px; font-size: 12.5px; line-height: 1.45; scrollbar-width: thin; scrollbar-color: #6b4a1d transparent; }
.chat-log .sys { color: #ffe066; }
.chat-log .sys-good { color: #7bf1a8; }
.chat-log .sys-bad { color: #ff8fa3; }
.chat-log .me { color: #b7f7c1; }
.chat-log .g b { color: #bde0fe; font-weight: 600; }
.chat-log .ann { color: #ff9e00; font-weight: 600; }
.chat-tabs { align-items: center; }
.chat-toggle {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  background: linear-gradient(#3a1f14, #1f110c); color: var(--gold-soft);
  border: 1px solid #6b4a1d; border-radius: 4px; padding: 1px 8px; font: inherit; font-size: 11px; cursor: pointer;
}
.chat-toggle:hover, .chat-toggle:focus-visible { border-color: var(--gold); outline: none; }
.chat-toggle .chev { transition: transform 0.2s ease; }
.chat.collapsed .chat-toggle .chev { transform: rotate(180deg); }
.chat-unread { background: var(--red); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 10px; line-height: 15px; min-width: 16px; text-align: center; }
.chat.collapsed { width: auto; }
.chat.collapsed .chat-tabs { padding-bottom: 4px; }
.chat.collapsed .chat-tabs > span:not(:first-child) { display: none; }
.chat.collapsed .chat-body { display: none; }
.chat-body { border-top: 1px solid #4a3216; }
.chat-form { border-top: 1px solid #4a3216; }

.mm-expand {
  display: flex; justify-content: center; align-items: center; gap: 6px; width: 100%; margin-top: 6px;
  background: linear-gradient(#3a1f14, #1f110c); color: var(--text);
  border: 1px solid #6b4a1d; border-radius: 6px; padding: 4px 8px; cursor: pointer; font: inherit; font-size: 12px;
}
.mm-expand:hover, .mm-expand:focus-visible { border-color: var(--gold); color: var(--gold-soft); outline: none; }
.mode-chip { position: absolute; top: 2px; left: 2px; font-size: 8px; line-height: 1.3; color: var(--gold-soft); background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(212, 175, 55, 0.5); border-radius: 999px; padding: 0 4px; }
.switch-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; cursor: pointer; position: relative; }
.switch-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.switch-text b { font-size: 13px; color: var(--text); font-weight: 600; }
.switch-text small { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; flex: none; width: 38px; height: 20px; border-radius: 999px; background: #2a1a12; border: 1px solid #6b4a1d; transition: background 0.2s ease, border-color 0.2s ease; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform 0.2s ease, background 0.2s ease; }
.switch-row input:checked + .switch { background: rgba(212, 175, 55, 0.3); border-color: var(--gold); }
.switch-row input:checked + .switch::after { transform: translateX(18px); background: var(--gold-soft); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--gold-soft); outline-offset: 2px; }

.window.map { width: auto; max-height: 94vh; }
.map-body { display: flex; flex-direction: column; gap: 8px; align-items: center; }
#worldmap { display: block; width: min(560px, 72vh); height: auto; aspect-ratio: 1; border: 1px solid #000; border-radius: 6px; cursor: crosshair; }
.map-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: 12px; color: var(--text); }
.map-legend li { display: flex; align-items: center; gap: 5px; }
.map-legend .muted { color: var(--muted); flex-basis: 100%; justify-content: center; }
.map-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
.map-legend .lg-me { background: #fff; clip-path: polygon(50% 0, 100% 100%, 50% 75%, 0 100%); border-radius: 0; width: 11px; height: 11px; }
.map-legend .lg-npc { background: #ffe066; border-radius: 50%; }
.map-legend .lg-bot { background: #7cc6ff; }
.map-legend .lg-mon { background: #ff5a5a; width: 6px; height: 6px; }
.map-legend .lg-boss { background: #ff2a6d; border-radius: 50%; box-shadow: 0 0 0 1px #fff; }

.setting-group { border: 1px solid #4a3216; border-radius: 6px; padding: 8px 10px 10px; margin: 0 0 10px; }
.setting-group legend, .setting-group h3 { color: var(--gold-soft); font-size: 13px; font-weight: 600; padding: 0 4px; margin: 0; }
.setting-group h3 { padding: 0 0 6px; }
.mode-options { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.mode-opt { position: relative; display: block; cursor: pointer; }
.mode-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.mode-card { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 8px 34px; border: 1px solid #6b4a1d; border-radius: 6px; background: rgba(0, 0, 0, 0.3); position: relative; }
.mode-card::before { content: ''; position: absolute; left: 11px; top: 50%; width: 12px; height: 12px; margin-top: -7px; border: 1px solid var(--gold); border-radius: 50%; }
.mode-card b { color: var(--text); font-size: 13px; }
.mode-card small { color: var(--muted); font-size: 11.5px; }
.mode-opt input:checked + .mode-card { border-color: var(--gold); background: rgba(212, 175, 55, 0.14); }
.mode-opt input:checked + .mode-card::before { background: radial-gradient(circle, var(--gold-soft) 0 45%, transparent 50%); }
.mode-opt input:focus-visible + .mode-card { outline: 2px solid var(--gold-soft); outline-offset: 1px; }
.mode-help { margin: 8px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.keys-ref dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 12px; }
.keys-ref dt { color: var(--gold-soft); }
.keys-ref dd { margin: 0; color: var(--text); }
.chat-form input {
  width: 100%; border: 0; background: rgba(0,0,0,0.35); color: var(--text);
  padding: 7px 10px; font-size: 13px; outline: none; border-radius: 0 0 var(--radius) var(--radius);
}
.chat-form input:focus { background: rgba(0,0,0,0.6); }

.window { left: 50%; top: 50%; transform: translate(-50%, -50%); width: 340px; max-height: 78vh; display: flex; flex-direction: column; z-index: 10; }
.window.wide { width: 460px; }
.window.npc { width: 420px; top: auto; bottom: 200px; transform: translateX(-50%); }
.win-title {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; font-weight: 600; color: var(--gold-soft);
  background: linear-gradient(90deg, #7a1010, #3a0a0a 60%, #7a1010);
  border-bottom: 1px solid var(--gold); border-radius: var(--radius) var(--radius) 0 0;
  cursor: move;
}
.win-title .x { background: none; border: 1px solid var(--gold); color: var(--gold-soft); border-radius: 4px; width: 22px; height: 22px; line-height: 1; cursor: pointer; }
.win-body { padding: 10px 12px; overflow-y: auto; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 3px 0; border-bottom: 1px dashed #3a2a18; }
.stat-row b { color: var(--gold-soft); min-width: 34px; display: inline-block; }
.stat-row .cost { font-size: 11px; color: var(--muted); }
.plus { background: #2b5a1e; border: 1px solid #7bf1a8; color: #fff; border-radius: 4px; width: 22px; height: 22px; cursor: pointer; }
.plus:disabled { opacity: 0.3; cursor: default; }
.derived .stat-row span:last-child { color: var(--text); }
.pts { margin-top: 8px; text-align: center; color: var(--gold-soft); }

.skill-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed #3a2a18; }
.skill-row .slot { width: 48px; height: 48px; cursor: default; }
.skill-row h4 { margin: 0; font-size: 14px; color: var(--gold-soft); }
.skill-row p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.equip-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.equip { border: 1px solid #6b4a1d; border-radius: 6px; padding: 6px; font-size: 12px; min-height: 52px; cursor: pointer; background: rgba(0,0,0,0.25); }
.equip small { display: block; color: var(--muted); font-size: 10px; }
.equip:hover { border-color: var(--gold); }
.inv-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.inv-cell { position: relative; aspect-ratio: 1; border: 1px solid #6b4a1d; border-radius: 6px; background: radial-gradient(circle at 50% 35%, #3a2216, #140b08); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.inv-cell:hover { border-color: var(--gold); }
.inv-cell .gem { width: 20px; height: 20px; transform: rotate(45deg); border: 1px solid #000; border-radius: 3px; }
.item-ico { display: block; image-rendering: pixelated; object-fit: contain; pointer-events: none; user-select: none; filter: drop-shadow(1px 1px 0 #000) drop-shadow(0 0 3px color-mix(in srgb, var(--glow, transparent) 45%, transparent)); }
.inv-cell .item-ico { width: 88%; height: 88%; transition: transform 0.12s ease; }
.inv-cell:hover .item-ico, .inv-cell:focus-visible .item-ico { transform: scale(1.1) translateY(-1px); }
.slot .item-ico.gem { width: 30px; height: 30px; transform: none; border: 0; border-radius: 0; }
.shop-row .item-ico { width: 26px; height: 26px; }
.equip-item { display: inline-flex; align-items: center; gap: 6px; }
.equip-item .item-ico { width: 24px; height: 24px; flex: none; }
.inv-cell .cnt { position: absolute; right: 3px; bottom: 1px; font-size: 11px; text-shadow: 1px 1px 0 #000; }
.inv-cell .tag { position: absolute; left: 3px; top: 1px; font-size: 9px; color: var(--muted); }
.inv-foot { margin-top: 8px; display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

.quest-card { border: 1px solid #6b4a1d; border-radius: 6px; padding: 8px 10px; background: rgba(0,0,0,0.25); }
.quest-card h4 { margin: 0 0 4px; color: var(--gold-soft); }
.quest-card p { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.progress { height: 8px; background: #0b0605; border-radius: 4px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--exp); }

.npc-text { line-height: 1.6; min-height: 60px; white-space: pre-line; }
.npc-text b { color: var(--gold-soft); }
.npc-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.npc-actions button, .shop-btn {
  background: linear-gradient(#3a1f14, #1f110c); color: var(--text);
  border: 1px solid #6b4a1d; border-radius: 6px; padding: 6px 10px; cursor: pointer; text-align: left; font-size: 13px;
}
.npc-actions button:hover, .shop-btn:hover { border-color: var(--gold); color: var(--gold-soft); }
.shop-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.shop-tabs button { flex: 1; text-align: center; }
.shop-tabs button.active { border-color: var(--gold); color: var(--gold-soft); background: #4a2412; }
.shop-row { display: grid; grid-template-columns: 26px 1fr auto auto; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px dashed #3a2a18; font-size: 13px; }
.shop-row .gem { width: 14px; height: 14px; transform: rotate(45deg); border: 1px solid #000; border-radius: 2px; margin-left: 4px; }
.shop-row small { display: block; color: var(--muted); font-size: 11px; }
.shop-row .price { color: var(--gold-soft); }
.shop-btn { padding: 3px 8px; text-align: center; font-size: 12px; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 240px;
  background: rgba(10, 6, 4, 0.96); border: 1px solid var(--gold); border-radius: 6px; padding: 6px 9px; font-size: 12px;
}
.tooltip b { color: var(--gold-soft); display: block; }
.tooltip span { color: var(--muted); }

.tooltip.item-tip {
  display: flex; gap: 12px; align-items: flex-start; width: 320px; max-width: calc(100vw - 16px); padding: 12px;
  background: linear-gradient(160deg, rgba(36, 20, 13, 0.98), rgba(10, 6, 4, 0.98));
  border-color: #8a6a2a; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 220, 160, 0.08);
  animation: tip-pop 0.14s ease-out both;
}
.tooltip.item-tip[hidden] { display: none; }
.ic-art {
  position: relative; flex: none; width: 104px; height: 104px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--glow) 32%, #2a170f), #0d0705 72%);
  border: 1px solid color-mix(in srgb, var(--glow) 55%, #6b4a1d);
  box-shadow: inset 0 0 22px color-mix(in srgb, var(--glow) 22%, transparent);
}
.ic-art .item-ico { width: 84px; height: 84px; filter: drop-shadow(2px 2px 0 #000) drop-shadow(0 0 8px color-mix(in srgb, var(--glow) 60%, transparent)); }
.ic-art .ref-badge { top: 5px; right: 6px; font-size: 16px; }
.ic-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.tooltip .ic-type { font-size: 10.5px; letter-spacing: 0.04em; color: var(--muted); text-transform: uppercase; }
.ic-type em { color: #7bf1a8; font-style: normal; }
.tooltip b.ic-name { font-size: 15px; line-height: 1.25; text-shadow: 1px 1px 0 #000; }
.ic-stats { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 0; }
.ic-stats div { display: flex; gap: 4px; align-items: baseline; padding: 1px 7px; border-radius: 999px; background: rgba(0, 0, 0, 0.4); border: 1px solid #3a2a18; }
.ic-stats dt { font-size: 10px; color: var(--muted); }
.ic-stats dd { margin: 0; font-size: 12px; font-weight: 700; color: #7bf1a8; font-variant-numeric: tabular-nums; }
.ic-desc { margin: 2px 0 0; font-size: 12px; line-height: 1.45; color: var(--text); }
.ic-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; padding-top: 6px; border-top: 1px dashed #3a2a18; font-size: 11px; }
.tooltip .ic-foot span { color: var(--muted); }
.tooltip .ic-foot b { display: inline; color: var(--gold-soft); }
.ic-hint { margin: 2px 0 0; font-size: 10.5px; color: var(--gold-soft); opacity: 0.8; }
@keyframes tip-pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
.shop-ico, .tip-ico { position: relative; display: inline-flex; cursor: help; }
[data-tip] .item-ico { pointer-events: none; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(0,0,0,0.75); border: 1px solid var(--gold); color: var(--gold-soft);
  border-radius: 6px; padding: 5px 14px; opacity: 0; transition: opacity 0.25s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ---------- Screens ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 100; }
#title-screen {
  background:
    radial-gradient(ellipse at 50% 120%, rgba(232, 120, 40, 0.35), transparent 60%),
    linear-gradient(180deg, rgba(10, 5, 8, 0.55), rgba(10, 5, 4, 0.92));
  overflow-y: auto; padding: 20px;
}
.title-wrap { width: min(760px, 100%); text-align: center; }
.title-kicker { margin: 0; letter-spacing: 0.3em; font-size: 12px; color: var(--muted); }
.game-title {
  margin: 0; font-size: clamp(56px, 11vw, 112px); line-height: 1; font-weight: 600;
  color: var(--gold-soft);
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.35), 4px 4px 0 #3a0a0a;
}
.game-title span { color: #e5383b; text-shadow: 0 0 24px rgba(229, 56, 59, 0.6), 4px 4px 0 #1a0505; }
.title-sub { margin: 4px 0 18px; letter-spacing: 0.35em; color: var(--muted); font-size: 13px; }
.panel {
  background: linear-gradient(180deg, rgba(36, 20, 15, 0.95), rgba(18, 10, 8, 0.95));
  border: 1px solid var(--gold); border-radius: 12px; padding: 18px; text-align: left;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.server-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 12px; flex-wrap: wrap; }
.server-row .dot { width: 8px; height: 8px; border-radius: 50%; background: #2ecc71; box-shadow: 0 0 8px #2ecc71; }
.muted { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field span { font-size: 13px; color: var(--muted); }
.field input {
  background: rgba(0,0,0,0.4); border: 1px solid #6b4a1d; border-radius: 6px; color: var(--text);
  padding: 9px 12px; font-size: 15px; outline: none;
}
.field input:focus { border-color: var(--gold); }
.class-pick { border: 0; padding: 0; margin: 0 0 14px; }
.class-pick legend { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.class-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.class-card {
  border: 1px solid #6b4a1d; border-radius: 10px; padding: 12px; cursor: pointer; text-align: left;
  background: rgba(0,0,0,0.3); color: var(--text); display: flex; flex-direction: column; gap: 4px;
}
.class-card:hover { border-color: var(--gold); }
.class-card[aria-pressed='true'] { border-color: var(--gold); background: rgba(185, 28, 28, 0.25); box-shadow: inset 0 0 0 1px var(--gold); }
.class-card h3 { margin: 0; font-size: 16px; color: var(--gold-soft); }
.class-card .en { font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }
.class-card p { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.class-card .stats { font-size: 11px; color: var(--text); opacity: 0.85; }
.title-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.btn { border-radius: 8px; padding: 10px 20px; font-size: 15px; cursor: pointer; font-weight: 600; }
.btn.primary { background: linear-gradient(#d62828, #8b0d0d); color: #fff8e1; border: 1px solid var(--gold); }
.btn.primary:hover { filter: brightness(1.15); }
.btn.ghost { background: transparent; color: var(--gold-soft); border: 1px solid var(--gold); }
.hint { margin: 12px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Online: server status, account, character ---------- */
.server-row .dot[data-state='wait'] { background: var(--exp); box-shadow: 0 0 8px var(--exp); animation: dot-pulse 1s ease-in-out infinite; }
.server-row .dot[data-state='off'] { background: #7a6a58; box-shadow: none; }
@keyframes dot-pulse { 50% { opacity: 0.35; } }
.net-status { margin: 0 0 12px; padding: 8px 12px; border-radius: 6px; font-size: 13px; line-height: 1.5; border: 1px solid #6b4a1d; background: rgba(0,0,0,0.35); color: var(--text); }
.net-status[data-kind='busy'] { color: var(--gold-soft); }
.net-status[data-kind='bad'] { border-color: rgba(229, 56, 59, 0.6); color: #ffb4a2; }
.auth-box, .char-box { display: flex; flex-direction: column; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid #4a3018; }
.auth-tab {
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--muted); font-size: 14px; font-weight: 600; padding: 8px 12px; cursor: pointer;
}
.auth-tab:hover { color: var(--text); }
.auth-tab[aria-selected='true'] { color: var(--gold-soft); border-bottom-color: var(--gold); }
.auth-form { display: flex; flex-direction: column; }
.form-msg { margin: 0 0 10px; min-height: 1.5em; font-size: 13px; line-height: 1.5; color: #ff8fa3; }
.dev-note { margin: 0 0 10px; font-size: 12px; color: var(--jexp); }
.account-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13px; color: var(--muted); padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid #4a3018;
}
.account-row b { color: var(--text); }
.char-existing {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; margin-bottom: 12px;
  border: 1px solid var(--gold); border-radius: 10px; background: rgba(185, 28, 28, 0.18);
}
.char-existing-kicker { font-size: 11px; letter-spacing: 0.12em; color: var(--muted); }
.char-existing b { font-size: 22px; color: var(--gold-soft); }
.btn:disabled { opacity: 0.55; cursor: wait; filter: none; }
.link-btn {
  background: none; border: 0; padding: 4px 2px; font-size: 13px; color: var(--muted);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.link-btn:hover { color: var(--gold-soft); }
.title-foot { display: flex; align-items: center; justify-content: center; gap: 8px 18px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid #3a2414; }
.title-foot .btn { padding: 7px 14px; font-size: 13px; }

.net-banner {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px;
  background: rgba(20, 8, 6, 0.92); border: 1px solid rgba(229, 56, 59, 0.7); color: #ffd6cc;
  font-size: 13px; pointer-events: none; box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
.net-banner .spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #ffd6cc; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.kick { background: rgba(10, 4, 4, 0.82); z-index: 200; }
.kick .panel { text-align: center; max-width: 420px; }
.kick h2 { margin: 0 0 8px; color: var(--gold-soft); }
.kick p { margin: 0 0 16px; color: var(--text); line-height: 1.6; }

.death { background: rgba(40, 0, 0, 0.55); backdrop-filter: grayscale(0.8); }
.death .panel { text-align: center; }
.death h2 { margin: 0 0 8px; color: #ff8fa3; }

@media (max-width: 760px) {
  .basic-info { width: 200px; padding: 8px; }
  .minimap-wrap { width: 130px; }
  #minimap { width: 118px; height: 118px; }
  .menu-bar { top: 236px; width: 130px; gap: 4px; }
  .mm-expand kbd, .menu-bar .mode-chip, .mb-btn kbd, .mb-label { display: none; }
  .window.map canvas { width: min(88vw, 70vh); height: auto; }
  .mi { width: 18px; height: 18px; }
  .mi.sm { width: 12px; height: 12px; }
  .chat { width: 46vw; }
  .chat-log { height: 90px; }
  .slot { width: 42px; height: 42px; font-size: 11px; }
  .hotbar { bottom: 8px; left: auto; right: 8px; transform: none; flex-wrap: wrap; width: 196px; }
  .class-list { grid-template-columns: 1fr; }
}

/* ---------- Cinematic ---------- */
.cine { position: fixed; inset: 0; z-index: 90; overflow: hidden; cursor: pointer; opacity: 0; transition: opacity 0.8s ease; pointer-events: none; }
.cine.on { opacity: 1; pointer-events: auto; }
.cine-fade { position: absolute; inset: 0; background: #000; opacity: 1; z-index: 1; }
.cine-vignette { position: absolute; inset: 0; z-index: 1; background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55) 100%); }
.cine-grain {
  position: absolute; inset: -50%; z-index: 1; opacity: 0.07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: cine-grain 0.5s steps(4) infinite;
}
@keyframes cine-grain { 0% { transform: translate(0, 0); } 25% { transform: translate(-3%, 2%); } 50% { transform: translate(2%, -3%); } 75% { transform: translate(-2%, -1%); } 100% { transform: translate(0, 0); } }
.cine-bar { position: absolute; left: 0; right: 0; height: 12vh; background: #000; z-index: 2; transition: transform 1s cubic-bezier(0.7, 0, 0.2, 1); }
.cine-bar.top { top: 0; transform: translateY(-100%); }
.cine-bar.bottom { bottom: 0; transform: translateY(100%); }
.cine.on .cine-bar { transform: translateY(0); }
.cine-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(212, 175, 55, 0.15); }
.cine-progress span { display: block; height: 100%; background: linear-gradient(90deg, #8b6914, var(--gold)); transform-origin: left; transform: scaleX(0); }

.cine-sub {
  position: absolute; left: 50%; bottom: 0; z-index: 3; transform: translateX(-50%);
  width: min(880px, 90vw); height: 12vh; display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; opacity: 0; transition: opacity 0.35s;
}
.cine-sub.show { opacity: 1; }
.cine-sub b { color: var(--gold); font-size: 13px; letter-spacing: 0.12em; margin-bottom: 2px; }
.cine-sub p { margin: 0; font-size: clamp(15px, 1.6vw, 20px); line-height: 1.5; color: #fff6e6; text-shadow: 0 1px 2px #000; min-height: 1.5em; text-wrap: balance; }
.cine-sub.narration p { color: #e8dcc6; }

.cine-title {
  position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px;
}
.cine-title small { color: var(--gold); letter-spacing: 0.1em; font-size: 13px; opacity: 0; transform: translateY(8px); transition: all 1s 0.2s; }
.cine-title strong { font-size: clamp(44px, 7vw, 88px); font-weight: 600; line-height: 1.1; color: #fff1d6; letter-spacing: 0.02em; opacity: 0; filter: blur(8px); transform: scale(1.06); transition: all 1.6s cubic-bezier(0.2, 0.7, 0.2, 1) 0.4s; text-shadow: 0 0 40px rgba(212, 60, 30, 0.45); }
.cine-title span { color: var(--muted); font-size: 15px; letter-spacing: 0.08em; opacity: 0; transition: opacity 1s 1.2s; }
.cine-title.show small, .cine-title.show span { opacity: 1; transform: none; }
.cine-title.show strong { opacity: 1; filter: none; transform: none; }

.cine-card {
  position: absolute; left: 6vw; bottom: calc(12vh + 28px); z-index: 3; display: flex; flex-direction: column;
  padding-left: 14px; border-left: 2px solid var(--gold);
}
.cine-card small { color: var(--gold); font-size: 12px; letter-spacing: 0.06em; }
.cine-card strong { font-size: clamp(22px, 2.6vw, 32px); font-weight: 600; color: #fff6e6; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8); line-height: 1.2; }
.cine-card span { color: #d9c9ab; font-size: 13px; text-shadow: 0 1px 4px #000; }
.cine-card > * { opacity: 0; transform: translateX(-14px); transition: all 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
.cine-card.show > * { opacity: 1; transform: none; }
.cine-card.show strong { transition-delay: 0.15s; }
.cine-card.show span { transition-delay: 0.3s; }
.cine-card { clip-path: inset(0 100% 0 0); transition: clip-path 0.8s cubic-bezier(0.7, 0, 0.2, 1); }
.cine-card.show { clip-path: inset(0 0 0 0); }

.cine-hero {
  position: absolute; right: 6vw; top: calc(12vh + 6vh); z-index: 3; display: flex; flex-direction: column; align-items: flex-end; text-align: right;
}
.cine-hero small { color: var(--gold-soft); font-size: 13px; letter-spacing: 0.08em; opacity: 0; transition: opacity 0.8s 0.5s; }
.cine-hero strong {
  font-size: clamp(36px, 5vw, 64px); font-weight: 600; line-height: 1.1; color: #fff; letter-spacing: 0.01em;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.9), 0 0 2px #000;
  opacity: 0; transform: translateX(40px) skewX(-8deg); transition: all 0.6s cubic-bezier(0.1, 0.9, 0.2, 1);
}
.cine-hero span {
  margin-top: 6px; padding: 3px 12px; background: linear-gradient(90deg, transparent, rgba(185, 28, 28, 0.85)); color: #ffe9c2; font-size: 13px; letter-spacing: 0.1em;
  opacity: 0; transition: opacity 0.6s 0.3s;
}
.cine-hero.show small, .cine-hero.show span { opacity: 1; }
.cine-hero.show strong { opacity: 1; transform: none; }

.cine-skip {
  position: absolute; top: calc(6vh - 16px); right: 24px; z-index: 4;
  display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.5); color: var(--gold-soft); border: 1px solid rgba(212, 175, 55, 0.5); font-size: 13px; cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.cine-skip:hover, .cine-skip:focus-visible { background: rgba(185, 28, 28, 0.6); border-color: var(--gold); outline: none; }
.cine-hint { position: absolute; top: calc(6vh - 9px); left: 24px; margin: 0; z-index: 4; font-size: 12px; color: rgba(185, 168, 140, 0.75); }
.cine.black .cine-vignette { opacity: 0; }

/* ---------- Tutorial ---------- */
.tut { left: 12px; top: 186px; width: 290px; padding: 10px 12px 10px; z-index: 6; }
.tut.enter { animation: tut-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes tut-in { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
.tut-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.tut-kicker { font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }
.tut-kicker b { color: var(--gold); font-weight: 600; }
.tut-dots { display: flex; gap: 4px; }
.tut-dots i { width: 14px; height: 4px; border-radius: 2px; background: #4a3216; transition: background 0.3s; }
.tut-dots i.cur { background: var(--gold); }
.tut-dots i.done { background: #4caf7a; }
.tut-title { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: var(--gold-soft); display: flex; align-items: center; gap: 6px; }
.tut.step-done .tut-title::after { content: ''; width: 16px; height: 16px; border-radius: 50%; background: #4caf7a url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>") center/12px no-repeat; animation: tut-pop 0.35s; }
@keyframes tut-pop { from { transform: scale(0); } 70% { transform: scale(1.25); } to { transform: scale(1); } }
.tut.step-done { border-color: #4caf7a; }
.tut-body { margin: 0; font-size: 13px; line-height: 1.55; color: var(--text); }
.tut-body b { color: var(--gold-soft); font-weight: 600; }
.tut-body kbd { font-size: 11px; color: var(--gold-soft); border-color: var(--gold); background: rgba(212, 175, 55, 0.12); padding: 0 5px; }
.tut-q { display: inline-block; color: #1a1006 !important; background: #ffd23f; border-radius: 3px; padding: 0 5px; }
.tut-check { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
.tut-check:empty { display: none; }
.tut-check li { display: flex; align-items: center; gap: 6px; }
.tut-check li > span[aria-hidden] { width: 12px; height: 12px; border: 1px solid #6b4a1d; border-radius: 3px; flex: none; }
.tut-check li.ok { color: #7bf1a8; }
.tut-check li.ok > span[aria-hidden] { background: #4caf7a; border-color: #4caf7a; }
.tut-foot { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; font-size: 11.5px; }
.tut-meta { color: var(--gold); font-weight: 600; }
.tut-meta:empty { display: none; }
.tut-hint { color: var(--muted); }
.tut-actions { display: flex; gap: 6px; margin-top: 8px; justify-content: flex-end; }
.tut-actions button, .tut-settings button {
  background: transparent; border: 1px solid #6b4a1d; color: var(--muted); border-radius: 5px; padding: 3px 9px; font-size: 11.5px; cursor: pointer;
}
.tut-actions button:hover, .tut-settings button:hover { color: var(--gold-soft); border-color: var(--gold); }
.tut-actions button.primary { background: linear-gradient(#d62828, #8b0d0d); color: #fff8e1; border-color: var(--gold); padding: 5px 14px; font-size: 13px; font-weight: 600; }
.tut.finished #tut-skip-step, .tut.finished #tut-skip-all { display: none; }
.tut.finished { border-color: var(--gold); box-shadow: 0 0 0 1px #000, 0 0 24px rgba(212, 175, 55, 0.35); }
.tut-settings { display: flex; flex-wrap: wrap; gap: 6px; }
.tut-settings button { font-size: 12.5px; padding: 5px 10px; color: var(--text); }

.tut-pulse { position: relative; animation: tut-pulse 1.2s ease-in-out infinite; z-index: 7; }
@keyframes tut-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 209, 102, 0.9), 0 0 0 1px var(--gold); } 50% { box-shadow: 0 0 0 6px rgba(255, 209, 102, 0), 0 0 14px 2px rgba(255, 209, 102, 0.6); } }

.tut-arrow { position: fixed; left: 0; top: 0; z-index: 5; pointer-events: none; width: 0; height: 0; }
.tut-arrow span {
  position: absolute; left: -16px; top: -16px; width: 32px; height: 32px; display: block;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><path d='M28 16 8 5l4 11-4 11z' fill='%23ffd166' stroke='%23000' stroke-width='1.5' stroke-linejoin='round'/></svg>") center/contain no-repeat;
  filter: drop-shadow(0 0 6px rgba(255, 209, 102, 0.8));
  animation: tut-arrow-bob 0.9s ease-in-out infinite;
}
@keyframes tut-arrow-bob { 50% { opacity: 0.6; } }
.tut-arrow em { position: absolute; left: -30px; top: 18px; width: 60px; text-align: center; font-style: normal; font-size: 11px; font-weight: 600; color: var(--gold-soft); text-shadow: 0 1px 2px #000, 0 0 4px #000; }

@media (max-width: 760px) {
  .tut { top: auto; bottom: 160px; width: min(290px, 60vw); }
  .cine-hint { display: none; }
  .cine-hero { right: 5vw; }
}
@media (prefers-reduced-motion: reduce) {
  .cine-grain, .tut-pulse, .tut-arrow span { animation: none; }
}

/* ---------------- skill icons ---------------- */
.skill-slot { isolation: isolate; }
.skill-slot .skill-ico-wrap { position: absolute; inset: 0; z-index: -1; }
.skill-slot .skill-ico { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; user-select: none; }
.skill-slot .cd { z-index: 1; }
.skill-slot .key, .skill-slot .sp-cost, .skill-slot .lv { z-index: 2; text-shadow: 0 0 2px #000, 1px 1px 0 #000; }
.skill-slot .lv { color: var(--text); }
.skill-slot::after { content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.6), inset 0 -14px 12px -8px rgba(0,0,0,0.75), inset 0 12px 10px -8px rgba(0,0,0,0.6); }
.skill-slot.locked { opacity: 1; filter: grayscale(1) brightness(0.45); }
.skill-row .skill-slot .skill-ico { z-index: -1; }

/* ---------------- refine badge ---------------- */
.ref-badge { position: absolute; top: 2px; right: 3px; font-size: 11px; font-weight: 700; color: #9be7ff; text-shadow: 0 0 3px #000, 1px 1px 0 #000; line-height: 1; }
.ref-badge.hi { color: #ffd166; text-shadow: 0 0 6px rgba(255, 170, 0, 0.8), 1px 1px 0 #000; }

/* ---------------- forge window ---------------- */
.window.forge { width: min(680px, 96vw); max-height: 86vh; }
.forge-zeny { margin-left: auto; align-self: center; font-size: 12px; color: var(--muted); }
.forge-zeny b { color: var(--gold-soft); }
.forge-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 12px; margin-top: 8px; }
.forge-col { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.forge-col h4, .recipe-head { margin: 0; font-size: 13px; color: var(--gold-soft); font-weight: 600; }
.recipe-head { margin-top: 14px; padding-top: 10px; border-top: 1px dashed #3a2a18; }
.forge-hint { margin: 0; font-size: 11px; color: var(--muted); }
.forge-empty { font-size: 12px; margin: 6px 0; }
.forge-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 5px; align-content: start; max-height: 220px; overflow-y: auto; padding: 2px; }
.forge-cell { position: relative; aspect-ratio: 1; border: 1px solid #6b4a1d; border-radius: 6px; background: radial-gradient(circle at 50% 35%, #3a2216, #140b08); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; color: var(--text); }
.forge-cell:hover, .forge-cell:focus-visible { border-color: var(--gold); outline: none; }
.forge-cell.active { border-color: var(--gold-soft); box-shadow: 0 0 0 1px var(--gold), 0 0 10px rgba(212, 175, 55, 0.45); }
.forge-cell.empty { opacity: 0.35; }
.forge-cell .item-ico { width: 86%; height: 86%; }
.forge-cell .cnt { position: absolute; right: 3px; bottom: 1px; font-size: 11px; text-shadow: 1px 1px 0 #000; }
.forge-cell .worn { position: absolute; left: 2px; bottom: 1px; font-size: 9px; color: #7bf1a8; text-shadow: 1px 1px 0 #000; }
.forge-cell.in-pool { background: radial-gradient(circle at 50% 40%, #5a3a12, #1a0e0a); border-color: #a8782a; }
.pool { min-height: 64px; display: flex; flex-wrap: wrap; gap: 5px; padding: 8px; border: 1px dashed #a8782a; border-radius: 10px; background: radial-gradient(ellipse at 50% 120%, rgba(255, 140, 40, 0.18), rgba(0, 0, 0, 0.35) 70%); align-items: center; }
.pool .forge-cell { width: 48px; }
.pool-hint { margin: 0 auto; font-size: 12px; color: var(--muted); text-align: center; }
.craft-preview { border: 1px solid #3a2a18; border-radius: 8px; padding: 8px; background: rgba(0, 0, 0, 0.25); }
.no-recipe { margin: 4px 0; text-align: center; font-size: 13px; }
.no-recipe small { font-size: 11px; color: var(--muted); }
.craft-out, .refine-head { display: flex; align-items: center; gap: 8px; }
.out-ico { position: relative; width: 44px; height: 44px; flex: none; border: 1px solid #6b4a1d; border-radius: 6px; background: radial-gradient(circle at 50% 35%, #3a2216, #140b08); display: flex; align-items: center; justify-content: center; }
.out-ico.big { width: 56px; height: 56px; }
.out-ico .item-ico { width: 80%; height: 80%; }
.out-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.out-info b { font-size: 14px; }
.out-info small { font-size: 11px; color: var(--muted); }
.chance { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; }
.chance b { font-size: 26px; font-variant-numeric: tabular-nums; }
.chance small { font-size: 10px; color: var(--muted); }
.chance.good b { color: #7bf1a8; } .chance.mid b { color: #ffd166; } .chance.low b { color: #ff6b6b; }
.chance-track { height: 6px; border-radius: 3px; background: #1a0e0a; margin: 6px 0; overflow: hidden; border: 1px solid #3a2a18; }
.chance-track span { display: block; height: 100%; transition: width 0.25s ease; }
.chance-track.good span { background: linear-gradient(90deg, #2d9d6a, #7bf1a8); } .chance-track.mid span { background: linear-gradient(90deg, #c08a1e, #ffd166); } .chance-track.low span { background: linear-gradient(90deg, #8b1e1e, #ff6b6b); }
.mat-bars { display: flex; flex-direction: column; gap: 3px; }
.mat-bar { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: center; font-size: 11px; }
.mat-bar .track { height: 4px; background: #1a0e0a; border-radius: 2px; overflow: hidden; }
.mat-bar .track b { display: block; height: 100%; background: var(--gold); }
.mat-bar .num { color: var(--muted); font-variant-numeric: tabular-nums; }
.forge-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 2px; }
.forge-go { background: linear-gradient(#c0392b, #7a1a12); color: #fff3d6; border: 1px solid var(--gold); border-radius: 6px; padding: 6px 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; }
.forge-go:hover:not(:disabled), .forge-go:focus-visible { filter: brightness(1.15); outline: none; }
.forge-go:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(0.6); }
.forge-result { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; animation: forge-pop 0.45s ease; }
.forge-result .item-ico { width: 32px; height: 32px; }
.forge-result div { display: flex; flex-direction: column; }
.forge-result b { font-size: 14px; }
.forge-result small { font-size: 11px; color: var(--muted); }
.forge-result.ok { background: rgba(123, 241, 168, 0.12); border: 1px solid #2d9d6a; }
.forge-result.ok b { color: #7bf1a8; }
.forge-result.fail { background: rgba(255, 80, 80, 0.12); border: 1px solid #8b1e1e; animation: forge-shake 0.4s ease; }
.forge-result.fail b { color: #ff6b6b; }
@keyframes forge-pop { 0% { transform: scale(0.85); opacity: 0; } 60% { transform: scale(1.04); opacity: 1; } 100% { transform: scale(1); } }
@keyframes forge-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.recipe-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.recipe-row { display: grid; grid-template-columns: minmax(150px, 1.1fr) 1.4fr auto; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.2); border: 1px solid #2a1c10; }
.recipe-out { display: flex; align-items: center; gap: 6px; min-width: 0; }
.recipe-out .item-ico { width: 30px; height: 30px; flex: none; }
.recipe-out span { display: flex; flex-direction: column; min-width: 0; font-size: 12px; }
.recipe-out small { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipe-mats { display: flex; flex-wrap: wrap; gap: 4px; }
.mat-chip { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; padding: 1px 5px 1px 2px; border-radius: 999px; background: #1a0e0a; border: 1px solid #3a2a18; font-variant-numeric: tabular-nums; }
.mat-chip .item-ico { width: 18px; height: 18px; }
.mat-chip.full { border-color: #2d9d6a; color: #7bf1a8; }
.mat-chip.none { color: #ff6b6b; opacity: 0.7; }
.shop-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.refine-stats { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; margin: 8px 0 4px; padding: 6px; border-radius: 6px; background: #1a0e0a; }
.refine-stats .arrow { color: var(--gold); }
.refine-stats .next { color: #7bf1a8; font-weight: 600; }
.refine-req { list-style: none; margin: 4px 0; padding: 0; font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.refine-req li::before { content: '•'; margin-right: 6px; }
.refine-req .ok { color: var(--text); } .refine-req .ok::before { color: #7bf1a8; }
.refine-req .bad { color: #ff6b6b; }
.refine-req .warn { color: #ffb38a; font-size: 11px; }
.refine-req small { color: var(--muted); }
.ladder { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; height: 92px; margin-top: 6px; }
.rung { position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; border-radius: 4px; background: rgba(0, 0, 0, 0.25); padding: 2px 0; }
.rung .bar { width: 60%; border-radius: 3px 3px 0 0; margin-bottom: 2px; max-height: 56px; }
.rung .bar.good { background: #2d9d6a; } .rung .bar.mid { background: #c08a1e; } .rung .bar.low { background: #a83232; }
.rung small { font-size: 11px; color: var(--gold-soft); font-weight: 600; }
.rung em { font-style: normal; font-size: 10px; color: var(--muted); }
.rung.done { opacity: 0.45; }
.rung.cur { outline: 1px solid var(--gold-soft); background: rgba(212, 175, 55, 0.15); }
@media (max-width: 640px) {
  .forge-grid { grid-template-columns: 1fr; }
  .recipe-row { grid-template-columns: 1fr; }
}

/* ---------------- forge animations ---------------- */
.forge-fx {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(ellipse at 50% 45%, rgb(56, 24, 12), rgb(12, 6, 4) 70%);
  border-radius: 0 0 var(--radius) var(--radius); cursor: pointer;
  animation: fx-in 0.25s ease both;
}
.forge-fx.out { animation: fx-out 0.26s ease both; }
.fx-stage { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.fx-label { margin: 0; text-align: center; font-size: 15px; font-weight: 600; color: var(--gold-soft); transition: opacity 0.25s ease; }
.fx-label small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.fx-dots::after { content: '...'; display: inline-block; width: 1.2em; text-align: left; overflow: hidden; vertical-align: bottom; animation: fx-dots 0.9s steps(4) infinite; }
.fx-skip { position: absolute; bottom: 8px; margin: 0; font-size: 11px; color: var(--muted); opacity: 0.8; }
.forge-fx.is-ok .fx-label, .forge-fx.is-fail .fx-label { opacity: 0; }

/* craft: alchemy circle */
.fx-circle { position: relative; width: 200px; height: 200px; transition: opacity 0.3s ease, transform 0.3s ease; }
.fx-ring { position: absolute; inset: 10px; border-radius: 50%; border: 2px dashed rgba(243, 217, 139, 0.65); box-shadow: 0 0 18px rgba(255, 150, 40, 0.35), inset 0 0 18px rgba(255, 150, 40, 0.3); animation: fx-spin 6s linear infinite; }
.fx-ring.r2 { inset: 38px; border: 1px solid rgba(255, 170, 60, 0.8); border-top-color: transparent; border-bottom-color: transparent; animation-duration: 1.6s; animation-direction: reverse; }
.fx-core { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: radial-gradient(circle, #fff3c4 0, #ffb347 35%, rgba(255, 90, 20, 0.5) 60%, transparent 72%); animation: fx-pulse 0.7s ease-in-out infinite alternate; }
.fx-circle.fuse .fx-core { animation: fx-fuse 0.6s ease-out forwards; }
.fx-circle.fuse .fx-ring { animation-duration: 0.8s; border-color: #ffe08a; }
.fx-mat { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; animation: fx-orbit 1.45s cubic-bezier(0.55, 0, 0.75, 0.4) var(--d) both; }
.fx-mat .item-ico { width: 100%; height: 100%; filter: drop-shadow(0 0 6px rgba(255, 180, 80, 0.8)); }

/* refine: anvil + hammer */
.fx-anvil-scene { --heat: 0; position: relative; width: 260px; height: 190px; transition: opacity 0.3s ease; }
.fx-glow { position: absolute; left: 70px; bottom: 50px; width: 96px; height: 96px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 170, 60, calc(0.25 + var(--heat) * 0.5)), transparent 70%); transition: background 0.2s ease; }
.fx-anvil { position: absolute; left: 55px; bottom: 0; width: 150px; height: 75px; fill: #2b2522; stroke: #8a6a3a; stroke-width: 1.5; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.6)); }
.fx-item.on-anvil { position: absolute; left: 90px; bottom: 68px; width: 56px; height: 56px; }
.fx-item.on-anvil .item-ico { width: 100%; height: 100%; filter: drop-shadow(0 0 calc(4px + var(--heat) * 10px) rgba(255, 140, 40, calc(0.4 + var(--heat) * 0.6))); }
.fx-item.on-anvil.struck { animation: fx-struck 0.22s ease-out; }
.fx-hammer { position: absolute; left: 210px; bottom: 100px; width: 10px; height: 100px; margin-left: -5px; transform-origin: 50% 100%; transform: rotate(35deg); animation: fx-hammer 0.5s ease-in-out 3 both; transition: opacity 0.25s ease; }
.fx-handle { position: absolute; inset: 14px 1px 0; border-radius: 3px; background: linear-gradient(90deg, #5a3417, #a0682f 50%, #5a3417); box-shadow: 0 0 0 1px #2a170b; }
.fx-head { position: absolute; top: 0; left: 50%; width: 48px; height: 24px; margin-left: -24px; border-radius: 4px; background: linear-gradient(#d9d4cc, #8b8780 45%, #4b4844); box-shadow: 0 0 0 1px #1d1b19, inset 0 2px 0 rgba(255, 255, 255, 0.4); }
.fx-spark { position: absolute; left: 118px; bottom: 120px; width: 5px; height: 5px; border-radius: 50%; background: #ffe7a3; box-shadow: 0 0 6px 2px rgba(255, 160, 40, 0.9); pointer-events: none; animation: fx-spark 0.65s ease-out both; }
.fx-circle .fx-spark { left: 50%; top: 50%; bottom: auto; }

/* reveal */
.fx-reveal { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -58%); display: flex; flex-direction: column; align-items: center; gap: 4px; width: 280px; text-align: center; animation: fx-reveal 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
.fx-reveal b { font-size: 20px; position: relative; text-shadow: 0 2px 4px #000; }
.fx-reveal small { font-size: 12px; color: var(--muted); position: relative; }
.fx-reveal .fx-item { position: relative; width: 92px; height: 92px; margin-bottom: 4px; }
.fx-reveal .fx-item .item-ico { width: 100%; height: 100%; }
.fx-rays { position: absolute; left: 50%; top: 46px; width: 260px; height: 260px; margin: -130px 0 0 -130px; border-radius: 50%; background: repeating-conic-gradient(from 0deg, rgba(255, 215, 110, 0.45) 0 8deg, transparent 8deg 22deg); mask: radial-gradient(circle, #000 15%, transparent 68%); -webkit-mask: radial-gradient(circle, #000 15%, transparent 68%); animation: fx-spin 5s linear infinite; }
.is-ok .fx-reveal b { color: #7bf1a8; }
.is-ok .fx-reveal .fx-item .item-ico { filter: drop-shadow(0 0 14px rgba(255, 215, 110, 0.95)); animation: fx-float 1.4s ease-in-out infinite alternate; }
.fx-reveal.epic b { color: #ffd166; font-size: 24px; }
.fx-reveal.epic .fx-rays { width: 340px; height: 340px; margin: -170px 0 0 -170px; background: repeating-conic-gradient(from 0deg, rgba(255, 190, 60, 0.6) 0 6deg, rgba(255, 90, 60, 0.25) 6deg 10deg, transparent 10deg 20deg); }
.fx-plus { position: absolute; right: -26px; top: -6px; font-size: 26px; font-weight: 700; color: #ffd166; text-shadow: 0 0 10px rgba(255, 170, 0, 0.9), 2px 2px 0 #000; animation: fx-plus 0.6s cubic-bezier(0.2, 1.6, 0.4, 1) 0.1s both; }
.fx-plus.down { color: #ff6b6b; text-shadow: 0 0 8px rgba(255, 60, 60, 0.8), 2px 2px 0 #000; }
.is-fail .fx-reveal b { color: #ff6b6b; }
.is-fail .fx-reveal .fx-item { animation: forge-shake 0.45s ease; }
.is-fail .fx-reveal .fx-item .item-ico { filter: grayscale(0.75) brightness(0.6) drop-shadow(0 0 8px rgba(255, 50, 50, 0.6)); }
.forge-fx.is-fail { background: radial-gradient(ellipse at 50% 45%, rgb(66, 12, 10), rgb(12, 6, 4) 70%); }
.is-fail .fx-reveal { animation: fx-reveal 0.35s ease both; }
.fx-smoke { position: absolute; left: 50%; top: 46px; width: 0; height: 0; }
.fx-smoke i { position: absolute; left: -30px; top: -30px; width: 60px; height: 60px; border-radius: 50%; background: radial-gradient(circle, rgba(140, 130, 120, 0.7), transparent 70%); animation: fx-smoke 1.3s ease-out both; }
.fx-smoke i:nth-child(2) { --sx: -40px; animation-delay: 0.08s; }
.fx-smoke i:nth-child(3) { --sx: 40px; animation-delay: 0.16s; }
.fx-smoke i:nth-child(4) { --sx: 0px; animation-delay: 0.24s; }
.fx-crack { position: absolute; left: 50%; top: 46px; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 60, 60, 0.45), transparent 65%); animation: fx-flash 0.5s ease-out both; }
.forge-fx.is-ok .fx-circle, .forge-fx.is-fail .fx-circle { opacity: 0; transform: scale(0.6); }
.forge-fx.is-ok .fx-anvil-scene, .forge-fx.is-fail .fx-anvil-scene { opacity: 0; }

@keyframes fx-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fx-out { to { opacity: 0; } }
@keyframes fx-spin { to { transform: rotate(360deg); } }
@keyframes fx-dots { from { width: 0; } to { width: 1.2em; } }
@keyframes fx-pulse { from { transform: scale(0.85); opacity: 0.75; } to { transform: scale(1.15); opacity: 1; } }
@keyframes fx-fuse { 0% { transform: scale(1); } 60% { transform: scale(3.2); opacity: 1; } 100% { transform: scale(4); opacity: 0.2; } }
@keyframes fx-orbit {
  0% { transform: rotate(var(--a)) translateX(84px) rotate(calc(-1 * var(--a))) scale(0.4); opacity: 0; }
  15% { transform: rotate(calc(var(--a) + 60deg)) translateX(84px) rotate(calc(-1 * var(--a) - 60deg)) scale(1); opacity: 1; }
  100% { transform: rotate(calc(var(--a) + 540deg)) translateX(0) rotate(calc(-1 * var(--a) - 540deg)) scale(0.2); opacity: 0; }
}
@keyframes fx-hammer { 0% { transform: rotate(35deg); } 45% { transform: rotate(52deg); } 60% { transform: rotate(-62deg); } 72% { transform: rotate(-54deg); } 100% { transform: rotate(35deg); } }
@keyframes fx-struck { 0% { transform: scale(1.12, 0.86); } 100% { transform: scale(1); } }
@keyframes fx-spark { 0% { transform: translate(0, 0) scale(var(--s)); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; } }
@keyframes fx-reveal { from { opacity: 0; transform: translate(-50%, -58%) scale(0.5); } to { opacity: 1; transform: translate(-50%, -58%) scale(1); } }
@keyframes fx-float { from { transform: translateY(2px); } to { transform: translateY(-4px); } }
@keyframes fx-plus { from { opacity: 0; transform: translateY(12px) scale(0.4); } to { opacity: 1; transform: none; } }
@keyframes fx-smoke { from { transform: translate(0, 10px) scale(0.4); opacity: 0.9; } to { transform: translate(var(--sx, 0), -50px) scale(1.8); opacity: 0; } }
@keyframes fx-flash { 0% { transform: scale(0.3); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .fx-ring, .fx-rays, .fx-core, .is-ok .fx-reveal .fx-item .item-ico { animation: none; }
}

/* ================= Touch / mobile (landscape) ================= */
:root {
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
}
html, body { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; overscroll-behavior: none; }
.touch-only { display: none !important; }
body.touch .touch-only { display: revert !important; }
body.touch .desktop-only { display: none !important; }
body.touch .stick-zone.touch-only, body.touch .act-btn.touch-only { display: flex !important; }

/* rotate guard */
.rotate-lock {
  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center;
  background: radial-gradient(ellipse at 50% 110%, rgba(185, 28, 28, 0.35), transparent 60%), #0b0706;
}
.rotate-lock h2 { margin: 0; font-size: 20px; color: var(--gold-soft); text-wrap: balance; }
.rotate-lock p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--muted); text-wrap: pretty; }
.rotate-phone {
  width: 54px; height: 92px; border: 3px solid var(--gold); border-radius: 12px; position: relative;
  animation: rotate-hint 2.4s cubic-bezier(0.6, 0, 0.3, 1) infinite;
}
.rotate-phone span { position: absolute; left: 50%; bottom: 6px; width: 14px; height: 3px; margin-left: -7px; border-radius: 2px; background: var(--gold); }
@keyframes rotate-hint { 0%, 20% { transform: rotate(0); } 50%, 75% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }

/* joystick */
.stick-zone {
  position: fixed; left: 0; bottom: 0; z-index: 3;
  width: min(42vw, 360px); height: 58vh;
  touch-action: none;
}
.stick-base {
  position: absolute; left: calc(84px + var(--sl)); top: calc(100% - 84px - var(--sb));
  width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(36, 20, 15, 0.35), rgba(18, 10, 8, 0.6));
  border: 2px solid rgba(212, 175, 55, 0.45);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.6);
  opacity: 0.6; transition: opacity 0.15s;
  pointer-events: none;
}
.stick-base.on { opacity: 1; transition: none; }
.stick-knob {
  width: 50px; height: 50px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #f3d98b, #b8862a 60%, #6b4a1d);
  border: 1px solid #000; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
}

/* context action button */
.act-btn {
  position: fixed; right: calc(14px + var(--sr)); bottom: calc(14px + var(--sb)); z-index: 4;
  width: 84px; height: 84px; border-radius: 50%; padding: 0;
  flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: radial-gradient(circle at 50% 35%, #d62828, #6e0a0a 75%);
  border: 2px solid var(--gold); color: #fff8e1;
  box-shadow: 0 0 0 2px #000, 0 6px 16px rgba(0, 0, 0, 0.55), inset 0 2px 0 rgba(255, 220, 160, 0.25);
  font: inherit; font-size: 13px; font-weight: 600; touch-action: manipulation;
}
.act-btn:active { transform: scale(0.94); filter: brightness(1.15); }
.act-btn .mi { width: 30px; height: 30px; }
.act-btn .act-ico { display: none; }
.act-btn[data-kind='attack'] .act-attack, .act-btn[data-kind='talk'] .act-talk, .act-btn[data-kind='pick'] .act-pick { display: block; }
.act-btn[data-kind='talk'] { background: radial-gradient(circle at 50% 35%, #c9a227, #6b4a1d 75%); }
.act-btn[data-kind='pick'] { background: radial-gradient(circle at 50% 35%, #2e8b57, #12402a 75%); }

body.touch kbd, body.touch .mode-chip, body.touch .slot .key { display: none; }
body.touch button, body.touch .slot, body.touch .inv-cell, body.touch .equip { touch-action: manipulation; }

/* --- HUD layout --- */
body.touch .basic-info { left: calc(8px + var(--sl)); top: 8px; width: 196px; padding: 6px 8px; }
body.touch .bi-head { margin-bottom: 3px; }
body.touch .bi-name { font-size: 13px; }
body.touch .bi-class, body.touch .bi-lv { font-size: 10.5px; }
body.touch .bi-lv b { font-size: 12px; }
body.touch .bar { height: 12px; margin: 2px 0; }
body.touch .bar em { font-size: 9.5px; }
body.touch .bar i { font-size: 8.5px; line-height: 12px; }
body.touch .bar.exp, body.touch .bar.jexp { height: 9px; }
body.touch .bar.exp i, body.touch .bar.jexp i { line-height: 9px; }
body.touch .bi-foot { margin-top: 3px; font-size: 11px; }

body.touch .minimap-wrap { right: calc(8px + var(--sr)); top: 8px; width: 124px; padding: 4px; }
body.touch #minimap { width: 114px; height: 114px; }
body.touch .mm-head { font-size: 10px; padding-bottom: 3px; }
body.touch .mm-foot { display: none; }
body.touch .mm-expand {
  position: absolute; right: 8px; bottom: 8px; width: 32px; height: 32px; margin: 0; padding: 0;
  font-size: 0; gap: 0; border-radius: 6px; background: rgba(20, 11, 8, 0.85);
}
body.touch .mm-expand .mi.sm { width: 18px; height: 18px; }

body.touch .menu-bar {
  top: 8px; right: auto; left: calc(212px + var(--sl));
  width: auto; grid-template-columns: repeat(8, 38px); gap: 4px;
}
body.touch .mb-btn { width: 38px; height: 38px; padding: 0; }
body.touch .mb-label { display: none; }
body.touch .mb-btn .mi { width: 20px; height: 20px; }

body.touch #announce { top: 54px; font-size: 13px; max-width: 50vw; }
body.touch #zone-banner { top: 64px; font-size: 18px; }
body.touch .target-frame { top: auto; bottom: calc(132px + var(--sb)); left: auto; right: calc(8px + var(--sr)); transform: none; width: 196px; padding: 4px 8px; font-size: 12px; }
body.touch .toast { bottom: auto; top: 56px; font-size: 13px; max-width: 60vw; text-align: center; }

body.touch .hotbar {
  left: auto; right: calc(106px + var(--sr)); bottom: calc(10px + var(--sb)); transform: none;
  display: grid; grid-template-columns: repeat(4, 50px); gap: 5px; padding: 5px; width: auto;
}
body.touch .hotbar .slot { width: 50px; height: 50px; font-size: 11px; }
body.touch .hotbar .slot.sep { display: none; }
body.touch .hotbar .slot .item-ico.gem { width: 28px; height: 28px; }

body.touch .chat { left: calc(8px + var(--sl)); bottom: auto; top: 142px; width: 196px; z-index: 4; }
body.touch .chat-log { height: min(86px, 20vh); font-size: 11.5px; padding: 3px 6px; }
body.touch .chat-tabs > span:not(.active) { display: none; }
body.touch .chat-toggle { padding: 4px 10px; }
body.touch .chat-form input { padding: 8px; font-size: 16px; }

body.touch .tut {
  left: calc(212px + var(--sl)); top: 54px; bottom: auto;
  width: min(320px, calc(100vw - 212px - 140px - var(--sl) - var(--sr)));
  max-height: calc(100dvh - 54px - 140px); overflow-y: auto; padding: 8px 10px;
}
body.touch .tut-title { font-size: 14px; }
body.touch .tut-body { font-size: 12px; line-height: 1.45; }
body.touch .tut-actions button { padding: 6px 10px; }

/* --- windows --- */
body.touch .window {
  width: min(var(--win-w, 340px), calc(100vw - 24px - var(--sl) - var(--sr)));
  max-height: calc(100dvh - 16px);
}
body.touch .window.wide { --win-w: 520px; }
body.touch .window.forge { --win-w: 720px; max-height: calc(100dvh - 12px); }
body.touch .window.npc { --win-w: 460px; top: 50%; bottom: auto; transform: translate(-50%, -50%); }
body.touch #win-settings { --win-w: 460px; }
body.touch .win-title { padding: 4px 6px 4px 10px; font-size: 13px; }
body.touch .win-title .x { width: 34px; height: 30px; font-size: 18px; }
body.touch .win-body { padding: 8px 10px; overscroll-behavior: contain; touch-action: pan-y; }
body.touch .plus { width: 32px; height: 30px; }
body.touch .shop-btn { padding: 7px 12px; }
body.touch .npc-actions button { padding: 9px 12px; }
body.touch .inv-grid { grid-template-columns: repeat(8, 1fr); }
body.touch .forge-cells { max-height: none; }
body.touch .window.map { max-height: calc(100dvh - 12px); }
body.touch .map-body { flex-direction: row; align-items: flex-start; }
body.touch #worldmap { width: min(560px, calc(100dvh - 70px)); }
body.touch .map-legend { flex-direction: column; flex-wrap: nowrap; align-items: flex-start; width: 120px; }
body.touch .map-legend .muted { flex-basis: auto; }

/* --- title / cinematic / death --- */
body.touch #title-screen, body.touch .chat-log, body.touch .tut, body.touch .forge-cells { touch-action: pan-y; }
body.touch #title-screen { align-items: flex-start; padding: 12px calc(16px + var(--sr)) 12px calc(16px + var(--sl)); }
body.touch .title-wrap { margin: auto; }
body.touch .cine-skip { top: 10px; right: calc(14px + var(--sr)); padding: 8px 16px; }
body.touch .cine-hint { display: block; top: 16px; left: calc(16px + var(--sl)); }
body.touch .cine-sub p { font-size: 15px; }

@media (max-height: 500px) {
  body.touch .game-title { font-size: clamp(38px, 9vh, 64px); }
  body.touch .title-sub { margin: 2px 0 10px; }
  body.touch .title-kicker, body.touch .class-card .en { display: none; }
  body.touch .panel { padding: 12px 14px; }
  body.touch .class-list { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  body.touch .class-card { padding: 8px; }
  body.touch .class-card p { font-size: 11px; line-height: 1.4; }
  body.touch .field { margin-bottom: 8px; }
  body.touch .field input { padding: 7px 10px; font-size: 16px; }
  body.touch .cine-title strong { font-size: clamp(32px, 10vh, 56px); }
  body.touch .cine-hero strong { font-size: clamp(26px, 8vh, 44px); }
  body.touch .cine-card strong { font-size: 20px; }
}
@media (max-height: 420px) {
  body.touch .chat { top: 132px; }
  body.touch .hotbar { grid-template-columns: repeat(4, 44px); }
  body.touch .hotbar .slot { width: 44px; height: 44px; }
  body.touch .act-btn { width: 74px; height: 74px; }
  body.touch .hotbar { right: calc(96px + var(--sr)); }
  body.touch .target-frame { bottom: calc(118px + var(--sb)); }
}
@media (prefers-reduced-motion: reduce) {
  .rotate-phone { animation: none; transform: rotate(-90deg); }
}
body.touch .forge-empty, .forge-cells > .forge-empty { grid-column: 1 / -1; }
