/* 3D combat cinematic overlay. Full-screen, self-contained (covers chrome). */
.combat-cine {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: #04060d;
  display: none;
  overflow: hidden;
  touch-action: none;
}
.combat-cine.is-active { display: block; }
body.ccine-open { overflow: hidden; }

.combat-cine-webgl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* fade-in from black on entry */
.ccine-fade {
  position: absolute;
  inset: 0;
  background: #02030a;
  pointer-events: none;
  opacity: 1;
  animation: ccine-fade-in 1.4s ease-out forwards;
}
@keyframes ccine-fade-in { from { opacity: 1; } to { opacity: 0; } }

/* caption top-left */
.ccine-caption {
  position: absolute;
  top: calc(max(14px, env(safe-area-inset-top)) + 46px);
  left: 16px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #cfe6ff;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.9), 0 0 18px rgba(80, 150, 255, 0.4);
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(8, 14, 26, 0.55);
  pointer-events: none;
  max-width: 70vw;
}

/* exit top-right */
.ccine-exit {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(120, 170, 230, 0.35);
  background: rgba(10, 16, 28, 0.7);
  color: #bcd6f5;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.ccine-exit:hover { background: rgba(20, 30, 48, 0.9); color: #fff; }

/* live per-side ship counts in the top corners (holographic) */
.ccine-count {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  z-index: 6;
  font: 600 11px/1.15 ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0.95;
}
.ccine-count .lbl { display: block; font-size: 10px; opacity: 0.72; }
.ccine-count .who { display: block; max-width: 34vw; margin-top: 1px; font-size: 12px; font-weight: 700; letter-spacing: 0.02em; text-transform: none; opacity: 0.96; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccine-count .n { font-size: 22px; font-weight: 700; line-height: 1.05; }
.ccine-integrity { display: grid; gap: 3px; width: clamp(126px, 18vw, 210px); margin-top: 5px; }
.ccine-count-def .ccine-integrity { margin-left: auto; }
.ccine-meter { display: grid; grid-template-columns: 28px minmax(64px, 1fr) 31px; align-items: center; gap: 5px; font-size: 8px; line-height: 1; letter-spacing: 0.04em; color: #d9eaff; text-shadow: 0 1px 3px #000; }
.ccine-meter-track { position: relative; height: 4px; overflow: hidden; border: 1px solid rgba(205, 231, 255, 0.24); border-radius: 999px; background: rgba(4, 11, 23, 0.72); box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.8); }
.ccine-meter-track i { display: block; width: var(--integrity, 0%); height: 100%; border-radius: inherit; transition: width 120ms linear; }
.ccine-meter-shield .ccine-meter-track i { background: linear-gradient(90deg, #278cff, #9fe8ff); box-shadow: 0 0 7px #58baff; }
.ccine-meter-hull .ccine-meter-track i { background: linear-gradient(90deg, #ff4c55, #ffd06a); box-shadow: 0 0 7px rgba(255, 115, 70, 0.9); }
.ccine-meter b { min-width: 31px; font-size: 8px; font-weight: 700; text-align: right; }
.ccine-count-def .ccine-meter { grid-template-columns: 31px minmax(64px, 1fr) 28px; }
.ccine-count-def .ccine-meter-lbl { grid-column: 3; grid-row: 1; text-align: right; }
.ccine-count-def .ccine-meter-track { grid-column: 2; grid-row: 1; }
.ccine-count-def .ccine-meter b { grid-column: 1; grid-row: 1; text-align: left; }
.ccine-meter.is-empty { opacity: 0.48; }
.ccine-count.is-shield-hit { filter: drop-shadow(0 0 8px rgba(94, 196, 255, 0.95)); }
.ccine-count.is-hit { filter: drop-shadow(0 0 9px rgba(255, 83, 61, 0.95)); }
.ccine-count.is-shield-hit .ccine-meter-shield,
.ccine-count.is-hit .ccine-meter-hull { color: #fff; transform: scale(1.025); transform-origin: center; }
.ccine-count-atk { left: 16px; text-align: left; color: #ffd83a; text-shadow: 0 0 13px rgba(255, 208, 0, 0.65), 0 1px 4px rgba(0, 0, 0, 0.9); }
.ccine-count-def { right: 58px; text-align: right; color: #5aa0ff; text-shadow: 0 0 13px rgba(43, 123, 255, 0.7), 0 1px 4px rgba(0, 0, 0, 0.9); }

/* battle location, centred between the two side panels */
.ccine-place {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  max-width: 38vw;
  text-align: center;
  font: 600 12px/1.2 ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #cfe6ff;
  text-shadow: 0 0 12px rgba(80, 150, 255, 0.5), 0 1px 4px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ccine-place::before { content: "\25C9"; margin-right: 6px; opacity: 0.75; }
.ccine-place[hidden] { display: none; }

/* transport bar bottom */
.ccine-transport {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(680px, calc(100vw - 28px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(8, 13, 24, 0.82);
  border: 1px solid rgba(110, 160, 220, 0.22);
}
.ccine-tbtn {
  flex: 0 0 auto;
  min-width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid rgba(120, 170, 230, 0.25);
  background: rgba(16, 24, 40, 0.85);
  color: #cfe2ff;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ccine-tbtn:hover { background: rgba(28, 42, 66, 0.95); color: #fff; }
.ccine-speed { font-weight: 600; font-size: 0.82rem; }
.ccine-shot { font-weight: 600; font-size: 0.72rem; padding: 0 10px; letter-spacing: 0.04em; text-transform: uppercase; }
.ccine-shot.is-active { color: #9fffe6; border-color: rgba(120, 255, 214, 0.45); background: rgba(14, 40, 34, 0.85); }
.ccine-scrub {
  flex: 1 1 auto;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: linear-gradient(90deg, #4f9bff, #7ad0ff);
  border-radius: 3px;
  cursor: pointer;
}
.ccine-scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #eaf4ff;
  box-shadow: 0 0 8px rgba(110, 180, 255, 0.8);
  cursor: pointer;
}
.ccine-scrub::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #eaf4ff;
  border: none;
}
.ccine-time {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: #8fb0d8;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* end-of-battle CTA */
.ccine-report-cta {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 58px);
}
.ccine-btn {
  padding: 11px 22px;
  border-radius: 12px;
  border: 1px solid rgba(120, 170, 230, 0.4);
  background: rgba(14, 22, 38, 0.92);
  color: #dceaff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}
.ccine-btn-primary {
  background: linear-gradient(135deg, #2b6fd6, #3aa0e8);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 22px rgba(40, 110, 210, 0.45);
}
.ccine-btn:hover { filter: brightness(1.08); }

/* choice modal: 3D cinematic OR killmail */
.ccine-choice-overlay {
  position: fixed;
  inset: 0;
  z-index: 4100;
  background: rgba(3, 6, 14, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ccine-choice-box {
  position: relative;
  width: min(420px, 92vw);
  padding: 26px 22px 24px;
  border-radius: 18px;
  background: rgba(11, 17, 30, 0.97);
  border: 1px solid rgba(120, 170, 230, 0.28);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
}
.ccine-choice-title {
  margin: 0 0 18px;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  color: #dcebff;
  color: #d7e7ff;
  text-transform: uppercase;
}
.ccine-choice-opts { display: flex; flex-direction: column; gap: 12px; }
.ccine-choice-btn {
  padding: 16px 18px;
  border-radius: 13px;
  border: 1px solid rgba(120, 170, 230, 0.3);
  background: rgba(18, 27, 46, 0.9);
  color: #dceaff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.ccine-choice-3d {
  background: linear-gradient(135deg, #2b6fd6, #3aa0e8);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 26px rgba(40, 110, 210, 0.4);
}
.ccine-choice-ic { font-size: 0.85rem; }
.ccine-choice-btn:hover { filter: brightness(1.08); }
.ccine-choice-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #8fb0d8;
  font-size: 0.95rem;
  cursor: pointer;
}
.ccine-choice-close:hover { color: #fff; }

@media (max-width: 480px) {
  .ccine-caption { font-size: 0.85rem; }
  .ccine-transport { gap: 7px; padding: 7px 9px; }
  .ccine-time { display: none; }
  .ccine-count .who { max-width: 26vw; font-size: 11px; }
  .ccine-integrity { width: min(32vw, 142px); }
  .ccine-meter { grid-template-columns: 23px minmax(42px, 1fr) 28px; gap: 3px; }
  .ccine-count-def .ccine-meter { grid-template-columns: 28px minmax(42px, 1fr) 23px; }
  .ccine-meter b, .ccine-meter { font-size: 7px; }
  .ccine-place { max-width: 30vw; font-size: 10px; letter-spacing: 0.08em; }
}

/* admin test-battle composer */
.ccsim-overlay {
  position: fixed;
  inset: 0;
  z-index: 4200;
  background: rgba(3, 6, 14, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.ccsim-box {
  width: min(760px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: rgba(11, 17, 30, 0.98);
  border: 1px solid rgba(120, 170, 230, 0.28);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.ccsim-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
}
.ccsim-head h3 { margin: 0; font-size: 1.05rem; letter-spacing: 0.05em; color: #dcebff; text-transform: uppercase; }
.ccsim-x { width: 30px; height: 30px; border: none; background: transparent; color: #8fb0d8; font-size: 1rem; cursor: pointer; }
.ccsim-x:hover { color: #fff; }
.ccsim-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 0 16px; overflow: hidden; }
.ccsim-col { display: flex; flex-direction: column; min-height: 0; }
.ccsim-coltitle { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; padding: 6px 8px; border-radius: 8px; margin-bottom: 8px; text-align: center; }
.ccsim-atk { color: #ffb070; background: rgba(255, 140, 60, 0.12); }
.ccsim-def { color: #70c0ff; background: rgba(70, 150, 255, 0.12); }
.ccsim-ctrls { display: flex; gap: 8px; margin-bottom: 8px; }
.ccsim-ctrl { flex: 1; display: flex; flex-direction: column; gap: 3px; font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: #8fb0d8; }
.ccsim-ctrl input, .ccsim-ctrl select, .ccsim-qty {
  background: rgba(20, 30, 48, 0.9);
  border: 1px solid rgba(120, 170, 230, 0.25);
  border-radius: 7px;
  color: #e6f0ff;
  padding: 6px 8px;
  font-size: 0.85rem;
}
.ccsim-list { flex: 1; overflow-y: auto; padding-right: 4px; display: flex; flex-direction: column; gap: 4px; min-height: 180px; }
.ccsim-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 6px; border-radius: 7px; }
.ccsim-row:hover { background: rgba(120, 170, 230, 0.08); }
.ccsim-name { font-size: 0.82rem; color: #cdddf2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccsim-qty { width: 76px; flex: 0 0 auto; text-align: right; }
.ccsim-sub { margin: 8px 0 2px; font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: #6f8db0; border-top: 1px solid rgba(120, 170, 230, 0.15); padding-top: 8px; }
.ccsim-msg { min-height: 18px; padding: 4px 18px 0; font-size: 0.8rem; color: #ffcf6e; text-align: center; }
.ccsim-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px 16px; }
.ccsim-templates { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 2px 18px 8px; }
.ccsim-tpl-lbl { font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase; color: #6f8db0; margin-right: 2px; }
.ccsim-tpl {
  background: rgba(20, 30, 48, 0.9);
  border: 1px solid rgba(120, 170, 230, 0.25);
  border-radius: 999px;
  color: #cdddf2;
  padding: 4px 11px;
  font-size: 0.72rem;
  cursor: pointer;
}
.ccsim-tpl:hover { border-color: rgba(120, 170, 230, 0.6); color: #fff; background: rgba(70, 150, 255, 0.14); }

@media (max-width: 560px) {
  .ccsim-cols { grid-template-columns: 1fr; overflow-y: auto; }
}

/* V2/V3 comparator table (admin test modal) */
.ccsim-engine-ctrl { margin-left: auto; }
.ccsim-results { padding: 0 18px 14px; }
.ccsim-cmp { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.ccsim-cmp th, .ccsim-cmp td { text-align: left; padding: 0.32rem 0.5rem; border-bottom: 1px solid rgba(120, 150, 200, 0.18); }
.ccsim-cmp thead th { color: #9db4d8; font-weight: 600; }
.ccsim-cmp td:first-child { color: #9db4d8; }
.ccsim-cmp-note { margin-top: 0.4rem; font-size: 0.76rem; color: rgba(170, 190, 220, 0.7); }

/* hover/tap unit inspector */
.ccine-tip {
  position: absolute; z-index: 30; pointer-events: none;
  min-width: 132px; max-width: 240px;
  padding: 7px 10px; border-radius: 8px;
  background: rgba(8, 14, 26, 0.94);
  border: 1px solid rgba(120, 170, 230, 0.45);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
  color: #dce8f7; font-size: 0.78rem; line-height: 1.3;
}
.ccine-tip[hidden] { display: none; }
.ccine-tip-name { font-weight: 700; color: #fff; font-size: 0.86rem; }
.ccine-tip-kind { font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; margin: 1px 0 4px; }
.ccine-tip-kind.is-atk { color: #ffb38a; }
.ccine-tip-kind.is-def { color: #8fd0ff; }
.ccine-tip-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; color: #9db4d8; font-size: 0.74rem; }
.ccine-tip-stats b { color: #eaf2ff; font-weight: 600; }
