/* Edge Case — blueprint theme, mobile-first. */
:root {
  --bg: #0b1220;
  --bg2: #101a30;
  --grid: rgba(106, 168, 255, 0.07);
  --panel: #142039;
  --panel2: #1b2a4a;
  --line: rgba(255, 255, 255, 0.09);
  --text: #eef2ff;
  --muted: #9aa7c7;
  --dim: #66739a;
  --orange: #f6821f;
  --orange2: #fbad41;
  --ink: #2b1400;
  --ok: #3ddc97;
  --bad: #ff6b6b;
  --warn: #ffd166;
  --poor: #ff8c42;
  --blue: #6aa8ff;
  --tile: #ffffff;
  --ext: #22314f;
  --ext-ink: #c9d4f2;
  --r: 18px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

/* CJK: lang-specific fonts so Han glyphs use the right regional forms; Korean wraps at spaces. */
:root:lang(zh-Hans) { --font: ui-rounded, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif; }
:root:lang(ja) { --font: ui-rounded, "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", "Noto Sans JP", system-ui, sans-serif; }
:root:lang(ko) { --font: ui-rounded, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif; }
:root:lang(ko) body { word-break: keep-all; overflow-wrap: anywhere; }
:root:lang(ja) body, :root:lang(zh-Hans) body { line-break: strict; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(246, 130, 31, 0.13), transparent 60%),
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--orange2); }
h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--orange2); outline-offset: 2px; }

#app {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: var(--sat);
  animation: screen-in 0.28s ease-out both;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } }

/* ── icons & tiles ── */
.ico {
  display: block;
  width: 58%;
  height: 58%;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--tile);
  color: var(--orange);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25), 0 6px 16px rgba(0, 0, 0, 0.28);
  flex: none;
}
.tile.sm { width: 38px; height: 38px; border-radius: 11px; font-weight: 800; color: var(--dim); }
.tile.big { width: 76px; height: 76px; border-radius: 22px; }
.badge {
  position: absolute;
  top: -7px;
  right: -9px;
  background: var(--ink);
  color: var(--orange2);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 2px 5px;
  border-radius: 6px;
  white-space: nowrap;
}
.cat-clef .tile { color: #8b5cf6; }

/* ── buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, filter 0.2s, opacity 0.2s;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn.primary {
  background: linear-gradient(180deg, var(--orange2), var(--orange));
  color: var(--ink);
  box-shadow: 0 4px 0 #b65a0c, 0 10px 24px rgba(246, 130, 31, 0.35);
}
.btn.primary:disabled { filter: grayscale(0.9) brightness(0.65); box-shadow: none; }
.btn.ghost { background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); }
.btn.danger { background: rgba(255, 107, 107, 0.15); color: #ffb3b3; border: 1px solid rgba(255, 107, 107, 0.35); }
.btn.big { min-height: 58px; font-size: 18px; padding: 0 30px; }
.btn.wide { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  font-size: 22px;
  font-weight: 700;
  flex: none;
  position: relative;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn.hint .cost {
  position: absolute;
  bottom: -6px;
  right: -6px;
  font-size: 10px;
  font-weight: 900;
  background: var(--warn);
  color: #3b2a00;
  border-radius: 8px;
  padding: 1px 4px;
}
.icon-btn:disabled { opacity: 0.4; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}
.pill.coin { color: var(--warn); }
.pill.flame { color: #ffb36b; }
.pill.soft { font-weight: 600; color: var(--muted); font-size: 12px; white-space: normal; }
.pill.big { font-size: 16px; padding: 8px 14px; }
.pill.sync.synced { color: var(--ok); }
.pill.sync.offline, .pill.sync.limited { color: var(--warn); }
.pill.sync.limited { white-space: normal; text-align: right; }
.spacer { width: 44px; }

/* ── top bars ── */
.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 8px;
  flex: none;
}
.bar-title { flex: 1; display: flex; flex-direction: column; min-width: 0; text-align: center; }
.bar-title small { color: var(--muted); font-size: 12px; font-weight: 700; }
.bar-title span { font-weight: 900; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── title screen ── */
.title-screen { justify-content: space-between; align-items: center; text-align: center; padding: calc(var(--sat) + 8vh) 24px calc(var(--sab) + 7vh); }
.title-top { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.logo svg { width: min(68vw, 300px); height: auto; filter: drop-shadow(0 18px 40px rgba(246, 130, 31, 0.35)); }
.logo .cloud { transform-origin: 50% 60%; animation: bob 4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) scale(1.015); } }
.title-screen h1 { font-size: clamp(44px, 13vw, 64px); font-weight: 900; letter-spacing: -0.03em; }
.title-screen h1 span { color: var(--orange); }
.tagline { color: var(--muted); font-weight: 700; letter-spacing: 0.02em; }
.resume { color: var(--text); }
.parade { display: grid; grid-template-columns: repeat(6, 44px); gap: 14px 12px; justify-content: center; margin: 18px 0; }
.parade .tile { width: 44px; height: 44px; border-radius: 13px; animation: float 3.6s ease-in-out infinite; animation-delay: calc(var(--i) * -0.37s); opacity: 0.92; }
.parade .tile:nth-child(odd) { transform: rotate(-4deg); }
.parade .badge { font-size: 7px; top: -5px; right: -7px; }
@keyframes float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }
@media (max-height: 700px) { .parade { display: none; } }
.title-bottom { display: flex; flex-direction: column; gap: 12px; align-items: center; width: 100%; }
.title-bottom .btn { animation: breathe 2.2s ease-in-out infinite; max-width: 100%; }
@keyframes breathe { 50% { transform: scale(1.04); } }

