/* 스트레스 철거 v2 — 캘크닷 미니게임 (calcdot sunset family) + 실제 지도 3D */
:root {
  --bg: #fff0e4;
  --paper: #fffaf4;
  --ink: #2a1208;
  --muted: #6b4534;
  --accent: #c03912;
  --accent-ink: #ffffff;
  --accent-glow: rgba(192, 57, 18, .28);
  --chip: #ffe1c8;
  --line: #f0cdb3;
  --warn: #8a2f15;
  --ok: #0b6a40;
  --ring: #ffb020;
  --sticker: #ffd36a;
  --sticker-ink: #2a1208;
  --shadow: 0 10px 32px rgba(42, 18, 8, .08);
  --score-bg: #2a1208;
  --score-ink: #fff4ea;
  --score-muted: #e2b89a;
  --score-num: #ffb020;
}

* { box-sizing: border-box; }
html {
  font-size: 17px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  word-break: keep-all;
  overflow-wrap: break-word;
  line-break: strict;
}
body {
  margin: 0;
  background:
    radial-gradient(circle at 12% -8%, rgba(255, 176, 32, .55), transparent 36%),
    radial-gradient(circle at 100% 8%, rgba(212, 72, 22, .22), transparent 34%),
    repeating-linear-gradient(-55deg, transparent 0 16px, rgba(192, 57, 18, .04) 16px 17px),
    var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Nunito", "Malgun Gothic", sans-serif;
  line-height: 1.65;
  min-height: 100dvh;
  overflow-x: hidden;
}
a { color: var(--accent); }
img { max-width: 100%; }
.wrap { width: min(1120px, calc(100% - 28px)); margin: 0 auto; }
.nowrap { white-space: nowrap; }

.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px; }
.skip:focus { left: 8px; z-index: 40; }

header.site {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
}
header.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 12px 0;
}
.logo, .logo.brand {
  font-weight: 900;
  letter-spacing: -0.05em;
  text-decoration: none;
  color: var(--ink);
  font-size: 1.12rem;
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.logo span, .logo.brand span {
  background: var(--sticker);
  color: var(--sticker-ink);
  border-radius: 999px;
  padding: 1px 8px 2px;
  font-size: .72rem;
  letter-spacing: 0.04em;
  margin-left: 4px;
  font-weight: 800;
}
nav { display: flex; flex-wrap: wrap; gap: 6px 4px; }
nav a {
  color: var(--muted);
  text-decoration: none;
  margin: 0;
  font-size: .86rem;
  font-weight: 650;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
nav a:hover, nav a:focus-visible, a[aria-current="page"] {
  color: var(--ink);
  background: var(--chip);
}
@media (max-width: 720px) {
  header.site .wrap { flex-direction: column; align-items: flex-start; padding: 8px 0; }
  header.site nav { width: 100%; justify-content: flex-start; gap: 4px 2px; }
  nav a { font-size: .8rem; padding: 6px 8px; }
}

.hero { padding: 28px 0 12px; }
.hero p.kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-weight: 800;
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}
h1 {
  font-size: clamp(1.7rem, 6.6vw, 2.8rem);
  letter-spacing: -0.05em;
  line-height: 1.22;
  margin: 0 0 14px;
  font-weight: 900;
}
.lead { font-size: 1.05rem; color: var(--muted); margin: 0 0 10px; max-width: 38em; }
.note { font-size: .9rem; color: var(--muted); margin: 8px 0 0; }

.card, .game-card, .receipt {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.game-card { border-radius: 28px; padding: 14px 14px 16px; }
.receipt { border-radius: 28px; padding: 22px 20px 20px; max-width: 460px; margin: 0 auto; }

.how {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 18px 0 22px;
  padding: 0;
  list-style: none;
}
.how li {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: var(--shadow);
}
.how .num {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--sticker);
  color: var(--sticker-ink);
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.04em;
}
.how p { margin: 0; color: var(--muted); }
.how strong { color: var(--ink); font-weight: 800; }

.best {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.best h2 { margin: 0 0 8px; font-size: 1rem; letter-spacing: -0.04em; }
.best ol { margin: 0; padding-left: 1.2em; color: var(--muted); font-variant-numeric: tabular-nums; }
.best li { margin: 2px 0; }

.btns, .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
button, .btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  min-height: 44px;
  min-width: 44px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: inherit;
}
button.primary, .btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 8px 20px var(--accent-glow);
}
button.primary:hover, .btn.primary:hover { filter: brightness(1.05); }
button.ghost, .btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
button.sticker, .btn.sticker {
  background: var(--sticker);
  color: var(--sticker-ink);
  box-shadow: 0 6px 16px rgba(255, 179, 32, .35);
}
button:disabled, .btn[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
}
button:focus-visible, .btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

