:root {
  --bg: #120e1a;
  --card: #1d1729;
  --chip: #251e34;
  --line: #2f2642;
  --text: #f6f2ff;
  --muted: #a89fbf;
  --gold: #ffc83d;
  --gold-2: #ff9f1c;
  --pink: #ff4d6d;
  --radius: 20px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

body {
  min-height: 100vh;
  background: radial-gradient(1000px 520px at 50% -8%, #2d1f4a 0%, var(--bg) 62%) no-repeat;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }

.app {
  max-width: 460px;
  margin: 0 auto;
  /* 휴대폰 노치·홈 바 영역을 피해서 (홈 화면에서 열었을 때) */
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    calc(40px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}

/* ---------- 헤더 ---------- */
.top { display: flex; align-items: center; justify-content: space-between; }
.logo { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: -0.5px; }
.logo span { color: var(--gold); }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card);
  font-size: 18px; cursor: pointer;
}

/* ---------- 무대: 룰렛과 결과가 같은 자리에 겹침 ---------- */
.stage {
  display: grid;
  margin-top: 10px;
}
.stage > .wheel-view,
.stage > .result {
  grid-area: 1 / 1;
  align-self: center;
}

/* 룰렛 (돌아올 때) */
.wheel-view {
  padding-top: 18px;
  text-align: center;
  transition: opacity .35s, transform .55s cubic-bezier(.2, .9, .3, 1.15), visibility 0s;
}
/* 룰렛 (결과가 나오면 빙글 돌며 작아져 사라짐) */
.stage.show-result .wheel-view {
  visibility: hidden;
  opacity: 0;
  transform: scale(.2) rotate(200deg);
  pointer-events: none;
  transition: opacity .45s, transform .55s cubic-bezier(.55, 0, .8, .2), visibility 0s .55s;
}

.wheel-wrap {
  position: relative;
  width: min(88vw, 400px);
  aspect-ratio: 1;
  margin: 0 auto;
}
#wheel {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(255, 200, 61, .10), 0 22px 50px rgba(0, 0, 0, .55);
  cursor: pointer;
}
.wheel-wrap.spinning #wheel { animation: glow .5s ease-in-out infinite alternate; }
.wheel-wrap.win #wheel { box-shadow: 0 0 0 6px rgba(255, 200, 61, .35), 0 0 46px 10px rgba(255, 200, 61, .5); }

.pointer {
  position: absolute;
  top: -16px;
  left: 50%;
  z-index: 3;
  width: 36px;
  height: 46px;
  transform: translateX(-50%);
  transform-origin: 50% 18%;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .5));
}
.pointer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(#fff6cf, var(--gold) 55%, #d48a00);
  clip-path: polygon(50% 100%, 4% 10%, 50% 0, 96% 10%);
}

.spin-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 27%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 4px solid #fff3c4;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8499, var(--pink) 58%, #b3163a);
  color: #fff;
  font-size: clamp(17px, 5.4vw, 23px);
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5), inset 0 -4px 0 rgba(0, 0, 0, .2);
  cursor: pointer;
  animation: pulse 1.6s ease-in-out infinite;
}
.spin-btn:disabled { animation: none; filter: brightness(.8); cursor: default; }

.caption { margin: 14px 0 0; min-height: 20px; font-size: 13px; color: var(--muted); }
.caption.shaking { color: var(--gold); font-size: 16px; font-weight: 900; animation: shake .18s linear infinite; }
.caption.decided { color: var(--gold); font-size: 20px; font-weight: 900; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }

/* 결과 카드 (평소엔 숨어 있음) */
.result {
  visibility: hidden;
  opacity: 0;
  transform: scale(.85) translateY(12px);
  pointer-events: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
  transition: opacity .25s, transform .25s, visibility 0s .25s;
}
/* 결과 카드 (룰렛이 사라진 뒤 튀어나옴) */
.stage.show-result .result {
  visibility: visible;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition: opacity .45s .4s, transform .65s .4s cubic-bezier(.2, 1.4, .4, 1), visibility 0s .4s;
}
.result-photo {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #3b2a5e, #1d1729) center / cover no-repeat;
}
.result-photo:not(.has-photo)::after { content: "🍽️"; font-size: 72px; }
.stage.show-result .result-photo { animation: reveal 1.1s .4s cubic-bezier(.2, .8, .2, 1) both; }
.result-body { padding: 14px 16px 16px; }
.result-kicker { margin: 0; color: var(--gold); font-size: 13px; font-weight: 800; letter-spacing: .5px; }
.result-name { margin: 4px 0 6px; font-size: 34px; font-weight: 900; letter-spacing: -0.5px; line-height: 1.15; }
.stage.show-result .result-name { animation: pop .55s .75s cubic-bezier(.2, 1.6, .4, 1) both; }
.result-desc { margin: 0; color: var(--muted); font-size: 14px; }
.again-btn {
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--pink), #d61f50);
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 6px 18px rgba(255, 77, 109, .35);
  cursor: pointer;
}
.again-btn:active { transform: scale(.98); }
.again-btn:disabled { opacity: .6; cursor: default; }

