/* ── 골라 — 전역 ── */
:root {
  --bg: #fbfbfd;
  --bg-soft: #ffffff;
  --line: #e4e6ef;
  --text: #171922;
  --muted: #6d7488;
  --faint: #9aa1b3;
  --accent: #ff7a45;
  --accent-2: #ff4d6d;

  --cat-dining: #ff7043;
  --cat-cafe: #f5a623;
  --cat-bar: #7c5cff;
  --cat-life: #17a2a2;
  --cat-other: #6b7a90;

  --shadow-card: 0 2px 10px rgba(23, 25, 34, 0.06);
  --shadow-lg: 0 16px 44px rgba(23, 25, 34, 0.16);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Malgun Gothic",
    "Apple SD Gothic Neo", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.screen {
  position: fixed;
  inset: 0;
}

.screen[hidden] {
  display: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* ── 홈 — 미니게임 카드 ── */
.screen--home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 32px 20px;
  overflow-y: auto;
  background:
    radial-gradient(900px 520px at 12% -12%, rgba(255, 122, 69, 0.16), transparent 62%),
    radial-gradient(820px 520px at 102% 108%, rgba(124, 92, 255, 0.12), transparent 62%),
    var(--bg);
}

.home__head {
  text-align: center;
}

.home__title {
  margin: 0;
  font-size: clamp(38px, 8vw, 60px);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(100deg, var(--text) 12%, var(--accent) 68%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.home__sub {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 260px));
  gap: 18px;
  justify-content: center;
  width: 100%;
  max-width: 860px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 26px 22px 22px;
  min-height: 250px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg-soft);
  box-shadow: var(--shadow-card);
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s var(--ease), border-color 0.25s, box-shadow 0.25s;
}

.card--live::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 20px;
  padding: 1px;
  background: linear-gradient(150deg, var(--accent), var(--accent-2), transparent 65%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.card--live:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.card__icon {
  font-size: 42px;
  line-height: 1.1;
  margin-top: 6px;
}

.card__name {
  font-size: 21px;
  font-weight: 700;
}

.card__desc {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}

.card__go {
  margin-top: auto;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}

.home__foot {
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}

/* ── 룰렛 · 링크 입력 ── */
.stage {
  position: absolute;
  inset: 0;
}

.stage[hidden] {
  display: none;
}

.stage--link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(760px 440px at 50% -4%, rgba(255, 122, 69, 0.14), transparent 66%),
    var(--bg);
}

