/* ============================================================
   어디지? — 국토지리정보원 지형도 무드
   palette: 지도종이 / 침엽수 잉크 / 측량깃발 레드 / 수계 청록 / 등고 골드
   ============================================================ */
:root {
  --map: #E9EFE6;        /* 지형도 종이 */
  --map-deep: #DEE7DA;
  --ink: #1C2B27;        /* 본문/실루엣 */
  --line: #C3CFC2;       /* 등고선/괘선 */
  --flag: #E8442E;       /* 측량 깃발 — 단 하나의 강조색 */
  --water: #2E6E62;      /* 수계 청록 — 보조 */
  --gold: #D9A311;       /* 근접 표시 */
  --card: #F4F7F1;
  --radius: 14px;
  --font-body: 'IBM Plex Sans KR', sans-serif;
  --font-disp: 'Do Hyeon', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; margin: 0; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    repeating-radial-gradient(circle at 18% -10%, transparent 0 46px, rgba(46,110,98,.05) 46px 47px),
    repeating-radial-gradient(circle at 110% 60%, transparent 0 64px, rgba(46,110,98,.04) 64px 65px),
    var(--map);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

header.top, main, footer { width: 100%; max-width: 430px; }

/* ---------- 헤더 ---------- */
.top {
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 4px 2px 12px;
  border-bottom: 2px solid var(--ink);
}
.brand h1 {
  font-family: var(--font-disp);
  font-size: 34px; line-height: 1; letter-spacing: 1px;
}
.brand .q { color: var(--flag); }
.tagline { font-size: 12px; color: var(--water); margin-top: 3px; }
.top-meta { text-align: right; font-family: var(--font-mono); font-size: 12px; }
.sheet-no { display: block; color: var(--water); }
.streak { color: var(--flag); }

/* ---------- 측량 도엽 (시그니처) ---------- */
.sheet {
  position: relative;
  margin-top: 16px;
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  padding: 26px 18px 14px;
  box-shadow: 4px 4px 0 rgba(28,43,39,.12);
}
.graticule .tick {
  position: absolute; font-family: var(--font-mono);
  color: var(--water); opacity: .55; font-size: 14px;
}
.tick.tl { top: 6px; left: 10px; } .tick.tr { top: 6px; right: 10px; }
.tick.bl { bottom: 6px; left: 10px; } .tick.br { bottom: 6px; right: 10px; }
.coords {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 11px; color: var(--water);
  margin-bottom: 6px; padding: 0 10px;
}
.silhouette { width: min(64vw, 250px); margin: 0 auto; color: var(--ink); }
.silhouette svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 2px 0 rgba(46,110,98,.18)); }
.silhouette.reveal svg { animation: pop .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.scalebar {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; color: var(--water);
  margin-top: 10px; opacity: .75;
}
.scalebar i { display: inline-block; width: 56px; height: 4px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 14px, var(--card) 14px 28px);
  border: 1px solid var(--ink); }

/* ---------- 힌트 ---------- */
.hints { display: flex; gap: 8px; margin-top: 12px; }
.hint {
  flex: 1; background: var(--card); border: 1.5px solid var(--ink);
  border-radius: 10px; padding: 8px 10px; min-width: 0;
}
.hint-k {
  display: block; font-family: var(--font-disp); font-size: 12px;
  color: var(--water); letter-spacing: 2px;
}
.hint-v { font-size: 13px; font-weight: 700; word-break: keep-all; }
.hint.locked { border-style: dashed; opacity: .55; }
.hint.locked .hint-v { font-weight: 400; font-size: 11px; color: var(--water); }
.hint.unlock { animation: unlock .4s ease; border-style: solid; opacity: 1; }
@keyframes unlock { from { transform: translateY(-4px); background: #FBF3DC; } }

/* ---------- 추측 보드 ---------- */
.board { margin-top: 14px; display: grid; gap: 7px; }
.row {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 10px; align-items: center;
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: 10px; padding: 9px 12px;
  animation: slidein .25s ease;
}
@keyframes slidein { from { transform: translateY(-5px); opacity: 0; } }
.row .name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .dist, .row .prox { font-family: var(--font-mono); font-size: 13px; }
.row .prox { color: var(--water); }
.row.warm .prox { color: var(--gold); font-weight: 700; }
.row.hot .prox { color: var(--flag); font-weight: 700; }
.row.correct { border-color: var(--flag); background: #FDEEE9; }
.row.correct .name { color: var(--flag); }
.slot {
  height: 40px; border: 1.5px dashed var(--line); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; color: var(--line);
}

/* ---------- 입력 ---------- */
.entry { position: relative; margin-top: 14px; }
.inputwrap { display: flex; gap: 8px; }
#guessInput {
  flex: 1; font: 16px var(--font-body); padding: 13px 14px;
  border: 2px solid var(--ink); border-radius: 12px;
  background: #fff; color: var(--ink); min-width: 0;
}
#guessInput:focus-visible { outline: 3px solid var(--water); outline-offset: 1px; }
#guessBtn {
  font-family: var(--font-disp); font-size: 17px; letter-spacing: 2px;
  padding: 0 20px; border: 2px solid var(--ink); border-radius: 12px;
  background: var(--flag); color: #fff; cursor: pointer;
  box-shadow: 2.5px 2.5px 0 var(--ink);
  transition: transform .06s, box-shadow .06s;
}
#guessBtn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.suggest {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 6px);
  list-style: none; padding: 4px; margin: 0;
  background: #fff; border: 2px solid var(--ink); border-radius: 12px;
  max-height: 260px; overflow-y: auto;
  box-shadow: 4px 4px 0 rgba(28,43,39,.15);
}
.suggest li {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  display: flex; justify-content: space-between; gap: 8px; font-size: 15px;
}
.suggest li .prov { color: var(--water); font-size: 12px; }
.suggest li:hover, .suggest li[aria-selected="true"] { background: var(--map-deep); }
.entry-msg { min-height: 18px; margin-top: 6px; font-size: 12.5px; color: var(--flag); }

