/* Reset & base */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #0a1929;
  color: #e6edf3;
  font-family: system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: grid;
  grid-template-areas:
    "hud hud"
    "sidebar map";
  grid-template-rows: auto 1fr;
  grid-template-columns: 180px 1fr;
  height: 100vh;
  height: 100dvh;
}

#hud { grid-area: hud; }
#sidebar { grid-area: sidebar; }
#map-container { grid-area: map; }

@media (max-width: 600px) {
  #app {
    grid-template-areas:
      "hud"
      "sidebar"
      "map";
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }
  #sidebar {
    border-right: none !important;
    border-bottom: 1px solid #1f3a5f;
    max-height: 30vh;
  }
}

/* HUD */
#hud {
  padding: 12px 16px;
  background: rgba(10, 25, 41, 0.95);
  border-bottom: 1px solid #1f3a5f;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#hud .label {
  font-size: 0.75rem;
  color: #8b9eb8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#hud .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ff6b6b;
}

#hud .value-pct {
  font-size: 0.7rem;
  color: #8b9eb8;
  font-weight: 500;
  letter-spacing: 0.04em;
  margin-top: -2px;
}

#hud .hud-right {
  text-align: right;
}

#hud .hud-right .value {
  color: #ffd866;
}

#hud .hud-dead {
  color: #8b9eb8;
}

#hud .hud-dna {
  color: #4ade80;
}

.hud-btn {
  background: #1a2f4a;
  border: 1px solid #2a4a70;
  color: #ffd866;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.hud-btn:hover { border-color: #ffd866; }
.hud-btn:active { transform: scale(0.96); }

.hud-btn.muted {
  color: #8b9eb8;
  opacity: 0.7;
}

.hud-btn.active {
  background: #4ade80;
  color: #0a1929;
  border-color: #4ade80;
}

#map-container #countries path.clean-highlight {
  stroke: #4ade80;
  stroke-width: 1.8;
  filter: drop-shadow(0 0 3px rgba(74, 222, 128, 0.7));
}

#cure-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
  flex: 0 0 100%;
}

#cure-bar.hidden {
  display: none;
}

#cure-bar .label {
  margin-right: 4px;
}

#cure-bar .cure-track {
  flex: 1;
  height: 6px;
  background: #1a2f4a;
  border-radius: 3px;
  overflow: hidden;
}

#cure-bar .cure-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4ade80, #ffd866 60%, #ff6b6b);
  transition: width 0.25s ease;
}

#cure-bar .cure-pct {
  font-size: 0.78rem;
  font-weight: 600;
  color: #ffd866;
  min-width: 36px;
  text-align: right;
}

#hud {
  flex-wrap: wrap;
}

/* Map */
#map-container {
  position: relative;
  background: #0a1929;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

/* Sidebar */
#sidebar {
  background: rgba(10, 25, 41, 0.95);
  border-right: 1px solid #1f3a5f;
  padding: 14px 14px;
  overflow-y: auto;
  font-size: 0.85rem;
  color: #b8c5d6;
}

#sidebar .virus-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffd866;
  margin-bottom: 2px;
  word-break: break-word;
}

#sidebar .virus-strain {
  font-size: 0.7rem;
  color: #6b7e95;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #1f3a5f;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

#sidebar .stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  margin: 0 0 16px;
}

#sidebar .stats dt {
  color: #8b9eb8;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: center;
  display: flex;
  align-items: center;
  gap: 6px;
}

#sidebar .stats .stat-icon {
  font-size: 0.95rem;
  line-height: 1;
  filter: grayscale(0.1);
}

#sidebar .stats dd {
  margin: 0;
  font-weight: 600;
  color: #e6edf3;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#sidebar .section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8b9eb8;
  margin-bottom: 6px;
}

#sidebar #mutations-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#sidebar #mutations-list li {
  font-size: 0.8rem;
  padding: 4px 0;
  border-bottom: 1px solid rgba(31, 58, 95, 0.5);
  color: #ffd866;
}

#sidebar .objectives-section {
  margin-top: 14px;
}

#sidebar #objectives-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#sidebar #objectives-list .tier {
  font-size: 0.78rem;
  padding: 3px 0;
  display: flex;
  gap: 6px;
  align-items: center;
  color: #8b9eb8;
}

#sidebar #objectives-list .tier.achieved {
  color: #4ade80;
}

#sidebar #objectives-list .tier-mark {
  width: 14px;
  display: inline-block;
  text-align: center;
  font-weight: 700;
}

/* Game-over modal */
#game-over-modal {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  z-index: 25;
  background: rgba(10, 25, 41, 0.97);
  animation: fadeIn 0.3s ease;
  text-align: center;
}

