:root {
  --paper: #f6f0e4;
  --paper-2: #efe6d3;
  --card: #fffdf7;
  --ink: #1f2a24;
  --muted: #5f6b62;
  --line: #d9cdb5;
  --forest: #1d4d3a;
  --forest-2: #2c6b52;
  --accent: #e8622c;
  --accent-2: #c94d1c;
  --gold: #d99a1c;
  --ok: #2c7a4b;
  --bad: #b23a2e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 42, 36, .08), 0 6px 18px rgba(31, 42, 36, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
#app { max-width: 720px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; margin: 0; }
p { margin: 0; }
a { color: var(--forest-2); }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.hero { padding: 28px 4px 18px; }
.hero .eyebrow { font: 600 12px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent-2); }
.hero h1 { font-size: clamp(38px, 10vw, 58px); margin: 10px 0 10px; color: var(--forest); letter-spacing: -.01em; }
.hero p { color: var(--muted); font-size: 17px; max-width: 34em; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h2 { font-size: 21px; margin-bottom: 10px; }
.label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.hint { font-size: 14px; color: var(--muted); }

textarea, input[type=text], input[type=search], input[type=number], input[type=datetime-local], select {
  width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; font-size: 17px; font-family: var(--serif); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: var(--forest-2); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.forest { background: var(--forest); border-color: var(--forest); color: #fff; }
.btn.forest:hover { background: var(--forest-2); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; font-size: 17px; min-height: 52px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack > * + * { margin-top: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--paper-2); border-radius: 999px; padding: 4px 10px; font-size: 14px; }
button.chip { border: 1px solid transparent; cursor: pointer; min-height: 36px; }
button.chip:hover { border-color: var(--forest-2); }

.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.theme { text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
.theme strong { display: block; font-family: var(--serif); font-size: 17px; }
.theme small { color: var(--muted); display: block; line-height: 1.3; margin-top: 2px; }
.theme[aria-pressed=true] { border-color: var(--accent); background: #fff4ec; box-shadow: inset 0 0 0 1px var(--accent); }

.place-results { list-style: none; margin: 6px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.place-results button { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--paper-2); padding: 11px 12px; cursor: pointer; }
.place-results li:last-child button { border-bottom: 0; }
.place-results button:hover { background: var(--paper-2); }
details > summary { cursor: pointer; font-weight: 600; min-height: 32px; }
details[open] > summary { margin-bottom: 10px; }

.mission { background: var(--forest); color: #f6f0e4; border-radius: var(--radius); padding: 20px; margin-bottom: 14px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.mission::after { content: ""; position: absolute; right: -40px; top: -40px; width: 150px; height: 150px; border: 2px dashed rgba(246, 240, 228, .25); border-radius: 50%; }
.mission .eyebrow { font: 600 12px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: #f4b48f; }
.mission h1 { font-size: clamp(28px, 7vw, 40px); margin: 8px 0 12px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 15px; }
.mission .story { font-family: var(--serif); font-size: 17px; margin-top: 14px; line-height: 1.45; }
.mission .promise { font-size: 14px; margin-top: 10px; opacity: .85; }
.badge { display: inline-block; font-size: 13px; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .15); margin-right: 4px; }

.notice { border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; background: #fff4d8; border: 1px solid #edd38f; }
.notice.alert { background: #fde9e3; border-color: #f0b3a0; }
.notice.magic { background: #efe8ff; border-color: #c8b8f0; }

.scorebar { position: sticky; top: 0; z-index: 400; background: var(--paper); padding: 8px 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.score { font: 700 15px var(--mono); color: var(--forest); white-space: nowrap; }
.letters { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.letter { width: 26px; height: 30px; display: grid; place-items: center; border: 1.5px dashed var(--line); border-radius: 6px; font: 700 15px var(--mono); }
.letter.on { background: var(--gold); border: 1.5px solid var(--gold); color: #fff; }

#map { height: 240px; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 14px; z-index: 0; }
.map-pin { background: var(--card); border: 2px solid var(--forest); border-radius: 50%; width: 32px; height: 32px; display: grid; place-items: center; font-size: 17px; box-shadow: var(--shadow); }

.timeline { list-style: none; margin: 0 0 14px; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 25px; top: 10px; bottom: 10px; border-left: 2px dashed var(--line); }
.step { position: relative; padding-left: 62px; margin-bottom: 12px; }
.step .pin { position: absolute; left: 4px; top: 8px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--card); border: 2px solid var(--forest); font-size: 21px; z-index: 1; }
.step.done .pin { background: var(--forest); border-color: var(--forest); }
.step .box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.step.done .box { opacity: .82; }
.step .time { font: 700 14px var(--mono); color: var(--accent-2); }
.step h3 { font-size: 19px; margin: 2px 0 2px; }
.step .kind { font-size: 13px; color: var(--muted); }
.step .story { font-family: var(--serif); margin-top: 8px; }
.step .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.tag-warn { color: #8a6a10; }
.tag-ok { color: var(--ok); }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.challenge { margin-top: 10px; border: 1.5px solid var(--gold); background: #fff9e8; border-radius: 12px; padding: 10px 12px; }
.challenge.done { border-color: var(--ok); background: #eef7f0; }
.challenge .head { font-weight: 700; font-size: 14px; }
.challenge .text { font-family: var(--serif); font-size: 16px; margin: 4px 0 8px; }
.challenge .won { color: var(--ok); font-weight: 600; font-size: 14px; }

.stars { display: flex; gap: 2px; }
.stars button { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; padding: 4px 3px; min-width: 40px; min-height: 40px; color: var(--line); }
.stars button.on { color: var(--gold); }
.rating-big { font: 700 32px var(--serif); color: var(--gold); }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 32px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.gallery figure { margin: 0; position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--paper-2); }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery button { position: absolute; top: 4px; right: 4px; background: rgba(0, 0, 0, .55); color: #fff; border: 0; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

.hunt { list-style: none; padding: 0; margin: 0; }
.hunt li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.hunt li:last-child { border-bottom: 0; }
.hunt input { width: 22px; height: 22px; accent-color: var(--forest); flex: none; }
.hunt label { flex: 1; }

.diff { list-style: none; padding: 0; margin: 8px 0 0; font-size: 15px; }
.diff .out { color: var(--bad); }
.diff .in { color: var(--ok); }
.bubble { background: var(--paper-2); border-radius: 10px; padding: 8px 10px; margin-top: 8px; font-size: 15px; }
.bubble small { display: block; color: var(--muted); }

.proposal { border-left: 6px solid var(--line); }
.proposal.chill { border-left-color: #3f9d5f; }
.proposal.decouverte { border-left-color: #e08a1c; }
.proposal.wtf { border-left-color: #cf3b2c; }
.proposal h2 { margin: 4px 0 8px; font-size: 24px; }
.proposal .route { font-size: 14px; color: var(--muted); margin: 8px 0 12px; }

.memory { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; display: block; color: inherit; text-decoration: none; }
.memory .cover { width: 100%; height: 170px; object-fit: cover; display: block; }
.memory .inner { padding: 14px 16px; }
.memory time { font: 700 13px var(--mono); letter-spacing: .08em; color: var(--accent-2); }
.memory h3 { font-size: 22px; margin: 6px 0; }
.memory .quote { font-family: var(--serif); font-style: italic; margin: 8px 0; }
.memory .nums { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; text-align: center; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 4px; }
.stats strong { display: block; font: 700 21px var(--serif); color: var(--forest); }
.stats span { font-size: 12px; color: var(--muted); }
.insights { background: var(--forest); color: #f6f0e4; }
.insights h2 { color: #f4b48f; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { font-size: 46px; }

#nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; z-index: 900; padding-bottom: env(safe-area-inset-bottom); }
#nav a { flex: 1; max-width: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 8px 4px; min-height: 60px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; }
#nav a span { font-size: 21px; line-height: 1.1; }
#nav a.on { color: var(--accent-2); }

#loader { position: fixed; inset: 0; background: rgba(29, 77, 58, .92); z-index: 2000; display: grid; place-items: center; padding: 24px; color: #f6f0e4; }
.loader-card { text-align: center; max-width: 320px; }
.compass { font-size: 62px; animation: swing 1.7s ease-in-out infinite; }
#loader-text { font: 19px/1.35 var(--serif); margin-top: 12px; min-height: 2.8em; }
@keyframes swing { 0%, 100% { transform: rotate(-24deg); } 50% { transform: rotate(32deg); } }
@media (prefers-reduced-motion: reduce) { .compass { animation: none; } }

#toast { position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 2100; font-size: 15px; max-width: calc(100vw - 32px); }
@media print { #nav, .tools, .btn { display: none !important; } }
