:root {
  --gold: #f5c45a;
  --gold-bright: #ffe6a0;
  --gold-dark: #7a4b16;
  --red: #9f1f1f;
  --red-bright: #e94b3e;
  --ink: #120d0a;
  --panel: #24160d;
  --paper: #f5dfb5;
  --paper-deep: #d6a95e;
  --green: #60c577;
  --blue: #49aeea;
  --purple: #a761ff;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: #fff4d6;
  font-family:
    "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", Georgia, serif;
  background:
    radial-gradient(circle at 18% 8%, rgba(179, 48, 55, 0.34), transparent 24rem),
    radial-gradient(circle at 88% 20%, rgba(119, 67, 190, 0.28), transparent 22rem),
    linear-gradient(135deg, #160d0a 0%, #29120d 42%, #100b10 100%);
}

button {
  font: inherit;
}

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

.title-screen {
  position: relative;
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: clamp(18px, 4vw, 54px);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(22, 9, 7, 0.24), rgba(22, 9, 7, 0.12) 44%, rgba(22, 9, 7, 0.7)),
    linear-gradient(0deg, rgba(12, 6, 5, 0.78), transparent 42%),
    url("assets/title-illustration.png") center/cover no-repeat;
}

.title-screen::before {
  content: "";
  position: absolute;
  inset: 14px;
  pointer-events: none;
  border: 2px solid rgba(245, 196, 90, 0.82);
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 242, 185, 0.28),
    inset 0 0 80px rgba(0, 0, 0, 0.58);
}

.title-overlay {
  position: relative;
  z-index: 1;
  width: min(660px, 100%);
  margin-left: auto;
  margin-right: clamp(22px, 5vw, 72px);
  padding: 0 clamp(8px, 3vw, 34px);
  text-align: right;
  text-shadow:
    0 4px 0 #3a100f,
    0 0 18px rgba(255, 206, 86, 0.56),
    0 0 42px rgba(0, 0, 0, 0.88);
}

.title-screen h1 {
  margin: 0 0 clamp(28px, 5vw, 54px);
  color: #fff3cf;
  font-size: clamp(2.7rem, 5.8vw, 5.8rem);
  line-height: 0.98;
}

.title-screen h1 span {
  display: block;
  white-space: nowrap;
}

.title-menu {
  display: grid;
  width: min(360px, 88vw);
  margin-left: auto;
  gap: 14px;
}

.title-button {
  min-height: 70px;
  cursor: pointer;
  color: #fff5d1;
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: 900;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(74, 48, 24, 0.98), rgba(16, 10, 7, 0.96)),
    radial-gradient(circle at 50% 0%, rgba(255, 229, 138, 0.22), transparent 70%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 244, 190, 0.2),
    0 14px 28px rgba(0, 0, 0, 0.46);
  transition:
    transform 0.16s ease,
    filter 0.16s ease,
    border-color 0.16s ease;
}

.title-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  border-color: var(--gold-bright);
}

.title-button.primary {
  background:
    linear-gradient(180deg, #e34731, #981a15 54%, #4c0e0c),
    radial-gradient(circle at 50% 0%, rgba(255, 238, 154, 0.36), transparent 70%);
}

.app-shell {
  width: min(1700px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 12px 0 18px;
}

.app-header {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 430px);
  gap: 18px;
  min-height: 170px;
  padding: 18px;
  border: 2px solid var(--gold);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(24, 12, 12, 0.95), rgba(92, 20, 26, 0.8)),
    url("assets/heroes-lineup.png") center/cover no-repeat;
  box-shadow: var(--shadow);
}

.app-header::before,
.battle-card::before,
.commander-card::before,
.tactics-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  pointer-events: none;
  border: 1px solid rgba(255, 225, 142, 0.48);
  border-radius: 6px;
}

.title-block {
  position: relative;
  z-index: 1;
  align-self: center;
  padding-left: 12px;
  text-shadow: 0 3px 0 #3a100f, 0 0 16px rgba(255, 207, 96, 0.46);
}

.eyebrow,
.subtitle,
.panel-kicker {
  margin: 0;
  color: var(--gold-bright);
  font-weight: 800;
}

.eyebrow {
  font-size: clamp(1rem, 2vw, 1.4rem);
  letter-spacing: 0;
}

h1 {
  margin: 6px 0 6px;
  font-size: clamp(2.4rem, 6vw, 5.1rem);
  line-height: 0.95;
  color: #fff5d7;
}

.subtitle {
  font-size: clamp(1rem, 2.4vw, 1.7rem);
}

.chapter-mark {
  position: absolute;
  right: 18px;
  top: 0;
  width: 84px;
  height: 112px;
  display: grid;
  place-items: center;
  color: #fff2c9;
  font-size: 1.9rem;
  font-weight: 900;
  z-index: 2;
  background: linear-gradient(#8b1714, #c93622 52%, #68130f);
  border: 2px solid var(--gold);
  border-top: 0;
  clip-path: polygon(0 0, 100% 0, 100% 82%, 50% 100%, 0 82%);
  box-shadow: 0 0 18px rgba(255, 205, 89, 0.45);
}

.hero-ribbon {
  position: relative;
  z-index: 1;
  min-height: 125px;
  border-radius: 6px;
  background:
    linear-gradient(90deg, transparent 0%, rgba(17, 9, 6, 0.18) 36%, rgba(17, 9, 6, 0.72) 100%),
    url("assets/heroes-lineup.png") center 43%/cover no-repeat;
  border: 1px solid rgba(255, 227, 150, 0.38);
}

.game-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) 210px;
  gap: 12px;
  margin-top: 0;
  align-items: start;
}

.commander-card,
.battle-card,
.tactics-card {
  position: relative;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background:
    linear-gradient(rgba(26, 16, 9, 0.92), rgba(26, 16, 9, 0.96)),
    radial-gradient(circle at 50% 10%, rgba(255, 204, 86, 0.24), transparent 60%);
  box-shadow: var(--shadow);
}

.commander-card,
.tactics-card {
  padding: 12px;
}

.lineup-art {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 6px;
  border: 1px solid rgba(255, 225, 142, 0.54);
  background: url("assets/heroes-lineup.png") 12% 50%/360% auto no-repeat;
  box-shadow: inset 0 0 42px rgba(0, 0, 0, 0.35);
}

.panel-kicker {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  color: #321909;
  background: var(--gold);
  font-size: 0.78rem;
}

.commander-status {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.commander-status div,
.enemy-meter,
.goal-meter {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  color: #ffe9ad;
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid rgba(245, 196, 90, 0.4);
  border-radius: 6px;
}

.commander-status span,
.enemy-meter span,
.goal-meter span {
  color: #d7c18a;
  font-weight: 700;
}

.battle-card {
  padding: 12px;
}

.battle-hud {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.stat-pill,
.hud-button {
  min-height: 44px;
  border: 2px solid rgba(245, 196, 90, 0.78);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(64, 42, 21, 0.96), rgba(18, 12, 9, 0.98));
  color: #fff1be;
  box-shadow: inset 0 0 0 1px rgba(255, 245, 193, 0.18);
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  white-space: nowrap;
}

.stat-pill span {
  color: var(--gold-bright);
  font-size: 0.82rem;
  font-weight: 800;
}

.stat-pill strong {
  font-size: 1.15rem;
}

.life strong {
  color: #ff817b;
}

.cost strong {
  color: #9ff08d;
}

.hud-button {
  cursor: pointer;
  padding: 7px 14px;
  font-weight: 900;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    filter 0.16s ease;
}

.hud-button:hover {
  transform: translateY(-1px);
  border-color: var(--gold-bright);
  filter: brightness(1.08);
}

.hud-button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
  transform: none;
}

.hud-button.primary {
  color: #fff7d7;
  background: linear-gradient(180deg, #e34430, #8f1715 56%, #4a0c0c);
  border-color: #ffe096;
}

.hud-button.icon {
  width: 48px;
  padding: 0;
  font-size: 1.25rem;
}

.hud-button.wide {
  width: 100%;
  justify-content: center;
}

.board-frame {
  padding: 6px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 218, 112, 0.5), rgba(87, 44, 8, 0.6)),
    #160d08;
  border: 2px solid rgba(245, 196, 90, 0.74);
}

.battle-board {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  border-radius: 6px;
  background:
    linear-gradient(rgba(10, 7, 6, 0.1), rgba(10, 7, 6, 0.1)),
    url("assets/battlefield.png") center/100% 100% no-repeat;
  box-shadow: inset 0 0 34px rgba(0, 0, 0, 0.48);
}

.grid-layer,
.entity-layer,
.effect-layer,
.lane-labels,
.column-labels {
  position: absolute;
  inset: 0;
}

.grid-layer {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(5, 1fr);
  z-index: 3;
}

.cell {
  position: relative;
  border: 1px solid rgba(255, 235, 169, 0.24);
  background: rgba(255, 255, 255, 0.02);
  cursor: crosshair;
}

.cell::after {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 5px;
  opacity: 0;
  border: 2px solid rgba(124, 223, 255, 0.78);
  background: rgba(45, 184, 230, 0.18);
  transition: opacity 0.12s ease;
}

.cell.placeable::after {
  opacity: 0.44;
}

.cell.placeable:hover::after,
.cell.is-target::after {
  opacity: 0.88;
}

.cell.blocked::after {
  border-color: rgba(255, 97, 84, 0.72);
  background: rgba(130, 20, 14, 0.25);
  opacity: 0.28;
}

.range-layer,
.entity-layer,
.effect-layer {
  pointer-events: none;
}

.range-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
}

.entity-layer {
  z-index: 8;
}

.effect-layer {
  z-index: 12;
}

.entity {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -58%);
}

.unit {
  width: min(10.9%, 108px);
  aspect-ratio: 1;
  filter: drop-shadow(0 8px 6px rgba(0, 0, 0, 0.45));
}

.unit-token {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--unit-color);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08)),
    url("assets/heroes-lineup.png");
  background-size: 650% auto;
  box-shadow:
    inset 0 0 0 2px rgba(255, 245, 197, 0.24),
    0 0 18px color-mix(in srgb, var(--unit-color), transparent 42%);
}

.unit-sprite {
  width: 100%;
  height: 100%;
  transform-origin: 52% 72%;
  transform: scale(var(--sprite-scale, 1));
  transition: transform 0.08s ease, filter 0.08s ease;
}

.unit-sprite.has-motion {
  background-size: 400% 200%;
  background-position: var(--sheet-x) var(--sheet-y);
  background-repeat: no-repeat;
}

.unit-sprite.fallback {
  border-radius: 32% 32% 40% 40%;
  border: 2px solid color-mix(in srgb, var(--unit-color), #ffeab1 24%);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08)),
    url("assets/heroes-lineup.png");
  background-size: 650% auto;
  box-shadow:
    inset 0 0 0 2px rgba(255, 245, 197, 0.2),
    0 0 18px color-mix(in srgb, var(--unit-color), transparent 44%);
}

.unit.is-attacking .unit-sprite.has-motion {
  transform: scale(calc(var(--sprite-scale, 1) * 1.08));
  filter: saturate(1.18) brightness(1.08);
}

.unit.is-attacking .unit-sprite.has-motion.stable-motion {
  transform: scale(var(--sprite-scale, 1));
  filter: saturate(1.14) brightness(1.06);
}

.unit.is-attacking .unit-sprite.fallback {
  animation: fallbackAttack 0.34s ease-out;
}

.p-0 { background-position: 0% 48%; }
.p-1 { background-position: 20% 48%; }
.p-2 { background-position: 40% 48%; }
.p-3 { background-position: 60% 48%; }
.p-4 { background-position: 80% 48%; }
.p-5 { background-position: 100% 48%; }
.p-6,
.p-7 {
  background-size: cover;
  background-position: center 44%;
  background-repeat: no-repeat;
}
.p-6 {
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08)),
    url("assets/portrait-maruna.png");
}
.p-7 {
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08)),
    url("assets/portrait-mikage.png");
}

.unit::before {
  content: attr(data-class);
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  padding: 1px 6px;
  color: #fff8d6;
  font-size: clamp(0.55rem, 1.3vw, 0.72rem);
  font-weight: 900;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid rgba(255, 234, 164, 0.7);
  background: rgba(21, 12, 8, 0.82);
}