/* ── map ── */
.hud {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(11, 18, 32, 0.96), rgba(11, 18, 32, 0.75));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  flex: none;
  z-index: 2;
}
.rank { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-align: left; }
.rank-emoji { font-size: 26px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line); flex: none; }
.rank-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.rank-txt b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-txt small { color: var(--muted); font-size: 11px; font-weight: 700; }
.meter { display: block; height: 7px; border-radius: 9px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--orange), var(--orange2)); transition: width 0.6s ease; }
.map-body { flex: 1; overflow-y: auto; padding: 14px 16px calc(var(--sab) + 30px); -webkit-overflow-scrolling: touch; }
.cards { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 16px 18px;
  border-radius: var(--r);
  text-align: left;
  background: linear-gradient(135deg, #2a1a0b, #3b200a 40%, #5a2d08);
  border: 1px solid rgba(251, 173, 65, 0.35);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle, rgba(251, 173, 65, 0.35), transparent 70%); }
.hero-kicker { font-size: 12px; font-weight: 800; color: var(--orange2); text-transform: uppercase; letter-spacing: 0.08em; }
.hero-title { font-size: 21px; font-weight: 900; }
.hero-sub { color: #f1c79a; font-size: 13px; font-weight: 600; }
.hero-cta { position: absolute; right: 16px; bottom: 16px; background: var(--orange); color: var(--ink); font-weight: 900; padding: 8px 14px; border-radius: 999px; z-index: 1; animation: breathe 2.2s ease-in-out infinite; }
.hero.done .hero-cta { display: none; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); text-align: left; }
.mini:active, .hero:active { transform: scale(0.98); }
.mini-ico { font-size: 22px; }
.mini-title { font-weight: 900; }
.mini-sub { font-size: 12px; color: var(--muted); font-weight: 600; }
.mini.daily.ready { border-color: rgba(255, 179, 107, 0.5); background: linear-gradient(160deg, #2a1c18, var(--panel)); }
.mini.daily.ready .mini-ico { animation: flicker 1.4s ease-in-out infinite; }
@keyframes flicker { 50% { transform: scale(1.15) rotate(-6deg); } }

.mini.debug { border: 1.5px dashed rgba(139, 92, 246, 0.7); background: linear-gradient(160deg, #221a3d, var(--panel)); }
.mini.debug .mini-title { color: #c4b5fd; }
.debug-badge { position: fixed; top: calc(var(--sat) + 2px); right: 4px; z-index: 90; pointer-events: none; font-size: 9px; font-weight: 900; letter-spacing: 0.1em; color: #fff; background: #7c3aed; padding: 2px 6px; border-radius: 999px; opacity: 0.85; }
.dbg-group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 14px 0 6px; }
.dbg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dbg-lv { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 10px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); text-align: left; font-size: 12.5px; }
.dbg-lv.wide { width: 100%; }
.dbg-lv:active { transform: scale(0.97); }
.dbg-lv.locked { border-style: dashed; }
.dbg-id { flex: none; min-width: 26px; font-weight: 900; color: var(--orange2); }
.dbg-name { flex: 1; font-weight: 700; line-height: 1.2; }
.dbg-meta { flex: none; font-size: 11px; color: var(--warn); }
.chapter { margin: 8px 0 18px; padding: 14px 12px 8px; border-radius: 22px; background: linear-gradient(180deg, hsla(var(--hue), 70%, 50%, 0.1), rgba(20, 32, 57, 0.6)); border: 1px solid hsla(var(--hue), 70%, 60%, 0.22); }
.ch-head { display: flex; align-items: center; gap: 12px; padding: 0 4px 6px; }
.ch-head > div { flex: 1; display: flex; flex-direction: column; }
.ch-head small { color: hsl(var(--hue), 80%, 72%); font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.ch-head b { font-size: 19px; }
.ch-emoji { font-size: 30px; }
.ch-stars { font-weight: 900; color: var(--warn); font-size: 14px; }
.ch-lock { padding: 22px; text-align: center; color: var(--muted); font-weight: 700; }
.chapter.locked { opacity: 0.6; }
.lv-wrap { position: relative; margin: 4px 0; }
.lv-path { position: absolute; inset: 0; width: 100%; height: 100%; }
.lv-path polyline { fill: none; stroke: hsla(var(--hue), 70%, 70%, 0.35); stroke-width: 3; stroke-dasharray: 2 8; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.lv { position: absolute; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; width: 110px; }
.lv-dot {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 900;
  background: var(--panel2);
  border: 3px solid rgba(255, 255, 255, 0.12);
  color: var(--muted);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.15s;
}
.lv:active .lv-dot { transform: scale(0.92); }
.lv.open .lv-dot { background: #fff; color: var(--ink); border-color: #fff; }
.lv.done .lv-dot { background: linear-gradient(180deg, var(--orange2), var(--orange)); border-color: #ffd29a; color: var(--ink); }
.lv.current .lv-dot { background: linear-gradient(180deg, var(--orange2), var(--orange)); color: var(--ink); border-color: #fff; animation: pulse-ring 1.6s ease-out infinite, hop 1.6s ease-in-out infinite; }
.lv.t-boss .lv-dot { width: 66px; height: 66px; font-size: 26px; }
.lv.t-incident.open:not(.done) .lv-dot { border-color: var(--bad); }
.lv.locked .lv-dot { font-size: 18px; opacity: 0.7; }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(251, 173, 65, 0.7), 0 4px 0 rgba(0, 0, 0, 0.35); } 100% { box-shadow: 0 0 0 18px rgba(251, 173, 65, 0), 0 4px 0 rgba(0, 0, 0, 0.35); } }
@keyframes hop { 50% { transform: translateY(-5px); } }
.lv-stars { display: flex; gap: 1px; margin-top: 3px; font-size: 13px; color: rgba(255, 255, 255, 0.18); }
.lv-stars .on { color: var(--warn); text-shadow: 0 0 8px rgba(255, 209, 102, 0.6); font-style: normal; }
.lv-stars i { font-style: normal; }
.lv.locked .lv-stars { visibility: hidden; }
.lv-name { font-size: 11px; font-weight: 800; color: var(--muted); text-align: center; line-height: 1.15; max-width: 110px; }
.lv.open .lv-name, .lv.done .lv-name { color: var(--text); }
.foot { text-align: center; margin-top: 10px; }

/* ── level screen ── */
.level-screen { background: linear-gradient(180deg, transparent, rgba(11, 18, 32, 0.6)); }
.brief {
  margin: 0 12px;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--panel);
  border: 1px solid var(--line);
  flex: none;
}
.brief.type-incident { border-color: rgba(255, 107, 107, 0.45); background: linear-gradient(160deg, #2b1620, var(--panel)); }
.brief.type-boss { border-color: rgba(255, 209, 102, 0.45); }
.brief.type-clef { border-color: rgba(139, 92, 246, 0.5); background: linear-gradient(160deg, #1f1838, var(--panel)); }
.brief-head { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; }
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--panel2); flex: none; }
.who { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tbadge { font-style: normal; font-size: 10px; font-weight: 900; letter-spacing: 0.05em; padding: 3px 7px; border-radius: 7px; background: rgba(255, 255, 255, 0.08); }
.type-incident .tbadge { background: rgba(255, 107, 107, 0.2); color: #ffb3b3; }
.type-boss .tbadge { background: rgba(255, 209, 102, 0.18); color: var(--warn); }
.type-clef .tbadge { background: rgba(139, 92, 246, 0.25); color: #c4b5fd; }
.chev { color: var(--muted); transition: transform 0.2s; }
.brief-body { margin-top: 8px; }
.brief-body p { font-size: 14px; color: #dbe3ff; margin-bottom: 8px; }
.reqs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.reqs::-webkit-scrollbar { display: none; }
.req { white-space: nowrap; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); }
.brief.collapsed .brief-body { display: none; }
.brief.collapsed .chev { transform: rotate(-90deg); }

.board { position: relative; flex: 1; min-height: 200px; margin: 4px 6px 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.board::-webkit-scrollbar { display: none; }
.board-inner { position: relative; width: 100%; }
.board.scrolls { -webkit-mask: linear-gradient(180deg, #000 calc(100% - 26px), transparent); mask: linear-gradient(180deg, #000 calc(100% - 26px), transparent); }
.wires { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; }
.wire { fill: none; stroke: rgba(154, 167, 199, 0.35); stroke-width: 2.5; }
.wire-flow { fill: none; stroke: rgba(251, 173, 65, 0.55); stroke-width: 2.5; stroke-dasharray: 3 11; stroke-linecap: round; animation: flow 1.2s linear infinite; }
.wire-flow.hot { stroke: #fff; stroke-width: 3.5; }
.wire-arrow { fill: none; stroke: rgba(201, 212, 242, 0.65); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes flow { to { stroke-dashoffset: -14; } }
.nodes { position: absolute; inset: 0; }
.node { position: absolute; transform: translate(-50%, calc(var(--t, 64px) / -2)); display: flex; flex-direction: column; align-items: center; width: var(--capw, 120px); pointer-events: none; transition: opacity 0.25s; }
.node .tile { width: var(--t, 64px); height: var(--t, 64px); border-radius: calc(var(--t, 64px) * 0.28); pointer-events: auto; transition: transform 0.15s, box-shadow 0.25s, background 0.2s; }
.node.ext .tile { background: var(--ext); color: var(--ext-ink); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 6px 16px rgba(0, 0, 0, 0.25); }
.node.slot.empty .tile {
  background: rgba(246, 130, 31, 0.08);
  border: 2.5px dashed rgba(251, 173, 65, 0.75);
  box-shadow: none;
  color: var(--orange2);
}
.node.slot .tile:active { transform: scale(0.94); }
.plus { font-size: 30px; font-weight: 400; line-height: 1; opacity: 0.85; }
.board.armed .node.slot .tile { animation: slot-glow 1.1s ease-in-out infinite; }
.node.focus .tile { transform: scale(1.1); box-shadow: 0 0 0 4px var(--orange2), 0 0 30px rgba(251, 173, 65, 0.6) !important; }
@keyframes slot-glow { 50% { box-shadow: 0 0 0 4px rgba(251, 173, 65, 0.55), 0 0 26px rgba(251, 173, 65, 0.45); } }
.cap { margin-top: 6px; text-align: center; line-height: 1.15; font-size: 11.5px; display: flex; flex-direction: column; gap: 1px; padding: 2px 6px 3px; border-radius: 8px; background: rgba(11, 18, 32, 0.78); max-width: 100%; }
.cap b { font-size: 12px; font-weight: 800; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cap span { color: var(--muted); font-size: 10.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cap .need { color: var(--orange2); font-weight: 800; font-size: 11.5px; -webkit-line-clamp: 3; }
.node.ext .cap b { color: var(--ext-ink); font-weight: 700; }
.node.pop .tile { animation: pop 0.38s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { 0% { transform: scale(0.6); } 100% { transform: scale(1); } }
.node.lit .tile { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.75), 0 0 24px rgba(251, 173, 65, 0.5); }
.node.dim { opacity: 0.45; }
.node.ok .tile { box-shadow: 0 0 0 4px var(--ok), 0 0 24px rgba(61, 220, 151, 0.55) !important; }
.node.alt .tile { box-shadow: 0 0 0 4px var(--warn), 0 0 24px rgba(255, 209, 102, 0.45) !important; }
.node.poor .tile { box-shadow: 0 0 0 4px var(--poor), 0 0 24px rgba(255, 140, 66, 0.5) !important; }
.node.bad .tile { box-shadow: 0 0 0 4px var(--bad), 0 0 28px rgba(255, 107, 107, 0.65) !important; animation: shake 0.45s; }
.node.ok .tile::after, .node.alt .tile::after, .node.poor .tile::after, .node.bad .tile::after {
  position: absolute; top: -8px; left: -8px; width: 22px; height: 22px; border-radius: 50%; z-index: 1;
  display: grid; place-items: center; font-size: 13px; font-weight: 900; color: #0b1220;
}
.node.ok .tile::after { content: "✓"; background: var(--ok); }
.node.alt .tile::after { content: "~"; background: var(--warn); }
.node.poor .tile::after { content: "↓"; background: var(--poor); }
.node.bad .tile::after { content: "!"; background: var(--bad); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.packet { pointer-events: none; }
.deploying .dock, .deploying .brief { opacity: 0.55; pointer-events: none; transition: opacity 0.3s; }

.dock {
  flex: none;
  padding: 6px 12px calc(var(--sab) + 12px);
  background: linear-gradient(180deg, rgba(11, 18, 32, 0), rgba(11, 18, 32, 0.92) 28%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.infobar { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); font-size: 13px; }
.info-text { flex: 1; line-height: 1.25; }
.info-text b { color: var(--orange2); }
.info-more { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, 0.1); font-size: 16px; flex: none; }
.tray { display: flex; gap: 8px; overflow-x: auto; padding: 8px 2px 6px; touch-action: pan-x; scrollbar-width: none; scroll-snap-type: x proximity; }
.tray::-webkit-scrollbar { display: none; }
.chip { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 74px; flex: none; scroll-snap-align: start; transition: transform 0.15s; touch-action: pan-x; }
.chip .tile { width: 54px; height: 54px; transition: transform 0.18s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.2s; }
.chip-name { font-size: 11px; font-weight: 800; text-align: center; line-height: 1.1; color: #dbe3ff; }
.chip.armed .tile { transform: translateY(-8px) scale(1.06); box-shadow: 0 0 0 3px var(--orange2), 0 14px 26px rgba(246, 130, 31, 0.45); }
.chip.armed .chip-name { color: var(--orange2); }
.chip:active .tile { transform: scale(0.94); }
.deploy { width: 100%; min-height: 54px; font-size: 17px; }
.deploy.ready { animation: breathe 1.8s ease-in-out infinite; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; width: 60px; height: 60px; box-shadow: 0 0 0 3px var(--orange2), 0 18px 40px rgba(0, 0, 0, 0.5); opacity: 0.95; }

/* coach marks */
.coach { position: fixed; z-index: 55; pointer-events: none; transform: translate(-50%, -50%); }
.coach-ring { width: var(--w); height: var(--h); border-radius: 20px; border: 3px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.0), 0 0 24px rgba(255, 255, 255, 0.6); animation: coach 1.2s ease-in-out infinite; }
.coach-text { position: absolute; left: 50%; top: calc(100% + 12px); transform: translateX(calc(-50% + var(--shift, 0px))); white-space: nowrap; background: #fff; color: var(--ink); font-weight: 900; padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow); font-size: 14px; }
.coach-text::before { content: ""; position: absolute; left: calc(50% - var(--shift, 0px)); top: -6px; width: 12px; height: 12px; background: #fff; transform: translateX(-50%) rotate(45deg); }
.coach.above .coach-text { top: auto; bottom: calc(100% + 12px); }
.coach.above .coach-text::before { top: auto; bottom: -6px; }
@keyframes coach { 50% { transform: scale(1.08); opacity: 0.7; } }

/* ── sheets ── */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(4, 8, 18, 0); display: flex; align-items: flex-end; justify-content: center; transition: background 0.22s; }
.backdrop.in { background: rgba(4, 8, 18, 0.62); }
.backdrop.out { background: rgba(4, 8, 18, 0); }
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  background: linear-gradient(180deg, #1a2745, #121c33);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  padding: 18px 18px calc(var(--sab) + 16px);
  transform: translateY(105%);
  transition: transform 0.3s cubic-bezier(0.2, 1.2, 0.4, 1);
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.5);
  -webkit-user-select: text;
  user-select: text;
}
.backdrop.in .sheet { transform: none; }
.backdrop.out .sheet { transform: translateY(105%); transition-duration: 0.2s; }
.sheet::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.2); margin: -6px auto 12px; }
.sheet-title { font-size: 19px; font-weight: 900; margin-bottom: 10px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; position: sticky; bottom: calc(-16px - var(--sab)); padding: 10px 0 calc(var(--sab) + 2px); background: linear-gradient(180deg, rgba(18, 28, 51, 0), #121c33 30%); }
.sheet-actions .btn { flex: 1; padding: 0 10px; }
.sheet-actions .btn.primary { flex: 1.4; }

.toasts { position: fixed; top: calc(var(--sat) + 64px); left: 0; right: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { max-width: 520px; background: rgba(20, 32, 57, 0.97); border: 1px solid rgba(251, 173, 65, 0.4); padding: 10px 16px; border-radius: 14px; font-weight: 700; font-size: 14px; box-shadow: var(--shadow); transform: translateY(-20px); opacity: 0; transition: transform 0.25s, opacity 0.25s; text-align: center; }
.toast.in { transform: none; opacity: 1; }
.toast.bad { border-color: rgba(255, 107, 107, 0.5); }

/* component card */
.ccard { display: flex; flex-direction: column; gap: 12px; }
.ccard-new { align-self: center; font-size: 12px; font-weight: 900; letter-spacing: 0.14em; color: var(--ink); background: linear-gradient(90deg, var(--orange2), var(--orange)); padding: 5px 12px; border-radius: 999px; animation: breathe 1.6s ease-in-out infinite; }
.ccard-head { display: flex; gap: 14px; align-items: center; }
.reveal .ccard-head .tile { animation: reveal 0.7s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes reveal { 0% { transform: scale(0.3) rotate(-25deg); } 100% { transform: none; } }
.ccard-cat { font-size: 11px; font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase; color: var(--orange2); }
.ccard-name { font-size: 24px; font-weight: 900; }
.ccard-tag { color: var(--muted); font-weight: 600; }
.ccard-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ccard-cols ul { margin: 4px 0 0; padding-left: 18px; font-size: 13px; color: #dbe3ff; }
.ccard-cols li { margin-bottom: 3px; }
.ccard-h { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.06em; }
.ccard-h.ok { color: var(--ok); }
.ccard-h.bad { color: var(--bad); }
.ccard-fact { background: rgba(255, 209, 102, 0.08); border: 1px solid rgba(255, 209, 102, 0.25); padding: 10px 12px; border-radius: 12px; font-size: 13px; }
.ccard-docs { font-size: 13px; font-weight: 700; }

/* results */
.result.win .sheet-body { text-align: center; }
.win-title { font-size: 24px; font-weight: 900; }
.stars { display: flex; justify-content: center; gap: 10px; margin: 10px 0 8px; }
.star { font-size: 54px; line-height: 1; color: rgba(255, 255, 255, 0.12); transition: color 0.2s; }
.star.on { color: var(--warn); text-shadow: 0 0 22px rgba(255, 209, 102, 0.8); animation: star-pop 0.5s cubic-bezier(0.3, 1.8, 0.5, 1); }
.star:nth-child(2) { transform: translateY(-10px); }
.star:nth-child(2).on { animation-name: star-pop2; }
@keyframes star-pop { 0% { transform: scale(0.2) rotate(-40deg); } }
@keyframes star-pop2 { 0% { transform: translateY(-10px) scale(0.2) rotate(-40deg); } 100% { transform: translateY(-10px); } }
.rewards { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 12px; }
.lesson { text-align: left; background: rgba(106, 168, 255, 0.08); border: 1px solid rgba(106, 168, 255, 0.25); border-radius: 14px; padding: 12px 14px; margin-top: 4px; }
.lesson-h { font-weight: 900; margin-bottom: 4px; color: #b9d3ff; }
.lesson p { margin: 0; font-size: 14px; }
.code-wrap { text-align: left; margin-top: 10px; }
.code-wrap summary { font-weight: 800; color: var(--orange2); cursor: pointer; padding: 6px 0; }
.code { font-family: var(--mono); font-size: 12px; line-height: 1.5; background: #0a1120; border: 1px solid var(--line); border-radius: 12px; padding: 12px; overflow-x: auto; margin: 6px 0 0; color: #dbe7ff; white-space: pre; }
.review-h { text-align: left; font-weight: 900; margin: 16px 0 6px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.review { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.rv { display: flex; gap: 10px; padding: 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.rv.bad { border-color: rgba(255, 107, 107, 0.4); background: rgba(255, 107, 107, 0.06); }
.rv.alt { border-color: rgba(255, 209, 102, 0.35); }
.rv.poor { border-color: rgba(255, 140, 66, 0.45); background: rgba(255, 140, 66, 0.05); }
.rv-body { flex: 1; min-width: 0; }
.rv-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.rv-need { font-size: 12px; color: var(--muted); font-weight: 700; }
.rv-msg { font-size: 13.5px; margin-top: 3px; color: #dbe3ff; }
.vpill { font-size: 11px; font-weight: 900; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.vpill.ok { background: rgba(61, 220, 151, 0.18); color: var(--ok); }
.vpill.alt { background: rgba(255, 209, 102, 0.18); color: var(--warn); }
.vpill.poor { background: rgba(255, 140, 66, 0.18); color: var(--poor); }
.vpill.bad { background: rgba(255, 107, 107, 0.18); color: var(--bad); }
.progress-line { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-weight: 800; font-size: 13px; color: var(--muted); }
.progress-line .meter { flex: 1; height: 10px; }
.progress-line .meter i { background: linear-gradient(90deg, var(--ok), #8ef0c4); }
.promo .sheet-body { padding: 10px 0; }
.promo-emoji { font-size: 64px; display: block; animation: reveal 0.7s cubic-bezier(0.3, 1.6, 0.5, 1); }
.promo-kicker { font-weight: 900; letter-spacing: 0.16em; color: var(--orange2); font-size: 13px; margin-top: 6px; }
.promo-name { font-size: 28px; font-weight: 900; margin: 4px 0 8px; }
.briefing h2 { font-size: 26px; margin: 2px 0 2px; }
.brf-avatar { font-size: 54px; width: 84px; height: 84px; margin: 0 auto 6px; display: grid; place-items: center; border-radius: 26px; background: var(--panel2); border: 1px solid var(--line); animation: reveal 0.6s cubic-bezier(0.3, 1.6, 0.5, 1); }
.brf-kicker { font-size: 12px; font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase; color: var(--orange2); margin-bottom: 4px; }
.briefing.type-incident .brf-kicker { color: var(--bad); }
.briefing.type-clef .brf-kicker { color: #c4b5fd; }
.brf-client { color: var(--muted); font-weight: 800; margin-bottom: 10px; }
.brf-text { font-size: 16px; color: #dbe3ff; text-align: left; }
.reqs.wrap { flex-wrap: wrap; justify-content: center; overflow: visible; }
.brf-new { margin-top: 14px; padding: 12px 8px 10px; border-radius: 16px; background: linear-gradient(160deg, rgba(251, 173, 65, 0.14), rgba(251, 173, 65, 0.04)); border: 1px solid rgba(251, 173, 65, 0.35); }
.brf-new-h { font-size: 12px; font-weight: 900; color: var(--orange2); margin-bottom: 10px; letter-spacing: 0.02em; }
.brf-new-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.brf-new-item { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 74px; font-size: 11.5px; font-weight: 800; line-height: 1.15; }
.brf-new-item .tile { width: 50px; height: 50px; animation: reveal 0.6s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.brf-new-item:nth-child(2) .tile { animation-delay: 0.08s; }
.brf-new-item:nth-child(3) .tile { animation-delay: 0.16s; }
.brf-new-item:nth-child(4) .tile { animation-delay: 0.24s; }
.brf-new-item:active .tile { transform: scale(0.94); }
.brf-goal { margin-top: 12px; font-size: 12px; font-weight: 800; color: var(--muted); }
.intro .sheet-body { text-align: center; }
.intro-legal { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.legal-link { font-size: 12px; color: var(--dim); text-decoration: underline; text-underline-offset: 2px; }
.intro h2 { font-size: 24px; margin: 6px 0 10px; }
.intro-emoji { font-size: 46px; }
.intro-list { list-style: none; padding: 0; margin: 14px 0 0; text-align: left; display: flex; flex-direction: column; gap: 8px; }
.intro-list li { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); padding: 10px 12px; border-radius: 12px; font-weight: 700; }

/* ── generic scroll screens ── */
.scroll-body { flex: 1; overflow-y: auto; padding: 6px 16px calc(var(--sab) + 30px); }
.tabs { display: flex; gap: 6px; background: rgba(255, 255, 255, 0.05); padding: 4px; border-radius: 14px; margin: 4px 0 14px; }
.tab { flex: 1; padding: 10px; border-radius: 11px; font-weight: 800; color: var(--muted); }
.tab.on { background: var(--panel2); color: var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }
.codex-group h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 14px 0 8px; }
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 12px 8px; }
.codex-item { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.codex-item:active:not(:disabled) .tile { transform: scale(0.94); }
.codex-name { font-size: 11.5px; font-weight: 800; text-align: center; line-height: 1.15; }
.codex-item.unknown .tile { background: var(--panel2); color: var(--dim); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.06); }
.codex-item.unknown .codex-name { color: var(--dim); }
.q { font-size: 24px; font-weight: 900; }
.career-rank { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px; }
.career-rank b { font-size: 22px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; }
.stat b { font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); font-weight: 700; }
.ladder { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.ladder li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); opacity: 0.55; }
.ladder li.got { opacity: 1; border-color: rgba(251, 173, 65, 0.35); }
.ladder b { flex: 1; }
.ladder small { color: var(--muted); font-weight: 700; }
.career h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.group { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 14px 12px; margin-bottom: 14px; }
.group h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); padding: 10px 0 4px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row.col { flex-direction: column; align-items: stretch; }
.row-txt { display: flex; flex-direction: column; }
.row-txt small { color: var(--muted); font-size: 12px; }
.switch { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); position: relative; transition: background 0.2s; flex: none; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.switch:checked { background: var(--orange); }
.switch:checked::after { transform: translateX(20px); }
.slider { width: 46%; accent-color: var(--orange); }
.code-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.save-code { flex: 1; font-family: var(--mono); font-size: 20px; font-weight: 800; letter-spacing: 0.12em; background: #0a1120; border: 1px dashed rgba(251, 173, 65, 0.5); border-radius: 12px; padding: 10px; text-align: center; color: var(--orange2); -webkit-user-select: all; user-select: all; }
.lang-select { font: inherit; font-weight: 800; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; max-width: 52%; }
.code-input { flex: 1; min-width: 0; font: 700 17px var(--mono); letter-spacing: 0.1em; text-transform: uppercase; background: #0a1120; color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; -webkit-user-select: text; user-select: text; }
.about p { margin-top: 6px; }

/* ── daily quickfire ── */
.qdots { display: flex; justify-content: center; gap: 8px; padding: 4px 0 10px; }
.qdots i { width: 28px; height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); }
.qdots i.cur { background: rgba(255, 255, 255, 0.4); }
.qdots i.ok { background: var(--ok); }
.qdots i.bad { background: var(--bad); }
.quiz-stage { flex: 1; overflow-y: auto; padding: 4px 16px calc(var(--sab) + 20px); }
.qcard { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 12px; animation: screen-in 0.3s ease-out both; }
.qnum { font-size: 12px; font-weight: 900; color: var(--orange2); letter-spacing: 0.08em; text-transform: uppercase; }
.qtext { font-size: 20px; font-weight: 900; line-height: 1.25; }
.timer { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.timer i { display: block; height: 100%; background: linear-gradient(90deg, var(--orange2), var(--orange)); transform-origin: left; animation: drain linear forwards; }
.timer.stop i { animation-play-state: paused; }
@keyframes drain { to { transform: scaleX(0); } }
.qopts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qopts.n3 { grid-template-columns: 1fr 1fr 1fr; }
.qopt { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border-radius: 16px; background: rgba(255, 255, 255, 0.05); border: 2px solid var(--line); font-weight: 800; font-size: 13px; transition: transform 0.12s, border-color 0.2s, background 0.2s; }
.qopt:active:not(:disabled) { transform: scale(0.96); }
.qopt .tile { width: 50px; height: 50px; }
.qopt.right { border-color: var(--ok); background: rgba(61, 220, 151, 0.12); }
.qopt.wrong { border-color: var(--bad); background: rgba(255, 107, 107, 0.12); animation: shake 0.4s; }
.qopt:disabled:not(.right):not(.wrong) { opacity: 0.5; }
.qwhy { margin: 0; font-size: 14px; color: #dbe3ff; min-height: 1em; }
.qwhy b { color: var(--orange2); }
.qcard.result { align-items: center; text-align: center; }
.qbig { font-size: 64px; font-weight: 900; color: var(--orange2); line-height: 1; }

/* ── fx ── */
.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 80; }
.fx-burst { position: fixed; z-index: 65; pointer-events: none; }
.fx-burst i { position: absolute; width: 7px; height: 7px; border-radius: 50%; left: -3.5px; top: -3.5px; animation: burst 0.6s ease-out forwards; }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; } }
.fx-float { position: fixed; z-index: 66; pointer-events: none; transform: translate(-50%, 0); font-weight: 900; font-size: 15px; background: rgba(20, 32, 57, 0.95); border: 1px solid rgba(255, 209, 102, 0.5); padding: 6px 12px; border-radius: 999px; white-space: nowrap; animation: float-up 1.3s ease-out forwards; }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, 10px); } 15% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -40px); } }

/* ── reduced motion / calm mode ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.calm *, .calm *::before, .calm *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
.calm .wire-flow { animation: none; }

/* small phones */
@media (max-height: 680px) {
  .brief-body p { font-size: 13px; }
  .infobar { min-height: 30px; padding: 4px 10px; font-size: 12px; }
  .tray { padding: 6px 2px 2px; }
  .chip-name { font-size: 10px; }
  .chip { width: 66px; }
  .chip .tile { width: 48px; height: 48px; }
  .deploy { min-height: 48px; }
  .bar { padding: 6px 12px 4px; }
}
@media (min-width: 600px) {
  #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: rgba(11, 18, 32, 0.4); }
}

/* ── bosses ── */
.boss-art { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font); }
.boss-art .b-body { animation: b-bob 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
.boss-art .b-eyes { animation: b-blink 3.8s infinite; transform-box: fill-box; transform-origin: center; }
.boss-art .b-float { animation: b-float 3s ease-in-out infinite; animation-delay: var(--d, 0s); transform-box: fill-box; transform-origin: center; }
.boss-art .b-head { animation: b-sway 2.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
.boss-art .b-jaw { animation: b-chomp 0.45s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 0; }
@keyframes b-bob { 50% { transform: translateY(-6px) scaleY(1.03); } }
@keyframes b-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes b-float { 50% { transform: translateY(-9px) rotate(-6deg); } }
@keyframes b-sway { 50% { transform: rotate(6deg); } }
@keyframes b-chomp { to { transform: scaleY(1.3); } }

.boss-intro {
  position: fixed; inset: 0; z-index: 75; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: calc(var(--sat) + 18px) 16px calc(var(--sab) + 22px);
  background: radial-gradient(circle at 50% 42%, hsla(var(--hue), 70%, 32%, 0.6), #05080f 72%), #05080f;
  animation: bi-in 0.25s ease-out both; transition: opacity 0.3s;
}
.boss-intro::before { content: ""; position: absolute; inset: 0; background: #ef4444; pointer-events: none; animation: bi-flash 0.9s 0.25s both; }
.boss-intro.out { opacity: 0; }
@keyframes bi-in { from { opacity: 0; } }
@keyframes bi-flash { 0%, 40% { opacity: 0; } 50% { opacity: 0.35; } 60% { opacity: 0; } 75% { opacity: 0.25; } 100% { opacity: 0; } }
.bi-stripes { width: 140%; height: 34px; flex: none; display: flex; align-items: center; overflow: hidden;
  background: repeating-linear-gradient(-45deg, #facc15 0 18px, #111827 18px 36px); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5); }
.bi-stripes.top { transform: rotate(-3deg); animation: stripe-l 0.4s ease-out both; }
.bi-stripes.bottom { transform: rotate(3deg); animation: stripe-r 0.4s ease-out both; }
.bi-stripes span { white-space: nowrap; background: #111827; color: #facc15; font-weight: 900; font-size: 13px; letter-spacing: 0.22em; padding: 3px 14px; animation: marquee 7s linear infinite; }
@keyframes stripe-l { from { translate: -100% 0; } }
@keyframes stripe-r { from { translate: 100% 0; } }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.bi-stage { position: relative; flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.boss-intro.shake .bi-stage { animation: bi-shake 0.45s; }
@keyframes bi-shake { 15% { transform: translate(-9px, 4px); } 30% { transform: translate(8px, -5px); } 45% { transform: translate(-6px, 3px); } 60% { transform: translate(5px, -2px); } 80% { transform: translate(-2px, 1px); } }
.bi-glow { position: absolute; top: 50%; left: 50%; width: 320px; height: 320px; margin: -230px 0 0 -160px; border-radius: 50%;
  background: radial-gradient(hsla(var(--hue), 90%, 60%, 0.45), transparent 65%); animation: bi-pulse 1.6s ease-in-out infinite; }
@keyframes bi-pulse { 50% { transform: scale(1.12); opacity: 0.7; } }
.bi-boss { position: relative; width: min(58vw, 250px); animation: boss-drop 0.75s 0.3s cubic-bezier(0.3, 1.4, 0.5, 1) both; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.6)); }
@keyframes boss-drop { from { transform: translateY(-120vh) scale(0.6); } }
.bi-plate { position: relative; text-align: center; animation: bi-slam 0.35s 1.05s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.bi-plate small { display: block; font-size: 11px; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; color: hsl(var(--hue), 90%, 75%); }
.bi-plate b { display: block; font-size: clamp(26px, 8vw, 36px); font-weight: 900; letter-spacing: -0.01em; text-shadow: 0 0 24px hsla(var(--hue), 90%, 60%, 0.8), 0 3px 0 rgba(0, 0, 0, 0.6); }
@keyframes bi-slam { from { transform: scale(2.4); opacity: 0; } }
.bi-bubble { position: relative; max-width: 320px; min-height: 2.8em; background: #fff; color: #0b1220; font-weight: 800; font-size: 15px; line-height: 1.3; padding: 10px 14px; border-radius: 16px; text-align: center; box-shadow: var(--shadow); animation: bi-pop 0.3s 1.35s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
@keyframes bi-pop { from { transform: scale(0.4); opacity: 0; } }
.bi-bubble::before { content: ""; position: absolute; left: 50%; top: -7px; width: 14px; height: 14px; background: #fff; transform: translateX(-50%) rotate(45deg); }
.bi-vs { position: relative; display: flex; align-items: center; gap: 18px; animation: fade-up 0.4s 1.7s both; }
.bi-vs em { font-style: normal; font-size: 28px; font-weight: 900; color: #facc15; text-shadow: 0 0 16px rgba(250, 204, 21, 0.7); }
.bi-you, .bi-them { display: flex; flex-direction: column; align-items: center; font-size: 11px; font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.bi-you i, .bi-them i { font-style: normal; font-size: 30px; }
.bi-fight { position: relative; z-index: 1; animation: fade-up 0.4s 1.2s both, breathe 2s 1.8s ease-in-out infinite; }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } }
.boss-intro.skip .bi-boss, .boss-intro.skip .bi-plate, .boss-intro.skip .bi-bubble, .boss-intro.skip .bi-vs, .boss-intro.skip::before { animation-delay: 0s !important; animation-duration: 0.15s !important; }
.boss-intro.skip .bi-fight { animation: breathe 2s ease-in-out infinite; }

.boss-defeat { position: relative; display: flex; flex-direction: column; align-items: center; margin: -6px 0 6px; }
.bd-art { width: 120px; animation: bd-hit 1s ease-out both; }
.bd-art .boss-art { filter: grayscale(0.8) brightness(0.85); }
.bd-art .boss-art .b-body { animation: b-dizzy 1.6s ease-in-out infinite; }
.bd-art .boss-art .b-eyes { animation: none; transform: scaleY(0.15); }
@keyframes bd-hit { 0% { transform: scale(1.15); } 15% { transform: translateX(-8px) rotate(-6deg); } 30% { transform: translateX(8px) rotate(6deg); } 45% { transform: translateX(-5px); } 100% { transform: rotate(-12deg) translateY(8px) scale(0.92); } }
@keyframes b-dizzy { 50% { transform: rotate(4deg) translateY(2px); } }
.bd-stamp { position: absolute; top: 74px; font-size: 19px; font-weight: 900; letter-spacing: 0.12em; color: #ff6b6b; border: 4px solid #ff6b6b; border-radius: 10px; padding: 0 12px; background: rgba(11, 18, 32, 0.65); transform: rotate(-14deg); animation: bd-stamp 0.35s 0.6s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
@keyframes bd-stamp { from { transform: rotate(-14deg) scale(3); opacity: 0; } }
.bd-name { font-weight: 900; margin-top: 2px; }
.bd-line { margin: 2px 0 4px; font-size: 13px; font-style: italic; color: var(--muted); }