.actions .btn, .actions button {
  width: 100%;
  min-height: 52px;
  font-size: 1.05rem;
}
.actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 520px) {
  .actions.dual { grid-template-columns: 1fr 1fr; }
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.hud .level-name {
  font-weight: 900;
  letter-spacing: -0.04em;
  font-size: 1.02rem;
  margin: 0;
  line-height: 1.3;
}
.hud .meta {
  margin: 0;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hud-right { display: flex; align-items: center; gap: 8px; }
#sound-btn {
  padding: 8px 12px;
  min-height: 44px;
  font-size: .85rem;
  background: var(--chip);
  color: var(--ink);
}
.budget-chip {
  display: inline-flex;
  align-items: center;
  background: var(--sticker);
  color: var(--sticker-ink);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: .78rem;
  font-weight: 800;
  margin: 0 0 10px;
  font-variant-numeric: tabular-nums;
}

.receipt-head {
  text-align: center;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 12px;
  margin-bottom: 12px;
}
.receipt-head .kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-weight: 800;
  font-size: .75rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.receipt-head h2 {
  margin: 0 0 4px;
  font-size: 1.4rem;
  letter-spacing: -0.04em;
}
.receipt-head p { margin: 0; color: var(--muted); font-size: .92rem; }

.receipt-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: .95rem;
}
.receipt-table th, .receipt-table td {
  text-align: left;
  padding: 6px 0;
  font-weight: 650;
}
.receipt-table td:last-child, .receipt-table th:last-child { text-align: right; }
.receipt-table tr.total td {
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  font-weight: 900;
  font-size: 1.02rem;
}
.receipt-table .gain { color: var(--ok); }
.receipt-table .loss { color: var(--accent); }

