:root {
  --bg-top: #f6efe1;
  --bg-bottom: #b9d9f4;
  --panel: rgba(255, 252, 245, 0.8);
  --panel-strong: rgba(255, 250, 240, 0.94);
  --text: #18314f;
  --muted: #4d6780;
  --primary: #0d6c9f;
  --primary-dark: #084d73;
  --accent: #eb7a3c;
  --sun: #ffd36b;
  --globe-water: #8fd0ee;
  --globe-deep: #206991;
  --globe-land: #f3f0cc;
  --globe-shadow: rgba(13, 48, 74, 0.18);
  --line-shortest: #f7d56a;
  --line-ne: #ff6b57;
  --border: rgba(24, 49, 79, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 231, 173, 0.95), transparent 28%),
    radial-gradient(circle at bottom right, rgba(31, 130, 177, 0.18), transparent 24%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

body {
  min-height: 100vh;
}

.layout {
  width: min(1440px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 30px;
}

.page-head {
  max-width: 1240px;
  margin: 0 auto 12px;
  text-align: center;
}

.hero {
  display: block;
}

.globe-shell {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 50px rgba(28, 67, 103, 0.12);
}

h1 {
  margin: 0 auto;
  font-size: clamp(1.75rem, 3vw, 2.85rem);
  line-height: 1.02;
  max-width: 24ch;
}

.intro {
  margin: 8px auto 0;
  max-width: 76ch;
  font-size: 0.96rem;
  line-height: 1.45;
  color: var(--muted);
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px);
}

.primary {
  background: linear-gradient(135deg, var(--primary) 0%, #1d90c9 100%);
  color: #fff8ef;
  box-shadow: 0 14px 24px rgba(11, 88, 126, 0.24);
}

.primary:hover {
  box-shadow: 0 16px 30px rgba(11, 88, 126, 0.28);
}

.ghost {
  background: rgba(255, 255, 255, 0.65);
  color: var(--primary-dark);
  border: 1px solid rgba(13, 108, 159, 0.14);
}

.toggle {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(13, 108, 159, 0.12);
  color: var(--primary-dark);
  font-weight: 600;
}

.toggle input {
  accent-color: var(--primary);
}

.script-label,
.guide-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.guide-card {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(24, 49, 79, 0.08);
}

.guide-card p:last-child {
  margin: 10px 0 0;
  line-height: 1.5;
  color: var(--muted);
}

.globe-shell {
  position: relative;
  padding: 12px 16px 16px;
  overflow: hidden;
}

.mode-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.summary-pill {
  appearance: none;
  text-align: left;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(24, 49, 79, 0.12);
  color: var(--primary-dark);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 0 10px 22px rgba(28, 67, 103, 0.08);
}

.summary-pill.is-active {
  color: #fffaf1;
  transform: translateY(-1px);
}

.summary-pill.is-game {
  border-color: rgba(255, 107, 87, 0.28);
}

.summary-pill.is-orthodrome {
  border-color: rgba(247, 213, 106, 0.5);
}

.summary-pill.is-rhumb {
  border-color: rgba(235, 122, 60, 0.32);
}

.summary-pill.is-game.is-active {
  background: linear-gradient(135deg, #ff866e 0%, #ff5f4a 100%);
  box-shadow: 0 16px 28px rgba(255, 107, 87, 0.28);
}

.summary-pill.is-rhumb.is-active {
  background: linear-gradient(135deg, #f19a57 0%, #eb7a3c 100%);
  box-shadow: 0 16px 28px rgba(235, 122, 60, 0.28);
}

.summary-pill.is-orthodrome.is-active {
  background: linear-gradient(135deg, #f3d975 0%, #dfb744 100%);
  box-shadow: 0 16px 28px rgba(240, 191, 56, 0.3);
  color: var(--primary-dark);
}

.globe-content {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.globe-aside-left,
.map-panel,
.globe-sidebar {
  min-width: 0;
}

.globe-aside-left {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.map-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.globe-frame {
  position: relative;
  width: min(100%, 760px);
  margin: 0 auto;
}

.globe-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mode-panel,
.playback-panel,
.azimuth-card,
.compass-card,
.explanation-card,
.azimuth-explainer,
.short-distance-card {
  background: rgba(255, 250, 240, 0.78);
  border: 1px solid rgba(24, 49, 79, 0.08);
}

.mode-panel {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
}

.mode-group {
  display: grid;
  gap: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.segment {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--primary-dark);
  border: 1px solid rgba(13, 108, 159, 0.12);
  box-shadow: none;
}

.segment.is-active {
  background: linear-gradient(135deg, var(--primary) 0%, #1d90c9 100%);
  color: #fff8ef;
}

.globe-shell::before,
.globe-shell::after {
  content: "";
  position: absolute;
  inset: auto;
  border-radius: 999px;
  pointer-events: none;
}

.globe-shell::before {
  width: 220px;
  height: 220px;
  right: -70px;
  top: -70px;
  background: radial-gradient(circle, rgba(255, 211, 107, 0.75), transparent 68%);
}

.globe-shell::after {
  width: 260px;
  height: 260px;
  left: -90px;
  bottom: -100px;
  background: radial-gradient(circle, rgba(32, 105, 145, 0.18), transparent 70%);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 4px 4px 12px;
  font-size: 0.94rem;
  color: var(--muted);
}

.legend div {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.dot-start {
  background: var(--accent);
}

.dot-goal {
  background: #26547c;
}

.dot-shortest {
  background: var(--line-shortest);
}

.dot-ne {
  background: var(--line-ne);
}

.swatch {
  width: 18px;
  height: 0;
  display: inline-block;
  border-top: 3px solid currentColor;
  border-radius: 999px;
}

.swatch-held {
  color: var(--line-ne);
}

.swatch-goal {
  color: #26547c;
}

.globe-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1.18 / 1;
  min-height: 300px;
  cursor: grab;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.66), transparent 34%),
    radial-gradient(circle at center, rgba(255, 255, 255, 0.28), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(16, 92, 138, 0.08));
}

.globe-stage svg {
  display: block;
  width: 100%;
  height: 100%;
}

.globe-stage.grabbing {
  cursor: grabbing;
}

.playback-panel {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 10px 16px 10px;
  border-radius: 18px;
}

.playback-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.playback-button {
  padding-inline: 18px;
  flex: 0 0 auto;
}

.playback-slider {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}

.playback-slider output {
  min-width: 36px;
  text-align: right;
  font-weight: 800;
  color: var(--muted);
}

.progress-slider {
  width: 100%;
  margin: 0;
  accent-color: var(--primary);
}

.explanation-card p:last-child {
  margin-top: 8px;
}

.explanation-body {
  line-height: 1.55;
}

.inline-link-button {
  display: inline;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.12em;
  box-shadow: none;
  vertical-align: baseline;
}

.inline-link-button:hover,
.inline-link-button:active {
  transform: none;
}

.explanation-card {
  width: min(100%, 760px);
  margin: 0 auto;
  padding-top: 14px;
  padding-bottom: 14px;
}

.azimuth-explainer {
  padding: 16px;
  border-radius: 20px;
}

.short-distance-card {
  padding: 16px;
  border-radius: 20px;
}

.azimuth-mini {
  display: flex;
  justify-content: center;
  margin: 14px 0 10px;
}

.azimuth-mini-compass {
  position: relative;
  width: 126px;
  height: 126px;
  border-radius: 50%;
  border: 1px solid rgba(24, 49, 79, 0.12);
  background: radial-gradient(circle at 40% 32%, rgba(255, 255, 255, 0.95), rgba(211, 235, 247, 0.95));
  box-shadow: inset 0 4px 14px rgba(32, 105, 145, 0.12);
}

.azimuth-mini-north,
.azimuth-mini-east {
  position: absolute;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.azimuth-mini-north {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.azimuth-mini-east {
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
}

.azimuth-mini-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 42px;
  transform-origin: center bottom;
  transform: translate(-50%, -100%) rotate(48deg);
  background: linear-gradient(180deg, #ffb06a 0%, var(--line-ne) 100%);
  border-radius: 999px;
}

.azimuth-mini-arrow::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -10px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 14px solid var(--line-ne);
}

.azimuth-mini-arc {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  border-top: 3px solid rgba(235, 122, 60, 0.72);
  border-right: 3px solid rgba(235, 122, 60, 0.72);
  border-radius: 0 56px 0 0;
  transform: translate(-4px, -56px);
}

.azimuth-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.azimuth-card {
  padding: 14px 16px;
  border-radius: 20px;
}

.azimuth-card p {
  margin: 0;
}

.azimuth-value {
  margin-top: 8px;
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.azimuth-note {
  margin-top: 8px;
  line-height: 1.45;
  color: var(--muted);
}

.compass-card {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  color: var(--muted);
}

.compass-display {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.compass {
  position: relative;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(24, 49, 79, 0.12);
  box-shadow: inset 0 2px 8px rgba(32, 105, 145, 0.12);
}

.compass .north,
.compass .east,
.compass .south,
.compass .west {
  position: absolute;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.compass .north {
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.compass .east {
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.compass .south {
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.compass .west {
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
}

.compass-arrow {
  position: absolute;
  width: 4px;
  height: 36px;
  top: 50%;
  left: 50%;
  transform-origin: center bottom;
  transform: translate(-50%, -100%) rotate(0deg);
  border-radius: 999px;
}

.compass-arrow::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -9px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
}

.compass-arrow-active {
  background: linear-gradient(180deg, #ffb06a 0%, var(--line-ne) 100%);
  box-shadow: 0 0 10px rgba(255, 107, 87, 0.24);
}

.compass-arrow-active::after {
  border-bottom: 14px solid var(--line-ne);
}

.compass-arrow-goal {
  background: linear-gradient(180deg, #6ea2d8 0%, #26547c 100%);
  box-shadow: 0 0 10px rgba(38, 84, 124, 0.2);
}

.compass-arrow-goal::after {
  border-bottom: 14px solid #26547c;
}

.compass-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(24, 49, 79, 0.5);
}

.compass-legend {
  display: grid;
  gap: 10px;
}

.compass-copy {
  margin: 0;
  line-height: 1.45;
}

.compass-copy-active {
  color: #c65533;
  font-weight: 700;
}

.compass-copy-goal {
  color: #26547c;
  font-weight: 700;
}

.compass-copy.is-muted {
  opacity: 0.55;
}

.compass-distance {
  margin: 0;
  padding-top: 2px;
  line-height: 1.45;
  font-weight: 700;
  color: var(--muted);
}

.sphere-shadow {
  display: none;
}

.sphere-water {
  fill: url(#waterGradient);
}

.map-backdrop {
  fill: rgba(143, 208, 238, 0.78);
}

.land {
  fill: #f4efcb;
  stroke: rgba(24, 49, 79, 0.14);
  stroke-width: 0.7;
}

.graticule {
  fill: none;
  stroke: rgba(255, 255, 255, 0.38);
  stroke-width: 0.8;
}

.equator {
  fill: none;
  stroke: rgba(255, 255, 255, 0.55);
  stroke-width: 1.2;
  stroke-dasharray: 5 5;
}

.shortest-path {
  fill: none;
  stroke: var(--line-shortest);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 7 8;
  filter: drop-shadow(0 0 8px rgba(247, 213, 106, 0.4));
}

.ne-path {
  fill: none;
  stroke: var(--line-ne);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 10px rgba(255, 107, 87, 0.2));
}

.trail-fade {
  fill: none;
  stroke: rgba(255, 107, 87, 0.22);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pole-ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.8);
  stroke-width: 1.2;
  stroke-dasharray: 3 5;
}

.goal-line {
  fill: none;
  stroke: rgba(38, 84, 124, 0.45);
  stroke-width: 1.4;
  stroke-dasharray: 2 6;
}

.hand-arrow {
  stroke: rgba(24, 49, 79, 0.76);
  stroke-width: 2.4;
  stroke-linecap: round;
  fill: none;
}

.hand-tip {
  fill: rgba(24, 49, 79, 0.8);
}

.bearing-arrow-held,
.bearing-arrow-goal {
  fill: none;
  stroke-linecap: round;
}

.bearing-arrow-held {
  stroke: var(--line-ne);
  stroke-width: 3.2;
}

.bearing-arrow-goal {
  stroke: #26547c;
  stroke-width: 2.8;
  stroke-dasharray: 4 4;
}

.bearing-tip-held {
  fill: var(--line-ne);
}

.bearing-tip-goal {
  fill: #26547c;
}

.marker-label {
  font-size: 0.88rem;
  font-weight: 800;
  fill: var(--text);
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.8);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.dragger-hint {
  font-size: 0.85rem;
  fill: rgba(24, 49, 79, 0.6);
}

@media (max-width: 960px) {
  .globe-content {
    grid-template-columns: 1fr;
  }

  .mode-summary {
    grid-template-columns: 1fr;
  }

  .globe-stage {
    min-height: 300px;
  }

  .globe-aside-left {
    order: -1;
  }
}

@media (max-width: 620px) {
  .layout {
    width: min(100vw - 18px, 1440px);
    padding-top: 14px;
    padding-bottom: 22px;
  }

  .globe-shell {
    border-radius: 24px;
  }

  .globe-shell {
    padding: 12px;
  }

  .legend {
    gap: 8px 12px;
    font-size: 0.88rem;
  }

  .controls {
    gap: 10px;
  }

  .toggle {
    width: 100%;
    justify-content: center;
  }

  .compass-card {
    width: 100%;
  }

  .compass-display {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .playback-row {
    flex-wrap: wrap;
  }

  .playback-button {
    width: 100%;
  }
}
