/* 럭키스팟 — 모바일 우선. 그린 + 골드 테마. */
:root {
  --green-1: #1f7a3d;
  --green-2: #2faa57;
  --green-3: #58c97f;
  --green-soft: #e7f6ec;
  --gold-1: #b8860b;
  --gold-2: #e8b923;
  --gold-3: #ffd95e;
  --ink: #15241a;
  --muted: #6b7d70;
  --bg: #f4f9f5;
  --card-bg: #ffffff;
  --shadow: 0 6px 24px rgba(20, 60, 35, 0.12);
  --radius: 16px;
  --topbar-h: 52px;
  --nav-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Malgun Gothic", "맑은 고딕", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  overscroll-behavior: none;
}

.hidden { display: none !important; }

/* ---------- 버튼 ---------- */
.btn {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--green-2), var(--green-1));
  color: #fff;
  box-shadow: 0 4px 14px rgba(31, 122, 61, 0.3);
}
.btn-ghost {
  background: #fff;
  color: var(--green-1);
  border: 1.5px solid var(--green-soft);
}

/* ---------- 닉네임 게이트 ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 30% 20%, #dff3e6, #bfe6cc 70%);
}
.gate-card {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border-radius: 24px;
  padding: 36px 28px 28px;
  text-align: center;
  box-shadow: var(--shadow);
}
.gate-logo { font-size: 54px; line-height: 1; }
.gate-card h1 {
  margin: 10px 0 6px;
  font-size: 30px;
  letter-spacing: -0.5px;
  color: var(--green-1);
}
.gate-sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.5; }
#nickname-input {
  width: 100%;
  font-size: 16px;
  padding: 14px 16px;
  border: 1.5px solid #d7e8dd;
  border-radius: 12px;
  margin-bottom: 12px;
  outline: none;
  font-family: var(--font);
}
#nickname-input:focus { border-color: var(--green-2); }
#nickname-start { width: 100%; font-size: 16px; padding: 14px; }
.gate-hint { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.gate-guide { display: inline-block; margin: 14px 0 0; font-size: 13px; font-weight: 700; color: var(--green-1); text-decoration: none; }
.gate-guide:active { opacity: 0.7; }

/* ---------- 상단바 ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 16px;
  padding-right: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #e3efe7;
  z-index: 40;
}
.brand { font-weight: 800; color: var(--green-1); font-size: 16px; }
.topbar-right { display: flex; gap: 6px; align-items: center; }
.hud-chip {
  font-size: 12px;
  font-weight: 700;
  background: var(--green-soft);
  color: var(--green-1);
  padding: 5px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- 뷰 컨테이너 ---------- */
.view {
  position: fixed;
  top: calc(var(--topbar-h) + env(safe-area-inset-top));
  left: 0; right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  overflow: hidden;
}
.view-inner {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 24px;
}
.view-title { font-size: 22px; margin: 6px 0 16px; color: var(--ink); }
.sub-title { font-size: 16px; margin: 24px 0 10px; color: var(--muted); }

.map, .roadview { width: 100%; height: 100%; background: #dde7e0; }

/* 폴백 안내 */
.fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  background: var(--green-soft);
}

/* 로드뷰 보조 */
.rv-back {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 20;
  padding: 9px 14px;
  font-size: 14px;
  box-shadow: var(--shadow);
}
.rv-hint {
  position: absolute;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(20, 36, 26, 0.82);
  color: #fff;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  max-width: 88%;
  text-align: center;
}

/* ---------- 로드뷰 스팟/힌트 패널 ---------- */
.rv-spot-toggle {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 20;
  padding: 9px 14px;
  font-size: 14px;
  box-shadow: var(--shadow);
}
.rv-reload {
  position: absolute;
  top: 12px; right: 92px;
  z-index: 20;
  padding: 9px 12px;
  font-size: 15px;
  box-shadow: var(--shadow);
}
.spot-panel {
  position: absolute;
  left: 10px; right: 10px;
  bottom: 58px;
  max-height: 58%;
  z-index: 25;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.spot-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-weight: 800;
  color: var(--green-1);
  border-bottom: 1px solid #eef4f0;
}
.spot-panel-close {
  border: none; background: none; font-size: 16px; cursor: pointer; color: var(--muted);
}
.spot-list { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 10px 10px; }
.spot-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 6px;
  border-bottom: 1px solid #f2f6f3;
}
.spot-row.done { opacity: 0.55; }
.spot-main { flex: 1; min-width: 0; }
.spot-name { font-weight: 700; font-size: 14px; color: var(--ink); }
.spot-status { font-size: 12px; color: var(--muted); margin-top: 2px; }
.spot-hint { font-size: 12.5px; color: var(--green-1); margin-top: 6px; line-height: 1.5; }
.spot-hint .spot-face { margin-top: 6px; padding: 7px 12px; font-size: 13px; }
.spot-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.spot-btn { padding: 7px 10px; font-size: 12.5px; white-space: nowrap; }

