:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #60707b;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --coral: #e85d4f;
  --sun: #f0b429;
  --leaf: #4d9f52;
  --ice: #7db7d8;
  --line: rgba(23, 32, 38, .12);
  --shadow: 0 24px 60px rgba(20, 34, 42, .16);
}

* { box-sizing: border-box; }

html { touch-action: manipulation; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(240, 180, 41, .24), transparent 26rem),
    radial-gradient(circle at 90% 12%, rgba(125, 183, 216, .24), transparent 28rem),
    linear-gradient(135deg, #f7f5ef 0%, #eaf2ee 52%, #f8e7dc 100%);
  overflow-x: hidden;
}

button { font: inherit; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(15, 118, 110, .25);
}

.brand strong,
.brand small { display: block; }

.brand small,
.top-stats small,
.eyebrow { color: var(--muted); }

.top-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(64px, 1fr));
  gap: 8px;
}

.top-stats div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .62);
  text-align: center;
}

.top-stats span {
  display: block;
  font-weight: 900;
  font-size: 1.2rem;
}

.top-stats small { font-size: .76rem; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 32px;
  align-items: center;
  min-height: 390px;
  margin-bottom: 28px;
}

.hero-copy h1 {
  max-width: 860px;
  margin: 0;
  font-size: clamp(2.7rem, 7vw, 5.4rem);
  line-height: .94;
  letter-spacing: 0;
}

.hero-copy p:not(.eyebrow) {
  max-width: 690px;
  color: #334049;
  font-size: 1.12rem;
  line-height: 1.62;
}

.eyebrow {
  margin: 0 0 9px;
  text-transform: uppercase;
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .12em;
}

.hero-actions,
.panel-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-btn,
.ghost-btn,
.link-btn,
.tab,
.climate-card {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}

.primary-btn {
  padding: 0 20px;
  background: var(--teal);
  color: white;
  font-weight: 850;
  box-shadow: 0 16px 32px rgba(15, 118, 110, .24);
}

.primary-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

.ghost-btn,
.link-btn {
  padding: 0 18px;
  background: rgba(255, 255, 255, .72);
  color: var(--teal-dark);
  border: 1px solid rgba(15, 118, 110, .22);
  font-weight: 800;
}

.link-btn { min-height: 36px; }

.primary-btn:not(:disabled):hover,
.ghost-btn:hover,
.link-btn:hover,
.climate-card:not(:disabled):hover,
.tab:hover { transform: translateY(-1px); }

.world-card {
  position: relative;
  min-height: 350px;
}

.globe {
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255,255,255,.7), transparent 13%),
    linear-gradient(180deg, #7db7d8 0 20%, #4d9f52 20% 42%, #f0b429 42% 62%, #e85d4f 62% 78%, #dfeef4 78% 100%);
  border: 12px solid rgba(255, 255, 255, .74);
  box-shadow: var(--shadow);
}

.globe::before,
.globe::after {
  content: "";
  position: absolute;
  inset: 12%;
  border: 2px solid rgba(255,255,255,.38);
  border-radius: 50%;
}

.globe::after { inset: 0 36%; }

.orbit {
  position: absolute;
  border: 2px solid rgba(15, 118, 110, .2);
  border-radius: 50%;
  transform: rotate(-18deg);
}

.orbit-one { inset: 2px 40px 30px; }
.orbit-two { inset: 44px 0 70px; transform: rotate(24deg); }

.mini-card {
  position: absolute;
  padding: 10px 13px;
  border-radius: 8px;
  color: white;
  font-weight: 900;
  box-shadow: 0 16px 30px rgba(20,34,42,.2);
}

.mini-card.one { top: 34px; right: 8px; background: var(--leaf); }
.mini-card.two { right: 44px; bottom: 32px; background: var(--sun); color: #3b2b0d; }
.mini-card.three { left: 8px; bottom: 92px; background: var(--ice); color: #103244; }

.game-panel,
.progress-card {
  background: rgba(255, 255, 255, .82);
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(20, 34, 42, .11);
  backdrop-filter: blur(16px);
}

.game-panel {
  padding: 24px;
  margin-bottom: 22px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
}

.mission-stack {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.round-pill {
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 999px;
  background: #172026;
  color: white;
  font-size: .86rem;
  font-weight: 850;
}

.round-pill.energy { background: var(--coral); }

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
}

.tab {
  padding: 0 14px;
  background: #edf1ee;
  color: #26333a;
  font-weight: 800;
}

.tab.active {
  background: var(--teal);
  color: white;
}

.game-board {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr);
  gap: 18px;
}

.country-stage {
  position: relative;
  min-height: 500px;
  padding: 16px;
  border-radius: 8px;
  background: #172026;
  color: white;
  overflow: hidden;
  touch-action: none;
}

.country-stage.ready {
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, .45);
}

