* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 280px;
  overscroll-behavior: none;
  background: #090d0f;
  color: #f1ebe0;
  font-family:
    ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.selection {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(500px, 1.2fr);
  align-items: center;
  gap: clamp(30px, 7vw, 120px);
  padding: clamp(28px, 8vw, 110px);
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 75%, #273333 0, transparent 27%),
    linear-gradient(125deg, #11191b, #090c0e 58%);
}
.hero {
  max-width: 480px;
}
.eyebrow {
  color: #c68955;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
}
.hero h1 {
  font-family: Georgia, serif;
  font-size: clamp(62px, 6.5vw, 96px);
  line-height: 0.82;
  margin: 18px 0;
  color: #f6ecdc;
}
.hero > p:not(.eyebrow) {
  color: #a9aaa4;
  line-height: 1.65;
}
.hero img {
  width: min(420px, 100%);
  mix-blend-mode: screen;
  filter: drop-shadow(0 24px 32px #0009);
  margin-top: 16px;
}
.choose {
  max-width: 680px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.class-card {
  text-align: left;
  min-height: 212px;
  padding: 20px 16px;
  background: #171d1e;
  border: 1px solid #30393a;
  color: #e7e2d5;
  border-radius: 4px;
  transition: 0.18s;
}
.class-card:hover,
.class-card.selected {
  border-color: var(--accent);
  background: linear-gradient(155deg, #202a2a, #14191a);
  transform: translateY(-3px);
  box-shadow: 0 13px 25px #0004;
}
.class-card strong {
  display: block;
  color: var(--accent);
  font-size: 19px;
}
.class-card span,
.class-card small,
.class-card i {
  display: block;
  margin-top: 10px;
  font-style: normal;
}
.class-card small {
  color: #aeb0a9;
  font-size: 11px;
  line-height: 1.45;
}
.class-card i {
  color: #737f78;
  font-size: 10px;
}
.seed-label {
  display: block;
  margin: 26px 0 12px;
  color: #aeb0a9;
  font-size: 12px;
}
.seed-label input,
.lab select {
  display: block;
  width: 100%;
  background: #0d1112;
  border: 1px solid #3e4744;
  color: #f5ecdf;
  padding: 13px;
  margin-top: 7px;
  outline-color: #d99b58;
}
.begin {
  width: 100%;
  padding: 17px;
  background: #d6954f;
  border: 0;
  color: #171412;
  font-weight: bold;
  font-size: 15px;
}
.begin span {
  float: right;
  font-size: 24px;
  line-height: 10px;
}
.hint {
  color: #68716d;
  font-size: 10px;
  margin-top: 17px;
}
.lab-toggle {
  position: fixed;
  right: 18px;
  bottom: 17px;
  z-index: 9;
  border: 1px solid #58615d;
  background: #151b1c;
  color: #cdd3cc;
  padding: 9px 12px;
  font-size: 11px;
}
.game {
  min-height: 100svh;
  display: grid;
  place-items: center;
  background: #070a0c;
}
.stage {
  position: relative;
  width: min(960px, 100vw, 177.778svh);
  aspect-ratio: 16/9;
  box-shadow: 0 30px 90px #000;
}
.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  touch-action: none;
}
.hud {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.hud.top {
  top: 0;
  padding: 14px;
}
.brand {
  font-family: Georgia, serif;
  letter-spacing: 0.08em;
  font-size: 18px;
  text-shadow: 0 2px 4px #000;
}
.brand small {
  display: block;
  font-family:
    ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 9px;
  color: #adb5ac;
  margin-top: 2px;
  letter-spacing: 0;
}
.counter {
  font-size: 11px;
  color: #e5c18d;
  background: #121718c9;
  padding: 8px 10px;
  height: max-content;
}
.objective {
  position: absolute;
  top: 10px;
  right: 78px;
  display: grid;
  width: 224px;
  height: 58px;
  padding: 9px 18px 9px 12px;
  grid-template-columns: 38px 1fr;
  align-items: center;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-position: 66.667% 0;
  background-repeat: no-repeat;
  background-size: 400% 400%;
  filter: drop-shadow(0 5px 8px #000);
}
.objective > span {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.objective strong,
.objective small {
  display: flex;
  justify-content: center;
  min-width: 0;
  line-height: 1;
}
.objective strong {
  font-size: 9px;
}
.objective small {
  font-size: 8px;
}
.objective-direction {
  display: block;
  width: 34px;
  height: 34px;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-position: 66.667% 100%;
  background-repeat: no-repeat;
  background-size: 400% 400%;
  transform-origin: center;
}
.hud.bottom {
  bottom: 0;
  align-items: end;
  padding: 14px;
  background: linear-gradient(transparent, #080b0de8);
}
.health span {
  display: block;
  font-size: 9px;
  color: #b4b6ae;
}
.health b {
  display: inline-block;
  width: 180px;
  height: 9px;
  background: #241719;
  border: 1px solid #684346;
  margin: 5px 8px 0 0;
}
.health b i {
  display: block;
  height: 100%;
  background: #d2665d;
}
.health em {
  font-size: 10px;
  font-style: normal;
}
.skills {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}
.skills button {
  color: #e9e7df;
  background: #1a2121e6;
  border: 1px solid #4b5751;
  padding: 7px;
  font-size: 10px;
}
.skills kbd {
  color: #dba35f;
}
.skills i {
  display: block;
  font-size: 8px;
  color: #83d0b1;
  margin-top: 3px;
}
.mobile-controls {
  display: none;
}
.loot-log {
  position: absolute;
  right: 14px;
  top: 60px;
  width: 160px;
  color: #aeb3aa;
  background: #101516bb;
  border-left: 2px solid #a66b43;
  padding: 8px;
  font-size: 10px;
  line-height: 1.5;
}
.loot-log strong {
  color: #e9ddc9;
}
.outcome {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  background: #080b0ddd;
}
.outcome p {
  color: #d39a5a;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
}
.outcome h2 {
  font:
    800 42px Georgia,
    serif;
  margin: 4px 0 25px;
}
.outcome button,
.lab button {
  border: 1px solid #af7d4c;
  background: #d6954f;
  color: #171412;
  padding: 10px;
}
.hidden {
  display: none;
}
.lab {
  position: fixed;
  z-index: 10;
  right: 15px;
  bottom: 62px;
  width: 290px;
  padding: 17px;
  background: #121819;
  border: 1px solid #56605c;
  box-shadow: 0 15px 45px #000b;
  color: #d9ddd5;
}
.lab h2 {
  font:
    600 28px Georgia,
    serif;
  margin: 4px 0 15px;
}
.lab label {
  font-size: 10px;
  color: #9aa39c;
}
.lab select {
  padding: 8px;
}
.lab div {
  display: flex;
  gap: 5px;
  margin: 9px 0;
}
.lab .close {
  position: absolute;
  right: 7px;
  top: 7px;
  background: none;
  border: 0;
  color: #fff;
  padding: 3px;
  font-size: 18px;
}
.lab .frame {
  font-size: 9px;
  color: #879088;
}
.mini {
  width: 100%;
  background: #090c0d;
  border: 1px solid #313a38;
}
@media (max-width: 760px) {
  .selection {
    grid-template-columns: 1fr;
    align-items: start;
    padding: max(28px, env(safe-area-inset-top)) 20px
      max(36px, env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
  }
  .hero img {
    display: none;
  }
  .hero h1 {
    font-size: 66px;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .class-card {
    min-height: 120px;
  }
  .class-card small {
    max-width: 270px;
  }
  .loot-log {
    display: none;
  }
  .skills button {
    font-size: 8px;
  }
  .health b {
    width: 100px;
  }
}

@media (max-width: 760px), (pointer: coarse) {
  .game {
    align-content: start;
    padding-bottom: calc(146px + env(safe-area-inset-bottom));
    overflow: hidden;
  }
  .stage {
    width: min(100vw, calc(177.778svh - 259.56px));
    max-width: 100vw;
  }
  .hud.top {
    padding: 9px max(10px, env(safe-area-inset-right)) 9px
      max(10px, env(safe-area-inset-left));
  }
  .brand {
    font-size: 14px;
  }
  .counter {
    padding: 6px 8px;
    font-size: 9px;
  }
  .hud.bottom {
    padding: 9px 10px;
  }
  .hud.bottom .skills {
    display: none;
  }
  .health b {
    width: min(40vw, 150px);
  }
  .mobile-controls {
    position: fixed;
    z-index: 7;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    height: calc(146px + env(safe-area-inset-bottom));
    padding: 10px max(14px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
    background: linear-gradient(180deg, #0a0e0fdd, #111819 35%);
    border-top: 1px solid #35413d;
    touch-action: none;
    user-select: none;
  }
  .move-pad {
    position: relative;
    flex: 0 0 118px;
    width: 118px;
    height: 118px;
    border-radius: 50%;
    background: #111718;
    border: 1px solid #50605a;
    box-shadow: inset 0 0 30px #000a;
    touch-action: none;
  }
  .move-ring {
    position: absolute;
    inset: 21px;
    border: 1px solid #41504b;
    border-radius: 50%;
  }
  .move-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46px;
    height: 46px;
    margin: -23px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #e5b06b, #9b5d35);
    box-shadow: 0 5px 14px #0009;
    will-change: transform;
  }
  .move-pad small {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    color: #89948e;
    font-size: 8px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }
  .mobile-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(58px, 82px));
    gap: 8px;
    width: min(62vw, 270px);
  }
  .mobile-actions button {
    min-height: 64px;
    padding: 8px 5px;
    color: #eee8db;
    background: #1b2322;
    border: 1px solid #53615b;
    border-radius: 50%;
    touch-action: manipulation;
  }
  .mobile-actions button:first-child {
    border-color: #b77d48;
    background: #2a211a;
  }
  .mobile-actions button:active {
    transform: scale(0.94);
    background: #36423d;
  }
  .mobile-actions strong,
  .mobile-actions span {
    display: block;
  }
  .mobile-actions strong {
    font-size: 10px;
  }
  .mobile-actions span {
    margin-top: 4px;
    color: #87bda7;
    font-size: 7px;
    text-transform: uppercase;
  }
  .game > .lab-toggle {
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(152px + env(safe-area-inset-bottom));
  }
  .lab {
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(190px + env(safe-area-inset-bottom));
    width: min(290px, calc(100vw - 16px));
    max-height: calc(100svh - 210px);
    overflow-y: auto;
  }
}

@media (orientation: portrait) and (max-width: 760px) {
  .stage {
    width: 100vw;
    height: calc(100svh - 146px - env(safe-area-inset-bottom));
    max-width: none;
    aspect-ratio: auto;
    overflow: hidden;
  }
  .stage canvas {
    position: absolute;
    left: 50%;
    width: auto;
    min-width: 100%;
    height: 100%;
    transform: translateX(-50%);
  }
}

@media (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  .game {
    padding-bottom: 0;
  }
  .stage {
    width: min(100vw, 177.778svh);
  }
  .mobile-controls {
    height: 118px;
    padding-top: 5px;
    padding-bottom: max(5px, env(safe-area-inset-bottom));
    background: linear-gradient(90deg, #0b1111e8, transparent 42%, #0b1111e8);
    border-top: 0;
    pointer-events: none;
  }
  .hud.bottom {
    padding-left: 58px;
  }
  .move-pad,
  .mobile-actions {
    pointer-events: auto;
  }
  .move-pad {
    flex-basis: 102px;
    width: 102px;
    height: 102px;
  }
  .mobile-actions button {
    min-height: 58px;
  }
  .game > .lab-toggle {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    bottom: auto;
  }
}

/* Resident actions sit above the touch controls and retain 48px targets. */
.city-service-sheet {
  position: fixed;
  z-index: 8;
  right: max(10px, env(safe-area-inset-right));
  bottom: calc(118px + env(safe-area-inset-bottom));
  left: max(10px, env(safe-area-inset-left));
  display: grid;
  gap: 7px;
  padding: 9px;
  color: #eee8db;
  background: linear-gradient(180deg, #1d2926f5, #101817fa);
  border: 1px solid #718278;
  border-radius: 10px 10px 4px 4px;
  box-shadow: 0 -5px 16px #0009;
}

.city-service-sheet.hidden {
  display: none;
}

.city-service-heading,
.city-service-feedback {
  text-align: center;
}

.city-service-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.city-service-actions button {
  min-height: 48px;
  padding: 7px;
  color: #eee8db;
  background: #293832;
  border: 1px solid #8d9b78;
  border-radius: 4px;
  touch-action: manipulation;
}

.city-service-actions button:active {
  transform: scale(0.97);
  background: #465640;
}

.city-service-heading .sprite-text {
  font-size: 10px;
}

.city-service-actions .sprite-text,
.city-service-feedback .sprite-text {
  font-size: 8px;
}

.city-service-feedback {
  min-height: 12px;
  color: #b9d2a5;
}

@media (orientation: landscape) and (max-height: 500px) {
  .city-service-sheet {
    top: max(52px, env(safe-area-inset-top));
    right: max(96px, env(safe-area-inset-right));
    bottom: auto;
    left: auto;
    width: min(270px, calc(100vw - 210px));
    padding: 7px;
  }

  .city-service-actions {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 761px) and (pointer: fine) {
  .city-service-sheet {
    right: 14px;
    bottom: 14px;
    left: auto;
    width: 240px;
  }
}

@media (min-width: 761px) and (pointer: fine) {
  .game .stage {
    width: min(100vw, 177.778svh);
  }
}

/* Mobile-first cinematic selection. The generated scene and portrait crops are
   raster sprites; CSS is limited to layout, legibility masks, and interaction. */
.selection.selection-v2 {
  position: relative;
  isolation: isolate;
  display: block;
  width: 100%;
  min-height: 100svh;
  padding: 0;
  overflow: hidden;
  background: #050708;
}
.selection-v2 .selection-art {
  position: absolute;
  z-index: -2;
  inset: 0;
  background-color: #050708;
  background-image: var(--selection-art);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  transform: scale(1.002);
}

.selection-v2[data-selected-class="arcanist"] .selection-art {
  background-position: center 8%;
}
.selection-v2::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(180deg, #030506dc 0, transparent 24%),
    linear-gradient(0deg, #030506 0, #030506f4 24%, transparent 57%);
}
.selection-v2 .selection-header {
  position: absolute;
  z-index: 2;
  top: max(18px, env(safe-area-inset-top));
  left: 18px;
  width: calc(100% - 36px);
  text-align: center;
  filter: drop-shadow(0 3px 8px #000);
}
.selection-v2 .selection-header .eyebrow {
  margin: 0 0 7px;
}
.selection-v2 .selection-header h1 {
  max-width: 100%;
  margin: 0;
  color: #f4ead9;
  font:
    700 clamp(40px, 13.5vw, 68px) / 0.88 Georgia,
    serif;
  letter-spacing: -0.055em;
  text-wrap: nowrap;
}
.selection-v2 .choose {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  width: min(100%, 560px);
  max-width: none;
  margin: 0 auto;
  padding: 0 14px max(14px, env(safe-area-inset-bottom));
}
.selection-v2 .selected-class {
  min-height: 58px;
  margin-bottom: 7px;
  text-align: center;
  text-shadow: 0 3px 10px #000;
}
.selection-v2 .selected-class h2 {
  margin: 0 0 3px;
  color: #f0c17b;
  font:
    700 clamp(27px, 8vw, 38px) / 1 Georgia,
    serif;
}
.selection-v2 .selected-class > .sprite-text {
  justify-content: center;
  margin: 3px auto 0;
}
.selection-v2 .selected-class .sprite-role {
  font-size: 10px;
  color: #e9e0d1;
}
.selection-v2 .selected-class .sprite-stats {
  font-size: 8px;
  color: #bcae98;
}
.selection-v2 .cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.selection-v2 .class-card {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 78px;
  padding: 0;
  overflow: hidden;
  border: 1px solid #746550;
  border-radius: 2px;
  background: #111;
  color: #f3e8d5;
  box-shadow: inset 0 -32px 24px #020303e8;
  transform: none;
}
.selection-v2 .class-card:hover,
.selection-v2 .class-card.selected {
  border: 1px solid #f2bd6a;
  background: #111;
  box-shadow:
    inset 0 -34px 24px #020303ea,
    0 0 0 2px #1b1209,
    0 0 16px #e7982d55;
  transform: translateY(-2px);
}
.selection-v2 .class-card:focus-visible,
.selection-v2 .begin:focus-visible,
.selection-v2 .selection-lab-toggle:focus-visible {
  outline: 3px solid #fff2c9;
  outline-offset: 2px;
}
.selection-v2 .class-portrait {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  background-image: var(--portrait);
  background-position: center 35%;
  background-repeat: no-repeat;
  background-size: cover;
  filter: saturate(0.72) brightness(0.72);
}
.selection-v2 .class-card.selected .class-portrait {
  filter: saturate(1) brightness(1);
}
.selection-v2 .class-card strong {
  position: absolute;
  z-index: 1;
  right: 4px;
  bottom: 6px;
  left: 4px;
  display: block;
  color: inherit;
  font:
    700 clamp(12px, 3.6vw, 16px) / 1 Georgia,
    serif;
  text-align: center;
  text-shadow: 0 2px 5px #000;
}
.selection-v2 .run-controls {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 8px;
  margin-top: 9px;
}
.selection-v2 .seed-label {
  min-width: 0;
  margin: 0;
}
.selection-v2 .seed-label > .sprite-text {
  height: 13px;
  margin-left: 5px;
  font-size: 8px;
}
.selection-v2 .seed-control,
.selection-v2 .begin {
  min-height: 48px;
  margin: 0;
}
.selection-v2 .seed-control {
  margin-top: 2px;
}
.selection-v2 .begin {
  align-self: end;
  padding: 0 12px;
  background-position: 0 0;
}
.selection-v2 .begin .sprite-text {
  justify-content: center;
  font-size: 11px;
}
.selection-v2 .selection-lab-toggle {
  top: max(14px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  bottom: auto;
  width: 48px;
  min-height: 44px;
  padding: 6px;
  opacity: 0.72;
}
.selection-v2 .selection-lab-toggle .sprite-text {
  justify-content: center;
  font-size: 9px;
}
.loading .loading-status {
  min-height: 18px;
}
.loading-failed {
  padding: 24px;
}
.loading-failed h1 {
  font-size: clamp(36px, 10vw, 64px);
}
.loading-failed > div {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}
.loading-failed button {
  min-width: 112px;
  min-height: 48px;
  border: 0;
  background-color: #171412;
  background-image: var(--ui-atlas);
  background-position: 0 0;
  background-repeat: no-repeat;
  background-size: 400% 400%;
  color: #f2ddbf;
}

@media (min-width: 761px) {
  .selection-v2 .selection-art {
    background-position: center 30%;
  }
  .selection-v2 .selection-header {
    top: clamp(28px, 5vh, 58px);
  }
  .selection-v2 .choose {
    width: min(640px, 54vw);
    padding-bottom: clamp(24px, 5vh, 54px);
  }
  .selection-v2 .class-card {
    min-height: 108px;
  }
}

@media (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  .selection.selection-v2 {
    display: block;
    padding: 0;
    overflow: hidden;
  }
  .selection-v2 .selection-header {
    top: 14px;
    left: 18px;
    width: auto;
    text-align: left;
  }
  .selection-v2 .selection-header h1 {
    font-size: 44px;
  }
  .selection-v2 .choose {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: auto;
    width: min(58vw, 500px);
    padding: 0;
  }
  .selection-v2 .selected-class {
    min-height: 38px;
    margin-bottom: 4px;
  }
  .selection-v2 .selected-class h2 {
    font-size: 26px;
  }
  .selection-v2 .selected-class .sprite-stats {
    display: none;
  }
  .selection-v2 .class-card {
    min-height: 62px;
  }
  .selection-v2 .run-controls {
    margin-top: 6px;
  }
  .selection-v2 .seed-control,
  .selection-v2 .begin {
    min-height: 44px;
  }
  .selection-v2 .selection-lab-toggle {
    min-height: 44px;
  }
}

/* Sprite-backed presentation. CSS positions and crops committed raster art;
   it does not invent visible game decoration. */
.loading {
  min-height: 100svh;
  display: grid;
  place-content: center;
  text-align: center;
  background: #090d0f;
}
.loading h1 {
  margin: 0;
  font:
    700 clamp(52px, 12vw, 96px) Georgia,
    serif;
}
.selection {
  background-color: #0b0c0c;
  background-image: var(--terrain-atlas);
  background-size: min(1024px, 118vw);
  background-position: center;
  box-shadow: inset 0 0 0 100vmax #050708b8;
}
.hero-lineup {
  display: flex;
  align-items: end;
  justify-content: center;
  height: 230px;
  margin-top: 12px;
  overflow: hidden;
}
.hero-lineup span,
.class-portrait {
  display: block;
  flex: 0 0 170px;
  width: 170px;
  height: 170px;
  background-repeat: no-repeat;
  /* ActorAtlasV2 is eight columns by twenty rows. Matching both axes crops
     exactly one fixed runtime cell instead of leaking an animation row. */
  background-size: 800% 2000%;
  background-position: 0 0;
  filter: drop-shadow(0 16px 18px #000c);
}
.hero-lineup span + span {
  margin-left: -58px;
}
.hero-lineup span:nth-child(2) {
  z-index: 2;
  width: 190px;
  height: 190px;
  flex-basis: 190px;
}
.cards {
  grid-template-columns: 1fr;
  gap: 8px;
}
.class-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  grid-template-rows: auto auto 1fr auto;
  column-gap: 12px;
  min-height: 146px;
  padding: 18px 28px 18px 20px;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 66.667% 66.667%;
  background-repeat: no-repeat;
}
.class-card:hover,
.class-card.selected {
  border: 0;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 100% 66.667%;
}
.class-portrait {
  grid-column: 1;
  grid-row: 1 / 5;
  align-self: center;
  width: 112px;
  height: 112px;
  margin: 0;
}
.class-card strong,
.class-card > .sprite-text {
  grid-column: 2;
  min-width: 0;
}
.begin,
.lab-toggle,
.lab button,
.outcome button {
  border: 0;
  background-color: #171412;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 0 0;
  background-repeat: no-repeat;
  color: #f2ddbf;
  text-shadow: 0 2px 3px #000;
}
.hud.bottom {
  background: transparent;
}
.counter {
  display: grid;
  place-content: center;
  width: 64px;
  height: 64px;
  padding: 0;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 100% 0;
  background-repeat: no-repeat;
  text-align: center;
  text-shadow: 0 2px 4px #000;
}
.health b {
  width: 192px;
  height: 34px;
  margin-top: 0;
  border: 0;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 0 0;
  background-repeat: no-repeat;
  padding: 9px 12px;
  overflow: hidden;
}
.health b i {
  height: 15px;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 33.333% 0;
  background-repeat: no-repeat;
}
.skills button,
.mobile-actions button {
  width: 78px;
  min-width: 78px;
  height: 78px;
  padding: 14px 8px;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 0 33.333%;
  background-repeat: no-repeat;
  text-shadow: 0 2px 4px #000;
}
.skills button:nth-child(2),
.mobile-actions button:nth-child(2) {
  background-position: 33.333% 33.333%;
}
.skills button:nth-child(3),
.mobile-actions button:nth-child(3) {
  background-position: 66.667% 33.333%;
}
.loot-log {
  min-height: 98px;
  border: 0;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 66.667% 66.667%;
  background-repeat: no-repeat;
  padding: 20px 18px;
}
.outcome {
  background-color: #080b0ddd;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 100% 66.667%;
  background-repeat: no-repeat;
}
.mobile-controls {
  background-color: #0a0e0f;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 66.667% 66.667%;
  background-repeat: no-repeat;
  border: 0;
}
.move-pad {
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 100% 33.333%;
  background-repeat: no-repeat;
  box-shadow: none;
}
.move-ring {
  inset: 15px;
  border: 0;
  border-radius: 0;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 0 66.667%;
  background-repeat: no-repeat;
}
.move-knob {
  border-radius: 0;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 33.333% 66.667%;
  background-repeat: no-repeat;
  box-shadow: none;
}
.sprite-text,
#hp,
#monsters,
#tonics,
#mobile-tonics,
#cd,
#mobile-cd,
.objective strong,
.objective small,
.brand small {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  line-height: 1;
}
.sprite-text > .sprite-word,
#hp > .sprite-word,
#monsters > .sprite-word,
#tonics > .sprite-word,
#mobile-tonics > .sprite-word,
#cd > .sprite-word,
#mobile-cd > .sprite-word,
.objective strong > .sprite-word,
.objective small > .sprite-word,
.brand small > .sprite-word {
  display: inline-flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  margin: 0;
}
.sprite-text > .sprite-space,
#hp > .sprite-space,
#monsters > .sprite-space,
#tonics > .sprite-space,
#mobile-tonics > .sprite-space,
#cd > .sprite-space,
#mobile-cd > .sprite-space,
.objective strong > .sprite-space,
.objective small > .sprite-space,
.brand small > .sprite-space {
  display: block;
  flex: 0 0 calc(var(--spaces, 1) * 0.52em);
  width: calc(var(--spaces, 1) * 0.52em);
  height: 1.28em;
  margin: 0;
}
.sprite-word > .sprite-glyph {
  display: inline-block;
  flex: 0 0 1.28em;
  width: 1.28em;
  height: 1.28em;
  margin: 0;
  background-color: transparent;
  background-image: var(--glyph-atlas);
  background-size: 1600% 800%;
  background-repeat: no-repeat;
}
.sprite-word > .sprite-glyph + .sprite-glyph {
  margin-left: -0.56em;
}
.sprite-copy {
  font-size: 14px;
  line-height: 1.45;
}
.sprite-role {
  min-height: 14px;
  font-size: 14px;
}
.sprite-description {
  min-height: 36px;
  font-size: 12px;
  line-height: 1.3;
}
.sprite-stats,
.sprite-hint,
.sprite-log {
  font-size: 11px;
  line-height: 1.35;
}
#hp,
#monsters,
#tonics,
#mobile-tonics,
#cd,
#mobile-cd,
.brand small {
  font-size: 12px;
}
.class-card > .sprite-text {
  display: flex;
  margin-top: 8px;
}
.skills #cd,
.skills #tonics {
  display: flex;
}
.sprite-eyebrow,
.sprite-loading,
.sprite-button-label,
.sprite-hud-label,
.sprite-shortcut,
.sprite-action-label,
.sprite-action-detail,
.sprite-panel-label,
.sprite-control-label,
.sprite-outcome-label,
.sprite-field-label,
.sprite-scenario-value,
.sprite-lab-copy,
.sprite-seed-label {
  justify-content: center;
}

/* Public-facing phone composition. The game-scoped specificity isolates these
   rules from legacy deterministic-lab selectors later in the sheet. */
@media (max-width: 760px), (pointer: coarse) {
  .game {
    width: 100vw;
    height: 100svh;
    min-height: 100svh;
    padding: 0;
    overflow: hidden;
  }

  .game .stage {
    width: 100vw;
    height: 100svh;
    max-width: none;
    aspect-ratio: auto;
    overflow: hidden;
  }

  .game .stage canvas {
    position: absolute;
    left: 50%;
    width: auto;
    min-width: 100%;
    height: 100%;
    transform: translateX(-50%);
  }

  .game .hud.top {
    padding: max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right)) 10px
      max(10px, env(safe-area-inset-left));
  }

  .game .brand {
    font-size: 13px;
  }

  .game .counter {
    width: 54px;
    height: 54px;
  }

  .game .objective {
    top: max(61px, calc(env(safe-area-inset-top) + 51px));
    right: max(10px, env(safe-area-inset-right));
    width: 54px;
    height: 54px;
    padding: 10px;
    grid-template-columns: 1fr;
    background-position: 100% 0;
  }

  .game .objective > span {
    display: none;
  }

  .game .objective-direction {
    width: 30px;
    height: 30px;
  }

  .game .objective strong {
    font-size: 8px;
  }

  .game .objective small {
    font-size: 7px;
  }

  .game .hud.bottom {
    z-index: 6;
    right: auto;
    bottom: calc(108px + env(safe-area-inset-bottom));
    left: 50%;
    width: auto;
    padding: 0;
    transform: translateX(-50%);
  }

  .game .health {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    justify-items: center;
    filter: drop-shadow(0 3px 7px #000);
  }

  .game .health-label {
    grid-column: 1 / 3;
  }

  .game .health b {
    width: min(44vw, 170px);
    height: 30px;
  }

  .game .mobile-controls {
    position: fixed;
    z-index: 7;
    inset: auto 0 0;
    display: flex;
    height: calc(112px + env(safe-area-inset-bottom));
    padding: 4px max(10px, env(safe-area-inset-right))
      max(4px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    align-items: end;
    justify-content: space-between;
    pointer-events: none;
    background: none;
    border: 0;
  }

  .game .move-pad {
    flex: 0 0 102px;
    width: 102px;
    height: 102px;
    pointer-events: auto;
    background-color: transparent;
    background-image: var(--ui-atlas);
    background-position: 100% 33.333%;
    background-repeat: no-repeat;
    background-size: 400% 400%;
    filter: drop-shadow(0 5px 8px #000);
  }

  .game .move-ring {
    inset: 13px;
  }

  .game .move-knob {
    width: 40px;
    height: 40px;
    margin: -20px;
  }

  .game .move-pad small {
    bottom: 4px;
  }

  .game .mobile-actions {
    display: grid;
    grid-template:
      "ability primary" 50px
      "tonic primary" 50px / 50px 82px;
    gap: 4px 7px;
    width: 139px;
    pointer-events: auto;
  }

  .game .mobile-actions button {
    width: 50px;
    min-width: 50px;
    height: 50px;
    min-height: 50px;
    padding: 8px 4px;
    border: 0;
    border-radius: 0;
    background-color: transparent;
    background-image: var(--ui-atlas);
    background-repeat: no-repeat;
    background-size: 400% 400%;
    filter: drop-shadow(0 4px 7px #000);
  }

  .game .mobile-actions .primary-action {
    grid-area: primary;
    align-self: center;
    width: 82px;
    min-width: 82px;
    height: 82px;
    min-height: 82px;
    background-color: transparent;
    background-image: var(--ui-atlas);
    background-position: 0 33.333%;
    background-repeat: no-repeat;
    background-size: 400% 400%;
  }

  .game .mobile-actions .ability-action {
    grid-area: ability;
    background-position: 33.333% 33.333%;
  }

  .game .mobile-actions .tonic-action {
    grid-area: tonic;
    background-position: 66.667% 33.333%;
  }

  .game .mobile-actions .sprite-action-label {
    font-size: 10px;
  }

  .game .mobile-actions .sprite-action-detail,
  .game #mobile-cd,
  .game #mobile-tonics {
    font-size: 8px;
  }

  .game > .lab-toggle {
    top: max(8px, env(safe-area-inset-top));
    right: 72px;
    bottom: auto;
    opacity: 0.62;
  }

  .selection.selection-v2 {
    height: 100svh;
    min-height: 100svh;
  }

  .selection-v2 .selection-art {
    background-position: center 42%;
  }

  .selection-v2::after {
    background:
      linear-gradient(180deg, #030506d9 0, transparent 20%),
      linear-gradient(0deg, #030506 0, #030506fa 22%, transparent 49%);
  }

  .selection-v2 .selection-header {
    top: max(12px, env(safe-area-inset-top));
  }

  .selection-v2 .selection-header .eyebrow {
    margin-bottom: 4px;
  }

  .selection-v2 .selection-header h1 {
    font-size: clamp(40px, 12vw, 50px);
    line-height: 0.9;
  }

  .selection-v2 .choose {
    padding: 0 11px max(10px, env(safe-area-inset-bottom));
  }

  .selection-v2 .selected-class {
    min-height: 48px;
    margin-bottom: 5px;
  }

  .selection-v2 .selected-class h2 {
    margin-bottom: 1px;
    font-size: clamp(25px, 7.5vw, 32px);
  }

  .selection-v2 .selected-class .sprite-role {
    font-size: 8px;
  }

  .selection-v2 .selected-class .sprite-stats {
    font-size: 7px;
  }

  .selection-v2 .cards {
    gap: 5px;
  }

  .selection-v2 .class-card,
  .selection-v2 .class-card.selected {
    min-height: 64px;
    transform: none;
  }

  .selection-v2 .class-card strong {
    bottom: 4px;
    font-size: clamp(11px, 3.2vw, 14px);
  }

  .selection-v2 .run-controls {
    gap: 6px;
    margin-top: 6px;
  }

  .selection-v2 .seed-label > .sprite-text {
    height: 10px;
    font-size: 6px;
  }

  .selection-v2 .seed-control,
  .selection-v2 .begin {
    min-height: 44px;
  }

  .selection-v2 .seed-control input {
    min-height: 44px;
  }

  .selection-v2 .begin .sprite-text,
  .selection-v2 .seed-display {
    font-size: 9px;
  }
}

@media (orientation: portrait) and (max-width: 760px) and (pointer: coarse) {
  .game .objective {
    position: fixed;
    top: max(70px, calc(env(safe-area-inset-top) + 60px));
    right: max(0px, env(safe-area-inset-right));
    width: 50px;
    height: 50px;
  }
}

@media (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  .selection.selection-v2 {
    background-image: var(--selection-art);
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
  }

  .selection-v2 .selection-art {
    background-position: 30% 43%;
    background-size: auto 120%;
    -webkit-mask-image: linear-gradient(
      90deg,
      transparent 7%,
      #000 19%,
      #000 50%,
      transparent 63%
    );
    mask-image: linear-gradient(
      90deg,
      transparent 7%,
      #000 19%,
      #000 50%,
      transparent 63%
    );
  }

  .selection-v2[data-selected-class="arcanist"] .selection-art {
    background-position: 30% 38%;
  }

  .game .stage {
    width: 100vw;
    height: 100svh;
    aspect-ratio: auto;
  }

  .game .stage canvas {
    top: 50%;
    left: 0;
    width: 100%;
    min-width: 100%;
    height: auto;
    min-height: 100%;
    transform: translateY(-50%);
  }

  .game .mobile-controls {
    height: calc(104px + env(safe-area-inset-bottom));
  }

  .game .hud.bottom {
    bottom: max(7px, env(safe-area-inset-bottom));
  }

  .selection-v2 .selection-header {
    top: max(10px, env(safe-area-inset-top));
  }

  .selection-v2 .selection-header h1 {
    font-size: 40px;
  }

  .selection-v2 .choose {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    width: min(45vw, 400px);
  }

  .selection-v2 .selected-class {
    min-height: 34px;
  }

  .selection-v2 .selected-class h2 {
    font-size: 23px;
  }

  .selection-v2 .class-card,
  .selection-v2 .class-card.selected {
    min-height: 56px;
  }
}

/* The playfield is the product surface on every device. The 16:9 canvas is
   cover-fitted inside this viewport frame; input mapping reads the canvas's
   actual client rect, so the cropped edges remain semantically correct. */
.game .stage {
  width: 100vw;
  height: 100svh;
  max-width: none;
  aspect-ratio: auto;
  overflow: hidden;
}

@media (min-width: 761px) and (pointer: fine) {
  .game .stage canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    width: auto;
    min-width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
  }
}

@media (min-width: 761px) and (max-width: 900px) and (pointer: fine) {
  .selection-v2 .selection-header {
    top: 22px;
    left: 24px;
    width: 340px;
    text-align: left;
  }

  .selection-v2 .selection-header h1 {
    font-size: 50px;
  }

  .selection-v2 .choose {
    right: 22px;
    left: auto;
    width: min(56vw, 448px);
    padding-bottom: 22px;
  }

  .selection-v2 .class-card {
    min-height: 82px;
  }
}
.seed-label > .sprite-text {
  font-size: 12px;
}
.seed-control {
  position: relative;
  display: block;
  min-height: 46px;
  margin-top: 7px;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 0 0;
  background-repeat: no-repeat;
}
.seed-control input {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 46px;
  margin: 0;
  padding: 13px;
  border: 0;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: #f5ecdf;
}
.seed-control:focus-within {
  outline: 2px solid #d99b58;
  outline-offset: 2px;
}
.seed-display {
  position: absolute;
  z-index: 1;
  inset: 0;
  flex-wrap: nowrap;
  overflow: hidden;
  padding: 13px;
  font-size: 12px;
  pointer-events: none;
}
.begin .sprite-text,
.begin .sprite-word {
  float: none;
  font-size: inherit;
  line-height: 1;
}
.begin > .sprite-text {
  justify-content: center;
}
.selection-lab-toggle {
  position: static;
  display: flex;
  width: max-content;
  min-width: 96px;
  min-height: 44px;
  margin: 14px 0 0 auto;
  align-items: center;
  justify-content: center;
}
.health-label .sprite-text,
.health-label .sprite-word {
  display: flex;
  margin: 0;
  font-size: 9px;
}
.skills .sprite-text {
  width: 100%;
  justify-content: center;
}
.skills .sprite-glyph {
  color: inherit;
  font-size: inherit;
}
.skills .sprite-shortcut {
  color: #dba35f;
  font-size: 8px;
}
.skills .sprite-action-label {
  margin-top: 3px;
  font-size: 10px;
}
.loot-log strong > .sprite-text {
  font-size: 10px;
}
.move-pad small > .sprite-text {
  font-size: 8px;
}
.mobile-actions .sprite-text,
.mobile-actions .sprite-word {
  margin: 0;
  text-transform: none;
}
.mobile-actions .sprite-text {
  display: flex;
  justify-content: center;
}
.mobile-actions .sprite-action-label {
  font-size: 10px;
}
.mobile-actions .sprite-action-detail {
  font-size: 7px;
}
.outcome p > .sprite-text {
  font-size: 11px;
}
.lab {
  border: 0;
  background-color: #121819;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 100% 66.667%;
  background-repeat: no-repeat;
}
.lab .close {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-content: center;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 0 33.333%;
  background-repeat: no-repeat;
}
.lab .eyebrow > .sprite-text {
  justify-content: flex-start;
  padding-right: 38px;
  font-size: 10px;
}
.lab .lab-field {
  display: block;
  margin: 0;
}
.lab-field-label > .sprite-text {
  justify-content: flex-start;
  font-size: 10px;
}
.lab .scenario-chooser {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 4px;
  margin: 7px 0 9px;
}
.scenario-chooser button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
}
.scenario-value {
  display: grid;
  min-width: 0;
  height: 44px;
  padding: 0 8px;
  place-content: center;
  overflow: hidden;
  background-color: transparent;
  background-image: var(--ui-atlas);
  background-size: 400% 400%;
  background-position: 66.667% 0;
  background-repeat: no-repeat;
}
.scenario-value > .sprite-text {
  flex-wrap: nowrap;
  justify-content: center;
  font-size: 9px;
}
.lab .lab-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin: 9px 0;
}
.lab-actions button {
  min-width: 0;
  min-height: 44px;
  padding: 6px 3px;
}
.lab > [data-lab="capture"] {
  width: 100%;
  min-height: 44px;
}
.lab button > .sprite-text {
  font-size: 9px;
}
.lab .frame > .sprite-text {
  justify-content: flex-start;
  font-size: 9px;
}

@media (min-width: 761px) {
  .selection {
    padding: clamp(28px, 4vw, 64px);
  }
}

@media (max-width: 760px) {
  .selection {
    gap: 20px;
  }
  .hero-lineup {
    display: flex;
    height: 142px;
  }
  .hero-lineup span,
  .hero-lineup span:nth-child(2) {
    width: 122px;
    height: 122px;
    flex-basis: 122px;
  }
  .class-card {
    grid-template-columns: 104px minmax(0, 1fr);
    column-gap: 8px;
    min-height: 158px;
    padding: 18px 24px 18px 18px;
  }
  .class-portrait {
    float: none;
    width: 104px;
    height: 104px;
    margin: 0;
  }
  .class-card > .sprite-text {
    display: flex;
    margin-top: 5px;
  }
  .sprite-role {
    font-size: 13px;
  }
  .sprite-description {
    min-height: 34px;
    font-size: 12px;
  }
  .sprite-stats {
    font-size: 11px;
  }
  .health b {
    width: min(45vw, 180px);
  }
}

@media (orientation: landscape) and (max-height: 600px) and (pointer: coarse) {
  .selection {
    grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
    align-items: start;
    gap: 14px;
    padding: max(16px, env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
    overflow-x: hidden;
    overflow-y: auto;
  }
  .selection .hero h1 {
    font-size: 48px;
  }
  .game {
    width: 100vw;
    height: 100svh;
    background-color: #0a0d0d;
    background-image: var(--terrain-atlas);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }
  .stage {
    width: min(100vw, 177.778svh);
    height: auto;
    max-width: 100vw;
    aspect-ratio: 16 / 9;
  }
  .mobile-controls {
    background-color: transparent;
    background-image: var(--ui-atlas);
  }
  .hud.bottom {
    z-index: 8;
    right: auto;
    bottom: 10px;
    left: 50%;
    width: auto;
    padding: 0;
    transform: translateX(-50%);
  }
  .health b {
    width: 192px;
  }
  .loot-log {
    display: none;
  }
  .game .objective {
    top: 8px;
    right: max(70px, calc(env(safe-area-inset-right) + 60px));
    width: 54px;
    height: 54px;
  }
}

/* Keep this final because legacy selection rules above remain shared by the
   test lab and outcome panels. */
.selection-v2 .selection-lab-toggle {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  bottom: auto;
  display: flex;
  width: 48px;
  min-width: 48px;
  min-height: 44px;
  margin: 0;
  align-items: center;
  justify-content: center;
}