.range-preview {
  position: absolute;
  left: var(--left);
  top: var(--top);
  width: var(--width);
  height: var(--height);
  border: 2px solid var(--unit-color);
  border-radius: 7px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--unit-color), transparent 70%), transparent),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 10%);
  box-shadow:
    inset 0 0 20px color-mix(in srgb, var(--unit-color), transparent 58%),
    0 0 18px color-mix(in srgb, var(--unit-color), transparent 42%);
}

.range-preview.is-circle {
  border-radius: 50%;
  background:
    radial-gradient(circle, color-mix(in srgb, var(--unit-color), transparent 74%) 0 62%, color-mix(in srgb, var(--unit-color), transparent 86%) 63%, transparent 72%),
    repeating-radial-gradient(circle, rgba(255, 255, 255, 0.14) 0 1px, transparent 1px 11%);
}

.range-preview.is-cross {
  border: 0;
  background: none;
  box-shadow: none;
}

.range-preview.is-cross::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(0 40%, 40% 40%, 40% 0, 60% 0, 60% 40%, 100% 40%, 100% 60%, 60% 60%, 60% 100%, 40% 100%, 40% 60%, 0 60%);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--unit-color), transparent 70%), transparent),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 20%);
  filter: drop-shadow(0 0 12px color-mix(in srgb, var(--unit-color), transparent 35%));
}

.range-preview.is-cross span {
  left: 50%;
  top: 50%;
  z-index: 1;
  transform: translate(-50%, -50%);
}

.range-preview span {
  position: absolute;
  left: 8px;
  top: 6px;
  padding: 2px 7px;
  color: #fff8d6;
  font-size: clamp(0.62rem, 1.2vw, 0.78rem);
  font-weight: 900;
  white-space: nowrap;
  text-shadow: 0 1px 0 #26100c;
  border: 1px solid rgba(255, 238, 181, 0.72);
  border-radius: 999px;
  background: rgba(18, 10, 7, 0.74);
}

.hp-bar {
  position: absolute;
  left: 4%;
  right: 4%;
  top: -8px;
  height: 7px;
  border: 1px solid #33140d;
  background: rgba(27, 8, 7, 0.72);
  border-radius: 999px;
  overflow: hidden;
}

.hp-bar i {
  display: block;
  height: 100%;
  width: var(--hp);
  background: linear-gradient(90deg, #63e36d, #fff17b);
}

.enemy .hp-bar i {
  background: linear-gradient(90deg, #ff2d2d, #ff7a4f);
}

.skill-glow {
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid rgba(255, 243, 162, 0.75);
  animation: pulse 1.2s ease-in-out infinite;
}

.enemy {
  width: min(9.8%, 92px);
  aspect-ratio: 1;
  transform: translate(-50%, -56%);
}

.enemy-motion {
  position: relative;
  width: 100%;
  height: 100%;
  transform:
    translate(var(--motion-x, 0), var(--motion-y, 0))
    rotate(var(--motion-rotate, 0deg))
    scale(var(--motion-scale-x, 1), var(--motion-scale-y, 1));
  transform-origin: 50% 76%;
  will-change: transform;
}

.enemy-sprite {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  background-size: 400% 200%;
  background-position: var(--sheet-x) var(--sheet-y);
  background-repeat: no-repeat;
  transform: scale(var(--enemy-scale, 1));
  transform-origin: 50% 72%;
  filter: drop-shadow(0 8px 6px rgba(0, 0, 0, 0.45));
}

.enemy-body {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 46% 46% 40% 40%;
  color: #f7e7cb;
  font-size: clamp(1rem, 2.4vw, 2rem);
  font-weight: 900;
  background:
    radial-gradient(circle at 35% 24%, rgba(255, 255, 255, 0.18), transparent 20%),
    linear-gradient(180deg, var(--enemy-a), var(--enemy-b));
  border: 2px solid #2d1110;
  box-shadow:
    inset 0 -8px 18px rgba(0, 0, 0, 0.35),
    0 8px 10px rgba(0, 0, 0, 0.4);
}

.enemy-ground-shadow {
  position: absolute;
  left: 22%;
  bottom: 5%;
  z-index: 0;
  width: 56%;
  height: 10%;
  opacity: var(--shadow-opacity, 0.34);
  border-radius: 50%;
  background: rgba(12, 5, 16, 0.82);
  filter: blur(2px);
  transform: translateY(var(--shadow-y, 0px)) scaleX(var(--shadow-scale, 1));
  transform-origin: 50% 50%;
}

.enemy-motion-accent {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
}

.enemy-motion.motion-scuttle.state-moving .enemy-motion-accent,
.enemy-motion.motion-lope.state-moving .enemy-motion-accent,
.enemy-motion.motion-stomp.state-moving .enemy-motion-accent {
  right: 10%;
  bottom: 8%;
  width: 24%;
  height: 13%;
  opacity: 0.34;
  background: radial-gradient(ellipse, rgba(220, 180, 132, 0.58), transparent 68%);
  filter: blur(2px);
}

.enemy-motion.motion-hover .enemy-motion-accent,
.enemy-motion.motion-flutter .enemy-motion-accent {
  inset: 14% 10% 19%;
  opacity: 0.3;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(181, 101, 255, 0.28), transparent 68%);
  filter: blur(5px);
}

.enemy-motion.motion-ooze .enemy-motion-accent,
.enemy-motion.motion-heave .enemy-motion-accent,
.enemy-motion.motion-pulse .enemy-motion-accent {
  left: 15%;
  right: 15%;
  bottom: 4%;
  height: 16%;
  opacity: 0.36;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(153, 55, 184, 0.5), transparent 70%);
  filter: blur(3px);
  transform: scaleX(var(--shadow-scale, 1));
}

.enemy-motion.is-attacking .enemy-motion-accent {
  left: -8%;
  right: auto;
  top: 28%;
  bottom: auto;
  width: 32%;
  height: 42%;
  opacity: 0.58;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 95, 74, 0.68), transparent 68%);
  filter: blur(4px);
}

.enemy.boss {
  width: min(14.5%, 138px);
}

.enemy.slowed .enemy-body {
  box-shadow:
    inset 0 -8px 18px rgba(0, 0, 0, 0.35),
    0 0 18px rgba(73, 174, 234, 0.88);
}

.enemy.slowed .enemy-sprite {
  filter:
    drop-shadow(0 8px 6px rgba(0, 0, 0, 0.45))
    drop-shadow(0 0 14px rgba(73, 174, 234, 0.86));
}

.projectile {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--color);
  box-shadow: 0 0 18px var(--color), 0 0 4px #fff;
}

.projectile.slash {
  width: 34px;
  height: 8px;
  border-radius: 999px;
  transform: translate(-50%, -50%) rotate(-14deg);
}

.float-text {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, calc(-90% - var(--rise)));
  color: var(--color);
  font-size: clamp(0.9rem, 1.6vw, 1.25rem);
  font-weight: 900;
  text-shadow: 0 2px 0 #1d0906, 0 0 10px rgba(0, 0, 0, 0.62);
  opacity: var(--alpha);
  white-space: nowrap;
}

.lane-labels span,
.column-labels span {
  position: absolute;
  color: rgba(255, 237, 176, 0.72);
  font-size: clamp(0.85rem, 1.6vw, 1.3rem);
  font-weight: 900;
  text-shadow: 0 2px 2px rgba(0, 0, 0, 0.8);
}

.lane-labels span:nth-child(1) { top: 10%; left: 2.4%; }
.lane-labels span:nth-child(2) { top: 30%; left: 2.4%; }
.lane-labels span:nth-child(3) { top: 50%; left: 2.4%; }
.lane-labels span:nth-child(4) { top: 70%; left: 2.4%; }
.lane-labels span:nth-child(5) { top: 90%; left: 2.4%; }

.column-labels span {
  top: 1.5%;
}

.column-labels span:nth-child(1) { left: 8%; }
.column-labels span:nth-child(2) { left: 18%; }
.column-labels span:nth-child(3) { left: 28%; }
.column-labels span:nth-child(4) { left: 38%; }
.column-labels span:nth-child(5) { left: 48%; }
.column-labels span:nth-child(6) { left: 58%; }
.column-labels span:nth-child(7) { left: 68%; }
.column-labels span:nth-child(8) { left: 78%; }
.column-labels span:nth-child(9) { left: 88%; }
.column-labels span:nth-child(10) { left: 96%; }

.route-arrow {
  position: absolute;
  right: 4%;
  top: 47%;
  z-index: 4;
  width: 76px;
  height: 36px;
  background: linear-gradient(90deg, #e23d2a, #a71918);
  border: 2px solid #ffdda1;
  clip-path: polygon(0 50%, 14% 0, 100% 0, 100% 100%, 14% 100%);
  opacity: 0.9;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}

body.is-running .route-arrow {
  opacity: 0;
  transform: translateX(24px);
}

body.is-running .game-layout {
  grid-template-columns: minmax(0, 1fr);
}

body.is-running .commander-card,
body.is-running .tactics-card {
  display: none;
}

body.is-running .battle-board {
  aspect-ratio: 2.08 / 1;
}

.lower-dock {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.unit-panel,
.skill-panel,
.tactics-block,
.class-list,
.log-panel {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(245, 196, 90, 0.52);
  background: rgba(0, 0, 0, 0.32);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: #ffe9ad;
  font-weight: 900;
}

.section-title strong {
  color: #9ff08d;
  font-size: 0.86rem;
}

.unit-roster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.unit-card {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-height: 78px;
  padding: 7px 78px 7px 7px;
  cursor: pointer;
  color: #fff4cf;
  text-align: left;
  border: 2px solid rgba(245, 196, 90, 0.52);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(53, 30, 15, 0.92), rgba(15, 10, 8, 0.96));
}

.unit-card.is-selected {
  border-color: var(--unit-color);
  box-shadow: 0 0 16px color-mix(in srgb, var(--unit-color), transparent 46%);
}

.unit-card.is-cooling {
  border-color: rgba(98, 173, 255, 0.72);
}

.unit-card:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.unit-token {
  width: 44px;
  height: 44px;
}

.unit-card b,
.skill-button b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-card small {
  display: block;
  margin-top: 2px;
  color: #e7d090;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cost-badge,
.deploy-badge {
  position: absolute;
  right: 5px;
  padding: 1px 6px;
  font-size: 0.72rem;
  font-weight: 900;
  border-radius: 999px;
}

.cost-badge {
  top: 4px;
  color: #ffe9ad;
  background: #12100e;
  border: 1px solid rgba(245, 196, 90, 0.58);
}

.deploy-badge {
  display: none;
  top: 25px;
  color: #cfeaff;
  border-color: rgba(98, 173, 255, 0.62);
  background: #0f1a24;
  border: 1px solid rgba(98, 173, 255, 0.62);
}

.unit-card.is-cooling .deploy-badge {
  display: inline-block;
}

.skill-strip {
  display: grid;
  gap: 8px;
}

.skill-button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 52px;
  padding: 6px 8px;
  cursor: pointer;
  color: #fff4cf;
  text-align: left;
  border: 1px solid rgba(245, 196, 90, 0.52);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(44, 29, 17, 0.96), rgba(9, 8, 7, 0.94));
}

.skill-button:disabled {
  cursor: default;
  opacity: 0.58;
}

.skill-button small {
  display: block;
  overflow: hidden;
  color: #d7c18a;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-button.is-ready {
  border-color: #fff0a8;
  box-shadow: 0 0 14px rgba(255, 207, 84, 0.42);
}

.skill-charge {
  width: 56px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.48);
  border: 1px solid rgba(255, 238, 175, 0.42);
}

.skill-charge i {
  display: block;
  width: var(--charge);
  height: 100%;
  background: linear-gradient(90deg, var(--unit-color), #fff2a0);
}

.tactics-card h2 {
  margin: 0 0 12px;
  color: #fff2bf;
  font-size: 1.4rem;
}

.stage-guide {
  margin: 0 0 12px;
  color: #e7d5aa;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.6;
}

.goal-meter {
  margin-top: 10px;
  align-items: center;
}

.goal-meter i {
  display: block;
  width: 96px;
  height: 12px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--green) var(--goal), #5e160f var(--goal)),
    #5e160f;
  border: 1px solid rgba(255, 235, 171, 0.44);
}

