:root {
  --ink: #07100e;
  --deep: #0b1714;
  --panel: rgba(9, 22, 19, 0.86);
  --panel-solid: #0c1a17;
  --line: rgba(154, 211, 193, 0.2);
  --line-bright: rgba(129, 255, 222, 0.46);
  --text: #e6eee9;
  --muted: #849b93;
  --cyan: #65f6d2;
  --cyan-soft: #8ae3ce;
  --gold: #d6b978;
  --danger: #ff705f;
  --enemy: #ff755f;
  --shadow: rgba(0, 0, 0, 0.48);
  --display: "Bahnschrift", "DIN Alternate", "Microsoft YaHei UI", sans-serif;
  --body: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", sans-serif;
  --serif: "STKaiti", "KaiTi", "Microsoft YaHei UI", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--ink);
  font-family: var(--body);
  user-select: none;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 3px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 23px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid rgba(156, 203, 190, 0.28);
  border-radius: 3px;
  color: #b8c9c3;
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.04);
  font-family: var(--display);
  font-size: 9px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.05em;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #07100e;
  cursor: crosshair;
}

.screen-grade {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(6, 18, 15, 0.3), transparent 32%, transparent 68%, rgba(4, 12, 10, 0.25)),
    radial-gradient(ellipse at center, transparent 45%, rgba(2, 8, 7, 0.47) 100%);
  mix-blend-mode: multiply;
}

.screen-grade::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background-image: repeating-linear-gradient(0deg, transparent 0, transparent 3px, rgba(169, 255, 226, 0.09) 4px);
}

.corner-mark {
  position: fixed;
  z-index: 3;
  width: 34px;
  height: 34px;
  pointer-events: none;
  opacity: 0.52;
}

.corner-mark--tl {
  top: 14px;
  left: 14px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.corner-mark--tr {
  top: 14px;
  right: 14px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.is-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ---------- Start screen ---------- */

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  overflow: hidden;
  background:
    radial-gradient(circle at 23% 40%, rgba(37, 118, 97, 0.32), transparent 33%),
    radial-gradient(circle at 80% 66%, rgba(125, 60, 37, 0.27), transparent 32%),
    linear-gradient(120deg, rgba(4, 14, 12, 0.96), rgba(5, 13, 12, 0.75) 52%, rgba(8, 17, 19, 0.91));
  backdrop-filter: blur(8px) saturate(0.76);
  transition: opacity 0.85s ease, visibility 0.85s;
}

.start-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 49.9%, rgba(123, 200, 178, 0.08) 50%, transparent 50.1%),
    linear-gradient(0deg, transparent 49.9%, rgba(123, 200, 178, 0.05) 50%, transparent 50.1%);
  background-size: 100px 100px;
  mask-image: linear-gradient(to bottom, transparent, black 22%, black 74%, transparent);
  opacity: 0.34;
}

.start-noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image:
    radial-gradient(circle at 12% 30%, rgba(255, 255, 255, 0.15) 0 1px, transparent 1.5px),
    radial-gradient(circle at 72% 67%, rgba(255, 255, 255, 0.1) 0 1px, transparent 1.6px);
  background-size: 37px 41px, 53px 47px;
}

.start-orbit {
  position: absolute;
  width: 75vw;
  height: 75vw;
  max-width: 1120px;
  max-height: 1120px;
  border: 1px solid rgba(111, 201, 175, 0.09);
  border-radius: 50%;
  pointer-events: none;
}

.start-orbit::before,
.start-orbit::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(111, 201, 175, 0.07);
  border-radius: 50%;
}

.start-orbit::before {
  inset: 7%;
}

.start-orbit::after {
  inset: 18%;
}

.start-orbit--one {
  top: -42vw;
  right: -12vw;
}

.start-orbit--two {
  bottom: -55vw;
  left: -24vw;
}

.intro-shell {
  position: relative;
  z-index: 1;
  width: min(1040px, 93vw);
  animation: intro-reveal 1s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes intro-reveal {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.intro-header {
  text-align: center;
  margin-bottom: 25px;
}

.intro-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--cyan-soft);
  font-family: var(--display);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.intro-eyebrow i {
  width: 31px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan));
  box-shadow: 0 0 8px var(--cyan);
}

.intro-header h1 {
  margin: 4px 0 -5px;
  color: #ecf5ef;
  font-family: var(--serif);
  font-size: clamp(54px, 7.1vw, 82px);
  font-weight: 400;
  letter-spacing: 0.12em;
  line-height: 1.12;
  text-shadow: 0 0 42px rgba(115, 232, 199, 0.12), 0 4px 25px rgba(0, 0, 0, 0.5);
}