.back {
  position: absolute;
  top: 22px;
  left: 22px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.back:hover {
  color: var(--text);
}

.linkbox {
  width: min(560px, 100%);
  text-align: center;
}

.linkbox__icon {
  font-size: 52px;
}

.linkbox__title {
  margin: 10px 0 0;
  font-size: 28px;
  font-weight: 800;
}

.linkbox__lead {
  margin: 12px 0 26px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.7;
}

.linkbox__lead b {
  color: var(--text);
}

.linkform {
  display: flex;
  gap: 10px;
}

.linkform__input {
  flex: 1;
  min-width: 0;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.linkform__input:focus {
  border-color: var(--accent);
}

.linkform__input::placeholder {
  color: var(--faint);
}

.linkform__submit {
  padding: 15px 24px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
}

.linkform__submit:disabled {
  opacity: 0.55;
  cursor: progress;
}

.linkform__error,
.linkform__status {
  margin: 14px 0 0;
  font-size: 13.5px;
  line-height: 1.6;
}

.linkform__error {
  color: #d92d3e;
}

.linkform__status {
  color: var(--muted);
}

.linkbox__note {
  margin: 30px 0 0;
  color: var(--faint);
  font-size: 12.5px;
  line-height: 1.7;
}

.linkbox__note b {
  color: var(--muted);
}

/* 안내가 두 줄이다. 그대로 두면 위의 30px 이 사이에도 들어가서 서로 남남처럼
   보인다. 둘째 줄부터는 붙여서 한 덩어리로 읽히게 한다. */
.linkbox__note + .linkbox__note {
  margin-top: 8px;
}

/* ── 룰렛 · 지도 ── */
/* 네이버 지도 SDK는 컨테이너에 position:relative 를 인라인으로 박는다.
   그러면 inset:0 이 크기를 만들지 못해 높이가 0으로 접힌다.
   인라인 스타일과 싸우는 대신 크기를 명시한다. */
.map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* 룰렛이 도는 동안 지도 바닥을 어둡게 깐다.
   z-index가 낮아야 마커(칩)가 이 위에 밝게 뜬다. 클릭은 .skipcatch 가 받는다. */
.dim {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 16, 0.42);
  pointer-events: none;
  z-index: 5;
  animation: fade-in 0.35s var(--ease);
}

.dim[hidden] {
  display: none;
}

/* 마커 위에 덮이는 투명한 클릭 판. 어디를 눌러도 연출을 건너뛴다.
   배경이 없으므로 아래의 칩은 그대로 밝게 보인다. */
.skipcatch {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 108px;
  border: 0;
  background: transparent;
  z-index: 28;
  cursor: pointer;
}

.skipcatch[hidden] {
  display: none;
}

.skipcatch__hint {
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(16, 18, 24, 0.78);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12.5px;
  font-weight: 600;
  animation: hint-pulse 1.9s ease-in-out infinite;
}

@keyframes hint-pulse {
  50% {
    opacity: 0.5;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.topbar {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.16);
  color: #16181d;
  /* 룰렛이 시작·종료될 때 부드럽게 물러났다 돌아온다 */
  transition: opacity 0.35s var(--ease);
}

.topbar__back {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: #f0f1f4;
  color: #16181d;
  font-size: 17px;
}

.topbar__back:hover {
  background: #e3e5ea;
}

.topbar__meta {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.topbar__title {
  font-size: 14.5px;
  font-weight: 700;
}

.topbar__count {
  color: #7b8395;
  font-size: 11.5px;
}

.filters {
  position: absolute;
  top: 68px;
  left: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  transition: opacity 0.35s var(--ease);
}

.filters__row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  pointer-events: auto;
  scrollbar-width: none;
}

.filters__row::-webkit-scrollbar {
  display: none;
}

.filters__row[hidden] {
  display: none;
}

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  color: #2b2f38;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s var(--ease), background 0.15s;
}

.chip:hover {
  transform: translateY(-1px);
}

.chip[aria-pressed="true"] {
  background: #16181d;
  color: #fff;
  border-color: #16181d;
}

.chip__n {
  color: #9aa1b1;
  font-size: 11.5px;
  font-weight: 700;
}

.chip[aria-pressed="true"] .chip__n {
  color: rgba(255, 255, 255, 0.62);
}

.filters__row--detail .chip {
  padding: 6px 12px;
  font-size: 12.5px;
}

/* 랜덤뽑기 버튼 */
/* 룰렛 중에는 막(.dim) 위로 올라와 '바로 보기' 버튼이 된다 */
.spin {
  position: absolute;
  right: 18px;
  bottom: 22px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 16px 24px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 10px 30px rgba(255, 77, 109, 0.42);
  transition: transform 0.18s var(--ease), box-shadow 0.18s;
}

.spin:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
}

.spin:disabled {
  opacity: 0.62;
  cursor: default;
}

.spin__icon {
  font-size: 19px;
}

.spin.is-spinning .spin__icon {
  animation: spin-shake 0.45s linear infinite;
}

@keyframes spin-shake {
  0%,
  100% {
    transform: rotate(-11deg);
  }
  50% {
    transform: rotate(11deg);
  }
}

/* 안내 토스트 */
.toast {
  position: absolute;
  left: 50%;
  bottom: 104px;
  z-index: 30;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 12px;
  background: rgba(16, 18, 24, 0.92);
  color: #fff;
  font-size: 13.5px;
  white-space: nowrap;
  animation: toast-in 0.28s var(--ease);
}

.toast[hidden] {
  display: none;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
}

/* ── 지도 위 POI 칩 — 네이버 지도의 네모 아이콘을 흉내낸다 ── */
.poi {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 150px;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.28s var(--ease);
}

.poi__pin {
  position: relative;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 2px solid #fff;
  border-radius: 9px;
  background: var(--cat-other);
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.3);
  font-size: 14px;
  line-height: 1;
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease);
}

.poi[data-cat="DINING"] .poi__pin {
  background: var(--cat-dining);
}
.poi[data-cat="CAFE"] .poi__pin {
  background: var(--cat-cafe);
}
.poi[data-cat="BAR"] .poi__pin {
  background: var(--cat-bar);
}
.poi[data-cat="LIFE_CULTURE"] .poi__pin {
  background: var(--cat-life);
}

.poi__name {
  margin-top: 3px;
  max-width: 100%;
  overflow: hidden;
  color: #23262d;
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow:
    0 0 3px #fff,
    0 0 3px #fff,
    0 0 5px #fff;
  transition: color 0.22s, font-size 0.22s var(--ease);
}

/* 넓게 보고 있을 때는 이름을 접어 겹침을 막는다 (map-naver.js 의 density) */
.map[data-density="icon"] .poi__name,
.map[data-density="dot"] .poi__name {
  display: none;
}