.class-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.class-list div {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 8px;
  color: #ffe8ad;
  align-items: center;
}

.class-list b {
  color: var(--gold-bright);
}

.class-list span {
  color: #e6d7b4;
  font-size: 0.88rem;
}

.log-panel {
  display: none;
}

.log-panel p {
  margin: 0 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(245, 196, 90, 0.18);
}

.hub-shell {
  width: min(1760px, calc(100vw - 24px));
  min-height: calc(100vh - 24px);
  margin: 12px auto;
  padding: clamp(12px, 2vw, 24px);
  color: #fff1c2;
  border: 2px solid rgba(245, 196, 90, 0.86);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(16, 9, 7, 0.78), rgba(16, 8, 7, 0.94)),
    radial-gradient(circle at 58% 42%, rgba(238, 166, 48, 0.24), transparent 28rem),
    url("assets/title-illustration.png") center/cover no-repeat;
  box-shadow:
    inset 0 0 0 1px rgba(255, 230, 160, 0.18),
    var(--shadow);
}

.hub-content {
  display: grid;
  gap: 16px;
}

.hub-content.is-screen-entering > :last-child {
  animation: hubScreenEnter 0.34s cubic-bezier(0.18, 0.78, 0.28, 1) both;
}

::view-transition-old(root) {
  animation: hubViewOut 0.16s ease-in both;
}

::view-transition-new(root) {
  animation: hubViewIn 0.28s cubic-bezier(0.18, 0.78, 0.28, 1) both;
}

.hub-topbar,
.hub-status-band,
.hub-section-title,
.reward-row,
.formation-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hub-topbar {
  justify-content: space-between;
  padding: 10px 12px;
  border: 2px solid rgba(245, 196, 90, 0.74);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(50, 31, 17, 0.95), rgba(12, 9, 8, 0.96));
  box-shadow: inset 0 0 0 1px rgba(255, 243, 184, 0.14);
}

.hub-profile,
.hub-currency {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.hub-resources {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.hub-avatar {
  flex: 0 0 62px;
  width: 62px;
  height: 62px;
}

.hub-profile strong,
.hub-currency strong {
  display: block;
  color: #fff8d8;
  font-size: clamp(1.05rem, 1.6vw, 1.35rem);
  font-weight: 900;
}

.hub-profile span,
.hub-currency span,
.hub-status-band span,
.hub-section-title span,
.hub-kicker {
  color: var(--gold-bright);
  font-weight: 900;
}

.hub-currency {
  justify-content: flex-end;
  padding: 9px 12px;
  border: 1px solid rgba(245, 196, 90, 0.58);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
}

.hub-resources .hub-currency {
  min-width: 156px;
}

.hub-exp {
  border-color: rgba(126, 226, 126, 0.56);
}

.hub-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.hub-nav-button,
.hub-big-button,
.chapter-tab,
.quest-stage-card,
.formation-unit-card,
.unit-library-card {
  cursor: pointer;
  color: #fff1c4;
  border: 2px solid rgba(245, 196, 90, 0.62);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(58, 36, 18, 0.96), rgba(14, 10, 8, 0.98));
  box-shadow: inset 0 0 0 1px rgba(255, 244, 190, 0.12);
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    filter 0.16s ease;
}

.hub-nav-button {
  min-width: 116px;
  min-height: 44px;
  padding: 7px 14px;
  font-weight: 900;
}

.hub-nav-button:hover,
.hub-big-button:hover,
.quest-stage-card:hover,
.formation-unit-card:hover,
.unit-library-card:hover {
  transform: translateY(-1px);
  border-color: var(--gold-bright);
  filter: brightness(1.08);
}

.hub-nav-button.is-active,
.hub-big-button.primary,
.quest-stage-card.is-selected,
.formation-unit-card.is-selected,
.unit-library-card.is-selected {
  border-color: #ffe29c;
  background: linear-gradient(180deg, #d8422e, #8f1714 58%, #3b0b0a);
  box-shadow:
    inset 0 0 0 1px rgba(255, 244, 190, 0.22),
    0 0 18px rgba(245, 196, 90, 0.34);
}

.hub-big-button {
  min-height: 56px;
  padding: 10px 18px;
  font-size: clamp(1rem, 1.7vw, 1.35rem);
  font-weight: 900;
}

.hub-home {
  display: grid;
  gap: 14px;
}

.home-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(240px, 0.86fr) minmax(320px, 1fr);
  min-height: min(62vh, 620px);
  overflow: hidden;
  border: 2px solid rgba(245, 196, 90, 0.72);
  border-radius: 8px;
  background:
    radial-gradient(circle at 62% 48%, rgba(255, 199, 78, 0.4), transparent 18rem),
    linear-gradient(90deg, rgba(18, 10, 8, 0.32), rgba(18, 10, 8, 0.9)),
    url("assets/title-illustration.png") center/cover no-repeat;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.52);
}

.home-character {
  min-height: 100%;
  background: url("assets/heroes-lineup.png") 8% 52%/310% auto no-repeat;
  filter: drop-shadow(0 16px 16px rgba(0, 0, 0, 0.5));
}

.home-actions {
  align-self: center;
  max-width: 620px;
  padding: clamp(20px, 4vw, 48px);
  text-shadow: 0 2px 0 #2a0d09, 0 0 18px rgba(0, 0, 0, 0.7);
}

.home-actions h2,
.quest-page h2,
.quest-detail h3,
.unit-showcase h2 {
  margin: 6px 0 10px;
  color: #fff6d4;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1.05;
}

.home-actions p,
.quest-page p,
.quest-detail p,
.unit-showcase p {
  margin: 0 0 16px;
  color: #f9e7b6;
  font-weight: 800;
  line-height: 1.7;
}

.home-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.hub-status-band {
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid rgba(245, 196, 90, 0.58);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.36);
}

.hub-status-band div {
  display: grid;
  gap: 3px;
  min-width: 210px;
}

.hub-status-band strong {
  color: #fff7d6;
  font-size: 1.08rem;
}

.quest-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 14px;
}

.chapter-list {
  display: grid;
  align-content: start;
  gap: 10px;
}

.chapter-tab {
  min-height: 88px;
  padding: 12px;
  text-align: left;
  font-size: 1.3rem;
  font-weight: 900;
}

.chapter-tab span {
  display: block;
  margin-top: 5px;
  color: #e4c985;
  font-size: 0.84rem;
}

.chapter-tab:not(:disabled):hover {
  transform: translateX(3px);
  border-color: #ffe28c;
  filter: brightness(1.08);
}

.chapter-tab.is-active {
  color: #fff6d0;
  border-color: #ffe18a;
  background:
    radial-gradient(circle at 88% 18%, rgba(255, 211, 93, 0.24), transparent 34%),
    linear-gradient(180deg, #a82921, #5d100e 58%, #270b09);
  box-shadow:
    inset 0 0 0 1px rgba(255, 245, 188, 0.2),
    0 0 16px rgba(255, 183, 53, 0.34);
}

.chapter-tab.is-active span {
  color: #fff0af;
}

.chapter-tab:disabled,
.quest-stage-card:disabled,
.unit-level-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.quest-book {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 0.74fr);
  gap: 16px;
  min-height: 720px;
  padding: clamp(16px, 2vw, 28px);
  border: 2px solid rgba(126, 78, 27, 0.9);
  border-radius: 10px;
  color: #321d10;
  background:
    linear-gradient(90deg, rgba(88, 46, 14, 0.16), transparent 48%, rgba(88, 46, 14, 0.2) 52%, transparent),
    linear-gradient(180deg, #f8e7c2, #ddbd82);
  box-shadow:
    inset 0 0 0 2px rgba(255, 247, 219, 0.38),
    0 18px 50px rgba(0, 0, 0, 0.46);
}

.quest-page,
.quest-detail,
.formation-owned,
.formation-board,
.formation-detail,
.unit-library,
.unit-showcase,
.unit-info-panel {
  border: 1px solid rgba(118, 74, 24, 0.48);
  border-radius: 8px;
  background: rgba(255, 248, 225, 0.42);
  box-shadow: inset 0 0 34px rgba(110, 63, 18, 0.12);
}

.quest-page,
.quest-detail {
  padding: clamp(14px, 2vw, 22px);
}

.quest-page .hub-kicker,
.quest-detail .hub-kicker {
  color: #8b421a;
}

.quest-page h2,
.quest-detail h3 {
  color: #3a1d0d;
  text-shadow: none;
}

.quest-page p,
.quest-detail p {
  color: #5d3518;
  text-shadow: none;
}

.quest-card-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.quest-stage-card {
  position: relative;
  display: grid;
  align-content: end;
  min-height: 340px;
  padding: 12px;
  overflow: hidden;
  color: #fff2c5;
  text-align: left;
  isolation: isolate;
}

.quest-stage-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, transparent 32%, rgba(18, 9, 6, 0.9) 100%),
    var(--stage-image) center/cover no-repeat;
  filter: saturate(0.95);
}

.quest-stage-card::after {
  content: "";
  position: absolute;
  inset: 8px;
  z-index: -1;
  border: 1px solid rgba(255, 227, 142, 0.48);
  border-radius: 5px;
}

.quest-stage-card.is-locked::before {
  filter: grayscale(1) brightness(0.48);
}

.quest-stage-no,
.quest-status {
  justify-self: start;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  border: 1px solid rgba(245, 196, 90, 0.58);
  font-size: 0.82rem;
  font-weight: 900;
}

.quest-stage-card strong {
  margin-top: 8px;
  font-size: 1.08rem;
  line-height: 1.25;
}

.quest-stage-card small {
  min-height: 3.4em;
  color: #f0d89d;
  line-height: 1.45;
}

.quest-status,
.quest-stars {
  margin-top: 8px;
  color: #ffe186;
}

.quest-preview {
  width: 100%;
  aspect-ratio: 16 / 8.3;
  margin: 12px 0;
  border: 2px solid rgba(104, 61, 19, 0.8);
  border-radius: 7px;
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 34px rgba(0, 0, 0, 0.38);
}

.quest-conditions,
.formation-detail dl,
.unit-info-panel dl {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.quest-conditions div,
.formation-detail dl div,
.unit-info-panel dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(47, 28, 14, 0.12);
}

.quest-conditions dt,
.formation-detail dt,
.unit-info-panel dt {
  color: #7f421d;
  font-weight: 900;
}

.quest-conditions dd,
.formation-detail dd,
.unit-info-panel dd {
  margin: 0;
  color: #271509;
  font-weight: 900;
}

.unit-exp-meter {
  display: grid;
  gap: 6px;
  max-width: 360px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(245, 196, 90, 0.62);
  border-radius: 7px;
  background: rgba(20, 11, 8, 0.62);
  color: #fff2bd;
  box-shadow: inset 0 0 18px rgba(255, 196, 77, 0.08);
}

.unit-exp-meter span,
.unit-exp-meter small {
  font-weight: 900;
}

.unit-exp-meter i {
  display: block;
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(245, 196, 90, 0.64);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.48);
}

.unit-exp-meter i::before {
  content: "";
  display: block;
  width: var(--exp);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #54d46a, #fff075);
  box-shadow: 0 0 12px rgba(255, 236, 117, 0.72);
}

.save-slot-screen {
  display: grid;
  grid-template-columns: minmax(280px, 0.38fr) minmax(0, 1fr);
  gap: clamp(14px, 2.2vw, 28px);
  min-height: min(80vh, 820px);
  padding: clamp(18px, 2.6vw, 34px);
  overflow: hidden;
  border: 2px solid rgba(245, 196, 90, 0.74);
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 222, 115, 0.18), transparent 18rem),
    radial-gradient(circle at 76% 52%, rgba(255, 72, 56, 0.14), transparent 20rem),
    linear-gradient(90deg, rgba(18, 10, 8, 0.48), rgba(18, 10, 8, 0.72)),
    url("assets/hub-home-room.png") center/cover no-repeat;
  box-shadow:
    inset 0 0 90px rgba(0, 0, 0, 0.52),
    0 18px 48px rgba(0, 0, 0, 0.42);
}