.medal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 16px 0 8px;
}
.badge {
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 900;
  font-size: .9rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge.gold { background: var(--sticker); color: var(--sticker-ink); }
.badge.silver { background: #e4e8ee; color: #2a1208; }
.badge.bronze { background: #f0c7a4; color: #2a1208; }
.badge.none { background: var(--chip); color: var(--muted); }
.badge.title { background: var(--score-bg); color: var(--score-ink); }

.relief {
  text-align: center;
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: -0.04em;
  margin: 6px 0 4px;
}
.toast {
  text-align: center;
  min-height: 1.4em;
  margin: 8px 0 0;
  color: var(--ok);
  font-weight: 700;
  font-size: .9rem;
}

.back-calc {
  margin: 22px 0 0;
  padding: 16px;
  border-radius: 24px;
  background: color-mix(in srgb, var(--chip) 70%, var(--paper));
  border: 1px solid var(--line);
}
.back-calc p { margin: 0 0 10px; font-weight: 800; letter-spacing: -0.03em; }
.back-calc .calc-links { display: flex; flex-wrap: wrap; gap: 8px; }
.back-calc .calc-links a {
  flex: 1 1 120px;
  text-align: center;
  text-decoration: none;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  border: 1.5px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ad-slot {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  margin: 18px 0 22px;
  font-size: .85rem;
}


#view-receipt { padding-top: 20px; }

.hidden { display: none !important; }

footer.site {
  border-top: 1px solid var(--line);
  padding: 28px 0 40px;
  color: var(--muted);
  font-size: .88rem;
  background: color-mix(in srgb, var(--paper) 80%, transparent);
}
footer.site nav { margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 8px; }

@media (min-width: 880px) {
  .how { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ----- 지도에서 장소 고르기 ----- */
#view-map { max-width: 520px; margin: 0 auto; padding-bottom: 8px; }
.map-card { padding: 16px 14px 16px; }
.map-title {
  margin: 0 0 8px;
  font-size: 1.2rem;
  letter-spacing: -0.04em;
  font-weight: 900;
  line-height: 1.3;
}
.map-card label {
  display: block;
  font-weight: 700;
  margin: 12px 0 6px;
  font-size: .92rem;
}
.search-row { display: flex; gap: 8px; align-items: stretch; }
.search-row input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
.search-row input:focus { outline: 3px solid var(--ring); outline-offset: 1px; border-color: var(--accent); }
.search-row #place-search-btn {
  flex: 0 0 auto;
  width: auto;
  min-width: 72px;
  min-height: 44px;
  margin: 0;
  font-size: 1rem;
}
.place-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 168px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.place-results li { margin: 0 0 6px; }
.place-results button {
  width: 100%;
  text-align: left;
  border-radius: 16px;
  border: 1.5px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  font-weight: 700;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  white-space: normal;
}
.place-results button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--chip);
}
.place-results .sub {
  font-weight: 650;
  font-size: .82rem;
  color: var(--muted);
}
.place-map-wrap {
  position: relative;
  margin: 10px 0 12px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  isolation: isolate;
  z-index: 1;
  background: #f4e6d6;
}
#place-map {
  width: 100%;
  height: min(42dvh, 300px);
  min-height: 220px;
  background: #f4e6d6;
}
.place-map-wrap.is-empty #place-map { visibility: hidden; height: 0; min-height: 0; }
.map-placeholder {
  margin: 0;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}
.place-map-wrap:not(.is-empty) .map-placeholder { display: none; }
#place-map .leaflet-container { font: inherit; background: #f4e6d6; }
#place-map .leaflet-control-attribution {
  font-size: 10px;
  line-height: 1.3;
  background: rgba(255, 250, 244, .92);
  color: var(--muted);
  max-width: 100%;
  white-space: normal;
  word-break: keep-all;
}
#place-confirm-btn, #place-skip-btn, #place-back-btn {
  width: 100%;
  margin-top: 8px;
}
#place-confirm-btn { margin-top: 0; }
#place-back-btn { margin-top: 8px; }

/* ---------- v2 ---------- */
.view { padding-bottom: 8px; }
#view-start { max-width: 620px; margin: 0 auto; }
#view-receipt { max-width: 520px; margin: 0 auto; padding-top: 16px; }
.hero { padding: 22px 0 6px; }

.search-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin: 10px 0 12px;
}
.search-label { display: block; font-weight: 900; letter-spacing: -0.04em; margin: 0 0 8px; font-size: 1.02rem; }
.search-row { display: flex; gap: 8px; }
.search-row input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 52px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  padding: 0 18px;
  font: inherit;
  font-size: 1.02rem;
  color: var(--ink);
}
.search-row input:focus { outline: 3px solid var(--ring); outline-offset: 1px; border-color: transparent; }
.search-row button { min-height: 52px; padding: 0 20px; flex: 0 0 auto; }
.search-msg { margin: 8px 4px 0; min-height: 1.3em; font-size: .88rem; color: var(--muted); font-weight: 650; }
.search-msg.err { color: var(--warn); }
.results { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.results button {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 10px 14px;
  min-height: 56px;
}
.results button:hover, .results button:focus-visible { border-color: var(--accent); }
.results .r-name { font-weight: 850; letter-spacing: -0.03em; line-height: 1.35; }
.results .r-addr { font-weight: 550; font-size: .8rem; color: var(--muted); line-height: 1.4; }
.skip-btn { width: 100%; margin-top: 10px; font-size: .95rem; }
.fine { margin: 10px 4px 0; font-size: .78rem; color: var(--muted); }
.disclaimer {
  margin: 10px 0 14px;
  padding: 10px 14px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--sticker) 35%, var(--paper));
  color: var(--ink);
  font-size: .86rem;
  font-weight: 700;
  text-align: center;
}
.disclaimer.small { font-size: .8rem; padding: 8px 12px; margin: 10px 0 6px; }
.best p { margin: 0; font-weight: 700; color: var(--muted); }
.best strong { color: var(--accent); font-size: 1.1rem; font-variant-numeric: tabular-nums; }

