:root {
  --red: #c0392b;
  --red-dark: #962d22;
  --ochre: #d97032;
  --sand: #f4e3c8;
  --sand-deep: #e9cfa3;
  --sky: #5aa9d6;
  --sky-soft: #d6ecf7;
  --sun: #f6b93b;
  --green: #27ae60;
  --green-soft: #d6f3e0;
  --wrong: #e74c3c;
  --wrong-soft: #fbe0dd;
  --ink: #3a2a20;
  --ink-soft: #7a6555;
  --card: #fffdf8;
  --shadow: 0 6px 0 rgba(150, 45, 34, 0.18);
  --shadow-soft: 0 8px 24px rgba(120, 70, 40, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: 'Fredoka', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-soft) 0%, var(--sand) 42%, var(--sand-deep) 100%);
  background-attachment: fixed;
  min-height: 100%;
  font-size: 18px;
  line-height: 1.4;
  overflow-x: hidden;
}

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }

/* ---------- Screens ---------- */
.screen { display: none; flex-direction: column; min-height: 100vh; padding: 18px; }
.screen.active { display: flex; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow-soft);
  border: 3px solid #fff;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-size: 19px;
  font-weight: 600;
  border: none;
  border-radius: 16px;
  padding: 15px 22px;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, opacity .2s;
  width: 100%;
}
.btn:active { transform: translateY(3px); box-shadow: none !important; }
.btn-primary { background: var(--red); color: #fff; box-shadow: var(--shadow); }
.btn-primary:disabled { opacity: .4; box-shadow: none; cursor: default; }
.btn-ghost-solid { background: var(--sand-deep); color: var(--ink); box-shadow: 0 5px 0 rgba(150,45,34,.14); }
.btn-ghost {
  background: rgba(255,255,255,.6); border: none; color: var(--ink-soft);
  font-family: inherit; font-weight: 600; font-size: 16px;
  padding: 9px 14px; border-radius: 12px; cursor: pointer;
}

/* ---------- Profile screen ---------- */
.hero { text-align: center; margin: 24px 0 18px; }
.hero-dog { font-size: 76px; line-height: 1; filter: drop-shadow(0 6px 6px rgba(0,0,0,.15)); animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
.hero h1 { font-size: 40px; font-weight: 700; color: var(--red); line-height: 1; letter-spacing: -.5px; }
.hero h1 span { color: var(--ochre); font-size: 30px; }
.subtitle { color: var(--ink-soft); margin-top: 10px; font-weight: 500; }

.card h2 { font-size: 22px; margin-bottom: 14px; color: var(--ink); }
.profile-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.profile-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--sky-soft); border: 2px solid transparent;
  padding: 10px 16px; border-radius: 14px; cursor: pointer; font-weight: 600;
  transition: transform .08s;
}
.profile-chip:active { transform: scale(.96); }
.profile-chip .pdel { color: var(--ink-soft); font-size: 14px; opacity: .6; padding: 0 2px; }
.new-profile { display: flex; gap: 8px; }
.new-profile input {
  flex: 1; font-family: inherit; font-size: 18px; padding: 13px 16px;
  border: 2px solid var(--sand-deep); border-radius: 14px; background: #fff; color: var(--ink);
}
.new-profile input:focus { outline: none; border-color: var(--ochre); }
.new-profile .btn { width: auto; white-space: nowrap; }
.booknote { text-align: center; color: var(--ink-soft); font-size: 14px; margin-top: auto; padding-top: 18px; }

/* ---------- Topbar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.topbar-stats { display: flex; gap: 10px; }
.stat {
  background: var(--card); padding: 7px 13px; border-radius: 13px; font-weight: 600;
  font-size: 16px; box-shadow: 0 3px 0 rgba(150,45,34,.12);
}
.stat b { color: var(--red); }

/* ---------- Map head ---------- */
.map-head { margin-bottom: 12px; }
.map-head h2 { font-size: 26px; color: var(--red-dark); }
.map-head h2 span { color: var(--ochre); }
.progress-wrap { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.progress-bar { flex: 1; height: 16px; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: inset 0 2px 4px rgba(0,0,0,.08); }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--sun), var(--ochre)); border-radius: 10px; transition: width .6s ease; }
.progress-label { font-size: 13px; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
.badge-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.badge-mini { font-size: 22px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.12)); }
.badge-mini.locked { filter: grayscale(1) opacity(.32); }

