:root {
  --v9-mint: #67e8cf;
  --v9-gold: #f5c45b;
  --v9-rose: #ff6f91;
  --v9-cyan: #67c7ff;
  --v9-ink: #f4f7f4;
  --v9-muted: #bac8c8;
  --v9-night: #07100f;
  --v9-panel: rgba(8, 18, 19, .96);
  --v9-line: rgba(142, 231, 211, .28);
}

html, body { background: var(--v9-night); }
#stage { background: #07100f; }
#gc { width: 100%; height: 100%; }
button { letter-spacing: 0; min-width: 46px !important; min-height: 46px !important; }
.hidden { display: none !important; }
/* Juice's pinned floatText implementation uses body-level z-index 100000. */
body:not([data-game-state="play"]) #__juice_overlay,
body:not([data-game-state="play"]) > div[style*="z-index: 100000"] { visibility: hidden !important; }

/* The shared audio control is still available, but it must not cover v9's bottom
   system rail or modal close controls. */
#__juice_mute {
  width: 46px !important;
  height: 46px !important;
  min-width: 46px !important;
  min-height: 46px !important;
  top: calc(var(--dfl-safe-t, 0px) + 112px) !important;
  right: calc(var(--dfl-safe-r, 0px) + 10px) !important;
  bottom: auto !important;
  left: auto !important;
}
body[data-game-state="play"] #__juice_mute {
  top: auto !important;
  right: calc(var(--dfl-safe-r, 0px) + 12px) !important;
  bottom: calc(var(--dfl-safe-b, 0px) + 14px) !important;
}
body:not([data-game-state="start"]):not([data-game-state="play"]) #__juice_mute { display: none !important; }

.icon-action {
  display: none;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 6px;
  color: var(--v9-ink);
  background: rgba(5, 12, 13, .82);
  touch-action: manipulation;
}
#pauseBtn { z-index: 300; }
.icon-action.show { display: flex; }
.icon-action svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.pause-panel { width: min(88vw, 330px); text-align: center; }
.pause-panel .decision-stack { margin-top: 16px; }

