/* Rooie Muppets - Brandweer Egmond aan Zee */

:root {
  --red: #E1251B;
  --red-deep: #A8140D;
  --yellow: #FFC93C;
  --yellow-deep: #F2A900;
  --bg: #FFF6E8;
  --card: #FFFFFF;
  --ink: #23140F;
  --ink-2: #74594F;
  --ink-3: #B39C92;
  --line: rgba(35, 20, 15, .09);
  --tint: rgba(225, 37, 27, .07);
  --shadow: 0 1px 2px rgba(60, 20, 10, .05), 0 12px 30px rgba(60, 20, 10, .08);
  --radius: 24px;
  --bar: rgba(255, 246, 232, .86);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --fun: "Fredoka", var(--font);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #160B09;
    --card: #24140F;
    --ink: #FFF1E6;
    --ink-2: #C9A99C;
    --ink-3: #85675C;
    --line: rgba(255, 230, 215, .11);
    --tint: rgba(255, 90, 70, .14);
    --shadow: none;
    --bar: rgba(22, 11, 9, .82);
  }
}

* { box-sizing: border-box; }

/* display:grid/flex wint anders van het hidden-attribuut */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--bar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.brand img { width: 36px; height: 36px; }
.brand span { font: 600 19px/1 var(--fun); letter-spacing: -.01em; white-space: nowrap; }
@media (max-width: 400px) { .brand span { font-size: 17px; } .brand img { width: 30px; height: 30px; } .topbar { gap: 8px; } }
@media (max-width: 350px) { .brand span { display: none; } }
.brand b { color: var(--red); font-weight: 700; }

.topbar .me {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: 600 14px/1 var(--fun);
  cursor: pointer;
  max-width: 48vw;
}
.topbar .me > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .me .avatar[hidden] + span { padding: 7px 0 7px 8px; }

/* ---------- avatars ---------- */
.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  overflow: hidden;
  background: #FFE3B0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.06); }
.avatar svg { width: 100%; height: 100%; }
.avatar.md { width: 42px; height: 42px; }
.avatar.lg { width: 58px; height: 58px; }
.avatar.xl { width: 104px; height: 104px; margin: 4px auto 14px; display: grid; box-shadow: 0 0 0 5px var(--yellow); }

/* ---------- layout ---------- */
main { max-width: 620px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 18px;
  color: #fff;
  background:
    repeating-linear-gradient(135deg, transparent 0 22px, rgba(255, 201, 60, .14) 22px 44px) right top / 52% 70% no-repeat,
    linear-gradient(160deg, #EE3B2F, var(--red) 45%, var(--red-deep));
  box-shadow: 0 14px 34px rgba(168, 20, 13, .28);
}

.kicker {
  margin: 0 0 8px;
  font: 600 12px/1.2 var(--font);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .75);
}

.hero > * { position: relative; z-index: 2; }
.hero > .kicker, .hero > h1, .hero > .lede, .hero > .steps { animation: enter .6s cubic-bezier(.2, .9, .3, 1) both; }
.hero > h1 { animation-delay: .06s; }
.hero > .lede { animation-delay: .12s; }
.hero > .steps { animation-delay: .18s; }
@keyframes enter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.hero h1 {
  margin: 0 0 10px;
  max-width: 11ch;
  font: 700 clamp(28px, 8vw, 40px)/1.02 var(--fun);
  letter-spacing: -.015em;
  text-wrap: balance;
}

.lede {
  margin: 0;
  max-width: 30ch;
  font-size: 15px;
  line-height: 1.45;
  color: rgba(255, 255, 255, .9);
}

/* Headerfoto: welkom bij binnenkomst, ingeklapt zodra je meedoet */
.hero-photo {
  margin: 16px -18px -18px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #c1dce9;
}
.hero-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.hero.compact .hero-photo { display: none; }
.hero.compact { padding-bottom: 18px; }

.tries {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  font: 600 14px/1 var(--fun);
}
.tries .dot {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, .55);
  font-size: 13px;
  color: rgba(255, 255, 255, .7);
}
.tries .dot.next { border: 2px solid var(--yellow); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
.tries .dot.used { border: 0; background: var(--yellow); color: var(--red-deep); }
.tries #triesText { margin-left: 6px; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 201, 60, .5); }
  50% { box-shadow: 0 0 0 6px rgba(255, 201, 60, 0); }
}

