* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0d1b2a; }
body {
  font-family: 'Pretendard Variable', Pretendard, system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
}
canvas { display: block; background: #0d1b2a; touch-action: none; }

.back-link {
  position: fixed; top: 12px; left: 12px; z-index: 20;
  background: rgba(255,255,255,0.92); color: #111;
  padding: 6px 12px; border-radius: 999px;
  font-size: 12px; text-decoration: none;
  border: 1px solid #e5e5e5; box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

#title {
  position: fixed; top: 16px; left: 0; right: 0; z-index: 5;
  text-align: center; pointer-events: none;
  transition: opacity 300ms ease;
}
#title.faded { opacity: 0; }
#title h1 {
  font-size: 17px; font-weight: 800; letter-spacing: -0.01em;
  color: rgba(255,255,255,0.92);
}
#title p {
  margin-top: 3px;
  font-size: 11px; font-weight: 500;
  color: rgba(255,255,255,0.45);
}

#controls {
  position: fixed; top: 50px; left: 12px; z-index: 20;
  max-width: calc(100% - 24px);
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
}

/* 결과 단위 스위치: 좌우 두 칸 중 하나가 켜지는 세그먼트. 모드 위에 둔다. */
#gran {
  display: flex; gap: 0; padding: 3px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
#gran button {
  border: 0; border-radius: 999px; cursor: pointer;
  padding: 5px 14px;
  font-family: inherit; font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,0.55); background: transparent;
  white-space: nowrap;
}
#gran button.on { color: #06283d; background: #8fd3ff; }

#mode {
  display: flex; flex-wrap: wrap; gap: 2px; padding: 3px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 18px;
  backdrop-filter: blur(4px);
}
#mode button {
  border: 0; border-radius: 999px; cursor: pointer;
  padding: 6px 11px;
  font-family: inherit; font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,0.55); background: transparent;
  white-space: nowrap;
}
#mode button.on { color: #16283a; background: rgba(255,255,255,0.92); }

#opts {
  display: flex; gap: 6px; flex-wrap: wrap;
}
#opts:empty { display: none; }
#opts button {
  border: 1px solid rgba(255,255,255,0.16); border-radius: 999px;
  padding: 6px 12px; cursor: pointer;
  font-family: inherit; font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,0.55); background: rgba(255,255,255,0.10);
  backdrop-filter: blur(4px);
}
#opts button.on { color: #06283d; background: #8fd3ff; border-color: #8fd3ff; }
#opts button[hidden] { display: none; }

#loading {
  position: fixed; inset: 0; z-index: 15;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.75); font-size: 15px; letter-spacing: 0.02em;
  background: #0d1b2a;
}
#loading[hidden] { display: none; }

#credit {
  position: fixed; left: 0; right: 0; bottom: 4px; z-index: 10;
  text-align: center; font-size: 9px; line-height: 1.4;
  color: rgba(255,255,255,0.30); padding: 0 10px;
  pointer-events: none;
}

#result {
  position: fixed; left: 50%; bottom: 26px; z-index: 30;
  transform: translateX(-50%);
  width: min(340px, calc(100% - 32px));
  padding: 20px 22px 18px;
  border-radius: 20px;
  background: rgba(255,255,255,0.97);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  text-align: center;
  animation: pop 340ms cubic-bezier(0.18, 1.2, 0.4, 1);
}
#result[hidden] { display: none; }

@keyframes pop {
  from { opacity: 0; transform: translateX(-50%) translateY(24px) scale(0.94); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

#result .badge {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  color: #b45309; background: #fef3c7;
  padding: 5px 11px; border-radius: 999px;
}
#result .place {
  margin-top: 12px;
  font-size: 30px; font-weight: 800; color: #111; letter-spacing: -0.02em;
  line-height: 1.2; word-break: keep-all;
}
#result .region {
  margin-top: 6px;
  font-size: 14px; font-weight: 600; color: #52606d;
}
#result .coord {
  margin-top: 8px;
  font-size: 11px; color: #9aa5b1; font-variant-numeric: tabular-nums;
}
#result button {
  margin-top: 16px; width: 100%;
  padding: 13px 0; border: 0; border-radius: 13px;
  background: #111; color: #fff;
  font-family: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer;
}
#result button:active { transform: scale(0.98); }

#result.sea .badge { color: #075985; background: #e0f2fe; }
#result.sea .place { font-size: 26px; }
