:root {
  --ink: #261c31;
  --muted: #6f6677;
  --paper: #fffdf8;
  --paper-deep: #f6f1e7;
  --line: #e9e0d2;
  --purple: #4f2d7f;
  --purple-dark: #38205b;
  --purple-soft: #eee7f7;
  --gold: #f1bd52;
  --gold-soft: #fff1c8;
  --terracotta: #b9584f;
  --teal: #279197;
  --teal-soft: #e0f4f1;
  --green: #377d5c;
  --red: #b3403a;
  --shadow-sm: 0 10px 28px rgba(53, 38, 66, .08);
  --shadow-md: 0 18px 48px rgba(53, 38, 66, .14);
  --shadow-lg: 0 28px 80px rgba(30, 20, 43, .24);
  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 30px;
  --header-height: 76px;
  font-family: "Noto Sans Thai", "Leelawadee UI", Tahoma, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); color: var(--ink); }
body.dialog-open { overflow: hidden; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }
svg { display: block; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 9999;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  padding: 10px 16px;
  border-radius: 10px;
  background: white;
  box-shadow: var(--shadow-md);
  font-weight: 700;
  text-decoration: none;
  transition: transform .2s ease;
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  height: var(--header-height);
  border-bottom: 1px solid rgba(89, 62, 113, .09);
  background: rgba(255, 253, 248, .92);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.header-inner {
  width: min(1180px, calc(100% - 40px));
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 28px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: max-content;
  color: var(--purple);
  text-decoration: none;
}
.brand-mark { width: 42px; height: 42px; flex: 0 0 42px; }
.brand-mark svg { width: 100%; height: 100%; }
.brand-copy { display: grid; line-height: 1.05; gap: 4px; }
.brand-copy strong { font-size: 17px; letter-spacing: -.02em; }
.brand-copy small { font-size: 9px; font-weight: 800; letter-spacing: .18em; color: var(--terracotta); }
.desktop-nav { display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 999px; background: #f7f2e9; }
.nav-link {
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 9px 18px;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}
.nav-link:hover { color: var(--purple); }
.nav-link.active { color: var(--purple); background: white; box-shadow: 0 4px 14px rgba(53, 38, 66, .08); }
.header-actions { justify-self: end; display: flex; align-items: center; gap: 8px; }
.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.icon-button:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.profile-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 999px;
  padding: 5px 13px 5px 5px;
  background: var(--purple-soft);
  color: var(--purple);
  font-weight: 800;
  cursor: pointer;
}
.profile-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--purple);
  color: white;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.35);
}
.profile-name { max-width: 130px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.hero-section {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 30%, rgba(241, 189, 82, .18), transparent 28%),
    radial-gradient(circle at 83% 5%, rgba(102, 190, 188, .16), transparent 25%),
    linear-gradient(135deg, #3f2369 0%, #4f2d7f 45%, #66368e 100%);
  color: white;
}
.hero-section::after {
  content: "";
  position: absolute;
  right: -150px;
  bottom: -230px;
  width: 560px;
  height: 560px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 50%;
  box-shadow: 0 0 0 44px rgba(255,255,255,.025), 0 0 0 90px rgba(255,255,255,.018);
}
.hero-pattern {
  position: absolute;
  inset: 0;
  opacity: .09;
  background-image:
    linear-gradient(45deg, transparent 44%, white 45%, white 46%, transparent 47%),
    linear-gradient(-45deg, transparent 44%, white 45%, white 46%, transparent 47%);
  background-size: 64px 64px;
  mask-image: linear-gradient(90deg, transparent, black 20%, black 80%, transparent);
}
.hero-inner {
  position: relative;
  z-index: 2;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 74px 0 68px;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(340px, .82fr);
  align-items: center;
  gap: 76px;
}
.eyebrow { display: inline-flex; align-items: center; gap: 9px; color: #ffe5a1; font-size: 13px; font-weight: 800; letter-spacing: .08em; }
.eyebrow > span { width: 28px; height: 2px; background: currentColor; border-radius: 99px; }
.eyebrow.dark { color: var(--terracotta); }
.hero-copy h1 { margin: 18px 0 18px; max-width: 680px; font-size: clamp(44px, 5.8vw, 76px); line-height: 1.04; letter-spacing: -.045em; }
.hero-copy h1 em { color: var(--gold); font-style: normal; }
.hero-copy > p { max-width: 610px; margin: 0; color: rgba(255,255,255,.78); font-size: 18px; line-height: 1.75; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 30px; }
.primary-button, .secondary-button, .danger-button, .small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  border-radius: 13px;
  padding: 11px 18px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, opacity .18s ease;
}
.primary-button { border: 0; background: var(--gold); color: #342009; box-shadow: 0 10px 25px rgba(32, 20, 5, .18); }
.primary-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(32,20,5,.24); }
.primary-button:active:not(:disabled) { transform: translateY(0); }
.primary-button:disabled { cursor: not-allowed; opacity: .48; box-shadow: none; }
.primary-button svg, .secondary-button svg, .small-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.secondary-button { border: 1px solid rgba(255,255,255,.28); background: rgba(255,255,255,.08); color: white; }
.secondary-button:hover { transform: translateY(-1px); background: rgba(255,255,255,.14); }
.primary-button.full, .secondary-button.full { width: 100%; }
.privacy-note { display: flex; align-items: center; gap: 7px; margin-top: 18px !important; font-size: 12px !important; color: rgba(255,255,255,.60) !important; }
.privacy-note svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 26px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 28px;
  background: rgba(255,255,255,.11);
  -webkit-backdrop-filter: blur(15px);
  backdrop-filter: blur(15px);
  box-shadow: 0 30px 70px rgba(20, 8, 36, .24);
}
.hero-card::before { content: ""; position: absolute; inset: -120px auto auto -90px; width: 240px; height: 240px; border-radius: 50%; background: rgba(241,189,82,.13); }
.hero-card-top { position: relative; display: flex; justify-content: space-between; align-items: flex-start; }
.hero-card-top small { display: block; margin-bottom: 3px; color: rgba(255,255,255,.62); }
.hero-card-top strong { font-size: 25px; }
.level-emblem { width: 54px; height: 54px; }
.level-emblem svg { width: 100%; height: 100%; }
.level-emblem path:first-child { fill: var(--gold); }
.level-emblem circle { fill: var(--purple); }
.level-emblem path:last-child { fill: none; stroke: white; stroke-width: 2.5; stroke-linecap: round; }
.progress-ring-wrap { display: grid; place-items: center; padding: 18px 0 16px; }
.progress-ring {
  --angle: calc(var(--progress) * 3.6deg);
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: conic-gradient(var(--gold) var(--angle), rgba(255,255,255,.14) 0);
  box-shadow: 0 0 0 7px rgba(255,255,255,.035);
  transition: background .5s ease;
}
.progress-ring::before { content: ""; position: absolute; width: 126px; height: 126px; border-radius: 50%; background: #523078; box-shadow: inset 0 0 25px rgba(255,255,255,.05); }
.progress-ring-inner { position: relative; z-index: 1; display: grid; justify-items: center; }
.progress-ring-inner strong { font-size: 42px; line-height: 1; }
.progress-ring-inner span { margin-top: 5px; color: rgba(255,255,255,.64); font-size: 13px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid rgba(255,255,255,.13); border-bottom: 1px solid rgba(255,255,255,.13); }
.hero-stats > div { padding: 15px 8px; text-align: center; }
.hero-stats > div + div { border-left: 1px solid rgba(255,255,255,.13); }
.hero-stats span { display: block; font-size: 20px; font-weight: 900; }
.hero-stats small { display: block; margin-top: 2px; color: rgba(255,255,255,.57); font-size: 11px; }
.level-progress { padding-top: 18px; }
.level-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 11px; color: rgba(255,255,255,.65); }
.level-progress-head strong { color: white; }
.progress-track { overflow: hidden; height: 7px; border-radius: 99px; background: rgba(255,255,255,.14); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f1bd52, #ffe5a1); transition: width .5s ease; }

.content-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 58px 0 100px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 30px; margin-bottom: 26px; }
.section-heading h2 { margin: 8px 0 4px; font-size: clamp(28px, 3.2vw, 42px); line-height: 1.2; letter-spacing: -.035em; }
.section-heading p { margin: 0; color: var(--muted); line-height: 1.65; }
.view-toggle { display: flex; gap: 4px; padding: 4px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 13px; background: white; }
.view-toggle button { display: flex; align-items: center; gap: 6px; border: 0; border-radius: 9px; padding: 8px 13px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.view-toggle button.active { background: var(--purple); color: white; }
.view-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.app-view { display: none; animation: fadeIn .26s ease; }
.app-view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.map-layout { display: grid; grid-template-columns: minmax(0, 1.58fr) minmax(310px, .72fr); gap: 20px; align-items: stretch; }
.quest-map-card, .map-side-panel { border: 1px solid var(--line); border-radius: var(--radius-lg); background: white; box-shadow: var(--shadow-sm); }
.quest-map-card { overflow: hidden; }
.map-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.map-legend { display: flex; flex-wrap: wrap; gap: 15px; color: var(--muted); font-size: 11px; font-weight: 700; }
.map-legend span { display: flex; align-items: center; gap: 6px; }
.legend-pin { width: 11px; height: 11px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--purple); }
.legend-pin.completed { background: var(--green); }
.legend-dot.user { width: 10px; height: 10px; border: 2px solid white; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 2px rgba(39,145,151,.26); }
.small-button { min-height: 36px; padding: 7px 11px; border: 1px solid var(--line); background: white; color: var(--purple); font-size: 11px; }
.small-button:hover { background: var(--purple-soft); }
.small-button svg { width: 15px; height: 15px; }
.schematic-map { position: relative; overflow: hidden; aspect-ratio: 1000 / 650; min-height: 430px; background: var(--paper-deep); }
.map-art { width: 100%; height: 100%; }
.map-label { position: absolute; padding: 4px 9px; border: 1px solid rgba(89,74,101,.12); border-radius: 999px; background: rgba(255,255,255,.82); box-shadow: 0 3px 10px rgba(53,38,66,.06); color: #766d75; font-size: 10px; font-weight: 800; pointer-events: none; }
.map-label.kku { left: 12%; top: 18%; }
.map-label.center { left: 42%; top: 55%; }
.map-label.east { right: 7%; top: 31%; }
.map-pin { cursor: pointer; outline: none; }
.map-pin .pin-body { fill: var(--purple); stroke: white; stroke-width: 3; filter: url(#pinShadow); transition: transform .18s ease, fill .18s ease; transform-origin: center bottom; }
.map-pin .pin-icon { fill: none; stroke: white; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.map-pin .pin-number { fill: white; font-size: 12px; font-weight: 900; pointer-events: none; }
.map-pin:hover .pin-body, .map-pin:focus .pin-body, .map-pin.selected .pin-body { transform: scale(1.12) translateY(-2px); fill: var(--terracotta); }
.map-pin.completed .pin-body { fill: var(--green); }
.map-pin.completed:hover .pin-body, .map-pin.completed.selected .pin-body { fill: #286447; }
.map-pin .pin-halo { fill: rgba(79,45,127,.10); opacity: 0; transition: opacity .2s ease; }
.map-pin.selected .pin-halo { opacity: 1; }
.user-pulse { animation: pulseMarker 1.8s ease-out infinite; }
@keyframes pulseMarker { 0% { r: 10; opacity: .8; } 100% { r: 27; opacity: 0; } }
.map-caption { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-top: 1px solid var(--line); color: var(--muted); background: #fffdf9; font-size: 10px; }
.map-caption svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.map-side-panel { overflow: hidden; display: flex; flex-direction: column; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 21px 21px 16px; }
.panel-kicker { display: block; color: var(--terracotta); font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.panel-head h3, .subsection-heading h3 { margin: 4px 0 0; font-size: 23px; line-height: 1.25; letter-spacing: -.025em; }
.category-pill { display: inline-flex; align-items: center; width: max-content; min-height: 25px; padding: 4px 9px; border-radius: 999px; background: var(--purple-soft); color: var(--purple); font-size: 10px; font-weight: 900; white-space: nowrap; }
.category-pill[data-category="ธรรมชาติ"] { background: var(--teal-soft); color: #1d777b; }
.category-pill[data-category="ศรัทธา"] { background: var(--gold-soft); color: #8a5900; }
.category-pill[data-category="ประวัติศาสตร์"] { background: #f4e8dc; color: #8d4c2c; }
.category-pill[data-category="ไลฟ์สไตล์"] { background: #fde8e5; color: #a5433c; }
.featured-image { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--paper-deep); }
.featured-body { flex: 1; display: flex; flex-direction: column; padding: 19px 21px 21px; }
.featured-body > p { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.featured-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.featured-meta span { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 9px 10px; border-radius: 11px; background: var(--paper-deep); color: var(--muted); font-size: 10px; }
.featured-meta svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: var(--purple); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.featured-meta b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.reward-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 15px 0; overflow: hidden; border-radius: 12px; background: var(--line); }
.reward-row > div { padding: 10px 12px; background: #fffdf9; }
.reward-row small { display: block; color: var(--muted); font-size: 9px; }
.reward-row strong { color: var(--purple); font-size: 15px; }
.map-side-panel .primary-button { margin-top: auto; }
.map-side-panel .primary-button, .dialog-content .primary-button, .quiz-content .primary-button, .result-content .primary-button, .profile-dialog-content .primary-button { background: var(--purple); color: white; box-shadow: 0 10px 22px rgba(79,45,127,.18); }
.map-side-panel .primary-button:hover, .dialog-content .primary-button:hover, .quiz-content .primary-button:hover, .result-content .primary-button:hover, .profile-dialog-content .primary-button:hover { box-shadow: 0 14px 30px rgba(79,45,127,.25); }

.route-section { margin-top: 42px; }
.subsection-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin-bottom: 17px; }
.route-note { color: var(--muted); font-size: 11px; }
.route-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.route-card { position: relative; overflow: hidden; min-height: 175px; padding: 18px; border: 1px solid var(--line); border-radius: 19px; background: white; box-shadow: 0 6px 18px rgba(53,38,66,.05); cursor: pointer; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.route-card:hover { transform: translateY(-4px); border-color: #d7c8e6; box-shadow: var(--shadow-sm); }
.route-card::after { content: ""; position: absolute; right: -35px; bottom: -55px; width: 130px; height: 130px; border-radius: 50%; background: var(--purple-soft); }
.route-card:nth-child(2)::after { background: var(--teal-soft); }
.route-card:nth-child(3)::after { background: var(--gold-soft); }
.route-card:nth-child(4)::after { background: #f7e6df; }
.route-icon { position: relative; z-index: 1; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--purple-soft); color: var(--purple); }
.route-card:nth-child(2) .route-icon { color: var(--teal); background: var(--teal-soft); }
.route-card:nth-child(3) .route-icon { color: #9a6500; background: var(--gold-soft); }
.route-card:nth-child(4) .route-icon { color: var(--terracotta); background: #f7e6df; }
.route-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.route-card h4 { position: relative; z-index: 1; margin: 13px 0 5px; font-size: 15px; }
.route-card p { position: relative; z-index: 1; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.route-meta { position: relative; z-index: 1; display: flex; gap: 12px; margin-top: 13px; color: var(--purple); font-size: 10px; font-weight: 800; }

.filter-bar { display: grid; grid-template-columns: minmax(230px, 1fr) auto auto; gap: 13px; align-items: center; margin-bottom: 16px; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 15px; top: 50%; width: 19px; height: 19px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.search-box input, .filter-bar select, .profile-dialog-content input { width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 13px; outline: none; background: white; color: var(--ink); transition: border-color .2s ease, box-shadow .2s ease; }
.search-box input { padding: 0 15px 0 45px; }
.search-box input:focus, .filter-bar select:focus, .profile-dialog-content input:focus { border-color: #9272b3; box-shadow: 0 0 0 4px rgba(79,45,127,.10); }
.filter-chips { display: flex; gap: 6px; }
.filter-chips button { border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: white; color: var(--muted); font-size: 11px; font-weight: 800; cursor: pointer; }
.filter-chips button.active { border-color: var(--purple); background: var(--purple); color: white; }
.filter-bar select { width: auto; min-width: 138px; padding: 0 36px 0 13px; cursor: pointer; }
.places-summary { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 15px; color: var(--muted); font-size: 11px; }
.places-summary strong { color: var(--ink); font-size: 13px; }
.places-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 17px; }
.place-card { overflow: hidden; border: 1px solid var(--line); border-radius: 21px; background: white; box-shadow: 0 8px 24px rgba(53,38,66,.055); transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease; }
.place-card:hover { transform: translateY(-5px); border-color: #d7c8e6; box-shadow: var(--shadow-md); }
.place-card.completed { border-color: rgba(55,125,92,.3); }
.place-card-main { width: 100%; height: 100%; border: 0; padding: 0; background: transparent; text-align: left; cursor: pointer; }
.place-image-wrap { position: relative; overflow: hidden; aspect-ratio: 16/10; background: var(--paper-deep); }
.place-image { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.place-card:hover .place-image { transform: scale(1.035); }
.place-status { position: absolute; right: 12px; top: 12px; display: none; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 999px; background: rgba(55,125,92,.94); color: white; font-size: 9px; font-weight: 900; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.place-card.completed .place-status { display: inline-flex; }
.place-status::before { content: "✓"; }
.place-number { position: absolute; left: 12px; top: 12px; display: grid; place-items: center; width: 29px; height: 29px; border-radius: 10px; background: rgba(38,28,49,.82); color: white; font-size: 10px; font-weight: 900; }
.place-card-body { padding: 15px 16px 16px; }
.place-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.place-distance { color: var(--muted); font-size: 9px; font-weight: 700; }
.place-card h3 { margin: 10px 0 5px; font-size: 17px; line-height: 1.3; letter-spacing: -.02em; }
.place-summary { display: -webkit-box; overflow: hidden; min-height: 41px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.65; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.place-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 13px; padding-top: 12px; border-top: 1px solid #f0e9df; }
.place-reward { color: var(--terracotta); font-size: 10px; font-weight: 800; }
.place-reward b { font-size: 15px; }
.place-cta { display: inline-flex; align-items: center; gap: 3px; color: var(--purple); font-size: 10px; font-weight: 900; }
.place-cta svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }
.empty-state svg { width: 68px; height: 68px; margin: 0 auto 17px; fill: none; stroke: #b9a9c6; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.empty-state h3 { margin: 0 0 5px; color: var(--ink); }
.empty-state p { margin: 0; }

.badge-dashboard { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; margin-bottom: 20px; }
.badge-intro, .badge-spotlight { position: relative; overflow: hidden; min-height: 260px; border-radius: 25px; }
.badge-intro { padding: 31px; background: var(--purple); color: white; }
.badge-intro::after { content: ""; position: absolute; right: -70px; top: -90px; width: 230px; height: 230px; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; box-shadow: 0 0 0 34px rgba(255,255,255,.03), 0 0 0 72px rgba(255,255,255,.025); }
.badge-intro h3 { position: relative; z-index: 1; max-width: 470px; margin: 8px 0 9px; font-size: clamp(28px, 4vw, 43px); line-height: 1.2; letter-spacing: -.035em; }
.badge-intro > p { position: relative; z-index: 1; max-width: 560px; margin: 0; color: rgba(255,255,255,.7); line-height: 1.7; }
.badge-total { position: absolute; left: 31px; bottom: 28px; display: flex; align-items: baseline; gap: 7px; }
.badge-total strong { color: var(--gold); font-size: 45px; line-height: 1; }
.badge-total span { color: rgba(255,255,255,.66); font-size: 12px; }
.badge-spotlight { display: flex; align-items: center; gap: 23px; padding: 30px; border: 1px solid var(--line); background: linear-gradient(145deg, #fffaf0, #f5ecdc); }
.spotlight-glow { position: absolute; left: 4%; top: 50%; width: 190px; height: 190px; transform: translateY(-50%); border-radius: 50%; background: radial-gradient(circle, rgba(241,189,82,.28), transparent 69%); }
.large-badge { position: relative; z-index: 1; flex: 0 0 125px; width: 125px; height: 125px; }
.large-badge.locked { filter: grayscale(1); opacity: .38; }
.badge-spotlight > div:last-child { position: relative; z-index: 1; }
.badge-spotlight small { color: var(--terracotta); font-weight: 900; }
.badge-spotlight h4 { margin: 6px 0 5px; font-size: 21px; }
.badge-spotlight p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.badges-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 13px; }
.badge-card { padding: 19px 13px 16px; border: 1px solid var(--line); border-radius: 19px; background: white; text-align: center; box-shadow: 0 5px 16px rgba(53,38,66,.04); }
.badge-card.locked { background: #faf8f4; }
.badge-emblem { width: 88px; height: 88px; margin: 0 auto 12px; }
.badge-card.locked .badge-emblem { filter: grayscale(1); opacity: .34; }
.badge-card h4 { margin: 0 0 4px; font-size: 13px; }
.badge-card p { min-height: 35px; margin: 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.badge-state { display: inline-flex; align-items: center; justify-content: center; min-height: 23px; margin-top: 10px; padding: 3px 8px; border-radius: 999px; background: var(--teal-soft); color: #247477; font-size: 8px; font-weight: 900; }
.badge-card.locked .badge-state { background: #eeeae4; color: #8e8680; }
.activity-panel { margin-top: 40px; }
.text-button { border: 0; background: transparent; font-size: 11px; font-weight: 800; cursor: pointer; }
.text-button.danger { color: var(--red); }
.timeline { overflow: hidden; border: 1px solid var(--line); border-radius: 19px; background: white; }
.timeline-item { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; padding: 14px 17px; }
.timeline-item + .timeline-item { border-top: 1px solid var(--line); }
.timeline-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--teal-soft); color: var(--teal); }
.timeline-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.timeline-copy strong { display: block; font-size: 12px; }
.timeline-copy small { color: var(--muted); font-size: 9px; }
.timeline-points { color: var(--green); font-size: 11px; font-weight: 900; }
.timeline-empty { padding: 34px; text-align: center; color: var(--muted); font-size: 12px; }

.mobile-nav { display: none; }

.app-dialog {
  width: min(610px, calc(100% - 28px));
  max-height: min(880px, calc(100dvh - 28px));
  overflow: auto;
  border: 0;
  border-radius: 26px;
  padding: 0;
  background: white;
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.app-dialog::backdrop { background: rgba(25, 16, 37, .64); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.app-dialog[open] { animation: dialogIn .24s ease both; }
@keyframes dialogIn { from { opacity: 0; transform: translateY(14px) scale(.975); } to { opacity: 1; transform: none; } }
.dialog-close { position: absolute; z-index: 5; right: 14px; top: 14px; display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%; background: rgba(255,255,255,.92); color: var(--ink); box-shadow: 0 4px 16px rgba(0,0,0,.12); cursor: pointer; }
.dialog-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.place-dialog-hero { position: relative; overflow: hidden; aspect-ratio: 16/8.3; background: var(--paper-deep); }
.place-dialog-hero img { width: 100%; height: 100%; object-fit: cover; }
.dialog-image-overlay { position: absolute; inset: auto 18px 16px; display: flex; justify-content: space-between; align-items: center; }
.dialog-image-overlay .category-pill { box-shadow: 0 4px 15px rgba(0,0,0,.13); }
.completion-pill { display: inline-flex; align-items: center; gap: 5px; min-height: 25px; padding: 4px 9px; border-radius: 999px; background: var(--green); color: white; font-size: 9px; font-weight: 900; box-shadow: 0 4px 15px rgba(0,0,0,.13); }
.completion-pill svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.dialog-content { padding: 25px 27px 27px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.dialog-heading h2 { margin: 5px 0 0; font-size: 30px; line-height: 1.2; letter-spacing: -.03em; }
.dialog-score { flex: 0 0 auto; padding: 8px 11px; border-radius: 11px; background: var(--gold-soft); text-align: right; }
.dialog-score small { display: block; color: #8a6e32; font-size: 8px; }
.dialog-score strong { color: #78500a; font-size: 14px; }
.dialog-story { margin: 15px 0; color: var(--muted); line-height: 1.75; }
.fact-box { display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px; border-radius: 14px; background: var(--purple-soft); }
.fact-box > svg { width: 22px; height: 22px; flex: 0 0 auto; fill: none; stroke: var(--purple); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fact-box small { display: block; color: var(--purple); font-size: 9px; font-weight: 900; }
.fact-box p { margin: 2px 0 0; color: #4b3a5a; font-size: 11px; line-height: 1.55; }
.clue-box { margin-top: 11px; padding: 11px 14px; border-left: 3px solid var(--terracotta); border-radius: 0 10px 10px 0; background: #fff7f4; }
.clue-box span { color: var(--terracotta); font-size: 9px; font-weight: 900; }
.clue-box p { margin: 2px 0 0; color: #6d514f; font-size: 11px; }
.dialog-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 17px 0; }
.dialog-info-grid > div { display: flex; align-items: center; gap: 9px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 12px; }
.dialog-info-grid svg { width: 19px; height: 19px; flex: 0 0 auto; fill: none; stroke: var(--purple); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dialog-info-grid span { color: var(--muted); font-size: 8px; }
.dialog-info-grid small { display: block; margin-top: 1px; color: var(--ink); font-size: 10px; font-weight: 800; }
.dialog-actions { display: grid; gap: 8px; }
.dialog-actions .primary-button svg { width: 19px; height: 19px; }
.secondary-action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dialog-content .secondary-button { border-color: var(--line); background: white; color: var(--purple); box-shadow: none; }
.dialog-content .secondary-button:hover { background: var(--purple-soft); }
.demo-disclaimer { margin: 9px 0 0; color: var(--muted); font-size: 8px; text-align: center; }

.quiz-dialog { width: min(510px, calc(100% - 28px)); }
.quiz-content { padding: 42px 34px 30px; text-align: center; }
.quiz-icon { width: 68px; height: 68px; margin: 0 auto 14px; }
.quiz-icon svg { width: 100%; height: 100%; }
.quiz-icon path:first-child { fill: var(--purple-soft); stroke: var(--purple); stroke-width: 2; }
.quiz-icon path:last-child { fill: none; stroke: var(--purple); stroke-width: 3; stroke-linecap: round; }
.quiz-content h2 { margin: 4px 0 12px; font-size: 27px; }
.quiz-prompt { margin: 0 auto 18px; max-width: 390px; color: var(--ink); font-size: 16px; font-weight: 800; line-height: 1.55; }
.quiz-options { display: grid; gap: 8px; margin-bottom: 15px; text-align: left; }
.quiz-option { display: grid; grid-template-columns: 31px 1fr; align-items: center; gap: 10px; min-height: 53px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 13px; background: white; cursor: pointer; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.quiz-option:hover { border-color: #bfa8d5; transform: translateY(-1px); }
.quiz-option.selected { border-color: var(--purple); background: var(--purple-soft); }
.quiz-option input { position: absolute; opacity: 0; pointer-events: none; }
.option-letter { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 10px; background: #f4f0ea; color: var(--muted); font-size: 11px; font-weight: 900; }
.quiz-option.selected .option-letter { background: var(--purple); color: white; }
.option-text { font-size: 12px; font-weight: 700; }
.quiz-hint { margin: 9px 0 0; color: var(--muted); font-size: 9px; }

.result-dialog { width: min(450px, calc(100% - 28px)); overflow: hidden; }
.result-content { position: relative; z-index: 2; padding: 39px 35px 31px; text-align: center; }
.result-emblem { width: 92px; height: 92px; margin: 0 auto 15px; }
.result-emblem svg { width: 100%; height: 100%; filter: drop-shadow(0 10px 19px rgba(55,125,92,.22)); }
.result-emblem circle { fill: var(--teal-soft); stroke: var(--green); stroke-width: 2.5; }
.result-emblem path { fill: none; stroke: var(--green); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.result-dialog.is-error .result-emblem circle { fill: #fde8e5; stroke: var(--red); }
.result-dialog.is-error .result-emblem path { stroke: var(--red); }
.result-content h2 { margin: 5px 0 6px; font-size: 27px; line-height: 1.3; }
.result-content > p { margin: 0; color: var(--muted); line-height: 1.6; }
.result-score { display: grid; justify-items: center; margin: 18px 0; }
.result-score span { color: var(--terracotta); font-size: 20px; font-weight: 900; }
.result-score b { font-size: 45px; line-height: 1; }
.result-score small { color: var(--muted); font-size: 9px; }
.new-badges { margin: 0 0 16px; padding: 12px; border-radius: 14px; background: var(--gold-soft); color: #6d4b0f; font-size: 11px; font-weight: 800; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 17px; border-radius: 2px; background: var(--gold); animation: confettiFall 2.4s ease-in infinite; }
.confetti i:nth-child(1) { left: 8%; animation-delay: .1s; transform: rotate(17deg); }
.confetti i:nth-child(2) { left: 22%; animation-delay: .45s; background: var(--teal); }
.confetti i:nth-child(3) { left: 35%; animation-delay: .8s; background: var(--terracotta); }
.confetti i:nth-child(4) { left: 48%; animation-delay: .2s; }
.confetti i:nth-child(5) { left: 62%; animation-delay: .65s; background: var(--purple); }
.confetti i:nth-child(6) { left: 74%; animation-delay: 1s; background: var(--teal); }
.confetti i:nth-child(7) { left: 86%; animation-delay: .35s; background: var(--terracotta); }
.confetti i:nth-child(8) { left: 94%; animation-delay: .85s; }
@keyframes confettiFall { 0% { transform: translateY(-15px) rotate(0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translateY(520px) rotate(560deg); opacity: .1; } }

.profile-dialog { width: min(475px, calc(100% - 28px)); }
.profile-dialog-content { padding: 35px 35px 31px; }
.profile-art { width: 130px; height: 98px; margin: 0 auto 3px; }
.profile-art svg { width: 100%; height: 100%; }
.profile-art path:first-child { fill: var(--purple-soft); }
.profile-art path:nth-child(2), .profile-art circle { fill: none; stroke: var(--purple); stroke-width: 4; stroke-linecap: round; }
.profile-dialog-content > .panel-kicker { text-align: center; }
.profile-dialog-content h2 { margin: 5px 0 4px; text-align: center; font-size: 25px; }
.profile-dialog-content > p { margin: 0 0 20px; color: var(--muted); text-align: center; font-size: 11px; }
.profile-dialog-content > label:not(.toggle-row) { display: block; margin: 0 0 6px; font-size: 11px; font-weight: 900; }
.profile-dialog-content input { padding: 0 14px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin: 14px 0 19px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 13px; cursor: pointer; }
.toggle-row span { display: grid; }
.toggle-row strong { font-size: 11px; }
.toggle-row small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row i { position: relative; flex: 0 0 40px; width: 40px; height: 23px; border-radius: 99px; background: #d8d2ca; transition: background .2s ease; }
.toggle-row i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 17px; height: 17px; border-radius: 50%; background: white; box-shadow: 0 2px 6px rgba(0,0,0,.16); transition: transform .2s ease; }
.toggle-row input:checked + i { background: var(--purple); }
.toggle-row input:checked + i::after { transform: translateX(17px); }

.confirm-dialog { width: min(420px, calc(100% - 28px)); }
.confirm-content { padding: 31px; text-align: center; }
.warning-icon { display: grid; place-items: center; width: 57px; height: 57px; margin: 0 auto 14px; border-radius: 50%; background: #fde8e5; color: var(--red); }
.warning-icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.confirm-content h2 { margin: 0 0 7px; font-size: 22px; }
.confirm-content p { margin: 0 0 19px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.confirm-actions .secondary-button { border-color: var(--line); color: var(--ink); background: white; }
.danger-button { border: 0; background: var(--red); color: white; }

.toast-region { position: fixed; z-index: 300; right: 18px; bottom: 18px; display: grid; gap: 8px; width: min(360px, calc(100% - 36px)); pointer-events: none; }
.toast { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid rgba(255,255,255,.14); border-radius: 14px; background: rgba(38,28,49,.96); color: white; box-shadow: var(--shadow-md); animation: toastIn .25s ease both; pointer-events: auto; }
.toast.leaving { animation: toastOut .22s ease both; }
.toast-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.12); color: var(--gold); }
.toast-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast strong { display: block; font-size: 11px; }
.toast p { margin: 1px 0 0; color: rgba(255,255,255,.65); font-size: 9px; line-height: 1.45; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

:focus-visible { outline: 3px solid rgba(241,189,82,.8); outline-offset: 3px; }

@media (max-width: 1040px) {
  .hero-inner { gap: 38px; }
  .map-layout { grid-template-columns: 1fr; }
  .map-side-panel { display: grid; grid-template-columns: 270px 1fr; }
  .map-side-panel .panel-head { grid-column: 1 / -1; }
  .featured-image { height: 100%; aspect-ratio: auto; }
  .featured-body { min-width: 0; }
  .route-grid { grid-template-columns: repeat(2, 1fr); }
  .places-grid { grid-template-columns: repeat(2, 1fr); }
  .badges-grid { grid-template-columns: repeat(3, 1fr); }
  .filter-bar { grid-template-columns: 1fr auto; }
  .filter-chips { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; padding-bottom: 3px; }
}

@media (max-width: 820px) {
  :root { --header-height: 66px; }
  .header-inner { width: min(100% - 28px, 1180px); grid-template-columns: 1fr auto; }
  .desktop-nav { display: none; }
  .profile-name { display: none; }
  .profile-chip { padding-right: 5px; }
  .hero-inner { width: min(100% - 32px, 1180px); grid-template-columns: 1fr; padding: 50px 0 46px; }
  .hero-copy h1 { max-width: 620px; }
  .hero-card { max-width: 540px; }
  .content-shell { width: min(100% - 28px, 1180px); padding-bottom: 110px; }
  .section-heading { align-items: flex-start; }
  .section-heading p { max-width: 560px; }
  .view-toggle { display: none; }
  .badge-dashboard { grid-template-columns: 1fr; }
  .badge-intro, .badge-spotlight { min-height: 235px; }
  .mobile-nav {
    position: fixed;
    z-index: 60;
    left: 50%;
    bottom: max(12px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: min(420px, calc(100% - 24px));
    padding: 5px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 18px;
    background: rgba(38,28,49,.94);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 14px 38px rgba(23,14,32,.28);
  }
  .mobile-nav button { display: grid; justify-items: center; gap: 2px; border: 0; border-radius: 13px; padding: 7px; background: transparent; color: rgba(255,255,255,.58); font-size: 9px; font-weight: 800; cursor: pointer; }
  .mobile-nav button.active { background: rgba(255,255,255,.12); color: white; }
  .mobile-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .toast-region { bottom: 88px; }
}

@media (max-width: 620px) {
  .brand-copy strong { font-size: 15px; }
  .brand-copy small { font-size: 8px; }
  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; }
  .hero-inner { padding-top: 42px; gap: 31px; }
  .hero-copy h1 { margin-top: 14px; font-size: clamp(39px, 13vw, 58px); }
  .hero-copy > p { font-size: 15px; }
  .hero-actions { align-items: stretch; }
  .hero-actions .primary-button, .hero-actions .secondary-button { flex: 1 1 180px; }
  .privacy-note { align-items: flex-start; }
  .hero-card { padding: 21px; }
  .progress-ring { width: 134px; height: 134px; }
  .progress-ring::before { width: 112px; height: 112px; }
  .progress-ring-inner strong { font-size: 36px; }
  .content-shell { padding-top: 39px; }
  .section-heading { margin-bottom: 19px; }
  .section-heading h2 { font-size: 30px; }
  .section-heading p { font-size: 13px; }
  .map-toolbar { align-items: flex-start; }
  .map-legend { gap: 8px; }
  .map-toolbar .small-button { font-size: 0; width: 36px; padding: 0; }
  .map-toolbar .small-button svg { width: 17px; height: 17px; }
  .schematic-map { min-height: 300px; aspect-ratio: 1.18 / 1; }
  .map-art { width: auto; min-width: 100%; height: 100%; transform: translateX(-11%); }
  .map-label.center { left: 34%; }
  .map-label.east { right: 2%; }
  .map-side-panel { display: flex; }
  .featured-image { height: auto; aspect-ratio: 16/9; }
  .route-grid { grid-template-columns: 1fr; }
  .route-card { min-height: 150px; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-bar select { width: 100%; }
  .filter-chips { grid-column: 1; grid-row: auto; }
  .places-grid { grid-template-columns: 1fr; }
  .places-summary { align-items: flex-start; }
  .badges-grid { grid-template-columns: repeat(2, 1fr); }
  .badge-spotlight { align-items: flex-start; }
  .large-badge { flex-basis: 93px; width: 93px; height: 93px; }
  .timeline-item { grid-template-columns: 34px 1fr auto; padding: 12px; }
  .dialog-content { padding: 21px 19px 23px; }
  .dialog-heading h2 { font-size: 25px; }
  .dialog-score { padding: 7px 9px; }
  .dialog-info-grid { grid-template-columns: 1fr; }
  .quiz-content { padding: 37px 19px 24px; }
  .profile-dialog-content { padding: 30px 21px 24px; }
  .result-content { padding: 34px 23px 25px; }
}

@media (max-width: 400px) {
  .header-inner { width: calc(100% - 20px); }
  .brand-copy small { letter-spacing: .11em; }
  .hero-inner { width: calc(100% - 24px); }
  .content-shell { width: calc(100% - 20px); }
  .hero-card { border-radius: 23px; }
  .hero-stats span { font-size: 17px; }
  .featured-meta { grid-template-columns: 1fr; }
  .badges-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .badge-card { padding-inline: 8px; }
  .badge-emblem { width: 74px; height: 74px; }
  .badge-spotlight { gap: 14px; padding: 22px; }
  .large-badge { flex-basis: 77px; width: 77px; height: 77px; }
  .secondary-action-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Enhancements for Khon Kaen Link production release */
.desktop-nav .nav-link { display: inline-flex; align-items: center; text-decoration: none; }
.home-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--purple);
  font-size: 10px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.home-link:hover { transform: translateY(-1px); background: var(--purple-soft); box-shadow: var(--shadow-sm); }
.home-link svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sound-toggle .sound-off-icon { display: none; }
.sound-toggle.is-muted .sound-on-icon { display: none; }
.sound-toggle.is-muted .sound-off-icon { display: block; }
.sound-toggle.is-muted { color: var(--muted); background: #f4f1ec; }

.how-to-section {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 8% 12%, rgba(241,189,82,.18), transparent 24%),
    radial-gradient(circle at 92% 84%, rgba(39,145,151,.13), transparent 26%),
    #fbf8f1;
}
.how-to-inner { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 58px 0 62px; }
.how-to-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; margin-bottom: 25px; }
.how-to-heading h2 { margin: 8px 0 5px; font-size: clamp(29px, 3.3vw, 43px); line-height: 1.18; letter-spacing: -.035em; }
.how-to-heading p { max-width: 700px; margin: 0; color: var(--muted); line-height: 1.75; }
.how-to-home-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 10px 15px;
  border: 1px solid #d9cfe4;
  border-radius: 13px;
  background: white;
  color: var(--purple);
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.how-to-home-link:hover { background: var(--purple-soft); }
.how-to-home-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.how-to-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.how-to-card {
  position: relative;
  min-height: 238px;
  padding: 22px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 10px 30px rgba(53,38,66,.055);
}
.how-to-number { position: absolute; right: 15px; top: 13px; color: rgba(79,45,127,.13); font-size: 31px; font-weight: 900; letter-spacing: -.05em; }
.how-to-icon { display: grid; place-items: center; width: 49px; height: 49px; margin-bottom: 17px; border-radius: 15px; background: var(--purple-soft); color: var(--purple); }
.how-to-card:nth-child(2) .how-to-icon { background: var(--teal-soft); color: var(--teal); }
.how-to-card:nth-child(3) .how-to-icon { background: var(--gold-soft); color: #8a5900; }
.how-to-card:nth-child(4) .how-to-icon { background: #fbe8e3; color: var(--terracotta); }
.how-to-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.how-to-card h3 { margin: 0 0 7px; font-size: 17px; }
.how-to-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.72; }
.play-safety-note { display: grid; grid-template-columns: 45px 1fr; align-items: start; gap: 13px; margin-top: 15px; padding: 15px 17px; border: 1px solid #cfe4df; border-radius: 16px; background: rgba(234,248,244,.82); }
.play-safety-icon { display: grid; place-items: center; width: 45px; height: 45px; border-radius: 13px; background: white; color: var(--green); }
.play-safety-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.play-safety-note strong { display: block; color: #285d47; font-size: 12px; }
.play-safety-note p { margin: 3px 0 0; color: #527063; font-size: 10px; line-height: 1.65; }

/* Stable SVG pin hit area and radar effects. The coordinate group never moves. */
.map-pin { pointer-events: all; }
.map-pin .pin-hit-target { fill: transparent; pointer-events: all; }
.map-pin .pin-halo,
.map-pin .pin-pulse,
.map-pin .pin-visual { pointer-events: none; }
.map-pin .pin-visual {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform .18s ease;
}
.map-pin:hover .pin-visual,
.map-pin:focus .pin-visual,
.map-pin.selected .pin-visual { transform: scale(1.08); }
.map-pin .pin-body,
.map-pin:hover .pin-body,
.map-pin:focus .pin-body,
.map-pin.selected .pin-body { transform: none; }
.map-pin .pin-pulse {
  fill: none;
  stroke: rgba(79,45,127,.58);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  transform-box: fill-box;
  transform-origin: center;
  animation: pinRadar 2.35s ease-out infinite;
}
.map-pin .pin-pulse.pin-pulse-two { animation-delay: 1.16s; }
.map-pin.completed .pin-pulse { stroke: rgba(55,125,92,.62); }
.map-pin.selected .pin-pulse { stroke: rgba(185,88,79,.76); animation-duration: 1.75s; }
.map-pin .pin-halo { fill: rgba(79,45,127,.12); transition: opacity .2s ease; }
.map-pin.selected .pin-halo { opacity: 1; }
@keyframes pinRadar {
  0% { opacity: .58; transform: scale(.52); }
  72%, 100% { opacity: 0; transform: scale(1.48); }
}

.checkin-photo-card { display: grid; grid-template-columns: 108px 1fr; gap: 12px; align-items: center; margin-top: 12px; padding: 10px; border: 1px solid #d7e8e4; border-radius: 15px; background: #f4fbf9; }
.checkin-photo-card[hidden] { display: none !important; }
.checkin-photo-card img { width: 108px; height: 82px; border-radius: 11px; object-fit: cover; background: #dfe8e5; }
.checkin-photo-card small { display: block; color: var(--green); font-size: 9px; font-weight: 900; }
.checkin-photo-card strong { display: block; margin: 2px 0 4px; font-size: 11px; }
.checkin-photo-card .text-button { padding: 0; color: var(--purple); }

.photo-dialog { width: min(720px, calc(100% - 28px)); }
.photo-content { padding: 34px 34px 28px; }
.photo-content > .panel-kicker { padding-right: 45px; }
.photo-content h2 { margin: 4px 0 5px; padding-right: 45px; font-size: 28px; line-height: 1.25; }
.photo-instruction { margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.camera-stage { position: relative; overflow: hidden; display: grid; place-items: center; width: 100%; aspect-ratio: 4/3; max-height: 470px; border-radius: 19px; background: linear-gradient(145deg, #17111d, #31243a); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.camera-stage video,
.camera-stage > img { width: 100%; height: 100%; object-fit: cover; }
.camera-stage video.user-facing { transform: scaleX(-1); }
.camera-placeholder { display: grid; justify-items: center; gap: 7px; padding: 24px; color: rgba(255,255,255,.78); text-align: center; }
.camera-placeholder svg { width: 74px; height: 74px; margin-bottom: 4px; fill: none; stroke: rgba(255,255,255,.55); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.camera-placeholder strong { color: white; font-size: 15px; }
.camera-placeholder span { font-size: 10px; }
.camera-guide { position: absolute; inset: 14px; pointer-events: none; }
.camera-guide span { position: absolute; width: 32px; height: 32px; border-color: rgba(255,255,255,.76); border-style: solid; }
.camera-guide span:nth-child(1) { left: 0; top: 0; border-width: 3px 0 0 3px; border-radius: 8px 0 0 0; }
.camera-guide span:nth-child(2) { right: 0; top: 0; border-width: 3px 3px 0 0; border-radius: 0 8px 0 0; }
.camera-guide span:nth-child(3) { left: 0; bottom: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 8px; }
.camera-guide span:nth-child(4) { right: 0; bottom: 0; border-width: 0 3px 3px 0; border-radius: 0 0 8px 0; }
.camera-status { min-height: 18px; margin: 9px 0 7px; color: var(--muted); font-size: 10px; text-align: center; }
.camera-live-actions,
.camera-review-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.camera-review-actions { grid-template-columns: .8fr 1.2fr; }
.camera-light-button { border-color: var(--line); background: white; color: var(--purple); box-shadow: none; }
.camera-light-button:hover { background: var(--purple-soft); }
.file-capture-button { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; margin-top: 8px; padding: 10px 14px; border: 1px dashed #bca9d0; border-radius: 13px; background: #faf7fd; color: var(--purple); font-size: 11px; font-weight: 900; cursor: pointer; }
.file-capture-button:hover { background: var(--purple-soft); }
.file-capture-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.file-capture-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.demo-photo-skip { display: block; margin: 10px auto 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.photo-privacy { display: flex; align-items: flex-start; justify-content: center; gap: 6px; margin: 12px 0 0; color: var(--muted); font-size: 9px; line-height: 1.55; text-align: left; }
.photo-privacy svg { width: 15px; height: 15px; flex: 0 0 auto; fill: none; stroke: var(--green); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.photo-content [hidden] { display: none !important; }

.result-photo-preview { width: 100%; max-height: 220px; margin: 15px 0 0; border: 5px solid white; border-radius: 16px; object-fit: cover; box-shadow: var(--shadow-sm); }
.result-photo-preview[hidden] { display: none !important; }
.timeline-item.with-photo { grid-template-columns: 38px 54px 1fr auto; }
.timeline-photo { width: 54px; height: 43px; border-radius: 9px; object-fit: cover; background: #e5e0d9; }

.site-footer { border-top: 1px solid rgba(255,255,255,.08); background: #24182f; color: white; }
.footer-inner { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 34px; display: flex; justify-content: space-between; align-items: center; gap: 28px; }
.footer-brand { display: flex; align-items: center; gap: 12px; }
.footer-brand .brand-mark { color: #f1bd52; }
.footer-brand strong { display: block; font-size: 15px; }
.footer-brand p { margin: 2px 0 0; color: rgba(255,255,255,.58); font-size: 10px; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 17px; }
.footer-links a { color: rgba(255,255,255,.74); font-size: 10px; font-weight: 800; text-decoration: none; }
.footer-links a:hover { color: var(--gold); }

@media (max-width: 1120px) {
  .home-link span { display: none; }
  .home-link { width: 42px; padding: 0; justify-content: center; }
  .how-to-grid { grid-template-columns: repeat(2, 1fr); }
  .how-to-card { min-height: 205px; }
}

@media (max-width: 820px) {
  .how-to-inner { width: min(100% - 28px, 1180px); padding: 44px 0 48px; }
  .how-to-heading { align-items: flex-start; flex-direction: column; }
  .how-to-home-link { align-self: flex-start; }
  .footer-inner { width: min(100% - 28px, 1180px); padding-bottom: 108px; align-items: flex-start; flex-direction: column; }
  .footer-links { justify-content: flex-start; }
}

@media (max-width: 620px) {
  .home-link { display: none; }
  .how-to-grid { grid-template-columns: 1fr; }
  .how-to-card { min-height: 0; }
  .play-safety-note { grid-template-columns: 38px 1fr; padding: 13px; }
  .play-safety-icon { width: 38px; height: 38px; }
  .checkin-photo-card { grid-template-columns: 88px 1fr; }
  .checkin-photo-card img { width: 88px; height: 70px; }
  .photo-content { padding: 30px 18px 22px; }
  .photo-content h2 { font-size: 24px; }
  .camera-stage { border-radius: 15px; }
  .camera-live-actions { grid-template-columns: 1fr 1fr; }
  .camera-live-actions #capture-photo-button { grid-column: 1 / -1; }
  .camera-review-actions { grid-template-columns: 1fr; }
  .timeline-item.with-photo { grid-template-columns: 34px 46px 1fr; }
  .timeline-item.with-photo .timeline-points { grid-column: 3; justify-self: start; }
  .timeline-photo { width: 46px; height: 40px; }
  .footer-inner { width: calc(100% - 24px); }
}

@media (max-width: 390px) {
  .sound-toggle { width: 38px; height: 38px; }
  .profile-chip { padding-left: 4px; }
  .camera-live-actions { grid-template-columns: 1fr; }
  .camera-live-actions #capture-photo-button { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .map-pin .pin-pulse { animation: none; opacity: .24; transform: scale(1.08); }
}


/* Branding: ม่วนเมืองขอนแก่น */
.brand-copy small {
  letter-spacing: .02em;
  white-space: nowrap;
}
.hero-copy > .hero-tagline {
  max-width: 720px;
  margin: -2px 0 10px;
  color: #fff;
  font-size: clamp(20px, 2.15vw, 28px);
  font-weight: 900;
  line-height: 1.45;
  letter-spacing: -.015em;
}
.hero-copy > .hero-description {
  max-width: 610px;
  color: rgba(255,255,255,.78);
  font-size: 17px;
  line-height: 1.75;
}
@media (max-width: 620px) {
  .brand-copy small { max-width: 185px; overflow: hidden; text-overflow: ellipsis; }
  .hero-copy > .hero-tagline { margin-top: -3px; font-size: 19px; line-height: 1.5; }
  .hero-copy > .hero-description { font-size: 15px; }
}
@media (max-width: 400px) {
  .brand-copy small { max-width: 145px; font-size: 7.5px; }
}

/* Competition, server verification and certificate */
.competition-panel {
  display: grid;
  gap: 16px;
  margin-top: 22px;
  padding: clamp(16px, 2.5vw, 28px);
  border: 1px solid #e2d7c8;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 96% 0, rgba(255, 212, 0, .24), transparent 31%),
    linear-gradient(145deg, #fffdf8, #f7efe4);
  box-shadow: var(--shadow-sm);
}
.competition-hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(17px, 2.4vw, 26px);
  border-radius: 22px;
  background: linear-gradient(125deg, #16110d, #4b2c18);
  color: white;
  overflow: hidden;
  position: relative;
}
.competition-hero-card::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -110px;
  width: 310px;
  height: 310px;
  border: 58px solid rgba(255, 212, 0, .14);
  border-radius: 50%;
}
.competition-brand-lockup,
.competition-actions { position: relative; z-index: 1; }
.competition-brand-lockup { display: flex; align-items: center; gap: 17px; min-width: 0; }
.competition-brand-lockup img {
  width: clamp(74px, 8vw, 105px);
  height: clamp(74px, 8vw, 105px);
  flex: 0 0 auto;
  object-fit: contain;
}
.competition-brand-lockup .panel-kicker { color: #ffd400; }
.competition-brand-lockup h3 { margin: 3px 0 4px; font-size: clamp(22px, 2.8vw, 36px); line-height: 1.25; }
.competition-brand-lockup p { margin: 0; color: rgba(255,255,255,.72); line-height: 1.6; }
.competition-actions { display: grid; justify-items: stretch; gap: 8px; min-width: 220px; }
.competition-actions .primary-button,
.competition-actions .secondary-button { justify-content: center; min-height: 42px; }
.competition-actions .secondary-button { border-color: rgba(255,255,255,.25); background: rgba(255,255,255,.09); color: white; }
.competition-status-badge {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  color: white;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
}
.competition-status-badge.open { background: #dcfce7; color: #166534; }
.competition-status-badge.scheduled { background: #fef3c7; color: #92400e; }
.competition-status-badge.closed,
.competition-status-badge.draft,
.competition-status-badge.error { background: #fee2e2; color: #991b1b; }
.competition-status-badge.loading::before { content: ""; width: 8px; height: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: competition-spin .7s linear infinite; }
@keyframes competition-spin { to { transform: rotate(360deg); } }
.competition-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.competition-facts article {
  display: grid;
  align-content: center;
  min-height: 116px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: white;
}
.competition-facts article > span { color: var(--muted); font-size: 10px; font-weight: 800; }
.competition-facts article > strong { margin: 3px 0; color: var(--purple-dark); font-size: clamp(20px, 2vw, 29px); line-height: 1.25; overflow-wrap: anywhere; }
.competition-facts article > small { color: var(--muted); font-size: 9px; }
.competition-progress-track { height: 7px; margin-top: 9px; overflow: hidden; border-radius: 999px; background: #e9e0d4; }
.competition-progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffd400, #b86b21); transition: width .4s ease; }
.competition-server-note { display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 11px; padding: 13px 15px; border: 1px solid #ead783; border-radius: 15px; background: #fff7cf; }
.competition-server-note svg { width: 32px; height: 32px; fill: none; stroke: #82620b; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.competition-server-note p { margin: 0; color: #67511a; font-size: 11px; line-height: 1.6; }
.competition-server-note strong { color: #42320c; }
.competition-leaderboard-card { padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: white; }
.competition-leaderboard-card .subsection-heading { margin-bottom: 12px; }
.competition-leaderboard-card .subsection-heading > small { max-width: 330px; color: var(--muted); font-size: 9px; text-align: right; }
.competition-leaderboard { display: grid; gap: 7px; }
.competition-leaderboard-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #eee5d9;
  border-radius: 13px;
  background: #fffdf9;
}
.competition-leaderboard-row.is-winner { border-color: #e1c45c; background: linear-gradient(90deg, #fff9db, #fffdf8); }
.competition-leaderboard-rank { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--purple-soft); color: var(--purple); font-weight: 900; }
.competition-leaderboard-row.is-winner .competition-leaderboard-rank { background: #111; color: #ffd400; }
.competition-leaderboard-name { min-width: 0; }
.competition-leaderboard-name strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.competition-leaderboard-name small { color: var(--muted); font-size: 9px; }
.competition-leaderboard-time { color: var(--brown, #4b2c18); font-size: 10px; font-weight: 800; text-align: right; }
.competition-empty { margin: 0; padding: 25px; border-radius: 13px; background: var(--paper-deep); color: var(--muted); text-align: center; font-size: 11px; }
.competition-certificate-link { text-decoration: none; }
.result-certificate-button { margin-top: 12px; text-decoration: none; }

.competition-dialog { width: min(620px, calc(100% - 24px)); }
.competition-dialog-content { padding: 34px clamp(20px, 5vw, 42px) 28px; }
.competition-dialog-logo { width: 90px; height: 90px; margin: 0 auto 12px; }
.competition-dialog-logo img { width: 100%; height: 100%; object-fit: contain; }
.competition-dialog-content > .panel-kicker,
.competition-dialog-content > h2,
.competition-dialog-content > p { text-align: center; }
.competition-dialog-content > h2 { margin: 4px 0 7px; font-size: clamp(25px, 5vw, 36px); }
.competition-dialog-content > p { margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.competition-dialog-status { margin-bottom: 14px; padding: 10px 12px; border-radius: 11px; background: var(--purple-soft); color: var(--purple); font-size: 10px; font-weight: 800; text-align: center; }
.competition-form-error { margin-bottom: 13px; padding: 10px 12px; border-radius: 11px; background: #fee2e2; color: #991b1b; font-size: 11px; font-weight: 800; }
.competition-dialog-content > label:not(.consent-row) { display: block; margin-top: 11px; color: var(--ink); font-size: 11px; font-weight: 900; }
.competition-dialog-content > label b,
.consent-row b { color: var(--red); }
.competition-dialog-content > label span { color: var(--muted); font-weight: 500; }
.competition-dialog-content > input { width: 100%; margin-top: 5px; padding: 12px 13px; border: 1px solid #d5c9bb; border-radius: 11px; background: white; }
.consent-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbf8f2; cursor: pointer; }
.consent-row.required { border-color: #d9c977; background: #fffaf0; }
.consent-row input { width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--purple); }
.consent-row span { display: grid; gap: 2px; }
.consent-row strong { font-size: 11px; }
.consent-row small { color: var(--muted); font-size: 9px; line-height: 1.5; }
.competition-dialog-content #competition-save-button { margin-top: 15px; }
.competition-privacy-summary { margin-top: 10px !important; font-size: 9px !important; }

@media (max-width: 820px) {
  .competition-hero-card { align-items: flex-start; flex-direction: column; }
  .competition-actions { width: 100%; min-width: 0; grid-template-columns: 1fr 1fr; }
  .competition-status-badge { grid-column: 1 / -1; }
  .competition-certificate-link { grid-column: 1 / -1; }
  .competition-facts { grid-template-columns: 1fr; }
  .competition-facts article { min-height: 90px; }
}
@media (max-width: 560px) {
  .competition-panel { padding: 12px; border-radius: 20px; }
  .competition-hero-card { padding: 17px; }
  .competition-brand-lockup { align-items: flex-start; }
  .competition-brand-lockup img { width: 68px; height: 68px; }
  .competition-brand-lockup h3 { font-size: 20px; }
  .competition-actions { grid-template-columns: 1fr; }
  .competition-status-badge,
  .competition-certificate-link { grid-column: auto; }
  .competition-leaderboard-card { padding: 13px; }
  .competition-leaderboard-card .subsection-heading { align-items: flex-start; flex-direction: column; }
  .competition-leaderboard-card .subsection-heading > small { text-align: left; }
  .competition-leaderboard-row { grid-template-columns: 48px minmax(0, 1fr); }
  .competition-leaderboard-time { grid-column: 2; text-align: left; }
}

/* Mobile navigation reliability — release v9 */
.mobile-menu-button { display: none; }
#game-content,
#how-to-play { scroll-margin-top: calc(var(--header-height) + 16px); }

.mobile-menu-dialog {
  position: fixed;
  z-index: 1000;
  inset: auto 12px max(12px, env(safe-area-inset-bottom)) 12px;
  width: min(430px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px - env(safe-area-inset-bottom));
  margin: 0 auto;
  overflow: auto;
  border: 0;
  border-radius: 25px;
  padding: 0;
  background: #fffdf8;
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(24, 14, 35, .34);
}
.mobile-menu-dialog::backdrop {
  background: rgba(28, 18, 40, .62);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.mobile-menu-dialog[open] { animation: mobileMenuIn .22s ease both; }
@keyframes mobileMenuIn {
  from { opacity: 0; transform: translateY(24px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.mobile-menu-sheet { padding: 21px; }
.mobile-menu-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 15px;
}
.mobile-menu-head h2 { margin: 4px 0 0; font-size: 24px; line-height: 1.2; }
.mobile-menu-close {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--ink);
  cursor: pointer;
}
.mobile-menu-close svg,
.mobile-menu-item svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mobile-menu-grid { display: grid; gap: 8px; }
.mobile-menu-item {
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 62px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 13px 8px 8px;
  background: white;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.mobile-menu-item:hover,
.mobile-menu-item:focus-visible { border-color: #bca9d0; background: #faf7fd; }
.mobile-menu-item:active { transform: scale(.99); }
.mobile-menu-item.active { border-color: rgba(79,45,127,.28); background: var(--purple-soft); color: var(--purple); }
.mobile-menu-icon {
  display: grid;
  place-items: center;
  width: 45px;
  height: 45px;
  border-radius: 13px;
  background: #f5efe6;
  color: var(--purple);
}
.mobile-menu-item.active .mobile-menu-icon { background: var(--purple); color: white; }
.mobile-menu-item strong { display: block; font-size: 13px; }
.mobile-menu-item small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; line-height: 1.4; }

@media (max-width: 820px) {
  .mobile-menu-button { display: grid; }
  .mobile-nav { grid-template-columns: repeat(4, 1fr); }
  .mobile-nav button {
    min-width: 0;
    min-height: 52px;
    padding: 7px 4px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav button[aria-current="page"] { background: rgba(255,255,255,.12); color: white; }
}

@media (max-width: 620px) {
  .header-actions { gap: 6px; }
  .mobile-menu-sheet { padding: 18px; }
  .mobile-menu-head h2 { font-size: 22px; }
}

@media (max-width: 400px) {
  .brand-copy small { display: none; }
  .brand-copy strong { font-size: 14px; }
  .header-inner { gap: 8px; }
  .mobile-menu-button,
  .sound-toggle,
  .profile-chip { width: 38px; height: 38px; min-width: 38px; }
  .mobile-nav { width: calc(100% - 16px); bottom: max(8px, env(safe-area-inset-bottom)); border-radius: 16px; }
  .mobile-nav button { min-height: 50px; font-size: 8px; }
  .mobile-nav svg { width: 19px; height: 19px; }
  .mobile-menu-dialog { inset-inline: 8px; width: calc(100% - 16px); }
}

/* Prevent author display rules from overriding the HTML hidden attribute. */
[hidden] { display: none !important; }

@media (max-width: 620px) {
  /* A fixed 300px minimum combined with aspect-ratio widened 320px devices. */
  .schematic-map {
    min-height: 0;
    height: clamp(250px, 80vw, 300px);
    aspect-ratio: auto;
  }
}