/* ---------- twee pogingen ---------- */
.steps {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
}
.steps li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .13);
  border: 1.5px solid transparent;
}
.steps li > b {
  display: grid; place-items: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, .6);
  font: 700 13px/1 var(--fun);
}
.steps li strong { display: block; font: 600 14.5px/1.2 var(--fun); }
.steps li small { display: block; margin-top: 2px; font-size: 12px; line-height: 1.35; color: rgba(255, 255, 255, .85); }
.steps li.next { border-color: var(--yellow); background: rgba(255, 255, 255, .18); }
.steps li.next > b { border: 0; background: #fff; color: var(--red); animation: pulse 1.6s ease-in-out infinite; }
.steps li.used > b { border: 0; background: var(--yellow); color: var(--red-deep); }
.steps li.used small { font-weight: 600; color: #fff; }

/* ---------- ranglijstknop ---------- */
.rank-btn {
  margin-left: auto;
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font: 600 13px/1 var(--fun);
  color: var(--ink);
  cursor: pointer;
}
.rank-btn[aria-pressed="true"] { background: var(--yellow); border-color: transparent; }
.rank-btn .badge { margin-left: 0; }
.topbar .rank-btn + .me { margin-left: 0; }
.back {
  justify-self: start;
  border: 0; background: none; padding: 4px 2px;
  font: 600 15px/1 var(--fun); color: var(--red); cursor: pointer;
}

/* ---------- segmented control ---------- */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  background: var(--tint);
  border-radius: 14px;
}
.segmented button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: 600 16px/1 var(--fun);
  padding: 11px 10px;
  border-radius: 11px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}
.segmented button[aria-selected="true"] {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.badge {
  display: inline-block;
  margin-left: 4px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 12px;
  vertical-align: 1px;
}
.badge:empty { display: none; }

.panel { display: grid; gap: 16px; }

/* ---------- map ---------- */
.map-card { padding: 10px; overflow: hidden; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--tint);
  border-radius: 12px;
  padding: 0 10px;
  margin-bottom: 10px;
}
.search svg { width: 17px; height: 17px; flex: none; fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; }
.search input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 400 16px/1 var(--font);
  padding: 12px 0;
  outline: none;
  min-width: 0;
}
.search input::placeholder { color: var(--ink-3); }
.search button { border: 0; background: transparent; color: var(--ink-2); font-size: 20px; line-height: 1; cursor: pointer; padding: 4px; }

.results { list-style: none; margin: -4px 0 10px; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.results li { border-top: 1px solid var(--line); }
.results li:first-child { border-top: 0; }
.results button {
  width: 100%;
  text-align: left;
  border: 0;
  background: var(--card);
  color: var(--ink);
  font: 400 14px/1.35 var(--font);
  padding: 11px 12px;
  cursor: pointer;
}
.results button:hover { background: var(--tint); }

.map-wrap { position: relative; }
.map-badge {
  position: absolute; z-index: 5; top: 10px; left: 50%;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font: 600 13px/1 var(--fun);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .25);
  pointer-events: none;
  white-space: nowrap;
}
.map-badge.done { background: var(--yellow); color: #3a1a00; }

#map {
  height: 52vh;
  height: 52svh;
  min-height: 300px;
  border-radius: 16px;
  overflow: hidden;
  z-index: 1;
  background: var(--tint);
}

.maphint { margin: 10px 4px 2px; font-size: 13.5px; color: var(--ink-2); text-align: center; }