/* ---------- 주변 음식점 ---------- */
.nearby {
  margin-top: 14px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.nearby h3 { margin: 0; font-size: 17px; font-weight: 900; }
.nearby-base { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.nearby-base .link { padding: 0; }
.nearby-status { margin: 10px 0 0; font-size: 13px; line-height: 1.5; color: #d9cfff; }
.area-form { display: flex; gap: 8px; margin-top: 10px; }
.area-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #15101f;
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.area-form button {
  flex: none;
  padding: 10px 18px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #2a1a00;
  font-weight: 900;
  cursor: pointer;
}
.radius-chips { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.radius-label { flex: none; margin-right: 2px; font-size: 12px; color: var(--muted); }
.radius-chips button {
  flex: 1;
  min-height: 36px;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--chip);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.radius-chips button.on { border-color: transparent; background: linear-gradient(135deg, var(--gold), var(--gold-2)); color: #2a1a00; }
.nearby-warn { margin: 8px 0 0; padding: 8px 10px; border-radius: 10px; background: rgba(255, 183, 3, .12); color: #ffd98a; font-size: 12px; line-height: 1.5; }
.nearby-more {
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.nearby-force {
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.place-list { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.place-list:empty { display: none; }
.place { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--chip); }
.place-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.place-name { min-width: 0; font-size: 15px; font-weight: 800; overflow-wrap: anywhere; }
.place-dist { flex: none; color: var(--gold); font-size: 14px; font-weight: 900; white-space: nowrap; }
.place-meta { margin: 4px 0 0; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.place-actions { display: flex; gap: 8px; margin-top: 10px; }
.place-phone, .place-map {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}
.place-phone { background: #2e2542; color: var(--text); }
.place-phone.none { color: var(--muted); font-weight: 500; }
.place-map { border: 0; background: linear-gradient(135deg, var(--gold), var(--gold-2)); color: #2a1a00; cursor: pointer; }
.nearby-note { margin: 10px 0 0; font-size: 11px; color: #7f7697; }

/* ---------- 지도 창 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(8, 5, 14, .72);
}
@media (min-width: 600px) { .modal { align-items: center; } }
.modal-card { width: 100%; max-width: 460px; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: 20px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; }
.modal-head h3 { min-width: 0; margin: 0; font-size: 17px; font-weight: 900; overflow-wrap: anywhere; }
.map-view { height: min(52vh, 380px); background: #2a2238; }
.map-info { margin: 12px 14px 0; color: var(--gold); font-size: 15px; font-weight: 900; }
.map-info:empty, .map-addr:empty { display: none; }
.map-addr { margin: 4px 14px 0; font-size: 12px; color: var(--muted); }
.map-links { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 14px; }
.map-links a {
  flex: 1 1 28%;
  padding: 11px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
}
.map-links a.primary { border-color: transparent; background: var(--pink); }
.me-dot {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}
.shop-tag { padding: 4px 8px; border-radius: 8px; background: #fff; color: #111; font-size: 12px; font-weight: 800; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
body.modal-open { overflow: hidden; }

/* ---------- 설정 ---------- */
.settings {
  margin-top: 18px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.group + .group { margin-top: 14px; }
.group h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 700; }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chips.three { grid-template-columns: repeat(3, 1fr); }
.chip {
  padding: 11px 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chip);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .12s, background .15s, box-shadow .15s;
}
.chip:active { transform: scale(.96); }
.chip.on {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #2a1a00;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(255, 200, 61, .35);
}
.chip:disabled { opacity: .55; cursor: default; }

.toggle { display: flex; align-items: center; gap: 12px; margin-top: 16px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  flex: none; position: relative; width: 46px; height: 26px;
  border-radius: 13px; background: #3a3150; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform .2s;
}
.toggle input:checked + .switch { background: var(--pink); }
.toggle input:checked + .switch::after { transform: translateX(20px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--gold); outline-offset: 2px; }
.toggle-text { font-size: 14px; font-weight: 700; }
.toggle-text small { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--muted); }

/* ---------- 하단 ---------- */
.foot { margin-top: 28px; text-align: center; }
.install-btn {
  width: 100%;
  margin-bottom: 14px;
  padding: 13px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #2a1a00;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}
.install-hint { margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: 13px; color: var(--text); }
.link { border: 0; background: none; color: var(--muted); font-size: 12px; text-decoration: underline; cursor: pointer; }
.credits {
  margin-top: 10px;
  max-height: 280px;
  overflow: auto;
  padding: 12px 14px;
  text-align: left;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.credits h4 { margin: 8px 0 4px; font-size: 12px; color: var(--text); }
.credits h4:first-child { margin-top: 0; }
.credits ul { margin: 0; padding-left: 16px; }
.credits a { color: #c9bff0; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- 애니메이션 ---------- */
@keyframes pulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.07); } }
@keyframes glow {
  from { box-shadow: 0 0 0 6px rgba(255, 200, 61, .15), 0 0 18px 2px rgba(255, 77, 109, .35); }
  to   { box-shadow: 0 0 0 6px rgba(255, 200, 61, .35), 0 0 42px 10px rgba(255, 77, 109, .55); }
}
@keyframes reveal { from { transform: scale(1.2); filter: blur(16px) brightness(1.8); } to { transform: none; filter: none; } }
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes shake { 0% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }

@media (prefers-reduced-motion: reduce) {
  .spin-btn, .wheel-wrap.spinning #wheel, .caption.shaking { animation: none; }
}
