:root {
  color-scheme: light;
  --bg: #f4f1e8;
  --surface: rgba(255, 252, 244, 0.84);
  --surface-solid: #fffaf0;
  --ink: #172019;
  --muted: #667066;
  --line: rgba(23, 32, 25, 0.14);
  --ocean-deep: #0e5f73;
  --ocean: #44a6af;
  --land: #85b66f;
  --land-dark: #4d8458;
  --country-border: rgba(255, 250, 240, 0.58);
  --accent: #d3543c;
  --accent-strong: #a7352a;
  --gold: #efb84a;
  --cold: #4a91c9;
  --warm: #f59f45;
  --hot: #d73535;
  --shadow: 0 24px 70px rgba(30, 37, 30, 0.22);
  --radius: 8px;
}

:root.dark {
  color-scheme: dark;
  --bg: #121713;
  --surface: rgba(24, 32, 27, 0.84);
  --surface-solid: #1a221d;
  --ink: #eef2e9;
  --muted: #a8b1a5;
  --line: rgba(238, 242, 233, 0.16);
  --ocean-deep: #083846;
  --ocean: #146d7d;
  --land: #6c9d61;
  --land-dark: #3f714a;
  --country-border: rgba(238, 242, 233, 0.52);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.44);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(239, 184, 74, 0.24), transparent 32rem),
    linear-gradient(135deg, rgba(14, 95, 115, 0.18), transparent 44%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  min-height: 100vh;
}

.play-area {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  padding: clamp(1rem, 2vw, 2rem);
}

.topbar {
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 0.35rem;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.8rem, 8vw, 6.7rem);
  line-height: 0.82;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.language-select {
  height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 35px rgba(31, 45, 34, 0.1);
  padding: 0 0.72rem;
  font-size: 0.82rem;
  font-weight: 900;
  outline: none;
}

.language-select:focus {
  border-color: rgba(211, 84, 60, 0.72);
  box-shadow: 0 0 0 4px rgba(211, 84, 60, 0.14);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 35px rgba(31, 45, 34, 0.1);
  font-size: 1.25rem;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.icon-button:hover {
  transform: translateY(-2px);
  border-color: rgba(211, 84, 60, 0.42);
  background: var(--surface-solid);
}

.globe-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 34rem;
  isolation: isolate;
}

#globeCanvas {
  width: min(74vh, 78vw);
  max-width: 900px;
  min-width: 320px;
  aspect-ratio: 1;
  border-radius: 50%;
  filter: drop-shadow(0 34px 44px rgba(15, 59, 66, 0.28));
  touch-action: none;
}

.globe-shadow {
  position: absolute;
  z-index: -1;
  width: min(58vh, 60vw);
  height: 9%;
  bottom: 12%;
  border-radius: 50%;
  background: rgba(16, 33, 28, 0.24);
  filter: blur(18px);
}

.zoom-controls {
  position: absolute;
  left: clamp(1rem, 4vw, 4rem);
  bottom: clamp(1rem, 6vw, 5rem);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  z-index: 2;
}

.zoom-button {
  width: 2.4rem;
  height: 2.4rem;
  font-size: 1.1rem;
  line-height: 1;
}

.compass {
  position: absolute;
  right: clamp(1rem, 4vw, 4rem);
  bottom: clamp(1rem, 6vw, 5rem);
  display: grid;
  grid-template-columns: repeat(3, 2rem);
  grid-template-rows: repeat(3, 2rem);
  place-items: center;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  opacity: 0.9;
}

.compass::before {
  content: "";
  grid-area: 1 / 1 / 4 / 4;
  width: 4rem;
  height: 4rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  backdrop-filter: blur(16px);
}

.compass span {
  z-index: 1;
}

.compass span:nth-child(1) {
  grid-column: 2;
  grid-row: 1;
}

.compass span:nth-child(2) {
  grid-column: 3;
  grid-row: 2;
}

.compass span:nth-child(3) {
  grid-column: 2;
  grid-row: 3;
}

.compass span:nth-child(4) {
  grid-column: 1;
  grid-row: 2;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 100vh;
  padding: clamp(1rem, 2vw, 1.5rem);
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: -18px 0 60px rgba(26, 38, 29, 0.12);
  backdrop-filter: blur(22px);
}

.status-block,
.guess-form,
.heat-section,
.history-section {
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-solid) 72%, transparent);
}

.status-block h2 {
  margin-bottom: 0.45rem;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  line-height: 1;
  letter-spacing: 0;
}

.status-block p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.guess-form {
  display: grid;
  gap: 0.65rem;
}

.guess-form label,
.metric span,
.section-head span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
}

input {
  min-width: 0;
  height: 3.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--ink);
  padding: 0 0.9rem;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus {
  border-color: rgba(211, 84, 60, 0.72);
  box-shadow: 0 0 0 4px rgba(211, 84, 60, 0.14);
}

.input-row button {
  min-width: 6rem;
  height: 3.1rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fffaf0;
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease;
}

.input-row button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

.form-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.metric {
  min-width: 0;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
}

.metric strong {
  display: block;
  margin-top: 0.35rem;
  overflow-wrap: anywhere;
  font-size: clamp(1.1rem, 3vw, 1.45rem);
  line-height: 1.05;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.section-head h3 {
  margin: 0;
  font-size: 1rem;
}

.heatbar {
  height: 0.7rem;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #4a91c9, #8abf6b 42%, #efb84a 68%, #d73535);
}

.heatbar span {
  display: block;
  width: var(--heat, 0%);
  height: 100%;
  background: rgba(255, 250, 240, 0.84);
  mix-blend-mode: overlay;
  transition: width 280ms ease;
}

.history-section {
  display: flex;
  flex: 1;
  min-height: 14rem;
  flex-direction: column;
}

.guess-history {
  display: grid;
  gap: 0.55rem;
  max-height: 38vh;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.guess-item {
  display: grid;
  grid-template-columns: 0.55rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.72rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
}

.guess-swatch {
  width: 0.55rem;
  height: 2.25rem;
  border-radius: 999px;
  background: var(--swatch);
}

.guess-name {
  display: block;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guess-meta {
  display: block;
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.guess-distance {
  font-weight: 900;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  flex: 1;
  place-items: center;
  min-height: 9rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 20;
  max-width: min(34rem, calc(100vw - 2rem));
  transform: translate(-50%, 140%);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 0.8rem 1rem;
  font-weight: 700;
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .play-area {
    min-height: 58vh;
    padding-bottom: 0;
  }

  .control-panel {
    min-height: auto;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  #globeCanvas {
    width: min(70vh, 92vw);
  }

  .compass {
    display: none;
  }

  .guess-history {
    max-height: none;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: center;
  }

  .play-area {
    min-height: 48vh;
  }

  .globe-stage {
    min-height: 22rem;
  }

  .input-row,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .input-row button {
    width: 100%;
  }
}
