:root {
  --bg: #0d0e1a;
  --bg2: #141629;
  --card: #1a1d33;
  --line: #2a2e4a;
  --text: #f3f1ff;
  --dim: #a3a6c4;
  --pin: #ff4d7d;
  --pin-glow: rgba(255, 77, 125, .42);
  --ans: #45e3be;
  --lilac: #9d8cff;
  --good: #3ddc97;
  --mid: #ffc857;
  --low: #5b607f;
  --land: #2b3052;
  --ocean: #11152a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

body { min-height: 100dvh; }

#app {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

button { font: inherit; cursor: pointer; }
a { color: var(--lilac); }

/* 맨 위 머리 줄 — 고정 + 배경색(아이폰 홈 화면 앱 맨 위 흐림 방지) */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: calc(var(--safe-t) + 14px) 16px 12px;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 28px; }
.brand { display: flex; align-items: center; gap: 6px; font-size: 20px; letter-spacing: -.02em; }
.brand svg { width: 18px; height: 24px; }
.brand.small { font-size: 16px; }
.brand.small svg { width: 14px; height: 19px; }
.badge {
  font-size: 12px; font-weight: 600; color: var(--lilac);
  border: 1px solid rgba(157, 140, 255, .45); border-radius: 999px; padding: 3px 9px;
}

