:root {
  --bg-dark: #0b1120;
  --bg-panel: #131c31;
  --bg-card: #1a2642;
  --border-color: #29385c;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;

  --strain-a: #f43f5e; /* Rose Red */
  --strain-b: #a855f7; /* Purple */
  --strain-c: #eab308; /* Amber Yellow */

  --accent-blue: #38bdf8;
  --accent-green: #22c55e;
  --accent-orange: #f97316;
  --accent-cyan: #06b6d4;
}

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

body {
  font-family: 'Segoe UI', 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.45;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: linear-gradient(90deg, #0f172a 0%, #1e293b 100%);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.header-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 110px;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 800;
}

.stat-value.danger { color: #fb7185; }
.stat-value.info { color: #38bdf8; }
.stat-value.accent { color: #c084fc; }
.stat-value.success { color: #4ade80; }

/* Main Layout */
.main-layout {
  display: grid;
  grid-template-columns: 315px 1fr 330px;
  gap: 14px;
  padding: 14px;
  flex: 1;
  max-width: 1850px;
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 1380px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.card-header h2 {
  font-size: 0.96rem;
  font-weight: 700;
}

.badge, .tag-non-specific, .tag-specific {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
}

.badge {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.tag-non-specific {
  background: rgba(249, 115, 22, 0.18);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.35);
}

.tag-specific {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.section-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* Strain Buttons */
.strain-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.strain-btn {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 7px 6px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 3px;
  transition: all 0.2s ease;
}

.strain-btn:hover {
  border-color: #64748b;
}

.strain-btn.active[data-strain="A"] {
  border-color: var(--strain-a);
  background: rgba(244, 63, 94, 0.15);
}

.strain-btn.active[data-strain="B"] {
  border-color: var(--strain-b);
  background: rgba(168, 85, 247, 0.15);
}

.strain-btn.active[data-strain="C"] {
  border-color: var(--strain-c);
  background: rgba(234, 179, 8, 0.15);
}

.strain-dot {
  font-size: 1rem;
  font-weight: bold;
}

.strain-a { color: var(--strain-a); }
.strain-b { color: var(--strain-b); }
.strain-c { color: var(--strain-c); }

.strain-a-bg { background: var(--strain-a); }
.strain-b-bg { background: var(--strain-b); }
.strain-c-bg { background: var(--strain-c); }

.strain-info strong {
  display: block;
  font-size: 0.8rem;
}

.strain-info small {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  transition: transform 0.12s ease, filter 0.2s ease;
}

.btn:hover {
  filter: brightness(1.12);
}

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

.btn span {
  font-weight: 700;
  font-size: 0.88rem;
}

.btn small {
  font-size: 0.72rem;
  opacity: 0.88;
}

.btn-warning {
  background: linear-gradient(135deg, #d97706, #b45309);
}

.btn-danger {
  background: linear-gradient(135deg, #e11d48, #be123c);
}

.btn-vaccine {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border: 1px solid rgba(56, 189, 248, 0.45);
}

.btn-secondary {
  background: #334155;
  align-items: center;
  text-align: center;
  font-weight: 600;
  font-size: 0.84rem;
  margin-top: 8px;
}

.full-width {
  width: 100%;
}

/* Controls & Toggles */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 8px 10px;
  border-radius: 8px;
}

.toggle-row strong {
  font-size: 0.82rem;
}

.muted-text {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.btn-small {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  transition: all 0.2s;
}

.status-intact {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid #22c55e;
}

.status-wounded {
  background: rgba(244, 63, 94, 0.25);
  color: #fb7185;
  border: 1px solid #f43f5e;
  animation: pulse-border 1.5s infinite;
}

.btn-outline {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.btn-outline:hover {
  background: rgba(56, 189, 248, 0.3);
}

/* Scenario List */
.scenario-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scenario-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease;
}

.scenario-btn:hover {
  border-color: var(--accent-blue);
  background: rgba(56, 189, 248, 0.08);
}

.scenario-btn strong {
  display: block;
  font-size: 0.8rem;
  color: #38bdf8;
}

.scenario-btn span {
  font-size: 0.71rem;
  color: var(--text-muted);
}

/* Center Stage */
.center-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.defense-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.defense-step {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.25s ease;
}

.defense-step.active {
  border-color: var(--accent-blue);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(30, 41, 59, 0.9));
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.defense-step.active-danger {
  border-color: #f97316;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.2), rgba(30, 41, 59, 0.9));
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.25);
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.defense-step.active .step-num {
  background: var(--accent-blue);
  color: #0f172a;
  border-color: var(--accent-blue);
}

.defense-step strong {
  display: block;
  font-size: 0.84rem;
}

.defense-step small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Canvas Wrapper */
.canvas-wrapper {
  position: relative;
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

#sim-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}

.canvas-overlay-tip {
  position: absolute;
  top: 8px;
  right: 10px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.25);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.74rem;
  color: #cbd5e1;
  pointer-events: none;
}

.inflammation-badge {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(185, 28, 28, 0.9);
  border: 1px solid #fca5a5;
  color: #fff;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 0.78rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.5);
  animation: pulse-border 1.5s infinite;
}

.hidden {
  display: none !important;
}

@keyframes pulse-border {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

/* Bottom Panels */
.bottom-panels {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 10px;
}

@media (max-width: 960px) {
  .bottom-panels {
    grid-template-columns: 1fr;
  }
}

.chart-card, .legend-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 14px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 6px;
}

.chart-header h3, .legend-card h3 {
  font-size: 0.84rem;
  font-weight: 700;
}

.chart-legend {
  display: flex;
  gap: 10px;
  font-size: 0.74rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot.strain-a { background: var(--strain-a); }
.dot.strain-b { background: var(--strain-b); }
.dot.strain-c { background: var(--strain-c); }

#chart-canvas {
  width: 100%;
  height: 140px;
  display: block;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px;
}

.entity-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.entity-item {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.entity-icon {
  font-size: 1.1rem;
  line-height: 1;
  margin-top: 2px;
}

.entity-item strong {
  display: block;
  font-size: 0.76rem;
}

.entity-item small {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: block;
  line-height: 1.3;
}

/* Right Panel: Memory & Log */
.card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.memory-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memory-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 10px;
  transition: all 0.25s;
}

.memory-item.memorized {
  border-color: #38bdf8;
  box-shadow: inset 0 0 12px rgba(56, 189, 248, 0.12);
}

.mem-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.strain-badge {
  font-size: 0.78rem;
  font-weight: 700;
}

.mem-state {
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
}

.mem-state.active-learning {
  background: rgba(250, 204, 21, 0.2);
  color: #fde047;
}

.mem-state.active-memory {
  background: rgba(34, 197, 94, 0.22);
  color: #4ade80;
  font-weight: 700;
}

.mem-progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.progress-bar {
  height: 6px;
  background: #0f172a;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-fill {
  height: 100%;
  transition: width 0.2s ease;
}

.mem-detail {
  font-size: 0.69rem;
  color: #cbd5e1;
}

/* Event Log */
.event-log {
  height: 155px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 4px;
}

.log-entry {
  font-size: 0.74rem;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--bg-card);
  border-left: 3px solid #64748b;
  animation: fadeIn 0.2s ease;
}

.log-entry.line1 { border-left-color: #22c55e; }
.log-entry.line2 { border-left-color: #f97316; }
.log-entry.line3 { border-left-color: #38bdf8; }
.log-entry.vaccine { border-left-color: #a855f7; }

.log-time {
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-right: 5px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Knowledge Accordion */
.accordion details {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 7px;
  margin-bottom: 6px;
  padding: 6px 10px;
}

.accordion summary {
  font-size: 0.79rem;
  font-weight: 700;
  cursor: pointer;
  color: #e2e8f0;
}

.accordion p {
  font-size: 0.73rem;
  color: #cbd5e1;
  margin-top: 6px;
  line-height: 1.45;
}
