.it-shell {
  --it-ink: #e8f5ef;
  --it-muted: #91b4b2;
  --it-line: #31545b;
  --it-panel: #0a2932;
  --it-panel-raised: #103b43;
  --it-teal: #62ddca;
  --it-gold: #ffc857;
  box-sizing: border-box;
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 14px 24px;
  border: 1px solid #2c6068;
  border-radius: 18px;
  background: radial-gradient(circle at 50% -20%, rgba(50, 139, 146, 0.22), transparent 38%), linear-gradient(180deg, #061b28 0%, #092b35 52%, #071e2a 100%);
  box-shadow: 0 22px 58px rgba(2, 15, 22, 0.42), inset 0 1px 0 rgba(192, 247, 236, 0.06);
  color: var(--it-ink);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.it-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.it-stats,
.it-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.it-stat {
  min-width: 78px;
  padding: 7px 10px;
  border: 1px solid rgba(112, 192, 187, 0.34);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(17, 61, 68, 0.94), rgba(6, 28, 38, 0.94));
  box-shadow: 0 8px 20px rgba(2, 15, 21, 0.22), inset 0 1px 0 rgba(210, 255, 244, 0.05);
  text-align: center;
}

.it-stat span,
.it-panel-head span,
.it-kicker {
  display: block;
  color: var(--it-muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-transform: uppercase;
}

.it-stat strong {
  display: block;
  margin-top: 2px;
  color: var(--it-ink);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.it-icon-btn,
.it-btn,
.it-pad,
.it-type,
.it-close {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--it-line);
  color: var(--it-ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, opacity 120ms ease;
}

.it-icon-btn {
  display: grid;
  padding: 0 11px;
  place-items: center;
  border-radius: 10px;
  background: #0e3942;
  box-shadow: 0 8px 20px rgba(2, 15, 21, 0.16);
}

.it-icon-btn:hover,
.it-btn:hover:not(:disabled),
.it-pad:hover:not(:disabled),
.it-type:hover:not(:disabled) {
  border-color: var(--it-teal);
  transform: translateY(-1px);
}

.it-icon-btn:active,
.it-btn:active:not(:disabled),
.it-pad:active:not(:disabled),
.it-type:active:not(:disabled) {
  transform: translateY(1px);
}

.it-icon-btn:focus-visible,
.it-btn:focus-visible,
.it-pad:focus-visible,
.it-type:focus-visible,
.it-canvas:focus-visible,
.it-close:focus-visible {
  outline: 3px solid rgba(98, 221, 202, 0.7);
  outline-offset: 3px;
}

.it-icon-btn:disabled,
.it-btn:disabled,
.it-pad:disabled,
.it-type:disabled {
  cursor: default;
  opacity: 0.5;
}

.it-icon {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.it-stage {
  position: relative;
  min-height: 500px;
  height: min(64vh, 620px);
  overflow: hidden;
  border: 1px solid #3b8586;
  border-radius: 16px;
  background: #0a3e52;
  box-shadow: 0 22px 48px rgba(2, 15, 21, 0.4), inset 0 0 0 1px rgba(188, 245, 230, 0.08), inset 0 -42px 70px rgba(2, 12, 25, 0.26);
  isolation: isolate;
}

.it-stage::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(255, 205, 130, 0.07), transparent 27%, rgba(2, 15, 30, 0.08) 72%, rgba(2, 12, 24, 0.24)), radial-gradient(circle at 52% 48%, rgba(105, 237, 215, 0.05), transparent 58%);
  content: '';
  pointer-events: none;
}

.it-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  outline: none;
  touch-action: none;
  user-select: none;
}

.it-software-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.it-software .it-canvas {
  opacity: 0.001;
}

.it-software .it-stage {
  background: linear-gradient(180deg, #0a2740 0%, #2a7e88 52%, #0b2d4a 100%);
}

.it-stage-top {
  position: absolute;
  top: 12px;
  right: 12px;
  left: 12px;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.it-objective,
.it-decision,
.it-wave-chip,
.it-aim {
  border: 1px solid rgba(182, 241, 232, 0.34);
  background: linear-gradient(145deg, rgba(7, 37, 46, 0.92), rgba(3, 21, 31, 0.88));
  color: #e6fbf5;
  box-shadow: 0 10px 24px rgba(3, 17, 23, 0.3), inset 0 1px 0 rgba(218, 255, 244, 0.06);
  backdrop-filter: blur(7px);
}

.it-stage-copy {
  display: grid;
  min-width: 0;
  gap: 6px;
  max-width: min(70%, 430px);
}

.it-decision {
  width: fit-content;
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  color: #ffd27c;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
}

.it-objective {
  max-width: none;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.25;
}

.it-wave-chip {
  flex: 0 0 auto;
  padding: 9px 11px;
  border-radius: 999px;
  color: var(--it-gold);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.it-aim {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 1;
  max-width: calc(100% - 24px);
  padding: 8px 11px;
  border-radius: 9px;
  color: #baf5e8;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  pointer-events: none;
}
.it-aim-zone {
  position: absolute;
  right: 12px;
  bottom: 52px;
  z-index: 1;
  padding: 7px 10px;
  border: 1px solid rgba(255, 210, 118, 0.55);
  border-radius: 999px;
  background: rgba(48, 43, 22, 0.82);
  color: #ffe19a;
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

.it-aim-zone b {
  color: #fff5c8;
  font-variant-numeric: tabular-nums;
}

.it-reticle {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 156px;
  padding: 5px 8px 5px 5px;
  border: 1px solid rgba(115, 245, 220, 0.8);
  border-radius: 9px;
  background: rgba(4, 25, 32, 0.92);
  color: #eafff8;
  box-shadow: 0 8px 18px rgba(0, 13, 18, 0.4);
  font-size: 10px;
  line-height: 1.2;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 18px));
}

.it-reticle-ring {
  display: block;
  width: 21px;
  height: 21px;
  border: 2px solid #73f5dc;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(115, 245, 220, 0.18), inset 0 0 0 3px rgba(115, 245, 220, 0.18);
}

.it-reticle b,
.it-reticle small {
  display: block;
}

.it-reticle b {
  color: #baffef;
  font-size: 11px;
}

.it-reticle small {
  margin-top: 2px;
  color: #c0d9d5;
  font-size: 9px;
}

.it-load {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  padding: 30px;
  background: radial-gradient(circle at 50% 38%, rgba(43, 129, 134, 0.92), rgba(12, 49, 61, 0.98));
  color: #eafff8;
  text-align: center;
}

.it-load strong {
  font-size: 22px;
}

.it-load small {
  max-width: 390px;
  color: #b5d8d5;
  font-size: 13px;
}

.it-load-ring {
  width: 38px;
  height: 38px;
  margin-bottom: 4px;
  border: 4px solid rgba(255, 255, 255, 0.23);
  border-top-color: #ffca68;
  border-radius: 50%;
  animation: it-spin 900ms linear infinite;
}

.it-reactor-flash {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: radial-gradient(circle at 50% 50%, rgba(224, 65, 65, 0) 35%, rgba(224, 65, 65, 0.66) 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.it-reactor-flash.it-active {
  opacity: 1;
  transition: opacity 35ms ease;
}

.it-damage-number {
  position: absolute;
  z-index: 3;
  color: #fff1c7;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 2px 0 #572d2d, 0 0 10px rgba(255, 209, 124, 0.72);
  transform: translate(-50%, -50%);
}

.it-damage-ice {
  color: #b8f2ff;
  text-shadow: 0 2px 0 #174c68, 0 0 10px rgba(117, 215, 255, 0.8);
}

.it-damage-reactor {
  color: #ffaaa0;
  font-size: 20px;
  text-shadow: 0 2px 0 #641e2b, 0 0 12px rgba(226, 82, 82, 0.86);
}

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

.it-panel {
  min-width: 0;
  padding: 13px;
  border: 1px solid rgba(73, 137, 139, 0.46);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(13, 52, 60, 0.97), rgba(6, 29, 39, 0.97));
  box-shadow: 0 10px 24px rgba(2, 15, 21, 0.24), inset 0 1px 0 rgba(202, 255, 241, 0.04);
}

.it-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.it-panel-head b {
  color: var(--it-teal);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.it-types {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.it-type {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  padding: 7px 8px;
  border-radius: 10px;
  background: var(--it-panel-raised);
  text-align: left;
}

.it-type b,
.it-type small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.it-type b {
  color: var(--it-ink);
  font-size: 12px;
}

.it-type small {
  margin-top: 2px;
  color: var(--it-muted);
  font-size: 10px;
  font-weight: 700;
}

.it-type-icon {
  display: grid;
  flex: 0 0 27px;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-size: 17px;
  font-weight: 900;
}

.it-cannon-icon {
  background: #c55e35;
}

.it-ballista-icon {
  background: #9b7529;
}

.it-ice-icon {
  background: #348caf;
}

.it-type.it-active {
  border-color: var(--it-teal);
  background: #174d51;
  box-shadow: inset 0 0 0 1px rgba(98, 221, 202, 0.24);
}

.it-pads {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 9px;
}

.it-pad {
  padding: 5px 6px;
  border-radius: 9px;
  background: #103b43;
  color: var(--it-muted);
  font-size: 12px;
  text-align: center;
}

.it-pad span {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 650;
}

.it-pad.it-active {
  border-color: var(--it-teal);
  background: #174d51;
  color: var(--it-ink);
}

.it-pad.it-filled::after {
  display: block;
  margin-top: 2px;
  color: var(--cg-green);
  content: 'ARMED';
  font-size: 9px;
  letter-spacing: 0.08em;
}

.it-btn {
  padding: 0 12px;
  border-radius: 9px;
  background: linear-gradient(180deg, #1a4b53, #123840);
  box-shadow: 0 6px 14px rgba(2, 15, 21, 0.2), inset 0 1px 0 rgba(214, 255, 243, 0.05);
  font-size: 12px;
}

.it-primary {
  border-color: transparent;
  background: var(--it-teal);
  color: #06272b;
}

.it-deploy {
  width: 100%;
  margin-top: 9px;
}

.it-brief {
  min-height: 34px;
  margin: 0 0 10px;
  color: var(--it-muted);
  font-size: 12px;
  line-height: 1.4;
}

.it-economy,
.it-ghost-status,
.it-occupancy {
  margin-top: 7px;
  padding: 7px 9px;
  border: 1px solid rgba(98, 221, 202, 0.24);
  border-radius: 8px;
  background: rgba(20, 73, 76, 0.58);
  color: var(--it-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
}

.it-ghost-status {
  border-color: rgba(255, 200, 87, 0.38);
  background: rgba(92, 67, 25, 0.42);
  color: #ffe0a0;
}

.it-occupancy {
  color: var(--it-ink);
}

.it-target-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 8px;
}

.it-threats,
.it-threat-list {
  min-height: 17px;
  color: var(--it-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
}

.it-threats {
  color: #ffd27c;
}
.it-combat-dock {
  display: none;
  gap: 7px;
  margin-top: 10px;
  padding: 9px;
  border: 1px solid var(--it-line);
  border-radius: 12px;
  background: rgba(10, 41, 50, 0.96);
  box-shadow: 0 8px 20px rgba(2, 15, 21, 0.18);
}

.it-dock-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--it-muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.it-dock-label b {
  color: var(--it-teal);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
}

.it-dock-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.it-dock-actions .it-btn {
  min-width: 0;
  padding: 0 6px;
  font-size: 10px;
}

.it-terminal-report {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 10px;
  margin: 2px 0;
  color: var(--it-muted);
  font-size: 10px;
  font-weight: 700;
  text-align: left;
}

.it-terminal-report span {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(98, 221, 202, 0.1);
}

.it-terminal-report b {
  color: var(--it-ink);
  font-variant-numeric: tabular-nums;
}

.it-threat-list {
  overflow: hidden;
  color: var(--it-ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.it-support-actions {
  margin-top: 7px;
}

.it-keyline {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 10px;
  color: var(--it-muted);
  font-size: 10px;
  font-weight: 700;
}

kbd {
  display: inline-block;
  min-width: 19px;
  margin: 0 1px;
  padding: 2px 4px;
  border: 1px solid #45666b;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #173f47;
  color: var(--it-ink);
  font: inherit;
  font-size: 9px;
  line-height: 1.1;
  text-align: center;
}

.it-collect:not(:disabled) {
  border-color: var(--it-gold);
  color: #ffe0a0;
}

.it-result {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 5;
  display: grid;
  width: min(88%, 360px);
  gap: 8px;
  padding: 23px;
  border: 1px solid #47747a;
  border-radius: 15px;
  background: rgba(7, 31, 41, 0.97);
  box-shadow: 0 26px 70px rgba(2, 14, 20, 0.58);
  color: var(--it-ink);
  text-align: center;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(8px);
}

.it-result strong {
  color: var(--it-ink);
  font-size: 31px;
  line-height: 1;
}

.it-result p {
  margin: 0;
  color: var(--it-muted);
  font-size: 13px;
  line-height: 1.35;
}

.it-final-score {
  color: var(--it-teal);
  font-size: 40px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  line-height: 1;
}

.it-result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 4px;
}

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

.it-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  padding: 18px;
  place-items: center;
  background: rgba(4, 22, 28, 0.68);
  backdrop-filter: blur(4px);
}

.it-dialog {
  position: relative;
  width: min(100%, 520px);
  padding: 25px;
  border: 1px solid #47747a;
  border-radius: 16px;
  background: #0a2932;
  box-shadow: 0 28px 80px rgba(3, 15, 20, 0.5);
  color: var(--it-ink);
}

.it-dialog h2 {
  margin: 7px 0 13px;
  color: var(--it-ink);
  font-size: 28px;
  line-height: 1;
}

.it-dialog p {
  margin: 9px 0;
  color: var(--it-muted);
  font-size: 13px;
  line-height: 1.5;
}

.it-close {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 0;
  border-radius: 50%;
  background: #16414a;
  color: var(--it-ink);
  font-size: 24px;
  line-height: 1;
}

.it-modal-done {
  width: 100%;
  margin-top: 8px;
}

@keyframes it-spin {
  to { transform: rotate(360deg); }
}

@media (hover: hover) and (pointer: fine) {
  .it-combat-dock {
    display: none !important;
  }
}

@media (pointer: coarse) {
  .it-btn,
  .it-icon-btn,
  .it-pad,
  .it-type {
    min-height: 48px;
  }
  .it-shell[data-state="combat"] .it-foundry,
  .it-shell[data-state="won"] .it-foundry,
  .it-shell[data-state="lost"] .it-foundry,
  .it-shell[data-state="combat"] .it-battle,
  .it-shell[data-state="won"] .it-battle,
  .it-shell[data-state="lost"] .it-battle {
    display: none;
  }

  .it-shell[data-state="combat"] .it-combat-dock {
    display: grid;
  }

  .it-dock-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .it-shell[data-state="prep"] #it-deploy:not(:disabled),
  .it-shell[data-state="prep"] #it-start,
  .it-shell[data-state="prep"] #it-upgrade:not(:disabled),
  .it-shell[data-state="prep"] #it-collect:not(:disabled) {
    position: fixed;
    z-index: 20;
    bottom: 12px;
    width: calc(50% - 18px);
    max-width: 180px;
    box-shadow: 0 12px 28px rgba(2, 15, 21, 0.42);
  }

  .it-shell[data-state="prep"] #it-deploy,
  .it-shell[data-state="prep"] #it-upgrade {
    left: 12px;
  }

  .it-shell[data-state="prep"] #it-start,
  .it-shell[data-state="prep"] #it-collect {
    right: 12px;
  }

  .it-shell[data-state="prep"] #it-upgrade:not(:disabled),
  .it-shell[data-state="prep"] #it-collect:not(:disabled) {
    bottom: 68px;
  }
}

@media (max-width: 700px) {
  .it-shell {
    padding: 0 8px 18px;
    border-radius: 14px;
  }
  .it-topbar {
    gap: 6px;
  }

  .it-stats {
    flex: 1 1 auto;
    gap: 4px;
  }

  .it-actions {
    gap: 4px;
  }

  .it-stat {
    min-width: 0;
    flex: 1 1 0;
    padding: 6px 3px;
  }

  .it-stat span {
    font-size: 8.5px;
    letter-spacing: 0.04em;
  }

  .it-stat strong {
    font-size: 15px;
  }

  .it-icon-btn {
    padding: 0 9px;
  }

  .it-stage {
    min-height: 410px;
    height: 58vh;
    max-height: 560px;
    border-radius: 13px;
  }

  .it-stage-top {
    top: 8px;
    right: 8px;
    left: 8px;
  }

  .it-objective {
    max-width: 68%;
    padding: 7px 9px;
    font-size: 10px;
  }

  .it-wave-chip {
    padding: 7px 8px;
    font-size: 9px;
  }

  .it-aim {
    right: 8px;
    bottom: 8px;
    left: 8px;
    max-width: none;
    font-size: 10px;
  }

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

  .it-panel {
    padding: 11px;
  }

  .it-type {
    gap: 4px;
    padding: 6px 5px;
  }

  .it-type-icon {
    flex-basis: 23px;
    width: 23px;
    height: 23px;
    font-size: 14px;
  }

  .it-type b {
    font-size: 11px;
  }

  .it-type small {
    font-size: 9px;
  }

  .it-dialog {
    padding: 21px 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .it-reactor-flash,
  .it-load-ring,
  .it-damage-number {
    animation: none;
    transition: none;
  }
}