.save-slot-intro,
.save-slot-panel {
  border: 1px solid rgba(245, 196, 90, 0.58);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(39, 20, 12, 0.88), rgba(10, 7, 6, 0.9));
  box-shadow:
    inset 0 0 34px rgba(255, 203, 78, 0.08),
    0 14px 28px rgba(0, 0, 0, 0.34);
}

.save-slot-intro {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: clamp(18px, 2.6vw, 30px);
}

.save-slot-intro h2 {
  margin: 0;
  color: #fff6d4;
  font-size: clamp(2rem, 3.8vw, 3.6rem);
  line-height: 1.05;
  text-shadow: 0 2px 0 #2a0d09, 0 0 18px rgba(0, 0, 0, 0.72);
}

.save-slot-intro p {
  margin: 0;
  color: #f8e4b4;
  font-weight: 800;
  line-height: 1.75;
}

.save-slot-back {
  justify-self: start;
  margin-top: 8px;
}

.save-slot-panel {
  padding: clamp(14px, 2vw, 24px);
}

.save-slot-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 1.7vw, 20px);
  margin-top: 14px;
}

.save-slot-card {
  position: relative;
  display: grid;
  gap: 12px;
  min-height: 286px;
  padding: 16px;
  border: 2px solid rgba(245, 196, 90, 0.62);
  border-radius: 8px;
  color: #fff0be;
  background:
    linear-gradient(135deg, rgba(255, 230, 120, 0.13), transparent 36%),
    linear-gradient(180deg, rgba(64, 31, 17, 0.95), rgba(13, 9, 8, 0.98));
  box-shadow:
    inset 0 0 0 1px rgba(255, 244, 190, 0.11),
    0 12px 24px rgba(0, 0, 0, 0.32);
}

.save-slot-card.is-auto {
  border-color: rgba(126, 226, 126, 0.55);
}

.save-slot-card.is-empty {
  background:
    linear-gradient(180deg, rgba(45, 35, 28, 0.82), rgba(11, 9, 8, 0.92));
}

.save-slot-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.save-slot-card-head h3 {
  margin: 0;
  color: #fff6d4;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
}

.save-slot-card-head span {
  flex: 0 0 auto;
  padding: 4px 9px;
  color: #271509;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe29a, #b36a20);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.save-slot-card dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.save-slot-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 235, 168, 0.08);
}

.save-slot-card dt {
  color: #dcb86d;
  font-weight: 900;
}

.save-slot-card dd {
  max-width: 62%;
  margin: 0;
  overflow: hidden;
  color: #fff5d0;
  font-weight: 900;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-slot-action {
  align-self: end;
  width: 100%;
}

.save-slot-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  filter: grayscale(0.35);
}

.gacha-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(560px, 1fr) minmax(410px, 0.54fr);
  gap: clamp(24px, 3.4vw, 58px);
  min-height: min(80vh, 820px);
  padding: clamp(30px, 3.6vw, 58px);
  overflow: hidden;
  border: 2px solid rgba(245, 196, 90, 0.74);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 244, 170, 0.34), transparent 16rem),
    radial-gradient(circle at 78% 50%, rgba(255, 180, 70, 0.2), transparent 22rem),
    linear-gradient(90deg, rgba(44, 21, 5, 0.1), rgba(14, 8, 3, 0.22)),
    url("assets/gacha-board-bg.png") center/cover no-repeat;
  box-shadow:
    inset 0 0 90px rgba(0, 0, 0, 0.38),
    0 18px 46px rgba(0, 0, 0, 0.34);
}

.gacha-layout::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 235, 152, 0.08), transparent 28%),
    radial-gradient(circle at 8% 92%, rgba(255, 201, 85, 0.15), transparent 16rem),
    radial-gradient(circle at 50% 52%, transparent 48%, rgba(0, 0, 0, 0.18));
}

.gacha-board {
  position: relative;
  z-index: 1;
  min-height: 760px;
}

.gacha-title-plate {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-grid;
  place-items: center;
  min-width: 280px;
  min-height: 92px;
  padding: 10px 44px 14px;
  color: #fff4bf;
  border: 2px solid rgba(245, 196, 90, 0.78);
  border-radius: 10px 10px 4px 4px;
  background:
    linear-gradient(135deg, rgba(255, 230, 141, 0.16), transparent 28%),
    linear-gradient(180deg, #7f2b1d, #2d0e08);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.42),
    inset 0 0 22px rgba(255, 214, 124, 0.2);
  font-size: clamp(2.5rem, 4.5vw, 4.9rem);
  font-weight: 900;
  text-shadow: 0 2px 0 #2a0e08, 0 0 14px rgba(255, 222, 132, 0.42);
}

.gacha-title-plate::before,
.gacha-title-plate::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e8bd54;
  box-shadow:
    -11px 7px 0 -4px #e8bd54,
    11px 7px 0 -4px #e8bd54,
    0 15px 0 -4px #e8bd54;
  transform: translateY(-50%);
}

.gacha-title-plate::before {
  left: 18px;
}

.gacha-title-plate::after {
  right: 18px;
}

.gacha-note {
  position: absolute;
  left: 31%;
  top: 8%;
  display: block;
  width: min(60%, 570px);
  padding: 0;
  transform: rotate(-1.4deg);
  filter: drop-shadow(0 24px 24px rgba(0, 0, 0, 0.34));
}

.gacha-note-image {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}

.gacha-note::before,
.gacha-note::after,
.gacha-note-pin {
  content: "";
  position: absolute;
  display: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe7a1, #9a5d1e 72%);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.gacha-note::before {
  left: 18px;
  top: 18px;
}

.gacha-note::after {
  right: 18px;
  bottom: 18px;
}

.gacha-note-pin.pin-top-right {
  right: 18px;
  top: 18px;
}

.gacha-note-pin.pin-bottom-left {
  left: 18px;
  bottom: 18px;
}

.gacha-note p {
  margin: 0;
  font-family: "Yuji Syuku", "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(2.05rem, 3.7vw, 4.3rem);
  font-weight: 900;
  line-height: 1.18;
  letter-spacing: 0.02em;
}

.gacha-note small {
  margin-top: 14px;
  font-size: clamp(1rem, 1.55vw, 1.45rem);
  font-weight: 900;
}

.gacha-doodles {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 38px;
  width: 100%;
  margin-top: 18px;
  color: #6b4420;
  font-weight: 900;
}

.doodle-shield,
.doodle-flag,
.doodle-paw {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 34px;
}

.doodle-shield {
  border: 4px solid #2c74a6;
  border-top-width: 3px;
  border-radius: 5px 5px 16px 16px;
  transform: rotate(-8deg);
}

.doodle-shield::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  width: 2px;
  height: 25px;
  background: #2c74a6;
  transform: translateX(-50%);
}

.doodle-flag::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 3px;
  width: 4px;
  height: 28px;
  background: #73451b;
}

.doodle-flag::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 4px;
  width: 22px;
  height: 14px;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  background: #c53623;
}

.doodle-paw::before {
  content: "";
  position: absolute;
  left: 10px;
  bottom: 4px;
  width: 16px;
  height: 14px;
  border-radius: 50% 50% 48% 48%;
  background: #765025;
  box-shadow:
    -10px -10px 0 -4px #765025,
    0 -14px 0 -4px #765025,
    10px -10px 0 -4px #765025,
    14px -1px 0 -6px #765025;
}

.gacha-home-button {
  position: absolute;
  left: 0;
  bottom: 0;
  min-width: 230px;
}

.gacha-panel {
  align-self: center;
  justify-self: end;
  position: relative;
  z-index: 1;
  display: grid;
  gap: 24px;
  width: min(520px, 100%);
  padding: clamp(28px, 3.2vw, 46px);
  color: #2a170a;
  border: 4px solid rgba(190, 122, 45, 0.9);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.7), transparent 11rem),
    linear-gradient(180deg, rgba(255, 249, 216, 0.96), rgba(239, 206, 154, 0.97));
  box-shadow:
    0 26px 48px rgba(0, 0, 0, 0.44),
    0 0 24px rgba(255, 220, 124, 0.28),
    inset 0 0 42px rgba(151, 77, 20, 0.2);
}

.gacha-panel::before {
  content: "";
  position: absolute;
  inset: 12px;
  pointer-events: none;
  border: 1px solid rgba(157, 96, 31, 0.26);
  border-radius: 16px;
}

.gacha-ribbon {
  position: relative;
  justify-self: center;
  min-width: 84%;
  padding: 14px 22px;
  color: #ffe9a6;
  text-align: center;
  border: 2px solid rgba(255, 220, 132, 0.82);
  border-radius: 18px 18px 30px 30px;
  background:
    linear-gradient(180deg, rgba(255, 229, 143, 0.16), transparent 34%),
    linear-gradient(180deg, #a33423, #60130f);
  box-shadow:
    0 10px 18px rgba(0, 0, 0, 0.26),
    inset 0 0 22px rgba(255, 220, 132, 0.18);
  font-size: clamp(1.35rem, 2.1vw, 2rem);
  font-weight: 900;
}

.gacha-ribbon::before,
.gacha-ribbon::after {
  content: "";
  position: absolute;
  bottom: -10px;
  width: 46px;
  height: 28px;
  background: linear-gradient(180deg, #812018, #4e0d0b);
  clip-path: polygon(0 0, 100% 0, 76% 50%, 100% 100%, 0 100%);
  z-index: -1;
}

.gacha-ribbon::before {
  left: -30px;
}

.gacha-ribbon::after {
  right: -30px;
  transform: scaleX(-1);
}

.gacha-panel p {
  margin: 0;
  text-align: center;
  font-size: clamp(1rem, 1.4vw, 1.28rem);
  font-weight: 900;
  line-height: 1.8;
}

.gacha-cost {
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 22px 20px;
  border: 2px solid rgba(126, 78, 27, 0.48);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 250, 227, 0.72), rgba(246, 224, 181, 0.58));
  box-shadow: inset 0 0 22px rgba(136, 83, 23, 0.1);
}

.gacha-cost strong::before {
  content: "";
  flex: 0 0 auto;
  display: inline-block;
  width: clamp(36px, 4.2vw, 52px);
  height: clamp(36px, 4.2vw, 52px);
  border-radius: 50%;
  border: 2px solid #6e3d11;
  background:
    radial-gradient(circle at 50% 47%, #5f340e 0 22%, transparent 23%),
    radial-gradient(circle at 36% 32%, #5f340e 0 10%, transparent 11%),
    radial-gradient(circle at 50% 24%, #5f340e 0 10%, transparent 11%),
    radial-gradient(circle at 64% 32%, #5f340e 0 10%, transparent 11%),
    radial-gradient(circle at 42% 66%, #5f340e 0 8%, transparent 9%),
    linear-gradient(135deg, #ffe295, #b8781c 64%, #6d3b0e);
  box-shadow: inset 0 0 12px rgba(255, 239, 164, 0.76), 0 2px 5px rgba(0, 0, 0, 0.28);
}

.gacha-cost span {
  color: #7b4c1c;
  font-weight: 900;
}

.gacha-cost strong {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  white-space: nowrap;
  font-size: clamp(1.65rem, 2.7vw, 2.8rem);
}

.gacha-pull-button {
  position: relative;
  min-height: 88px;
  cursor: pointer;
  color: #fff6d0;
  border: 2px solid #ffd986;
  border-radius: 10px;
  background: linear-gradient(180deg, #ef4b32, #a11210 62%, #4a0707);
  box-shadow: 0 12px 18px rgba(0, 0, 0, 0.32), inset 0 0 18px rgba(255, 220, 132, 0.22);
  font-size: clamp(2rem, 4vw, 4rem);
  font-weight: 900;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.gacha-pull-button::before,
.gacha-pull-button::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f3c45c;
  box-shadow:
    -10px 7px 0 -5px #f3c45c,
    10px 7px 0 -5px #f3c45c,
    0 14px 0 -5px #f3c45c;
  transform: translateY(-50%);
}

.gacha-pull-button::before {
  left: 28px;
}

.gacha-pull-button::after {
  right: 28px;
}

.gacha-pull-button:not(:disabled):hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.gacha-pull-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.45);
  opacity: 0.56;
}

.gacha-status {
  display: grid;
  gap: 8px;
  color: #5f3814;
  text-align: center;
  font-weight: 900;
}

.gacha-status strong {
  font-size: 1.05rem;
}

.gacha-status em {
  color: #b3231b;
  font-style: normal;
}

.gacha-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle, rgba(255, 231, 146, 0.22), rgba(4, 2, 1, 0.9) 66%);
}

.gacha-movie-card {
  position: relative;
  width: min(1080px, 96vw);
  height: min(620px, 80vh);
  min-height: min(620px, 80vh);
  overflow: hidden;
  border: 2px solid rgba(245, 196, 90, 0.78);
  border-radius: 12px;
  background: #080503;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.62);
}

.gacha-video {
  display: block;
  width: 100%;
  height: min(620px, 80vh);
  object-fit: cover;
}

.gacha-result-card {
  display: grid;
  place-items: center;
  gap: 12px;
  height: min(620px, 80vh);
  min-height: 0;
  overflow: auto;
  padding: 28px;
  color: #fff4c0;
  text-align: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 226, 121, 0.42), transparent 14rem),
    linear-gradient(180deg, #30120c, #080503);
}

.gacha-result-kicker {
  color: #91ffb0;
  font-size: 1.25rem;
  font-weight: 900;
}

.gacha-result-token {
  width: min(180px, 34vw);
  aspect-ratio: 1;
  border-radius: 18px;
  filter: drop-shadow(0 0 22px var(--unit-color));
}

.gacha-result-card h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.8rem);
  text-shadow: 0 3px 0 #2c0a05, 0 0 20px rgba(245, 196, 90, 0.42);
}