.intro-header h1 span {
  color: var(--gold);
}

.intro-en {
  color: rgba(174, 204, 194, 0.45);
  font-family: var(--display);
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.72em;
  text-indent: 0.72em;
}

.intro-header p {
  margin: 16px auto 0;
  color: #8da39c;
  font-size: 12px;
  line-height: 1.85;
  letter-spacing: 0.04em;
}

.intro-grid {
  display: grid;
  grid-template-columns: 1.28fr 0.92fr;
  gap: 12px;
}

.briefing-card,
.difficulty-card {
  position: relative;
  min-height: 180px;
  border: 1px solid rgba(137, 195, 178, 0.16);
  background:
    linear-gradient(135deg, rgba(24, 48, 41, 0.54), rgba(6, 16, 14, 0.69)),
    rgba(7, 19, 16, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025), 0 16px 45px rgba(0, 0, 0, 0.17);
  backdrop-filter: blur(14px);
}

.briefing-card {
  padding: 17px 19px 16px;
}

.panel-corner {
  position: absolute;
  width: 9px;
  height: 9px;
  border-color: var(--gold);
  opacity: 0.62;
}

.panel-corner--a {
  top: -1px;
  left: -1px;
  border-top: 1px solid;
  border-left: 1px solid;
}

.panel-corner--b {
  right: -1px;
  bottom: -1px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.briefing-label,
.briefing-facts,
.difficulty-readout,
.intro-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.briefing-label {
  padding-bottom: 11px;
  border-bottom: 1px solid rgba(134, 186, 170, 0.1);
}

.briefing-label span,
.small-label {
  color: #a1b5ae;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.briefing-label b {
  color: var(--gold);
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.briefing-body {
  display: grid;
  grid-template-columns: 1fr 142px;
  gap: 15px;
  align-items: center;
}

.sector-map {
  position: relative;
  height: 111px;
  margin-top: 4px;
  overflow: hidden;
  background: radial-gradient(ellipse at center, rgba(50, 111, 91, 0.14), transparent 65%);
}

.sector-map::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(102, 235, 195, 0.5), transparent) 0 0 / 34% 100% no-repeat;
  opacity: 0.12;
  animation: map-scan 5.5s linear infinite;
}

@keyframes map-scan {
  from { transform: translateX(-100%); }
  to { transform: translateX(390%); }
}

.sector-map svg {
  width: 100%;
  height: 100%;
}

.briefing-facts {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding-left: 15px;
  border-left: 1px solid rgba(141, 192, 176, 0.13);
}

.briefing-facts span {
  display: flex;
  justify-content: space-between;
  color: #647f75;
  font-size: 9px;
  letter-spacing: 0.05em;
}

.briefing-facts b {
  color: #b2c4be;
  font-weight: 500;
}

.difficulty-card {
  padding: 17px 18px 14px;
}

.difficulty-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 13px;
}

.difficulty-head h2 {
  margin: 4px 0 0;
  color: #d6e2dc;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.difficulty-code {
  color: rgba(213, 184, 119, 0.36);
  font-family: var(--display);
  font-size: 32px;
  font-weight: 200;
  line-height: 1;
}

.difficulty-options {
  display: grid;
  gap: 5px;
}

.difficulty-options button {
  position: relative;
  display: grid;
  grid-template-columns: 24px 58px 1fr;
  align-items: center;
  height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  color: #718a81;
  background: rgba(3, 12, 10, 0.28);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}

.difficulty-options button:hover {
  color: #b8c9c3;
  background: rgba(100, 221, 190, 0.05);
}

.difficulty-options button.is-selected {
  border-color: rgba(101, 246, 210, 0.27);
  color: #d9ebe5;
  background: linear-gradient(90deg, rgba(94, 241, 205, 0.11), rgba(94, 241, 205, 0.025));
}

.difficulty-options button.is-selected::before {
  content: "";
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: -1px;
  width: 2px;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.difficulty-options button span {
  color: #506a61;
  font-family: var(--display);
  font-size: 9px;
}

.difficulty-options button.is-selected span {
  color: var(--cyan-soft);
}

.difficulty-options b {
  font-size: 11px;
  font-weight: 500;
}

.difficulty-options small {
  justify-self: end;
  color: #5e766d;
  font-size: 8px;
}

.difficulty-readout {
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid rgba(141, 192, 176, 0.1);
  color: #5f766e;
  font-size: 8px;
}

.difficulty-readout > span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.difficulty-readout b {
  color: #a7b6b1;
  font-weight: 500;
}

#pressureBars {
  display: inline-flex;
  gap: 2px;
}

