.chapter-briefing {
  --chapter-overlay: linear-gradient(180deg, rgba(3, 30, 52, 0.08) 0 44%, rgba(3, 23, 42, 0.94) 100%);
  --chapter-position: 50% 50%;
  position: absolute;
  z-index: 35;
  inset: 0;
  overflow: hidden;
  color: white;
  background: #07516f;
}

.chapter-backdrop {
  position: absolute;
  inset: 0;
  background:
    var(--chapter-overlay),
    var(--chapter-scene, url("./assets/scene-coral.webp")) var(--chapter-position) / cover no-repeat;
  transform: scale(1.04);
  filter: saturate(1.04) contrast(1.03);
}

.chapter-briefing[data-theme="sky"] {
  --chapter-overlay: linear-gradient(180deg, rgba(31, 91, 148, 0.04) 0 47%, rgba(7, 28, 60, 0.92) 100%);
  --chapter-position: 54% 50%;
}

.chapter-briefing[data-theme="abyss"] {
  --chapter-overlay: linear-gradient(180deg, rgba(1, 10, 25, 0.16) 0 40%, rgba(1, 13, 29, 0.96) 100%);
  --chapter-position: 56% 50%;
}

.chapter-briefing[data-theme="tempest"] {
  --chapter-overlay: linear-gradient(180deg, rgba(26, 8, 51, 0.12) 0 43%, rgba(10, 4, 27, 0.95) 100%);
  --chapter-position: 55% 50%;
}

.chapter-briefing[data-theme="omega"] {
  --chapter-overlay: linear-gradient(180deg, rgba(25, 2, 16, 0.08) 0 42%, rgba(13, 2, 15, 0.95) 100%);
  --chapter-position: 59% 50%;
}

.chapter-briefing[data-theme="lunar"] {
  --chapter-overlay: linear-gradient(180deg, rgba(74, 91, 157, 0.03) 0 46%, rgba(39, 53, 91, 0.9) 100%);
  --chapter-position: 50% 50%;
}

.chapter-briefing[data-theme="dune"] {
  --chapter-overlay: linear-gradient(180deg, rgba(255, 229, 164, 0.02) 0 46%, rgba(100, 69, 45, 0.88) 100%);
  --chapter-position: 50% 50%;
}

.chapter-briefing[data-theme="citadel"] {
  --chapter-overlay: linear-gradient(180deg, rgba(222, 246, 255, 0.02) 0 46%, rgba(55, 80, 104, 0.86) 100%);
  --chapter-position: 50% 50%;
}

.chapter-number {
  position: absolute;
  z-index: 3;
  top: calc(20px + env(safe-area-inset-top));
  left: 18px;
  padding: 6px 11px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 9px 3px 9px 3px;
  background: rgba(3, 31, 52, 0.58);
  font-size: 9px;
  font-weight: 1000;
  letter-spacing: 0.16em;
  backdrop-filter: blur(7px);
}

.chapter-exit {
  position: absolute;
  z-index: 5;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 0 13px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 14px 5px 14px 5px;
  color: white;
  background: rgba(3, 31, 52, 0.68);
  box-shadow: 0 7px 18px rgba(0, 18, 35, 0.24);
  backdrop-filter: blur(9px);
  cursor: pointer;
}

.chapter-exit span {
  font-size: 24px;
  line-height: 1;
}

.chapter-exit b {
  font-size: 9px;
}

.chapter-briefing > img {
  position: absolute;
  z-index: 2;
  width: 104%;
  height: 68%;
  top: 5%;
  left: -2%;
  object-fit: contain;
  object-position: 50% 0;
  filter: drop-shadow(0 18px 25px rgba(0, 19, 36, 0.5));
  animation: chapter-enter 0.5s cubic-bezier(0.17, 0.83, 0.25, 1);
}

.chapter-card {
  position: absolute;
  z-index: 4;
  right: 15px;
  bottom: calc(15px + env(safe-area-inset-bottom));
  left: 15px;
  padding: 18px 17px 16px;
  border: 2px solid rgba(255, 255, 255, 0.74);
  border-radius: 23px 7px 23px 7px;
  background: linear-gradient(145deg, rgba(4, 35, 59, 0.97), rgba(6, 81, 101, 0.95));
  box-shadow: 0 22px 52px rgba(0, 17, 33, 0.52);
  backdrop-filter: blur(12px);
  animation: card-enter 0.42s 0.08s ease-out both;
  max-height: calc(100svh - 105px);
  overflow-y: auto;
}

.chapter-card > small {
  color: var(--cyan-soft);
  font-size: 8px;
  font-weight: 1000;
  letter-spacing: 0.17em;
}