.gacha-result-card p {
  margin: 0 0 10px;
  font-size: clamp(1rem, 2vw, 1.6rem);
  font-weight: 900;
}

.enemy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.hub-enemy-token {
  display: grid;
  place-items: center;
  width: 58px;
  min-height: 70px;
  padding: 4px;
  color: #fff3cf;
  border: 1px solid rgba(245, 196, 90, 0.58);
  border-radius: 6px;
  background: rgba(16, 10, 8, 0.88);
}

.hub-enemy-token i {
  width: 42px;
  height: 42px;
  background-size: 400% 200%;
  background-position: var(--sheet-x) var(--sheet-y);
  background-repeat: no-repeat;
}

.hub-enemy-token small {
  width: 100%;
  overflow: hidden;
  color: #e7d090;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.66rem;
}

.reward-row {
  justify-content: center;
  flex-wrap: wrap;
  margin: 12px 0;
}

.reward-row span {
  padding: 6px 12px;
  color: #fff0bd;
  font-weight: 900;
  border: 1px solid rgba(245, 196, 90, 0.58);
  border-radius: 999px;
  background: rgba(21, 12, 8, 0.86);
}

.formation-layout,
.unit-book-layout {
  display: grid;
  gap: 14px;
}

.formation-layout {
  grid-template-columns: minmax(270px, 0.72fr) minmax(420px, 1.1fr) minmax(270px, 0.56fr);
}

.formation-owned,
.formation-board,
.formation-detail,
.unit-library,
.unit-showcase,
.unit-info-panel {
  padding: 14px;
  color: #fff1c2;
  border-color: rgba(245, 196, 90, 0.58);
  background: linear-gradient(180deg, rgba(33, 20, 11, 0.92), rgba(10, 8, 7, 0.96));
}

.hub-section-title {
  justify-content: space-between;
  margin-bottom: 12px;
}

.hub-section-title h2 {
  margin: 0;
  color: #fff7d7;
  font-size: clamp(1.15rem, 2vw, 1.8rem);
}

.formation-unit-grid,
.unit-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.formation-unit-card,
.unit-library-card {
  display: grid;
  justify-items: start;
  gap: 5px;
  min-height: 150px;
  padding: 10px;
  text-align: left;
}

.formation-unit-card .unit-token,
.unit-library-card .unit-token {
  width: 58px;
  height: 58px;
}

.formation-unit-card strong,
.unit-library-card strong {
  max-width: 100%;
  overflow: hidden;
  color: #fff7d7;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formation-unit-card small,
.unit-library-card small {
  max-width: 100%;
  overflow: hidden;
  color: #e5cb8c;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.formation-ring {
  display: grid;
  grid-template-columns: repeat(5, minmax(86px, 1fr));
  gap: 12px;
  min-height: 440px;
  padding: clamp(14px, 2vw, 24px);
  border: 1px solid rgba(245, 196, 90, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 203, 76, 0.16), transparent 32%),
    radial-gradient(circle, transparent 52%, rgba(245, 196, 90, 0.16) 53%, transparent 54%);
}

.formation-slot {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  min-height: 118px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--unit-color, var(--gold)), transparent 32%);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.42);
}

.formation-slot > span {
  position: absolute;
  left: 6px;
  top: 4px;
  color: var(--gold-bright);
  font-weight: 900;
}

.formation-slot .unit-token {
  width: 58px;
  height: 58px;
}

.formation-slot strong {
  width: 100%;
  overflow: hidden;
  color: #fff7d7;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.formation-slot.is-empty {
  border-style: dashed;
  border-color: rgba(245, 196, 90, 0.34);
}

.formation-actions {
  justify-content: center;
  margin-top: 12px;
}

.formation-detail-art,
.unit-showcase-art {
  width: min(210px, 70%);
  height: auto;
  aspect-ratio: 1;
  margin: 0 auto 12px;
  border-radius: 14px;
}

.formation-detail h3 {
  margin: 0 0 12px;
  color: #fff7d7;
  text-align: center;
  font-size: 1.5rem;
}

.formation-detail dt,
.unit-info-panel dt {
  color: #e4c985;
}

.formation-detail dd,
.unit-info-panel dd {
  color: #fff6d4;
}

.unit-book-layout {
  grid-template-columns: minmax(280px, 0.62fr) minmax(360px, 1fr) minmax(300px, 0.64fr);
}

.unit-showcase {
  display: grid;
  grid-template-columns: minmax(170px, 0.46fr) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.unit-showcase-art {
  width: min(320px, 100%);
  border-radius: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 50;
  transform: translate(-50%, 16px);
  min-width: min(420px, calc(100vw - 32px));
  padding: 12px 18px;
  color: #fff4cf;
  text-align: center;
  font-weight: 900;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: rgba(30, 16, 10, 0.96);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.ui-fx-layer {
  position: fixed;
  inset: 0;
  z-index: 120;
  overflow: hidden;
  pointer-events: none;
}

.ui-click-burst {
  --fx-color: #ffd86e;
  position: absolute;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

.ui-click-burst::before,
.ui-click-burst::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.ui-click-burst::before {
  border: 2px solid var(--fx-color);
  box-shadow: 0 0 7px var(--fx-color), inset 0 0 7px var(--fx-color);
  animation: uiBurstRing 0.58s cubic-bezier(0.12, 0.7, 0.24, 1) forwards;
}

.ui-click-burst::after {
  inset: 36%;
  background: #fff7c7;
  box-shadow: 0 0 12px 5px var(--fx-color);
  animation: uiBurstCore 0.42s ease-out forwards;
}

.ui-click-burst.is-orb {
  width: 58px;
  height: 58px;
}

.ui-click-burst i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff9d8, var(--fx-color), transparent);
  box-shadow: 0 0 7px var(--fx-color);
  transform: translate(-50%, -50%) rotate(var(--spark-angle)) translateY(-15px) scaleY(0.55);
  transform-origin: 50% 50%;
  animation: uiBurstSpark 0.56s var(--spark-delay) cubic-bezier(0.12, 0.66, 0.22, 1) forwards;
}

button.is-pressing:not(.home-orbit-button):not(.audio-toggle) {
  animation: uiButtonTap 0.3s cubic-bezier(0.2, 0.82, 0.3, 1);
}

@keyframes homeOrbActivate {
  0% { transform: scale(1); filter: saturate(1.08) drop-shadow(0 0 6px var(--orb-glow)); }
  44% { transform: scale(0.92); filter: brightness(1.34) saturate(1.35) drop-shadow(0 0 20px var(--orb-glow)); }
  100% { transform: scale(1.05); filter: brightness(1.12) saturate(1.18) drop-shadow(0 0 13px var(--orb-glow)); }
}

@keyframes uiButtonTap {
  0% { transform: translateY(0) scale(1); filter: brightness(1); }
  46% { transform: translateY(2px) scale(0.975); filter: brightness(1.32) saturate(1.16); }
  100% { transform: translateY(0) scale(1); filter: brightness(1); }
}

@keyframes uiBurstRing {
  0% { opacity: 0; transform: scale(0.3); }
  28% { opacity: 1; }
  100% { opacity: 0; transform: scale(2.45); }
}

@keyframes uiBurstCore {
  0% { opacity: 0; transform: scale(0.25); }
  36% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(0.2); }
}

@keyframes uiBurstSpark {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--spark-angle)) translateY(-12px) scaleY(0.35); }
  24% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--spark-angle)) translateY(-54px) scaleY(0); }
}

@keyframes hubScreenEnter {
  0% { opacity: 0; transform: translateY(12px) scale(0.992); filter: brightness(1.18); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: brightness(1); }
}

@keyframes hubViewOut {
  to { opacity: 0; filter: brightness(1.2) blur(2px); transform: scale(0.995); }
}

@keyframes hubViewIn {
  from { opacity: 0; filter: brightness(1.15) blur(2px); transform: scale(1.008); }
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.result-pop {
  position: fixed;
  inset: 0;
  z-index: 72;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 28px);
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 236, 163, 0.18), transparent 42%),
    rgba(10, 5, 4, 0.62);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.result-pop.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  cursor: pointer;
}

.result-pop::before {
  content: "";
  position: absolute;
  width: min(78vw, 760px);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 236, 145, 0.28), transparent 64%),
    conic-gradient(from 0deg, transparent, rgba(255, 236, 145, 0.34), transparent, rgba(255, 255, 255, 0.2), transparent);
  filter: blur(1px);
  opacity: 0;
}

.result-pop.is-visible::before {
  animation: resultAura 2.8s linear infinite;
}

.result-pop__card {
  position: relative;
  width: min(92vw, 1040px);
  filter:
    drop-shadow(0 18px 34px rgba(0, 0, 0, 0.58))
    drop-shadow(0 0 24px rgba(255, 218, 106, 0.2));
}

.result-pop.is-visible .result-pop__card {
  animation:
    resultBounceIn 0.72s cubic-bezier(0.18, 1.34, 0.38, 1) both,
    resultIdleBounce 2.15s ease-in-out 0.74s infinite;
}

.result-pop__image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: min(2vw, 18px);
  user-select: none;
}

.result-pop.is-fail::before {
  background:
    radial-gradient(circle, rgba(115, 99, 105, 0.42), transparent 64%),
    conic-gradient(from 0deg, transparent, rgba(180, 150, 158, 0.3), transparent, rgba(255, 255, 255, 0.16), transparent);
}

@keyframes resultAura {
  0% {
    opacity: 0.76;
    transform: scale(0.94) rotate(0deg);
  }
  50% { opacity: 0.38; }
  100% { opacity: 0.76; transform: scale(1.02) rotate(360deg); }
}

@keyframes resultBounceIn {
  0% {
    opacity: 0;
    transform: translateY(-34px) scale(0.58) rotate(-4deg);
  }
  46% {
    opacity: 1;
    transform: translateY(16px) scale(1.12) rotate(2deg);
  }
  66% {
    transform: translateY(-8px) scale(0.96) rotate(-1deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

@keyframes resultIdleBounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% { transform: translateY(-8px) scale(1.01); }
}

.story-overlay {
  position: fixed;
  inset: 0;
  z-index: 58;
  display: none;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 30% 20%, rgba(155, 44, 35, 0.24), transparent 36%),
    rgba(10, 5, 4, 0.84);
}

.story-overlay.is-open {
  display: grid;
}

.story-overlay::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  background: #000;
  transition: opacity 420ms ease;
}

.story-overlay.is-blackout::after {
  opacity: 1;
}

.story-overlay.is-transitioning .story-card {
  pointer-events: none;
}

body.is-story-blackout .audio-toggle,
body.is-story-blackout .ui-fx-layer {
  opacity: 0;
  pointer-events: none;
}