#pressureBars b {
  display: block;
  width: 10px;
  height: 3px;
  background: rgba(255, 255, 255, 0.11);
}

#pressureBars b.is-on {
  background: var(--gold);
  box-shadow: 0 0 5px rgba(214, 185, 120, 0.4);
}

.intro-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  margin-top: 14px;
}

.control-brief {
  display: flex;
  gap: 21px;
}

.control-brief div {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #687f77;
  font-size: 9px;
}

.start-button {
  position: relative;
  display: flex;
  align-items: center;
  width: 280px;
  height: 58px;
  padding: 0 16px;
  overflow: hidden;
  border: 1px solid rgba(122, 244, 210, 0.4);
  color: #071512;
  background: linear-gradient(100deg, #74edca, #b6d7a5 58%, #d4c184);
  box-shadow: 0 0 34px rgba(97, 234, 197, 0.13), inset 0 1px rgba(255, 255, 255, 0.4);
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  transition: filter 0.2s, transform 0.2s;
}

.start-button:hover {
  filter: brightness(1.08) saturate(1.05);
  transform: translateY(-2px);
}

.start-button:active {
  transform: translateY(0);
}

.start-button-glint {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.47), transparent 67%);
  transform: translateX(-130%);
  animation: button-glint 4.8s ease-in-out 1.5s infinite;
}

@keyframes button-glint {
  0%, 58% { transform: translateX(-130%); }
  77%, 100% { transform: translateX(130%); }
}

.button-index {
  margin-right: 15px;
  color: rgba(6, 23, 18, 0.44);
  font-family: var(--display);
  font-size: 9px;
  font-weight: 600;
}

.button-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1px;
  text-align: left;
}

.button-copy b {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.13em;
}

.button-copy small {
  font-family: var(--display);
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0.15em;
  opacity: 0.56;
}

.button-arrow {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 300;
}

.intro-foot {
  margin-top: 17px;
  color: rgba(111, 138, 129, 0.45);
  font-family: var(--display);
  font-size: 7px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.intro-status {
  color: #708b81;
}

.intro-status i,
.live-dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 7px var(--cyan);
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  50% { opacity: 0.35; }
}

/* ---------- In-game HUD ---------- */

.game-hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.5s;
}

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 72px;
  padding: 12px 24px 10px 26px;
  background: linear-gradient(to bottom, rgba(4, 13, 11, 0.9), rgba(5, 16, 13, 0.54) 70%, transparent);
}

.topbar::after {
  content: "";
  position: absolute;
  bottom: 1px;
  left: 26px;
  right: 26px;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent 30%, transparent 70%, var(--line));
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-sigil {
  width: 38px;
  height: 38px;
  color: var(--gold);
  filter: drop-shadow(0 0 8px rgba(214, 185, 120, 0.18));
}

.brand-sigil svg {
  width: 100%;
  height: 100%;
}

.brand-name {
  color: #d9e5df;
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.16em;
}

.brand-sub {
  margin-top: 1px;
  color: #60766e;
  font-family: var(--display);
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0.17em;
}

.brand-sub span {
  margin: 0 3px;
  color: var(--gold);
}

.resource-rail {
  display: flex;
  align-items: stretch;
  justify-self: center;
  height: 40px;
  border: 1px solid rgba(141, 197, 179, 0.13);
  background: rgba(5, 16, 13, 0.58);
  backdrop-filter: blur(8px);
}

.resource-chip {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 132px;
  padding: 5px 13px;
  border-right: 1px solid rgba(141, 197, 179, 0.11);
}

.resource-chip:last-child {
  border-right: 0;
}

.resource-chip--time {
  min-width: 104px;
}

.resource-icon {
  width: 23px;
  height: 23px;
  margin-right: 9px;
  color: var(--cyan);
}

.resource-chip:nth-child(2) .resource-icon {
  color: #a3bbcd;
}

.resource-icon svg {
  width: 100%;
  height: 100%;
}

.resource-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.resource-label {
  margin-bottom: 2px;
  color: #637b72;
  font-size: 7px;
  letter-spacing: 0.12em;
}

.resource-copy strong {
  color: #e1ebe6;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.resource-copy em {
  margin: 0 2px;
  color: #546a62;
  font-size: 10px;
  font-style: normal;
}

.resource-rate {
  align-self: flex-end;
  margin: 0 0 5px 10px;
  color: #5fc9aa;
  font-family: var(--display);
  font-size: 8px;
  font-variant-numeric: tabular-nums;
}

.resource-chip--crystal {
  min-width: 155px;
}