#game-over-modal.visible {
  display: flex;
}

#game-over-modal .game-over-title {
  font-size: 2rem;
  margin-bottom: 12px;
  letter-spacing: 0.04em;
}

#game-over-modal.victory .game-over-title {
  color: #4ade80;
}

#game-over-modal.defeat .game-over-title {
  color: #ff6b6b;
}

#game-over-modal .game-over-sub {
  color: #b8c5d6;
  font-size: 1rem;
}

#map-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

#map-container #countries path {
  cursor: pointer;
  stroke: #1f3a5f;
  stroke-width: 0.5;
  vector-effect: non-scaling-stroke;
}

#map-container #countries path.flash-tap {
  animation: tap-flash 0.25s ease-out;
}

@keyframes tap-flash {
  0%   { filter: brightness(1); }
  30%  { filter: brightness(1.6); }
  100% { filter: brightness(1); }
}


#reset-zoom {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #2a4a70;
  background: rgba(26, 47, 74, 0.9);
  color: #e6edf3;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  touch-action: manipulation;
  transition: transform 0.1s ease, border-color 0.15s ease;
}

#reset-zoom:active {
  transform: scale(0.92);
  border-color: #ff6b6b;
}

/* Skill tree modal */
#skill-tree-modal {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  background: rgba(10, 25, 41, 0.97);
  z-index: 18;
  animation: fadeIn 0.2s ease;
}

#skill-tree-modal.visible { display: flex; }

#skill-tree-modal .tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid #1f3a5f;
}

#skill-tree-modal .tree-header h2 {
  font-size: 1.2rem;
  color: #ff6b6b;
}

#skill-tree-modal .tree-dna-display {
  font-size: 0.95rem;
  color: #b8c5d6;
}

#skill-tree-modal .tree-dna {
  color: #4ade80;
  font-weight: 700;
  font-size: 1.1rem;
  margin-left: 6px;
}

#skill-tree-modal .tree-close {
  background: transparent;
  border: 1px solid #2a4a70;
  color: #e6edf3;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
}

#skill-tree-modal .tree-close:hover { border-color: #ff6b6b; }

#skill-tree-modal .tree-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 18px;
}

/* Sticky stats bar: current virus state always visible while browsing.
   Hovering a power card temporarily overlays the would-be values. */
.tree-stats {
  position: sticky;
  top: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 0;
  margin: 0 -20px 16px;
  padding-left: 20px;
  padding-right: 20px;
  background: rgba(10, 25, 41, 0.96);
  border-bottom: 1px solid #1f3a5f;
  z-index: 2;
  backdrop-filter: blur(4px);
}

.tree-stat {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: 0.78rem;
  color: #b8c5d6;
  white-space: nowrap;
}

.tree-stat .ts-icon { font-size: 1rem; line-height: 1; }

.tree-stat .ts-label {
  color: #8b9eb8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.66rem;
}

.tree-stat .ts-value {
  color: #e6edf3;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tree-stat .ts-arrow,
.tree-stat .ts-new { display: none; }

.tree-stat.changed .ts-value { color: #6b7e95; font-weight: 500; }
.tree-stat.changed .ts-arrow { display: inline; color: #8b9eb8; margin: 0 2px; }
.tree-stat.changed .ts-new   { display: inline; color: #ffd866; font-weight: 800; }

#skill-tree-modal .tree-category {
  margin-bottom: 22px;
}

#skill-tree-modal .tree-category h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8b9eb8;
  margin-bottom: 10px;
}

#skill-tree-modal .tree-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 720px) {
  #skill-tree-modal .tree-body {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1100px) {
  #skill-tree-modal .tree-body {
    grid-template-columns: repeat(3, 1fr);
  }
}

#skill-tree-modal .tree-category {
  text-align: center;
  --cat-color: #ffd866;
  overflow-x: auto;
  overflow-y: hidden;
}

#skill-tree-modal .tree-category h3 {
  color: var(--cat-color);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  font-weight: 700;
}

.tree-svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.tree-edge {
  stroke: #2a4a70;
  stroke-width: 2;
  fill: none;
}

.tree-edge--active {
  stroke: var(--cat-color);
  stroke-width: 2.5;
  filter: drop-shadow(0 0 3px var(--cat-color));
}

.tree-node-circle {
  fill: #1a2f4a;
  stroke: #2a4a70;
  stroke-width: 2;
  transition: fill 0.15s ease, stroke 0.15s ease;
}

.tree-node-glyph {
  font-size: 14px;
  font-weight: 700;
  font-family: system-ui, sans-serif;
  fill: #8b9eb8;
  pointer-events: none;
}