.story-card {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.72fr);
  gap: 14px;
  width: min(1480px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 14px;
  border: 3px solid var(--gold);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(34, 18, 10, 0.98), rgba(15, 8, 7, 0.99)),
    radial-gradient(circle at 15% 0%, rgba(245, 196, 90, 0.2), transparent 46%);
  box-shadow: var(--shadow);
}

.story-visual {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 2px solid rgba(245, 196, 90, 0.74);
  border-radius: 8px;
  background: #0d0806;
}

.story-visual img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(660px, calc(100dvh - 64px));
  object-fit: cover;
}

.story-visual .story-image-alt {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.story-visual .story-image-alt[hidden] {
  display: none;
}

.story-visual.is-crossfade .story-image-alt {
  animation: storyImageCrossfade 8s ease-in-out forwards;
}

@keyframes storyImageCrossfade {
  0%,
  38% { opacity: 0; }
  58%,
  100% { opacity: 1; }
}

.story-copy {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  min-height: 0;
  padding: 18px;
  color: #3b2110;
  border: 2px solid var(--gold-dark);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 246, 222, 0.98), rgba(231, 193, 125, 0.97)),
    repeating-linear-gradient(0deg, rgba(114, 67, 26, 0.08) 0 1px, transparent 1px 12px);
}

.story-kicker {
  width: fit-content;
  padding: 3px 10px;
  color: #fff0bd;
  font-size: 0.78rem;
  font-weight: 900;
  border-radius: 999px;
  background: linear-gradient(180deg, #9b1d18, #5b120f);
  border: 1px solid rgba(245, 196, 90, 0.7);
}

.story-copy h2 {
  margin: 10px 0 12px;
  color: #7d1513;
  font-size: clamp(1.55rem, 3vw, 2.45rem);
  line-height: 1.12;
}

.story-body {
  min-height: 0;
  overflow: hidden;
  color: #3d2110;
  font-weight: 800;
  line-height: 1.68;
}

.story-body p {
  margin: 0 0 10px;
}

.story-quote {
  display: grid;
  gap: 1px;
  margin: 4px 0 10px;
  padding: 9px 12px;
  color: #7d1513;
  font-weight: 1000;
  line-height: 1.35;
  text-align: center;
  border: 1px solid rgba(125, 21, 19, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.38);
}

.story-quote span {
  display: block;
}

.story-footer {
  color: #7d1513;
}

.story-body ul {
  display: grid;
  gap: 6px;
  margin: 0 0 10px;
  padding-left: 1.2em;
}

.story-range {
  display: inline-block;
  margin: 2px 0 10px;
  padding: 8px 14px;
  color: #2c170b;
  font-size: 1.05rem;
  line-height: 1.24;
  letter-spacing: 0;
  white-space: pre;
  background: rgba(255, 255, 255, 0.44);
  border: 1px solid rgba(114, 67, 26, 0.28);
  border-radius: 6px;
}

.story-progress {
  color: #7a4f24;
  font-size: 0.84rem;
  font-weight: 900;
}

.story-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1.35fr;
  gap: 8px;
  margin-top: 12px;
}

.story-actions .hud-button {
  justify-content: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(11, 6, 4, 0.72);
}

.modal.is-open {
  display: grid;
}

.modal-card {
  width: min(520px, 100%);
  padding: 26px;
  color: #3b2110;
  border: 3px solid var(--gold);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 245, 218, 0.98), rgba(224, 181, 104, 0.96));
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 12px 0 10px;
  color: #7d1513;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
}

.modal-card p {
  margin: 0 0 18px;
  line-height: 1.8;
  font-weight: 800;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

@keyframes fallbackAttack {
  0% {
    transform: translateX(0) scale(1);
    filter: brightness(1);
  }
  38% {
    transform: translateX(9%) scale(1.08);
    filter: brightness(1.16);
  }
  100% {
    transform: translateX(0) scale(1);
    filter: brightness(1);
  }
}

@media (max-width: 1180px) {
  .gacha-layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .gacha-board {
    min-height: 760px;
  }

  .gacha-note {
    left: 50%;
    top: 9%;
    width: min(540px, 82vw);
    padding: 0;
    transform: translateX(-50%) rotate(-1.2deg);
  }

  .gacha-home-button {
    position: absolute;
    left: 0;
    bottom: 0;
  }

  .gacha-panel {
    justify-self: center;
  }

  .hub-topbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .hub-profile,
  .hub-currency {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }

  .hub-resources {
    width: 100%;
    justify-content: center;
  }

  .hub-resources .hub-currency {
    width: auto;
    min-width: min(180px, 46%);
  }

  .quest-layout,
  .quest-book,
  .formation-layout,
  .unit-book-layout,
  .save-slot-screen {
    grid-template-columns: minmax(0, 1fr);
  }

  .chapter-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .chapter-tab {
    min-height: 70px;
    font-size: 1rem;
  }

  .quest-book {
    min-height: auto;
  }

  .formation-ring {
    border-radius: 12px;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .commander-card,
  .tactics-card {
    display: none;
  }

  .story-card {
    grid-template-columns: minmax(0, 1fr);
    max-width: 860px;
  }

  .story-visual img {
    min-height: auto;
    aspect-ratio: 16 / 9;
  }
}

@media (max-width: 820px) {
  .gacha-layout {
    padding: 12px;
  }

  .gacha-board {
    min-height: 720px;
  }

  .gacha-title-plate {
    min-width: 0;
    width: min(100%, 330px);
    min-height: 74px;
    font-size: 2.35rem;
  }

  .gacha-note {
    top: 112px;
    width: min(86vw, 430px);
    min-height: 0;
    padding: 0;
  }

  .gacha-note p {
    font-size: 1.65rem;
  }

  .gacha-panel {
    padding: 18px;
  }

  .gacha-pull-button {
    min-height: 66px;
  }

  .hub-shell {
    width: min(100vw - 10px, 760px);
    margin: 5px auto;
    padding: 8px;
  }

  .hub-topbar {
    gap: 8px;
    padding: 8px;
  }

  .hub-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .hub-nav-button {
    min-width: 0;
    min-height: 42px;
    padding: 6px 8px;
  }

  .home-hero,
  .unit-showcase {
    grid-template-columns: 1fr;
  }

  .home-hero {
    min-height: auto;
  }

  .home-character {
    min-height: 280px;
    background-position: 12% 48%;
    background-size: 260% auto;
  }

  .home-actions {
    padding: 16px;
  }

  .home-action-grid,
  .chapter-list,
  .quest-card-row {
    grid-template-columns: 1fr;
  }

  .hub-status-band {
    display: grid;
  }

  .hub-status-band div {
    min-width: 0;
  }

  .save-slot-screen {
    padding: 10px;
  }

  .save-slot-list {
    grid-template-columns: 1fr;
  }

  .save-slot-card {
    min-height: 0;
  }

  .save-slot-card dl div {
    display: grid;
    gap: 2px;
  }

  .save-slot-card dd {
    max-width: 100%;
    text-align: left;
  }

  .quest-book {
    padding: 10px;
  }

  .quest-stage-card {
    min-height: 230px;
  }

  .formation-unit-grid,
  .unit-library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .formation-unit-card,
  .unit-library-card {
    min-height: 132px;
  }

  .formation-ring {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: auto;
  }

  .formation-actions {
    display: grid;
  }

  .title-screen {
    align-items: end;
    padding: 18px;
    background-position: 38% center;
  }

  .title-screen::before {
    inset: 8px;
  }

  .title-overlay {
    width: 100%;
    margin: 0 auto 46px;
    padding: 0;
    text-align: center;
  }

  .title-screen h1 {
    margin-bottom: 24px;
    font-size: clamp(2rem, 9vw, 3rem);
  }

  .title-menu {
    margin: 0 auto;
  }

  .title-button {
    min-height: 58px;
  }

  .app-shell {
    width: min(100vw - 12px, 760px);
    padding-top: 6px;
  }

  .app-header {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .hero-ribbon {
    display: none;
  }

  h1 {
    font-size: clamp(2rem, 10vw, 3.6rem);
  }

  .title-block {
    padding-right: 74px;
  }

  .chapter-mark {
    width: 62px;
    height: 84px;
    right: 10px;
    font-size: 1.25rem;
  }

  .battle-card {
    padding: 10px;
  }

  .story-overlay {
    padding: 8px;
  }

  .story-card {
    width: min(100vw - 12px, 760px);
    gap: 8px;
    padding: 8px;
    max-height: calc(100dvh - 12px);
  }

  .story-copy {
    padding: 12px;
  }

  .story-copy h2 {
    margin-bottom: 8px;
  }

  .story-body {
    font-size: 0.92rem;
    line-height: 1.5;
  }

  .story-body p {
    margin-bottom: 7px;
  }

  .story-actions {
    grid-template-columns: 1fr 1fr 1.2fr;
  }

  .route-arrow {
    display: none;
  }

  .lower-dock {
    grid-template-columns: 1fr;
  }

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

  .unit-card {
    min-height: 70px;
  }

  .battle-hud {
    gap: 6px;
  }

  .stat-pill,
  .hud-button {
    min-height: 40px;
  }
}

.hub-topbar.is-home {
  position: relative;
  z-index: 3;
  max-width: 100%;
  margin-bottom: -92px;
  border-color: rgba(255, 222, 139, 0.86);
  background:
    linear-gradient(180deg, rgba(37, 22, 13, 0.72), rgba(9, 7, 6, 0.66));
  backdrop-filter: blur(2px);
}

.home-v2 {
  gap: 8px;
}

.home-scene {
  position: relative;
  min-height: min(78vh, 780px);
  overflow: hidden;
  border: 2px solid rgba(245, 196, 90, 0.8);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(10, 6, 5, 0.06) 0%, rgba(10, 6, 5, 0.08) 40%, rgba(10, 6, 5, 0.36) 100%),
    url("assets/hub-home-room.png") center/cover no-repeat;
  box-shadow:
    inset 0 0 80px rgba(0, 0, 0, 0.42),
    0 18px 48px rgba(0, 0, 0, 0.46);
}

.home-standee {
  position: absolute;
  left: clamp(-12px, 2vw, 46px);
  bottom: -24px;
  z-index: 2;
  width: min(40vw, 520px);
  height: min(70vh, 650px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  filter:
    drop-shadow(0 22px 22px rgba(0, 0, 0, 0.66))
    drop-shadow(0 0 18px color-mix(in srgb, var(--unit-color), transparent 42%));
  pointer-events: none;
}

.home-standee::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 7%;
  z-index: -1;
  width: 82%;
  height: 44%;
  border-radius: 50%;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--unit-color), transparent 62%), transparent 68%);
  transform: translateX(-50%);
}

.home-standee img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.home-standee.is-riku {
  left: clamp(18px, 4vw, 72px);
  width: min(34vw, 440px);
}

.home-nameplate {
  position: absolute;
  left: clamp(14px, 2vw, 30px);
  top: 112px;
  z-index: 4;
  display: none;
  align-items: center;
  gap: 10px;
  min-width: min(360px, 42vw);
  padding: 10px 14px;
  border: 2px solid rgba(245, 196, 90, 0.76);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(117, 26, 21, 0.92), rgba(32, 16, 10, 0.88));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.38);
}

.home-nameplate .unit-token {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
}