.resource-chip--crystal::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(102, 239, 202, 0.04);
  pointer-events: none;
}

.top-actions {
  display: flex;
  justify-self: end;
  gap: 6px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(132, 185, 168, 0.14);
  color: #829b92;
  background: rgba(5, 15, 12, 0.48);
  cursor: pointer;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}

.icon-button:hover {
  border-color: rgba(115, 239, 207, 0.36);
  color: var(--cyan);
  background: rgba(32, 81, 67, 0.33);
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.icon-button .sound-off {
  display: none;
}

.icon-button.is-muted .sound-on {
  display: none;
}

.icon-button.is-muted .sound-off {
  display: block;
}

.icon-button span {
  font-family: var(--display);
  font-size: 14px;
}

.mission-stack {
  position: absolute;
  top: 95px;
  left: 27px;
  width: 245px;
  padding: 13px 14px 13px 16px;
  border-left: 1px solid rgba(214, 185, 120, 0.28);
  background: linear-gradient(90deg, rgba(7, 19, 16, 0.76), rgba(7, 19, 16, 0.12));
}

.mission-kicker {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--gold);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.17em;
}

.pulse-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: blink 1.8s ease-in-out infinite;
}

.mission-title {
  margin-top: 5px;
  color: #dce7e2;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.mission-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 5px 0 12px;
  color: #617a71;
  font-size: 8px;
}

.mission-meta b {
  margin-left: 5px;
  color: #7d968d;
  font-weight: 500;
}

.objective-list {
  display: grid;
  gap: 7px;
}

.objective {
  display: grid;
  grid-template-columns: 9px 1fr auto;
  align-items: center;
  gap: 7px;
  color: #849b92;
  font-size: 9px;
  transition: color 0.3s;
}

.objective-node {
  width: 5px;
  height: 5px;
  border: 1px solid #5f786e;
  transform: rotate(45deg);
}

.objective em {
  color: #5f766d;
  font-family: var(--display);
  font-size: 8px;
  font-style: normal;
}

.objective.is-active {
  color: #d5e3dd;
}

.objective.is-active .objective-node {
  border-color: var(--cyan);
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.objective.is-complete {
  color: #5e7d71;
  text-decoration: line-through;
}

.objective.is-complete .objective-node {
  border-color: #65b594;
  background: #65b594;
}

.objective.is-complete em {
  color: #65b594;
}

.threat-panel {
  position: absolute;
  top: 95px;
  right: 27px;
  width: 184px;
  padding: 11px 12px;
  border: 1px solid rgba(141, 195, 178, 0.1);
  background: linear-gradient(180deg, rgba(7, 19, 16, 0.72), rgba(7, 19, 16, 0.24));
}

.threat-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #6c827a;
  font-size: 8px;
  letter-spacing: 0.1em;
}

.threat-heading b {
  color: var(--gold);
  font-size: 9px;
  font-weight: 500;
}

.threat-bars {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  margin: 8px 0 7px;
}

.threat-bars i {
  height: 3px;
  background: rgba(200, 224, 215, 0.1);
}

.threat-bars i.is-active {
  background: var(--gold);
  box-shadow: 0 0 6px rgba(214, 185, 120, 0.36);
}

.threat-bars i.is-danger {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(255, 112, 95, 0.45);
}

.threat-foot {
  display: flex;
  justify-content: space-between;
  color: #566e65;
  font-size: 7px;
}

.threat-foot b {
  color: #98aaa3;
  font-family: var(--display);
  font-size: 8px;
  font-variant-numeric: tabular-nums;
}

.toast-stack {
  position: absolute;
  top: 84px;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transform: translateX(-50%);
}

.toast {
  display: flex;
  align-items: center;
  min-width: 250px;
  padding: 8px 13px;
  border: 1px solid rgba(123, 233, 204, 0.18);
  color: #b9ccc5;
  background: rgba(5, 17, 14, 0.82);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
  font-size: 10px;
  animation: toast-in 0.32s ease both;
}

.toast::before {
  content: "";
  width: 3px;
  height: 3px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 7px var(--cyan);
}

.toast.is-warning {
  border-color: rgba(255, 112, 95, 0.25);
}

.toast.is-warning::before {
  background: var(--danger);
  box-shadow: 0 0 7px var(--danger);
}

.toast.is-success::before {
  background: var(--gold);
  box-shadow: 0 0 7px var(--gold);
}

.toast.is-out {
  animation: toast-out 0.3s ease forwards;
}

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

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-6px); }
}

.tip-rail {
  position: absolute;
  bottom: 186px;
  left: 27px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #81968e;
  font-size: 9px;
  pointer-events: auto;
}

