/* Visual layer for the Rogue UI (palette + Traditional Chinese font). Loaded after the original stylesheet.
   Cosmetic only: no layout, size or interaction rules are changed here. */
@font-face {
  font-family: "Rogue TC";
  src: url(../fonts/NotoSansTC-subset.97214da6ec.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
:root {
  /* deep purple / navy base */
  --void: #0c0919;
  --ink: #140f2b;
  --ink-2: #1d1640;
  --ink-3: #2b2250;
  --line: #e9ddff24;
  --line-2: #e9ddff4d;
  --text: #f4edff;
  --muted: #b5a9d8;
  /* warm peach primary (was gold) */
  --gold: #f7c8a0;
  --gold-2: #ffe2c6;
  --ember: #ff9170;
  /* status colours: pink-violet danger, teal good */
  --red: #ff6f9c;
  --good: #67e8cb;
  --display: Sora, "Rogue TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --body: Figtree, "Rogue TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}
body, button, input, select, textarea { font-family: var(--body); }

/* Leaderboards need a backend that is not part of this build (see rogue/patches.mjs); hide the entry point. */
.screen-title .menu .row [data-arg="board"] { display: none; }

/* Title screen: the four characters as sticker standees on the right edge. Purely decorative. */
.screen-title { position: relative; }
.screen-title::after {
  content: "";
  position: absolute;
  right: 1.5vw;
  bottom: 0;
  width: min(44vw, 720px);
  height: min(80vh, 640px);
  pointer-events: none;
  background-repeat: no-repeat;
  background-image: var(--skin-yan, url(../skins/yan.webp?v=97214da6ec)), var(--skin-yang, url(../skins/yang.webp?v=97214da6ec)), var(--skin-tu, url(../skins/tu.webp?v=97214da6ec)), var(--skin-wu, url(../skins/wu.webp?v=97214da6ec));
  background-size: auto 78%, auto 72%, auto 72%, auto 66%;
  background-position: 54% 100%, 100% 100%, 4% 100%, 78% 100%;
  filter: drop-shadow(0 10px 22px #0009);
  opacity: 0.96;
}
@media (max-width: 760px), (max-aspect-ratio: 1/1) { .screen-title::after { display: none; } }

/* Gentle night-city colour grade over the 3D scene (cheap overlay, no post-processing cost). */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(180deg, #3a1f7a33 0%, #0c0a2a14 55%, #ff7aa31f 100%);
  mix-blend-mode: soft-light;
}

/* Phones in portrait: the skill bar used to be centred and ran under the 2x2 touch buttons.
   Put the bar bottom-left and the buttons bottom-right so they never share horizontal space
   (bar 12..232px, buttons 245..369px on a 393px screen). Layout only; no gameplay input is touched. */
@media (max-width: 520px) and (pointer: coarse) {
  .hud-bc { left: calc(12px + var(--safe-l, 0px)); transform: none; justify-items: start; }
  .slotbar { gap: 8px; }
  .hslot { width: 46px; height: 46px; }
  .hslot.is-ult { width: 58px; height: 58px; }
  .hslot .emblem { --s: 30px !important; }
  .hslot.is-ult .hslot-ico .emblem { --s: 46px !important; }
  .hslot .key { font-size: 0.56em; padding: 0 4px; max-width: 48px; }
  .tbtns { gap: 8px; grid-template-columns: repeat(2, 68px); }
  .tbtn { width: 68px; height: 68px; font-size: 0.76em; }
  .tbtn.t-pause { width: 58px; height: 58px; font-size: 0.68em; }
}
/* Overlap guard, measured with rogue-work/overlap.mjs on 13 viewports.
   Skill bar = 12..248px wide; the 2x2 touch pad starts at (vw - 148)px, so portrait phones narrower than
   ~420px collide (390px wide still overlapped by 6px). Lift the pad above the bar (bar top = 242px above the
   bottom edge) instead of shrinking the slots further. Same trigger as the base game's own touch rules
   (body.has-touch). Layout only: no input handler, hit-test or gameplay value is touched. */
@media (max-width: 440px) and (max-aspect-ratio: 1/1) {
  body.has-touch .tbtns { bottom: calc(254px + var(--safe-b, 0px)); }
}
/* Short landscape phones (e.g. 568x320): the pad used to start 2px from the top edge and touch the bar.
   Park it bottom-right, immediately left of the aim stick (stick = 140px wide + 24px margin). */
@media (max-height: 420px) and (min-aspect-ratio: 1/1) {
  body.has-touch .tbtns { right: calc(24px + 140px + 16px + var(--safe-r, 0px)); bottom: calc(24px + var(--safe-b, 0px)); transform: scale(.85); transform-origin: right bottom; }
}

/* Small portrait viewports (embeds, 300-360px wide x <= 560px tall): lifting the pad above the skill bar left only
   ~112px between the pause button (bottom edge ~126px) and the bar (top 238px at 480px high), so the top-right pad
   button touched the pause button. Scale the pad to 80% (bottom-right origin) so it fits in that gap. Layout only. */
@media (max-width: 440px) and (max-aspect-ratio: 1/1) and (max-height: 560px) {
  body.has-touch .tbtns { bottom: calc(248px + var(--safe-b, 0px)); transform: scale(.78); transform-origin: right bottom; }
  /* 68px pad x .78 = 53px buttons (was 46px); the pause button goes back to its upstream 44px so the pad top (118px) clears its bottom edge (114px). */
  .tbtn.t-pause { width: 44px; height: 44px; }
}
/* Short landscape phones/embeds (<= 340px high, e.g. 568x320): the centred skill bar (172px above the bottom, 70px
   high) overlapped the room title line (bottom edge ~84px). Use the compact slot sizes of the portrait rule so the bar
   is ~62px high and ends exactly at the sticks' top edge (bar x 174..394 stays clear of the 164px move stick). */
@media (max-height: 340px) and (min-aspect-ratio: 1/1) and (pointer: coarse) {
  .slotbar { gap: 8px; }
  .hslot { width: 46px; height: 46px; }
  .hslot.is-ult { width: 58px; height: 58px; }
  .hslot .emblem { --s: 30px !important; }
  .hslot.is-ult .hslot-ico .emblem { --s: 46px !important; }
  .hslot .key { font-size: 0.56em; padding: 0 4px; max-width: 48px; }
  body.has-touch .hud-bc { bottom: calc(164px + var(--safe-b, 0px)); }
}

/* ---------------------------------------------------------------- 造型 (styling) panel — see rogue/overlay/styling.97214da6ec.js */
.rs-modal {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  background: #05030acc; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); pointer-events: auto;
}
.rs-panel {
  display: flex; flex-direction: column; gap: 10px; width: min(760px, 100%); max-height: 100%; overflow: auto;
  padding: 14px 16px; border: 1px solid var(--line-2); border-radius: 16px; color: var(--text);
  background: linear-gradient(180deg, var(--ink-2), var(--ink)); box-shadow: 0 18px 60px #000a;
}
.rs-panel header { display: flex; align-items: center; justify-content: space-between; }
.rs-panel h2 { font-size: 1.25em; color: var(--gold-2); }
.rs-x { width: 40px; height: 40px; border-radius: 12px; font-size: 1.5em; line-height: 1; }
.rs-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rs-tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px 8px; min-height: 64px; border-radius: 12px; }
.rs-tab img { height: 44px; width: auto; max-width: 100%; object-fit: contain; object-position: top; pointer-events: none; }
.rs-tab.on { border-color: var(--gold); background: #f7c8a022; box-shadow: inset 0 0 0 1px var(--gold); }
.rs-star { position: absolute; top: 4px; right: 6px; font-size: .6em; color: var(--good); }
.rs-body { display: grid; grid-template-columns: minmax(150px, 38%) 1fr; gap: 14px; align-items: start; }
.rs-stage { position: relative; display: grid; place-items: center; min-height: 220px; border-radius: 12px; background: repeating-conic-gradient(#ffffff0d 0% 25%, #ffffff05 0% 50%) 0 0 / 18px 18px; }
.rs-preview { max-width: 100%; max-height: min(52vh, 420px); width: auto; height: auto; filter: drop-shadow(0 8px 14px #0008); }
.rs-busy { position: absolute; left: 8px; bottom: 6px; font-size: .78em; color: var(--muted); }
.rs-opts { display: grid; gap: 10px; }
.rs-part h3 { margin: 0 0 6px; font-size: .85em; }
.rs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rs-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 12px; border-radius: 999px; }
.rs-chip.on { border-color: var(--gold); background: #f7c8a02b; box-shadow: inset 0 0 0 1px var(--gold); color: var(--gold-2); }
.rs-dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid #ffffff66; flex: none; }
.rs-dot-orig { background: conic-gradient(#f7c8a0, #67e8cb, #ff6f9c, #f7c8a0); }
.rs-note { margin: 0; font-size: .78em; color: var(--muted); }
.rs-panel footer { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.rs-panel footer button { min-height: 44px; padding: 8px 16px; border-radius: 12px; }
.rs-primary { background: var(--gold); color: #2a1a12; border-color: var(--gold); font-weight: 700; }
.rs-open { order: -1; }
@media (max-width: 640px) {
  .rs-body { grid-template-columns: 1fr; }
  .rs-stage { min-height: 180px; }
  .rs-preview { max-height: 30vh; }
}
@media (prefers-reduced-motion: reduce) { .rs-modal { -webkit-backdrop-filter: none; backdrop-filter: none; } }
.rs-x { display: grid; place-items: center; padding: 0; }

/* ---- 出戰角色 (lead character) row in the 造型 panel */
.rs-leadwrap h3 { margin: 0 0 6px; font-size: .85em; }
.rs-lead { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rs-leadbtn { position: relative; min-height: 44px; padding: 6px 4px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.rs-leadbtn.on { border-color: var(--gold); background: #f7c8a022; box-shadow: inset 0 0 0 1px var(--gold); }
.rs-3d { font-style: normal; font-size: .62em; line-height: 1; padding: 2px 6px; border-radius: 999px; background: #7ee8d0; color: #10202a; font-weight: 700; }
.rs-hint { margin: 6px 0 0; font-size: .74em; color: var(--muted); }

/* ---- 偷心賊: hearts / coins flying into the character (canvas drawn by steal-fx.97214da6ec.js; never takes input) */
.steal-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---- 手機版：計時文字不被右側暫停鈕蓋住（score 與 clock 都在 .hud-tr；暫停鈕 fixed 在其下方右側） */
body.has-touch .hud-tr .clock { margin-right: 62px; }

/* ---------------------------------------------------------------- touch camera zoom + exit guide (camera-hud.97214da6ec.js / exit-guide.97214da6ec.js) */
.rg-zoom { position: absolute; left: calc(12px + var(--safe-l, 0px)); top: calc(84px + var(--safe-t, 0px)); display: grid; gap: 8px; pointer-events: none; }
.rg-zbtn {
  pointer-events: auto; touch-action: none; width: 44px; height: 44px; padding: 0; border-radius: 9999px;
  border: 2px solid var(--gold, #f7c8a0); background: #140e20d9; color: var(--gold-2, #ffd9b8);
  font-size: 1.25em; font-weight: 800; line-height: 1; box-shadow: 0 2px 10px #0009;
}
.rg-zbtn.down { transform: scale(.92); background: #f7c8a033; }
body:not(.has-touch) .rg-zoom, body:not(.has-touch) .rg-guide { display: none; }
.rg-guide { position: fixed; inset: 0; z-index: 6; overflow: hidden; pointer-events: none; }
.rg-exit { position: absolute; left: 0; top: 0; display: flex; flex-direction: column-reverse; align-items: center; gap: 2px; will-change: transform; }
.rg-exit.rg-off { flex-direction: column; }
.rg-arrow { font-size: 1.6em; line-height: 1; color: var(--gold-2, #ffd9b8); text-shadow: 0 0 10px #ff6f9c, 0 2px 4px #000; }
.rg-lab {
  padding: 3px 10px; border-radius: 9999px; font-size: .72em; font-weight: 700; white-space: nowrap;
  border: 1.5px solid var(--gold, #f7c8a0); background: #140e20e6; color: var(--gold-2, #ffd9b8); box-shadow: 0 2px 8px #000a;
}
.tbtn.t-use.rg-door-near { border-color: var(--gold-2, #ffd9b8); box-shadow: 0 0 0 3px #f7c8a0aa, 0 0 18px 4px #ff6f9caa; animation: rg-pulse 1s ease-in-out infinite; }
@keyframes rg-pulse { 50% { box-shadow: 0 0 0 5px #f7c8a0, 0 0 26px 8px #ff6f9c; } }
@media (prefers-reduced-motion: reduce) { .tbtn.t-use.rg-door-near { animation: none; } }
/* Short landscape phones (e.g. 568x320): the move stick's top edge is ~156px from the top, so the zoom pair goes side by side under the HP bar. */
@media (max-height: 420px) and (min-aspect-ratio: 1/1) {
  .rg-zoom { top: calc(82px + var(--safe-t, 0px)); grid-auto-flow: column; gap: 6px; }
  .rg-zbtn { width: 36px; height: 36px; font-size: 1.1em; }
}
/* Short landscape phones: the objective block (room title + 波次 line, top 64px) ran into the lifted skill bar (top ~94px) once the wave line appears. The block is only ~110px wide and clear of the HP bar (x<190) and timer, so lift it 28px. */
@media (max-height: 340px) and (min-aspect-ratio: 1/1) and (pointer: coarse) {
  body.has-touch .hud-tc { top: calc(36px + var(--safe-t, 0px)); }
}

/* Bigger touch pad (58 -> 68px) and a hit area 4px larger than the drawn circle on every side (inset -6px = 2px border + 4px) (the gap between buttons is 8px, so
   neighbours just meet). The extra area belongs to the same button element; no handler or gameplay value changes. */
body.has-touch .tbtns .tbtn { position: relative; border: 2px solid #f7c8a0b3; box-shadow: 0 2px 10px #0008; }
body.has-touch .tbtns .tbtn::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; }
body.has-touch .tbtns .tbtn.t-ult { border-color: var(--gold, #f2c867); }
/* Aim-assist ring under the enemy the next attack will be pointed at (touch only; pointer-events none). Solid = inside the aim cone,
   dashed = nearest enemy picked because none was in front. */
.rg-lock { position: fixed; left: 0; top: 0; width: 54px; height: 54px; border: 3px solid #ff6f9c; border-radius: 50%; box-shadow: 0 0 12px 2px #ff6f9caa, inset 0 0 8px #ff6f9c66; pointer-events: none; z-index: 5; will-change: transform; }
.rg-lock.rg-lock-far { border-style: dashed; border-color: #f7c8a0; box-shadow: 0 0 12px 2px #f7c8a0aa; }
body:not(.has-touch) .rg-lock { display: none; }

/* ---- Phones: reward / relic picker (and any other .modal) ----
   Upstream stacks three 240px+ tall cards in one column inside a centred, non-scrolling flex box: on a 390x844 screen the content
   is 857px so the title and the "skip" button are clipped off-screen (unreachable), in an in-app browser (~600px visible) the
   first card is cut as well, and the HUD (HP bar, skill bar) and the touch layer (which sits after the modal in the DOM and
   so is drawn above it) are painted over the cards. (Measured: they cover the text but do not intercept taps.)
   Fix = layout only: (1) hide the HUD and touch layer while a modal is open, (2) let the modal scroll from the top
   (margin:auto on the content centres it when it fits), (3) lay each card out as icon-left / text-right so all three fit. */
@media (max-width: 860px), (max-aspect-ratio: 1/1) {
  #ui:has(.modal.open) > .touch,
  #ui:has(.modal.open) > .screen-hud { visibility: hidden; pointer-events: none; }
  .modal { align-items: flex-start; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    padding: calc(10px + var(--safe-t, 0px)) calc(10px + var(--safe-r, 0px)) calc(14px + var(--safe-b, 0px)) calc(10px + var(--safe-l, 0px)); }
  .modal > .reward, .modal > .panel { margin: auto; }
  .modal[data-kind="reward"] .reward { gap: .5em; }
  .modal[data-kind="reward"] .reward h2 { font-size: 1.35em; }
  .modal[data-kind="reward"] .cards { gap: .4em; }
  .modal[data-kind="reward"] .cards .card {
    display: grid; grid-template-columns: 84px minmax(0, 1fr); grid-template-areas: "ic rar" "ic nm" "ic ds" "ic bg" "ic rk";
    column-gap: .8em; row-gap: .12em; align-content: center; justify-items: start; text-align: left;
    min-height: 0; padding: 1.55em 1.7em 1.95em 1.7em;
  }
  .modal[data-kind="reward"] .card-icons { grid-area: ic; align-self: center; justify-self: center; gap: .2em; }
  .modal[data-kind="reward"] .card-icons .emblem { --s: 38px !important; }
  .modal[data-kind="reward"] .card .rarity { grid-area: rar; }
  .modal[data-kind="reward"] .card b { grid-area: nm; font-size: 1.05em; }
  .modal[data-kind="reward"] .card p { grid-area: ds; font-size: .86em; line-height: 1.3; }
  .modal[data-kind="reward"] .card .badges { grid-area: bg; justify-content: flex-start; gap: .25em; }
  .modal[data-kind="reward"] .card .rank { grid-area: rk; position: static; font-size: .78em; }
  .modal[data-kind="reward"] .card-key { top: 1.1em; left: 1.4em; }
}

/* ---- Phones: the skill bar and the touch pad were the same four skills drawn twice (touch-merge.97214da6ec.js) ----
   .tm-on is set by touch-merge.97214da6ec.js only once it has found the skill bar and the three skill buttons, so if the mirror cannot start
   the original bar stays visible. The bar is kept in the render tree (opacity 0, not display:none) so its icons keep loading.
   The buttons only receive extra inert children (pointer-events:none); the button element, its listeners and its hit area are untouched. */
body.has-touch.tm-on .slotbar { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
body.has-touch .tbtn.tm { display: grid; place-items: center; overflow: visible; --c: #f7c8a0; }
body.has-touch .tbtn.tm > * { pointer-events: none; }
body.has-touch .tbtn.tm .tm-lbl { position: absolute; left: 0; right: 0; bottom: 7%; z-index: 4; text-align: center; font-size: .62em; line-height: 1; white-space: nowrap; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
body.has-touch .tbtn.tm .tm-ico { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); z-index: 1; display: grid; place-items: center; }
body.has-touch .tbtn.tm .tm-ico .emblem { --s: 36px !important; }
body.has-touch .tbtn.t-ult.tm .tm-ico .emblem { --s: 40px !important; }
body.has-touch .tbtn.tm .tm-ico:empty { display: none; }
body.has-touch .tbtn.tm .tm-cd { position: absolute; inset: 0; border-radius: 50%; z-index: 2; background: conic-gradient(#05030acc calc(var(--cd, 0) * 360deg), transparent 0); }
body.has-touch .tbtn.tm .tm-ch { position: absolute; top: 3px; left: 9px; z-index: 5; font-size: .7em; font-weight: 800; color: var(--gold-2, #ffd9b8); text-shadow: 0 1px 2px #000; }
body.has-touch .tbtn.tm .tm-ring { position: absolute; inset: -4px; border-radius: 50%; z-index: 0; pointer-events: none; opacity: 0;
  background: conic-gradient(var(--gold, #f2c867) calc(var(--ult, 0) * 360deg), #ffffff1f 0);
  -webkit-mask: radial-gradient(circle, #0000 calc(50% - 4px), #000 calc(50% - 3px)); mask: radial-gradient(circle, #0000 calc(50% - 4px), #000 calc(50% - 3px)); }
body.has-touch .tbtn.t-ult.tm .tm-ring { opacity: 1; }
body.has-touch .tbtn.tm[data-a="dash"], body.has-touch .tbtn.tm[data-a="secondary"], body.has-touch .tbtn.t-ult.tm { border-color: color-mix(in srgb, var(--c) 75%, #f7c8a0); }
body.has-touch .tbtn.tm.tm-ready { box-shadow: 0 0 14px color-mix(in srgb, var(--c) 55%, transparent), 0 2px 10px #0008; }
body.has-touch .tbtn.t-use.tm { --c: #f7c8a0; }
body.has-touch .tbtn.t-use.tm.tm-idle { opacity: .45; }
body.has-touch .tbtn.t-use.tm .tm-lbl { bottom: auto; top: 50%; transform: translateY(-50%); font-size: .7em; }
/* With the skill bar gone (tm-on) the pad no longer has to sit above it: bring it back to the upstream spot just above the aim stick. */
@media (max-width: 440px) and (max-aspect-ratio: 1/1) {
  body.has-touch.tm-on .tbtns { bottom: calc(176px + var(--safe-b, 0px)); }
}
@media (max-width: 440px) and (max-aspect-ratio: 1/1) and (max-height: 560px) {
  body.has-touch.tm-on .tbtns { bottom: calc(172px + var(--safe-b, 0px)); }
}

/* ---- Phones: relic strip vs. touch controls (checked by rogue-work/relicchk.mjs with 0/6/12/63 relics) ----
   Upstream lets the strip wrap to 90vw with unlimited rows. With >~9 relics it ran under the touch pad (dash / 使用 / 終極技) and with
   dozens it climbed into the zoom buttons, room title and HP text. It now:
   - stays at most two rows high (60px incl. padding) (extra relics scroll vertically inside the strip, they are not dropped),
   - on portrait phones is as wide as the free space left of the touch pad (pad = 144px + 24px margin, plus 12px gap each side).
   The negative margin / padding pair keeps the x2 stack badge (it sticks out 4px) from being clipped by the scroll box. */
body.has-touch .relic-strip { max-height: 60px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; touch-action: pan-y; align-content: flex-start; padding: 2px 6px 6px 2px; margin: -2px -6px 0 -2px; }
body.has-touch .relic-strip::-webkit-scrollbar { display: none; }
@media (max-width: 440px) and (max-aspect-ratio: 1/1) {
  body.has-touch .relic-strip { max-width: calc(100vw - 188px - var(--safe-l, 0px) - var(--safe-r, 0px)); }
}