.pin-icon { background: none; border: 0; }
.pin-icon svg { display: block; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35)); transform-origin: 50% 100%; }
.pin-icon.drop svg { animation: pindrop .45s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes pindrop {
  0% { transform: translateY(-36px) scale(.8); opacity: 0; }
  60% { transform: translateY(0) scale(1.1, .9); opacity: 1; }
  100% { transform: none; }
}
.home-icon { background: none; border: 0; }
.home-icon span {
  display: flex; align-items: center; gap: 4px;
  width: max-content;
  padding: 3px 8px 3px 3px;
  border-radius: 999px;
  background: #fff;
  color: #23140F;
  font: 600 11px/1 var(--fun);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.home-icon img { width: 18px; height: 18px; border-radius: 50%; }
.pin-body { fill: var(--red); stroke: #fff; stroke-width: 2.5; }
.pin-icon.faded .pin-body { fill: var(--red-deep); }
.pin-num {
  position: absolute;
  right: -6px; top: -6px;
  display: grid;
  place-items: center;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--red-deep);
  font: 700 12px/1 var(--fun);
  border: 2px solid #fff;
}

/* ---------- ranglijst ---------- */
.progress-card { padding: 16px 18px; }
.progress-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.progress-top strong { font: 600 18px/1.2 var(--fun); }
.progress-top span { font: 700 15px/1 var(--fun); color: var(--red); white-space: nowrap; }
.bar { height: 10px; margin: 12px 0 10px; border-radius: 999px; background: var(--tint); overflow: hidden; }
.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: repeating-linear-gradient(135deg, var(--red) 0 10px, var(--yellow) 10px 20px);
  transition: width .6s ease;
}
.progress-card p { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }
.progress-card.open { background: var(--yellow); border-color: transparent; color: #3a1a00; }
.progress-card.open p { color: #6b3a00; }
.progress-card.open .progress-top span { color: var(--red-deep); }

.ranking {
  list-style: none; margin: 0; padding: 0;
  border-radius: var(--radius); overflow: hidden;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.ranking li { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); }
.ranking li:first-child { border-top: 0; }
.ranking li.empty { color: var(--ink-2); font-size: 14px; justify-content: center; }
.ranking li.mine { background: var(--tint); }
.ranking li.todo .avatar { filter: grayscale(1); opacity: .55; }
.ranking li.todo .who b { color: var(--ink-2); }

.place { width: 28px; flex: none; text-align: center; font: 700 17px/1 var(--fun); color: var(--ink-3); }
.ranking li.podium .place { font-size: 24px; }
.ranking li.p1 { background: linear-gradient(90deg, rgba(255, 201, 60, .35), transparent 80%); }
.who { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.who b { font: 600 16px/1.2 var(--fun); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { font-size: 12.5px; color: var(--ink-2); }
.ranking li.done:not(.podium) .who small { color: #23864A; }
.pts { font: 700 17px/1 var(--fun); white-space: nowrap; letter-spacing: .02em; }
.ranking li .pts:not(:empty) { min-width: 3ch; text-align: right; }

.ranking li.reveal { animation: unveil .55s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes unveil {
  from { opacity: .3; filter: blur(6px); transform: scale(.97); }
  to { opacity: 1; filter: none; transform: none; }
}
.ranking li.p1.reveal { animation-name: unveil, champ; animation-duration: .55s, 1.2s; }
@keyframes champ { 50% { transform: scale(1.03); } }

footer {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin-top: 12px;
  padding: 28px 0 12px;
  border-top: 1px solid var(--line);
  text-align: center;
}
footer img { width: 36px; height: 36px; border-radius: 50%; margin-bottom: 6px; opacity: .9; }
footer strong { font: 600 13px/1.3 var(--fun); color: var(--ink-2); }
footer span { font-size: 12px; color: var(--ink-3); letter-spacing: .02em; }

/* ---------- actiebalk ---------- */
.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
.actionbar > * { max-width: 620px; margin-inline: auto; }

.primary {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 16px;
  background: var(--red);
  color: #fff;
  font: 600 18px/1 var(--fun);
  padding: 17px 20px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--red-deep);
  transition: transform .1s ease, box-shadow .1s ease;
}
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-deep); }
.primary:disabled { background: var(--tint); color: var(--ink-3); box-shadow: none; cursor: default; transform: none; }
.primary.done { background: var(--yellow); color: #3a1a00; box-shadow: 0 4px 0 var(--yellow-deep); }

.ghost {
  border: 0; border-radius: 16px;
  background: var(--tint);
  color: var(--ink);
  font: 600 17px/1 var(--fun);
  padding: 16px 20px; cursor: pointer;
}

/* ---------- sheets ---------- */
dialog.sheet {
  border: 0;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  width: min(560px, 100%);
  max-width: 100%;
  max-height: 88vh;
  margin: auto auto 0;
  border-radius: 28px 28px 0 0;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25);
}
@media (min-width: 640px) {
  dialog.sheet { margin: auto; border-radius: 28px; padding-bottom: 22px; }
}
dialog.sheet[open] { animation: rise .28s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes rise { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
dialog.sheet::backdrop { background: rgba(30, 8, 4, .5); backdrop-filter: blur(3px); }
dialog.narrow { width: min(400px, 100%); }

.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-mascot { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; flex: none; }
.sheet-head h2 { flex: 1; }
.sheet h2 { margin: 0; font: 700 24px/1.15 var(--fun); }
.sheet-head button { border: 0; background: var(--tint); color: var(--ink-2); width: 32px; height: 32px; border-radius: 50%; font-size: 18px; line-height: 1; cursor: pointer; }
.sheet-sub { margin: 8px 0 16px; font-size: 14px; color: var(--ink-2); line-height: 1.45; }
.sheet-actions { display: grid; gap: 10px; margin-top: 20px; }

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
  overflow-y: auto;
  max-height: 60vh;
  padding: 2px;
}
.choices button {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 12px 4px 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  font: 600 14px/1.15 var(--fun);
  cursor: pointer;
}
.choices button:hover { border-color: var(--red); }
.choices button:active { transform: scale(.96); }
.choices button[disabled] { opacity: .35; cursor: not-allowed; }
.choices button[disabled] span::after { content: "bezet"; display: block; font: 400 11px/1.3 var(--font); color: var(--ink-3); }

.error { margin: 12px 0 0; font-size: 13px; color: var(--red); min-height: 1em; }

dialog.center { text-align: center; }
dialog.center h2 { margin-bottom: 4px; }

:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 14px; }

/* ---------- uitslag van een pin ---------- */
.result-label { margin: 4px 0 4px; font: 600 12px/1 var(--font); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.result-emoji { font-size: 64px; line-height: 1; margin: 4px 0 10px; animation: wobble .7s ease both; }
@keyframes wobble {
  0% { transform: scale(.3) rotate(-20deg); }
  60% { transform: scale(1.15) rotate(8deg); }
  100% { transform: none; }
}
.result-km { margin: 8px 0 0; font-size: 15px; color: var(--ink-2); }
.result-score { margin: 14px 0 0; }
.result-score span { display: block; font: 700 64px/1 var(--fun); color: var(--red); letter-spacing: -.01em; }
.result-score small { display: block; margin-top: 2px; font: 600 12px/1 var(--font); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.result-compare { margin: 14px 0 0; padding: 10px 14px; border-radius: 14px; background: var(--tint); font: 600 15px/1.35 var(--fun); }
.result-total {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 4px 10px;
  margin: 14px 0 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--yellow);
  color: #3a1a00;
  text-align: left;
}
.result-total span { font: 600 16px/1 var(--fun); }
.result-total b { font: 700 22px/1 var(--fun); }
.result-total small { grid-column: 1 / -1; font-size: 13px; color: #6b3a00; }
dialog.result .primary { margin-top: 20px; }

.confetti {
  position: fixed; inset: 0; z-index: 100;
  width: 100vw; height: 100vh;
  margin: 0; padding: 0; border: 0; background: transparent;
  pointer-events: none; overflow: hidden;
}
.confetti i {
  position: absolute;
  top: -20px;
  width: 9px; height: 14px;
  border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translate(var(--dx), 110vh) rotate(var(--spin)); }
}

/* kleine telefoons (iPhone SE en kleiner) */
@media (max-width: 360px) {
  main { padding: 12px; gap: 12px; }
  .hero { padding: 18px 16px 80px; }
  .lede { font-size: 14px; }
  .brand span { font-size: 17px; }
  .topbar .me { max-width: 42vw; }
  .choices { grid-template-columns: repeat(3, 1fr); }
  .result-score span { font-size: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .confetti { display: none; }
}
