/* ============================================================================
   CRYPTO QUEST — modern UI (Inter + Noto Sans Thai)
   ========================================================================== */
:root {
  --bg: #0a0b0f;
  --surface: rgba(20, 22, 29, 0.72);
  --surface-solid: #121419;
  --surface-2: rgba(255, 255, 255, 0.05);
  --surface-3: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f4f5f7;
  --text-2: #c7ccd6;
  --muted: #8a93a4;
  --accent: #38bdf8;
  --cyan: #38bdf8;
  --cyan-2: #7dd3fc;
  --gold: #fbbf24;
  --amber: #fbbf24;
  --green: #34d399;
  --red: #f87171;
  --pink: #f472b6;
  --violet: #a78bfa;
  --radius: 16px;
  --font: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --head: var(--font);
  --mono: var(--font);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  letter-spacing: -0.006em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  user-select: none;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--cyan-2); }
h1, h2, h3, h4 { font-family: var(--head); font-weight: 600; margin: 0; letter-spacing: -0.02em; }
.mono, .tnum { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
svg.i { width: 1.05em; height: 1.05em; vertical-align: -0.16em; flex: none; }
::selection { background: rgba(56, 189, 248, 0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }

/* ------------------------------------------------------------ buttons & chips */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface-2);
  cursor: pointer; font-weight: 500; font-size: 14px; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, transform .12s ease, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: rgba(255, 255, 255, 0.22); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: #facc15; color: #1a1400; border-color: transparent; font-weight: 600; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 6px 18px rgba(250, 204, 21, 0.18); }
.btn-primary:hover:not(:disabled) { background: #fde047; border-color: transparent; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 8px 24px rgba(250, 204, 21, 0.28); }
.btn-primary:focus-visible { outline-color: #fde047; }
.btn-gold { background: rgba(251, 191, 36, 0.12); color: #fcd34d; border-color: rgba(251, 191, 36, 0.28); }
.btn-gold:hover:not(:disabled) { background: rgba(251, 191, 36, 0.2); border-color: rgba(251, 191, 36, 0.45); }
.btn-green { background: rgba(52, 211, 153, 0.14); color: #6ee7b7; border-color: rgba(52, 211, 153, 0.3); }
.btn-danger { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.3); color: #fca5a5; }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.18); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line); }
.btn-sm { height: 32px; padding: 0 12px; border-radius: 8px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 500; white-space: nowrap;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.chip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.chip.coin svg { color: var(--gold); }
.chip.token svg { color: var(--cyan-2); }
.chip.warn { border-color: rgba(251, 191, 36, 0.4); color: #fcd34d; }
.chip.danger { border-color: rgba(248, 113, 113, 0.5); color: #fca5a5; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--line); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------------------ top bar */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 64px; z-index: 30;
  display: flex; align-items: center; gap: 8px; padding: 0 20px;
  background: linear-gradient(180deg, rgba(10, 11, 15, 0.92), rgba(10, 11, 15, 0.6) 65%, transparent);
}
#topbar .brand { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-right: auto; }
#topbar .brand .logo-mark { width: 30px; height: 30px; }
#topbar .brand span { font-weight: 700; letter-spacing: -0.02em; font-size: 15px; }
#topbar .brand span em { font-style: normal; color: var(--muted); font-weight: 500; }
#topbar .wallet-btn.connected { border-color: rgba(52, 211, 153, 0.35); }
#topbar .wallet-btn .dot { width: 7px; height: 7px; background: var(--green); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
body.playing #topbar { display: none; }

/* ------------------------------------------------------------ screens */
.screen { position: fixed; inset: 0; overflow-y: auto; padding: 84px 24px 40px; z-index: 10; display: none; }
.screen.active { display: block; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: var(--shadow);
}

/* title */
#screen-title { background: linear-gradient(90deg, rgba(10, 11, 15, 0.94) 0%, rgba(10, 11, 15, 0.75) 36%, rgba(10, 11, 15, 0) 62%); }
.title-wrap { max-width: 1240px; margin: 0 auto; min-height: calc(100vh - 140px); min-height: calc(100dvh - 140px); display: flex; flex-direction: column; justify-content: center; }
.title-col { max-width: 540px; }
.kicker { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); font-size: 12px; font-weight: 500; letter-spacing: 0.02em; }
.kicker::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2); }
.logo { font-weight: 800; font-size: clamp(48px, 7.4vw, 92px); line-height: 0.92; letter-spacing: -0.055em; margin: 20px 0 8px; color: #fff;
  background: linear-gradient(180deg, #ffffff 30%, #9aa3b2 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo small { display: block; font-size: 0.18em; letter-spacing: 0.32em; font-weight: 600; margin-top: 14px; color: var(--muted); -webkit-text-fill-color: var(--muted); }
.title-sub { font-size: 16.5px; color: var(--text-2); margin: 16px 0 28px; max-width: 480px; line-height: 1.65; }
.title-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.title-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 540px; }
.stat-card { padding: 14px 16px; }
.stat-card .k { font-size: 12.5px; line-height: 18px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-card .v { font-size: 24px; line-height: 32px; font-weight: 600; margin-top: 6px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-card .v.small { font-size: 21px; }
.stat-card .v span { line-height: 1; }
.stat-card .v.warn { color: var(--amber); }
.stat-card .v.danger { color: var(--red); }
.feature-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* map screen */
#screen-map { background: rgba(10, 11, 15, 0.88); }
.map-wrap { max-width: 1440px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.map-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.map-head h2 { font-size: 24px; margin-right: 6px; }
.map-head .grow { flex: 1; min-width: 140px; }
.progress { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .5s; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: rgba(255, 255, 255, 0.1); color: var(--text); }

/* list view */
.tier { margin-bottom: 26px; }
.tier-head { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.tier-head h3 { font-size: 15px; display: inline-flex; align-items: center; gap: 8px; }
.tier-head h3::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tier-head .range { font-size: 12.5px; color: var(--muted); }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.lv {
  position: relative; padding: 14px; min-height: 148px; cursor: pointer; overflow: hidden;
  background: var(--surface-solid); border: 1px solid var(--line); border-radius: 14px;
  transition: transform .15s, border-color .15s, background .15s; display: flex; flex-direction: column; gap: 3px;
}
.lv:hover { transform: translateY(-2px); border-color: var(--line-2); background: #171a21; }
.lv .num { font-weight: 700; font-size: 26px; line-height: 1; letter-spacing: -0.04em; color: var(--text); font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.lv .num::after { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--tc, var(--accent)); margin-left: 6px; vertical-align: 0.35em; }
.lv .name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.lv .th { font-size: 12.5px; color: var(--muted); }
.lv .meta { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.lv .reward { color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; font-weight: 500; }
.lv .reward svg { color: var(--gold); }
.lv .stars { color: var(--gold); letter-spacing: 1px; font-size: 12px; }
.lv .badge { position: absolute; top: 12px; right: 12px; font-size: 11.5px; font-weight: 500; height: 22px; padding: 0 8px; display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); }
.lv.cleared .badge { color: #6ee7b7; border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.08); }
.lv.current { border-color: rgba(56, 189, 248, 0.6); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15); }
.lv.current .badge { color: #0a0b0f; background: #f8fafc; border-color: transparent; font-weight: 600; }
.lv.locked { cursor: not-allowed; }
.lv.locked > *:not(.lock-ic) { opacity: .42; }
.lv.locked:hover { transform: none; background: var(--surface-solid); border-color: var(--line); }
.lv.disabled { opacity: .3; cursor: not-allowed; }
.lv .lock-ic { position: absolute; right: 12px; bottom: 12px; color: var(--muted); }
.lv .boss-tag { color: var(--pink); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; }

/* side panel */
.side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 12px; }
.side .panel { padding: 18px; }
.side h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.side .label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.countdown { font-size: 38px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.15; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.countdown.warn { color: var(--amber); }
.countdown.danger { color: var(--red); }
.camp-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.camp-meta div { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.camp-meta span { display: block; font-size: 11.5px; color: var(--muted); }
.camp-meta b { font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }
.timeline { position: relative; margin-top: 14px; }
.sched-day { position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding-bottom: 16px; }
.sched-day:last-child { padding-bottom: 0; }
.sched-day::before { content: ''; position: absolute; left: 16px; top: 34px; bottom: 2px; width: 2px; background: var(--line); border-radius: 2px; }
.sched-day:last-child::before { display: none; }
.sched-day .d { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 600; font-size: 15px; background: var(--surface-2); border: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
.sched-day.done .d { background: rgba(52, 211, 153, 0.14); border-color: rgba(52, 211, 153, 0.4); color: #6ee7b7; }
.sched-day.now .d { background: #f8fafc; color: #0a0b0f; border-color: transparent; }
.sched-day .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.sched-day .row b { font-weight: 600; font-size: 13.5px; }
.sched-day .due { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.sched-day .lvls { display: flex; flex-wrap: wrap; gap: 4px; }
.sched-day .lvls span { min-width: 28px; height: 24px; padding: 0 6px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 500; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); font-variant-numeric: tabular-nums; }
.sched-day .lvls span.ok { background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.35); color: #6ee7b7; }
.sched-day .lvls span.late { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }
.sched-day .lvls span.next { background: #f8fafc; color: #0a0b0f; border-color: transparent; font-weight: 600; }
.sched-day .bar-mini { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.07); overflow: hidden; margin-top: 8px; }
.sched-day .bar-mini i { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.rule-note { font-size: 12.5px; color: var(--text-2); padding: 10px 12px; border-radius: 10px; background: rgba(251, 191, 36, 0.07); border: 1px solid rgba(251, 191, 36, 0.2); margin-top: 16px; line-height: 1.6; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-actions .btn { height: auto; padding: 12px 6px; flex-direction: column; gap: 6px; font-size: 12.5px; white-space: normal; text-align: center; }
.quick-actions .btn svg { width: 18px; height: 18px; }

/* ------------------------------------------------------------ world map */
.wm { position: relative; height: calc(100vh - 152px); height: calc(100dvh - 152px); min-height: 460px; border-radius: 18px; overflow: hidden;
  background: #0c0e13; border: 1px solid var(--line); touch-action: none; cursor: grab; box-shadow: var(--shadow); }
.wm.dragging { cursor: grabbing; }
.wm-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.wm-world.anim { transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
.wm-bg { position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1.2px, transparent 1.2px);
  background-size: 28px 28px; }
.wm-band { position: absolute; border-radius: 48px; border: 1px solid color-mix(in srgb, var(--tc) 22%, transparent);
  background: linear-gradient(90deg, color-mix(in srgb, var(--tc) 9%, transparent), color-mix(in srgb, var(--tc) 3%, transparent)); pointer-events: none; }
.wm-band .bl { position: absolute; left: 40px; top: 26px; display: flex; align-items: baseline; gap: 12px; }
.wm-band .bl b { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; color: var(--tc); }
.wm-band .bl span { font-size: 22px; color: var(--muted); font-weight: 500; }
.wm-path { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.wm-path .p-lock { stroke: rgba(255, 255, 255, 0.14); stroke-width: 6; fill: none; stroke-dasharray: 2 18; stroke-linecap: round; }
.wm-path .p-done { stroke: rgba(52, 211, 153, 0.85); stroke-width: 6; fill: none; stroke-linecap: round; }
.wm-path .p-next { stroke: #f8fafc; stroke-width: 6; fill: none; stroke-dasharray: 14 14; stroke-linecap: round; animation: dashMove 1.2s linear infinite; }
.wm-flag { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 18px; border-radius: 999px;
  background: var(--surface-solid); border: 1px solid var(--line-2); font-weight: 600; font-size: 18px; pointer-events: none; }
.mt { position: absolute; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.mt-frame { position: relative; border-radius: 18px; overflow: hidden; background: #07080b; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.14); box-shadow: 0 0 0 6px rgba(10, 11, 15, 0.9), 0 24px 60px rgba(0, 0, 0, 0.55); transition: box-shadow .2s, transform .2s; }
.mt-frame:hover { box-shadow: 0 0 0 6px rgba(10, 11, 15, 0.9), 0 0 0 8px rgba(255, 255, 255, 0.2), 0 24px 60px rgba(0, 0, 0, 0.6); }
.mt-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; -webkit-user-drag: none; }
.mt-frame .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px;
  background: linear-gradient(110deg, #0e1016 30%, #171a22 50%, #0e1016 70%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.mt-num { position: absolute; top: 12px; left: 12px; height: 34px; min-width: 46px; padding: 0 12px; border-radius: 10px; display: inline-flex; align-items: center; gap: 8px;
  background: rgba(10, 11, 15, 0.82); border: 1px solid rgba(255, 255, 255, 0.12); backdrop-filter: blur(8px); font-weight: 700; font-size: 18px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; z-index: 2; }
.mt-num i { width: 9px; height: 9px; border-radius: 50%; background: var(--tc); }
.mt-state { position: absolute; top: 12px; right: 12px; height: 30px; padding: 0 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; z-index: 2;
  background: rgba(10, 11, 15, 0.82); border: 1px solid rgba(255, 255, 255, 0.12); backdrop-filter: blur(8px); }
.mt.cleared .mt-state { color: #6ee7b7; border-color: rgba(52, 211, 153, 0.35); }
.mt.current .mt-state { background: #f8fafc; color: #0a0b0f; border-color: transparent; }
.mt.current .mt-frame { box-shadow: 0 0 0 6px rgba(10, 11, 15, 0.9), 0 0 0 9px #f8fafc, 0 24px 60px rgba(0, 0, 0, 0.6); animation: ringPulse 2s ease-in-out infinite; }
.mt.locked .mt-frame img { filter: grayscale(0.55) brightness(0.72); }
.wm.far .mt-label span { display: none; }
.wm.far .mt-state, .wm.far .mt-lock { transform: scale(1.4); }
.wm.far .mt-lock { transform: translate(-50%, -50%) scale(1.6); }
.mt.locked .mt-frame::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10, 11, 15, 0) 40%, rgba(10, 11, 15, 0.7)); }
.mt.disabled { opacity: .35; }
.mt.sel .mt-frame { box-shadow: 0 0 0 6px rgba(10, 11, 15, 0.9), 0 0 0 9px var(--accent), 0 24px 60px rgba(0, 0, 0, 0.6); }
.mt-lock { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; z-index: 2;
  background: rgba(10, 11, 15, 0.75); border: 1px solid rgba(255, 255, 255, 0.16); color: var(--text-2); backdrop-filter: blur(6px); }
.mt-lock svg { width: 26px; height: 26px; }
.mt-marks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity .25s; z-index: 1; }
.wm.marks .mt-marks { opacity: 1; }
.mt-label { display: flex; flex-direction: column; align-items: center; gap: 2px; transform: scale(var(--lk, 1)); transform-origin: 50% 0; transition: transform .2s; pointer-events: none; text-align: center; }
.mt-label b { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.mt-label span { font-size: 16px; color: var(--muted); white-space: nowrap; }
.mt-label .rw { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; color: var(--text-2); font-variant-numeric: tabular-nums; margin-top: 2px; }
.mt-label .rw svg { color: var(--gold); }
.mt-label .rw .st { color: var(--gold); letter-spacing: 2px; }
.mt-scale { position: absolute; bottom: 10px; right: 12px; z-index: 2; font-size: 12px; color: var(--text-2); padding: 3px 8px; border-radius: 6px; background: rgba(10, 11, 15, 0.7); font-variant-numeric: tabular-nums; opacity: 0; transition: opacity .2s; }
.wm.near .mt-scale { opacity: 1; }

.wm-tools { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; gap: 4px; padding: 4px; border-radius: 14px; z-index: 5;
  background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(14px); box-shadow: var(--shadow); cursor: default; }
.wm-tools button { width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); cursor: pointer; display: grid; place-items: center; font-size: 18px; font-weight: 500; }
.wm-tools button:hover { background: var(--surface-3); color: var(--text); }
.wm-tools button.on { background: rgba(255, 255, 255, 0.12); color: var(--text); }
.wm-tools hr { border: 0; height: 1px; background: var(--line); margin: 2px 4px; }
.wm-zoom { position: absolute; left: 14px; top: 14px; z-index: 5; display: flex; gap: 8px; align-items: center; cursor: default; }
.wm-zoom .chip { background: var(--surface); }
.wm-legend { position: absolute; left: 14px; top: 56px; z-index: 5; display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 12px; font-size: 12px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(14px); cursor: default; opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; pointer-events: none; }
.wm.marks .wm-legend { opacity: 1; transform: none; }
.wm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.wm-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.wm-mini { position: absolute; right: 14px; bottom: 14px; z-index: 5; width: 128px; opacity: .92; border-radius: 12px; overflow: hidden; background: rgba(12, 14, 19, 0.9); border: 1px solid var(--line-2); cursor: pointer; box-shadow: var(--shadow); }
.wm-mini canvas { display: block; width: 100%; }
.wm-card { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 6; width: min(560px, calc(100% - 220px)); padding: 14px; display: grid; grid-template-columns: 96px 1fr; gap: 14px; cursor: default; animation: popIn .22s ease; }
.wm-card .thumb { width: 96px; height: 72px; border-radius: 10px; overflow: hidden; background: #07080b; border: 1px solid var(--line); }
.wm-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wm-card h4 { font-size: 16px; }
.wm-card .sub { font-size: 12.5px; color: var(--muted); margin: 2px 0 8px; }
.wm-card .acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.wm-card .x { position: absolute; right: 8px; top: 8px; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.wm-card .x:hover { background: var(--surface-3); color: var(--text); }
.wm-progress { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 5; }
.wm-hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 4; font-size: 12.5px; color: var(--muted); padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); pointer-events: none; white-space: nowrap; }

/* ------------------------------------------------------------ modals */
#modals { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.modal-backdrop {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 18px; pointer-events: auto;
  background: rgba(5, 6, 9, 0.66); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fadeIn .16s ease;
}
.modal {
  width: min(620px, 100%); max-height: calc(100vh - 36px); max-height: calc(100dvh - 36px); display: flex; flex-direction: column;
  background: var(--surface-solid); border: 1px solid var(--line-2); border-radius: 20px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6); animation: popIn .2s cubic-bezier(.2, .9, .3, 1.1);
}
.modal.wide { width: min(940px, 100%); }
.modal.xwide { width: min(1180px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 20px 22px 10px; }
.modal-head svg.i { color: var(--muted); }
.modal-head h3 { font-size: 18px; flex: 1; }
.modal-head .x { background: none; border: 0; color: var(--muted); cursor: pointer; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; }
.modal-head .x:hover { color: var(--text); background: var(--surface-3); }
.modal-body { padding: 6px 22px 18px; overflow-y: auto; min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.modal-head, .modal-foot { flex: none; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }
.modal-foot:empty { display: none; }

/* how-to stepper */
.steps-dots { display: flex; gap: 6px; margin-bottom: 18px; }
.steps-dots i { flex: 1; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); transition: background .2s; }
.steps-dots i.on { background: #f8fafc; }
.step-card { display: grid; grid-template-columns: 104px 1fr; gap: 20px; align-items: start; min-height: 220px; }
.step-art { width: 104px; height: 104px; border-radius: 24px; display: grid; place-items: center; background: linear-gradient(160deg, rgba(56, 189, 248, 0.16), rgba(167, 139, 250, 0.1)); border: 1px solid var(--line-2); color: #e0f2fe; }
.step-art svg { width: 44px; height: 44px; }
.step-num { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.step-card h4 { font-size: 21px; margin: 4px 0 10px; }
.step-card p { color: var(--text-2); margin: 0 0 8px; }
.step-card ul { margin: 8px 0 0; padding-left: 18px; color: var(--text-2); }
.step-card li { margin: 5px 0; }
.kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 22px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; background: var(--surface-2); font-size: 11.5px; font-weight: 600; color: var(--text); }
.controls-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; margin-top: 10px; font-size: 13.5px; color: var(--text-2); }
.controls-grid div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* agreement */
.rules { counter-reset: r; list-style: none; padding: 0; margin: 0 0 14px; }
.rules li { counter-increment: r; position: relative; padding: 10px 0 10px 40px; border-bottom: 1px solid var(--line); color: var(--text-2); }
.rules li::before { content: counter(r); position: absolute; left: 0; top: 10px; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text); }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; margin-top: 10px; transition: border-color .15s, background .15s; }
.check input { width: 18px; height: 18px; accent-color: #f8fafc; margin-top: 2px; flex: none; }
.check:has(input:checked) { border-color: rgba(52, 211, 153, 0.45); background: rgba(52, 211, 153, 0.06); }
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; }
.hint.err { color: #fca5a5; }

/* briefing */
.brief-top { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; margin-bottom: 14px; }
.brief-num { width: 68px; height: 68px; border-radius: 18px; display: grid; place-items: center; font-weight: 700; font-size: 28px; letter-spacing: -0.03em; color: #0a0b0f; background: var(--tc, #f8fafc); }
.brief-map { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #07080b; margin: 4px 0 12px; }
.brief-map img { display: block; width: 100%; max-height: 260px; object-fit: cover; }
.brief-map .cap { position: absolute; left: 10px; bottom: 10px; font-size: 12px; padding: 3px 8px; border-radius: 6px; background: rgba(10, 11, 15, 0.75); color: var(--text-2); }
.brief-goal { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); margin: 10px 0; color: var(--text-2); }
.brief-goal b { color: var(--text); }
.brief-steps { counter-reset: s; list-style: none; padding: 0; margin: 10px 0; }
.brief-steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 6px 0; color: var(--text-2); }
.brief-steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text); font-weight: 600; font-size: 12px; border: 1px solid var(--line-2); }
.kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.kv > div { padding: 11px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.kv .k { font-size: 11.5px; color: var(--muted); }
.kv .v { font-size: 15px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* results */
.result-hero { text-align: center; padding: 6px 0 4px; }
.result-hero h2 { font-size: 28px; }
.result-hero .kicker { margin-bottom: 10px; }
.big-stars { font-size: 40px; letter-spacing: 8px; color: rgba(255, 255, 255, 0.12); margin: 6px 0; }
.big-stars b { color: var(--gold); display: inline-block; animation: starPop .5s backwards; }
.big-stars b:nth-child(2) { animation-delay: .15s; }
.big-stars b:nth-child(3) { animation-delay: .3s; }
.reward-lines { margin: 14px 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.reward-lines div { display: flex; justify-content: space-between; padding: 11px 14px; border-bottom: 1px solid var(--line); color: var(--text-2); }
.reward-lines div:last-child { border-bottom: 0; background: var(--surface-2); font-weight: 600; color: var(--text); }
.reward-lines .amt { color: var(--gold); font-variant-numeric: tabular-nums; font-weight: 600; }
.reward-lines .amt.tok { color: var(--cyan-2); }

/* shop / wallet */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.card { padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.card h4 { font-size: 15px; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.pkg { text-align: center; cursor: pointer; transition: border-color .15s, transform .15s, background .15s; position: relative; }
.pkg:hover { border-color: var(--line-2); background: var(--surface-3); transform: translateY(-2px); }
.pkg > svg { color: var(--cyan-2); width: 22px; height: 22px; }
.pkg .amt { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin: 4px 0 0; font-variant-numeric: tabular-nums; }
.pkg .bonus { position: absolute; top: 10px; right: 10px; font-size: 11px; font-weight: 600; color: #6ee7b7; }
.pkg .price { font-size: 14px; color: var(--text-2); margin: 6px 0 12px; font-variant-numeric: tabular-nums; }
.wallet-head { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 12px; }
.wallet-head .addr { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.wallet-opts { display: grid; gap: 8px; margin-top: 8px; }
.wallet-opt { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; text-align: left; width: 100%; transition: border-color .15s, background .15s; }
.wallet-opt:hover:not(:disabled) { border-color: var(--line-2); background: var(--surface-3); }
.wallet-opt:disabled { opacity: .45; cursor: not-allowed; }
.wallet-opt .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--text); flex: none; }
.tx-list { max-height: 220px; overflow: auto; font-size: 13px; }
.tx-list div { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.tx-list .hash { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.demo-banner { font-size: 12.5px; padding: 10px 12px; border-radius: 10px; background: rgba(251, 191, 36, 0.07); border: 1px solid rgba(251, 191, 36, 0.22); color: #fde68a; margin-bottom: 12px; }
.confirm-table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.confirm-table td { padding: 10px 2px; border-bottom: 1px solid var(--line); color: var(--text-2); }
.confirm-table td:last-child { text-align: right; color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.1); border-top-color: #f8fafc; animation: spin 0.8s linear infinite; margin: 12px auto; }
.wd-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.wd { display: flex; flex-direction: column; padding: 16px; min-width: 0; }
.wd .confirm-table td { padding: 8px 2px; }
.wd-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.wd-head h4 { margin: 0 0 2px; }
.wd-step { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; background: #f8fafc; color: #0a0b0f; font-weight: 700; font-size: 13px; }
.swap-box { padding: 12px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); }
.swap-box:focus-within { border-color: rgba(255, 255, 255, 0.28); }
.swap-lbl { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.swap-row { display: flex; align-items: center; gap: 10px; }
.swap-inp { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; padding: 0; }
.swap-inp::-webkit-inner-spin-button { -webkit-appearance: none; }
.swap-out { flex: 1; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.swap-row .unit { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 999px; background: var(--surface-3); font-size: 13px; font-weight: 600; white-space: nowrap; }
.swap-sub { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--muted); min-height: 18px; }
.swap-sub b { color: var(--text-2); font-weight: 600; }
.pcts { display: inline-flex; gap: 4px; }
.pcts button { height: 22px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line-2); background: transparent; font-size: 11.5px; color: var(--text-2); cursor: pointer; }
.pcts button:hover { background: var(--surface-3); color: var(--text); }
.swap-arrow { align-self: center; width: 32px; height: 32px; margin: -6px 0; z-index: 1; border-radius: 10px; display: grid; place-items: center; background: var(--surface-solid); border: 1px solid var(--line-2); color: var(--text-2); transform: rotate(90deg); }
.wd-st { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; margin-left: 4px; border-radius: 6px; font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.wd-st.completed, .wd-st.paid { background: rgba(52, 211, 153, 0.14); color: #6ee7b7; }
.wd-st.pending { background: rgba(251, 191, 36, 0.14); color: #fcd34d; }
.wd-st.rejected { background: rgba(248, 113, 113, 0.14); color: #fca5a5; }
.upg { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.pips { display: flex; gap: 4px; margin-top: 8px; }
.pips i { width: 18px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); }
.pips i.on { background: #f8fafc; }

/* ------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; display: none; }
body.playing #hud { display: block; }
/* top HUD: left column (status + level bars) · centre (mission + boss) · right (balances + pause) */
.hud-top { position: absolute; top: 14px; left: 14px; right: 14px; display: flex; align-items: flex-start; gap: 12px; }
.hud-left { width: 300px; flex: none; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hud-center { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hud-status { padding: 12px 14px; }
.hud-status .lvl { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; white-space: nowrap; }
.hud-status .lvl span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hud-status .lvl b { color: var(--text); font-weight: 600; letter-spacing: 0.02em; }
.meter { margin-top: 8px; }
.meter .row { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; margin-bottom: 4px; }
.meter .row span:first-child { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; letter-spacing: 0.04em; }
.meter .row b { font-weight: 500; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.bar { position: relative; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; transition: width .15s linear; }
.bar > i.lag { background: rgba(255, 255, 255, 0.4); transition: width .6s ease .25s; }
.bar.hp > i.fill { background: linear-gradient(90deg, #ef4444, #fb7185); }
.bar.sh > i.fill { background: linear-gradient(90deg, #3b82f6, #7dd3fc); }
.bar.en > i.fill { background: linear-gradient(90deg, #f59e0b, #fde047); }
.bar.thin { height: 6px; }
.hud-status.low .bar.hp { animation: pulseRed .8s infinite; }
.hud-extra { display: flex; flex-direction: column; gap: 8px; }
.hud-extra:empty { display: none; }
.hud-extra .panel { padding: 10px 12px; }
.hud-mission { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 8px; text-align: center; max-width: 100%; }
.hud-mission .timer { display: inline-block; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; padding: 8px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(14px); font-variant-numeric: tabular-nums; }
.hud-mission .timer.warn { color: var(--red); border-color: rgba(248, 113, 113, 0.4); animation: pulse 1s infinite; }
.hud-mission .obj { padding: 9px 16px; display: inline-block; min-width: 0; max-width: 100%; }
.hud-mission .obj b { display: block; font-size: 15px; font-weight: 600; }
.hud-mission .obj span { font-size: 12.5px; color: var(--muted); }
.hud-boss { width: min(600px, 100%); text-align: center; }
.hud-boss .name { font-weight: 700; letter-spacing: 0.2em; font-size: 13px; color: #fecaca; margin-bottom: 6px; }
.hud-boss .name small { letter-spacing: 0.02em; color: var(--muted); font-weight: 500; margin-left: 8px; }
.hud-boss .bar { height: 10px; background: rgba(0, 0, 0, 0.5); border: 1px solid rgba(255, 255, 255, 0.12); }
.hud-boss .bar > i.fill { background: linear-gradient(90deg, #db2777, #f87171, #fb923c); }
.hud-boss.shielded .bar > i.fill { background: linear-gradient(90deg, #3b82f6, #7dd3fc); }
.hud-right { flex: none; display: flex; gap: 8px; align-items: center; pointer-events: auto; }
.hud-quick { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 8px; pointer-events: auto; }
.qbtn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 9px 12px; min-width: 116px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); backdrop-filter: blur(14px); cursor: pointer; text-align: left; transition: border-color .15s, transform .1s, background .15s; }
.qbtn:hover { border-color: var(--line-2); background: rgba(30, 33, 42, 0.8); }
.qbtn:active { transform: scale(.97); }
.qbtn .t { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; }
.qbtn .p { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.qbtn .p .c { color: #fcd34d; }
.qbtn .p .tk { color: var(--cyan-2); }
.qbtn.hp .t { color: #fda4af; }
.qbtn.en .t { color: #fde68a; }
.qbtn.sh .t { color: #bae6fd; }
.qbtn.flash { animation: flashBtn .6s 3; }
.hud-abil { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 8px; }
.abil { width: 76px; padding: 9px 6px; text-align: center; border-radius: 12px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); }
.abil .ic { font-size: 17px; color: var(--text); font-weight: 600; }
.abil.ready { border-color: rgba(255, 255, 255, 0.3); color: var(--text); }
.abil.ammo .ic { color: var(--amber); font-variant-numeric: tabular-nums; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 19; opacity: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(239, 68, 68, 0.5) 100%); transition: opacity .25s; }
#vignette.low { animation: lowHp 1.1s infinite; }
#vignette.hit { opacity: .8; transition: none; }
#announce { position: fixed; left: 0; right: 0; top: 30%; text-align: center; z-index: 25; pointer-events: none; }
#announce .a { animation: announce 2.2s ease forwards; }
#announce .a b { display: block; font-weight: 800; font-size: clamp(30px, 5vw, 56px); letter-spacing: -0.04em; text-shadow: 0 4px 30px rgba(0, 0, 0, 0.7); }
#announce .a span { font-size: 12px; letter-spacing: 0.3em; font-weight: 600; color: #fff; opacity: .75; }
#floaters { position: fixed; inset: 0; z-index: 21; pointer-events: none; overflow: hidden; }
#floaters span { position: absolute; font-weight: 700; font-size: 15px; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9); animation: floatUp .8s ease-out forwards; white-space: nowrap; transform: translate(-50%, -50%); font-variant-numeric: tabular-nums; }
#toasts { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(560px, 92vw); }
.toast { padding: 10px 16px; border-radius: 12px; background: rgba(18, 20, 25, 0.96); border: 1px solid var(--line-2); font-size: 13.5px; animation: toastIn .22s ease, toastOut .4s ease 3.4s forwards; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); text-align: center; color: var(--text-2); }
.toast.good { border-color: rgba(52, 211, 153, 0.4); }
.toast.bad { border-color: rgba(248, 113, 113, 0.45); }
.toast.gold { border-color: rgba(251, 191, 36, 0.45); }

/* touch controls */
#touch { position: fixed; inset: 0; z-index: 22; pointer-events: none; display: none; }
body.touch.playing #touch { display: block; }
body.touch .hud-abil { display: none; }
/* touch: quick-buy row sits above the joystick / action buttons */
body.touch .hud-quick { left: 50%; right: auto; bottom: 236px; transform: translateX(-50%); gap: 6px; }
body.touch .hud-quick .qbtn { min-width: 0; padding: 7px 12px; border-radius: 999px; }
body.touch .hud-quick .qbtn .p { display: none; }
body.touch .hud-quick .qbtn .kbd { display: none; }
body.touch.playing #toasts { bottom: auto; top: 42%; }
.joy { position: absolute; left: 22px; bottom: 26px; width: 148px; height: 148px; border-radius: 50%; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line-2); pointer-events: auto; touch-action: none; backdrop-filter: blur(8px); }
.joy i { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); border: 1px solid rgba(255, 255, 255, 0.35); }
.tbtns { position: absolute; right: 18px; bottom: 22px; width: 210px; height: 200px; pointer-events: none; }
.tbtn { position: absolute; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 12px; background: rgba(18, 20, 25, 0.7); border: 1px solid var(--line-2); pointer-events: auto; touch-action: none; color: var(--text); backdrop-filter: blur(8px); }
.tbtn.fire { width: 96px; height: 96px; right: 0; bottom: 0; border-color: rgba(248, 113, 113, 0.6); color: #fecaca; font-size: 14px; }
.tbtn.jump { width: 62px; height: 62px; right: 108px; bottom: 6px; }
.tbtn.dash { width: 62px; height: 62px; right: 104px; bottom: 82px; }
.tbtn.spec { width: 62px; height: 62px; right: 30px; bottom: 112px; }
.tbtn.on { background: rgba(255, 255, 255, 0.2); }

/* ------------------------------------------------------------ admin */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); width: fit-content; max-width: 100%; }
.tabs button { background: none; border: 0; height: 32px; padding: 0 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; font-size: 13.5px; }
.tabs button.on { color: var(--text); background: rgba(255, 255, 255, 0.1); }
.tbl-wrap { overflow: auto; max-height: 56vh; border: 1px solid var(--line); border-radius: 12px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { position: sticky; top: 0; background: #171a21; text-align: left; font-weight: 500; color: var(--muted); padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; font-size: 12px; }
table.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tr:hover td { background: rgba(255, 255, 255, 0.02); }
.inp { width: 100%; min-width: 64px; height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-2); background: rgba(0, 0, 0, 0.25); font-size: 13px; font-variant-numeric: tabular-nums; }
textarea.inp { height: auto; padding: 10px; }
.inp:focus { outline: none; border-color: rgba(255, 255, 255, 0.35); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08); }
select.inp { padding-right: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.field .inp { color: var(--text); }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.toggle { position: relative; display: inline-block; vertical-align: middle; width: 38px; height: 22px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.14); cursor: pointer; transition: .2s; }
.toggle span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(16px); }
.section-title { font-size: 13px; font-weight: 600; color: var(--text); margin: 20px 0 10px; letter-spacing: -0.01em; }
.section-title:first-child { margin-top: 0; }
.admin-note { font-size: 12.5px; color: var(--muted); padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); margin-top: 12px; line-height: 1.6; }
.hist { font-size: 13px; max-height: 260px; overflow: auto; }
.hist div { display: grid; grid-template-columns: 150px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.hist div span:first-child { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pin-box { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 14px 0; }
.pin-box .inp { width: 180px; height: 48px; text-align: center; font-size: 22px; letter-spacing: 10px; }

/* ------------------------------------------------------------ animations */
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes pulseRed { 50% { box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.45); } }
@keyframes ringPulse { 50% { box-shadow: 0 0 0 6px rgba(10, 11, 15, 0.9), 0 0 0 14px rgba(248, 250, 252, 0.35), 0 24px 60px rgba(0, 0, 0, 0.6); } }
@keyframes lowHp { 0%, 100% { opacity: .25; } 50% { opacity: .65; } }
@keyframes announce { 0% { opacity: 0; transform: scale(1.15); filter: blur(6px); } 12% { opacity: 1; transform: scale(1); filter: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-16px); } }
@keyframes floatUp { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -46px; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }
@keyframes starPop { from { transform: scale(0) rotate(-30deg); opacity: 0; } 70% { transform: scale(1.25); } }
@keyframes flashBtn { 50% { border-color: var(--red); background: rgba(248, 113, 113, 0.18); } }
@keyframes dashMove { to { stroke-dashoffset: -28; } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------ responsive */
/* modals never grow wider than the screen; wide content (tables) scrolls inside */
.modal-backdrop { grid-template-columns: minmax(0, 1fr); }
.modal { min-width: 0; justify-self: center; }
.modal-body > * { max-width: 100%; }

/* large desktops: give the map and HUD a little more room */
@media (min-width: 1800px) {
  .map-wrap { max-width: 1720px; grid-template-columns: minmax(0, 1fr) 380px; }
  .title-wrap { max-width: 1480px; }
}

/* small laptops / tablets */
@media (max-width: 1100px) {
  .map-wrap { grid-template-columns: 1fr; }
  .side { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
  .levels { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .wm { height: 68vh; height: 68dvh; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* HUD: below ~1000px the mission/boss column moves under the status row */
@media (max-width: 999px) {
  .hud-top { flex-wrap: wrap; row-gap: 10px; }
  .hud-left { width: 270px; }
  .hud-right { margin-left: auto; }
  .hud-center { order: 3; flex-basis: 100%; }
}

/* phones (portrait) */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .screen { padding: 74px 14px 28px; }
  #topbar { padding: 0 12px; gap: 6px; }
  #topbar .brand span { display: none; }
  #topbar .hide-sm { display: none; }
  #topbar .wallet-btn .wl { display: none; }
  #topbar .chip { padding: 0 9px; }
  #topbar .wallet-btn { width: 36px; padding: 0; }
  .title-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .title-cards .stat-card:nth-child(2) { grid-column: 1 / -1; order: 3; }
  .stat-card .v { font-size: 22px; }
  .stat-card .v.small { font-size: 18px; }
  .step-card { grid-template-columns: 1fr; }
  .step-art { width: 72px; height: 72px; border-radius: 18px; }
  .step-art svg { width: 32px; height: 32px; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wd-grid { grid-template-columns: 1fr; }
  .wm { height: 62vh; height: 62dvh; min-height: 380px; border-radius: 14px; }
  .wm-card { width: calc(100% - 24px); bottom: 12px; grid-template-columns: 72px 1fr; }
  .wm-card .thumb { width: 72px; height: 56px; }
  .wm-mini { display: none; }
  .wm-hint { display: none; }
  .modal-backdrop { padding: 8px 8px max(8px, env(safe-area-inset-bottom)); }
  .modal { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); border-radius: 18px; }
  .modal-head { padding: 16px 16px 8px; }
  .modal-head h3 { font-size: 16.5px; }
  .modal-body { padding: 4px 16px 12px; }
  .modal-foot { padding: 12px 16px 14px; }
  .modal-foot .spacer { display: none; }
  .modal-foot .btn { flex: 1 1 auto; }
  .quick-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hud-right .chip { display: none; }
}

/* compact HUD for phones in either orientation */
@media (max-width: 760px), (max-height: 520px) {
  .hud-top { top: 8px; left: 8px; right: 8px; gap: 8px; row-gap: 8px; }
  .hud-left { width: min(230px, calc(100vw - 70px)); gap: 6px; }
  .hud-status { padding: 8px 10px; }
  .hud-status .lvl { font-size: 11px; margin-bottom: 2px; }
  .meter { margin-top: 5px; }
  .meter .row { font-size: 10.5px; margin-bottom: 2px; }
  .meter .row b { font-size: 11px; }
  .bar { height: 6px; }
  .bar.thin { height: 5px; }
  .hud-extra .panel { padding: 7px 10px; }
  .hud-mission { gap: 6px; }
  .hud-mission .timer { font-size: 18px; padding: 7px 10px; border-radius: 10px; }
  .hud-mission .obj { padding: 6px 12px; }
  .hud-mission .obj b { font-size: 13.5px; }
  .hud-mission .obj span { font-size: 11.5px; }
  .hud-boss .name { font-size: 11.5px; margin-bottom: 4px; }
  .hud-boss .bar { height: 8px; }
  .hud-quick { left: 8px; bottom: 8px; }
  .qbtn { min-width: 0; padding: 7px 10px; }
  .hud-abil { right: 8px; bottom: 8px; }
  .abil { width: 64px; padding: 6px 4px; }
  #announce .a b { font-size: clamp(24px, 7vw, 40px); }
}

/* phones in landscape: keep everything in one top row, controls in the corners */
@media (max-height: 520px) {
  .screen { padding-top: 70px; }
  .hud-top { flex-wrap: nowrap; }
  .hud-left { width: 210px; }
  .hud-center { order: 0; flex-basis: 0; }
  .hud-right .chip { display: none; }
  .title-wrap { min-height: 0; justify-content: flex-start; }
  .logo { font-size: 46px; margin: 12px 0 4px; }
  .logo small { margin-top: 8px; }
  .title-sub { font-size: 14px; margin: 8px 0 14px; }
  .title-actions { margin-bottom: 14px; }
  .title-actions .btn-lg { height: 42px; font-size: 14px; }
  .stat-card { padding: 10px 14px; }
  .feature-row { display: none; }
  .wm { height: calc(100dvh - 90px); min-height: 260px; }
  .wm-mini, .wm-hint { display: none; }
  body.touch .hud-quick { bottom: 12px; gap: 4px; }
  body.touch .hud-quick .qbtn { padding: 6px 9px; }
  .qbtn .t { font-size: 12px; }
  .joy { left: 14px; bottom: 14px; width: 120px; height: 120px; }
  .joy i { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
  .tbtns { right: 12px; bottom: 12px; transform: scale(.82); transform-origin: 100% 100%; }
  body.touch.playing #toasts { top: auto; bottom: 70px; }
  /* level bars as slim one-liners so the left column clears the joystick */
  .hud-extra { gap: 4px; }
  .hud-extra .panel { padding: 5px 10px; }
  .hud-extra .meter { margin-top: 0; }
  .hud-extra .bar { height: 4px; }
}

/* very short landscape screens (e.g. 568×320) */
@media (max-height: 380px) {
  .kicker, .title-sub { display: none; }
  .logo { font-size: 38px; margin-top: 4px; }
  .logo small { font-size: 0.24em; }
  .title-actions { margin-bottom: 10px; }
  .joy { width: 108px; height: 108px; }
  .joy i { width: 44px; height: 44px; margin: -22px 0 0 -22px; }
  .tbtns { transform: scale(.74); }
  .hud-status .lvl { display: none; }
  .hud-status .meter:first-of-type { margin-top: 0; }
}

@media (max-width: 560px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* very small phones */
@media (max-width: 400px) {
  .screen { padding-left: 12px; padding-right: 12px; }
  .grid-2 { grid-template-columns: 1fr; }
  .title-actions .btn-lg { padding: 0 16px; }
  .joy { left: 12px; bottom: 16px; width: 120px; height: 120px; }
  .joy i { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
  .tbtns { right: 10px; bottom: 14px; transform: scale(.8); transform-origin: 100% 100%; }
  body.touch .hud-quick { bottom: 196px; }
  .qbtn .t { font-size: 12.5px; }
}
