:root {
  --bg: #0a0d14;
  --ink: #eef1f6;
  --mute: #8b93a5;
  --rule: rgba(255, 255, 255, 0.1);
  --loss: #ff8a3d;
  --gain: #4ea8ff;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

#app {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, #121826 0%, var(--bg) 70%);
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.head {
  position: absolute;
  left: 24px;
  top: 18px;
  right: 340px;   /* clear of the ? and search box at the top right */
  pointer-events: none;
}

.kicker {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
}

h1 {
  margin: 6px 0 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
  transition: opacity 0.35s;
}

.sub {
  margin: 6px 0 0;
  max-width: 640px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--mute);
  transition: opacity 0.35s;
}

.fade {
  opacity: 0;
}

/* The legend sits in the viz, centered above the tabs, big enough to read at a glance. */
.legend {
  position: absolute;
  left: 50%;
  bottom: 66px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  pointer-events: none;
}

.legend i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-left: 14px;
}

.legend .loss { background: var(--loss); box-shadow: 0 0 8px var(--loss); }
.legend .gain { background: var(--gain); box-shadow: 0 0 8px var(--gain); }

.chips {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: rgba(10, 13, 20, 0.72);
  backdrop-filter: blur(8px);
  max-width: calc(100% - 32px);
  overflow-x: auto;
}

.chips button {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  font: 600 12px system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--mute);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}

.chips button:hover { color: var(--ink); }
.chips button.on { color: var(--bg); background: var(--ink); }
.chips button.tour { color: var(--gain); }
.chips button.tour { position: sticky; right: 0; background: rgba(10, 13, 20, 0.95); }   /* Play never scrolls out of view */
.chips button.tour.on { color: var(--bg); background: var(--gain); }
.chips button.tour.invite { color: var(--bg); background: var(--gain); animation: invite 1.6s ease-in-out infinite; }
@keyframes invite { 0%, 100% { box-shadow: 0 0 0 0 rgba(78, 168, 255, 0.55); } 50% { box-shadow: 0 0 0 8px rgba(78, 168, 255, 0); } }
.chips button.step { font-size: 18px; line-height: 1; padding-left: 12px; padding-right: 12px; color: var(--ink); }

.pill {
  position: absolute;
  left: 24px;
  bottom: 64px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
}

.pill[hidden] { display: none; }

.pill button {
  border: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  line-height: 20px;
  padding: 0;
}

.tip {
  position: absolute;
  pointer-events: none;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgba(14, 18, 28, 0.94);
  font-size: 12px;
  line-height: 1.45;
  white-space: nowrap;
  z-index: 3;
}

.tip[hidden] { display: none; }

/* How to get the best experience */
.helpBtn {
  position: absolute; top: 44px; right: 316px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid rgba(255, 201, 77, 0.45); background: rgba(17, 22, 32, 0.92); color: #ffc94d;
  font: 800 15px system-ui, -apple-system, "Segoe UI", sans-serif; cursor: pointer; z-index: 4;
}
.helpBtn:hover { border-color: #ffc94d; }
.help { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(6, 8, 13, 0.3); }
.help[hidden] { display: none; }
.helpCard { max-width: 860px; width: 100%; max-height: 100%; overflow: auto; box-sizing: border-box; padding: 26px 30px 22px;
  background: rgba(14, 18, 28, 0.78); border: 1px solid rgba(255, 201, 77, 0.35); border-radius: 16px; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: tip-pop 260ms cubic-bezier(0.2, 0.9, 0.3, 1.2); }
.helpCard h2 { margin: 0; font-size: 26px; font-weight: 800; }
.helpCard .lead { margin: 6px 0 18px; color: var(--mute); font-size: 14px; }
.helpGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px; }
.helpGrid h3 { margin: 0 0 6px; font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #ffc94d; }
.helpGrid ul { margin: 0; padding-left: 16px; }
.helpGrid li { margin: 0 0 6px; font-size: 13px; line-height: 1.45; color: rgba(238, 241, 246, 0.9); }
.helpCard kbd { display: inline-block; min-width: 14px; padding: 0 5px; border: 1px solid var(--rule); border-radius: 4px;
  font: 700 11px system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); text-align: center; }