/* ---------- 현장(GPS) 모드 ---------- */
.onsite-map { width: 100%; height: 46%; background: #dde7e0; }
.onsite-panel { height: 54%; display: flex; flex-direction: column; background: #fff; }
.onsite-head { padding: 10px 14px; font-size: 12.5px; font-weight: 800; color: var(--green-1); background: var(--green-soft); }
.onsite-status { padding: 12px 14px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.onsite-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.onsite-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid #f2f6f3; }
.onsite-row.done { opacity: 0.55; }
.os-main { flex: 1; min-width: 0; }
.os-name { font-weight: 700; font-size: 14px; color: var(--ink); }
.os-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.os-btn { padding: 8px 12px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }
.onsite-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; }

/* 4개 네비도 균등 */

/* ---------- 하단 네비 ---------- */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: #fff;
  border-top: 1px solid #e3efe7;
  z-index: 40;
}
.nav-btn {
  flex: 1;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}
.nav-btn span { font-size: 21px; }
.nav-btn.active { color: var(--green-1); }

/* ---------- 카드 그리드 ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.card-thumb {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  cursor: pointer;
  box-shadow: var(--shadow);
  background: #fff;
}
.card-thumb canvas { width: 100%; height: 100%; display: block; }
.card-thumb .tier-tag {
  position: absolute;
  top: 8px; left: 8px;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 999px;
  color: #fff;
}
.tier-normal { background: var(--green-2); }
.tier-gold { background: linear-gradient(135deg, var(--gold-2), var(--gold-1)); }

.empty-msg { color: var(--muted); text-align: center; margin-top: 40px; line-height: 1.6; }

/* ---------- 랭킹 ---------- */
.badge {
  font-size: 11px;
  font-weight: 700;
  background: #ffe9c7;
  color: #9a6a00;
  padding: 3px 8px;
  border-radius: 999px;
  vertical-align: middle;
}
.ranking-list, .ranking-region { display: flex; flex-direction: column; gap: 8px; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 2px 8px rgba(20, 60, 35, 0.06);
}
.rank-row.me { outline: 2px solid var(--green-3); }
.rank-no { font-weight: 800; color: var(--green-1); width: 28px; text-align: center; }
.rank-no.top1 { color: var(--gold-1); }
.rank-name { flex: 1; font-weight: 700; }
.rank-meta { font-size: 12px; color: var(--muted); }
.rank-score { font-weight: 800; color: var(--ink); }
.region-tag { font-size: 12px; color: var(--muted); margin-right: 4px; }

/* 내 기록 카드 */
.my-rank-card {
  background: linear-gradient(135deg, var(--green-soft), #fff);
  border: 1px solid #d7e8dd;
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.mrc-nick { font-weight: 800; font-size: 16px; color: var(--green-1); }
.mrc-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--ink); }
.mrc-rank { margin-top: 8px; font-size: 13px; color: var(--muted); }
.mrc-rank b { color: var(--green-1); font-size: 15px; }

/* 포디움 Top3 */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
  min-height: 10px;
}
.podium-col {
  flex: 1;
  max-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.podium-medal { font-size: 30px; line-height: 1; }
.podium-name {
  font-weight: 800; font-size: 13px; margin-top: 4px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.podium-score { font-size: 13px; font-weight: 800; color: var(--green-1); margin-bottom: 6px; }
.podium-bar { width: 100%; border-radius: 10px 10px 0 0; }
.podium-col.first .podium-bar { height: 70px; background: linear-gradient(180deg, var(--gold-2), var(--gold-1)); }
.podium-col.second .podium-bar { height: 52px; background: linear-gradient(180deg, #c8d3cd, #97a8a0); }
.podium-col.third .podium-bar { height: 38px; background: linear-gradient(180deg, #e0b48a, #b9824f); }
.podium-col.me .podium-name { color: var(--green-1); }
.podium-col.me .podium-bar { outline: 2px solid var(--green-3); outline-offset: -2px; }

.ranking-note {
  margin-top: 20px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
  background: #f1f6f2;
  border-radius: 10px;
  padding: 10px 12px;
}

/* ---------- 획득 오버레이 ---------- */
.claim-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 24, 15, 0.55);
  backdrop-filter: blur(3px);
}
.claim-pop {
  background: #fff;
  border-radius: 24px;
  padding: 32px 28px;
  text-align: center;
  max-width: 320px;
  width: 84%;
  box-shadow: var(--shadow);
  animation: pop-in 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.claim-icon { font-size: 72px; animation: bounce 0.6s ease 0.1s 2; }
.claim-title { font-size: 24px; font-weight: 800; margin: 8px 0 4px; color: var(--green-1); }
.claim-title.gold { color: var(--gold-1); }
.claim-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; min-height: 18px; }
@keyframes pop-in { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}

/* ---------- 카드 모달 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 24, 15, 0.7);
  padding: 20px;
}
.modal-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 360px;
  width: 100%;
}
.modal-close {
  position: absolute;
  top: -8px; right: -4px;
  width: 36px; height: 36px;
  border-radius: 999px;
  border: none;
  background: #fff;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 2;
}
.card-canvas {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 2 / 3;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  background: #fff;
}
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.card-actions .btn { font-size: 14px; padding: 11px 14px; }
.photo-label { display: inline-flex; align-items: center; }

/* ---------- 게이트 빌런 경고 ---------- */
.gate-warn {
  margin: 16px 0 0;
  font-size: 12.5px;
  color: #b5557a;
  background: #fff0f6;
  border: 1px solid #ffd6e6;
  border-radius: 12px;
  padding: 9px 12px;
  line-height: 1.4;
}
.gate-warn b { color: #d6336c; }

/* ---------- 지도 오버레이: 이벤트 + 오늘의 스팟 ---------- */
.map-overlay {
  position: absolute;
  top: 10px; left: 10px; right: 10px;
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.map-overlay > * { pointer-events: auto; }

.event-banners { display: flex; flex-direction: column; gap: 8px; }
.event-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e3efe7;
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.event-emoji { font-size: 22px; line-height: 1.2; }
.event-text { flex: 1; min-width: 0; }
.event-title { font-weight: 800; font-size: 13.5px; color: var(--ink); }
.event-body { font-size: 12px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.event-close {
  border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: 15px; padding: 2px 4px; line-height: 1;
}

.today-spot {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  cursor: pointer;
  border-radius: 14px;
  padding: 11px 14px;
  font-family: var(--font);
  color: #5a4300;
  background: linear-gradient(135deg, var(--gold-3), var(--gold-2));
  box-shadow: 0 4px 16px rgba(184, 134, 11, 0.35);
}
.today-spot .ts-emoji { font-size: 24px; }
.today-spot .ts-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.today-spot .ts-text b { font-size: 14px; font-weight: 800; }
.today-spot .ts-sub { font-size: 12px; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-spot .ts-go { font-weight: 800; font-size: 13px; white-space: nowrap; }

/* ---------- 함정 흔들기 잠금 ---------- */
.shake-overlay {
  position: fixed;
  inset: 0;
  z-index: 98;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(40, 12, 12, 0.72);
  backdrop-filter: blur(4px);
  padding: 24px;
}
.shake-card {
  background: #fff;
  border-radius: 24px;
  padding: 32px 26px 26px;
  text-align: center;
  max-width: 340px;
  width: 88%;
  box-shadow: var(--shadow);
  animation: shake-in 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
.shake-villain { width: 96px; height: 96px; margin: 0 auto; animation: wiggle 0.7s ease-in-out infinite; }
.shake-villain svg { display: block; }
.shake-title { font-size: 24px; font-weight: 800; color: #d6336c; margin: 6px 0 4px; }
.shake-line { font-size: 13.5px; color: #b5557a; font-weight: 700; margin-bottom: 8px; min-height: 18px; line-height: 1.4; }
.shake-sub { font-size: 14px; color: var(--muted); line-height: 1.5; margin-bottom: 18px; }
.shake-sub b { color: #c0392b; }
.shake-count { font-size: 30px; font-weight: 800; color: var(--ink); margin-bottom: 10px; }
.shake-count #shake-num { color: var(--green-1); }
.shake-bar {
  height: 12px;
  background: #f0e3e3;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}
.shake-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green-3), var(--green-1));
  border-radius: 999px;
  transition: width 0.12s ease;
}
.shake-card .btn { width: 100%; }
.shake-tap { margin-top: 10px; font-size: 13px; }
@keyframes shake-in {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
  100% { transform: translateX(0); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(12deg); }
}

/* ---------- 제휴 쿠폰 ---------- */
.coupons-section { margin-bottom: 22px; }
.coupons-list { display: flex; flex-direction: column; gap: 8px; }
.coupon-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #fff7e6, #fff);
  border: 1px solid #ffe2b0;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.12);
}
.cr-logo { font-size: 26px; }
.cr-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cr-main b { font-size: 14px; color: var(--ink); }
.cr-main span { font-size: 12.5px; color: var(--gold-1); font-weight: 700; }
.cr-go { font-weight: 800; font-size: 13px; color: var(--gold-1); white-space: nowrap; }

.coupon-card {
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px 24px;
  max-width: 320px;
  width: 86%;
  text-align: center;
  box-shadow: var(--shadow);
  border: 3px dashed var(--gold-2);
}
#coupon-body .coupon-logo { font-size: 56px; line-height: 1; }
#coupon-body .coupon-sponsor { font-size: 18px; font-weight: 800; color: var(--ink); margin-top: 6px; }
#coupon-body .coupon-offer { font-size: 22px; font-weight: 800; color: var(--gold-1); margin: 8px 0 14px; }
#coupon-body .coupon-code {
  font-family: monospace;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--ink);
  background: #fff7e6;
  border: 1px dashed var(--gold-2);
  border-radius: 10px;
  padding: 10px;
}
#coupon-body .coupon-note { font-size: 13px; color: var(--muted); margin-top: 12px; line-height: 1.5; }
#coupon-body .coupon-valid { font-size: 12px; color: var(--muted); margin-top: 6px; }
#coupon-body .coupon-foot {
  font-size: 12px; color: var(--gold-1); font-weight: 700;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid #f0e3c8;
}

/* ---------- 토스트 ---------- */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 36, 26, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 110;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* iOS 100vh 대응: dvh 지원 시 */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}