/* 무대 (지도/3D) */
#view-game { max-width: 760px; margin: 0 auto; padding-top: 6px; }
.stage {
  position: relative;
  width: 100%;
  height: calc(100dvh - 150px);
  min-height: 460px;
  max-height: 820px;
  border-radius: 24px;
  overflow: hidden;
  background: #d9dde2;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  isolation: isolate;
}
@media (min-width: 721px) { .stage { height: calc(100dvh - 120px); } }
.stage .layer { position: absolute; inset: 0; }
#scene canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.slot-layer { pointer-events: none; z-index: 3; }
.slot-btn {
  position: absolute;
  left: 0; top: 0;
  width: 46px; height: 46px;
  min-width: 46px; min-height: 46px;
  margin: -23px 0 0 -23px;
  padding: 0;
  border-radius: 50%;
  pointer-events: auto;
  background: rgba(255, 211, 106, .9);
  border: 3px solid #fffaf4;
  box-shadow: 0 0 0 2px rgba(42,18,8,.55), 0 6px 14px rgba(0,0,0,.35);
  color: var(--ink);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  will-change: transform;
  animation: slotPulse 1.6s ease-in-out infinite;
}
.slot-btn::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); opacity: .75; }
.slot-btn[aria-pressed="true"] { background: var(--accent); color: #fff; animation: none; }
.slot-btn[aria-pressed="true"]::after { content: "TNT"; width: auto; height: auto; background: none; opacity: 1; }
.slot-btn.behind { opacity: .45; }
@keyframes slotPulse { 0%,100% { box-shadow: 0 0 0 2px rgba(42,18,8,.55), 0 0 0 0 rgba(255,211,106,.7); } 50% { box-shadow: 0 0 0 2px rgba(42,18,8,.55), 0 0 0 10px rgba(255,211,106,0); } }

.top-ui {
  position: absolute; z-index: 5;
  left: 10px; right: 10px; top: 10px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  pointer-events: none;
}
.top-ui > * { pointer-events: auto; }
.chip, .chip-btn {
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 44px;
  display: inline-flex; align-items: center;
  font-weight: 850; font-size: .88rem; letter-spacing: -0.03em;
  box-shadow: 0 4px 14px rgba(42,18,8,.18);
  max-width: 62%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip-btn { border: 0; cursor: pointer; font-size: .84rem; max-width: none; }
.sheet {
  position: absolute; z-index: 5;
  left: 10px; right: 10px; bottom: 34px;
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  backdrop-filter: blur(10px);
  border-radius: 22px;
  padding: 12px 14px 14px;
  box-shadow: 0 10px 30px rgba(42,18,8,.25);
}
.sheet-title { margin: 0; font-weight: 900; letter-spacing: -0.04em; font-size: 1.02rem; line-height: 1.35; }
.sheet-sub { margin: 2px 0 0; color: var(--muted); font-size: .84rem; font-weight: 650; line-height: 1.45; }
.sheet .wide { width: 100%; margin-top: 10px; min-height: 52px; font-size: 1.05rem; }
.sheet-row { display: flex; gap: 8px; margin-top: 10px; }
.sheet-row .small { flex: 0 0 auto; padding: 0 16px; min-height: 52px; background: var(--paper); }
.sheet-row .boom { flex: 1 1 auto; min-height: 56px; font-size: 1.2rem; letter-spacing: -0.03em; }
.loading {
  position: absolute; inset: 0; z-index: 8;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(255, 240, 228, .72);
  backdrop-filter: blur(4px);
  font-weight: 850; color: var(--ink);
}
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.credit { margin: 0 0 4px; font-size: .72rem; color: var(--muted); text-align: center; }
.credit a { color: var(--muted); }

/* MapLibre 출처 표기: 작게, 그러나 항상 보이게 */
.maplibregl-ctrl-attrib { font-size: 10px !important; background: rgba(255,250,244,.82) !important; }
.maplibregl-ctrl-bottom-right { z-index: 6; }
.pick-marker {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(192,57,18,.25), 0 4px 10px rgba(0,0,0,.3);
}

.receipt-shot {
  display: block; width: calc(100% + 40px); max-width: none; height: auto;
  aspect-ratio: 16 / 9; object-fit: cover;
  margin: -22px -20px 14px; border-radius: 28px 28px 0 0;
  background: #cfd3d8;
}
.receipt-table th { color: var(--muted); }
.receipt { overflow: hidden; }
