/* Red Team Demo — mobile-first */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

html,
body {
  height: 100%;
}

body {
  background: #04091a;
  color: #c9d6f0;
  font-family: "Courier New", Courier, monospace;
  line-height: 1.5;
  overflow-x: hidden;
}

#root {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 12px 20px;
}

/* ── Main stage: arena + agent panel ── */
.main-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

.main-stage__arena {
  min-width: 0;
}

.main-stage__arena .arena-wrap {
  margin-bottom: 0;
}

/* ── Header (mobile: stacked) ── */
.header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 14px;
}

.title {
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.3;
}

.title-red {
  color: #f87171;
  font-weight: bold;
}

.title-vs {
  color: #4a6080;
  margin: 0 0.4em;
  font-weight: normal;
}

.title-blue {
  color: #34d399;
  font-weight: bold;
}

.scoreboard {
  display: flex;
  justify-content: space-around;
  gap: 16px;
  width: 100%;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.score-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: #4a6080;
  text-transform: uppercase;
}

.score-value {
  font-size: 26px;
  font-weight: bold;
}

.score-attacks .score-value {
  color: #f87171;
}

.score-blocks .score-value {
  color: #34d399;
}

/* ── Controls ── */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

.scenario-field {
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scenario-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7a9cc8;
}

.scenario-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.scenario-row .scenario-input {
  flex: 1;
  min-width: 0;
}

.scenario-run {
  flex: 0 0 auto;
  min-width: 96px;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 11px;
}

.scenario-preview {
  font-size: 10px;
  color: #7a9cc8;
  line-height: 1.4;
}

.scenario-input {
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #1a3050;
  background: #060e20;
  color: #c9d6f0;
}

.scenario-input:focus {
  outline: none;
  border-color: #34d399;
}

.scenario-input:disabled {
  opacity: 0.55;
}

.scenario-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scenario-hint {
  font-family: inherit;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #1a3050;
  background: #0a1528;
  color: #7a9cc8;
  cursor: pointer;
}

.scenario-hint:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.scenario-error,
.demo-exhausted {
  font-size: 11px;
  line-height: 1.35;
}

.scenario-error {
  color: #f87171;
}

.demo-exhausted {
  color: #fbbf24;
}

.demo-exhausted strong {
  color: #fde68a;
  font-weight: bold;
}

.btn-run-demo {
  flex: 1 1 auto;
  min-width: 160px;
}

.btn {
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 20px;
  min-height: 48px;
  min-width: 44%;
  flex: 1 1 44%;
  border: 1px solid #0d1c36;
  background: #060e20;
  color: #7a9cc8;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  border-color: #34d399;
  color: #34d399;
}

.btn-danger {
  border-color: #f87171;
  color: #f87171;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mock-hint {
  flex: 1 1 100%;
  font-size: 10px;
  text-align: center;
  color: #4a6080;
}

.mock-hint-full {
  display: none;
}

/* ── SVG arena ── */
.arena-wrap {
  background: linear-gradient(165deg, #071022 0%, #060e20 48%, #051018 100%);
  border: 1px solid #1a3050;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
  touch-action: manipulation;
  box-shadow:
    inset 0 1px 0 rgba(122, 156, 200, 0.06),
    0 8px 28px rgba(0, 0, 0, 0.35);
  aspect-ratio: 3 / 4;
  max-height: min(58vh, 520px);
}

.arena-wrap svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 300px;
}

.arena-node {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.arena-node-core {
  transition: stroke-width 0.2s ease, r 0.2s ease;
}

.arena-node-halo {
  stroke-width: 1.5;
  opacity: 0.55;
  animation: node-halo 1.6s ease-in-out infinite;
}

.arena-node--lit .arena-node-core {
  filter: brightness(1.08);
}

.arena-node--attack:active .arena-node-core {
  stroke-width: 3;
}

@keyframes node-halo {
  0%,
  100% {
    opacity: 0.3;
    stroke-width: 1;
  }
  50% {
    opacity: 0.75;
    stroke-width: 2;
  }
}

.arena-attack-line {
  transition: stroke 0.75s ease, stroke-width 0.35s ease, opacity 0.3s ease;
}

.arena-attack-line--idle {
  stroke: #2a3d58;
}

.arena-attack-line--attack {
  stroke: #f87171;
}

.arena-attack-line--pending {
  stroke: #4a3050;
}

.arena-attack-line--blocked {
  stroke: #34d399;
}

.arena-defender-line {
  stroke: #1e3a52;
  transition: stroke 0.75s ease;
}

.arena-defender-line--blocked {
  stroke: #34d399;
}

/* ── Agent panel (sidebar on desktop) ── */
.agent-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.agent-panel__head {
  padding: 0 2px;
}

.agent-panel__title {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7a9cc8;
  font-weight: bold;
}

.agent-panel__sub {
  font-size: 10px;
  color: #4a6080;
  margin-top: 2px;
}

.agent-panel__status {
  margin: 0;
  padding: 8px 10px;
  background: #060e20;
  border: 1px solid #0d1c36;
  border-radius: 6px;
  font-size: 11px;
}

.agent-panel__log {
  flex: 1 1 auto;
  min-height: 160px;
  max-height: 38vh;
  max-height: 38dvh;
}

/* ── Orchestration timeline ── */
.orch-timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  list-style: none;
  padding: 8px 10px;
  background: #060e20;
  border: 1px solid #0d1c36;
  border-radius: 6px;
}