/* ---------- 결과 ---------- */
.result {
  margin-top: 16px; background: var(--card);
  border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 18px; text-align: center;
  box-shadow: 4px 4px 0 rgba(28,43,39,.12);
  animation: slidein .3s ease;
}
.result-title { font-family: var(--font-disp); font-size: 24px; }
.result-answer { margin-top: 6px; font-size: 15px; }
.result-answer b { color: var(--flag); }
.result-fact { margin-top: 4px; font-size: 12.5px; color: var(--water); }
.share {
  margin-top: 14px; width: 100%; padding: 13px;
  font: 700 16px var(--font-body); color: #fff;
  background: var(--water); border: 2px solid var(--ink); border-radius: 12px;
  cursor: pointer; box-shadow: 2.5px 2.5px 0 var(--ink);
  transition: transform .06s, box-shadow .06s;
}
.share:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.result-next { margin-top: 10px; font-family: var(--font-mono); font-size: 12px; color: var(--water); }
.stats {
  margin-top: 12px; padding-top: 12px; border-top: 1.5px dashed var(--line);
  display: flex; justify-content: space-around;
  font-family: var(--font-mono); font-size: 12px;
}
.stats b { display: block; font-size: 19px; color: var(--ink); }

/* ---------- 기타 ---------- */
footer { margin-top: auto; padding-top: 22px; text-align: center; font-size: 11.5px; color: var(--water); }
footer a { color: inherit; }
dialog {
  border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 22px; max-width: 340px; background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgba(28,43,39,.45); }
dialog h2 { font-family: var(--font-disp); margin-bottom: 10px; }
dialog p { font-size: 14px; line-height: 1.55; margin-bottom: 8px; }
dialog button {
  margin-top: 8px; width: 100%; padding: 11px;
  font: 700 15px var(--font-body); background: var(--flag); color: #fff;
  border: 2px solid var(--ink); border-radius: 10px; cursor: pointer;
}

/* ── Streak Layer ──────────────────────────────────── */
#streakLayer {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: translateY(100%);
  will-change: transform;
  overflow: hidden;
  opacity: 0.7;
}
#slCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#slClose {
  position: absolute;
  top: max(1rem, env(safe-area-inset-top));
  right: 1rem;
  width: 2.6rem;
  height: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  color: inherit;
  cursor: pointer;
  transition: background .15s;
  z-index: 1;
}
#slClose:hover { background: rgba(255,255,255,.28); }
.sl-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  padding: 0 1.5rem;
  text-align: center;
}
.sl-num-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
#slCrack {
  position: absolute;
  width: 260px;
  height: 150px;
  overflow: visible;
  pointer-events: none;
}
.sl-num-roller {
  position: relative;
  overflow: hidden;
  z-index: 1;
}
.sl-num {
  font-family: var(--font-disp);
  font-size: clamp(120px, 22vw, 180px);
  line-height: 1;
  letter-spacing: -2px;
}
.sl-label {
  font-size: clamp(1rem, 4vw, 1.3rem);
  font-weight: 700;
  margin-top: .3rem;
  opacity: 0;
  transform: translateY(48px);
  transition: opacity 0.55s ease, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.sl-label.sl-vis { opacity: 1; transform: translateY(0); }
.sl-share {
  margin-top: 1.8rem;
  min-width: min(280px, 80vw);
  opacity: 0;
  transform: translateY(48px);
  transition: opacity 0.55s ease 0.12s, transform 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.12s;
  background: #fff;
  color: #1C2B27;
  border-color: rgba(255,255,255,.4);
  box-shadow: 2.5px 2.5px 0 rgba(255,255,255,.2);
}
.sl-share.sl-vis { opacity: 1; transform: translateY(0); }
@keyframes sl-shake {
  0%,100% { transform: translateX(0); }
  15%      { transform: translateX(-8px); }
  30%      { transform: translateX(8px); }
  45%      { transform: translateX(-6px); }
  60%      { transform: translateX(6px); }
  75%      { transform: translateX(-3px); }
  90%      { transform: translateX(3px); }
}
.sl-shake { animation: sl-shake .4s ease-in-out !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
