/* Visual language lifted unchanged from the original prototype — see DESIGN.md.
   London transport palette: tube blue, bus red, Big Ben gold, paper cream. */
:root {
  --tube-blue: #1D3A8F;
  --bus-red: #E1251B;
  --ben-gold: #FFD23F;
  --paper: #F6F1E5;
  --ink: #17224D;
  --stamp-green: #1E8A5A;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Deliberately light-only. A four-year-old's sticker board should not invert
   itself because the phone hit sunset, and the stamp/paper metaphor depends on
   the cream ground. Hence the fixed background and color-scheme: light. */
html { background: #1D3A8F; color-scheme: light; }
body {
  font-family: 'Fredoka', 'Comic Sans MS', 'Trebuchet MS', sans-serif;
  background: #1D3A8F;
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  padding-top: env(safe-area-inset-top);
}

header { text-align: center; padding: 22px 16px 8px; color: #fff; }
header h1 { font-weight: 700; font-size: 1.45rem; letter-spacing: 0.5px; }
header .sub { color: var(--ben-gold); font-weight: 600; font-size: 0.95rem; margin-top: 2px; }

.road-wrap { margin: 14px 16px 4px; position: relative; height: 64px; }
.road { position: absolute; bottom: 10px; left: 0; right: 0; height: 14px; background: #3A4668; border-radius: 7px; overflow: hidden; }
.road .dashes { position: absolute; top: 5px; left: 0; right: 0; height: 4px; background: repeating-linear-gradient(90deg, var(--ben-gold) 0 14px, transparent 14px 28px); opacity: 0.9; }
.bus { position: absolute; bottom: 14px; left: 0; font-size: 38px; transform: translateX(-6px) scaleX(-1); transition: left 0.9s cubic-bezier(.5,1.5,.5,1); filter: drop-shadow(0 3px 3px rgba(0,0,0,0.35)); }
.flag { position: absolute; right: 0; bottom: 20px; font-size: 26px; }
.progress-label { text-align: center; color: #fff; font-weight: 600; font-size: 0.9rem; margin-bottom: 12px; opacity: 0.95; }

.degraded {
  display: none; margin: 0 16px 12px; padding: 10px 12px; border-radius: 12px;
  background: var(--bus-red); color: #fff; font-weight: 600; font-size: 0.82rem; text-align: center;
}
.degraded.show { display: block; }

.missions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 4px 16px; }
.mission {
  background: var(--paper);
  border: none;
  border-radius: 18px;
  padding: 14px 10px 12px;
  text-align: center;
  box-shadow: 0 4px 0 rgba(0,0,0,0.28);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.1s;
  font-family: inherit;
  min-height: 128px;
}
.mission:active { transform: scale(0.96) translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,0.28); }
.mission:focus-visible { outline: 4px solid var(--ben-gold); outline-offset: 2px; }
.mission .emoji { font-size: 44px; display: block; margin-bottom: 6px; filter: grayscale(0.85) opacity(0.55); }
.mission .name { font-weight: 600; font-size: 0.92rem; line-height: 1.2; color: var(--ink); }
.mission .day-tag { display: inline-block; margin-top: 6px; font-size: 0.68rem; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: rgba(29,58,143,0.12); color: var(--tube-blue); }
.mission .hint { display: block; margin-top: 4px; font-size: 0.66rem; font-weight: 600; color: rgba(23,34,77,0.5); }

/* Stamped: the photo fills the tile and the mission name drops to a caption. */
.mission.done { padding: 0; }
.mission.done .photo { position: absolute; inset: 0; background-size: cover; background-position: center; }
.mission.done .caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.72));
  color: #fff; font-weight: 600; font-size: 0.8rem;
  padding: 18px 6px 6px;
}
.stamp { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; opacity: 0; }
.mission.done .stamp { opacity: 1; }
.stamp span {
  border: 4px solid var(--stamp-green); color: var(--stamp-green);
  border-radius: 12px; font-weight: 700; font-size: 1rem; letter-spacing: 1px;
  padding: 3px 10px; background: rgba(255,255,255,0.78); text-transform: uppercase;
  transform: rotate(var(--tilt));
}
.mission.done.just-stamped .stamp span { animation: slam 0.45s cubic-bezier(.2,2.2,.4,1) both; }
@keyframes slam {
  0% { transform: scale(3) rotate(0deg); opacity: 0; }
  60% { transform: scale(0.92) rotate(var(--tilt)); opacity: 1; }
  100% { transform: scale(1) rotate(var(--tilt)); opacity: 1; }
}

.finish { display: none; margin: 18px 16px 0; background: var(--ben-gold); border-radius: 20px; padding: 20px; text-align: center; box-shadow: 0 5px 0 rgba(0,0,0,0.3); }
.finish.show { display: block; animation: pop 0.5s cubic-bezier(.2,2,.4,1); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.finish h2 { font-size: 1.4rem; font-weight: 700; }
.finish p { font-weight: 600; margin-top: 4px; }
.finish .medal { font-size: 56px; display: block; margin-bottom: 6px; }

.reset { display: block; margin: 26px auto 0; background: none; border: none; color: rgba(255,255,255,0.45); font-family: inherit; font-size: 0.75rem; text-decoration: underline; cursor: pointer; }

.confetti-bit { position: fixed; top: -20px; font-size: 22px; animation: fall linear forwards; pointer-events: none; z-index: 99; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.viewer {
  position: fixed; inset: 0; background: rgba(10,15,40,0.92);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.viewer.show { display: flex; }
.viewer img { max-width: 100%; max-height: 58vh; border-radius: 16px; border: 4px solid #fff; }
.viewer .vtitle { color: #fff; font-weight: 700; font-size: 1.2rem; margin: 14px 0 16px; text-align: center; }
.viewer .vbtns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.viewer button { font-family: inherit; font-weight: 600; font-size: 0.95rem; border: none; border-radius: 14px; padding: 12px 18px; cursor: pointer; }
.vb-retake { background: var(--ben-gold); color: var(--ink); }
.vb-remove { background: var(--bus-red); color: #fff; }
.vb-close  { background: rgba(255,255,255,0.2); color: #fff; }

.saving {
  position: fixed; inset: 0; background: rgba(10,15,40,0.85);
  display: none; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1.3rem; z-index: 60;
}
.saving.show { display: flex; }

@media (prefers-reduced-motion: reduce) {
  .bus { transition: none; }
  .mission.done.just-stamped .stamp span { animation: none; }
  .finish.show { animation: none; }
  .confetti-bit { display: none; }
}