.tip-key {
  padding: 3px 5px;
  border: 1px solid rgba(214, 185, 120, 0.28);
  color: var(--gold);
  font-size: 7px;
  letter-spacing: 0.1em;
}

#tipClose {
  padding: 0 2px;
  border: 0;
  color: #526b62;
  background: none;
  cursor: pointer;
}

.command-dock {
  position: absolute;
  right: 318px;
  bottom: 16px;
  left: 16px;
  display: grid;
  grid-template-columns: 280px minmax(165px, 0.75fr) minmax(320px, 1.25fr);
  min-height: 158px;
  border: 1px solid rgba(141, 198, 180, 0.17);
  background:
    linear-gradient(100deg, rgba(11, 27, 23, 0.95), rgba(7, 19, 16, 0.92)),
    var(--panel-solid);
  box-shadow: 0 -14px 55px rgba(0, 0, 0, 0.27), inset 0 1px rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

.command-dock::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  width: 168px;
  height: 1px;
  background: linear-gradient(90deg, var(--cyan), transparent);
  opacity: 0.52;
}

.selection-summary {
  position: relative;
  display: grid;
  grid-template-columns: 69px 1fr;
  gap: 12px;
  align-content: center;
  padding: 18px 16px 18px 18px;
  border-right: 1px solid rgba(139, 192, 175, 0.1);
  background: radial-gradient(circle at 19% 50%, rgba(56, 147, 122, 0.12), transparent 52%);
}

.portrait-frame {
  position: relative;
  width: 69px;
  height: 81px;
  overflow: hidden;
  border: 1px solid rgba(110, 220, 190, 0.22);
  background:
    linear-gradient(145deg, rgba(68, 136, 117, 0.25), rgba(2, 9, 7, 0.7)),
    repeating-linear-gradient(135deg, transparent 0 8px, rgba(130, 255, 221, 0.02) 8px 9px);
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}

.portrait-frame::after {
  content: "";
  position: absolute;
  right: 5px;
  bottom: 5px;
  left: 5px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.36;
}

.portrait-art {
  position: absolute;
  inset: 4px;
  background-position: center;
  background-size: 72%;
  background-repeat: no-repeat;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.45));
}

.portrait-tier {
  position: absolute;
  top: 5px;
  right: 6px;
  color: rgba(139, 238, 212, 0.54);
  font-family: var(--display);
  font-size: 7px;
}

.selection-copy {
  min-width: 0;
  align-self: center;
}

.selection-name {
  color: #e3ebe7;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.selection-role {
  margin: 3px 0 9px;
  overflow: hidden;
  color: #637a72;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-health {
  height: 2px;
  background: rgba(162, 198, 187, 0.13);
}

.mini-health i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--cyan);
  box-shadow: 0 0 6px rgba(101, 246, 210, 0.34);
  transition: width 0.2s;
}

.selection-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 3px;
  margin-top: 6px;
  color: #536c63;
  font-size: 7px;
}

.selection-stats b {
  color: #8da39a;
  font-family: var(--display);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.selection-count {
  position: absolute;
  right: 10px;
  bottom: 8px;
  color: rgba(125, 181, 162, 0.2);
  font-family: var(--display);
  font-size: 24px;
  font-weight: 200;
}

.unit-strip-wrap,
.command-section {
  padding: 13px 14px;
}

.unit-strip-wrap {
  min-width: 0;
  border-right: 1px solid rgba(139, 192, 175, 0.1);
}

.dock-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 16px;
  margin-bottom: 8px;
  color: #7f968d;
  font-size: 8px;
  letter-spacing: 0.13em;
}

.dock-section-label small {
  overflow: hidden;
  color: #4e665d;
  font-size: 6px;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-list {
  display: grid;
  grid-template-columns: repeat(4, 34px);
  align-content: start;
  gap: 4px;
  min-height: 99px;
}

.unit-token {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(124, 205, 181, 0.16);
  background: linear-gradient(140deg, rgba(49, 105, 88, 0.24), rgba(2, 10, 8, 0.6));
  cursor: pointer;
  pointer-events: auto;
}

.unit-token:hover,
.unit-token.is-primary {
  border-color: rgba(116, 243, 210, 0.5);
  background: rgba(67, 158, 130, 0.22);
}

.unit-token img,
.unit-token canvas,
.unit-token svg {
  width: 100%;
  height: 100%;
}

.unit-token .token-health {
  position: absolute;
  right: 2px;
  bottom: 1px;
  left: 2px;
  height: 1px;
  background: rgba(0, 0, 0, 0.5);
}

.unit-token .token-health i {
  display: block;
  height: 100%;
  background: #6ce8c7;
}

.unit-token .token-index {
  position: absolute;
  top: 1px;
  left: 2px;
  color: rgba(221, 244, 236, 0.4);
  font-family: var(--display);
  font-size: 5px;
}

.command-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(49px, 1fr));
  gap: 5px;
  min-height: 99px;
}