.tree-node-label {
  font-size: 11px;
  font-family: system-ui, sans-serif;
  fill: #e6edf3;
  pointer-events: none;
}

.tree-node-cost {
  font-size: 10px;
  font-family: system-ui, sans-serif;
  fill: #ffd866;
  font-weight: 600;
  pointer-events: none;
}

/* States */
.tree-node--locked .tree-node-circle {
  opacity: 0.3;
  stroke-dasharray: 3 3;
}
.tree-node--locked .tree-node-glyph,
.tree-node--locked .tree-node-label,
.tree-node--locked .tree-node-cost {
  opacity: 0.45;
}

.tree-node--unaffordable .tree-node-circle {
  stroke: var(--cat-color);
  opacity: 0.6;
}
.tree-node--unaffordable .tree-node-cost { fill: #ff6b6b; }

.tree-node--affordable .tree-node-circle {
  stroke: var(--cat-color);
}
.tree-node--affordable .tree-node-glyph {
  fill: var(--cat-color);
}
.tree-node--affordable:hover .tree-node-circle {
  fill: var(--cat-color);
  fill-opacity: 0.18;
}

.tree-node--owned .tree-node-circle {
  fill: var(--cat-color);
  stroke: var(--cat-color);
  filter: drop-shadow(0 0 4px var(--cat-color));
}
.tree-node--owned .tree-node-glyph {
  fill: #0a1929;
}
.tree-node--owned .tree-node-cost {
  fill: #4ade80;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Startup modal */
#startup-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 41, 0.96);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 15;
  animation: fadeIn 0.2s ease;
}

#startup-modal.visible {
  display: flex;
}

#startup-modal .game-logo {
  display: block;
  width: clamp(340px, 80vw, 720px);
  height: auto;
  margin: 0 auto 20px;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 4px 24px rgba(255, 107, 107, 0.45));
}

#startup-modal h2 {
  font-size: 1.05rem;
  margin-bottom: 20px;
  color: #b8c5d6;
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.02em;
}

#virus-name-input {
  width: 100%;
  max-width: 320px;
  padding: 14px 16px;
  background: #1a2f4a;
  border: 2px solid #2a4a70;
  border-radius: 8px;
  color: #e6edf3;
  font-family: inherit;
  font-size: 1.1rem;
  text-align: center;
  margin-bottom: 18px;
  outline: none;
}

#virus-name-input:focus {
  border-color: #ffd866;
}

#startup-modal .startup-section { display: contents; }
#startup-modal .startup-section.hidden { display: none; }

.startup-btn {
  border: none;
  padding: 14px 28px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: transform 0.1s ease, filter 0.15s ease, background 0.15s ease;
  min-width: 220px;
}

.startup-btn.primary {
  background: #ff6b6b;
  color: #0a1929;
}

.startup-btn.secondary {
  background: transparent;
  color: #b8c5d6;
  border: 2px solid #2a4a70;
  margin-top: 10px;
}

.startup-btn.secondary:hover { border-color: #ff6b6b; color: #fff; }

.startup-btn:active {
  transform: scale(0.96);
  filter: brightness(1.15);
}

#startup-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bmc-link {
  display: inline-block;
  margin-top: 10px;
  color: #ffd866;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.bmc-link:hover { color: #fff; }

#startup-modal .startup-footer {
  margin-top: 28px;
  max-width: 320px;
  font-size: 0.72rem;
  color: #8b9eb8;
  text-align: center;
  line-height: 1.5;
}

#startup-modal .startup-footer a {
  color: #ffd866;
  text-decoration: underline;
  text-underline-offset: 2px;
  pointer-events: auto;
}

#startup-modal .startup-footer a:hover {
  color: #fff;
}

/* Tap particles */
#particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  border-radius: 50%;
  background: #ff6b6b;
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.75);
  pointer-events: none;
  animation: particle-burst 0.6s cubic-bezier(0.2, 0.7, 0.4, 1) forwards;
}

/* Breaking-news popup — anchored to the right edge, vertically centered,
   ~1/3 smaller than the centered version. Stays out of the map's main area. */
#breaking-news {
  position: fixed;
  top: 50%;
  right: 18px;
  transform: translateY(-50%);
  width: min(380px, 65vw);
  z-index: 24;
  display: none;
  pointer-events: none;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.6));
}

#breaking-news.visible {
  display: block;
  animation:
    bn-pop-in  0.35s cubic-bezier(0.2, 0.7, 0.4, 1.2),
    bn-pop-out 0.35s 2.45s ease-out forwards;
}