.home-nameplate strong {
  display: block;
  max-width: 240px;
  overflow: hidden;
  color: #fff7d7;
  font-size: clamp(1.05rem, 2vw, 1.5rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-nameplate small {
  display: block;
  max-width: 250px;
  overflow: hidden;
  color: #f3d891;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.home-picker {
  position: absolute;
  left: clamp(12px, 2vw, 30px);
  bottom: 18px;
  z-index: 5;
  width: min(560px, 48vw);
  padding: 10px;
  border: 1px solid rgba(245, 196, 90, 0.62);
  border-radius: 8px;
  background: rgba(10, 7, 6, 0.68);
  backdrop-filter: blur(2px);
}

.home-picker > span {
  display: block;
  margin-bottom: 8px;
  color: var(--gold-bright);
  font-weight: 900;
}

.home-picker > div {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.home-picker-button {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  padding: 6px 4px;
  cursor: pointer;
  color: #fff1c4;
  border: 1px solid rgba(245, 196, 90, 0.46);
  border-radius: 7px;
  background: rgba(18, 12, 8, 0.82);
}

.home-picker-button.is-selected {
  border-color: var(--unit-color);
  box-shadow: 0 0 16px color-mix(in srgb, var(--unit-color), transparent 38%);
}

.home-picker-button .unit-token {
  width: 44px;
  height: 44px;
}

.home-picker-button small {
  max-width: 100%;
  overflow: hidden;
  color: #f6deb0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.68rem;
  font-weight: 900;
}

.home-orbit {
  position: absolute;
  right: clamp(18px, 5vw, 92px);
  top: 50%;
  z-index: 3;
  width: min(48vw, 660px);
  aspect-ratio: 1;
  transform: translateY(-49%);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 221, 111, 0.22) 0 12%, transparent 13%),
    repeating-radial-gradient(circle, transparent 0 16%, rgba(255, 213, 103, 0.22) 16.4% 16.8%, transparent 17.2% 27%),
    conic-gradient(from 12deg, transparent, rgba(255, 210, 81, 0.34), transparent 19%, rgba(255, 240, 165, 0.22), transparent 38%, rgba(255, 210, 81, 0.3), transparent);
  filter: drop-shadow(0 0 18px rgba(255, 203, 76, 0.5));
}

.home-orbit::before,
.home-orbit::after {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  border: 1px solid rgba(255, 224, 129, 0.42);
}

.home-orbit::after {
  inset: 20%;
  border-color: rgba(255, 242, 170, 0.32);
}

.home-orbit-core {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 25%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  color: #fff1b0;
  font-weight: 900;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 230, 123, 0.98), rgba(176, 96, 20, 0.34) 54%, rgba(0, 0, 0, 0.28) 70%);
  box-shadow:
    0 0 30px rgba(255, 214, 84, 0.88),
    inset 0 0 22px rgba(255, 255, 255, 0.22);
}

.home-orbit-core::before {
  content: "●";
  position: absolute;
  color: rgba(255, 238, 158, 0.7);
  font-size: min(8vw, 86px);
  text-shadow:
    -26px -24px 0 rgba(255, 238, 158, 0.62),
    0 -34px 0 rgba(255, 238, 158, 0.62),
    26px -24px 0 rgba(255, 238, 158, 0.62),
    -16px 20px 0 rgba(255, 238, 158, 0.62),
    16px 20px 0 rgba(255, 238, 158, 0.62);
}

.home-orbit-core span {
  position: relative;
  z-index: 1;
  opacity: 0;
}

.home-orbit-button {
  --orb-glow: rgba(255, 211, 102, 0.62);
  position: absolute;
  z-index: 4;
  width: min(15.5vw, 174px);
  aspect-ratio: 1;
  padding: 0;
  cursor: pointer;
  color: #fff1c4;
  border: 0;
  border-radius: 50%;
  background: transparent;
  filter: drop-shadow(0 11px 8px rgba(0, 0, 0, 0.64));
  transition: transform 0.2s cubic-bezier(0.2, 0.78, 0.25, 1.25), filter 0.2s ease;
}

.home-orbit-button.is-quest { --orb-glow: rgba(255, 114, 58, 0.72); left: 50%; top: 17%; transform: translate(-50%, -50%); }
.home-orbit-button.is-formation { --orb-glow: rgba(75, 156, 255, 0.72); left: 83%; top: 31%; transform: translate(-50%, -50%); }
.home-orbit-button.is-unit { --orb-glow: rgba(189, 83, 255, 0.72); left: 83%; top: 69%; transform: translate(-50%, -50%); }
.home-orbit-button.is-gacha { --orb-glow: rgba(255, 94, 185, 0.76); left: 50%; top: 83%; transform: translate(-50%, -50%); }
.home-orbit-button.is-save { --orb-glow: rgba(117, 218, 82, 0.72); left: 17%; top: 69%; transform: translate(-50%, -50%); }
.home-orbit-button.is-load { --orb-glow: rgba(129, 112, 255, 0.72); left: 17%; top: 31%; transform: translate(-50%, -50%); }

.home-orbit-button:hover {
  transform: translate(-50%, -50%) scale(1.075) translateY(-3px);
  filter: drop-shadow(0 0 14px var(--orb-glow)) drop-shadow(0 13px 9px rgba(0, 0, 0, 0.62));
}

.home-orbit-button:focus-visible {
  outline: 3px solid #fff0a5;
  outline-offset: 7px;
}

.home-orbit-button.is-pressing {
  transform: translate(-50%, -50%) scale(0.94) translateY(3px);
  filter: drop-shadow(0 0 22px var(--orb-glow));
}

.home-orbit-button strong {
  position: absolute;
  left: 50%;
  bottom: -5%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 84%;
  min-height: 27%;
  padding: 3px 14px 5px;
  border: 1px solid rgba(255, 223, 135, 0.9);
  border-radius: 5px;
  background:
    linear-gradient(90deg, transparent, rgba(255, 222, 128, 0.14) 18% 82%, transparent),
    linear-gradient(180deg, rgba(53, 30, 23, 0.98), rgba(13, 9, 9, 0.98));
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 199, 0.1),
    0 4px 10px rgba(0, 0, 0, 0.72),
    0 0 10px color-mix(in srgb, var(--orb-glow), transparent 36%);
  transform: translateX(-50%);
  font-size: clamp(0.82rem, 1.55vw, 1.22rem);
  line-height: 1;
  text-shadow: 0 2px 0 #140906, 0 0 7px rgba(255, 223, 142, 0.34);
  white-space: nowrap;
}

.home-orbit-button strong::before,
.home-orbit-button strong::after {
  content: "✦";
  position: absolute;
  top: 50%;
  color: #f7cf6a;
  font-size: 0.48em;
  transform: translateY(-50%);
}

.home-orbit-button strong::before { left: 5px; }
.home-orbit-button strong::after { right: 5px; }

.home-orbit-icon {
  position: absolute;
  inset: -7%;
  z-index: 1;
  border-radius: 50%;
  background-image: url("assets/home-menu-orbs-v3-transparent.png");
  background-repeat: no-repeat;
  background-size: 300% 200%;
  filter: saturate(1.08) contrast(1.04) drop-shadow(0 0 6px var(--orb-glow));
  transition: transform 0.2s cubic-bezier(0.2, 0.78, 0.25, 1.25), filter 0.2s ease;
}

.home-orbit-button:hover .home-orbit-icon {
  transform: scale(1.035) translateY(-2px);
  filter: saturate(1.18) brightness(1.12) drop-shadow(0 0 13px var(--orb-glow));
}

.home-orbit-button.is-pressing .home-orbit-icon {
  animation: homeOrbActivate 0.34s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.home-orbit-button.is-quest .home-orbit-icon { background-position: 0 0; }
.home-orbit-button.is-formation .home-orbit-icon { background-position: 50% 0; }
.home-orbit-button.is-unit .home-orbit-icon { background-position: 100% 0; }
.home-orbit-button.is-save .home-orbit-icon { background-position: 0 100%; }
.home-orbit-button.is-load .home-orbit-icon { background-position: 50% 100%; }
.home-orbit-button.is-gacha .home-orbit-icon { background-position: 100% 100%; }

.home-status {
  position: relative;
  z-index: 2;
  margin-top: -2px;
}

.formation-v2 {
  grid-template-columns: minmax(330px, 0.78fr) minmax(560px, 1.08fr) minmax(330px, 0.68fr);
}

.formation-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.formation-toolbar button {
  min-height: 38px;
  cursor: default;
  color: #fff0bd;
  border: 1px solid rgba(245, 196, 90, 0.56);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.34);
  font-weight: 900;
}

.formation-v2 .formation-unit-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.formation-v2 .formation-unit-card {
  min-height: 178px;
  align-content: start;
  padding: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--unit-color), #2b160c 24%), rgba(14, 10, 8, 0.96));
}

.formation-v2 .formation-unit-card.is-detail {
  box-shadow:
    inset 0 0 0 1px rgba(255, 247, 196, 0.2),
    0 0 18px color-mix(in srgb, var(--unit-color), transparent 34%);
}

.formation-card-art.unit-token {
  width: 100%;
  height: 84px;
  border-radius: 6px;
  background-size: 650% auto;
}

.formation-card-art.unit-token.p-6,
.formation-card-art.unit-token.p-7,
.formation-detail-art.unit-token.p-6,
.formation-detail-art.unit-token.p-7,
.unit-showcase-art.unit-token.p-6,
.unit-showcase-art.unit-token.p-7 {
  background-size: cover;
  background-position: center 42%;
}

.formation-stars {
  color: #ffd970;
  letter-spacing: 0;
  font-size: 0.86rem;
}

.formation-v2 .formation-ring {
  position: relative;
  display: block;
  min-height: 610px;
  padding: 0;
  overflow: hidden;
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 202, 71, 0.24) 0 8%, transparent 9% 21%, rgba(255, 202, 71, 0.14) 22% 22.6%, transparent 23% 38%, rgba(255, 202, 71, 0.13) 39% 39.7%, transparent 40%),
    conic-gradient(from 20deg, transparent, rgba(255, 203, 76, 0.22), transparent 20%, rgba(255, 238, 154, 0.16), transparent 42%, rgba(255, 203, 76, 0.2), transparent),
    linear-gradient(180deg, rgba(21, 13, 8, 0.92), rgba(4, 4, 4, 0.96));
}

.formation-v2 .formation-ring::before,
.formation-v2 .formation-ring::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(245, 196, 90, 0.5);
  pointer-events: none;
}

.formation-v2 .formation-ring::after {
  width: 44%;
  border-color: rgba(255, 232, 148, 0.34);
}

.formation-core {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(34%, 210px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  color: rgba(255, 230, 143, 0.7);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 199, 76, 0.18), transparent 62%),
    rgba(0, 0, 0, 0.26);
}

.formation-core::before {
  content: "●";
  position: absolute;
  color: rgba(255, 212, 98, 0.32);
  font-size: min(7vw, 78px);
  text-shadow:
    -24px -20px 0 rgba(255, 212, 98, 0.24),
    0 -30px 0 rgba(255, 212, 98, 0.24),
    24px -20px 0 rgba(255, 212, 98, 0.24),
    -14px 22px 0 rgba(255, 212, 98, 0.24),
    14px 22px 0 rgba(255, 212, 98, 0.24);
}

.formation-core span {
  position: relative;
  z-index: 1;
  font-weight: 900;
}

.formation-v2 .formation-slot {
  position: absolute;
  left: var(--slot-x);
  top: var(--slot-y);
  z-index: 2;
  width: min(16.5%, 122px);
  min-height: 138px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(180deg, rgba(28, 17, 10, 0.9), rgba(5, 4, 4, 0.92));
}

.formation-v2 .formation-slot.is-empty {
  background: rgba(0, 0, 0, 0.36);
}

.formation-v2 .formation-slot .unit-token {
  width: 64px;
  height: 64px;
}

.formation-detail-note {
  margin: 12px 0 0;
  color: #f5ddb3;
  font-weight: 800;
  line-height: 1.65;
}