.chapter-card h2 {
  margin: 3px 0 0;
  color: var(--gold);
  font-size: clamp(25px, 7vw, 36px);
  font-style: italic;
  font-weight: 1000;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.chapter-card h3 {
  margin: 4px 0 10px;
  color: white;
  font-size: 12px;
}

.chapter-card > p {
  margin: 0 0 10px;
  color: #d7f7f0;
  font-size: 10px;
  line-height: 1.6;
}

.chapter-story {
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid rgba(152, 242, 232, 0.28);
  border-radius: 14px 5px 14px 5px;
  background: rgba(2, 24, 40, 0.4);
}

.story-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
  color: #87c8ce;
  font-size: 7px;
  font-weight: 1000;
  letter-spacing: 0.14em;
}

.chapter-story > b {
  display: block;
  color: var(--gold);
  font-size: 10px;
}

.chapter-story > p {
  min-height: 30px;
  margin: 3px 0 8px;
  color: #effffb;
  font-size: 10px;
  line-height: 1.48;
}

.story-next {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 14px 5px 14px 5px;
  color: white;
  background: rgba(83, 174, 184, 0.44);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.story-next b {
  font-size: 20px;
}

.chapter-objective {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 15px;
  padding: 8px;
  border: 1px solid rgba(152, 242, 232, 0.28);
  border-radius: 12px 4px 12px 4px;
  background: rgba(2, 24, 40, 0.38);
}

.chapter-objective > span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px 3px 9px 3px;
  color: var(--navy-950);
  background: var(--gold);
  font-weight: 1000;
}

.chapter-objective p {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.chapter-objective small {
  color: #87c8ce;
  font-size: 7px;
  font-weight: 900;
  text-transform: uppercase;
}

.chapter-objective b {
  font-size: 9px;
  line-height: 1.35;
}

.chapter-intel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: -5px 0 10px;
}

.chapter-intel-card {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid rgba(170, 241, 231, 0.28);
  border-radius: 13px 5px 13px 5px;
  background: rgba(2, 23, 39, 0.48);
}

.chapter-intel-enemy {
  grid-column: 1 / -1;
  gap: 10px;
  min-height: 66px;
}

.chapter-intel-card img {
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  object-fit: contain;
  filter: drop-shadow(0 5px 4px rgba(0, 17, 30, 0.4));
}

.chapter-intel-card span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.chapter-intel-card small {
  color: #8ddbd7;
  font-size: 10px;
  font-weight: 1000;
  letter-spacing: 0.08em;
}

.chapter-intel-card b {
  overflow: hidden;
  color: white;
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-intel-card em {
  color: var(--gold);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.chapter-decision {
  margin: 0 1px 10px;
  color: #bce9e2;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}

.chapter-card .primary-cta {
  min-height: 50px;
  font-size: 14px;
}

.hero-dialog {
  box-sizing: border-box;
  width: min(100vw, 520px);
  height: 100svh;
  max-height: min(100svh, 980px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 0;
  color: white;
  background: linear-gradient(155deg, #062c4b, #07536d);
  box-shadow: 0 25px 70px rgba(0, 15, 29, 0.58);
}

.hero-dialog::backdrop {
  background: rgba(1, 16, 29, 0.72);
  backdrop-filter: blur(5px);
}

.hero-dialog form {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  padding: 15px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.hero-dialog form::-webkit-scrollbar {
  display: none;
}

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

.hero-dialog header span small {
  color: var(--cyan-soft);
  font-size: 7px;
  font-weight: 1000;
  letter-spacing: 0.18em;
}

.hero-dialog h2 {
  margin: 0;
  font-size: 20px;
}

.hero-dialog header button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.16);
  cursor: pointer;
}

.hero-dialog form > p {
  margin: 4px 0 11px;
  color: #a7d9dc;
  font-size: 9px;
}

.hero-training {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--hero-accent) 42%, white);
  border-radius: 18px 6px 18px 6px;
  background:
    radial-gradient(circle at 16% 22%, color-mix(in srgb, var(--hero-accent) 36%, transparent), transparent 35%),
    linear-gradient(145deg, rgba(6, 43, 70, 0.96), rgba(4, 28, 48, 0.96));
  box-shadow: inset 0 0 28px rgba(108, 227, 226, 0.08), 0 12px 28px rgba(0, 17, 31, 0.25);
}

.hero-training-art {
  position: relative;
  min-height: 142px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px 4px 14px 4px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--hero-accent) 34%, #dff9f5), rgba(4, 31, 50, 0.54));
}

.hero-training-art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 8%;
  filter: drop-shadow(0 8px 7px rgba(0, 13, 25, 0.46));
}