/* Image + overlay sub-wrapper so .bn-name's % positions are always
   relative to the image alone, regardless of whether a header is shown. */
#breaking-news .bn-image-wrap {
  position: relative;
  width: 100%;
}

#breaking-news .bn-bg {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

#breaking-news .bn-name,
#breaking-news .bn-virus {
  position: absolute;
  /* top/left/width/height/fontSize are set per-variant by BreakingNewsPopup */
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-family: 'Arial Narrow', 'Arial Black', Arial, sans-serif;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

#breaking-news .bn-virus {
  display: none; /* shown only when a variant defines a virusBox */
  color: #ff6b6b;
}

/* Header banner above the image, used by variants that don't have an
   in-image placeholder (e.g. "hôpitaux débordés"). Hidden by default. */
#breaking-news .bn-header {
  display: none;
}
#breaking-news.with-header .bn-header {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, #c41818 0%, #ff6b6b 100%);
  color: #fff;
  font-family: 'Arial Black', 'Arial Narrow', Arial, sans-serif;
  font-weight: 900;
  font-size: clamp(1rem, 2.2vw, 1.6rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  border-radius: 4px 4px 0 0;
}
#breaking-news.with-header .bn-name {
  display: none;
}

@keyframes bn-pop-in {
  from { transform: translateY(-50%) translateX(40px) scale(0.92); opacity: 0; }
  to   { transform: translateY(-50%) translateX(0)    scale(1);    opacity: 1; }
}

@keyframes bn-pop-out {
  to { transform: translateY(-50%) translateX(40px); opacity: 0; }
}

/* Country hover tooltip (follows cursor) */
#country-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  background: rgba(10, 25, 41, 0.95);
  border: 1px solid #2a4a70;
  border-radius: 6px;
  padding: 10px 12px;
  color: #e6edf3;
  font-size: 0.82rem;
  z-index: 22;
  display: none;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#country-tooltip.visible { display: block; }

#country-tooltip .tip-name {
  font-size: 1rem;
  font-weight: 700;
  color: #ffd866;
  margin-bottom: 6px;
}

#country-tooltip .tip-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

#country-tooltip .tip-tag {
  background: #1a2f4a;
  border: 1px solid #2a4a70;
  border-radius: 3px;
  padding: 2px 6px;
  font-size: 0.7rem;
  color: #b8c5d6;
}

#country-tooltip .tip-bar {
  display: flex;
  height: 10px;
  background: #1a2f4a;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

#country-tooltip .tip-bar-seg { height: 100%; }
#country-tooltip .tip-bar-infected { background: #ff6b6b; }
#country-tooltip .tip-bar-dead     { background: #6b7e95; }
#country-tooltip .tip-bar-healthy  { background: #4ade80; }

#country-tooltip .tip-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 0.72rem;
  color: #b8c5d6;
  margin-bottom: 6px;
}

#country-tooltip .tip-legend .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
#country-tooltip .tip-legend .dot-infected { background: #ff6b6b; }
#country-tooltip .tip-legend .dot-dead     { background: #6b7e95; }
#country-tooltip .tip-legend .dot-healthy  { background: #4ade80; }

#country-tooltip .tip-overwhelm {
  font-size: 0.72rem;
  color: #8b9eb8;
}


/* Event toasts */
#toasts {
  position: fixed;
  top: 90px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 22;
  pointer-events: none;
  max-width: 320px;
}

.toast {
  background: rgba(26, 47, 74, 0.95);
  border-left: 3px solid #5ec8ff;
  padding: 9px 12px;
  border-radius: 4px;
  color: #e6edf3;
  font-size: 0.82rem;
  line-height: 1.35;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.25s ease-out, toast-out 0.5s 8.5s ease-out forwards;
}

.toast--warn   { border-left-color: #ffd866; }
.toast--danger { border-left-color: #ff6b6b; }

@keyframes toast-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toast-out {
  to { transform: translateX(40px); opacity: 0; }
}

@media (max-width: 600px) {
  #toasts {
    top: auto;
    bottom: 18px;
    left: 12px;
    right: 12px;
    max-width: none;
  }
}

@keyframes particle-burst {
  from {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(var(--dx), var(--dy)) scale(0.2);
    opacity: 0;
  }
}

/* Plane sprites — live inside the world-map SVG, after #countries.
   Pointer events are off so they never block taps on countries below. */
.plane-sprite path {
  fill: #ffd866;
  stroke: rgba(20, 30, 45, 0.7);
  stroke-width: 0.4;
  vector-effect: non-scaling-stroke;
  opacity: 0.9;
  filter: drop-shadow(0 0 1.5px rgba(255, 216, 102, 0.6));
}