.command-button {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 47px;
  padding: 5px;
  overflow: hidden;
  border: 1px solid rgba(126, 193, 174, 0.14);
  color: #9bb0a8;
  background: linear-gradient(145deg, rgba(31, 65, 55, 0.36), rgba(3, 13, 10, 0.45));
  cursor: pointer;
  pointer-events: auto;
  text-align: left;
  transition: border-color 0.14s, background 0.14s, color 0.14s, transform 0.14s;
}

.command-button:hover:not(:disabled) {
  border-color: rgba(115, 241, 208, 0.4);
  color: #dfece7;
  background: linear-gradient(145deg, rgba(52, 118, 97, 0.5), rgba(5, 18, 14, 0.55));
  transform: translateY(-1px);
}

.command-button.is-active {
  border-color: var(--cyan);
  color: #ebfff9;
  background: rgba(64, 158, 130, 0.33);
  box-shadow: inset 0 0 18px rgba(100, 246, 210, 0.08), 0 0 12px rgba(100, 246, 210, 0.07);
}

.command-button:disabled {
  color: #43564f;
  cursor: not-allowed;
  filter: saturate(0.4);
}

.command-button .cmd-icon {
  display: grid;
  flex: 0 0 26px;
  place-items: center;
  width: 26px;
  height: 26px;
  color: var(--cyan-soft);
}

.command-button:disabled .cmd-icon {
  color: #4c6259;
}

.command-button .cmd-icon svg {
  width: 22px;
  height: 22px;
}

.command-button .cmd-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding-left: 4px;
}

.command-button b {
  overflow: hidden;
  color: inherit;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-button small {
  margin-top: 2px;
  color: #526b62;
  font-family: var(--display);
  font-size: 6px;
  font-variant-numeric: tabular-nums;
}

.command-button .hotkey {
  position: absolute;
  top: 2px;
  right: 4px;
  color: rgba(142, 237, 211, 0.35);
  font-family: var(--display);
  font-size: 6px;
}

.command-button .queue-badge {
  position: absolute;
  right: 3px;
  bottom: 2px;
  display: grid;
  place-items: center;
  min-width: 13px;
  height: 11px;
  padding: 0 3px;
  border-radius: 6px;
  color: #07120f;
  background: var(--cyan);
  font-family: var(--display);
  font-size: 6px;
  font-weight: 700;
}

.command-empty {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 99px;
  border: 1px dashed rgba(132, 184, 168, 0.1);
  color: #4d655c;
  font-size: 8px;
  letter-spacing: 0.1em;
}

.command-tooltip {
  position: absolute;
  right: 14px;
  bottom: calc(100% + 9px);
  width: 236px;
  padding: 10px 12px;
  border: 1px solid rgba(127, 218, 190, 0.18);
  color: #b8cbc4;
  background: rgba(5, 16, 13, 0.94);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.26);
  font-size: 8px;
  line-height: 1.6;
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 0.15s, transform 0.15s;
}

.command-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.command-tooltip b {
  display: block;
  margin-bottom: 2px;
  color: #e0ebe6;
  font-size: 9px;
  font-weight: 500;
}

.command-tooltip em {
  color: var(--gold);
  font-style: normal;
}

.minimap-panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 288px;
  height: 158px;
  border: 1px solid rgba(143, 201, 184, 0.18);
  background: rgba(4, 14, 11, 0.9);
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  pointer-events: auto;
}

.minimap-panel::before,
.minimap-panel::after {
  content: "";
  position: absolute;
  z-index: 3;
  width: 10px;
  height: 10px;
  pointer-events: none;
}

.minimap-panel::before {
  top: -1px;
  left: -1px;
  border-top: 1px solid var(--cyan);
  border-left: 1px solid var(--cyan);
}

.minimap-panel::after {
  right: -1px;
  bottom: -1px;
  border-right: 1px solid var(--gold);
  border-bottom: 1px solid var(--gold);
}

.minimap-head {
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 21px;
  padding: 0 8px;
  background: linear-gradient(to bottom, rgba(3, 12, 10, 0.95), rgba(3, 12, 10, 0.17));
  color: #80978e;
  font-size: 7px;
  letter-spacing: 0.08em;
}

.minimap-head small {
  color: #536c63;
  font-size: 6px;
}

