:root {
  color-scheme: dark;
  --ink: #050710;
  --panel: #11182b;
  --panel-2: #18213a;
  --line: #405477;
  --line-bright: #7187ad;
  --text: #fbfbf7;
  --muted: #c4ccdd;
  --purple: #72d5e8;
  --purple-deep: #285d69;
  --cyan: #72d5e8;
  --red: #e34b68;
  --gold: #e6b84a;
  --green: #63d19e;
  --shadow: 0 18px 60px rgba(0, 0, 0, .48);
  --pixel: ui-monospace, "Cascadia Mono", "BIZ UDPGothic", "Yu Gothic UI", monospace;
  --body: system-ui, "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  --speed: 1;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ink);
  min-height: 100%;
  scrollbar-color: var(--cyan) var(--ink);
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--body);
  background:
    radial-gradient(circle at 50% -20%, rgba(42, 137, 158, .28), transparent 45rem),
    radial-gradient(circle at 100% 40%, rgba(22, 91, 124, .13), transparent 36rem),
    linear-gradient(180deg, #070913 0%, #04060d 78%, #071017 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .16;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .02) 1px, transparent 1px);
  background-size: 4px 4px;
  image-rendering: pixelated;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

button:not(:disabled),
select,
input[type="range"],
input[type="checkbox"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

.is-hidden {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -80px;
  z-index: 100;
  padding: 10px 16px;
  color: #000;
  background: var(--cyan);
}

.skip-link:focus {
  top: 12px;
}

.abyss-shell {
  width: min(1240px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.topbar {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 10px 12px 12px;
  border-bottom: 2px solid var(--line);
}

.brand-block h1 {
  margin: 2px 0 0;
  font: 900 clamp(1.45rem, 3vw, 2.15rem)/.95 var(--pixel);
  letter-spacing: -.08em;
  text-shadow: 3px 3px 0 #10343c;
}

.brand-block h1 span { color: var(--cyan); }

.eyebrow,
.kicker,
.micro-heading,
.status-card > span,
.board-head span,
.enemy-title span,
.intent-card small,
footer {
  color: var(--muted);
  font: 700 .68rem/1.2 var(--pixel);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.run-stats {
  display: flex;
  gap: 6px;
}

.run-stats > div {
  min-width: 70px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: rgba(9, 13, 27, .82);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .35);
}

.run-stats span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font: 700 .58rem var(--pixel);
}

.run-stats strong {
  font: 800 .9rem var(--pixel);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line-bright);
  border-radius: 4px;
  color: var(--text);
  background: linear-gradient(#171d31, #0a0e1c);
  box-shadow: inset 0 0 0 2px #080b14;
}

.icon-button:hover {
  border-color: var(--cyan);
}

main {
  min-height: calc(100dvh - 132px);
}

.screen {
  position: relative;
  min-height: calc(100dvh - 150px);
  padding: clamp(24px, 4vw, 52px) 10px;
  animation: screen-in calc(.35s / var(--speed)) steps(5, end) both;
}

.screen::after {
  content: "";
  position: absolute;
  z-index: 40;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, #060810 0 8px, #11142a 8px 16px);
  transform-origin: right;
  animation: pixel-wipe calc(.42s / var(--speed)) steps(10, end) both;
}

@keyframes pixel-wipe { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.scene-atlas {
  background-image: linear-gradient(rgba(3, 5, 12, .12), rgba(3, 5, 12, .46)), url('./assets/generated/web-image2-v1/scene-atlas.webp');
  background-size: 300% 200%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
.scene-atlas[data-scene="title"] { background-position: 0 0; }
.scene-atlas[data-scene="mark"] { background-position: 50% 0; }
.scene-atlas[data-scene="route"] { background-position: 100% 0; }
.scene-atlas[data-scene="event"] { background-position: 0 100%; }
.scene-atlas[data-scene="shop"] { background-position: 50% 100%; }
.scene-atlas[data-scene="reward"] { background-position: 100% 100%; }

.scene-banner {
  width: min(760px, 94vw);
  height: clamp(132px, 22vw, 220px);
  margin: 0 auto;
  border: 2px solid var(--line);
  box-shadow: var(--shadow), inset 0 0 0 4px rgba(2, 4, 10, .72);
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.start-screen {
  position: relative;
  display: grid;
  grid-template-columns: minmax(280px, 1.1fr) minmax(300px, .9fr);
  align-items: center;
  gap: clamp(28px, 6vw, 76px);
  overflow: hidden;
}

.title-art {
  position: relative;
  min-height: min(62vw, 560px);
  border: 2px solid var(--line);
  overflow: hidden;
  background-color: #070913;
  box-shadow: var(--shadow);
  image-rendering: pixelated;
  background-image: linear-gradient(180deg, rgba(2, 5, 10, .02), rgba(2, 5, 10, .18)), url('./assets/generated/web-image2-v1/title-keyart.webp') !important;
  background-size: cover !important;
  background-position: center !important;
}

.title-gate,
.title-water {
  position: absolute;
  pointer-events: none;
}
.title-gate,
.title-water { display: none; }
@keyframes gate-pulse { 50% { transform: scale(.97); filter: brightness(1.35); } }
@keyframes water-step { 50% { transform: translateX(5%); opacity: .55; } }

.moon {
  position: absolute;
  top: 9%;
  left: 12%;
  width: clamp(70px, 11vw, 130px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #d7f6fa;
  box-shadow: 0 0 0 8px rgba(114, 213, 232, .10), 0 0 50px rgba(67, 180, 201, .45);
}

.deep-eye {
  position: absolute;
  inset: 25% 20% auto;
  display: grid;
  place-items: center;
  height: 38%;
  color: #a8edf6;
  font: 900 clamp(6rem, 18vw, 13rem)/1 var(--pixel);
  text-shadow: 0 0 15px var(--cyan), 0 0 50px #155c69;
  animation: breathe calc(4s / var(--speed)) steps(8, end) infinite;
}

@keyframes breathe {
  50% { transform: scale(1.04) translateY(-3px); filter: brightness(1.25); }
}

.mist {
  position: absolute;
  width: 75%;
  height: 20px;
  border: solid rgba(92, 190, 208, .44);
  border-width: 3px 0;
  opacity: .55;
  filter: blur(2px);
}

.mist-a { left: -10%; top: 68%; transform: rotate(-4deg); }
.mist-b { right: -12%; top: 78%; transform: rotate(3deg); }

.title-copy {
  position: relative;
  z-index: 2;
}

.title-copy h2,
.section-heading h2,
.result-screen h2 {
  margin: 10px 0 18px;
  font: 900 clamp(2.2rem, 6vw, 4.9rem)/.95 var(--pixel);
  letter-spacing: -.09em;
}

.title-copy h2 span { color: var(--cyan); text-shadow: 3px 3px 0 #123f48; }

.title-copy > p:not(.kicker),
.section-heading > p:not(.kicker),
.result-screen > p:not(.kicker) {
  max-width: 56ch;
  color: #c1c7d7;
  line-height: 1.8;
}

.title-actions,
.screen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.hold-button,
.choice-card,
.shop-card,
.potion-button {
  min-height: 48px;
  border-radius: 3px;
  font: 800 .78rem/1.25 var(--pixel);
}

.primary-button,
.secondary-button,
.danger-button {
  padding: 14px 20px;
  border: 1px solid;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .45), 4px 4px 0 rgba(0, 0, 0, .4);
}

.primary-button {
  border-color: #ffe08a;
  color: #071018;
  background: linear-gradient(180deg, #ffe184, #e6a73f);
}

.primary-button:hover {
  filter: brightness(1.18);
}

.secondary-button {
  border-color: var(--line-bright);
  background: linear-gradient(180deg, #1a2340, #0d1326);
}

.danger-button {
  border-color: var(--red);
  background: linear-gradient(180deg, #69273b, #351522);
}

.text-button {
  padding: 8px 2px;
  color: var(--cyan);
  background: none;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.hold-button {
  position: relative;
  min-width: 190px;
  padding: 0 14px;
  overflow: hidden;
  color: var(--muted);
  border: 1px solid var(--line);
  background: #090d18;
}

.hold-button span {
  position: relative;
  z-index: 2;
}

.hold-button i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: rgba(227, 75, 104, .35);
}

.hold-button.is-holding i {
  width: 100%;
  transition: width 1.5s linear;
}

.start-options {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 10px;
  margin-top: 18px;
}

.start-options label {
  color: var(--muted);
  font: 700 .68rem var(--pixel);
}

.start-options input,
.start-options select {
  width: 100%;
  height: 44px;
  margin-top: 5px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--text);
  background: #080c18;
}

.record-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 14px;
}

.record-panel > div {
  min-width: 0;
  padding: 9px 8px;
  border: 1px solid var(--line);
  background: rgba(8, 12, 24, .82);
}

.record-panel span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font: 700 .56rem var(--pixel);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.record-panel strong {
  display: block;
  margin-top: 5px;
  color: var(--cyan);
  font: 900 .82rem var(--pixel);
}

.next-goal {
  margin: 10px 0 0 !important;
  color: #d6c9ee !important;
  font: 700 .68rem/1.55 var(--pixel);
}

.choice-screen {
  display: grid;
  align-content: center;
  gap: 28px;
}

.choice-screen .scene-banner + .section-heading { margin-top: -74px; padding: 24px 30px 18px; position: relative; z-index: 2; background: rgba(5, 7, 15, .82); border: 1px solid rgba(82, 174, 190, .34); }

.section-heading {
  max-width: 820px;
  margin: 0 auto;
  text-align: center;
}

.section-heading h2 {
  font-size: clamp(2rem, 6vw, 4rem);
}

.card-grid {
  display: grid;
  gap: 14px;
}

.mark-grid,
.event-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(1040px, 100%);
  margin: 0 auto;
}

.choice-card,
.shop-card {
  position: relative;
  min-height: 190px;
  padding: 20px;
  text-align: left;
  border: 1px solid var(--line);
  color: var(--text);
  background:
    linear-gradient(145deg, rgba(20, 48, 58, .82), rgba(7, 12, 25, .95)),
    #090d1a;
  box-shadow: inset 0 0 0 3px rgba(3, 5, 12, .8), 6px 6px 0 rgba(0, 0, 0, .35);
}

.choice-card > .atlas-icon,
.shop-card > .atlas-icon { float: right; margin: -4px -4px 8px 12px; }

.choice-card:hover,
.shop-card:hover:not(:disabled) {
  z-index: 2;
  border-color: var(--cyan);
  transform: translateY(-3px);
}

.choice-card[data-alignment="blood"] { border-top: 4px solid var(--red); }
.choice-card[data-alignment="knowledge"] { border-top: 4px solid var(--cyan); }
.choice-card[data-alignment="void"] { border-top: 4px solid #d58a45; }

.choice-card small,
.shop-card small {
  color: var(--muted);
  font: 700 .65rem var(--pixel);
  letter-spacing: .08em;
}

.choice-card strong,
.shop-card strong {
  display: block;
  margin: 12px 0;
  font: 900 1.18rem var(--pixel);
}

.choice-card p,
.shop-card p {
  margin: 0;
  color: #b8c0d3;
  line-height: 1.65;
}

.combat-screen {
  padding-top: 20px;
}

.combat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 16px;
}

.combat-primary {
  min-width: 0;
}

.enemy-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(150px, .72fr) minmax(260px, 1.28fr);
  min-height: 235px;
  overflow: hidden;
  border: 2px solid var(--line);
  background: #080b18;
  box-shadow: var(--shadow), inset 0 0 0 3px #03050b;
}

.enemy-panel.is-hit {
  animation: enemy-hit calc(.25s / var(--speed)) steps(3, end);
}

@keyframes enemy-hit {
  35% { filter: saturate(2) brightness(1.8); transform: translateX(-3px); }
}

.enemy-scene {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #050712;
}

.enemy-scene::before {
  content: "";
  position: absolute;
  inset: 60% -20% -20%;
  background:
    linear-gradient(160deg, transparent 35%, #173055 36% 44%, transparent 45%),
    linear-gradient(200deg, transparent 38%, #173846 39% 47%, transparent 48%);
  opacity: .22;
}

.enemy-art {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background-image: var(--enemy-art);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  animation: enemy-idle calc(2.8s / var(--speed)) steps(6,end) infinite;
}

.title-more {
  margin-top: 14px;
  color: var(--muted);
  font-size: .78rem;
}
.title-more > summary { cursor: pointer; width: max-content; padding: 8px 0; }

@media (max-width: 720px) and (orientation: portrait) {
  .start-screen {
    display: flex;
    min-height: calc(100dvh - 92px);
    flex-direction: column;
    gap: 0;
    padding: 4px 0 18px;
  }
  .start-screen .title-art {
    width: 100%;
    min-height: 0;
    height: min(47dvh, 390px);
    border-width: 0 0 2px;
  }
  .start-screen .title-copy {
    width: 100%;
    margin-top: -42px;
    padding: 0 14px;
    text-align: center;
  }
  .start-screen .title-copy h2 { margin: 6px 0 8px; font-size: clamp(2rem, 11vw, 3rem); text-shadow: 0 4px 16px #000; }
  .start-screen .title-copy > p:not(.kicker) { margin: 0 auto; font-size: .88rem; line-height: 1.5; }
  .start-screen .mechanic-hook { margin: 12px auto 0; }
  .start-screen .title-actions { margin-top: 12px; justify-content: center; }
  .start-screen .primary-button { min-width: min(310px, 92vw); min-height: 58px; font-size: 1rem; }
  .start-screen .title-more { text-align: left; }
  .start-screen .title-more > summary { margin: 0 auto; }
  .start-screen .record-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .start-screen .title-gate, .start-screen .title-water { display: none; }
}
@keyframes enemy-idle { 50% { transform: translateY(-3px) scale(1.015); filter: brightness(1.08); } }

.enemy-aura {
  position: absolute;
  width: 60%;
  aspect-ratio: 1;
  border: 2px dashed rgba(114, 213, 232, .40);
  border-radius: 50%;
  display: none;
}

@keyframes turn { to { transform: rotate(1turn); } }

.enemy-sigil {
  position: absolute;
  z-index: 4;
  left: 10px;
  bottom: 10px;
  width: 42px;
  height: 42px;
  border: 2px solid #4a8691;
  background-color: rgba(6, 8, 18, .86);
  box-shadow: 3px 3px 0 #070913, 0 0 12px rgba(114, 213, 232, .22);
  animation: breathe calc(3.4s / var(--speed)) steps(7, end) infinite;
}

.damage-float { position:absolute; z-index:6; right:12%; top:20%; opacity:0; color:#fff1a6; font:900 clamp(1.6rem,5vw,3.6rem)/1 var(--pixel); text-shadow:3px 3px 0 #8a5424; pointer-events:none; }
.damage-float.is-active { animation: damage-float calc(.58s / var(--speed)) steps(6,end); }
.enemy-panel.has-impact::after { content:""; position:absolute; z-index:5; inset:0; pointer-events:none; border:4px solid rgba(255,238,151,.7); animation: merge-shock calc(.44s / var(--speed)) steps(5,end); }
@keyframes damage-float { 20% { opacity:1; transform:translateY(0) scale(1.2); } 100% { opacity:0; transform:translateY(-28px); } }
@keyframes merge-shock { from { opacity:1; transform:scale(.86); } to { opacity:0; transform:scale(1.04); } }

.enemy-copy {
  display: grid;
  min-width: 0;
  align-content: center;
  gap: 15px;
  padding: 18px;
  background: linear-gradient(90deg, rgba(7, 18, 24, .72), rgba(8, 14, 23, .98));
}

.enemy-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.enemy-title h2 {
  margin: 4px 0 0;
  font: 900 clamp(1.3rem, 4vw, 2.15rem)/1.05 var(--pixel);
}

.enemy-title > strong {
  padding: 5px 7px;
  color: var(--cyan);
  border: 1px solid #285d69;
  font: 800 .62rem var(--pixel);
}

.bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.bar {
  height: 16px;
  padding: 3px;
  border: 1px solid #5c2740;
  background: #160812;
}

.bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(90deg, #b62e50 0 12px, #d94a66 12px 16px);
  transition: width calc(.32s / var(--speed)) steps(8, end);
}

.bar-row b {
  font: 800 .72rem var(--pixel);
}

.intent-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 9px 12px;
  border: 1px solid #67314b;
  background: linear-gradient(90deg, rgba(104, 24, 58, .24), rgba(24, 13, 35, .65));
}
.intent-card { animation: intent-warning calc(1.5s / var(--speed)) steps(6,end) infinite; }
@keyframes intent-warning { 50% { border-color:#b74a68; box-shadow: inset 0 0 16px rgba(172,48,88,.22); } }

.intent-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--red);
  border: 1px solid #743047;
  font: 900 1.35rem var(--pixel);
}

.atlas-icon { display:inline-block; width:36px; height:36px; flex:0 0 auto; background-image:url('./assets/generated/web-image2-v1/ui-icon-atlas.webp'); background-size:400% 400%; background-repeat:no-repeat; image-rendering:pixelated; vertical-align:middle; }
.atlas-icon[data-icon="flesh-mark"] { background-position:0 0; }
.atlas-icon[data-icon="knowledge-mark"] { background-position:33.333% 0; }
.atlas-icon[data-icon="void-mark"] { background-position:66.667% 0; }
.atlas-icon[data-icon="echo-coin"] { background-position:100% 0; }
.atlas-icon[data-icon="heal"] { background-position:0 33.333%; }
.atlas-icon[data-icon="cleanse"] { background-position:33.333% 33.333%; }
.atlas-icon[data-icon="ward"] { background-position:66.667% 33.333%; }
.atlas-icon[data-icon="transmute"] { background-position:100% 33.333%; }
.atlas-icon[data-icon="combat"] { background-position:0 66.667%; }
.atlas-icon[data-icon="elite"] { background-position:33.333% 66.667%; }
.atlas-icon[data-icon="boss"] { background-position:66.667% 66.667%; }
.atlas-icon[data-icon="event-node"] { background-position:100% 66.667%; }
.atlas-icon[data-icon="shop"] { background-position:0 100%; }
.atlas-icon[data-icon="reward"] { background-position:33.333% 100%; }
.atlas-icon[data-icon="relic"] { background-position:66.667% 100%; }
.atlas-icon[data-icon="ward-icon"] { background-position:100% 100%; }
.intent-icon.atlas-icon { border:1px solid #743047; background-color:#120b18; }
.status-mark { display:flex!important; align-items:center; gap:8px; }
.status-mark .atlas-icon { width:30px; height:30px; }
.relic-button .atlas-icon { width:26px; height:26px; }
.relic-button > span:last-child { font-size:.52rem; }
.potion-button .atlas-icon { float:left; width:32px; height:32px; margin:0 8px 4px 0; }

.intent-card strong {
  display: block;
  margin-top: 4px;
  font: 800 .78rem var(--pixel);
}

.intent-card > b {
  color: #ff7b8e;
  font: 900 1.35rem var(--pixel);
}

.relic-section,
.potion-section {
  position: relative;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(8, 12, 25, .78);
}

.micro-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.relic-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 38px;
}

.relic-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line-bright);
  color: #c9edf2;
  background: #12152b;
  font: 800 .65rem var(--pixel);
}

.relic-button[data-rarity="rare"] { color: var(--cyan); border-color: #267b92; }
.relic-button[data-rarity="abyss"] { color: var(--gold); border-color: #8e6b23; box-shadow: inset 0 0 12px rgba(230, 184, 74, .15); }

.relic-button.is-triggered {
  animation: relic-flash calc(.6s / var(--speed)) steps(5, end);
}

@keyframes relic-flash {
  30% { background: #c9f3f6; color: #07151a; box-shadow: 0 0 12px rgba(114,213,232,.35); }
}

.relic-empty {
  color: #687188;
  font: .72rem var(--pixel);
}

.popover {
  position: absolute;
  z-index: 15;
  left: 10px;
  bottom: calc(100% - 8px);
  width: min(380px, calc(100vw - 48px));
  padding: 12px;
  border: 1px solid var(--purple);
  color: #ded7ed;
  background: #090b18;
  box-shadow: var(--shadow);
}

.popover strong {
  display: block;
  margin-bottom: 5px;
  color: var(--purple);
  font: 800 .82rem var(--pixel);
}

.board-frame {
  position: relative;
  width: min(620px, 100%);
  margin: 14px auto 0;
  padding: 12px;
  border: 2px solid var(--line-bright);
  background: linear-gradient(145deg, #0b1020, #080a15);
  box-shadow: 7px 8px 0 #020308, inset 0 0 0 3px #03050b;
}

.board-head {
  display: grid;
  grid-template-columns: minmax(70px, auto) 1fr minmax(70px, auto);
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.board-head > div {
  padding: 7px;
  text-align: center;
  border: 1px solid var(--line);
  background: #080c19;
}

.board-head strong {
  display: block;
  margin-top: 3px;
  color: var(--cyan);
  font: 900 .92rem var(--pixel);
}

.board-head p {
  margin: 0;
  color: #adb5c8;
  font-size: .78rem;
  line-height: 1.5;
  text-align: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(5px, 1.4vw, 9px);
  aspect-ratio: 1;
  padding: clamp(6px, 1.6vw, 10px);
  touch-action: none;
  overscroll-behavior: contain;
  user-select: none;
  border: 1px solid #253b5d;
  background:
    linear-gradient(135deg, rgba(50, 47, 92, .4), rgba(7, 16, 29, .9)),
    #0a0d19;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  border: 2px solid #31394f;
  color: #d8d9d7;
  background: linear-gradient(145deg, #252938, #151a26);
  box-shadow: inset 0 0 0 3px rgba(4, 6, 12, .7), 3px 3px 0 #02040a;
  font: 900 clamp(1rem, 5vw, 2.25rem)/1 var(--pixel);
}

.cell::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 255, 255, .05);
  pointer-events: none;
}

.cell.is-empty {
  opacity: .52;
}

.cell[data-value="2"],
.cell[data-value="4"] { color: #e3e2df; }
.cell[data-value="8"],
.cell[data-value="16"] { color: #8fe4ff; border-color: #2d6c84; background: linear-gradient(145deg, #173149, #101c2c); }
.cell[data-value="32"],
.cell[data-value="64"] { color: #b9f3fa; border-color: #2f7886; background: linear-gradient(145deg, #1d4e59, #112d34); }
.cell[data-value="128"],
.cell[data-value="256"] { color: #ff9ead; border-color: #8c3348; background: linear-gradient(145deg, #5b2135, #30131f); }
.cell[data-value="512"],
.cell[data-value="1024"] { color: #ffd878; border-color: #977025; background: linear-gradient(145deg, #5c4717, #2d240f); }
.cell[data-value="2048"] { color: #fff4ae; border-color: #d5aa31; background: linear-gradient(145deg, #8c6418, #3d2c0e); box-shadow: 0 0 18px rgba(255, 200, 66, .45), inset 0 0 0 3px #2b1908; }

.cell.is-merged {
  animation: tile-pop calc(.28s / var(--speed)) steps(4, end);
}

@keyframes tile-pop {
  40% { transform: scale(1.09); filter: brightness(1.5); }
}

.cell.is-cursed {
  border-color: var(--red);
}

.cell.is-cursed::before {
  content: attr(data-curse);
  position: absolute;
  top: 3px;
  right: 4px;
  color: #ff7a8f;
  font: 900 .62rem var(--pixel);
}

.cell.is-targetable {
  cursor: crosshair;
  animation: target-pulse calc(1s / var(--speed)) steps(4, end) infinite;
}

@keyframes target-pulse {
  50% { border-color: var(--cyan); filter: brightness(1.25); }
}

.lock-warning {
  position: absolute;
  inset: 58px 12px 12px;
  z-index: 10;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 22px;
  text-align: center;
  background: rgba(11, 5, 14, .94);
  border: 2px solid var(--red);
}

.potion-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.combat-compact { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:8px; }
.potion-count { display:flex; align-items:baseline; gap:7px; color:var(--muted); font:800 .72rem var(--pixel); }
.potion-count b { color:var(--text); font-size:.9rem; }
.mark-chip { display:grid; place-items:center; width:42px; height:42px; padding:0; border:1px solid var(--line); background:#0a111d; }
.mark-chip:hover, .mark-chip[aria-expanded="true"] { border-color:var(--cyan); }
.mark-chip .atlas-icon { width:30px; height:30px; }

.potion-button {
  min-width: 0;
  padding: 10px;
  text-align: left;
  border: 1px solid #3d4b6d;
  color: var(--text);
  background: linear-gradient(145deg, #1b2542, #0c1222);
}
.potion-button.is-using { animation: potion-use calc(.55s / var(--speed)) steps(5,end); }
@keyframes potion-use { 50% { transform:translateY(-3px); filter:brightness(1.4); box-shadow:0 0 18px rgba(93,207,229,.4); } }

.relic-button.relic-merge { border-color:#9a4d5f; }
.relic-button.relic-board { border-color:#4c7a86; }
.relic-button.relic-defense { border-color:#6f76a8; }
.relic-button.relic-potion { border-color:#4b8f7d; }
.relic-button.relic-economy { border-color:#a27a35; }
.relic-button.relic-conditional { border-color:#b97838; }

.potion-button strong,
.potion-button span {
  display: block;
}

.potion-button strong {
  overflow: hidden;
  font-size: .7rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.potion-button span {
  margin-top: 5px;
  color: var(--muted);
  font-size: .64rem;
  line-height: 1.35;
}

.potion-button.is-selected {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(75, 200, 227, .16);
}

.potion-button:disabled {
  opacity: .42;
}

.selection-hint {
  margin: 8px 0 0;
  color: var(--cyan);
  font-size: .78rem;
}

.combat-side {
  display: grid;
  align-content: start;
  gap: 12px;
}

.status-card,
.combat-log {
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(9, 13, 27, .84);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .4);
}

.status-card > strong {
  display: block;
  margin: 9px 0 6px;
  color: var(--cyan);
  font: 900 .88rem var(--pixel);
}

.status-card p {
  margin: 0;
  color: #aeb6c9;
  font-size: .76rem;
  line-height: 1.55;
}

.alignment-meter {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.alignment-meter b {
  padding: 7px 8px;
  border-left: 3px solid currentColor;
  background: #080c18;
  font: 700 .7rem var(--pixel);
}

.blood { color: var(--red); }
.knowledge { color: var(--cyan); }
.void { color: #d58a45; }

.combat-log {
  min-height: 0;
}

.log-row {
  padding: 8px 0;
  color: #aeb6c9;
  border-bottom: 1px solid rgba(66, 79, 112, .3);
  font: .7rem/1.45 var(--pixel);
}

.log-row:first-child {
  color: var(--text);
}

.log-row.damage { color: #ff8ea2; }
.log-row.heal { color: var(--green); }
.log-row.relic { color: var(--gold); }

.event-art {
  display: grid;
  place-items: center;
  width: min(520px, 90vw);
  height: 190px;
  margin: 0 auto;
  overflow: hidden;
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
}

.event-details { width:min(620px,100%); margin:8px auto 0; color:var(--muted); text-align:left; }
.event-details summary { cursor:pointer; width:max-content; margin:0 auto; padding:7px 0; font:700 .72rem var(--pixel); }
.event-details p { margin:8px 0 0; line-height:1.55; }

.shop-groups {
  display: grid;
  gap: 24px;
  width: min(1100px, 100%);
  margin: 0 auto;
}

.shop-groups h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font: 800 .82rem var(--pixel);
}

.shop-grid {
  grid-template-columns: repeat(3, 1fr);
}

.shop-card {
  min-height: 150px;
}

.shop-card b {
  display: inline-block;
  margin-top: 14px;
  padding: 6px 8px;
  color: var(--gold);
  background: #17130a;
  font: 800 .72rem var(--pixel);
}

.shop-card:disabled {
  opacity: .4;
}

.result-screen {
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
}
.result-scene { position:relative; overflow:hidden; margin-bottom:-38px; opacity:1; }
.result-screen > :not(.result-scene) { position:relative; z-index:2; }
.result-scene::after { content:""; position:absolute; inset:0; background:linear-gradient(180deg,rgba(3,5,12,.02),rgba(3,5,12,.28)); }
.result-scene.is-reward-burst::before { content:""; position:absolute; z-index:3; left:50%; top:52%; width:90px; height:90px; transform:translate(-50%,-50%); border:8px double #e6b84a; animation:reward-burst calc(.8s / var(--speed)) steps(8,end); }
.result-scene.is-route-pulse::before { content:""; position:absolute; z-index:3; left:50%; top:50%; width:42px; height:42px; border:5px solid #72d5e8; animation:route-node-pulse calc(1.3s / var(--speed)) steps(6,end) infinite; }
@keyframes reward-burst { from { opacity:0; transform:translate(-50%,-50%) scale(.2) rotate(0); } 55% { opacity:1; } to { opacity:0; transform:translate(-50%,-50%) scale(2) rotate(90deg); } }
@keyframes route-node-pulse { 50% { transform:scale(1.45); opacity:.38; } }
.defeated-enemy-ghost { position:absolute; z-index:2; inset:0; background-image:var(--enemy-art); background-size:cover; background-position:center; background-repeat:no-repeat; image-rendering:pixelated; }
.defeated-enemy-ghost.is-dissolving { animation:enemy-dissolve calc(.9s / var(--speed)) steps(10,end) forwards; }
@keyframes enemy-dissolve { from { opacity:.62; filter:contrast(1.3); clip-path:inset(0); } to { opacity:0; filter:contrast(2) brightness(1.8); clip-path:inset(0 0 100% 0); } }

.result-sigil {
  display: grid;
  place-items: center;
  width: 140px;
  aspect-ratio: 1;
  margin-bottom: 20px;
  color: var(--cyan);
  border: 2px solid var(--line-bright);
  background: radial-gradient(circle, rgba(72, 169, 187, .26), transparent 68%);
  font: 900 4.5rem var(--pixel);
  box-shadow: none;
}

.result-sigil.has-crown-art {
  width: clamp(112px, 32vw, 156px);
  border: 0;
  background: url('./assets/generated/web-image2-v1/crown.webp') center / contain no-repeat;
  color: transparent;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.55));
  box-shadow: none;
}

.result-screen h2 {
  font-size: clamp(2rem, 7vw, 4.3rem);
}

.reward-list {
  display: grid;
  gap: 8px;
  width: min(520px, 100%);
  margin-top: 18px;
}

.reward-item {
  padding: 10px;
  border: 1px solid var(--line);
  color: #c4cbda;
  background: #090d19;
  font: .75rem var(--pixel);
}

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}

dialog {
  width: min(520px, calc(100% - 30px));
  padding: 0;
  border: 1px solid var(--line-bright);
  color: var(--text);
  background: #090d19;
  box-shadow: 0 28px 100px #000;
}

dialog::backdrop {
  background: rgba(0, 0, 0, .82);
  backdrop-filter: blur(4px);
}

.dialog-card {
  display: grid;
  gap: 16px;
  padding: 26px;
}

.dialog-card h2,
.dialog-card p {
  margin: 0;
}

.dialog-card p {
  color: #bdc5d5;
  line-height: 1.7;
}

.warning-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: #fff;
  border: 2px solid var(--red);
  font: 900 1.5rem var(--pixel);
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-card label {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.settings-card input[type="range"] {
  width: 170px;
}

.settings-card input[type="checkbox"] {
  width: 24px;
  height: 24px;
}

html.large-text { font-size: 112.5%; }
body.large-text { font-size: 1rem; }

body.reduced-gore .enemy-panel.is-hit {
  animation-name: gentle-hit;
}

@keyframes gentle-hit {
  50% { filter: brightness(1.2); }
}

body.reduced-flash .relic-button.is-triggered {
  animation: none;
  border-color: var(--gold);
}
body.reduced-flash .damage-float.is-active,
body.reduced-flash .enemy-panel.has-impact::after,
body.reduced-flash .result-scene.is-reward-burst::before { filter:none; box-shadow:none; }
body.reduced-gore .defeated-enemy-ghost { filter:grayscale(.45) brightness(.7); opacity:.38; }

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}

@media (max-width: 900px) {
  .combat-layout {
    grid-template-columns: 1fr;
  }

  .combat-side {
    grid-template-columns: 1fr 1fr;
  }

  .combat-log {
    grid-column: 1 / -1;
    min-height: auto;
  }
}

@media (min-width: 1100px) and (max-height: 800px) {
  .combat-screen {
    padding-top: 10px;
  }

  .combat-layout {
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 10px;
  }

  .combat-primary {
    display: grid;
    grid-template-columns: minmax(370px, 1.15fr) minmax(320px, .85fr);
    grid-template-areas:
      "enemy board"
      "relic board"
      "potions board";
    align-items: start;
    gap: 8px 12px;
  }

  .enemy-panel {
    grid-area: enemy;
    grid-template-columns: minmax(120px, .6fr) minmax(220px, 1.4fr);
    min-height: 185px;
  }

  .enemy-copy {
    gap: 9px;
    padding: 12px;
  }

  .relic-section {
    grid-area: relic;
  }

  .board-frame {
    grid-area: board;
    width: 100%;
    margin: 0;
    padding: 8px;
  }

  .potion-section {
    grid-area: potions;
  }

  .combat-side {
    gap: 8px;
  }

  .status-card,
  .combat-log {
    padding: 10px;
  }

  .combat-log {
    min-height: 0;
    max-height: 280px;
    overflow: auto;
  }
}

@media (max-width: 720px) {
  .abyss-shell {
    padding-left: max(9px, env(safe-area-inset-left));
    padding-right: max(9px, env(safe-area-inset-right));
  }

  .topbar {
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding-inline: 3px;
  }

  .run-stats {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .run-stats > div {
    min-width: 0;
  }

  .start-screen {
    grid-template-columns: 1fr;
    align-content: center;
  }

  .title-art {
    min-height: 280px;
  }

  .title-copy {
    padding: 0 6px;
  }

  .mark-grid,
  .event-grid,
  .shop-grid {
    grid-template-columns: 1fr;
  }

  .choice-card,
  .shop-card {
    min-height: 0;
  }

  .enemy-panel {
    grid-template-columns: 110px 1fr;
    min-height: 190px;
  }

  .enemy-copy {
    padding: 12px;
  }

  .enemy-title {
    display: block;
  }

  .enemy-title > strong {
    display: inline-block;
    margin-top: 7px;
  }

  .intent-card {
    grid-template-columns: 34px 1fr auto;
    padding: 7px;
  }

  .intent-icon {
    width: 32px;
    height: 32px;
  }

  .board-frame {
    padding: 8px;
  }

  .board-head {
    grid-template-columns: 64px 1fr 64px;
  }

  .board-head p {
    font-size: .66rem;
  }

  .potion-row {
    gap: 5px;
  }

  .potion-button {
    padding: 8px 6px;
  }

  .combat-side {
    grid-template-columns: 1fr;
  }

  .combat-log {
    grid-column: auto;
  }

  .start-options {
    grid-template-columns: 1fr;
  }

  .record-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  footer {
    flex-wrap: wrap;
  }
}

@media (max-width: 390px) {
  .screen {
    padding-inline: 0;
  }

  .enemy-panel {
    grid-template-columns: 90px 1fr;
  }

  .enemy-sigil {
    width: 36px;
    height: 36px;
    left: 6px;
    bottom: 6px;
  }

  .enemy-title h2 {
    font-size: 1.12rem;
  }

  .cell {
    font-size: clamp(.9rem, 7vw, 1.45rem);
  }

  .micro-heading {
    font-size: .58rem;
  }
}

/* V2 MOBILE-FIRST PASS
   On a phone, the playable board and immediate combat choices come before
   collection/status details. Desktop keeps the wider information layout. */
@media (max-width: 720px) and (orientation: portrait) {
  .abyss-shell {
    padding-top: 0;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 0;
    gap: 5px 8px;
    padding: max(7px, env(safe-area-inset-top)) 4px 7px;
    border-bottom-color: #63789e;
    background: rgba(9, 13, 26, .96);
    backdrop-filter: blur(10px);
  }

  .brand-block h1 {
    margin-top: 0;
    font-size: 1.28rem;
    letter-spacing: -.07em;
  }

  .brand-block .eyebrow {
    font-size: .7rem;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .run-stats {
    gap: 5px;
  }

  .run-stats > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 5px;
    min-height: 32px;
    padding: 6px 8px;
  }

  .run-stats span {
    margin: 0;
    font-size: .7rem;
  }

  .run-stats strong {
    font-size: .9rem;
  }

  main,
  .screen {
    min-height: 0;
  }

  .screen {
    padding: 12px 0 18px;
  }

  .start-screen {
    align-content: start;
    gap: 14px;
  }

  .title-art {
    min-height: 320px;
    height: min(45dvh, 360px);
    max-height: none;
  }

  .start-screen .title-copy { margin-top:-18px; }

  .title-copy h2 {
    margin: 6px 0 12px;
    font-size: clamp(2rem, 9vw, 2.6rem);
  }

  .title-copy > p:not(.kicker) {
    font-size: .98rem;
    line-height: 1.62;
  }

  .title-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 16px;
  }

  .title-actions > button {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }

  .title-actions .primary-button {
    grid-column: 1 / -1;
  }

  .start-options {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
  }

  .record-panel {
    gap: 6px;
    margin-top: 10px;
  }

  .next-goal {
    margin-top: 8px !important;
    font-size: .78rem;
  }

  .choice-screen {
    align-content: start;
    gap: 12px;
  }

  .scene-banner,
  .event-art {
    width: 100%;
    height: 108px;
  }

  .choice-screen .scene-banner + .section-heading {
    margin-top: -42px;
    padding: 14px 16px 12px;
  }

  .section-heading h2 {
    margin: 6px 0 10px;
    font-size: clamp(1.75rem, 8vw, 2.25rem);
  }

  .section-heading > p:not(.kicker) {
    font-size: .94rem;
    line-height: 1.55;
  }

  .card-grid,
  .shop-groups {
    gap: 10px;
  }

  .choice-card,
  .shop-card {
    padding: 15px 16px;
  }

  .choice-card strong,
  .shop-card strong {
    margin: 8px 0;
    font-size: 1.08rem;
  }

  .choice-card p,
  .shop-card p {
    font-size: .91rem;
    line-height: 1.55;
  }

  .combat-screen {
    padding-top: 9px;
  }

  .combat-layout {
    gap: 9px;
  }

  .combat-primary {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .enemy-panel { order: 1; }
  .board-frame { order: 2; }
  .potion-section { order: 3; }
  .relic-section { order: 4; }

  .enemy-panel {
    grid-template-columns: minmax(148px, .9fr) minmax(0, 1.1fr);
    min-height: 214px;
    max-height: none;
  }

  .enemy-art { background-size:cover; background-position:center; }
  .enemy-sigil { opacity:.72; }

  .enemy-copy {
    gap: 6px;
    padding: 9px 10px;
  }

  .enemy-title {
    display: flex;
    align-items: start;
  }

  .enemy-title h2 {
    margin-top: 2px;
    font-size: 1.18rem;
  }

  .enemy-title > strong {
    flex: 0 0 auto;
    margin-top: 0;
    font-size: .67rem;
  }

  .bar {
    height: 13px;
    padding: 2px;
  }

  .bar-row b {
    font-size: .75rem;
  }

  .intent-card {
    grid-template-columns: 30px 1fr auto;
    min-height: 49px;
    gap: 7px;
    padding: 6px 8px;
  }

  .intent-icon {
    width: 30px;
    height: 30px;
  }

  .intent-card small {
    font-size: .68rem;
  }

  .intent-card strong {
    font-size: .78rem;
  }

  .intent-card > b {
    font-size: 1.18rem;
  }

  .enemy-sigil {
    width: 32px;
    height: 32px;
    left: 5px;
    bottom: 5px;
  }

  .board-frame {
    width: 100%;
    margin: 0;
    padding: 6px;
  }

  .board-head {
    grid-template-columns: 58px 1fr 58px;
    gap: 6px;
    margin-bottom: 6px;
  }

  .board-head > div {
    padding: 5px;
  }

  .board-head span {
    font-size: .68rem;
  }

  .board-head strong {
    font-size: .92rem;
  }

  .board-head p {
    font-size: .73rem;
    line-height: 1.35;
  }

  .board {
    gap: 5px;
    padding: 6px;
  }

  .cell {
    font-size: clamp(1.12rem, 7vw, 1.6rem);
  }

  .potion-section,
  .relic-section {
    margin-top: 0;
    padding: 8px;
  }

  .micro-heading {
    margin-bottom: 6px;
    font-size: .69rem;
  }

  .potion-row {
    gap: 5px;
  }

  .potion-button {
    min-height: 64px;
    padding: 7px 6px;
  }

  .potion-button .atlas-icon {
    width: 27px;
    height: 27px;
    margin-right: 5px;
  }

  .potion-button strong {
    font-size: .75rem;
  }

  .potion-button span {
    font-size: .68rem;
    line-height: 1.35;
  }

  .relic-strip {
    flex-wrap: nowrap;
    gap: 6px;
    min-height: 36px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  .relic-button {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
  }

  .combat-side {
    gap: 8px;
  }

  .status-card,
  .combat-log {
    padding: 12px;
  }

  .combat-log {
    max-height: 92px;
    overflow-y: auto;
  }

  footer {
    min-height: 46px;
    flex-wrap: nowrap;
    padding: 6px 4px;
  }

  footer span:nth-child(2) {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 500px) and (max-width: 950px) {
  .abyss-shell {
    padding: 0 8px max(4px, env(safe-area-inset-bottom));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    grid-template-columns: auto 1fr auto;
    min-height: 42px;
    gap: 8px;
    padding: 2px max(6px, env(safe-area-inset-right)) 2px max(6px, env(safe-area-inset-left));
    background: rgba(9, 13, 26, .97);
  }

  .brand-block .eyebrow {
    display: none;
  }

  .brand-block h1 {
    margin: 0;
    font-size: 1.08rem;
  }

  .run-stats {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }

  .run-stats > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    min-width: 0;
    padding: 4px 6px;
  }

  .run-stats span {
    margin: 0;
    font-size: .62rem;
  }

  .run-stats strong {
    font-size: .78rem;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  main,
  .screen {
    min-height: 0;
  }

  .screen {
    padding: 5px 0;
  }

  .start-screen {
    grid-template-columns: minmax(190px, .78fr) minmax(300px, 1.22fr);
    align-items: start;
    gap: 12px;
  }

  .title-art {
    min-height: 250px;
    max-height: 250px;
  }

  .title-copy h2 {
    margin: 4px 0 7px;
    font-size: 1.75rem;
  }

  .title-copy > p:not(.kicker) {
    font-size: .82rem;
    line-height: 1.45;
  }

  .title-actions {
    margin-top: 8px;
  }

  .start-options,
  .record-panel {
    margin-top: 7px;
  }

  .choice-screen {
    align-content: start;
    gap: 8px;
  }

  .choice-screen > .scene-banner,
  .choice-screen > .event-art {
    display: none;
  }

  .section-heading h2 {
    margin: 3px 0 5px;
    font-size: 1.55rem;
  }

  .section-heading > p:not(.kicker) {
    font-size: .8rem;
    line-height: 1.4;
  }

  .mark-grid,
  .event-grid,
  .shop-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .choice-card,
  .shop-card {
    padding: 10px;
  }

  .choice-card strong,
  .shop-card strong {
    margin: 5px 0;
    font-size: .9rem;
  }

  .choice-card p,
  .shop-card p {
    font-size: .72rem;
    line-height: 1.4;
  }

  .combat-layout {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .combat-primary {
    display: grid;
    grid-template-columns: minmax(210px, 1fr) minmax(250px, .95fr);
    grid-template-areas:
      "enemy board"
      "potions board"
      "relic board";
    align-items: start;
    gap: 6px 8px;
  }

  .enemy-panel {
    grid-area: enemy;
    grid-template-columns: 82px 1fr;
    min-height: 132px;
    max-height: 132px;
  }

  .enemy-copy {
    gap: 4px;
    padding: 7px;
  }

  .enemy-title h2 {
    font-size: 1rem;
  }

  .bar {
    height: 11px;
    padding: 1px;
  }

  .intent-card {
    grid-template-columns: 26px 1fr auto;
    min-height: 42px;
    gap: 5px;
    padding: 4px 6px;
  }

  .intent-icon {
    width: 26px;
    height: 26px;
  }

  .intent-card small,
  .intent-card strong {
    font-size: .64rem;
  }

  .intent-card > b {
    font-size: .95rem;
  }

  .board-frame {
    grid-area: board;
    width: min(100%, clamp(240px, calc(100dvh - 104px), 300px));
    margin: 0 auto;
    padding: 4px;
  }

  .board-head {
    grid-template-columns: 50px 1fr 50px;
    gap: 4px;
    margin-bottom: 2px;
  }

  .board-head > div {
    padding: 2px;
  }

  .board-head span,
  .board-head p {
    font-size: .58rem;
    line-height: 1.15;
  }

  .board-head strong {
    font-size: .68rem;
    line-height: 1;
  }

  .board {
    gap: 3px;
    padding: 3px;
  }

  .cell {
    font-size: clamp(.9rem, 4vw, 1.35rem);
  }

  .potion-section {
    grid-area: potions;
  }

  .relic-section {
    grid-area: relic;
  }

  .potion-section,
  .relic-section {
    margin: 0;
    padding: 6px;
  }

  .micro-heading {
    margin-bottom: 4px;
    font-size: .61rem;
  }

  .potion-button {
    min-height: 54px;
    padding: 5px;
  }

  .potion-button .atlas-icon {
    width: 23px;
    height: 23px;
    margin-right: 4px;
  }

  .potion-button strong,
  .potion-button span {
    font-size: .6rem;
  }

  .relic-strip {
    flex-wrap: nowrap;
    min-height: 32px;
    overflow-x: auto;
  }

  .relic-button {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
  }

  .combat-side {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .status-card,
  .combat-log {
    padding: 8px;
  }

  .combat-log {
    grid-column: 1 / -1;
    max-height: 120px;
    overflow-y: auto;
  }

  footer {
    min-height: 38px;
    padding: 3px 6px;
  }

  footer span:nth-child(2) {
    display: none;
  }
}

/* V2 COMMERCIAL VERTICAL-SLICE PASS
   The atlases already carry the art direction. This layer makes the first
   mechanic, enemy presence, and every player action read immediately. */
.mechanic-hook {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  margin-top: 17px;
  padding: 8px 11px;
  border: 1px solid #697da6;
  background: linear-gradient(90deg, rgba(20, 29, 52, .96), rgba(36, 22, 62, .96));
  box-shadow: inset 0 0 0 2px rgba(4, 7, 15, .72), 4px 4px 0 rgba(0, 0, 0, .3);
}

.hook-tile {
  display: grid;
  place-items: center;
  width: 38px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  border: 2px solid #65708c;
  color: #f3f3ed;
  background: linear-gradient(145deg, #3c4359, #202637);
  box-shadow: inset 0 0 0 2px #111624, 2px 2px 0 #02040a;
  font: 900 .9rem/1 var(--pixel);
}

.hook-tile.is-result {
  border-color: #ad62c8;
  color: #ffc4ff;
  background: linear-gradient(145deg, #612d70, #33183e);
  animation: hook-result calc(1.9s / var(--speed)) steps(5, end) infinite;
}

.mechanic-hook > b {
  color: #aeb8cd;
  font: 900 .78rem/1 var(--pixel);
}

.mechanic-hook > strong {
  display: grid;
  gap: 3px;
  margin-left: 4px;
  color: #ffe67f;
  font: 900 .78rem/1.2 var(--pixel);
}

.mechanic-hook > strong small {
  color: #9ea9c0;
  font-size: .58rem;
}

@keyframes hook-result {
  50% { filter: brightness(1.35); transform: translateY(-2px); }
}

#new-run {
  position: relative;
  overflow: hidden;
  min-height: 58px;
  font-size: .92rem;
  text-shadow: 2px 2px 0 rgba(36, 12, 66, .8);
}

#new-run::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, .18) 45%, transparent 70%);
  transform: translateX(-120%);
  animation: cta-sweep calc(3.4s / var(--speed)) steps(12, end) infinite;
}

#new-run > span {
  display: inline-block;
  margin-left: 9px;
  padding-left: 9px;
  border-left: 1px solid rgba(255, 255, 255, .35);
  color: #eadcff;
  font-size: .65rem;
}

@keyframes cta-sweep {
  55%, 100% { transform: translateX(140%); }
}

.encounter-banner,
.phase-banner {
  position: absolute;
  z-index: 20;
  inset: 0;
  pointer-events: none;
}

.encounter-banner {
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  background: linear-gradient(90deg, rgba(4, 6, 14, .95), rgba(24, 11, 37, .90), rgba(4, 6, 14, .95));
  border-block: 2px solid #9b62e5;
}

.encounter-banner small {
  color: #d8b3ff;
  font: 900 .68rem/1 var(--pixel);
  letter-spacing: .12em;
}

.encounter-banner strong {
  color: #fff6df;
  font: 900 clamp(1rem, 4vw, 1.75rem)/1.2 var(--pixel);
  text-shadow: 3px 3px 0 #3b174e;
}

.encounter-banner.is-active {
  animation: encounter-reveal calc(1.05s / var(--speed)) steps(10, end) both;
}

.enemy-panel[data-kind="boss"] .encounter-banner {
  border-color: #f1bd56;
  background: linear-gradient(90deg, rgba(9, 4, 11, .97), rgba(84, 24, 48, .93), rgba(9, 4, 11, .97));
}

.enemy-panel[data-kind="boss"] .encounter-banner small { color: #ffd978; }

@keyframes encounter-reveal {
  0% { clip-path: inset(48% 0 48%); opacity: 0; }
  18%, 70% { clip-path: inset(0); opacity: 1; }
  100% { clip-path: inset(48% 0 48%); opacity: 0; }
}

.phase-banner {
  display: grid;
  place-items: center;
  color: #fff0ba;
  background: radial-gradient(circle, rgba(136, 28, 70, .90), rgba(8, 5, 16, .72) 68%);
  border: 3px double #e35c81;
  font: 900 clamp(.74rem, 3vw, 1.15rem)/1.2 var(--pixel);
  text-align: center;
  text-shadow: 3px 3px 0 #4d0f2b;
}

.phase-banner.is-active {
  animation: phase-break calc(1.05s / var(--speed)) steps(9, end) both;
}

@keyframes phase-break {
  0% { opacity: 0; transform: scaleX(.1); filter: brightness(2.4); }
  20%, 72% { opacity: 1; transform: scaleX(1); }
  100% { opacity: 0; transform: scale(1.08); }
}

.enemy-panel.is-entering .enemy-art {
  animation:
    enemy-arrive calc(.62s / var(--speed)) steps(8, end) both,
    enemy-idle calc(2.8s / var(--speed)) steps(6, end) calc(.62s / var(--speed)) infinite;
}

@keyframes enemy-arrive {
  0% { opacity: 0; transform: translateY(18px) scale(.82); filter: brightness(.2) saturate(.4); }
  65% { opacity: 1; transform: translateY(-3px) scale(1.035); filter: brightness(1.45) saturate(1.2); }
  100% { opacity: 1; transform: none; filter: none; }
}

.enemy-panel[data-kind="elite"],
.enemy-panel[data-kind="boss"] {
  border-color: #8657bd;
  box-shadow: 0 0 0 2px #171020, 0 0 24px rgba(152, 74, 214, .25), var(--shadow);
}

.enemy-panel[data-kind="boss"] {
  border-color: #c58a4d;
  background: #170b15;
}

.enemy-panel[data-kind="boss"] .enemy-aura {
  width: 74%;
  border: 3px double rgba(245, 180, 78, .72);
  box-shadow: 0 0 28px rgba(203, 51, 102, .28), inset 0 0 20px rgba(128, 72, 221, .24);
  animation: boss-aura calc(6s / var(--speed)) steps(18, end) infinite;
}

@keyframes boss-aura {
  50% { transform: rotate(.5turn) scale(1.08); filter: hue-rotate(24deg) brightness(1.25); }
  100% { transform: rotate(1turn); }
}

.enemy-panel.is-defeated .enemy-art {
  animation: enemy-fall calc(.72s / var(--speed)) steps(10, end) forwards;
}

@keyframes enemy-fall {
  0% { opacity: 1; filter: brightness(2) saturate(1.5); }
  28% { transform: translateX(-5px) scale(1.05); }
  100% { opacity: 0; transform: translateY(24px) scale(.78); filter: grayscale(1) brightness(.18); }
}

.combat-toast {
  position: absolute;
  z-index: 18;
  left: 50%;
  top: 56%;
  display: grid;
  min-width: 156px;
  gap: 4px;
  padding: 10px 13px;
  pointer-events: none;
  text-align: center;
  border: 2px solid #ffe585;
  color: #fff7d6;
  background: rgba(14, 9, 22, .94);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .55), 0 0 22px rgba(255, 210, 76, .24);
  transform: translate(-50%, -50%);
}

.combat-toast strong { font: 900 .78rem/1.1 var(--pixel); }
.combat-toast span { color: #ffe585; font: 900 1rem/1 var(--pixel); }
.combat-toast[data-tone="combo"] { border-color: #d998ff; box-shadow: 4px 4px 0 rgba(0,0,0,.55), 0 0 24px rgba(197,98,255,.32); }
.combat-toast[data-tone="combo"] span { color: #f1bdff; }
.combat-toast[data-tone="victory"] { border-color: #75e6c6; }
.combat-toast[data-tone="victory"] span { color: #75e6c6; }
.combat-toast[data-tone="invalid"] { border-color: #e15a78; }
.combat-toast[data-tone="invalid"] span { color: #ff9aae; }

.combat-toast.is-active {
  animation: combat-toast calc(.72s / var(--speed)) steps(7, end) both;
}

@keyframes combat-toast {
  0% { opacity: 0; transform: translate(-50%, -35%) scale(.72); }
  20%, 68% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -68%) scale(.92); }
}

.board-frame.is-merge-impact {
  animation: board-impact calc(.42s / var(--speed)) steps(5, end);
}

@keyframes board-impact {
  35% { border-color: #ffe37b; box-shadow: 0 0 28px rgba(255, 207, 70, .42), inset 0 0 0 3px #24160b; }
}

.board-frame.has-invalid-input {
  animation: invalid-nudge calc(.26s / var(--speed)) steps(4, end);
}

@keyframes invalid-nudge {
  25% { transform: translateX(-4px); border-color: #d64b68; }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.cell.is-merged {
  z-index: 2;
  border-color: #ffdf72;
  box-shadow: 0 0 20px rgba(255, 204, 58, .5), inset 0 0 0 3px rgba(255, 240, 168, .18);
}

#combat-coach[data-step="1"] { color: #8ce9ff; }
#combat-coach[data-step="2"] { color: #f1b9ff; }
#combat-coach[data-step="3"] { color: #ffd67e; }

body.reduced-flash .encounter-banner,
body.reduced-flash .phase-banner,
body.reduced-flash .combat-toast,
body.reduced-flash .board-frame.is-merge-impact {
  filter: none;
  box-shadow: none;
}

@media (max-width: 720px) and (orientation: portrait) {
  .mechanic-hook {
    width: 100%;
    justify-content: center;
    margin-top: 12px;
    padding: 7px 8px;
  }

  .hook-tile { width: 34px; }
  .mechanic-hook > strong { font-size: .68rem; }

  .enemy-panel[data-kind="boss"] {
    min-height: 162px;
    max-height: 162px;
  }

  .encounter-banner { padding: 12px; }
  .encounter-banner strong { font-size: 1rem; }
  .combat-toast { top: 58%; min-width: 142px; padding: 8px 10px; }
}

@media (max-width: 390px) {
  .mechanic-hook { gap: 5px; }
  .hook-tile { width: 31px; font-size: .78rem; }
  .mechanic-hook > strong { margin-left: 1px; font-size: .62rem; }
  #new-run > span { margin-left: 6px; padding-left: 6px; }
}

@media (orientation: landscape) and (max-height: 500px) and (max-width: 950px) {
  .mechanic-hook { margin-top: 6px; padding: 4px 7px; }
  .hook-tile { width: 26px; font-size: .65rem; }
  .mechanic-hook > strong { font-size: .58rem; }
  #new-run { min-height: 42px; }
  .encounter-banner { padding: 8px; }
  .combat-toast { top: 58%; min-width: 128px; padding: 6px 8px; }
  .combat-toast strong { font-size: .62rem; }
  .combat-toast span { font-size: .78rem; }
}

@media (prefers-reduced-motion: reduce) {
  .mechanic-hook *,
  #new-run::before,
  .encounter-banner,
  .phase-banner,
  .combat-toast,
  .enemy-panel.is-entering .enemy-art,
  .enemy-panel.is-defeated .enemy-art,
  .board-frame.is-merge-impact,
  .board-frame.has-invalid-input {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }
}
/* ABYSS V10 RUN RHYTHM
   A continuous incision shows progress without turning the run into a node map.
   Rewards become a deliberate three-way build choice; route consequences stay
   attached to the immediate event choice. */
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: var(--run-progress, 0%);
  height: 2px;
  background: linear-gradient(90deg, #5a4327, var(--reliquary-brass-light));
  box-shadow: 0 0 10px rgba(209, 174, 109, .22);
  transition: width .38s cubic-bezier(.2, .74, .2, 1);
}

.choice-route {
  display: block;
  grid-column: 2;
  width: max-content;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid color-mix(in srgb, var(--choice-accent) 42%, transparent);
  color: var(--reliquary-brass-light);
  font: 600 .65rem/1.2 var(--hud);
  letter-spacing: .08em;
}

.reward-list:has(.reward-choice) {
  display: grid;
  gap: 7px;
}

.reward-choice {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 11px;
  width: 100%;
  min-height: 86px;
  padding: 11px 12px;
  overflow: hidden;
  border: 1px solid rgba(227, 222, 210, .14);
  border-left: 2px solid var(--reliquary-brass);
  border-radius: 1px;
  color: var(--reliquary-bone);
  text-align: left;
  background: linear-gradient(105deg, rgba(23, 29, 30, .96), rgba(7, 9, 10, .98));
  box-shadow: none;
}

.reward-choice::after {
  content: "選ぶ";
  position: absolute;
  right: 10px;
  top: 9px;
  color: #7f8985;
  font: 600 .58rem/1 var(--hud);
  letter-spacing: .08em;
}

.reward-choice[data-rarity="rare"] {
  border-left-color: #83b8b9;
}

.reward-choice[data-rarity="abyss"] {
  border-left-color: #d1ae6d;
  background: linear-gradient(105deg, rgba(53, 40, 22, .96), rgba(8, 9, 9, .98));
}

.reward-choice:hover,
.reward-choice:focus-visible {
  border-color: var(--reliquary-brass-light);
  transform: translateY(-1px);
}

.reward-choice > .relic-glyph {
  width: 46px;
  height: 46px;
  align-self: center;
  border: 1px solid rgba(209, 174, 109, .26);
  background-color: #080a0a;
}

.relic-glyph {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: inline-block;
  background-color: #080a0a;
  background-image: url('./assets/generated/web-image2-v1/relic-icon-atlas.webp');
  background-size: 600% 600%;
  background-position: var(--relic-x) var(--relic-y);
  background-repeat: no-repeat;
  image-rendering: pixelated;
}
.relic-button .relic-glyph { width: 26px; height: 26px; }
.shop-card > .relic-glyph { float: right; margin: -4px -4px 8px 12px; }

.reward-choice > span {
  min-width: 0;
}

.reward-choice small {
  display: block;
  margin: 0 48px 3px 0;
  color: var(--reliquary-muted);
  font: 600 .68rem/1.2 var(--hud);
  letter-spacing: .08em;
}

.reward-choice strong {
  display: block;
  color: var(--reliquary-bone);
  font: 400 1rem/1.2 var(--display-ja);
}

.reward-choice p {
  margin: 5px 0 0;
  color: #aeb3af;
  font: .82rem/1.45 var(--body);
}

.potion-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.potion-button {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 54px;
  padding: 7px;
}

.potion-button .atlas-icon {
  float: none;
  width: 34px;
  height: 34px;
  margin: 0;
}

.potion-button strong {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.potion-button .potion-slot-label {
  position: absolute;
  right: 5px;
  bottom: 4px;
  color: #747d79;
  font: 600 .58rem/1 var(--hud);
}

.potion-button.is-selected .potion-slot-label {
  color: var(--reliquary-brass-light);
}

.selection-hint {
  margin-top: 6px;
  color: #bec4bf;
  font: .7rem/1.45 var(--body);
}

body.reduced-motion .topbar::after,
body.reduced-motion .reward-choice {
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .topbar::after,
  .reward-choice {
    transition: none !important;
  }
}

@media (orientation: landscape) and (min-width: 720px) and (max-height: 500px) and (max-width: 950px) {
  .combat-layout {
    grid-template-columns: minmax(0, 1fr) 205px;
  }

  .combat-side {
    grid-template-columns: 1fr;
  }

  .combat-log {
    grid-column: auto;
  }

  .status-card p {
    font-size: .7rem;
    line-height: 1.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