.country-stage.drop-hot {
  box-shadow: inset 0 0 0 4px rgba(240, 180, 41, .9);
}

.country-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.country-head span {
  color: rgba(255,255,255,.68);
  font-size: .9rem;
}

.country-head strong {
  text-align: right;
  font-size: clamp(1.6rem, 4vw, 3rem);
  line-height: 1;
}

#countrySvg {
  position: absolute;
  inset: 58px 12px 84px;
  width: calc(100% - 24px);
  height: calc(100% - 142px);
  z-index: 1;
}

.country-shape {
  fill: #e8f3ef;
  stroke: rgba(255,255,255,.94);
  stroke-width: 1.5;
  filter: drop-shadow(0 22px 30px rgba(0,0,0,.22));
}

.country-graticule {
  fill: none;
  stroke: rgba(255,255,255,.11);
  stroke-width: .8;
}

.placed-climates {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  z-index: 3;
}

.placed-chip {
  border: 0;
  border-radius: 999px;
  padding: 8px 11px;
  background: white;
  color: #172026;
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(0,0,0,.18);
}

.deck-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.mission-board {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: #172026;
  color: white;
}

.mission-board span { font-weight: 900; }

.mission-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  overflow: hidden;
}

.mission-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sun), var(--leaf), var(--ice));
}

.climate-deck {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.climate-card {
  min-height: 62px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(20, 34, 42, .07);
  touch-action: none;
  user-select: none;
}

.climate-card.placed {
  opacity: .45;
}

.drag-ghost {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  min-width: 180px;
  max-width: 260px;
  padding: 14px;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 900;
  box-shadow: 0 18px 38px rgba(20, 34, 42, .22);
  transform: translate(-50%, -50%) scale(1.04);
}

.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #f0f7f6;
  border: 1px solid rgba(15, 118, 110, .2);
  line-height: 1.5;
}

.feedback.good { background: #edf8ed; }
.feedback.bad { background: #fff0ed; border-color: rgba(232, 93, 79, .28); }

.panel-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.learning-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.progress-card { padding: 18px; }

.progress-card h2 {
  margin: 0 0 14px;
  font-size: 1.1rem;
}

.meter {
  height: 12px;
  border-radius: 999px;
  background: #e2e8e4;
  overflow: hidden;
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--sun), var(--coral));
}

.mistake-list {
  display: grid;
  gap: 8px;
}

.mistake-item {
  padding: 10px 11px;
  border-radius: 8px;
  background: rgba(247, 245, 239, .9);
  border: 1px solid var(--line);
  font-size: .92rem;
  line-height: 1.35;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(30px);
  padding: 12px 16px;
  border-radius: 8px;
  background: #172026;
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  box-shadow: var(--shadow);
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.burst {
  position: fixed;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  pointer-events: none;
  animation: burst .7s ease-out forwards;
  z-index: 30;
}

@keyframes burst {
  to {
    transform: translate(var(--x), var(--y)) scale(.4);
    opacity: 0;
  }
}

@media (max-width: 980px) {
  .topbar,
  .hero,
  .panel-head,
  .game-board,
  .learning-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-head { align-items: stretch; }

  .mission-stack { justify-items: start; }

  .world-card { min-height: 300px; }

  .globe { inset: 10px 56px; }

  .country-stage { min-height: 460px; }

  .climate-deck {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

  .top-stats,
  .climate-deck {
    grid-template-columns: 1fr;
  }

  .hero { min-height: 0; }

  .hero-copy h1 { font-size: 2.45rem; }

  .game-panel,
  .progress-card { padding: 14px; }

  .country-stage { min-height: 420px; }

  #countrySvg {
    inset: 70px 8px 100px;
    width: calc(100% - 16px);
    height: calc(100% - 170px);
  }

  .country-head {
    align-items: start;
    flex-direction: column;
  }

  .country-head strong { text-align: left; }

  .round-pill {
    white-space: normal;
    width: fit-content;
  }
}
