@import url('../design-system/default/tokens.css');

:root {
  --ink: #1e1b4b;
  --ink-soft: #475569;
  --purple: #4f46e5;
  --purple-soft: #eef2ff;
  --orange: #ea580c;
  --orange-soft: #fff1e8;
  --surface: #ffffff;
  --line: #c7d2fe;
  --shadow: 0 14px 30px rgba(30, 27, 75, .10);
  --radius-lg: 24px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #e2e8ff; }
body { margin: 0; min-width: 320px; min-height: 100%; color: var(--ink); background: radial-gradient(circle at top right, #c7d2fe 0, transparent 34%), linear-gradient(145deg, #eef2ff 0%, #fff7ed 100%); font-family: 'Nunito', system-ui, sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(100%, 760px); margin: 0 auto; min-height: 100vh; padding: max(20px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom)); }
.screen { min-height: calc(100vh - 48px); display: flex; flex-direction: column; gap: 18px; animation: appear .25s ease both; }
.screen[hidden], .modal[hidden] { display: none; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: 'Fredoka', sans-serif; letter-spacing: -.02em; }
h1 { margin-bottom: 12px; font-size: clamp(2.6rem, 11vw, 4.8rem); line-height: .95; }
h2 { margin-bottom: 8px; font-size: clamp(2rem, 8vw, 3rem); line-height: 1; }
h3 { margin-bottom: 4px; font-size: 1.45rem; }
.eyebrow, .section-kicker { margin-bottom: 8px; color: var(--orange); font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.section-kicker { color: var(--purple); }

.hero-card { position: relative; overflow: hidden; padding: 28px 24px 22px; border: 3px solid rgba(79,70,229,.18); border-radius: var(--radius-lg); background: rgba(255,255,255,.84); box-shadow: var(--shadow); }
.hero-card::after { content: ''; position: absolute; width: 180px; height: 180px; top: -90px; left: -64px; border-radius: 50%; background: #ffedd5; opacity: .7; }
.hero-mark { position: relative; z-index: 1; width: 64px; height: 64px; display: grid; place-items: center; margin-bottom: 28px; border-radius: 18px; background: var(--purple); box-shadow: 0 8px 0 #c7d2fe; }
.hero-mark svg, .hero-mark path { width: 36px; fill: none; stroke: white; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.hero-visual { position: relative; overflow: hidden; min-height: 190px; margin: 0 -8px 24px; border-radius: 20px; background: #dbeafe; box-shadow: 0 9px 18px rgba(30,27,75,.14); }
.hero-visual::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(30,27,75,.04), rgba(30,27,75,.25)); pointer-events: none; }
.hero-visual img { width: 100%; height: 220px; display: block; object-fit: cover; object-position: center; }
.hero-visual-label { position: absolute; z-index: 1; right: 12px; bottom: 12px; padding: 7px 10px; border: 2px solid rgba(255,255,255,.8); border-radius: 999px; color: #fff; background: rgba(79,70,229,.88); font-size: .72rem; font-weight: 800; }
.hero-copy { max-width: 48ch; margin-bottom: 22px; color: var(--ink-soft); font-size: 1.12rem; line-height: 1.55; }
.quick-stats { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 24px; }
.quick-stats span { padding: 9px 12px; border-radius: 999px; background: var(--purple-soft); color: var(--ink-soft); font-size: .88rem; }
.quick-stats strong { color: var(--purple); font-family: 'Fredoka', sans-serif; font-size: 1.05rem; }
.team-field { display: grid; gap: 7px; margin-bottom: 14px; color: var(--ink); font-size: .9rem; font-weight: 800; }
.team-field span { color: var(--ink-soft); font-size: .78rem; font-weight: 600; }
.team-field small { color: var(--ink-soft); font-size: .76rem; font-weight: 600; }
.team-field input { width: 100%; min-height: 48px; padding: 11px 14px; border: 2px solid var(--line); border-radius: 13px; color: var(--ink); background: #fff; font-weight: 700; outline: none; transition: border-color .2s ease, box-shadow .2s ease; }
.team-field input:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(79,70,229,.14); }
.team-field input:invalid:not(:placeholder-shown) { border-color: #fca5a5; }
.form-error { margin: -2px 0 12px; padding: 10px 12px; border-radius: 11px; color: #991b1b; background: #fef2f2; font-size: .82rem; font-weight: 700; }
.privacy-note { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 15px 0 0; color: var(--ink-soft); font-size: .8rem; }
.privacy-dot { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; }
.welcome-panel, .map-intro, .album-card, .ai-card { padding: 20px; border: 2px solid rgba(79,70,229,.13); border-radius: var(--radius-md); background: rgba(255,255,255,.72); box-shadow: 0 8px 20px rgba(30,27,75,.06); }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.how-grid div { display: grid; gap: 8px; color: var(--ink-soft); font-size: .83rem; line-height: 1.2; }
.step-number { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 10px; background: var(--orange-soft); color: var(--orange); font-family: 'Fredoka', sans-serif; font-weight: 700; }

.button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; padding: 12px 18px; border: 2px solid transparent; border-radius: 13px; font-weight: 800; transition: transform .2s ease, box-shadow .2s ease, background .2s ease; }
.button:focus-visible, .icon-button:focus-visible, .modal-close:focus-visible { outline: 3px solid #fbbf24; outline-offset: 3px; }
.button:active { transform: translateY(1px); }
.button--wide { width: 100%; }
.button--primary { color: #fff; background: var(--purple); box-shadow: 0 4px 0 #312e81; }
.button--primary:hover { background: #4338ca; }
.button--primary:disabled { cursor: not-allowed; opacity: .48; box-shadow: none; }
.button--secondary { color: var(--purple); border-color: var(--purple); background: #fff; }
.button--secondary:hover { background: var(--purple-soft); }
.button--ghost { color: var(--ink-soft); background: transparent; }
.button--ghost:hover { background: rgba(255,255,255,.7); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 2px; }
.topbar h2 { margin-bottom: 0; }
.topbar--station { justify-content: flex-start; }
.topbar-spacer { width: 42px; }
.station-counter { color: var(--ink-soft); font-weight: 800; font-size: .9rem; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 13px; background: #fff; box-shadow: var(--shadow); }
.icon-button svg { width: 23px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.progress-ring { width: 52px; height: 52px; display: grid; place-items: center; border: 6px solid #c7d2fe; border-left-color: var(--orange); border-radius: 50%; background: #fff; font-family: 'Fredoka', sans-serif; font-size: .86rem; }
.map-intro { display: grid; gap: 4px; color: var(--ink-soft); line-height: 1.45; }
.map-intro strong { color: var(--ink); font-family: 'Fredoka', sans-serif; font-size: 1.2rem; }
.route-list { position: relative; display: grid; gap: 12px; padding: 4px 0; }
.route-list::before { content: ''; position: absolute; top: 28px; bottom: 28px; right: 22px; width: 4px; border-radius: 4px; background: #c7d2fe; }
.route-item { position: relative; z-index: 1; width: 100%; display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; padding: 12px; border: 2px solid transparent; border-radius: var(--radius-md); color: var(--ink); text-align: right; background: #fff; box-shadow: 0 6px 18px rgba(30,27,75,.07); transition: border-color .2s ease, transform .2s ease; }
.route-item:hover { border-color: var(--line); transform: translateY(-1px); }
.route-item:disabled { cursor: not-allowed; opacity: .62; }
.route-dot { width: 44px; height: 44px; display: grid; place-items: center; border: 4px solid #fff; border-radius: 15px; color: var(--purple); background: var(--purple-soft); box-shadow: 0 0 0 2px var(--line); font-family: 'Fredoka', sans-serif; font-size: 1.1rem; }
.route-item.is-done .route-dot { color: #fff; background: #16a34a; box-shadow: 0 0 0 2px #bbf7d0; }
.route-item.is-current .route-dot { color: #fff; background: var(--orange); box-shadow: 0 0 0 2px #fed7aa; }
.route-copy { display: grid; gap: 3px; }
.route-copy strong { font-family: 'Fredoka', sans-serif; font-size: 1.08rem; }
.route-copy span { color: var(--ink-soft); font-size: .83rem; }
.route-action { color: var(--purple); font-size: .8rem; font-weight: 800; }
.team-name-display { margin: 0 0 2px; color: var(--ink-soft); font-size: .8rem; font-weight: 800; }
.map-footer { margin-top: auto; }

/* Map-first game layer: real streets underneath, original game markers above. */
.screen[data-screen="map"] { gap: 0; min-height: calc(100vh - 48px); margin: -4px -18px -28px; padding-bottom: 0; }
.game-topbar { position: relative; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px 10px; background: rgba(255,255,255,.94); box-shadow: 0 3px 15px rgba(30,27,75,.08); }
.game-team { display: flex; align-items: center; gap: 9px; min-width: 0; }
.game-team > div { display: grid; gap: 2px; min-width: 0; }
.game-team strong { overflow: hidden; font-family: 'Fredoka', sans-serif; font-size: 1.03rem; text-overflow: ellipsis; white-space: nowrap; }
.game-team span:not(.team-shield) { color: var(--ink-soft); font-size: .72rem; font-weight: 700; }
.team-shield { width: 34px; height: 34px; display: grid; place-items: center; border: 3px solid #fff; border-radius: 12px; color: #fff; background: var(--purple); box-shadow: 0 0 0 2px #c7d2fe, 0 3px 0 #312e81; font-family: 'Fredoka', sans-serif; font-weight: 700; }
.game-progress { min-width: 104px; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; color: var(--ink-soft); font-size: .68rem; font-weight: 800; }
.game-progress strong { color: var(--orange); font-family: 'Fredoka', sans-serif; font-size: .9rem; }
.progress-bar { grid-column: 1 / -1; height: 7px; overflow: hidden; border-radius: 999px; background: #e2e8f0; }
.progress-bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--orange), #fbbf24); transition: width .25s ease; }
.map-stage { position: relative; min-height: 46vh; overflow: hidden; background: #dbeafe; }
#game-map { position: absolute; inset: 0; z-index: 1; min-height: 46vh; font-family: 'Nunito', sans-serif; }
.map-search { position: absolute; z-index: 3; top: 14px; right: 18px; left: 18px; min-height: 52px; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 2px solid rgba(255,255,255,.8); border-radius: 18px; color: var(--ink-soft); background: rgba(255,255,255,.94); box-shadow: 0 8px 18px rgba(30,27,75,.14); font-weight: 800; pointer-events: none; }
.search-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: var(--purple-soft); }
.search-icon svg { width: 19px; fill: none; stroke: var(--purple); stroke-width: 2.2; stroke-linecap: round; }
.menu-button { width: 34px; height: 34px; display: grid; place-content: center; gap: 4px; margin-right: auto; border: 0; border-radius: 10px; background: transparent; }
.menu-button span { display: block; width: 21px; height: 3px; border-radius: 2px; background: var(--ink); }
.map-status-chip { position: absolute; z-index: 3; top: 78px; right: 18px; display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border-radius: 999px; color: #166534; background: rgba(240,253,244,.94); box-shadow: 0 5px 14px rgba(30,27,75,.1); font-size: .74rem; font-weight: 800; }
.status-pulse { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px #bbf7d0; }
.map-locate { position: absolute; z-index: 3; bottom: 18px; right: 18px; width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 16px; background: #fff; box-shadow: 0 7px 18px rgba(30,27,75,.18); }
.map-locate svg { width: 25px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.map-sheet { position: relative; z-index: 2; max-height: 48vh; overflow: auto; padding: 10px 18px 24px; border-radius: 24px 24px 0 0; background: rgba(255,255,255,.97); box-shadow: 0 -7px 20px rgba(30,27,75,.1); }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 12px; border-radius: 999px; background: #cbd5e1; }
.map-sheet-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.map-sheet-heading h2 { margin-bottom: 0; font-size: 1.8rem; }
.map-sheet .map-intro { margin: 12px 0; padding: 13px; }
.map-sheet .route-list { max-height: 260px; overflow: auto; }
.map-sheet .route-item { box-shadow: 0 3px 10px rgba(30,27,75,.06); }
.map-next-hint { margin: 12px 2px 4px; color: var(--ink-soft); text-align: center; font-size: .78rem; font-weight: 700; line-height: 1.45; }
.route-item--revealed { border-color: rgba(234,88,12,.22); background: linear-gradient(135deg, #fff 0%, #fff7ed 100%); }
.route-item--revealed .route-action { padding: 7px 9px; border-radius: 9px; color: #fff; background: var(--orange); }
.leaflet-control-attribution { font-size: 8px !important; }
.leaflet-control-zoom { border: 0 !important; box-shadow: 0 5px 14px rgba(30,27,75,.14) !important; }
.leaflet-control-zoom a { color: var(--ink) !important; }
.station-pin-wrap { background: transparent; border: 0; }
.station-pin { width: 46px; height: 46px; display: grid; place-items: center; border: 4px solid #fff; border-radius: 16px 16px 16px 3px; transform: rotate(-45deg); color: #fff; box-shadow: 0 5px 12px rgba(30,27,75,.24); font-family: 'Fredoka', sans-serif; font-size: 1.2rem; font-weight: 700; }
.station-pin b { display: block; transform: rotate(45deg); font-weight: 700; }
.station-pin::after { content: ''; position: absolute; width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.34); }
.station-pin--active { background: var(--orange); }
.station-pin--done { background: #16a34a; }
.station-pin--locked { color: #64748b; background: #cbd5e1; }
.leaflet-marker-icon .station-pin { line-height: 38px; text-align: center; }

.station-card, .camera-card { padding: 20px; border: 2px solid rgba(79,70,229,.15); border-radius: var(--radius-lg); background: rgba(255,255,255,.88); box-shadow: var(--shadow); }
.station-illustration { min-height: 120px; margin-bottom: 20px; border-radius: 18px; background: radial-gradient(circle at 25% 35%, #fed7aa 0 8%, transparent 8.5%), radial-gradient(circle at 70% 28%, #c7d2fe 0 11%, transparent 11.5%), linear-gradient(145deg, #4f46e5, #818cf8 62%, #f97316); }
.station-story { margin-bottom: 18px; color: var(--ink-soft); font-size: 1.04rem; line-height: 1.65; }
.mission-box { display: flex; align-items: flex-start; gap: 12px; margin: 16px 0 18px; padding: 15px; border-radius: 15px; background: var(--orange-soft); }
.mission-icon { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: #fff; }
.mission-icon svg { width: 24px; fill: none; stroke: var(--orange); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.mission-text { margin: 0; font-weight: 700; line-height: 1.5; }
.station-hint, .camera-instruction { margin: 12px 0 0; color: var(--ink-soft); text-align: center; font-size: .82rem; }

.camera-card { margin-top: 2vh; }
.camera-placeholder { min-height: 250px; display: grid; place-items: center; align-content: center; gap: 14px; border: 2px dashed var(--line); border-radius: 18px; color: var(--ink-soft); text-align: center; }
.camera-placeholder svg { width: 64px; fill: none; stroke: var(--purple); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.camera-placeholder p { margin: 0; font-weight: 800; }
.external-photo-card { margin-top: 2vh; }
.photo-steps { display: grid; gap: 12px; margin: 20px 0; padding: 0 24px 0 0; color: var(--ink); font-weight: 700; line-height: 1.45; }
.photo-steps li::marker { color: var(--orange); font-family: 'Fredoka', sans-serif; font-size: 1.2rem; }

.finish-hero { padding: 24px 8px 6px; text-align: center; }
.finish-hero p:last-child { max-width: 44ch; margin: 0 auto; color: var(--ink-soft); line-height: 1.55; }
.finish-badge { width: 76px; height: 76px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 25px; background: #dcfce7; }
.finish-badge svg { width: 50px; fill: none; stroke: #16a34a; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.album-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.album-heading h3 { margin-bottom: 0; }
.album-heading > span { color: var(--ink-soft); font-size: .82rem; font-weight: 800; }
.album-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.album-grid figure { min-width: 0; margin: 0; }
.album-grid img { width: 100%; aspect-ratio: 1; display: block; object-fit: cover; border-radius: 12px; background: var(--purple-soft); }
.album-grid figcaption { overflow: hidden; margin-top: 5px; color: var(--ink-soft); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.finish-copy { margin: 0; color: var(--ink-soft); line-height: 1.6; }
.album-empty { grid-column: 1 / -1; padding: 18px; border-radius: 12px; color: var(--ink-soft); background: var(--purple-soft); text-align: center; font-size: .9rem; }
.ai-card { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.ai-card .button { grid-column: 1 / -1; }
.ai-card p:not(.section-kicker) { margin-bottom: 0; color: var(--ink-soft); line-height: 1.5; }
.ai-spark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--purple-soft); }
.ai-spark svg { width: 24px; fill: none; stroke: var(--purple); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(30,27,75,.48); backdrop-filter: blur(4px); }
.modal-card { position: relative; width: min(100%, 480px); padding: 28px 22px 22px; border-radius: var(--radius-lg); background: #fff; box-shadow: 0 20px 50px rgba(30,27,75,.25); }
.modal-close { position: absolute; top: 12px; left: 12px; width: 40px; height: 40px; border: 0; border-radius: 12px; color: var(--ink-soft); background: var(--purple-soft); font-size: 1.6rem; line-height: 1; }
.ai-steps { display: grid; gap: 12px; padding-right: 22px; color: var(--ink-soft); line-height: 1.5; }
.modal-note { padding: 12px; border-radius: 12px; color: #166534; background: #f0fdf4; font-size: .86rem; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(1px, 1px, 1px, 1px) !important; white-space: nowrap !important; }

@keyframes appear { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (min-width: 640px) { .app-shell { padding-inline: 28px; } .hero-card { padding: 38px; } .station-card, .camera-card { padding: 28px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
