:root {
  --bg: #050711;
  --panel-bg: rgba(10, 15, 32, 0.86);
  --card-bg: rgba(15, 22, 46, 0.72);
  --border: rgba(56, 232, 255, 0.28);
  --border-bright: rgba(56, 232, 255, 0.72);
  --cyan: #38e8ff;
  --amber: #ffb84d;
  --crimson: #ff3b6b;
  --violet: #c56bff;
  --emerald: #4eff9f;
  --text: #eaf3ff;
  --muted: #8ea1c4;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 25%, #121c3d 0%, #070b1a 48%, #04060e 100%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#app-shell {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 10px 18px;
}

.side-panel {
  width: 268px;
  max-height: calc(100vh - 20px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow:
    0 0 28px rgba(10, 140, 255, 0.12),
    inset 0 0 20px rgba(56, 232, 255, 0.05);
  overflow-y: auto;
}

.panel-header h1 {
  font-size: 1.55rem;
  letter-spacing: 0.14em;
  color: #fff;
  text-shadow: 0 0 14px rgba(56, 232, 255, 0.65);
  margin-top: 4px;
}

.subtitle {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--cyan);
  margin-top: 2px;
}

.badge-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(56, 232, 255, 0.14);
  border: 1px solid rgba(56, 232, 255, 0.45);
  color: var(--cyan);
}

.badge-tag.amber {
  background: rgba(255, 184, 77, 0.14);
  border-color: rgba(255, 184, 77, 0.48);
  color: var(--amber);
}

.panel-card {
  background: var(--card-bg);
  border: 1px solid rgba(110, 150, 220, 0.22);
  border-radius: 8px;
  padding: 10px 11px;
}

.panel-card h2 {
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  color: var(--cyan);
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(56, 232, 255, 0.16);
  padding-bottom: 4px;
}

.weapon-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.weapon-list li {
  display: flex;
  align-items: center;
  gap: 9px;
}

.weapon-list strong {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: #fff;
}

.weapon-list span {
  display: block;
  font-size: 0.69rem;
  color: var(--muted);
}

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-weight: 800;
  font-size: 0.78rem;
  color: #fff;
  flex-shrink: 0;
}