.orch-step {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #4a6080;
  padding: 3px 6px;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.orch-step__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1a3050;
  flex-shrink: 0;
}

.orch-step--done {
  color: #34d399;
}

.orch-step--done .orch-step__dot {
  background: #34d399;
}

.orch-step--active {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.08);
}

.orch-step--active .orch-step__dot {
  background: #fbbf24;
  animation: orch-pulse 1s ease-in-out infinite;
}

@keyframes orch-pulse {
  50% {
    transform: scale(1.35);
    opacity: 0.7;
  }
}

/* ── Specialist strip ── */
.specialist-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  background: #060e20;
  border: 1px solid #0d1c36;
  border-radius: 6px;
}

.specialist-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #1a3050;
  color: #4a6080;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.specialist-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  opacity: 0.5;
}

.specialist-chip--primary {
  border-color: #34d399;
  color: #34d399;
  background: rgba(52, 211, 153, 0.08);
}

.specialist-chip--primary .specialist-chip__dot {
  opacity: 1;
}

.specialist-chip--secondary {
  border-color: #38bdf8;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.06);
}

.specialist-chip__tag {
  font-size: 7px;
  opacity: 0.85;
}

.specialist-strip__reason {
  flex: 1 1 100%;
  font-size: 9px;
  color: #4a6080;
  line-height: 1.35;
  margin-top: 2px;
}

/* ── Agent roster ── */
.agent-roster {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding: 6px;
  background: #060e20;
  border: 1px solid #0d1c36;
  border-radius: 6px;
}

.agent-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 4px;
  opacity: 0.45;
  transition: opacity 0.2s, background 0.2s;
}

.agent-card--live {
  opacity: 1;
  background: rgba(122, 156, 200, 0.06);
}

.agent-card--streaming {
  opacity: 1;
  background: rgba(52, 211, 153, 0.07);
}

.agent-card__badge {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: bold;
  border: 1.5px solid;
  border-radius: 50%;
  background: #0a1528;
}

.agent-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.agent-card__name {
  font-size: 10px;
  font-weight: bold;
  color: #c9d6f0;
}