.map[data-density="dot"] .poi__pin {
  width: 15px;
  height: 15px;
  border-width: 1.5px;
  border-radius: 5px;
  font-size: 0;
}

/* 당첨된 곳은 아무리 멀리서 봐도 이름이 보여야 한다 */
.map[data-density] .poi.is-won .poi__name,
.map[data-density] .poi.is-lit .poi__name {
  display: block;
}

.map[data-density="dot"] .poi.is-won .poi__pin,
.map[data-density="dot"] .poi.is-lit .poi__pin {
  width: 27px;
  height: 27px;
  border-width: 2px;
  border-radius: 9px;
  font-size: 14px;
}

/* 폐업 */
.poi[data-closed] {
  opacity: 0.4;
}

.poi[data-closed] .poi__pin {
  background: #9aa1b1;
}

/* 룰렛이 돌면서 잠깐 켜지는 상태 */
.poi.is-lit .poi__pin {
  transform: scale(1.75);
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.95),
    0 0 0 8px rgba(255, 122, 69, 0.55),
    0 6px 18px rgba(0, 0, 0, 0.35);
}

.poi.is-lit .poi__name {
  color: #ff4d6d;
  font-size: 13px;
}

/* 당첨 */
.poi.is-won .poi__pin {
  transform: scale(2.1);
  box-shadow:
    0 0 0 5px #fff,
    0 0 0 11px rgba(255, 77, 109, 0.85),
    0 10px 26px rgba(0, 0, 0, 0.4);
  animation: won-bounce 0.65s var(--ease);
}

.poi.is-won .poi__name {
  color: #ff2d55;
  font-size: 14px;
}

.poi.is-won::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 50%;
  width: 27px;
  height: 27px;
  margin: -13px 0 0 -13px;
  border: 3px solid rgba(255, 77, 109, 0.9);
  border-radius: 12px;
  animation: won-ring 1.15s var(--ease) infinite;
  pointer-events: none;
}

@keyframes won-bounce {
  0% {
    transform: scale(1.75);
  }
  45% {
    transform: scale(2.5);
  }
  100% {
    transform: scale(2.1);
  }
}

@keyframes won-ring {
  0% {
    opacity: 0.85;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(3.4);
  }
}

/* 룰렛 중에는 대상이 아닌 칩을 죽인다 */
.is-spinning-map .poi:not(.is-candidate) {
  opacity: 0.22;
}

/* 돌아가는 동안에는 상단 UI 도 같이 물러난다.
   지도만 어두워지고 카테고리 바가 그대로 밝으면 시선이 그쪽으로 끌린다. */
.is-spinning-map .topbar,
.is-spinning-map .filters {
  opacity: 0.2;
  pointer-events: none;
}

/* ── 결과 카드 ── */
.result {
  position: absolute;
  left: 50%;
  bottom: 20px;
  z-index: 40;
  width: min(430px, calc(100% - 28px));
  transform: translateX(-50%);
  border-radius: 20px;
  background: #fff;
  color: #16181d;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: result-up 0.42s var(--ease);
}

.result[hidden] {
  display: none;
}

@keyframes result-up {
  from {
    opacity: 0;
    transform: translate(-50%, 26px);
  }
}

.result__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 22, 28, 0.55);
  color: #fff;
  font-size: 13px;
  line-height: 1;
}

.result__photo {
  height: 152px;
  background: #e9ebef center/cover no-repeat;
}

.result__photo:empty {
  display: none;
}

.result__body {
  padding: 18px 20px 20px;
}

.result__tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff0eb;
  color: #e2532c;
  font-size: 11.5px;
  font-weight: 700;
}

.result__name {
  margin: 10px 0 6px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.result__addr {
  margin: 0 0 16px;
  color: #6d7488;
  font-size: 13px;
  line-height: 1.55;
}

.result__actions {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  padding: 13px 12px;
  border: 0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  /* 좁은 화면에서 버튼 글자가 두 줄로 갈라지지 않게 한다 */
  white-space: nowrap;
}

.btn--ghost {
  background: #f1f2f6;
  color: #3a3f4d;
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

/* ── 좁은 화면 ── */
@media (max-width: 560px) {
  .cards {
    grid-template-columns: minmax(0, 1fr);
    max-width: 340px;
  }

  .card {
    min-height: 0;
  }

  .linkform {
    flex-direction: column;
  }

  .spin {
    right: 14px;
    bottom: 16px;
    padding: 14px 20px;
    font-size: 15px;
  }

  .filters {
    top: 64px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
