:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: #aab8c8;
  --panel: rgba(16, 21, 28, 0.72);
  --panel-border: rgba(255, 255, 255, 0.16);
  --accent: #76d7ff;
  --wood-a: #7b4832;
  --wood-b: #3a2019;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 28% 18%, rgba(125, 210, 255, 0.24), transparent 28rem),
    radial-gradient(circle at 70% 14%, rgba(255, 218, 122, 0.16), transparent 22rem),
    linear-gradient(145deg, #081016 0%, #142032 46%, #221b24 100%);
}

.app-shell {
  width: min(1180px, 100%);
  flex: 1;
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 44px);
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(260px, 330px);
  align-items: center;
  gap: clamp(20px, 5vw, 56px);
}

.content-shell {
  width: min(900px, 100%);
  flex: 1;
  margin: 0 auto;
  padding: clamp(22px, 5vw, 56px) clamp(18px, 4vw, 44px);
}

.legal-panel {
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(20px);
}

.legal-panel h1,
.legal-panel h2,
.legal-panel p {
  margin-top: 0;
}

.legal-panel h1 {
  margin-bottom: 24px;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1;
  letter-spacing: 0;
}

.legal-panel h2 {
  margin-bottom: 8px;
  font-size: clamp(1rem, 3vw, 1.24rem);
  line-height: 1.25;
}

.legal-panel section + section {
  margin-top: 24px;
}

.legal-panel p {
  max-width: 68ch;
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.65;
}

.stage {
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: center;
  padding-bottom: clamp(18px, 3vw, 36px);
}

.globe-wrap {
  width: min(72vh, 100%, 720px);
  aspect-ratio: 1;
  position: relative;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  filter: drop-shadow(0 42px 48px rgba(0, 0, 0, 0.5));
}

.globe-wrap:active {
  cursor: grabbing;
}

.globe-wrap::before,
.globe-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}

.globe-wrap::before {
  background:
    radial-gradient(circle at 31% 22%, rgba(255, 255, 255, 0.9) 0 2.4%, transparent 8%),
    radial-gradient(ellipse at 27% 20%, rgba(255, 255, 255, 0.46), transparent 20%),
    radial-gradient(ellipse at 72% 78%, rgba(255, 255, 255, 0.18), transparent 22%),
    radial-gradient(circle at 50% 50%, transparent 62%, rgba(255, 255, 255, 0.28) 72%, rgba(255, 255, 255, 0.08) 100%);
  z-index: 3;
  mix-blend-mode: screen;
}

.globe-wrap::after {
  inset: 1.8%;
  border: 1px solid rgba(255, 255, 255, 0.34);
  box-shadow:
    inset -34px -48px 70px rgba(2, 5, 8, 0.28),
    inset 24px 20px 48px rgba(255, 255, 255, 0.16);
  z-index: 4;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  background: transparent;
}

.base {
  width: min(58vh, 78%, 560px);
  margin-top: clamp(-58px, -7vw, -30px);
  position: relative;
  z-index: 5;
  filter: drop-shadow(0 24px 30px rgba(0, 0, 0, 0.42));
}

.base-top {
  height: clamp(32px, 5vw, 58px);
  border-radius: 50% 50% 12px 12px / 75% 75% 22px 22px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.2), transparent 24% 76%, rgba(255, 255, 255, 0.14)),
    linear-gradient(180deg, #a66a43, #57301f 58%, #24120e);
  border: 1px solid rgba(255, 236, 209, 0.28);
}

.base-front {
  min-height: clamp(72px, 11vw, 116px);
  margin: -8px auto 0;
  width: 88%;
  border-radius: 8px 8px 24px 24px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.1), transparent 30% 70%, rgba(0, 0, 0, 0.2)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 12px, transparent 12px 26px),
    linear-gradient(180deg, var(--wood-a), var(--wood-b));
  border: 1px solid rgba(255, 226, 190, 0.18);
}

.base-front span {
  padding: 8px 18px;
  border-radius: 999px;
  font-size: clamp(0.78rem, 1.6vw, 1rem);
  letter-spacing: 0;
  color: #ffe1af;
  background: rgba(33, 17, 11, 0.46);
  border: 1px solid rgba(255, 222, 164, 0.24);
}

.controls {
  width: 100%;
  padding: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(20px);
}

.help-panel {
  margin: -2px -2px 22px;
  padding: 14px 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(118, 215, 255, 0.08);
}

.help-panel summary {
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
}

.help-content {
  padding-top: 12px;
  display: grid;
  gap: 8px;
}

.help-content p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.help-content strong {
  color: var(--ink);
}

.help-panel + .control-block {
  padding-top: 4px;
}

.control-block,
.control-row {
  display: grid;
  gap: 9px;
}

.control-block + .control-block,
.control-row {
  margin-top: 16px;
}

label {
  font-size: 0.84rem;
  color: var(--muted);
}

select,
input[type="range"],
button,
.file-drop {
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font: inherit;
}

select {
  width: 100%;
  padding: 0 12px;
}

select option {
  background: #17202c;
}

.range-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

output {
  min-width: 54px;
  text-align: right;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  margin: 0;
  padding: 0 12px;
  accent-color: var(--accent);
}

button,
.file-drop {
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

button:hover,
.file-drop:hover {
  transform: translateY(-1px);
  border-color: rgba(118, 215, 255, 0.48);
  background: rgba(118, 215, 255, 0.12);
}

button:active,
.file-drop:active {
  transform: translateY(0);
}

.file-drop {
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 10px 12px;
  cursor: pointer;
}

.file-title {
  font-weight: 700;
}

.file-name {
  color: var(--muted);
  font-size: 0.82rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

input[type="file"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.control-row {
  grid-template-columns: 1fr;
}

.icon-button {
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent);
}

.site-footer {
  width: 100%;
  padding: 14px clamp(18px, 4vw, 44px);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(8, 13, 19, 0.76);
  backdrop-filter: blur(16px);
}

.footer-nav {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.footer-nav a {
  min-height: 40px;
  padding: 10px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.07);
  transition: border-color 160ms ease, background 160ms ease;
}

.footer-nav a:hover,
.footer-nav a[aria-current="page"] {
  border-color: rgba(118, 215, 255, 0.48);
  background: rgba(118, 215, 255, 0.12);
}

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

  .app-shell {
    grid-template-columns: 1fr;
    align-content: start;
    padding-bottom: 26px;
  }

  .globe-wrap {
    width: min(94vw, 620px);
  }

  .controls {
    max-width: 620px;
    justify-self: center;
  }
}