@media (max-width: 1180px) {
  .hub-topbar.is-home {
    margin-bottom: 8px;
  }

  .home-scene {
    min-height: 720px;
  }

  .home-standee {
    width: min(54vw, 480px);
    height: 560px;
  }

  .home-orbit {
    width: min(68vw, 620px);
    right: 0;
  }

  .formation-v2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .home-scene {
    min-height: 1170px;
  }

  .home-nameplate {
    display: flex;
    top: 16px;
    left: 12px;
    right: 12px;
    min-width: 0;
  }

  .home-standee {
    left: 50%;
    top: 96px;
    bottom: auto;
    width: min(90vw, 420px);
    height: 420px;
    transform: translateX(-50%);
  }

  .home-orbit {
    left: 50%;
    right: auto;
    top: 610px;
    width: min(96vw, 430px);
    transform: translateX(-50%);
  }

  .home-orbit-button {
    width: min(25vw, 108px);
  }

  .home-picker {
    left: 10px;
    right: 10px;
    top: 1008px;
    bottom: auto;
    width: auto;
  }

  .home-picker > div {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .formation-v2 .formation-unit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .formation-v2 .formation-ring {
    min-height: 520px;
  }

  .formation-v2 .formation-slot {
    width: min(24%, 94px);
    min-height: 112px;
  }

  .formation-v2 .formation-slot .unit-token {
    width: 48px;
    height: 48px;
  }
}

/* Crisp home orbit: keep the circular UI sharp instead of layered blurry gradients. */
.home-orbit {
  background:
    url("assets/home-orbit-rings.svg") center/100% 100% no-repeat,
    radial-gradient(circle, rgba(255, 226, 146, 0.065) 0 17%, rgba(113, 78, 142, 0.055) 36%, rgba(32, 20, 48, 0.025) 64%, transparent 76%);
  filter: none;
}

.home-orbit::before {
  display: block;
  inset: 13%;
  z-index: 1;
  border: 0;
  background: conic-gradient(from 18deg, transparent 0 10%, rgba(255, 231, 148, 0.54) 13%, transparent 18% 38%, rgba(143, 218, 255, 0.42) 41%, transparent 46% 69%, rgba(255, 158, 218, 0.4) 72%, transparent 78% 100%);
  mask: radial-gradient(circle, transparent 0 77%, #000 79% 81%, transparent 83%);
  animation: homeOrbitTurn 22s linear infinite;
  pointer-events: none;
}

.home-orbit::after {
  display: block;
  inset: 29%;
  z-index: 1;
  border: 1px solid rgba(255, 235, 166, 0.24);
  box-shadow: 0 0 20px rgba(206, 156, 255, 0.14), inset 0 0 18px rgba(133, 220, 255, 0.1);
  animation: homeOrbitBreathe 3.8s ease-in-out infinite;
  pointer-events: none;
}

.home-orbit-core {
  display: none;
}

@keyframes homeOrbitTurn {
  to { transform: rotate(360deg); }
}

@keyframes homeOrbitBreathe {
  0%, 100% { opacity: 0.55; transform: scale(0.97); }
  50% { opacity: 1; transform: scale(1.03); }
}

/* Battle polish: compact HUD telemetry, readable state changes, and layered impact feedback. */
.hud-mini-gauge {
  width: 58px;
  height: 5px;
  overflow: hidden;
  border: 1px solid rgba(255, 232, 157, 0.5);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
}

.hud-mini-gauge b {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e53b32, #ffcc62 72%, #fff3b5);
  box-shadow: 0 0 8px rgba(255, 200, 87, 0.7);
  transition: width 0.2s ease;
}

.stat-pill.enemy-count strong {
  min-width: 1.5ch;
  color: #ff7e76;
  text-align: center;
}

.stat-pill.is-danger-pulse {
  animation: hudDangerPulse 0.42s ease-out;
}

.stat-pill.is-reward-pulse {
  animation: hudRewardPulse 0.42s ease-out;
}

.stat-pill.is-enemy-pulse {
  animation: hudEnemyPulse 0.36s ease-out;
}

.battle-board::before,
.battle-board::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.battle-board::before {
  background:
    linear-gradient(90deg, rgba(58, 212, 245, 0.16), transparent 9%, transparent 87%, rgba(166, 53, 255, 0.2)),
    repeating-linear-gradient(180deg, transparent 0 19.7%, rgba(255, 235, 168, 0.08) 19.8% 20%);
  box-shadow:
    inset 28px 0 34px rgba(52, 187, 220, 0.13),
    inset -34px 0 40px rgba(118, 42, 207, 0.19);
}

.battle-board::after {
  inset: 1.5%;
  border: 1px solid rgba(255, 224, 135, 0.2);
  border-radius: 5px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.38);
}

.battle-announcer {
  position: absolute;
  left: 50%;
  top: 47%;
  z-index: 24;
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: min(70%, 620px);
  padding: 14px 34px;
  color: #fff5cc;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.76);
  background:
    linear-gradient(90deg, transparent, rgba(20, 10, 7, 0.9) 16%, rgba(47, 19, 9, 0.94) 50%, rgba(20, 10, 7, 0.9) 84%, transparent);
  border-top: 2px solid rgba(255, 220, 112, 0.82);
  border-bottom: 2px solid rgba(255, 220, 112, 0.82);
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.7));
}

.battle-announcer::before,
.battle-announcer::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 11px;
  aspect-ratio: 1;
  transform: translateY(-50%) rotate(45deg);
  background: #ffe48d;
  box-shadow: 0 0 14px #ffba43;
}

.battle-announcer::before {
  left: 9%;
}

.battle-announcer::after {
  right: 9%;
}

.battle-announcer span {
  color: #f3d48a;
  font-size: 0.78rem;
  font-weight: 900;
}

.battle-announcer strong {
  font-size: 2rem;
  line-height: 1.05;
  text-shadow: 0 3px 0 #4b130e, 0 0 18px rgba(255, 192, 60, 0.72);
}

.battle-announcer.is-visible {
  animation: battleBannerIn var(--banner-duration, 1.45s) cubic-bezier(0.18, 0.86, 0.22, 1) both;
}

.battle-announcer.is-warning {
  color: #fff;
  background:
    linear-gradient(90deg, transparent, rgba(68, 4, 8, 0.94) 16%, rgba(127, 8, 12, 0.96) 50%, rgba(68, 4, 8, 0.94) 84%, transparent);
  border-color: #ff6f55;
}

.battle-announcer.is-warning strong {
  color: #fff0d0;
  text-shadow: 0 3px 0 #530507, 0 0 20px #ff321f;
}

.battle-announcer.is-clear {
  color: #fff5b7;
  background:
    linear-gradient(90deg, transparent, rgba(14, 51, 24, 0.92) 16%, rgba(31, 103, 50, 0.95) 50%, rgba(14, 51, 24, 0.92) 84%, transparent);
  border-color: #b9f58e;
}

.pause-curtain {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  place-content: center;
  justify-items: center;
  color: #fff0bb;
  pointer-events: none;
  opacity: 0;
  background: rgba(9, 7, 7, 0.58);
  backdrop-filter: blur(2px) saturate(0.7);
  transition: opacity 0.18s ease;
}

.pause-curtain strong {
  font-size: 2.5rem;
  letter-spacing: 0;
  text-shadow: 0 3px 0 #401510, 0 0 18px rgba(255, 215, 109, 0.52);
}

.pause-curtain small {
  margin-top: 4px;
  color: #ddc995;
  font-weight: 900;
}

body.is-paused .pause-curtain {
  opacity: 1;
  pointer-events: auto;
}

body.is-paused .entity-layer,
body.is-paused .effect-layer {
  filter: brightness(0.78) saturate(0.78);
}

.unit.is-hit .unit-sprite {
  filter: brightness(1.8) saturate(0.35) drop-shadow(0 0 10px #ff4a3f);
}

.enemy.is-hit .enemy-sprite,
.enemy.is-hit .enemy-body {
  filter: brightness(2) saturate(0.28) drop-shadow(0 0 12px #ff3f36);
}

.impact-fx {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 13;
  width: var(--fx-size);
  aspect-ratio: 1;
  pointer-events: none;
  opacity: var(--alpha);
  transform: translate(-50%, -50%) scale(calc(0.45 + var(--progress)));
  border-radius: 50%;
  filter: drop-shadow(0 0 10px var(--color));
}

.impact-fx::before,
.impact-fx::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.impact-fx.is-hit::before,
.impact-fx.is-unit-hit::before {
  background:
    linear-gradient(45deg, transparent 43%, #fff 46% 52%, transparent 55%),
    linear-gradient(-45deg, transparent 43%, var(--color) 46% 52%, transparent 55%);
}

.impact-fx.is-hit::after,
.impact-fx.is-unit-hit::after {
  inset: 28%;
  background: radial-gradient(circle, #fff 0 16%, var(--color) 17% 42%, transparent 44%);
}

.impact-fx.is-deploy::before,
.impact-fx.is-heal::before,
.impact-fx.is-skill::before {
  border: 3px solid var(--color);
  box-shadow:
    inset 0 0 16px var(--color),
    0 0 18px var(--color);
}

.impact-fx.is-deploy::after {
  inset: 19%;
  border: 2px dashed #fff0a8;
}

.impact-fx.is-heal::after {
  content: "+";
  display: grid;
  place-items: center;
  color: #e8ffe1;
  font-size: 2rem;
  font-weight: 900;
  text-shadow: 0 0 12px #6cff83;
}

.impact-fx.is-spawn::before {
  background: conic-gradient(from 15deg, transparent, var(--color), transparent 18%, var(--color), transparent 42%, var(--color), transparent);
}

.impact-fx.is-spawn::after {
  inset: 23%;
  border: 2px solid #df9dff;
  box-shadow: inset 0 0 18px #5b0b8a, 0 0 16px #a229f2;
}

.impact-fx.is-defeat::before,
.impact-fx.is-retreat::before,
.impact-fx.is-breach::before {
  background:
    radial-gradient(circle, #fff 0 7%, var(--color) 9% 17%, transparent 19%),
    repeating-conic-gradient(from 7deg, var(--color) 0 4deg, transparent 5deg 22deg);
}

.impact-fx.is-defeat::after,
.impact-fx.is-retreat::after {
  inset: 20%;
  border: 2px solid var(--color);
}

.impact-fx.is-skill::before {
  border-width: 4px;
  background: repeating-conic-gradient(from 0deg, transparent 0 12deg, color-mix(in srgb, var(--color), white 26%) 13deg 16deg);
}

.impact-fx.is-skill::after {
  inset: 24%;
  border: 2px solid #fff4b4;
  transform: rotate(45deg);
}

.battle-card.shake-soft {
  animation: screenShakeSoft 0.26s ease-out;
}

.battle-card.shake-heavy {
  animation: screenShakeHeavy 0.46s ease-out;
}

.audio-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  cursor: pointer;
  color: #fff4c9;
  font-size: 1.2rem;
  font-weight: 900;
  border: 2px solid rgba(255, 222, 132, 0.86);
  border-radius: 50%;
  background: linear-gradient(180deg, #7e251c, #2a100d);
  box-shadow:
    inset 0 0 0 2px rgba(255, 247, 196, 0.12),
    0 8px 20px rgba(0, 0, 0, 0.48);
}

.audio-toggle:hover {
  filter: brightness(1.13);
}

.audio-toggle.is-muted {
  color: #b7aa91;
  border-color: rgba(193, 170, 119, 0.62);
  background: linear-gradient(180deg, #49352e, #1b1513);
}

button:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid #fff0a2;
  outline-offset: 3px;
}

@keyframes battleBannerIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.06);
  }
  22%,
  76% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.04);
  }
}

@keyframes hudDangerPulse {
  45% {
    color: #fff;
    border-color: #ff4a43;
    box-shadow: 0 0 22px rgba(255, 45, 37, 0.82);
    transform: scale(1.06);
  }
}

@keyframes hudRewardPulse {
  45% {
    border-color: #fff28f;
    box-shadow: 0 0 20px rgba(255, 221, 84, 0.74);
    transform: scale(1.045);
  }
}

@keyframes hudEnemyPulse {
  45% {
    border-color: #c360ff;
    box-shadow: 0 0 18px rgba(166, 61, 255, 0.68);
  }
}

@keyframes screenShakeSoft {
  20% { transform: translateX(-2px); }
  42% { transform: translateX(2px); }
  64% { transform: translateX(-1px); }
}

@keyframes screenShakeHeavy {
  12% { transform: translate(-4px, 1px); }
  26% { transform: translate(4px, -2px); }
  40% { transform: translate(-3px, 2px); }
  56% { transform: translate(3px, 0); }
  72% { transform: translate(-1px, -1px); }
}

@media (max-width: 820px) {
  .hud-mini-gauge {
    width: 42px;
  }

  .battle-announcer {
    min-width: 82%;
    padding: 10px 20px;
  }

  .battle-announcer strong {
    font-size: 1.35rem;
  }

  .battle-announcer span {
    font-size: 0.68rem;
  }

  .pause-curtain strong {
    font-size: 1.8rem;
  }

  .audio-toggle {
    right: 10px;
    bottom: 10px;
    width: 44px;
    height: 44px;
  }
}

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

  .battle-card.shake-soft,
  .battle-card.shake-heavy {
    animation: none;
  }

  .enemy-motion {
    transform: none !important;
  }

  .enemy-ground-shadow {
    transform: none !important;
  }
}