.dots { display: flex; gap: 6px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots span.done { background: var(--pin); }
.dots span.now { background: var(--text); }
.count { font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }

/* 점수 상자 = 오늘 내 깃발 힘 — 문제마다 올라간다 */
.power-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 34px; margin-top: 10px; }
.power { position: relative; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.power .pl { font-size: 12.5px; color: var(--dim); white-space: nowrap; }
.power b { font-size: 22px; font-weight: 850; color: var(--pin); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.plus {
  position: absolute; left: 100%; top: 2px; margin-left: 8px; white-space: nowrap;
  font-size: 13px; font-weight: 700; color: var(--ans); opacity: 0; transform: translateY(6px);
  transition: opacity .3s, transform .3s;
}
.plus.show { opacity: 1; transform: none; }
.mult { flex: 0 0 auto; font-size: 12.5px; font-weight: 700; color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.mult.hot { color: var(--mid); border-color: rgba(255, 200, 87, .55); background: rgba(255, 200, 87, .1); }

.stage { flex: 1; padding: 6px 16px calc(var(--safe-b) + 100px); }

/* 아래 고정 단추 줄 — 누르는 자리가 바뀌지 않게 늘 같은 곳 */
.bar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 10;
  display: flex; gap: 10px;
  padding: 14px 16px calc(var(--safe-b) + 14px);
  background: linear-gradient(to bottom, rgba(13, 14, 26, 0), var(--bg) 28%);
}
.primary, .secondary {
  flex: 1; height: 56px; border-radius: 16px; font-size: 17px; font-weight: 700;
}
.primary {
  border: 0; background: var(--pin); color: #fff;
  box-shadow: 0 10px 26px var(--pin-glow);
  transition: background .15s, box-shadow .15s, color .15s;
}
.primary:disabled { background: #2f2b45; color: #807a9c; box-shadow: none; cursor: default; }
.secondary { flex: 0 0 38%; background: var(--card); color: var(--text); border: 1px solid var(--line); }

/* ---------- 첫 화면 */
.intro .date { margin: 22px 0 6px; color: var(--dim); font-size: 15px; }
.hero { margin: 0; font-size: 34px; line-height: 1.2; letter-spacing: -.03em; font-weight: 800; }
.hero em { font-style: normal; color: var(--pin); }
.lead { margin: 12px 0 24px; color: #d6d3ec; font-size: 16px; line-height: 1.6; }
.how { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.how li {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
}
.how .ic {
  flex: 0 0 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: rgba(255, 77, 125, .14); color: var(--pin); font-weight: 800; font-size: 18px;
}
.how .ic svg { width: 20px; height: 20px; }
.how b { display: block; font-size: 16px; }
.how span { display: block; margin-top: 2px; color: var(--dim); font-size: 13.5px; }
.note { margin: 18px 2px 0; color: var(--dim); font-size: 13px; line-height: 1.5; }

/* ---------- 문제 화면 */
.chip {
  display: inline-flex; align-items: center; height: 28px; padding: 0 11px; border-radius: 999px;
  background: rgba(157, 140, 255, .14); color: var(--lilac); font-size: 13px; font-weight: 600;
}
.qtext { margin: 10px 0 14px; font-size: 22px; line-height: 1.38; letter-spacing: -.02em; font-weight: 750; }

.widget { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.widget.map { aspect-ratio: 1.55; }
.map-zoom { position: absolute; bottom: 10px; right: 10px; display: flex; gap: 6px; }
.map-zoom button {
  width: 40px; height: 38px; border-radius: 10px; padding: 0;
  background: rgba(13, 14, 26, .78); border: 1px solid var(--line); color: var(--text); font-size: 17px;
}
.map-zoom button[data-z="all"] { font-size: 11.5px; color: var(--dim); }
.widget.map svg { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.map-hint {
  position: absolute; left: 10px; bottom: 10px; pointer-events: none;
  font-size: 12px; color: var(--dim); background: rgba(13, 14, 26, .72); padding: 5px 9px; border-radius: 9px;
}
.ocean { fill: var(--ocean); }
.grat { fill: none; stroke: #1c2140; stroke-width: .6; vector-effect: non-scaling-stroke; }
.land { fill: var(--land); stroke: #3a4068; stroke-width: .5; vector-effect: non-scaling-stroke; }
.gc { fill: none; stroke: var(--mid); stroke-width: 2.2; stroke-dasharray: 5 5; vector-effect: non-scaling-stroke; }
.hit { fill: var(--ans); fill-opacity: .32; stroke: var(--ans); stroke-width: 1.2; vector-effect: non-scaling-stroke; animation: hitin .5s ease-out; }
@keyframes hitin { from { fill-opacity: 0; } }
.p path { stroke: #fff; stroke-width: 1.5; }
.pin-g path { fill: var(--pin); filter: drop-shadow(0 3px 6px rgba(255, 77, 125, .6)); }
.pin-a path { fill: var(--ans); filter: drop-shadow(0 3px 6px rgba(69, 227, 190, .6)); }
.pin-dot { fill: #fff; }
.p text { font-size: 13px; font-weight: 700; fill: #fff; paint-order: stroke; stroke: rgba(13, 14, 26, .9); stroke-width: 4px; }

.widget.tl { height: 224px; padding: 20px 16px 14px; }
.tl-value {
  height: 42px; text-align: center; font-size: 30px; font-weight: 800; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tl-value.empty { font-size: 16px; line-height: 42px; font-weight: 500; color: var(--dim); }
.tl-value.answer { color: var(--ans); font-size: 22px; line-height: 42px; }
.tl-sub { height: 18px; margin-top: 2px; text-align: center; font-size: 13px; color: var(--dim); }
.tl-track { position: relative; height: 66px; margin: 6px 8px 0; touch-action: none; cursor: pointer; }
.tl-rail { position: absolute; left: 0; right: 0; top: 26px; height: 6px; border-radius: 3px; background: var(--line); }
.tl-tick { position: absolute; top: 23px; width: 1px; height: 12px; background: #3d4268; }
.tl-label { position: absolute; top: 44px; transform: translateX(-50%); font-size: 11px; color: var(--dim); white-space: nowrap; }
.tl-gap { position: absolute; top: 26px; height: 6px; background: rgba(255, 200, 87, .75); }
.tl-pin { position: absolute; top: 18px; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; }
.tl-pin { background: var(--pin); border: 2px solid #fff; box-shadow: 0 0 0 5px rgba(255, 77, 125, .22), 0 6px 16px var(--pin-glow); }
/* 정답은 가는 세로 깃발 — 내 핀과 겹쳐도 둘 다 보이게 핀 위에 그린다 */
.tl-ans { position: absolute; top: 2px; width: 4px; height: 40px; margin-left: -2px; border-radius: 2px; background: var(--ans); box-shadow: 0 0 10px rgba(69, 227, 190, .7); }
.tl-ans::before {
  content: ''; position: absolute; top: -4px; left: -5px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--ans); border: 2px solid #fff; box-sizing: border-box;
}
.tl-gap.grow { animation: grow .56s ease-out both; }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.tl-ans.pop { animation: pop .35s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(.2); opacity: 0; } }
.nudge { display: flex; justify-content: space-between; margin-top: 2px; }
.nudge button {
  height: 40px; padding: 0 14px; border-radius: 12px;
  background: transparent; border: 1px solid var(--line); color: var(--dim); font-size: 14px;
}
.nudge button:disabled { opacity: .35; cursor: default; }

.reveal {
  margin-top: 14px; min-height: 176px; padding: 14px 16px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 16px;
}
.reveal.wait { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; color: var(--dim); font-size: 14px; line-height: 1.5; }
.reveal.wait p { margin: 0; }
.toggle {
  height: 34px; padding: 0 14px; border-radius: 999px; font-size: 13px;
  background: transparent; border: 1px solid var(--line); color: var(--dim);
}
.toggle::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 7px; border-radius: 50%; border: 1.5px solid currentColor; vertical-align: -1px; }
.toggle[aria-pressed="true"] { color: var(--text); border-color: var(--lilac); }
.toggle[aria-pressed="true"]::before { background: var(--lilac); border-color: var(--lilac); }
.warn { height: 20px; font-size: 13.5px; font-weight: 700; color: var(--mid); }
.suspense { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: .02em; }
.suspense span { animation: blink 1s infinite; opacity: .2; }
.suspense span:nth-child(2) { animation-delay: .2s; }
.suspense span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 50% { opacity: 1; } }
.rv-head { display: flex; align-items: baseline; gap: 4px; }
.rv-score { font-size: 36px; font-weight: 850; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.rv-pt { font-size: 15px; color: var(--dim); }
.rv-mult { margin-left: 10px; font-size: 15px; color: var(--dim); }
.rv-mult b { font-size: 22px; color: var(--mid); font-variant-numeric: tabular-nums; }
.rv-diff { margin: 2px 0 0; font-size: 13.5px; color: var(--dim); }
.rv-quip { margin: 8px 0 0; font-size: 16px; font-weight: 750; color: var(--text); }
.good { color: var(--good); }
.mid { color: var(--mid); }
.low { color: var(--low); }
.rv-fact { margin: 6px 0 6px; font-size: 14.5px; line-height: 1.55; color: #dcd9f2; }
.rv-meta { margin: 0; font-size: 12px; color: var(--dim); }

/* ---------- 결과 화면 */
.res-top { text-align: center; padding: 18px 0 6px; }
.res-label { color: var(--dim); font-size: 14px; }
.res-score { margin-top: 4px; font-size: 64px; font-weight: 850; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.res-score small { font-size: 22px; color: var(--dim); font-weight: 600; margin-left: 4px; }
.squares { display: flex; justify-content: center; gap: 8px; margin: 14px 0 4px; }
.squares i { width: 30px; height: 30px; border-radius: 8px; display: block; }
.sq-good { background: var(--good); }
.sq-mid { background: var(--mid); }
.sq-low { background: var(--low); }

.card { margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px; }
.card h2 { margin: 0 0 10px; font-size: 16px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.fmap { width: 100%; aspect-ratio: 2 / 1.05; border-radius: 14px; overflow: hidden; background: var(--ocean); }
.fmap svg { display: block; width: 100%; height: 100%; }
.fstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.fstats div { background: var(--bg2); border-radius: 12px; padding: 10px; text-align: center; font-size: 12.5px; color: var(--dim); }
.fstats b { display: block; font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.news { margin: 12px 0 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.news::before { content: ''; flex: 0 0 8px; height: 8px; border-radius: 50%; background: var(--ans); box-shadow: 0 0 0 4px rgba(69, 227, 190, .2); }
.mine p { margin: 0; font-size: 14.5px; line-height: 1.55; color: #dcd9f2; }
.mine b { color: var(--pin); font-size: 17px; }

.rows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 14px; }
.row .k { flex: 0 0 auto; font-size: 12px; color: var(--lilac); background: rgba(157, 140, 255, .12); border-radius: 8px; padding: 3px 7px; }
.row .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #dcd9f2; }
.row .x { flex: 0 0 22px; font-size: 12px; font-weight: 700; color: var(--mid); text-align: right; }
.row .s { flex: 0 0 38px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

/* 우리 팬덤 안 내 자리 — 분포 막대 */
.hist { display: grid; gap: 7px; }
.hrow { display: grid; grid-template-columns: 78px 1fr 58px; align-items: center; gap: 8px; font-size: 12.5px; color: var(--dim); }
.hl { font-variant-numeric: tabular-nums; }
.hb { height: 14px; border-radius: 7px; background: var(--bg2); overflow: hidden; }
.hb i { display: block; height: 100%; border-radius: 7px; background: #474c70; }
.hp { text-align: right; font-variant-numeric: tabular-nums; }
.hrow.me { color: var(--text); font-weight: 700; }
.hrow.me .hb i { background: var(--pin); }
.fstats.two { grid-template-columns: 1fr 1fr; }
.hq { margin: 10px 0 0; font-size: 12.5px; color: var(--dim); line-height: 1.5; }

.tag { font-size: 11px; font-weight: 600; color: var(--mid); border: 1px solid rgba(255, 200, 87, .5); border-radius: 999px; padding: 2px 7px; white-space: nowrap; }
.mine-flag { display: flex; align-items: center; gap: 8px; margin: 0 0 10px !important; font-size: 16.5px !important; font-weight: 700; color: var(--text) !important; }
.mine-flag .hex { flex: 0 0 18px; color: var(--pin); }
.mine-flag svg { display: block; width: 18px; height: 20px; }

/* ---------- 오늘 내 깃발 */
.flag-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; height: 60px; margin-top: 4px; }
.flag-power { font-size: 44px; line-height: 1; font-weight: 850; letter-spacing: -.03em; color: var(--pin); font-variant-numeric: tabular-nums; }
.flag-unit { margin-left: 8px; font-size: 13.5px; color: var(--dim); }
.link {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; flex: 0 0 auto;
  border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--text); font-size: 13px;
}
.link[hidden] { display: none; }
.link svg { width: 10px; height: 14px; }
.flag-body { height: 300px; margin-top: 10px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.cities-title { margin: 2px 2px 12px; font-size: 15px; font-weight: 700; }
.cities { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.city { height: 52px; border-radius: 14px; background: var(--bg2); border: 1px solid var(--line); color: var(--text); font-size: 15px; font-weight: 600; }
.city[aria-pressed="true"] { border-color: var(--pin); background: rgba(255, 77, 125, .16); box-shadow: inset 0 0 0 1px var(--pin); }
.board { display: block; width: 100%; height: 212px; }
.hx { stroke: var(--card); stroke-width: 2; transition: fill .45s ease; }
.hx-u { fill: #e8486f; }
.hx-o { fill: #474c70; }
.hx-e { fill: transparent; stroke: #2f3455; stroke-width: 1.5; }
.hx-me { stroke: #fff; stroke-width: 3; }
.hx-me.flipped { filter: drop-shadow(0 0 12px rgba(255, 77, 125, .85)); }
.burst { fill: none; stroke: var(--pin); stroke-width: 3; opacity: 0; transform-box: fill-box; transform-origin: center; }
.burst.soft { stroke: var(--ans); }
.burst.go { animation: burst .75s ease-out forwards; }
@keyframes burst { from { opacity: .95; transform: scale(.85); } to { opacity: 0; transform: scale(2.6); } }
.drop-pin { fill: var(--pin); stroke: #fff; stroke-width: 1.5; }
.tug-labels { display: flex; justify-content: space-between; margin: 4px 2px 8px; font-size: 13px; color: var(--dim); }
.tug-labels b { margin-left: 4px; color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.tug { position: relative; height: 14px; border-radius: 7px; background: #474c70; overflow: hidden; }
.tug i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--pin); transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.tug-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #fff; opacity: .9; }
.flag-msg { height: 150px; margin-top: 12px; padding: 14px 16px; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; }
.flag-msg.wait { display: flex; align-items: center; justify-content: center; text-align: center; }
.flag-note { margin: 0; color: var(--dim); font-size: 13.5px; line-height: 1.6; }
.fm-title { margin: 0; font-size: 22px; font-weight: 850; color: var(--pin); }
.fm-line { margin: 4px 0 0; font-size: 15.5px; line-height: 1.45; }
.fm-line b { color: var(--pin); }
.fm-sub { margin: 6px 0 0; font-size: 13px; color: var(--dim); line-height: 1.5; }
.mini { margin-top: 10px; height: 40px; padding: 0 16px; border-radius: 12px; border: 0; background: var(--pin); color: #fff; font-weight: 700; font-size: 14.5px; }
.flag-today { margin: 12px 2px 0; font-size: 13px; color: var(--dim); line-height: 1.6; }
.flag-today b { color: var(--text); }

.cardview { width: 100%; aspect-ratio: 4 / 5; border-radius: 16px; overflow: hidden; background: var(--bg2); }
.cardview img { display: block; width: 100%; height: 100%; }
.fine { margin: 10px 0 0; font-size: 12.5px; color: var(--dim); line-height: 1.5; }
