:root {
  --nouryon-blue: #0F2C5F;
  --nouryon-blue-2: #19407D;
  --nouryon-bright: #2E6BCE;
  --nouryon-green: #6CB33F;
  --nouryon-green-2: #4F9426;
  --paper: #F4F6FA;
  --paper-2: #FFFFFF;
  --ink: #1B2540;
  --ink-soft: #4A5878;
  --line: rgba(255, 255, 255, 0.12);
  --rail-bg: #0A1635;
  --rail-bg-2: #0E1E47;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: linear-gradient(140deg, #060E25 0%, #0A1635 50%, #102350 100%);
  min-height: 100vh;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 18% 20%, rgba(108, 179, 63, 0.15), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(46, 107, 206, 0.18), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  gap: 18px;
  padding: 18px;
}

/* ----- Side rail ----- */
.rail {
  background: linear-gradient(180deg, var(--rail-bg) 0%, var(--rail-bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: #fff;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.logo { width: 40px; height: 40px; flex-shrink: 0; }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: 0.3px; }
.brand-sub { font-size: 11px; opacity: 0.65; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; }

.rail-section { display: flex; flex-direction: column; gap: 8px; }
.rail-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rail-label-counter {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.5px;
}
.score-big {
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
  font-feature-settings: "tnum";
  background: linear-gradient(135deg, #fff 0%, var(--nouryon-green) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.rail-sub { font-size: 12px; opacity: 0.65; }

/* Categories */
.cat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cat {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}
.cat-icon { font-size: 16px; opacity: 0.55; }
.cat-name { letter-spacing: 0.2px; }
.cat-count {
  font-size: 11px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 26px;
  text-align: center;
  font-feature-settings: "tnum";
}
.cat.activated {
  background: rgba(108, 179, 63, 0.10);
  border-color: rgba(108, 179, 63, 0.25);
}
.cat.activated .cat-icon { opacity: 1; color: var(--nouryon-green); }
.cat.activated .cat-count { background: var(--nouryon-green); color: #0B1F45; }

.achievements-section { flex: 1; min-height: 0; }
.ach-list { display: flex; flex-direction: column; gap: 6px; }
.ach {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.5;
  transition: all 0.3s;
}
.ach-emoji { font-size: 16px; flex-shrink: 0; }
.ach-text { line-height: 1.3; }
.ach-text small { display: block; font-size: 10px; font-weight: 500; opacity: 0.7; margin-top: 1px; }
.ach.unlocked {
  opacity: 1;
  background: linear-gradient(135deg, rgba(108, 179, 63, 0.18) 0%, rgba(46, 107, 206, 0.12) 100%);
  border-color: rgba(108, 179, 63, 0.3);
}

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.rail-btn {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.rail-btn:hover { background: rgba(255, 255, 255, 0.12); }
.rail-disclaimer { font-size: 10px; opacity: 0.45; line-height: 1.4; }

/* ----- Stage / browser window ----- */
.stage {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  min-width: 0;
}
.browser-window {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #06112B;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.browser-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--line);
}
.browser-dots { display: flex; gap: 6px; padding-right: 6px; }
.browser-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
}
.browser-dot.dot-r { background: #FF5F57; }
.browser-dot.dot-y { background: #FEBC2E; }
.browser-dot.dot-g { background: #28C840; }

.browser-controls { display: flex; gap: 4px; }
.ctrl-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
}
.ctrl-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.ctrl-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.ctrl-btn-tip { margin-left: 0; }
.ctrl-btn-info {
  margin-left: auto;
  font-style: italic;
  font-family: Georgia, serif;
  display: none; /* shown only on narrow screens via media query */
}
@media (max-width: 440px) {
  .ctrl-btn-info { display: flex; }
  .stat-card.force-show .stat-close-btn { display: flex; }
}
/* Close button inside the force-shown stat card on narrow screens */
.stat-close-btn {
  display: none;
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.address-bar {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.addr-prefix { color: var(--nouryon-green); font-weight: 600; }
.addr-path {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Inter', monospace;
  font-feature-settings: "tnum";
}
.addr-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--nouryon-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Browser content */
.browser-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #000;
  cursor: crosshair;
}
.canvas-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.55s ease-out, transform 0.85s cubic-bezier(0.16, 1, 0.3, 1), filter 0.55s ease-out;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform, opacity, filter;
}
.canvas-img.shown { opacity: 1; }
.canvas-img-prev { z-index: 1; }
#canvas-img:not(.canvas-img-prev) { z-index: 2; }
/* Outgoing image — zoom INTO the click point + fade out (camera push) */
.canvas-img-prev.zooming-out {
  transition: opacity 0.6s ease-in, transform 0.85s cubic-bezier(0.55, 0, 0.7, 0.5), filter 0.6s ease-in;
  filter: blur(2px);
}

.canvas-loading {
  position: absolute;
  inset: 0;
  background: rgba(6, 17, 43, 0.55);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 5;
  color: #fff;
}
.loading-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--nouryon-green);
  border-right-color: var(--nouryon-bright);
  animation: spin 1s linear infinite;
}
.loading-text { font-weight: 700; font-size: 16px; letter-spacing: 0.5px; }
.loading-sub {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.75;
  max-width: 60%;
  text-align: center;
  line-height: 1.4;
}

/* Hotspot dots (positioned over canvas) */
.hotspot-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.hotspot {
  position: absolute;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(108, 179, 63, 0.8);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(108, 179, 63, 0.18), 0 6px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s, box-shadow 0.18s;
}
.hotspot.cat-climate     { background: #FFB948; box-shadow: 0 0 0 4px rgba(255, 185, 72, 0.22), 0 6px 16px rgba(0, 0, 0, 0.4); }
.hotspot.cat-eco-premium { background: var(--nouryon-green); }
.hotspot.cat-safety      { background: #5BC0E8; box-shadow: 0 0 0 4px rgba(91, 192, 232, 0.22), 0 6px 16px rgba(0, 0, 0, 0.4); }
.hotspot.cat-innovation  { background: #B68CE5; box-shadow: 0 0 0 4px rgba(182, 140, 229, 0.22), 0 6px 16px rgba(0, 0, 0, 0.4); }
.hotspot.cat-earth       { background: #4FE0AD; box-shadow: 0 0 0 4px rgba(79, 224, 173, 0.22), 0 6px 16px rgba(0, 0, 0, 0.4); }
.hotspot:hover {
  transform: translate(-50%, -50%) scale(1.25);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.18), 0 10px 22px rgba(0, 0, 0, 0.5);
}
.hotspot-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: inherit;
  opacity: 0.55;
  animation: hotspotPulse 1.8s ease-out infinite;
  z-index: -1;
}
@keyframes hotspotPulse {
  0% { transform: scale(1); opacity: 0.55; }
  70% { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}
.hotspot-label {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 18, 38, 0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.hotspot:hover .hotspot-label { opacity: 1; }

/* Leaf back-pill (centered over canvas at leaves) */
.back-pill {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: rgba(8, 18, 38, 0.78);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  z-index: 7;
  font-family: inherit;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  animation: backPillIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: background 0.18s, transform 0.18s, box-shadow 0.18s;
}
.back-pill:hover {
  background: linear-gradient(135deg, var(--nouryon-blue) 0%, var(--nouryon-bright) 100%);
  border-color: rgba(46, 107, 206, 0.5);
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 22px 44px rgba(46, 107, 206, 0.45);
}
.back-pill-arrow {
  font-size: 16px;
  font-weight: 900;
  transition: transform 0.18s;
}
.back-pill:hover .back-pill-arrow { transform: translateX(-3px); }
.back-pill-label b { color: var(--nouryon-green); font-weight: 800; }
.back-pill:hover .back-pill-label b { color: #fff; }
@keyframes backPillIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.click-marker {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--nouryon-green);
  background: rgba(108, 179, 63, 0.25);
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
  z-index: 4;
}
.click-marker.firing { animation: clickPulse 0.7s ease-out; }
@keyframes clickPulse {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.4); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  gap: 6px;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}
.empty-state.shown { opacity: 1; }
.empty-headline { font-weight: 800; font-size: 24px; }
.empty-sub { font-size: 14px; opacity: 0.7; max-width: 460px; line-height: 1.5; }

/* Footer */
.browser-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.45);
  border-top: 1px solid var(--line);
  color: rgba(255, 255, 255, 0.85);
  min-height: 60px;
  flex-wrap: wrap;
}
.children-strip {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  width: 100%;
}

/* Breadcrumb row */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.crumb {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.78);
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.crumb:hover:not(.crumb-current) {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}
.crumb.crumb-current {
  background: var(--nouryon-green);
  color: #0B1F45;
  border-color: var(--nouryon-green);
  cursor: default;
}
.crumb-sep {
  color: rgba(255, 255, 255, 0.35);
  font-size: 14px;
  font-weight: 700;
  padding: 0 2px;
}

/* Action row (children chips or sibling jump) */
.action-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.up-btn {
  background: linear-gradient(135deg, var(--nouryon-blue) 0%, var(--nouryon-bright) 100%);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  box-shadow: 0 6px 14px rgba(46, 107, 206, 0.3);
}
.up-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(46, 107, 206, 0.4);
}
.up-btn .up-arrow {
  font-size: 14px;
  font-weight: 800;
}
.up-btn b { font-weight: 800; }
.children-label-sibs {
  margin-left: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  padding-left: 12px;
}
.sibling-chip {
  font-size: 11px;
  padding: 6px 12px;
}
.children-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.55;
  margin-right: 4px;
}
.child-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.child-chip:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}
.chip-cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nouryon-green);
}
.child-chip.cat-climate .chip-cat-dot { background: #FFB948; }
.child-chip.cat-eco-premium .chip-cat-dot { background: #6CB33F; }
.child-chip.cat-safety .chip-cat-dot { background: #5BC0E8; }
.child-chip.cat-innovation .chip-cat-dot { background: #B68CE5; }
.child-chip.cat-earth .chip-cat-dot { background: #4FE0AD; }
.leaf-note {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 14px;
  border-radius: 8px;
  width: 100%;
  border-left: 3px solid var(--nouryon-green);
}

/* Stat card overlay (top-right of canvas) */
.stat-card {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 6;
  width: 320px;
  max-width: calc(100% - 32px);
  background: rgba(8, 18, 38, 0.78);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 16px 18px 14px;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  transition: opacity 0.4s, transform 0.4s;
}
.stat-card.hidden { display: none; }
.stat-topic { display: flex; flex-direction: column; gap: 6px; }
.cat-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: rgba(108, 179, 63, 0.2);
  color: var(--nouryon-green);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(108, 179, 63, 0.3);
  align-self: flex-start;
}
.cat-pill.cat-climate { color: #FFB948; background: rgba(255, 185, 72, 0.12); border-color: rgba(255, 185, 72, 0.3); }
.cat-pill.cat-safety { color: #5BC0E8; background: rgba(91, 192, 232, 0.12); border-color: rgba(91, 192, 232, 0.3); }
.cat-pill.cat-innovation { color: #B68CE5; background: rgba(182, 140, 229, 0.12); border-color: rgba(182, 140, 229, 0.3); }
.cat-pill.cat-earth { color: #4FE0AD; background: rgba(79, 224, 173, 0.12); border-color: rgba(79, 224, 173, 0.3); }
.stat-topic-title {
  font-size: 17px;
  font-weight: 800;
  margin: 0;
  line-height: 1.25;
}
.stat-figure {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
}
.stat-value {
  font-size: 36px;
  font-weight: 900;
  line-height: 1;
  font-feature-settings: "tnum";
  background: linear-gradient(135deg, #fff 0%, var(--nouryon-green) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-label {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;
  line-height: 1.4;
}
.stat-blurb {
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
  opacity: 0.78;
}
.stat-facts {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  padding-top: 10px;
}
.stat-facts li {
  position: relative;
  padding-left: 14px;
  font-size: 11.5px;
  line-height: 1.45;
  opacity: 0.85;
}
.stat-facts li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--nouryon-green);
}
.stat-insight {
  background: linear-gradient(135deg, rgba(108, 179, 63, 0.10) 0%, rgba(46, 107, 206, 0.06) 100%);
  border-left: 3px solid var(--nouryon-green);
  border-radius: 8px;
  padding: 10px 12px 10px 14px;
  margin-top: 4px;
}
.stat-insight-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--nouryon-green);
  margin-bottom: 4px;
}
.stat-insight-body {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  font-style: italic;
  color: rgba(255, 255, 255, 0.90);
}
.stat-source {
  font-size: 10px;
  opacity: 0.5;
  margin-top: 2px;
}
.stat-source a { color: #fff; text-decoration: none; }
.stat-source a:hover { color: var(--nouryon-green); text-decoration: underline; }

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 100px);
  background: linear-gradient(135deg, var(--nouryon-green) 0%, var(--nouryon-green-2) 100%);
  color: #fff;
  padding: 12px 20px 12px 16px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 18px 40px rgba(108, 179, 63, 0.4);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast-emoji { font-size: 20px; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(10px); }
.modal-card {
  position: relative;
  background: var(--paper);
  border-radius: 18px;
  padding: 32px;
  max-width: 520px;
  width: 92vw;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 28px;
  color: var(--ink-soft);
  cursor: pointer;
  width: 32px;
  height: 32px;
}
.modal-card h2 { color: var(--nouryon-blue); font-size: 24px; margin: 0 0 14px; }
.help-list {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.help-list li {
  padding-left: 20px;
  position: relative;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.help-list li::before {
  content: "&#10095;";
  position: absolute;
  left: 0;
  color: var(--nouryon-green);
  font-weight: 700;
}
.help-list li b { color: var(--ink); }
.help-foot {
  font-size: 11px;
  color: var(--ink-soft);
  opacity: 0.7;
  margin: 0;
  padding-top: 14px;
  border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

/* Utility */
.hidden { display: none !important; }

/* Responsive — desktop down to ~tablet */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 8px;
    padding: 8px;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  .rail {
    flex-direction: row;
    overflow-x: auto;
    gap: 16px;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .rail-section { flex-shrink: 0; min-width: 140px; }
  .rail-foot { display: none; }
  .cat-list { flex-direction: row; }
  .cat { min-width: 110px; }
  .ach-list { flex-direction: row; }
  .ach { min-width: 160px; }
  .empty-headline { font-size: 18px; }
  .empty-sub { font-size: 12px; }
}

/* Phone-class screens */
@media (max-width: 640px) {
  .app { padding: 6px; gap: 6px; }

  /* Compact rail */
  .rail {
    padding: 10px 12px;
    gap: 14px;
    border-radius: 14px;
  }
  .rail::-webkit-scrollbar { display: none; }
  .brand { padding-bottom: 0; border-bottom: none; gap: 10px; }
  .logo { width: 34px; height: 34px; }
  .brand-name { font-size: 14px; }
  .brand-sub { display: none; }
  .rail-label { font-size: 9px; letter-spacing: 1.5px; }
  .score-big { font-size: 30px; }
  .rail-sub { font-size: 11px; white-space: nowrap; }
  .cat { padding: 6px 10px; min-width: 96px; font-size: 11px; }
  .cat-icon { font-size: 14px; }
  .cat-count { font-size: 10px; padding: 1px 6px; min-width: 22px; }
  .ach { min-width: 140px; padding: 6px 10px; font-size: 11px; }
  .ach-emoji { font-size: 14px; }
  .ach small { font-size: 9px; }

  /* Browser chrome */
  .browser-window { border-radius: 14px; }
  .browser-toolbar { padding: 7px 8px; gap: 6px; }
  .browser-dots { display: none; }
  .ctrl-btn { width: 30px; height: 30px; font-size: 12px; }
  .address-bar { padding: 5px 10px; font-size: 11px; }

  /* Stat card — compact, top-right, scrollable inside */
  .stat-card {
    top: 6px;
    right: 6px;
    left: auto;
    width: 56vw;
    max-width: 240px;
    min-width: 180px;
    padding: 10px 12px;
    gap: 7px;
    max-height: 50vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .stat-topic-title { font-size: 13px; line-height: 1.2; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 10px; }
  .stat-blurb { font-size: 10.5px; line-height: 1.45; }
  .stat-facts { padding-top: 8px; gap: 5px; }
  .stat-facts li { font-size: 10px; padding-left: 12px; line-height: 1.4; }
  .stat-facts li::before { width: 4px; height: 4px; top: 6px; }
  .stat-insight { padding: 8px 10px 8px 12px; }
  .stat-insight-label { font-size: 8px; letter-spacing: 1.5px; }
  .stat-insight-body { font-size: 10.5px; line-height: 1.4; }
  .stat-source { font-size: 9px; }
  .cat-pill { font-size: 9px; padding: 2px 7px; }

  /* Hotspots — always show labels on touch (no hover) */
  .hotspot { width: 20px; height: 20px; }
  .hotspot-label {
    opacity: 1;
    font-size: 9.5px;
    padding: 3px 7px;
    bottom: calc(100% + 4px);
  }
  .hotspot-pulse { animation-duration: 2.4s; }

  /* Back-pill — smaller, lifted above the footer */
  .back-pill {
    bottom: 12px;
    padding: 9px 16px;
    font-size: 12px;
    gap: 6px;
  }
  .back-pill-arrow { font-size: 13px; }

  /* Footer (breadcrumb + children) */
  .browser-foot { padding: 8px 10px; gap: 8px; min-height: 0; }
  .children-strip { gap: 8px; }
  .crumbs { gap: 3px; }
  .crumb { font-size: 10.5px; padding: 3px 8px; }
  .crumb-sep { font-size: 12px; }
  .action-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .action-row::-webkit-scrollbar { display: none; }
  .child-chip, .sibling-chip {
    font-size: 11px;
    padding: 6px 12px;
    flex-shrink: 0;
  }
  .up-btn { font-size: 11px; padding: 6px 12px; flex-shrink: 0; }
  .children-label { font-size: 9px; }
  .children-label-sibs { padding-left: 8px; margin-left: 2px; }

  /* Help modal — full-screen sheet */
  .modal-card {
    max-width: 100%;
    width: calc(100vw - 16px);
    margin: 0 8px;
    padding: 22px 18px;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 14px;
  }
  .modal-card h2 { font-size: 20px; margin-bottom: 10px; }
  .help-list li { font-size: 13px; }

  /* Toast — leave room from bottom for back-pill */
  .toast { bottom: 70px; padding: 10px 16px; font-size: 12px; }
}

/* Hide stat card entirely below ~440px so the image isn't smothered;
   use a small Info button in the toolbar instead (see #btn-info). */
@media (max-width: 440px) {
  .stat-card { display: none; }
  .stat-card.force-show {
    display: flex;
    position: fixed;
    inset: 12px;
    width: auto;
    max-width: none;
    max-height: none;
    height: auto;
    z-index: 250;
  }
}