.agent-card__model {
  font-size: 8px;
  color: #4a6080;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-card__pulse,
.agent-card__live {
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.agent-card__pulse {
  color: #34d399;
  animation: blink 0.8s step-end infinite;
}

.agent-card__live {
  color: #fbbf24;
}

.agent-card--attacker.agent-card--live .agent-card__badge {
  border-color: #f87171;
  color: #f87171;
}

.agent-card--orchestrator.agent-card--live .agent-card__badge {
  border-color: #a78bfa;
  color: #a78bfa;
}

/* ── Log ── */
.log-wrap {
  background: #060e20;
  border: 1px solid #0d1c36;
  border-radius: 6px;
  padding: 12px 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.log-empty {
  font-size: 10px;
  color: #4a6080;
  line-height: 1.45;
  margin-bottom: 6px;
}

.log-entry {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  margin-bottom: 6px;
}

.log-entry__agent {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(122, 156, 200, 0.08);
}

.log-title {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #4a6080;
  margin-bottom: 8px;
}

.log-line {
  font-size: 11px;
  margin-bottom: 4px;
  word-break: break-word;
}

.log-line.attack {
  color: #f87171;
}

.log-line.routing {
  color: #fbbf24;
}

.log-line.defense {
  color: #34d399;
}

.log-line.system {
  color: #4a6080;
}

.log-cursor {
  display: inline-block;
  color: #34d399;
  animation: blink 0.8s step-end infinite;
}

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

.status-bar {
  margin-top: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  color: #4a6080;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

.status-bar.active {
  color: #34d399;
}

.status-bar.attack-active {
  color: #f87171;
}

.status-bar.routing,
.status-bar.dispatch,
.status-bar.engage {
  color: #fbbf24;
}

/* ── Mobile (<640px) ── */
@media (max-width: 639px) {
  .app {
    padding: 10px 10px 16px;
  }

  .header {
    gap: 8px;
    margin-bottom: 10px;
  }

  .title {
    font-size: 11px;
  }

  .score-value {
    font-size: 22px;
  }

  .main-stage {
    gap: 10px;
  }

  .arena-wrap {
    aspect-ratio: 9 / 10;
    max-height: min(36vh, 300px);
    margin-bottom: 0;
  }

  .arena-wrap svg {
    min-height: 0;
  }

  .agent-panel__title {
    font-size: 10px;
  }

  .agent-panel__sub {
    font-size: 9px;
  }

  .agent-panel__log {
    min-height: 100px;
    max-height: min(28vh, 220px);
  }

  .scenario-hints {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .scenario-hints::-webkit-scrollbar {
    display: none;
  }

  .scenario-hint {
    flex-shrink: 0;
    min-height: 36px;
    padding: 8px 10px;
  }

  .specialist-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .specialist-strip::-webkit-scrollbar {
    display: none;
  }

  .specialist-chip {
    flex-shrink: 0;
  }

  .btn {
    min-height: 44px;
  }

  .orch-step {
    font-size: 8px;
    padding: 4px 5px;
  }
}

/* ── Tablet ── */
@media (min-width: 640px) {
  .app {
    padding: 20px 18px 28px;
    max-width: 1180px;
  }

  .main-stage {
    display: grid;
    grid-template-columns: minmax(0, 720px) minmax(300px, 360px);
    gap: 12px;
    align-items: start;
    justify-content: center;
    width: 100%;
  }

  .main-stage__arena {
    flex: unset;
    width: 100%;
    max-width: 720px;
  }

  .agent-panel {
    flex: unset;
    width: 100%;
    max-width: 360px;
    max-height: min(72vh, 560px);
  }

  .agent-panel__log {
    max-height: none;
    min-height: 180px;
    flex: 1 1 auto;
  }

  .header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
  }

  .title {
    font-size: 15px;
    letter-spacing: 0.08em;
    text-align: left;
  }

  .arena-wrap {
    aspect-ratio: 18 / 10;
    max-height: min(48vh, 400px);
    width: 100%;
    max-width: 720px;
  }

  .arena-wrap svg {
    min-height: 0;
  }

  .scoreboard {
    justify-content: flex-end;
    width: auto;
    gap: 24px;
  }

  .score-value {
    font-size: 22px;
  }

  .controls {
    margin-bottom: 16px;
  }

  .btn {
    flex: 0 1 auto;
    min-width: auto;
    min-height: auto;
    padding: 8px 18px;
    font-size: 12px;
  }

  .mock-hint {
    flex: 0 1 auto;
    text-align: left;
  }

  .mock-hint-full {
    display: inline;
  }
}

/* ── Desktop ── */
@media (min-width: 960px) {
  .app {
    padding: 24px 20px 32px;
    max-width: min(1280px, 97vw);
  }

  .main-stage {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
    gap: 16px;
  }

  .main-stage__arena {
    max-width: none;
  }

  .agent-panel {
    max-width: 400px;
  }

  .arena-wrap {
    max-height: min(52vh, 440px);
    aspect-ratio: 18 / 10;
  }

  .title {
    font-size: 16px;
  }

  .scenario-label {
    font-size: 11px;
  }

  .scenario-input {
    font-size: 14px;
  }

  .log-line {
    font-size: 12px;
  }

  .log-entry__agent {
    font-size: 10px;
  }

  .orch-step {
    font-size: 9px;
  }

  .btn {
    font-size: 12px;
  }

  .btn:hover {
    border-color: #1a3a6e;
    color: #c9d6f0;
  }

  .btn-primary:hover {
    background: #0a2018;
  }

  .btn-danger:hover {
    background: #1a0808;
  }
}

/* ── Laptop 13" (1024–1440px) ── */
@media (min-width: 1024px) and (max-width: 1440px) {
  .app {
    max-width: min(1320px, 98vw);
    padding: 18px 22px 28px;
  }

  .title {
    font-size: 17px;
  }

  .score-value {
    font-size: 24px;
  }

  .score-label {
    font-size: 11px;
  }

  .arena-wrap {
    max-height: min(58vh, 500px);
  }

  .agent-panel__title {
    font-size: 12px;
  }

  .agent-panel__sub {
    font-size: 10px;
  }

  .log-line {
    font-size: 13px;
  }

  .log-title {
    font-size: 11px;
  }

  .specialist-chip__label {
    font-size: 11px;
  }

  .scenario-preview {
    font-size: 11px;
  }
}

/* ── Embed preview (landing page iframe) ── */
.app--embed {
  max-width: 100%;
  padding: 8px 10px 12px;
}

.app--embed .header {
  margin-bottom: 8px;
}

.app--embed .title {
  font-size: 12px;
}

.app--embed .score-value {
  font-size: 20px;
}

.app--embed .main-stage {
  gap: 10px;
}

.app--embed .arena-wrap {
  max-height: min(52vh, 380px);
}

.app--embed .agent-panel {
  max-height: min(52vh, 380px);
}

/* safe area (iPhone notch) */
@supports (padding: max(0px)) {
  .app {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
}