#startOv {
  background: rgba(2, 8, 9, .42);
  backdrop-filter: none;
}
#startOv .dfl-panel#homePanel {
  position: absolute;
  inset: var(--dfl-safe-t, 0) var(--dfl-safe-r, 0) var(--dfl-safe-b, 0) var(--dfl-safe-l, 0);
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  padding: 18px 16px max(14px, 7dvh);
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(3, 10, 12, .64), rgba(3, 10, 12, .14) 45%, rgba(3, 10, 12, .84));
  box-shadow: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  overflow: hidden;
}
.home-brand { text-align: center; align-self: start; }
.brand-kicker, .panel-kicker, .goal-label {
  color: var(--v9-gold);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0;
}
#homePanel .title {
  margin-top: 3px;
  font-size: 42px;
  line-height: 1;
  letter-spacing: 0;
  color: var(--v9-ink);
  background: none;
  text-shadow: 0 3px 16px #000;
}
#homePanel .sub {
  margin: 7px auto 0;
  max-width: 320px;
  color: #d9e8e6;
  font-size: 15px;
  line-height: 1.35;
}
.home-focus {
  display: flex;
  min-height: 0;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 9px;
}
#homePanel .onboard { gap: 4px; margin: 0; }
.rune-preview {
  width: 66px;
  height: 66px;
  display: block;
  background-image: url("./assets/rune-atlas-v9.webp");
  background-size: 300% 200%;
  background-position: 0 0;
  filter: drop-shadow(0 4px 12px rgba(57, 255, 211, .34));
}
.onboard-cap { color: var(--v9-mint); font-size: 12px; }
.goal-band {
  width: min(100%, 380px);
  padding: 9px 2px 8px;
  border-top: 1px solid var(--v9-line);
  border-bottom: 1px solid var(--v9-line);
  text-align: left;
}
.goal-band > div:first-child, .goal-reward {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.goal-band strong { color: var(--v9-ink); font-size: 15px; line-height: 1.25; }
.goal-reward { margin-top: 5px; color: var(--v9-muted); font-size: 12px; }
.goal-reward b { flex: 0 0 auto; color: var(--v9-mint); }
.goal-track { height: 5px; margin-top: 7px; overflow: hidden; background: rgba(255, 255, 255, .13); }
.goal-track i { display: block; width: 0; height: 100%; background: var(--v9-mint); transition: width .2s ease; }
.next-unlock { margin-top: 6px; color: var(--v9-gold); font-size: 12px; font-weight: 700; }

.home-controls {
  width: min(100%, 390px);
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.mode-tabs {
  align-self: center;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 280px);
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 6px;
  background: rgba(4, 12, 13, .78);
}
.mode-tab {
  min-height: 46px;
  border: 0;
  border-radius: 4px;
  color: #b9c8c7;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  touch-action: manipulation;
}
.mode-tab.active { color: #07100f; background: var(--v9-mint); }
.btn, .shop-buy {
  border-radius: 6px;
  background: var(--v9-mint);
  color: #051514;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
}
.btn.ghost { border-color: rgba(151, 234, 216, .38); color: #dff9f3; background: rgba(7, 19, 20, .82); }
.start-primary {
  width: 100%;
  min-height: 56px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 17px;
}
.start-primary svg { width: 20px; height: 20px; fill: currentColor; }
.outer-systems {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding-top: 2px;
}
.system-entry {
  position: relative;
  min-width: 0;
  min-height: 48px;
  padding: 4px 2px;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 6px;
  color: #d9e8e6;
  background: rgba(5, 14, 15, .76);
  display: grid;
  grid-template-columns: 20px minmax(0, auto);
  align-content: center;
  justify-content: center;
  column-gap: 4px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  touch-action: manipulation;
}
.system-entry svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.system-entry > span:not(.daily-badge) { white-space: nowrap; }
.system-entry small { grid-column: 1 / -1; min-height: 0; margin-top: 2px; color: var(--v9-gold); font-size: 9px; line-height: 1; white-space: nowrap; }
.system-entry.locked { opacity: .6; }
.system-entry:disabled { filter: grayscale(.4); }
.daily-badge { top: -5px; right: -4px; border-radius: 4px; background: var(--v9-gold); box-shadow: none; color: #171005; }

#hud { padding-left: 54px; }
#hud .hudLabel { letter-spacing: 0; color: #a8bcba; }
#hud .hudVal { font-size: 24px; }
#banner { top: calc(var(--dfl-safe-t) + 86px); max-width: calc(100% - 28px); font-size: 22px; line-height: 1.1; }
#peekBtn, .reward-chip {
  border-radius: 6px;
  box-shadow: 0 5px 16px rgba(0, 0, 0, .35);
}
#peekBtn { gap: 7px; color: #051514; }
#peekLabel { font-size: 12px; }
#peekN { min-width: 20px; height: 20px; padding: 2px 5px; border-radius: 4px; color: #fff; background: #153d38; }
.reward-chip {
  display: none;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid rgba(245, 196, 91, .68);
  color: #fff3c8;
  background: rgba(26, 20, 8, .94);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}
.reward-chip.show { display: flex; }

.video-mark {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  color: var(--v9-gold);
  font-size: 11px;
  line-height: 1;
}
.video-mark svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.ad-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #e9b84a;
  color: #fff7df;
  background: #352608;
}
#focusAdBtn, #reviveAdBtn { padding: 12px 8px; font-size: 13px; white-space: nowrap; }
.decision-stack { width: min(100%, 360px); display: flex; flex-direction: column; gap: 8px; }
.decision-stack .btn { width: 100%; margin: 0; }
.text-btn { border: 0; box-shadow: none; color: #c5d4d3; background: transparent; }
.status-line { min-height: 18px; color: var(--v9-gold); font-size: 12px; line-height: 1.35; }

#goalsOv, #loadoutOv, #rewardOv, #chapterOv, #focusOv, #shopOv, #reviveOv, #overOv {
  background: rgba(2, 8, 9, .78);
}
#goalsOv .dfl-panel, #loadoutOv .dfl-panel, #rewardOv .dfl-panel,
#chapterOv .dfl-panel, #focusOv .dfl-panel, #shopOv .dfl-panel,
#reviveOv .dfl-panel, #overOv .dfl-panel {
  width: min(calc(100% - 24px), 430px);
  max-height: calc(100dvh - var(--dfl-safe-t, 0px) - var(--dfl-safe-b, 0px) - 20px);
  gap: 9px;
  padding: 18px;
  border: 1px solid var(--v9-line);
  border-radius: 8px;
  color: var(--v9-ink);
  background: var(--v9-panel);
  overflow: auto;
}
.compact-panel, .reward-panel, .chapter-panel { text-align: left; }
.compact-panel .big, .reward-panel .big, .chapter-panel .big { font-size: 24px; line-height: 1.08; }
.reward-panel { align-items: center; text-align: center; }
.offer-row {
  width: 100%;
  min-height: 58px;
  padding: 7px 9px;
  border: 1px solid rgba(245, 196, 91, .45);
  border-radius: 6px;
  color: var(--v9-ink);
  background: rgba(245, 196, 91, .08);
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  text-align: left;
  touch-action: manipulation;
}
.offer-row b, .offer-row small { display: block; overflow-wrap: normal; word-break: normal; }
.offer-row b { font-size: 14px; line-height: 1.2; }
.offer-row small { margin-top: 2px; color: #e8cd84; font-size: 11px; line-height: 1.25; }
.offer-art {
  width: 42px;
  height: 42px;
  display: block;
  border-radius: 6px;
  background-image: url("./assets/rune-atlas-v9.webp");
  background-size: 300% 200%;
  background-position: 50% 100%;
}
.preview-art { background-position: 0 0; }
.trail-art { background-position: 50% 100%; filter: hue-rotate(32deg); }
.cache-art { background-position: 100% 100%; }
.reward-art { background-position: 50% 0; }
.offer-art { position: relative; }
.offer-art::after { content: "\25B6"; position: absolute; right: 0; bottom: 0; font-size: 12px; color: #fff1be; background: #15392e; padding: 1px 3px; }
.video-mark:not(:has(svg))::before { content: "\25B6"; font-size: 10px; margin-right: 3px; }
.ad-shortfall small { display: block; font-size: 10px; line-height: 1.1; }
.loadout-preview { width: 100%; display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 9px; align-items: center; padding: 7px 2px; }
.loadout-preview small, .loadout-preview strong { display: block; }
.loadout-preview small { color: var(--v9-muted); font-size: 11px; }
.trail-swatch { width: 42px; height: 42px; border: 1px solid var(--v9-line); border-radius: 50%; background: radial-gradient(circle, #67e8cf 0 8%, transparent 10%), #102422; }

.goal-ladder { width: 100%; display: flex; flex-direction: column; }
.ladder-row { min-height: 52px; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; align-items: center; border-bottom: 1px solid rgba(255, 255, 255, .09); }
.ladder-row:last-child { border-bottom: 0; }
.ladder-node { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .2); border-radius: 50%; color: #d5dfde; font-size: 11px; font-weight: 800; }
.ladder-row.done .ladder-node { border-color: var(--v9-mint); color: #03110f; background: var(--v9-mint); }
.ladder-row.current .ladder-node { border-color: var(--v9-gold); color: var(--v9-gold); }
.ladder-copy b, .ladder-copy small { display: block; }
.ladder-copy b { font-size: 13px; }
.ladder-copy small { margin-top: 2px; color: var(--v9-muted); font-size: 11px; }
.ladder-state { color: var(--v9-gold); font-size: 10px; font-weight: 800; white-space: nowrap; }

.chapter-seal { width: 64px; height: 64px; display: grid; place-items: center; border: 2px solid var(--v9-gold); border-radius: 50%; color: var(--v9-gold); background: #17180e; box-shadow: 0 0 26px rgba(245, 196, 91, .2); }
.chapter-seal span { font-size: 26px; font-weight: 900; }
.reward-bank { color: var(--v9-mint); font-size: 15px; font-weight: 800; }
.chapter-next { color: var(--v9-muted); font-size: 12px; }
.chapter-panel .btn { width: 100%; margin: 0; }
.over-actions { max-width: 100%; }
.over-actions .btn { min-height: 46px; }

#shopList { max-width: 100%; }
.shop-row { border-radius: 6px; background: rgba(255, 255, 255, .045); }
.shop-row:has(.ad-shortfall) .shop-name { font-size: 13px; white-space: nowrap; }
#wellPanel .dfg-hub { background: rgba(3, 13, 12, .92); color: #eff9f4; }
#wellPanel .dfg-hub-title { font-size: 16px; }
#wellPanel .dfg-hub-card { border-radius: 8px; background: rgba(24, 53, 47, .88); border-color: #416d61; box-shadow: none; }
#wellPanel .dfg-hub-card .cbtn, #wellPanel .dfg-hub-close { border-radius: 6px; }
#wellPanel .dfg-hub-card .cbtn[data-rewarded-ad] { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 1px; }
#wellPanel .well-ad-action, #wellPanel [data-rewarded-ad] > span { white-space: nowrap; }
#wellPanel .well-ad-action .video-mark { color: #183b30; }
#cacheAdMeta { display: flex; flex-wrap: wrap; column-gap: 3px; }
#cacheAdMeta span { white-space: nowrap; }
.shop-ico { border-radius: 6px; }
.shop-buy.ad-shortfall { border: 1px solid #e9b84a; color: #fff1be; background: #352608; width: 78px; min-width: 78px; flex: 0 0 78px; display: flex; flex-direction: column; gap: 1px; padding: 4px; font-size: 11px; line-height: 1.1; }
.shop-row.shop-ad-row { flex-direction: column; align-items: stretch; gap: 5px; }
.shop-ad-main { display: flex; align-items: center; gap: 6px; width: 100%; }
.shop-ad-main .shop-ico { width: 28px; height: 28px; flex-basis: 28px; }
.shop-row.shop-ad-row .shop-name { font-size: 12px; }
.shop-ad-main .ad-shortfall { width: 100px; min-width: 100px; flex-basis: 100px; font-size: 10px; }
.shop-ad-main .ad-shortfall > span { white-space: nowrap; }
.shop-quote { color: #f4dfa0; font-size: 11px; line-height: 1.25; overflow-wrap: normal; word-break: normal; }
@media (orientation: portrait) {
  #shopOv .shop-desc { display: block; }
  #shopOv .shop-quote { white-space: nowrap; }
}
@media (orientation: portrait) and (max-height: 760px) {
  #shopOv .dfl-panel { gap: 5px; padding: 12px 18px; }
  #shopTtl { font-size: 24px !important; }
  #shopSub { display: none; }
  #shopList { gap: 5px; }
  .shop-row { padding: 6px 10px; }
}
@media (orientation:landscape) and (max-height:520px) {
  .shop-ad-main { flex-direction: column; flex: 1; gap: 4px; }
  .shop-ad-main .ad-shortfall { width: 100%; min-width: 46px; flex-basis: auto; }
  .shop-quote { font-size: 10px; text-align: center; }
}

@media (max-width: 359px) {
  #startOv .dfl-panel#homePanel { padding: 12px 10px 10px; gap: 6px; }
  #homePanel .title { font-size: 32px; }
  #homePanel .sub { margin-top: 4px; font-size: 13px; }
  #homePanel .onboard { display: none; }
  .goal-band { padding-top: 7px; padding-bottom: 6px; }
  .goal-band strong { font-size: 13px; }
  .home-controls { gap: 6px; }
  .mode-tabs { width: 236px; }
  .mode-tab { min-height: 46px; }
  .start-primary { min-height: 50px; font-size: 15px; }
  .outer-systems { gap: 4px; }
  .system-entry { min-height: 46px; grid-template-columns: 17px minmax(0, auto); font-size: 10px; }
  .system-entry svg { width: 17px; height: 17px; }
  .system-entry small { font-size: 8px; }
  #hud { padding-left: 48px; }
  #hud .hudVal { font-size: 21px; }
  #banner { top: calc(var(--dfl-safe-t) + 80px); font-size: 19px; }
}

@media (max-height: 600px) and (orientation: portrait) {
  #startOv .dfl-panel#homePanel { padding-top: 10px; gap: 5px; }
  #homePanel .title { font-size: 32px; }
  #homePanel .sub { margin-top: 3px; font-size: 12px; }
  #homePanel .onboard { display: none; }
  .goal-band { padding-top: 6px; padding-bottom: 5px; }
  .mode-tab { min-height: 46px; }
  .start-primary { min-height: 48px; }
  .system-entry { min-height: 46px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  body[data-game-state="start"] #__juice_mute { top: calc(var(--dfl-safe-t, 0px) + 10px) !important; }
  #startOv .dfl-panel#homePanel {
    padding: 10px 44px 9px;
    grid-template-columns: .8fr 1.1fr 1.2fr;
    grid-template-rows: minmax(0, 1fr);
    align-items: center;
    gap: 14px;
  }
  .home-brand { text-align: left; }
  #homePanel .title { font-size: 32px; }
  #homePanel .sub { margin: 6px 0 0; font-size: 12px; }
  #homePanel .onboard { display: none; }
  .home-focus { justify-content: center; }
  .goal-band { width: 100%; }
  .home-controls { width: 100%; gap: 6px; }
  .mode-tabs { width: 100%; }
  .start-primary { min-height: 48px; }
  .system-entry { min-height: 46px; grid-template-columns: 14px minmax(0, auto); column-gap: 3px; padding: 4px 1px; font-size: 10px; }
  .system-entry svg { width: 14px; height: 14px; }
  #goalsOv .dfl-panel, #loadoutOv .dfl-panel, #rewardOv .dfl-panel,
  #chapterOv .dfl-panel, #focusOv .dfl-panel, #shopOv .dfl-panel,
  #reviveOv .dfl-panel, #overOv .dfl-panel {
    width: min(calc(100% - 80px), 720px);
    max-width: min(calc(100% - 80px), 720px);
    max-height: calc(100dvh - 16px);
    padding: 10px 42px;
    gap: 5px;
  }
  .goal-ladder { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; }
  .ladder-row { min-height: 43px; }
  .decision-stack { flex-direction: row; width: 100%; }
  .decision-stack .btn { min-width: 0; }
  #overOv .over-actions { width: 100%; max-width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #overOv .over-actions .btn { min-height: 46px; }
  #chapterOv .chapter-panel { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); grid-template-rows: repeat(6, auto); column-gap: 18px; align-items: center; }
  .chapter-panel .chapter-seal { grid-column: 1; grid-row: 1 / span 2; width: 54px; height: 54px; justify-self: center; }
  #chapterKicker { grid-column: 1; grid-row: 3; }
  #chapterTitle { grid-column: 1; grid-row: 4; font-size: 20px; }
  #chapterBaseReward { grid-column: 1; grid-row: 5; font-size: 13px; }
  #chapterNext { grid-column: 1; grid-row: 6; font-size: 12px; }
  #chapter5xBtn { grid-column: 2; grid-row: 1 / span 2; }
  #cacheAdBtn { grid-column: 2; grid-row: 3 / span 2; }
  #chapterNextBtn { grid-column: 2; grid-row: 5; }
  #chapterHomeBtn { grid-column: 2; grid-row: 6; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; }
  .rune-preview, .offer-art { filter: none !important; }
}

@media (orientation: portrait) and (max-height: 600px) {
  #shopOv .dfl-panel { padding: 6px 10px; gap: 3px; }
  #shopOv #shopTtl { font-size: 20px !important; }
  #shopList { display: flex; flex-direction: column; gap: 3px; margin-top: 0; }
  #shopOv .shop-row { min-height: 0; padding: 2px 6px; flex-direction: row; text-align: left; }
  #shopOv .shop-row.shop-ad-row { flex-direction: column; gap: 2px; }
  #shopOv .shop-meta { align-items: flex-start; }
  #shopOv .shop-name { font-size: 12px; white-space: nowrap; }
  #shopOv .shop-ico { width: 24px; height: 24px; flex-basis: 24px; }
  #shopOv .shop-buy { width: 64px; min-width: 64px; }
  #shopOv .shop-ad-main .ad-shortfall { width: 100px; min-width: 100px; }
}