.hero-training-art > span {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #112f45;
  background: linear-gradient(135deg, #fff2a8, #f4b759);
  font-size: 9px;
  font-weight: 1000;
  box-shadow: 0 4px 10px rgba(0, 15, 28, 0.35);
}

.hero-training-copy {
  min-width: 0;
}

.hero-training-copy > small {
  color: color-mix(in srgb, var(--hero-accent) 58%, white);
  font-size: 10px;
  font-weight: 1000;
  letter-spacing: 0.08em;
}

.hero-training-copy h3 {
  margin: 1px 0 5px;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-training-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.hero-training-badges b {
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #d7f5f2;
  background: rgba(0, 17, 31, 0.36);
  font-size: 9px;
}

.hero-training-copy > strong {
  display: block;
  color: var(--gold);
  font-size: 12px;
}

.hero-training-copy p {
  display: -webkit-box;
  margin: 3px 0 0;
  overflow: hidden;
  color: #c4e5e5;
  font-size: 11px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.hero-training-stats,
.hero-training-actions {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.hero-training-stats > span {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border: 1px solid rgba(143, 226, 222, 0.2);
  border-radius: 10px 3px 10px 3px;
  background: rgba(2, 22, 38, 0.42);
}

.hero-training-stats small {
  color: #8fdedb;
  font-size: 10px;
  font-weight: 900;
}

.hero-training-stats b,
.hero-training-stats em {
  font-size: 11px;
  font-style: normal;
  line-height: 1.25;
}

.hero-training-stats em {
  color: #b9d6da;
}

.hero-training-actions button {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 48px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 232, 143, 0.58);
  border-radius: 12px 4px 12px 4px;
  color: #163349;
  background: linear-gradient(145deg, #fff3b3, #efb253);
  box-shadow: 0 4px 0 #9f6638;
  text-align: left;
}

.hero-training-actions button:nth-child(2) {
  color: #e9ffff;
  background: linear-gradient(145deg, #358f9f, #17627f);
  box-shadow: 0 4px 0 #0a354d;
}

.hero-training-actions button:disabled {
  border-color: rgba(255, 255, 255, 0.14);
  color: #a9bec5;
  background: #29495c;
  box-shadow: 0 3px 0 #173246;
  opacity: 0.78;
}

.hero-training-actions i {
  font-size: 17px;
  font-style: normal;
  text-align: center;
}

.hero-training-actions span {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.hero-training-actions small {
  font-size: 9px;
  font-weight: 1000;
  letter-spacing: 0.04em;
}

.hero-training-actions b {
  font-size: 11px;
  white-space: nowrap;
}

.hero-training-actions em {
  max-width: 78px;
  overflow: hidden;
  font-size: 10px;
  font-style: normal;
  font-weight: 1000;
  line-height: 1.15;
  text-align: right;
  text-overflow: ellipsis;
}

.hero-collection-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.hero-collection-heading b {
  font-size: 13px;
}

.hero-collection-heading small {
  color: #9bcdd1;
  font-size: 10px;
}

.hero-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
  padding: 2px;
}

.hero-card {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  min-height: 96px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px 5px 16px 5px;
  color: white;
  background: linear-gradient(120deg, color-mix(in srgb, var(--hero-accent) 26%, #04243c), rgba(3, 27, 45, 0.88));
  text-align: left;
}

.hero-card.is-selected {
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 212, 93, 0.16), inset 0 0 28px rgba(255, 212, 93, 0.09);
}

.hero-card.is-locked {
  filter: grayscale(0.85) brightness(0.68);
}

.hero-card > img {
  width: 70px;
  height: 98px;
  align-self: end;
  margin-left: -10px;
  object-fit: cover;
  object-position: 50% 7%;
  pointer-events: none;
}

.hero-card-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 9px 7px 8px;
}

.hero-card-copy > small {
  color: color-mix(in srgb, var(--hero-accent) 65%, white);
  font-size: 7px;
  font-weight: 1000;
  letter-spacing: 0.1em;
}

.hero-card-copy > b {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-card-levels {
  display: flex;
  gap: 4px;
  margin-top: 7px;
}

.hero-card-levels em {
  padding: 2px 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #d9f7f4;
  background: rgba(0, 18, 32, 0.42);
  font-size: 9px;
  font-style: normal;
  font-weight: 1000;
}

.hero-skill {
  margin-top: 7px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px 3px 9px 3px;
  background: rgba(0, 0, 0, 0.18);
}

.hero-skill strong {
  display: block;
  color: var(--gold);
  font-size: 9px;
}

.hero-skill span {
  display: block;
  margin-top: 2px;
  color: #c2e8e6;
  font-size: 8px;
  line-height: 1.35;
}

.hero-select-state {
  align-self: flex-end;
  margin-top: auto;
  padding-top: 6px;
  color: white;
  font-size: 8px;
  font-weight: 1000;
}

.hero-dialog .dialog-close {
  flex: 0 0 auto;
  margin-top: 4px;
}

@keyframes chapter-enter {
  from { opacity: 0; transform: translateY(20px) scale(1.03); }
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(24px); }
}

@media (max-height: 700px) {
  .chapter-briefing > img {
    height: 64%;
  }

  .chapter-card {
    padding: 13px 14px;
  }

  .chapter-card > p {
    line-height: 1.4;
  }

  .chapter-objective {
    margin-bottom: 10px;
  }

  .hero-training {
    grid-template-columns: 90px minmax(0, 1fr);
  }

  .hero-training-art {
    min-height: 126px;
  }

  .hero-training-copy p {
    -webkit-line-clamp: 2;
  }
}