#minimapCanvas {
  display: block;
  width: 260px;
  height: 154px;
  margin: 2px auto 0;
  cursor: crosshair;
}

.minimap-scan {
  position: absolute;
  z-index: 1;
  top: 22px;
  bottom: 0;
  width: 50%;
  background: linear-gradient(90deg, transparent, rgba(103, 248, 211, 0.05), transparent);
  pointer-events: none;
  animation: minimap-scan 7s linear infinite;
}

@keyframes minimap-scan {
  from { transform: translateX(-100%); }
  to { transform: translateX(300%); }
}

.minimap-foot {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 19px;
  padding: 0 8px;
  color: #506a61;
  background: linear-gradient(to top, rgba(3, 12, 10, 0.95), transparent);
  font-size: 6px;
}

.minimap-foot kbd {
  height: 13px;
  min-width: 24px;
  border-color: rgba(138, 185, 170, 0.18);
  font-size: 5px;
}

.control-hints {
  position: absolute;
  bottom: 181px;
  right: 320px;
  display: flex;
  gap: 13px;
  color: #4e675e;
  font-size: 7px;
}

.control-hints span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.placement-hint {
  position: absolute;
  bottom: 185px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border: 1px solid rgba(102, 239, 201, 0.27);
  background: rgba(5, 20, 16, 0.88);
  transform: translate(-50%, 7px);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}

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

.placement-icon {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border: 1px solid rgba(104, 241, 204, 0.38);
  color: var(--cyan);
  font-family: var(--display);
}

.placement-hint div {
  display: flex;
  flex-direction: column;
}

.placement-hint b {
  color: #c8ded6;
  font-size: 8px;
  font-weight: 500;
}

.placement-hint small {
  margin-top: 2px;
  color: #617a71;
  font-size: 6px;
}

/* ---------- Modals ---------- */

.modal-screen,
.help-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 25px;
  background: rgba(3, 10, 8, 0.72);
  backdrop-filter: blur(8px);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.28s, visibility 0.28s;
}

.modal-card {
  position: relative;
  width: min(520px, 92vw);
  padding: 38px 38px 30px;
  border: 1px solid rgba(141, 209, 188, 0.22);
  background:
    radial-gradient(circle at 50% 0%, rgba(86, 183, 155, 0.15), transparent 42%),
    linear-gradient(145deg, rgba(14, 35, 29, 0.98), rgba(5, 15, 12, 0.98));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.modal-card::before,
.modal-card::after {
  content: "";
  position: absolute;
  width: 40px;
  height: 1px;
  background: var(--gold);
  opacity: 0.46;
}

.modal-card::before {
  top: -1px;
  left: 22px;
}

.modal-card::after {
  right: 22px;
  bottom: -1px;
}

.modal-card--small {
  width: min(420px, 92vw);
  padding-top: 34px;
}

.modal-kicker {
  color: var(--gold);
  font-family: var(--display);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.19em;
}

.modal-card h2 {
  margin: 9px 0 8px;
  color: #e8f0ec;
  font-family: var(--serif);
  font-size: 33px;
  font-weight: 400;
  letter-spacing: 0.12em;
}

.modal-card p {
  margin: 0;
  color: #738b82;
  font-size: 10px;
  line-height: 1.75;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 23px;
}

.primary-button,
.secondary-button {
  min-width: 139px;
  height: 40px;
  border: 1px solid;
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.primary-button {
  border-color: rgba(105, 245, 209, 0.55);
  color: #061611;
  background: linear-gradient(110deg, #6be8c5, #b5d4a2);
}

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

.secondary-button {
  border-color: rgba(139, 193, 176, 0.18);
  color: #92a79f;
  background: rgba(0, 0, 0, 0.17);
}

.secondary-button:hover {
  border-color: rgba(139, 193, 176, 0.35);
  color: #c4d2cd;
}

.end-emblem {
  width: 64px;
  height: 64px;
  margin: -3px auto 8px;
  color: var(--cyan);
  filter: drop-shadow(0 0 18px rgba(101, 246, 210, 0.2));
}

.end-emblem.is-defeat {
  color: var(--danger);
  filter: drop-shadow(0 0 18px rgba(255, 112, 95, 0.2));
}

.end-emblem svg {
  width: 100%;
  height: 100%;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 22px;
  background: rgba(130, 190, 171, 0.1);
}

.result-stats div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 5px;
  background: rgba(5, 18, 14, 0.82);
}

.result-stats span {
  color: #5e776e;
  font-size: 7px;
  letter-spacing: 0.08em;
}

.result-stats b {
  color: #c8dbd4;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.help-screen {
  z-index: 28;
}

.help-card {
  width: min(850px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 25px 28px 29px;
  border: 1px solid rgba(138, 206, 184, 0.22);
  background: rgba(6, 19, 15, 0.97);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.45);
}

.help-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(141, 198, 180, 0.13);
}

.help-card header span {
  color: var(--gold);
  font-size: 8px;
  letter-spacing: 0.17em;
}

.help-card h2 {
  margin: 5px 0 0;
  color: #dce7e2;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 400;
  letter-spacing: 0.1em;
}

.help-card header button {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(134, 184, 168, 0.15);
  color: #829990;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
}

.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 36px;
  padding-top: 19px;
}