.swatch-vulcan { background: linear-gradient(135deg, #ff3b4d, #ff8f29); box-shadow: 0 0 10px rgba(255, 80, 60, 0.55); }
.swatch-laser { background: linear-gradient(135deg, #2b8cff, #48f4ff); box-shadow: 0 0 10px rgba(60, 200, 255, 0.55); }
.swatch-plasma { background: linear-gradient(135deg, #983bff, #ff56e8); box-shadow: 0 0 10px rgba(210, 90, 255, 0.55); }
.swatch-n { background: linear-gradient(135deg, #ff6c2b, #ffd24d); }
.swatch-h { background: linear-gradient(135deg, #1fd1a5, #47e8ff); }
.swatch-r { background: linear-gradient(135deg, #5d7bff, #b975ff); }

.panel-note {
  font-size: 0.74rem;
  line-height: 1.45;
  color: #c7d6f2;
}

.accent-gold {
  color: var(--amber);
}

.key-grid, .telemetry-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  font-size: 0.73rem;
}

.key-grid dt, .telemetry-grid dt {
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: 0.04em;
}

.key-grid dd, .telemetry-grid dd {
  color: #f3f7ff;
  text-align: right;
  font-weight: 600;
}

.score-block {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.metric-value {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 0 12px rgba(56, 232, 255, 0.45);
}

.metric-value.gold {
  color: var(--amber);
  text-shadow: 0 0 14px rgba(255, 184, 77, 0.5);
}

.arm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}

.arm-row:last-child {
  margin-bottom: 0;
}

.arm-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.arm-badge {
  font-family: ui-monospace, monospace;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.arm-badge.vulcan { background: rgba(255, 70, 70, 0.22); border-color: rgba(255, 110, 70, 0.65); color: #ffba82; }
.arm-badge.laser { background: rgba(45, 170, 255, 0.22); border-color: rgba(70, 225, 255, 0.65); color: #8ff3ff; }
.arm-badge.plasma { background: rgba(180, 70, 255, 0.24); border-color: rgba(225, 120, 255, 0.7); color: #f0b3ff; }
.arm-badge.sub { background: rgba(90, 230, 175, 0.16); border-color: rgba(90, 230, 175, 0.45); color: #8dffcf; }

.boss-status {
  font-family: ui-monospace, monospace;
  font-size: 0.76rem;
  padding: 7px 9px;
  border-radius: 6px;
  background: rgba(56, 232, 255, 0.08);
  border: 1px solid rgba(56, 232, 255, 0.24);
  color: #cfe8ff;
}

.boss-status.alert {
  background: rgba(255, 45, 85, 0.22);
  border-color: rgba(255, 75, 115, 0.78);
  color: #ffd0d9;
  box-shadow: 0 0 14px rgba(255, 45, 85, 0.35);
}

.switch-stack {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.switch-btn {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(110, 160, 240, 0.34);
  background: rgba(20, 30, 62, 0.78);
  color: #dce9ff;
  font-family: ui-monospace, monospace;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.switch-btn:hover {
  border-color: var(--cyan);
  background: rgba(34, 52, 98, 0.9);
}

.switch-btn.active {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(56, 232, 255, 0.3);
  color: #fff;
}

#stage-wrap {
  position: relative;
  height: min(calc(100vh - 16px), 960px);
  aspect-ratio: 3 / 4;
  max-width: calc(100vw - 16px);
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid rgba(110, 118, 134, 0.28);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 12px 48px rgba(0, 0, 0, 0.85);
  background: #02040a;
  flex-shrink: 0;
  touch-action: none;
}

#gl-canvas,
#hud-canvas,
#ui-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#gl-canvas {
  display: block;
}

#hud-canvas {
  display: block;
  pointer-events: none;
}

#ui-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.screen-panel {
  display: none;
  width: 100%;
  height: 100%;
  padding: 24px 20px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: auto;
  background: radial-gradient(circle at 50% 35%, rgba(8, 16, 42, 0.56), rgba(4, 7, 18, 0.78));
  backdrop-filter: blur(2px);
}

.screen-panel.active {
  display: flex;
}

.title-emblem {
  text-align: center;
  margin-bottom: 4px;
}

.title-kicker {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(56, 232, 255, 0.8);
}

.title-main {
  font-size: clamp(2.5rem, 6vw, 3.6rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1.05;
  color: #ffffff;
  text-shadow:
    0 0 18px rgba(56, 232, 255, 0.85),
    0 0 38px rgba(255, 65, 110, 0.55),
    0 4px 0 #16264d;
  margin: 4px 0;
}

.title-num {
  color: var(--amber);
  text-shadow:
    0 0 20px rgba(255, 184, 77, 0.95),
    0 0 42px rgba(255, 70, 50, 0.75);
}

.title-sub {
  font-size: 0.84rem;
  letter-spacing: 0.22em;
  color: #d6e6ff;
  opacity: 0.92;
}

.select-group {
  width: 100%;
  max-width: 400px;
}

.select-label {
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--cyan);
  margin-bottom: 6px;
  text-align: center;
}

.card-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.select-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  padding: 10px 11px;
  border-radius: 8px;
  border: 1px solid rgba(110, 165, 255, 0.34);
  background: rgba(11, 19, 44, 0.86);
  color: #eef5ff;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}

.select-card:hover {
  transform: translateY(-1px);
  border-color: var(--cyan);
}

.select-card.selected {
  border-color: var(--amber);
  background: linear-gradient(155deg, rgba(24, 42, 86, 0.94), rgba(50, 24, 42, 0.88));
  box-shadow: 0 0 18px rgba(255, 184, 77, 0.38);
}

.card-code {
  font-family: ui-monospace, monospace;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--amber);
}

.card-name {
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.card-meta {
  font-size: 0.65rem;
  color: var(--muted);
}

.pill-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pill-btn {
  padding: 8px 6px;
  border-radius: 6px;
  border: 1px solid rgba(110, 165, 255, 0.34);
  background: rgba(11, 19, 44, 0.86);
  color: #cde0ff;
  font-family: ui-monospace, monospace;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pill-btn.selected {
  border-color: var(--cyan);
  background: rgba(20, 62, 108, 0.92);
  color: #fff;
  box-shadow: 0 0 14px rgba(56, 232, 255, 0.42);
}

.toggle-row {
  display: flex;
  justify-content: center;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(56, 232, 255, 0.35);
  background: rgba(10, 22, 48, 0.82);
  font-family: ui-monospace, monospace;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.toggle-chip input {
  accent-color: var(--cyan);
}

.asset-loader {
  width: min(100%, 340px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(56, 232, 255, 0.34);
  background: rgba(8, 15, 34, 0.88);
  box-shadow: inset 0 0 14px rgba(56, 232, 255, 0.08);
  transition: border-color 0.25s, opacity 0.25s;
}

.asset-loader.ready {
  border-color: rgba(109, 255, 143, 0.55);
}

.loader-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #8eeeff;
}

.asset-loader.ready .loader-header {
  color: #88ffaa;
}

.loader-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.loader-bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #28c8ff 0%, #58f0ff 60%, #ffd04d 100%);
  box-shadow: 0 0 10px rgba(56, 232, 255, 0.75);
  transition: width 0.12s ease-out;
}

.asset-loader.ready .loader-bar {
  background: linear-gradient(90deg, #32e88a 0%, #7dffb0 100%);
  box-shadow: 0 0 10px rgba(109, 255, 143, 0.75);
}

.cta-btn {
  min-width: 230px;
  padding: 13px 26px;
  border: 1px solid rgba(255, 220, 140, 0.85);
  border-radius: 8px;
  background: linear-gradient(135deg, #ff3b6b 0%, #ff8b2b 52%, #ffd04d 100%);
  color: #0b0d18;
  font-family: ui-monospace, monospace;
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  cursor: pointer;
  box-shadow:
    0 0 24px rgba(255, 115, 70, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.12s, box-shadow 0.15s, filter 0.15s;
}

.cta-btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  filter: grayscale(0.65);
  box-shadow: none;
  transform: none;
  border-color: rgba(130, 160, 210, 0.35);
  background: linear-gradient(135deg, #26324d 0%, #344466 100%);
  color: #a6bbd8;
}

.cta-btn:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.015);
  filter: brightness(1.08);
  box-shadow: 0 0 32px rgba(255, 165, 70, 0.85);
}

.ghost-btn {
  min-width: 230px;
  padding: 10px 18px;
  border-radius: 7px;
  border: 1px solid rgba(110, 175, 255, 0.45);
  background: rgba(14, 24, 52, 0.88);
  color: #e4f0ff;
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  cursor: pointer;
}

.ghost-btn:hover {
  border-color: var(--cyan);
  background: rgba(24, 40, 82, 0.94);
}

.title-hint {
  font-family: ui-monospace, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-align: center;
}

.touch-bomb-btn {
  position: absolute;
  right: 14px;
  bottom: 54px;
  z-index: 25;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(71, 240, 255, 0.85);
  background: radial-gradient(circle at 35% 30%, rgba(71, 240, 255, 0.34), rgba(8, 22, 48, 0.78));
  box-shadow:
    0 0 18px rgba(56, 232, 255, 0.48),
    inset 0 0 10px rgba(255, 245, 207, 0.25);
  color: #fff5cf;
  font-family: ui-monospace, monospace;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.08s, opacity 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.touch-bomb-btn.visible {
  display: flex;
}

.touch-bomb-btn:active {
  transform: scale(0.90);
  box-shadow: 0 0 28px rgba(255, 195, 70, 0.85);
  border-color: #ffd04d;
}

.touch-bomb-btn.empty {
  opacity: 0.34;
  border-color: rgba(120, 150, 200, 0.4);
  box-shadow: none;
}

.touch-bomb-label {
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  line-height: 1;
}

.touch-bomb-count {
  font-size: 0.88rem;
  font-weight: 900;
  color: #47f0ff;
  line-height: 1.1;
}

.touch-bomb-btn.empty .touch-bomb-count {
  color: #889ab8;
}

.modal-box {
  width: min(90%, 360px);
  padding: 22px 20px;
  border-radius: 10px;
  border: 1px solid var(--border-bright);
  background: rgba(9, 15, 34, 0.94);
  box-shadow: 0 0 36px rgba(56, 232, 255, 0.25);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-box.danger {
  border-color: rgba(255, 65, 110, 0.75);
  box-shadow: 0 0 36px rgba(255, 45, 95, 0.35);
}

.modal-box.gold {
  border-color: rgba(255, 195, 75, 0.82);
  box-shadow: 0 0 36px rgba(255, 184, 77, 0.38);
}

.modal-kicker {
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  color: var(--cyan);
}

.modal-box.danger .modal-kicker { color: var(--crimson); }
.modal-box.gold .modal-kicker { color: var(--amber); }

.modal-box h2 {
  font-size: 1.55rem;
  letter-spacing: 0.12em;
  color: #fff;
}

.stat-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 12px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 7px;
  background: rgba(16, 26, 54, 0.78);
  border: 1px solid rgba(100, 150, 230, 0.2);
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
}

.stat-list dt { color: var(--muted); }
.stat-list dd { text-align: right; font-weight: 700; color: #fff; }

.modal-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}

@media (max-width: 1019px) {
  .side-panel {
    display: none;
  }
  #app-shell {
    padding: 4px;
    gap: 0;
  }
  #stage-wrap {
    height: min(calc(100vh - 8px), calc((100vw - 8px) * 4 / 3));
  }
}

.pill-btn:disabled {
  opacity: 0.36;
  cursor: not-allowed;
  pointer-events: none;
}
