:root {
  color-scheme: dark;
  --ink: #f4efe2;
  --ink-2: #b8b2cc;
  --bg: #0b0a1c;
  --glass: rgba(16, 13, 36, 0.86);
  --glass-2: rgba(28, 24, 58, 0.92);
  --line: rgba(190, 180, 255, 0.22);
  --gold: #ffd84a;
  --star: #fff3b0;
  --hp: #ff5d73;
  --mp: #5b9cff;
  --xp: #ffc83a;
  --good: #8ff0b4;
  --bad: #ff8a8a;
  --accent: #9fc4ff;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { font: 700 10px/1 system-ui; padding: 2px 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.2); margin-right: 6px; }

.sf { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#layer { position: absolute; inset: 0; pointer-events: none; }
#layer > * { pointer-events: none; }
#layer button, #layer .bt-cmd, #layer .bt-party, #layer .map-info, #layer .map-tabs, #layer [role="menu"] { pointer-events: auto; }

/* buttons & chips */
.btn {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(70, 60, 140, 0.85), rgba(40, 32, 90, 0.9));
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 700;
  min-height: 40px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.btn:hover:not([disabled]) { filter: brightness(1.15); }
.btn:active:not([disabled]) { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #ffd86a, #e0a52a); color: #2a1a06; border-color: #fff0b0; }
.btn.ghost { background: rgba(255, 255, 255, 0.06); }
.btn.mini { padding: 4px 8px; min-height: 30px; font-size: 12px; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn small { display: block; font-weight: 600; opacity: 0.75; font-size: 11px; }
.chip {
  border: 1px solid var(--line);
  background: var(--glass);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 13px;
  min-height: 34px;
}
.chip.on { background: linear-gradient(180deg, #ffd86a, #e0a52a); color: #2a1a06; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.hint { color: var(--ink-2); font-size: 13px; line-height: 1.45; margin: 4px 0 10px; }

/* HUD */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 10px 0;
  pointer-events: none;
  z-index: 5;
}
.hud > * { pointer-events: auto; }
.hud-l { background: var(--glass); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; max-width: 58%; }
.hud-l b { display: block; font-size: 14px; }
#hud-quest { display: block; max-width: 100%; margin: 1px 0 0; padding: 2px 0; border: 0; background: none; font-size: 12px; font-weight: 700; color: var(--gold); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: underline dotted rgba(255, 216, 74, 0.45); text-underline-offset: 3px; }
#hud-quest:hover { color: #fff0b0; }
.hud-auto { display: block; font-size: 11px; color: #c8f0ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-auto::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #8ff0e0; box-shadow: 0 0 8px #8ff0e0; animation: pulse 0.7s infinite alternate; vertical-align: 1px; }
.hud-r { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.gold { background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; font-weight: 800; color: var(--gold); font-size: 13px; }

/* map UI */
.map-ui .map-tabs { position: absolute; left: 10px; bottom: max(10px, env(safe-area-inset-bottom)); display: flex; gap: 6px; flex-wrap: wrap; max-width: 52%; }
.map-ui .map-info {
  position: absolute; right: 10px; bottom: max(10px, env(safe-area-inset-bottom));
  width: min(360px, calc(100% - 20px));
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; font-size: 13px; line-height: 1.4;
}
.map-info em { color: #c8c8e0; }
.map-info small { color: var(--ink-2); }
.map-info .goal { color: var(--gold); }
.map-info .row { margin: 8px 0 0; }
.narrow .map-ui .map-tabs { bottom: auto; top: 64px; max-width: calc(100% - 20px); }
.narrow .map-ui .map-tabs span { display: none; }

/* field UI */
.field-ui .loc { display: none; }
.field-ui .touch-move { position: absolute; left: 10px; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.field-ui .tm { width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); font-size: 22px; touch-action: none; }
.field-ui .act-btn {
  position: absolute; right: 12px; bottom: max(16px, env(safe-area-inset-bottom));
  min-width: 104px; min-height: 56px; border-radius: 16px; font-weight: 900; font-size: 16px;
  border: 1px solid #fff0b0; background: linear-gradient(180deg, #ffd86a, #e0a52a); color: #2a1a06;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
@media (pointer: fine) { .field-ui .touch-move { opacity: 0.55; } }

/* battle UI */
.bt-ui { position: absolute; inset: 0; }
.bt-top { position: absolute; top: max(6px, env(safe-area-inset-top)); left: 8px; right: 8px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.bt-timeline { display: flex; gap: 4px; flex-wrap: nowrap; overflow: hidden; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; padding: 4px 6px; }
.bt-timeline .tl { min-width: 32px; padding: 3px 5px; border-radius: 8px; font: 800 11px system-ui; text-align: center; background: color-mix(in srgb, var(--c) 30%, #12102a); border: 1px solid color-mix(in srgb, var(--c) 70%, transparent); }
.bt-timeline .tl.enemy { border-style: dashed; }
.bt-timeline .tl.first { transform: scale(1.14); box-shadow: 0 0 10px var(--c); }
.bt-timeline .tl.broken { opacity: 0.55; }
.bt-toggles { display: flex; gap: 6px; pointer-events: auto; }
.bt-banner {
  position: absolute; top: 56px; left: 50%; transform: translate(-50%, -10px);
  padding: 8px 18px; border-radius: 12px; background: var(--glass-2); border: 1px solid var(--line);
  font-weight: 900; letter-spacing: 0.04em; opacity: 0; transition: opacity 0.15s, transform 0.15s; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
.bt-banner.show { opacity: 1; transform: translate(-50%, 0); }
.bt-banner.big { font-size: 22px; color: var(--star); border-color: var(--gold); box-shadow: 0 0 24px rgba(255, 216, 74, 0.45); }
.bt-banner.enemy { color: #ffb0b0; }
.bt-banner.boss { color: #ffd0e0; white-space: normal; text-align: center; font-size: 15px; }
.bt-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 8px max(8px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); grid-template-rows: auto auto; gap: 6px; background: linear-gradient(180deg, rgba(8, 6, 20, 0), rgba(8, 6, 20, 0.85) 30%); }
.bt-star { grid-column: 1 / 3; position: relative; height: 14px; border-radius: 8px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); overflow: hidden; }
.bt-star i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #6a8aff, #fff3b0); transition: width 0.25s; }
.bt-star span { position: absolute; inset: 0; font: 800 10px/14px system-ui; text-align: center; text-shadow: 0 1px 2px #000; }
.bt-star b { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, 0.5); }
.bt-star b:nth-of-type(1) { left: 33.33%; }
.bt-star b:nth-of-type(2) { left: 66.66%; }
.bt-star b:nth-of-type(3) { display: none; }
.bt-star.ready { box-shadow: 0 0 12px rgba(255, 243, 176, 0.7); }
.bt-party { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; align-content: start; }
.bt-card { background: var(--glass); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 10px; padding: 4px 7px; font-size: 12px; position: relative; }
.bt-card b { font-size: 13px; }
.bt-card small { color: var(--ink-2); margin-left: 4px; font-size: 10px; }
.bt-card .sts { position: absolute; right: 6px; top: 3px; font-size: 11px; }
.bt-card.now { box-shadow: 0 0 0 2px var(--gold), 0 0 14px rgba(255, 216, 74, 0.4); }
.bt-card.ko { opacity: 0.45; filter: grayscale(1); }
.bt-card.low .bar.hp i { background: #ff2d4a; animation: pulse 0.8s infinite alternate; }
@keyframes pulse { to { opacity: 0.55; } }
.bar { position: relative; height: 9px; border-radius: 5px; background: rgba(0, 0, 0, 0.45); overflow: hidden; margin-top: 3px; }
.bar i { position: absolute; inset: 0 auto 0 0; transition: width 0.3s; }
.bar em { position: relative; display: block; font: 700 8px/9px system-ui; font-style: normal; padding-left: 4px; text-shadow: 0 1px 1px #000; }
.bar.hp i { background: linear-gradient(90deg, #ff5d73, #ff9a6a); }
.bar.mp i { background: linear-gradient(90deg, #4f8dff, #7fd6ff); }
.bar.xp i { background: linear-gradient(90deg, #ffb83a, #ffe14d); }
.bar.bond i { background: linear-gradient(90deg, #ff8ad8, #ffd0f0); }
.bar.thin { height: 6px; }
.bar.thin i { background: linear-gradient(90deg, #6a8aff, #fff3b0); }
.member .bar { height: 14px; margin-top: 5px; }
.member .bar em { display: block; font-size: 10px; line-height: 14px; }
.bt-cmd { background: var(--glass-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px; max-height: 42vh; overflow: auto; min-height: 40px; }
.bt-cmd:empty { visibility: hidden; }
.cmd-title { font: 800 12px system-ui; color: var(--gold); margin: 2px 4px 6px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.cmd-back { border: 0; background: rgba(255, 255, 255, 0.1); border-radius: 6px; padding: 3px 6px; font-size: 11px; }
.cmd-list { display: grid; grid-template-columns: 1fr; gap: 4px; }
.cmd { display: flex; align-items: center; gap: 4px; text-align: left; border: 1px solid transparent; background: rgba(255, 255, 255, 0.06); border-radius: 8px; padding: 7px 8px; min-height: 36px; font-weight: 700; font-size: 13px; }
.cmd span { flex: 1; }
.cmd small { color: var(--ink-2); font-size: 11px; }
.cmd:hover:not([disabled]), .cmd:focus-visible { background: rgba(255, 216, 74, 0.18); border-color: var(--gold); outline: none; }
.cmd[disabled] { opacity: 0.4; }
.cmd.star:not([disabled]) { background: linear-gradient(90deg, rgba(255, 216, 74, 0.25), rgba(140, 160, 255, 0.2)); }
.cmd.ult:not([disabled]) { box-shadow: 0 0 12px rgba(255, 243, 176, 0.6); }
.narrow .bt-bottom { grid-template-columns: 1fr; }
.narrow .bt-star { grid-column: 1; }
.narrow .bt-cmd { max-height: 32vh; }
.narrow .cmd-list { grid-template-columns: 1fr 1fr; }
.narrow .bt-timeline .tl { min-width: 24px; }
.narrow .bt-card { padding: 3px 5px; }
.narrow .bt-card small { display: none; }

/* story */
.story { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; justify-content: flex-end; padding: 10px 10px max(12px, env(safe-area-inset-bottom)); }
.story-title { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); font: 700 13px Georgia, serif; letter-spacing: 0.14em; text-transform: uppercase; color: var(--star); text-shadow: 0 2px 6px #000; white-space: nowrap; }
.story-box { position: relative; display: flex; gap: 12px; align-items: flex-start; background: linear-gradient(180deg, rgba(20, 16, 44, 0.92), rgba(10, 8, 26, 0.96)); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; min-height: 120px; max-width: 980px; width: 100%; margin: 0 auto; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); cursor: pointer; }
.story.narration .story-box { justify-content: center; text-align: center; font-style: italic; }
.story-portrait { flex: 0 0 auto; }
.portrait { width: 96px; height: 96px; border-radius: 12px; overflow: hidden; border: 2px solid var(--c, #fff); box-shadow: 0 0 14px color-mix(in srgb, var(--c, #fff) 45%, transparent); background: #1a1530; }
.portrait img, .portrait canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.story-main { flex: 1; min-width: 0; }
.story-name { font-size: 16px; letter-spacing: 0.03em; }
.story-text { margin: 4px 0 0; font-size: 17px; line-height: 1.5; white-space: pre-line; min-height: 3em; }
.story-next { position: absolute; right: 16px; bottom: 8px; color: var(--gold); animation: bob 0.8s infinite alternate; }
@keyframes bob { to { transform: translateY(4px); } }
.story-skip { position: absolute; right: 10px; top: -36px; border: 1px solid var(--line); background: var(--glass); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 700; }
.story-choices { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.story-choices .btn { text-align: left; }
.narrow .portrait { width: 64px; height: 64px; }
.narrow .story-text { font-size: 15px; }

/* panel */
.panel { position: absolute; inset: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); margin: auto; max-width: 620px; max-height: calc(100% - 20px); height: fit-content; display: flex; flex-direction: column; background: var(--glass-2); border: 1px solid var(--line); border-radius: 18px; z-index: 9; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); backdrop-filter: blur(6px); }
.panel.wide { max-width: 900px; height: calc(100% - 20px); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { margin: 0; font: 700 18px Georgia, serif; color: var(--star); }
.panel-tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tab { border: 1px solid transparent; background: rgba(255, 255, 255, 0.06); border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.tab.on { background: rgba(255, 216, 74, 0.2); border-color: var(--gold); color: var(--gold); }
.x { margin-left: auto; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); font-size: 16px; }
.panel-body { padding: 10px 14px 14px; overflow: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.panel-body h3 { margin: 6px 0; font-family: Georgia, serif; }
.panel-body h4 { margin: 14px 0 6px; color: var(--gold); font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; }
.list { display: flex; flex-direction: column; gap: 6px; }
.li { display: flex; gap: 8px; justify-content: space-between; align-items: center; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.06); border-radius: 10px; padding: 8px 10px; font-size: 13px; text-align: left; width: 100%; }
.li small { color: var(--ink-2); }
.li.dim { opacity: 0.45; }
.li.pick:hover, .li.pick.on { border-color: var(--gold); background: rgba(255, 216, 74, 0.1); }
.li-act { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; flex: 0 0 auto; }
.li-act span { font-weight: 800; font-size: 12px; }
.li.quest { cursor: pointer; }
.li.quest .go { color: var(--gold); white-space: nowrap; }
.up { color: var(--good); }
.down { color: var(--bad); }
.ok { color: var(--good); }
.no { color: var(--bad); }
.new { color: var(--gold); font-size: 11px; }
.ings span { margin-right: 6px; }
textarea.code { width: 100%; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: 12px ui-monospace, monospace; user-select: text; -webkit-user-select: text; }
select, input[type="range"] { accent-color: var(--gold); }
select { background: #1a1638; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.settings { display: flex; flex-direction: column; gap: 12px; }
.settings label { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-weight: 700; }
.victory .big { font-size: 22px; font-weight: 900; color: var(--gold); margin: 4px 0; }
.victory ul { margin: 4px 0; padding-left: 18px; line-height: 1.6; }
.star { color: var(--star); }

/* party screen */
.party-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.party-tabs .chip { border-left: 4px solid var(--c); }
.party-tabs .chip.act { box-shadow: inset 0 -2px 0 var(--c); }
.m-head { display: flex; gap: 12px; align-items: flex-start; }
.m-head > div:last-child { flex: 1; min-width: 0; }
.m-head h3 small { color: var(--ink-2); font: 600 13px system-ui; }
.bio { font-size: 13px; color: var(--ink-2); margin: 2px 0 6px; }
.stats { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 10px 0; }
.stats span { background: rgba(255, 255, 255, 0.05); border-radius: 8px; padding: 6px; text-align: center; }
.stats small { display: block; color: var(--ink-2); font-size: 10px; }
.narrow .stats { grid-template-columns: repeat(4, 1fr); }

/* bestiary, completion, constellation */
.beast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.beast { background: rgba(255, 255, 255, 0.05); border-radius: 8px; padding: 6px 8px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.beast small { color: var(--ink-2); font-size: 11px; }
.beast.dim { opacity: 0.35; text-align: center; justify-content: center; min-height: 52px; }
.complete .overall { display: flex; align-items: baseline; gap: 12px; }
.complete .overall b { font: 900 40px Georgia, serif; color: var(--star); }
.crests { display: flex; gap: 6px; flex-wrap: wrap; }
.crest { width: 54px; height: 62px; border-radius: 12px 12px 26px 26px; border: 2px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.04); }
.crest b { font: 900 18px Georgia, serif; }
.crest small { font-size: 10px; color: var(--ink-2); }
.crest.on { border-color: var(--gold); background: radial-gradient(circle, rgba(255, 216, 74, 0.35), rgba(255, 216, 74, 0.05)); box-shadow: 0 0 12px rgba(255, 216, 74, 0.4); }
.const { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.branch { display: flex; flex-direction: column; gap: 6px; }
.branch h4 { margin: 4px 0; }
.node { text-align: left; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); border-radius: 10px; padding: 7px 9px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.node small { color: var(--ink-2); font-size: 11px; }
.node.lit { border-color: #8aa0ff; background: rgba(120, 140, 255, 0.14); }
.node.max { border-color: var(--gold); background: rgba(255, 216, 74, 0.15); }
.node:not([disabled]):hover { box-shadow: 0 0 10px rgba(255, 216, 74, 0.4); }
.node[disabled] { cursor: default; }

/* mini-games */
.fish { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.fish canvas { width: min(100%, 320px); border-radius: 12px; border: 1px solid var(--line); }
.fish-msg { min-height: 2.6em; text-align: center; margin: 0; }
.fish-log small { color: var(--ink-2); }
.needle-bar { position: relative; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); margin: 14px 0; }
.needle-bar .great { position: absolute; top: 0; bottom: 0; background: rgba(143, 240, 180, 0.35); }
.needle-bar .perfect { position: absolute; top: 0; bottom: 0; background: rgba(255, 216, 74, 0.8); }
.needle-bar b { position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px; background: #fff; border-radius: 2px; box-shadow: 0 0 8px #fff; }
.sc { position: relative; width: 74px; height: 92px; border-radius: 9px; border: 2px solid rgba(255, 255, 255, 0.25); background: linear-gradient(160deg, #3a3470, #1a1838); font: 900 14px system-ui; flex: 0 0 auto; }
.sc.mine { background: linear-gradient(160deg, #3a5aa0, #1a2a5a); border-color: #7fb8ff; }
.sc.theirs { background: linear-gradient(160deg, #a03a5a, #4a1a2a); border-color: #ff8aa8; }
.sc.r4, .sc.r5 { box-shadow: 0 0 10px rgba(255, 216, 74, 0.5); }
.sc .t { position: absolute; top: 3px; left: 50%; transform: translateX(-50%); }
.sc .b { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); }
.sc .l { position: absolute; left: 6px; top: 34px; }
.sc .r { position: absolute; right: 6px; top: 34px; }
.sc em { position: absolute; bottom: 2px; left: 2px; right: 2px; font: 700 8px/1.1 system-ui; font-style: normal; text-align: center; color: var(--ink-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sc.back { background: repeating-linear-gradient(45deg, #2a2050, #2a2050 6px, #3a3070 6px, #3a3070 12px); }
.sc.flip { animation: flip 0.35s; }
@keyframes flip { 50% { transform: rotateY(90deg); } }
.sc-btn { border: 0; background: none; padding: 2px; border-radius: 11px; }
.sc-btn.on { outline: 3px solid var(--gold); }
.sc-pick { display: flex; flex-wrap: wrap; gap: 4px; }
.sc-game { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sc-hand { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; min-height: 96px; }
.sc-board { display: grid; grid-template-columns: repeat(3, 80px); grid-template-rows: repeat(3, 98px); gap: 4px; }
.sc-board .cell { border: 1px dashed rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.04); border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0; }
.sc-score { font: 900 20px system-ui; display: flex; gap: 10px; align-items: center; }
.sc-score .mine { color: #7fb8ff; }
.sc-score .theirs { color: #ff8aa8; }
.sc-score span { font: 600 13px system-ui; color: var(--ink-2); }
.narrow .sc { width: 58px; height: 74px; font-size: 12px; }
.narrow .sc .l, .narrow .sc .r { top: 26px; }
.narrow .sc-board { grid-template-columns: repeat(3, 62px); grid-template-rows: repeat(3, 78px); }
.forge-card { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--gold); border-radius: 12px; padding: 10px; margin-bottom: 10px; }

/* toasts, fade, title */
.toasts { position: absolute; top: 72px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 12; width: min(520px, calc(100% - 20px)); pointer-events: none; }
.toast { background: var(--glass-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 700; text-align: center; animation: tin 0.25s; transition: opacity 0.5s, transform 0.5s; }
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--bad); }
.toast.star { border-color: var(--gold); color: var(--star); box-shadow: 0 0 16px rgba(255, 216, 74, 0.35); }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }
.fade { position: absolute; inset: 0; background: #05040e; opacity: 0; pointer-events: none; transition: opacity 0.18s; z-index: 11; }
.fade.on { opacity: 1; }
.title { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; background: radial-gradient(ellipse at 50% 60%, rgba(10, 8, 30, 0.1), rgba(5, 4, 14, 0.65)); }
.title-card { text-align: center; max-width: 440px; width: 100%; }
.kicker { letter-spacing: 0.3em; text-transform: uppercase; font-size: 12px; color: var(--ink-2); margin: 0; }
.logo { font: 700 clamp(40px, 9vw, 72px)/1 Georgia, "Times New Roman", serif; margin: 10px 0 22px; color: var(--star); text-shadow: 0 0 24px rgba(255, 216, 74, 0.55), 0 4px 0 #2a1a50; letter-spacing: 0.02em; }
.logo span { display: block; font-size: 0.55em; letter-spacing: 0.35em; color: #c8d8ff; }
.title-actions { display: flex; flex-direction: column; gap: 8px; }
.title-actions .btn { min-height: 48px; font-size: 16px; }
.title-note { font-size: 12px; color: var(--ink-2); margin-top: 14px; }
.gd-back { z-index: 20 !important; }
/* cinematic story layer */
.cine { position: absolute; inset: 0; z-index: 7; overflow: hidden; opacity: 0; transition: opacity 0.4s; pointer-events: none; }
.cine.has-poster, .cine.playing { background: #000; }
.cine.on { opacity: 1; }
.cine-poster, .cine-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cine-poster { opacity: 0; transform-origin: 60% 45%; }
.cine.has-poster .cine-poster { opacity: 1; animation: kenburns 22s ease-in-out forwards; }
.cine-video { opacity: 0; transition: opacity 0.6s; }
.cine.playing .cine-video { opacity: 1; }
.cine-bar { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); z-index: 1; }
.cine-bar.top { top: 0; }
.cine-bar.bot { bottom: 0; }
.cine.on .cine-bar { height: 11vh; }
.cine-cap { position: absolute; left: 50%; top: 40%; z-index: 2; margin: 0; transform: translate(-50%, -50%); width: min(90vw, 900px); text-align: center; font: 700 clamp(26px, 5.4vw, 54px)/1.1 Georgia, "Times New Roman", serif; letter-spacing: 0.12em; color: var(--star); text-shadow: 0 0 28px rgba(255, 216, 74, 0.45), 0 3px 12px #000; opacity: 0; }
.cine-cap.show { animation: cinecap 4.6s ease forwards; }
@keyframes kenburns { from { transform: scale(1.04) translate(0, 0); } to { transform: scale(1.16) translate(-2.5%, -1.5%); } }
@keyframes cinecap { 0% { opacity: 0; letter-spacing: 0.32em; } 18% { opacity: 1; letter-spacing: 0.12em; } 72% { opacity: 1; } 100% { opacity: 0; letter-spacing: 0.16em; } }
.story.cinematic .story-title { top: calc(5.5vh - 8px); }
.story.cinematic .story-box { background: linear-gradient(180deg, rgba(8, 6, 20, 0.72), rgba(4, 3, 12, 0.88)); }

/* limit cut-in */
.cutin { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.cutin-band { position: absolute; left: -20%; right: -20%; top: 32%; height: clamp(120px, 26vh, 220px); transform: rotate(-8deg) scaleY(0); background: linear-gradient(90deg, rgba(5, 4, 16, 0.92), color-mix(in srgb, var(--c, #9fc4ff) 40%, #0a0820) 50%, rgba(5, 4, 16, 0.92)); border-top: 3px solid var(--c, #9fc4ff); border-bottom: 3px solid var(--c, #9fc4ff); box-shadow: 0 0 40px color-mix(in srgb, var(--c, #9fc4ff) 60%, transparent); display: flex; align-items: center; justify-content: center; gap: 18px; }
.cutin-lines { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0) 0 34px, rgba(255, 255, 255, 0.28) 34px 36px, rgba(255, 255, 255, 0) 36px 90px); mix-blend-mode: screen; }
.cutin-pors { display: flex; gap: 6px; transform: rotate(8deg); }
.cutin-pors .portrait { width: clamp(96px, 22vh, 190px); height: clamp(96px, 22vh, 190px); border-radius: 14px; overflow: hidden; border: 2px solid var(--c, #fff); box-shadow: 0 0 24px rgba(0, 0, 0, 0.6); }
.cutin-pors .portrait img, .cutin-pors .portrait canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.cutin-text { transform: rotate(8deg); display: flex; flex-direction: column; }
.cutin-text b { font: 900 clamp(22px, 4.6vw, 44px)/1 Georgia, serif; color: #fff; text-shadow: 0 0 16px var(--c, #fff), 0 3px 0 #000; letter-spacing: 0.04em; }
.cutin-text small { font-weight: 800; font-size: 12px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--star); margin-top: 6px; }
.cutin.show .cutin-band { animation: cutband var(--dur, 1.1s) cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
.cutin.show .cutin-lines { animation: speed calc(var(--dur, 1.1s) / 3) linear infinite; }
.cutin.show .cutin-pors { animation: cutslide var(--dur, 1.1s) cubic-bezier(0.1, 0.9, 0.2, 1) forwards; }
.cutin.show .cutin-text { animation: cuttext var(--dur, 1.1s) ease-out forwards; }
@keyframes cutband { 0% { transform: rotate(-8deg) scaleY(0); } 14% { transform: rotate(-8deg) scaleY(1); } 84% { transform: rotate(-8deg) scaleY(1); opacity: 1; } 100% { transform: rotate(-8deg) scaleY(0.2); opacity: 0; } }
@keyframes cutslide { 0% { transform: rotate(8deg) translateX(-70vw); } 30% { transform: rotate(8deg) translateX(0); } 78% { opacity: 1; transform: rotate(8deg) translateX(3vw); } 100% { opacity: 0; transform: rotate(8deg) translateX(-12vw); } }
@keyframes cuttext { 0%, 18% { opacity: 0; transform: rotate(8deg) translateX(30vw); } 36% { opacity: 1; transform: rotate(8deg) translateX(0); } 78% { opacity: 1; transform: rotate(8deg) scale(1); } 100% { opacity: 0; transform: rotate(8deg) scale(1.15); } }
@keyframes speed { to { background-position: -90px 0; } }
.narrow .cutin-band { gap: 10px; }

/* boss phase caption */
.bt-cine { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.bt-cine .bar { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
.bt-cine .bar.top { top: 0; }
.bt-cine .bar.bot { bottom: 0; }
.bt-cine p { position: absolute; left: 50%; bottom: 2.5vh; transform: translateX(-50%); width: min(92vw, 720px); margin: 0; text-align: center; font: italic 700 clamp(16px, 2.6vw, 22px)/1.35 Georgia, serif; color: #ffd0e0; text-shadow: 0 2px 10px #000; opacity: 0; transition: opacity 0.4s; }
.bt-cine.show .bar { height: 12vh; }
.bt-cine.show .bar.bot { height: max(12vh, 64px); }
.bt-cine.show p { opacity: 1; }

/* class change */
.promo { position: absolute; inset: 0; z-index: 9; display: flex; align-items: flex-end; justify-content: center; padding: 16px 16px max(18px, env(safe-area-inset-bottom)); pointer-events: none; }
.promo-card { pointer-events: auto; text-align: center; width: min(520px, 100%); background: linear-gradient(180deg, rgba(20, 16, 50, 0.82), rgba(8, 6, 24, 0.94)); border: 1px solid var(--gold); border-radius: 16px; padding: 14px 16px; box-shadow: 0 0 40px rgba(255, 216, 74, 0.25); opacity: 0; transform: translateY(16px) scale(0.96); }
.promo.show .promo-card { animation: promoin 0.7s 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards; }
.promo-title { margin: 6px 0; font: 700 clamp(19px, 3.6vw, 28px)/1.25 Georgia, serif; color: var(--star); }
.promo-title small { font-size: 0.7em; color: var(--ink-2); }
.promo-title b { color: #fff; text-shadow: 0 0 14px var(--gold); }
.promo-skills { list-style: none; margin: 6px 0; padding: 0; font-size: 14px; }
.promo-skills b { color: var(--gold); }
.promo-note { margin: 4px 0 10px; color: var(--ink-2); font-size: 13px; }
@keyframes promoin { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .story-next, .bt-card.low .bar.hp i { animation: none; }
  .cine.has-poster .cine-poster { animation: none; transform: scale(1.04); }
  .cutin.show .cutin-lines { animation: none; }
  .cutin.show .cutin-pors, .cutin.show .cutin-text { animation-name: fadeonly; }
  .hud-auto::before { animation: none; }
}
@keyframes fadeonly { 0% { opacity: 0; } 20%, 80% { opacity: 1; } 100% { opacity: 0; } }