.help-grid section h3 {
  margin: 0 0 10px;
  color: #b4c7c0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
}

.help-grid section p {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 25px;
  margin: 0;
  color: #70877e;
  font-size: 9px;
  line-height: 1.55;
}

.help-grid section p kbd {
  flex: 0 0 auto;
}

.help-note {
  grid-column: 1 / -1;
  padding: 13px 15px;
  border-left: 1px solid rgba(214, 185, 120, 0.31);
  background: rgba(94, 160, 139, 0.06);
}

.help-note p {
  display: block;
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .command-dock {
    grid-template-columns: 250px 170px 1fr;
  }

  .selection-summary {
    grid-template-columns: 58px 1fr;
    padding-left: 14px;
  }

  .portrait-frame {
    width: 58px;
    height: 72px;
  }

  .command-button b {
    font-size: 7px;
  }

  .command-button small {
    display: none;
  }

  .control-hints,
  .threat-panel {
    display: none;
  }
}

@media (max-width: 900px) {
  .start-screen {
    align-items: flex-start;
    overflow-y: auto;
    padding: 22px;
  }

  .intro-grid {
    grid-template-columns: 1fr;
  }

  .briefing-card {
    min-height: auto;
  }

  .intro-actions {
    align-items: flex-start;
    flex-direction: column-reverse;
  }

  .start-button {
    width: 100%;
  }

  .control-brief {
    flex-wrap: wrap;
    gap: 10px 17px;
  }

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

  .resource-rail {
    position: absolute;
    top: 65px;
    left: 50%;
    transform: translateX(-50%);
  }

  .brand-lockup {
    grid-column: 1;
  }

  .top-actions {
    grid-column: 2;
  }

  .mission-stack {
    top: 122px;
    left: 14px;
    width: 210px;
  }

  .command-dock {
    right: 14px;
    bottom: 14px;
    left: 14px;
    grid-template-columns: 210px 1fr;
  }

  .unit-strip-wrap {
    display: none;
  }

  .minimap-panel {
    right: 14px;
    bottom: 184px;
    transform: scale(0.74);
    transform-origin: right bottom;
  }

  .selection-summary {
    grid-template-columns: 52px 1fr;
  }

  .portrait-frame {
    width: 52px;
    height: 68px;
  }

  .command-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .command-empty {
    min-height: 90px;
  }
}

@media (max-height: 730px) {
  .intro-header {
    margin-bottom: 16px;
  }

  .intro-header h1 {
    font-size: 57px;
  }

  .intro-header p {
    margin-top: 10px;
    line-height: 1.6;
  }

  .briefing-card,
  .difficulty-card {
    min-height: 160px;
  }

  .intro-foot {
    margin-top: 10px;
  }

  .command-dock {
    min-height: 144px;
  }
}

@media (max-width: 620px) {
  .intro-shell {
    width: 100%;
  }

  .intro-header h1 {
    font-size: 48px;
  }

  .intro-header p br {
    display: none;
  }

  .briefing-body {
    grid-template-columns: 1fr;
  }

  .briefing-facts {
    display: none;
  }

  .intro-en,
  .intro-foot,
  .control-brief {
    display: none;
  }

  .mission-stack {
    display: none;
  }

  .brand-sub {
    display: none;
  }

  .resource-chip {
    min-width: 100px;
    padding: 4px 8px;
  }

  .resource-chip--crystal {
    min-width: 128px;
  }

  .resource-chip--time {
    display: none;
  }

  .resource-icon {
    width: 18px;
  }

  .resource-copy strong {
    font-size: 12px;
  }

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

  .selection-summary {
    display: none;
  }

  .command-section {
    padding: 10px;
  }

  .command-button {
    min-width: 0;
  }

  .command-button .cmd-copy {
    display: none;
  }

  .command-button .cmd-icon {
    flex: 1;
  }

  .minimap-panel {
    opacity: 0.58;
  }
}

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