/* ---------- Journey ---------- */
.journey { display: flex; flex-direction: column; gap: 0; position: relative; padding-left: 8px; }
.stop { display: flex; gap: 14px; align-items: stretch; position: relative; }
.stop-rail { display: flex; flex-direction: column; align-items: center; width: 34px; flex-shrink: 0; }
.stop-node {
  width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 3px solid var(--sand-deep);
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700;
  color: var(--ink-soft); z-index: 2; flex-shrink: 0;
}
.stop.done .stop-node { background: var(--green); border-color: var(--green); color: #fff; }
.stop.next .stop-node { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 0 0 5px rgba(192,57,43,.18); }
.stop-line { width: 4px; flex: 1; background: var(--sand-deep); margin: 2px 0; border-radius: 4px; }
.stop.done .stop-line { background: var(--green); }
.stop:last-child .stop-line { display: none; }

.stop-card {
  flex: 1; background: var(--card); border-radius: 16px; padding: 14px 16px; margin-bottom: 14px;
  box-shadow: 0 4px 0 rgba(150,45,34,.1); border: 2px solid #fff; cursor: pointer;
  transition: transform .08s;
}
.stop-card:active { transform: scale(.98); }
.stop.next .stop-card { border-color: var(--red); }
.stop-loc { font-size: 12px; font-weight: 600; color: var(--ochre); text-transform: uppercase; letter-spacing: .5px; }
.stop-title { font-size: 19px; font-weight: 600; color: var(--ink); margin: 1px 0 4px; }
.stop-meta { display: flex; align-items: center; justify-content: space-between; }
.stop-stars { letter-spacing: 2px; font-size: 16px; color: var(--sun); }
.stop-stars .empty { color: var(--sand-deep); }
.stop-cta { font-size: 14px; font-weight: 600; color: var(--red); }
.stop.done .stop-cta { color: var(--green); }
.stop.next-tag::after {
  content: "NEXT"; position: absolute; top: -8px; right: 10px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 8px; letter-spacing: .5px;
}
.map-foot { text-align: center; color: var(--ink-soft); font-size: 14px; margin-top: 8px; padding-bottom: 10px; }

/* ---------- Quiz ---------- */
.quiz-dots { display: flex; gap: 6px; }
.qdot { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.6); }
.qdot.cur { background: var(--red); transform: scale(1.3); }
.qdot.right { background: var(--green); }
.qdot.wrong { background: var(--wrong); }

.quiz-body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 8px 0; }
.quiz-chapter { font-size: 13px; font-weight: 600; color: var(--ochre); text-transform: uppercase; letter-spacing: 1px; text-align: center; }
.quiz-question { font-size: 24px; font-weight: 600; text-align: center; margin: 12px 0 22px; line-height: 1.3; color: var(--ink); }
.quiz-options { display: flex; flex-direction: column; gap: 12px; }
.opt {
  font-family: inherit; font-size: 18px; font-weight: 500; text-align: left;
  background: var(--card); border: 3px solid #fff; border-radius: 16px; padding: 16px 18px;
  cursor: pointer; box-shadow: 0 4px 0 rgba(150,45,34,.1); color: var(--ink);
  transition: transform .07s; display: flex; align-items: center; gap: 12px;
}
.opt .optletter {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 9px; background: var(--sand);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--ink-soft);
}
.opt:active { transform: translateY(2px); }
.opt.correct { background: var(--green-soft); border-color: var(--green); }
.opt.correct .optletter { background: var(--green); color: #fff; }
.opt.incorrect { background: var(--wrong-soft); border-color: var(--wrong); }
.opt.incorrect .optletter { background: var(--wrong); color: #fff; }
.opt.dim { opacity: .5; }
.opt:disabled { cursor: default; }

.quiz-feedback { min-height: 56px; margin-top: 16px; text-align: center; font-weight: 500; opacity: 0; transition: opacity .25s; }
.quiz-feedback.show { opacity: 1; }
.quiz-feedback .fb-head { font-size: 20px; font-weight: 700; }
.quiz-feedback.good .fb-head { color: var(--green); }
.quiz-feedback.bad .fb-head { color: var(--wrong); }
.quiz-feedback .fb-explain { font-size: 15px; color: var(--ink-soft); margin-top: 3px; }
.quiz-foot { padding-top: 8px; }

/* reflection question */
.quiz-feedback.reflect .fb-head { color: var(--ochre); }

/* ---------- Results ---------- */
#screen-results { justify-content: center; text-align: center; }
.results-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.results-dog { font-size: 84px; animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
#results-title { font-size: 30px; color: var(--red-dark); }
.results-stars { font-size: 52px; letter-spacing: 6px; color: var(--sun); margin: 4px 0; min-height: 56px; }
.results-stars .empty { color: var(--sand-deep); }
.results-score { font-size: 20px; font-weight: 600; }
.results-points { font-size: 22px; font-weight: 700; color: var(--ochre); }
.results-badges { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.badge-won {
  background: var(--sun); color: var(--ink); font-weight: 600; padding: 10px 18px; border-radius: 14px;
  box-shadow: var(--shadow-soft); animation: pop .5s ease; font-size: 16px;
}
.results-msg { color: var(--ink-soft); font-weight: 500; max-width: 380px; }
.results-foot { display: flex; gap: 10px; padding-top: 10px; }
.results-foot .btn { flex: 1; }

/* ---------- Confetti ---------- */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; display: none; }
#confetti.go { display: block; }

@media (max-width: 380px) {
  body { font-size: 17px; }
  .hero h1 { font-size: 34px; }
  .quiz-question { font-size: 21px; }
}