.helpCard .sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 5px 0 4px; vertical-align: -1px; }
.helpCard .sw.gain { background: var(--gain); } .helpCard .sw.loss { background: var(--loss); } .helpCard .sw.slate { background: #56637c; }
.helpActions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--rule); }
.helpActions button { border: 0; border-radius: 999px; padding: 9px 18px; font: 700 14px system-ui, -apple-system, "Segoe UI", sans-serif; cursor: pointer; }
.helpActions .go { background: var(--gain); color: var(--bg); }
.helpActions .own { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.helpActions .m { color: var(--mute); font-size: 12px; margin-left: auto; }
@media (max-width: 640px) {
  .helpBtn { top: 14px; right: 16px; width: 30px; height: 30px; }
  .helpGrid { grid-template-columns: 1fr; }
  .helpCard { padding: 20px 18px 16px; } .helpCard h2 { font-size: 21px; }
  .helpActions .m { display: none; }
}
.tip b { font-size: 13px; }
.tip { padding: 14px 16px 12px; border-color: rgba(255, 201, 77, 0.35); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55); }
.tip.pop { animation: tip-pop 220ms cubic-bezier(0.2, 0.9, 0.3, 1.3); }
@keyframes tip-pop { from { opacity: 0; transform: scale(0.88); } to { opacity: 1; transform: scale(1); } }
.tip .h > b { font-size: 20px; font-weight: 800; }
.tip .h .m { font-size: 12px; margin-top: 2px; }
.tip .rows { margin-top: 10px; display: grid; gap: 3px; }
.tip .mix { display: flex; height: 10px; margin-top: 10px; border-radius: 5px; overflow: hidden; background: rgba(255, 255, 255, 0.08); }
.tip .mix s { display: block; height: 100%; }
.tip .mix s.neg { background: var(--loss); }
.tip .mix s.mid { background: #56637c; }
.tip .mix s.pos { background: var(--gain); }
.tip .mixk { display: flex; justify-content: space-between; margin-top: 4px; font-size: 11px; font-weight: 700; }
.tip .r { display: grid; grid-template-columns: 136px 44px 96px 56px; align-items: center; gap: 8px; font-size: 12px; }
.tip .r span { color: var(--mute); }
.tip .r b { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.tip .r i { display: block; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.tip .r i s { display: block; height: 100%; border-radius: 3px; background: #56637c; }
.tip .r i.pos s { background: var(--gain); }
.tip .r i.neg s { background: var(--loss); }
.tip .r em { font-style: normal; font-size: 11px; color: var(--mute); }
.tip .r em.pos { color: var(--gain); }
.tip .r em.neg { color: var(--loss); }
.tip .r.hd i { height: auto; background: none; font-style: normal; font-size: 10px; color: var(--mute); overflow: visible; }
.tip .cta { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--rule); color: #ffc94d; font-weight: 700; font-size: 12px; }
@media (max-width: 640px) { .tip .r { grid-template-columns: 100px 40px 56px 50px; font-size: 11px; } }
.tip .m { color: var(--mute); }
.tip .neg { color: var(--loss); }
.tip .pos { color: var(--gain); }

.foot {
  position: absolute;
  right: 24px;
  bottom: 22px;
  font-size: 10px;
  color: rgba(139, 147, 165, 0.6);
  pointer-events: none;
}

.error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--mute);
  font-size: 14px;
}

/* Narrow sheets: tuck the legend under the title, shrink the type. */
@media (max-width: 640px) {
  h1 { font-size: 20px; }
  .sub { font-size: 12.5px; }
  .legend { font-size: 13px; gap: 5px; }
  .legend i { width: 10px; height: 10px; margin-left: 8px; }
  .pill { bottom: 96px; }
  .head { left: 16px; right: 56px; }
  .foot { display: none; }
}

.legend .gold { background: #ffc94d; box-shadow: 0 0 8px #ffc94d; }
.legend .slate { background: #5d6b85; }
.legend .dim { background: #3a4458; }
#foot { top: 24px; bottom: auto; max-width: 46%; text-align: right; }
@media (max-width: 640px) { #foot { display: none; } }

/* Follow a country: search for one, or click one, and it stays lit through every chart. */
.find { position: absolute; top: 44px; right: 24px; width: 280px; z-index: 4; }
.find input {
  width: 100%; box-sizing: border-box; padding: 8px 14px;
  font: 600 14px system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink);
  background: rgba(17, 22, 32, 0.92); border: 1px solid rgba(255, 201, 77, 0.45); border-radius: 999px; outline: none;
}
.find input::placeholder { color: rgba(238, 241, 246, 0.55); }
.find input:focus { border-color: #ffc94d; box-shadow: 0 0 0 3px rgba(255, 201, 77, 0.18); }
.find ul {
  list-style: none; margin: 6px 0 0; padding: 4px; background: rgba(14, 18, 28, 0.97);
  border: 1px solid var(--rule); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}
.find ul[hidden] { display: none; }
.find li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.find li span { color: var(--mute); font-size: 12px; }
.find li.on, .find li:hover { background: rgba(255, 201, 77, 0.14); }
.find .keys { margin-top: 4px; text-align: right; white-space: nowrap; pointer-events: none; font: 600 11px system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--mute); }
.find kbd { display: inline-block; min-width: 14px; padding: 0 5px; border: 1px solid var(--rule); border-radius: 4px; font: 700 10px system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); text-align: center; }
/* Mobile view: the chart gets the screen. Title and caption on top, one slim bar below. */
#app.mob .kicker, #app.mob .legend, #app.mob #foot, #app.mob .helpBtn, #app.mob .find { display: none; }
#app.mob .head { left: 12px; right: 12px; top: 10px; }
#app.mob h1 { margin: 0; font-size: 18px; }
#app.mob .sub { margin-top: 3px; font-size: 12px; line-height: 1.35; max-width: none;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#app.mob .chips { left: 8px; right: 8px; bottom: 8px; transform: none; max-width: none; justify-content: space-between; }
#app.mob .chips button { padding: 8px 10px; font-size: 13px; }
#app.mob .chips button:not(.step):not(.tour):not(.view):not(.on) { display: none; }
#app.mob .chips button.on:not(.tour) { flex: 1; color: var(--ink); background: transparent; }
#app.mob .chips button.tour { position: static; }
#app.mob .pill { left: 12px; bottom: 58px; }
#app.mob .tip { max-width: calc(100% - 16px); box-sizing: border-box; }
.chips button.view { color: var(--mute); border-right: 1px solid var(--rule); border-radius: 999px 0 0 999px; }
.find.off input { opacity: 0.45; cursor: not-allowed; border-color: var(--rule); }
.find.off .hint { visibility: hidden; }
.find .hint { margin-top: 5px; text-align: right; pointer-events: none; font: 600 11px system-ui, -apple-system, "Segoe UI", sans-serif; color: #ffc94d; }
@media (max-width: 640px) { .find { top: auto; bottom: 140px; right: 16px; width: 200px; } .find .hint, .find .keys { display: none; } .find ul { position: absolute; bottom: 100%; width: 100%; margin: 0 0 6px; } }
