/* Morocco Explorer shell — mobile-first, portrait, offline-first. */

@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('../fonts/fraunces-900-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Mulish';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/mulish-latin.woff2') format('woff2');
}

:root {
  --red: #C8402A;
  --red-deep: #9E2F1C;
  --green: #2F7D4F;
  --green-deep: #1E5E3A;
  --gold: #E7A93B;
  --sand: #F6E3BE;
  --cream: #FBF2DD;
  --ink: #3B2415;
  --ink-soft: #7A5C46;
  --sky: #7FBEDD;
  --shadow: 0 16px 44px rgba(59, 36, 21, .18);
  --shadow-sm: 0 8px 22px rgba(59, 36, 21, .13);
  --nav-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Mulish', system-ui, sans-serif;
  font-weight: 600;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
body.dyslexia, body.dyslexia button, body.dyslexia input {
  font-family: 'Comic Sans MS', 'Comic Neue', Verdana, system-ui, sans-serif;
  letter-spacing: .02em;
}
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; font-weight: 900; line-height: 1.1; }
body.dyslexia h1, body.dyslexia h2, body.dyslexia h3 { font-family: 'Comic Sans MS', 'Comic Neue', Verdana, sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
button, .navbtn, .stop-cta { min-height: 48px; min-width: 48px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 8px; }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* ---------- splash / loading ---------- */
#splash {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; text-align: center;
  background: linear-gradient(160deg, var(--red), var(--red-deep));
  color: var(--cream); transition: opacity .4s;
}
#splash.hide { opacity: 0; pointer-events: none; }
#splash img { width: 96px; height: 96px; border-radius: 24px; box-shadow: var(--shadow); }
#splash h1 { font-size: 1.8rem; margin: 14px 0 4px; }
#splash p { font-weight: 700; opacity: .85; }

/* ---------- shared bits ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font-family: 'Fraunces', Georgia, serif; font-weight: 900; font-size: 1rem;
  padding: .7em 1.4em; border-radius: 999px; transition: transform .15s;
}
.btn:active { transform: scale(.97); }
.btn-red { background: var(--red); color: #fff; box-shadow: 0 8px 20px rgba(200, 64, 42, .4); }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 8px 20px rgba(47, 125, 79, .38); }
.btn-gold { background: var(--gold); color: var(--ink); box-shadow: 0 8px 20px rgba(231, 169, 59, .5); }
.btn-ghost { background: rgba(255, 255, 255, .85); color: var(--ink); box-shadow: var(--shadow-sm); }
.chip {
  display: inline-flex; align-items: center; gap: .35em;
  font-size: .78rem; font-weight: 800; letter-spacing: .03em;
  background: rgba(255, 255, 255, .85); color: var(--ink-soft);
  border-radius: 999px; padding: .3em .9em;
}
.eyebrow {
  font-weight: 800; letter-spacing: .16em; text-transform: uppercase;
  font-size: .72rem; color: var(--gold);
}

/* ---------- map / journey ---------- */
.hero {
  background: linear-gradient(160deg, var(--green), var(--green-deep));
  color: #fff; text-align: center; padding: 26px 0 56px;
  border-radius: 0 0 32px 32px;
}
.hero h1 { font-size: clamp(1.9rem, 7vw, 2.6rem); margin: 4px 0 6px; }
.hero p { font-weight: 700; opacity: .92; max-width: 420px; margin: 0 auto; padding: 0 18px; }

.plane-card {
  background: #fff; border-radius: 20px; box-shadow: var(--shadow);
  margin: -36px auto 20px; padding: 16px 18px; position: relative;
}
.plane-card h2 { font-size: 1.15rem; color: var(--red); }
.plane-card p { font-size: .9rem; color: var(--ink-soft); margin: 2px 0 10px; }
.plane-status { font-size: .84rem; font-weight: 800; color: var(--green-deep); margin-top: 8px; min-height: 1.2em; }

.journey { list-style: none; position: relative; margin: 6px 0 30px; }
.journey::before {
  content: ''; position: absolute; left: 31px; top: 30px; bottom: 30px;
  border-left: 3px dashed rgba(122, 92, 70, .35);
}
.stop-card {
  position: relative; display: flex; align-items: center; gap: 12px;
  background: #fff; border-radius: 18px; box-shadow: var(--shadow-sm);
  padding: 12px 14px; margin-bottom: 12px; width: 100%; text-align: left;
}
.stop-card .dot {
  flex: none; width: 54px; height: 54px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.5rem;
  color: #fff; position: relative; z-index: 1;
  /* dark halo so emoji stay legible on same-hue dots (the Agadir teapot
     vanished into the sunset gradient on Android) */
  text-shadow: 0 0 3px rgba(30, 10, 5, .6), 0 1px 2px rgba(30, 10, 5, .5);
}
.stop-card .meta { flex: 1; min-width: 0; }
.stop-card .city { font-family: 'Fraunces', Georgia, serif; font-weight: 900; font-size: 1.02rem; }
.stop-card .line { font-size: .8rem; color: var(--ink-soft); }
.stop-card .state { flex: none; text-align: right; font-size: .78rem; font-weight: 800; }
.stop-card .state .stars { color: var(--gold); font-size: .95rem; letter-spacing: .05em; display: block; }
.stop-card .state .go { color: var(--red); }
.stop-card .state .packing { color: var(--ink-soft); opacity: .8; }
.stop-card .state .ready { color: var(--green); display: block; font-size: .72rem; }
.stop-card.next { outline: 3px solid var(--gold); }
.next-pill {
  position: absolute; top: -10px; right: 12px;
  background: var(--gold); color: var(--ink); font-size: .68rem; font-weight: 800;
  letter-spacing: .06em; text-transform: uppercase; border-radius: 999px; padding: .25em .8em;
}
.map-foot { text-align: center; font-size: .8rem; color: var(--ink-soft); padding: 0 20px 26px; }

/* ---------- stop screen ---------- */
.stop-hero { color: #fff; padding: 14px 0 20px; border-radius: 0 0 28px 28px; }
.stop-hero .bar { display: flex; align-items: center; gap: 8px; }
.backbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(0, 0, 0, .22); color: #fff; font-size: 1.3rem;
}
.stop-hero .titles { flex: 1; min-width: 0; }
.stop-hero h1 { font-size: 1.35rem; }
.stop-hero .tag { font-size: .8rem; font-weight: 800; opacity: .9; }
.stop-hero .scene { text-align: center; padding: 8px 0 0; }
.stop-hero .scene .big { font-size: 4rem; display: block; filter: drop-shadow(0 6px 10px rgba(0,0,0,.25)); text-shadow: 0 0 6px rgba(30, 10, 5, .45); }
.stop-hero .who { font-size: .85rem; font-weight: 700; opacity: .95; padding: 0 20px; }

.gamebox { background: #fff; border-radius: 22px; box-shadow: var(--shadow); margin: 16px 0; padding: 20px 18px; min-height: 260px; }
.packing { text-align: center; padding: 18px 6px; }
.packing-emoji { font-size: 3.4rem; }
.packing h2 { color: var(--red); margin: 6px 0 2px; }
.packing-song { color: var(--green-deep); font-weight: 800; font-size: .9rem; margin-bottom: 10px; }
.packing p { color: var(--ink-soft); font-size: .95rem; }
.packing-suitcase { font-size: 2.2rem; margin-top: 14px; animation: bob 2.2s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }

.stop-download { display: flex; align-items: center; gap: 10px; justify-content: center; font-size: .85rem; font-weight: 800; color: var(--ink-soft); padding-bottom: 20px; }

/* full-track music (GAMES_SPEC v3) */
.music-row { display: flex; justify-content: center; margin-top: 14px; }
.music-btn { font-size: .95rem; }
.start-scrim {
  position: absolute; inset: 0; z-index: 5; border-radius: 22px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(59, 36, 21, .55); color: #fff;
  font-family: 'Fraunces', Georgia, serif; font-weight: 900; font-size: 1.05rem;
  cursor: pointer; text-align: center; padding: 20px; width: 100%;
}
.start-scrim .big {
  width: 74px; height: 74px; border-radius: 50%; background: var(--gold); color: var(--ink);
  display: grid; place-items: center; font-size: 1.9rem; box-shadow: 0 10px 26px rgba(0, 0, 0, .35);
}
.start-scrim .sub { font-family: 'Mulish', system-ui, sans-serif; font-weight: 700; font-size: .85rem; opacity: .95; }
.music-float {
  position: absolute; top: 10px; right: 10px; z-index: 6;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--gold); font-size: 1.45rem;
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(59, 36, 21, .35);
  transition: transform .12s;
}
.music-float:active { transform: scale(.92); }
.music-float.muted { background: #d8c7a6; }

/* ---------- passport ---------- */
.ppwrap { padding-top: 20px; }
.ppbook { position: relative; perspective: 1600px; margin-bottom: 20px; }
.pp-inside { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 18px; min-height: 300px; }
.pp-cover {
  position: absolute; inset: 0; z-index: 2; border-radius: 20px;
  background: linear-gradient(150deg, #7a1622, #4c0d15); color: #E8C879;
  display: flex; align-items: center; justify-content: center; text-align: center;
  cursor: pointer; transform-origin: left center;
  transition: transform .9s cubic-bezier(.2, .7, .2, 1);
  backface-visibility: hidden; box-shadow: 0 16px 44px rgba(40, 8, 12, .45);
  border: none; width: 100%;
}
.ppbook.open .pp-cover { transform: rotateY(-160deg); pointer-events: none; }
.pp-cover .ppframe {
  border: 2px solid rgba(232, 200, 121, .55); border-radius: 14px;
  margin: 14px; padding: 18px; width: calc(100% - 28px);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.pp-cover .ar { font-size: 1.1rem; font-weight: 700; direction: rtl; }
.pp-cover .fr { font-size: .64rem; letter-spacing: .1em; opacity: .9; }
.pp-cover .ttl { font-family: 'Fraunces', Georgia, serif; font-weight: 900; font-size: 1.5rem; color: #F0D58A; }
.pp-cover svg { width: 56px; height: 56px; }
.pp-cover .openhint { margin-top: 8px; font-weight: 800; font-size: .75rem; background: rgba(232, 200, 121, .16); padding: .4em 1em; border-radius: 999px; }
.pp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.pp-head h2 { color: var(--red); font-size: 1.2rem; }
.pp-count { font-family: 'Fraunces', Georgia, serif; font-weight: 900; color: var(--green-deep); }
.pbar { height: 12px; border-radius: 999px; background: #eaddc4; overflow: hidden; margin: 8px 0 14px; }
.pbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width .5s; }
.visas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.visa {
  border: 2px dashed #d8c7a6; border-radius: 14px; padding: 10px 6px;
  text-align: center; min-height: 92px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
  cursor: pointer; transition: transform .12s;
}
.visa:active { transform: scale(.95); }
.visa .em { font-size: 1.5rem; filter: grayscale(1); opacity: .45; }
.visa .nm { font-size: .66rem; font-weight: 800; color: var(--ink-soft); line-height: 1.2; }
.visa .stars { color: var(--gold); font-size: .8rem; letter-spacing: .05em; }
.visa .dt { font-size: .58rem; color: var(--ink-soft); }
.visa.on { border: 2px solid var(--green); background: rgba(47, 125, 79, .08); transform: rotate(-1.5deg); }
.visa.on .em { filter: none; opacity: 1; }
.pigeon-strip { margin-top: 16px; background: rgba(127, 190, 221, .16); border-radius: 14px; padding: 12px; text-align: center; }
.pigeon-strip .slots { font-size: 1.05rem; letter-spacing: .12em; margin-top: 4px; }
.pigeon-strip p { font-size: .78rem; color: var(--ink-soft); font-weight: 700; }
.cert-card { margin-top: 16px; background: linear-gradient(150deg, var(--gold), #d3902c); border-radius: 16px; padding: 16px; text-align: center; }
.cert-card h3 { font-size: 1.1rem; }
.cert-card input {
  border: none; border-radius: 999px; padding: .7em 1.1em; margin: 8px 0;
  font-family: inherit; font-weight: 700; width: 100%; max-width: 260px;
}

/* ---------- settings / more ---------- */
.panel { background: #fff; border-radius: 20px; box-shadow: var(--shadow-sm); padding: 18px; margin: 16px 0; }
.panel h2 { color: var(--red); font-size: 1.15rem; margin-bottom: 10px; }
.panel p.note { font-size: .84rem; color: var(--ink-soft); }
.tiertog { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tiertog button {
  font-family: 'Fraunces', Georgia, serif; font-weight: 900; color: #fff;
  padding: .9em .6em; border-radius: 16px; font-size: .98rem; opacity: .75; transition: .18s;
}
.tiertog .t-little { background: linear-gradient(135deg, #3a9c63, var(--green-deep)); }
.tiertog .t-big { background: linear-gradient(135deg, #e0612f, var(--red-deep)); }
.tiertog button.active { opacity: 1; outline: 4px solid var(--gold); outline-offset: 2px; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.setrow .lab { font-weight: 800; }
.setrow .sub { display: block; font-size: .78rem; color: var(--ink-soft); font-weight: 600; }
.switch { position: relative; width: 58px; height: 34px; border-radius: 999px; background: #d8c7a6; transition: background .2s; flex: none; }
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 28px; height: 28px;
  border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.switch.on { background: var(--green); }
.switch.on::after { left: 27px; }
.shelf-card { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: 18px; box-shadow: var(--shadow-sm); padding: 14px 16px; margin-bottom: 12px; }
.shelf-card .em { font-size: 1.9rem; }
.shelf-card .meta { flex: 1; }
.shelf-card h3 { font-size: 1rem; }
.shelf-card p { font-size: .8rem; color: var(--ink-soft); }
.danger { color: var(--red-deep); font-weight: 800; font-size: .88rem; padding: 10px 0; }

/* ---------- bottom nav ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #fff; box-shadow: 0 -6px 24px rgba(59, 36, 21, .14);
  display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; font-size: .66rem; font-weight: 800; color: var(--ink-soft);
}
nav.tabs a .ic { font-size: 1.35rem; }
nav.tabs a.active { color: var(--red); }

/* ---------- modals & celebration ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 40; background: rgba(59, 36, 21, .55);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  background: var(--cream); border-radius: 24px; box-shadow: var(--shadow);
  padding: 22px 20px; width: 100%; max-width: 420px; text-align: center;
  max-height: 86vh; overflow-y: auto;
}
.modal h2 { color: var(--red); margin-bottom: 6px; }
.modal p { color: var(--ink-soft); font-size: .95rem; margin-bottom: 14px; }
.modal .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.celebrate-stars { font-size: 2.4rem; letter-spacing: .1em; color: var(--gold); margin: 6px 0; }
.kform { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; text-align: left; }
.kform input[type=email] { border: 1.5px solid #e4d6bd; border-radius: 999px; padding: .8em 1.1em; font: inherit; }
.kform .consent { display: flex; gap: .5em; align-items: flex-start; font-size: .74rem; }
.kform .consent input { margin-top: .25em; width: 18px; height: 18px; }
.kthanks { background: rgba(47, 125, 79, .12); border-radius: 12px; padding: 12px; font-weight: 800; color: var(--green-deep); }

.confetti { position: fixed; top: -12px; width: 10px; height: 14px; z-index: 60; pointer-events: none; border-radius: 2px; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .9; } }

/* ---------- shared win celebration (celebrate.js) ---------- */
.win-back {
  position: fixed; inset: 0; z-index: 55; display: grid; place-items: center;
  padding: 20px; background: rgba(59, 36, 21, 0);
  opacity: 0; transition: opacity .28s ease, background .28s ease;
  pointer-events: none;
}
.win-back.show { opacity: 1; background: rgba(59, 36, 21, .62); pointer-events: auto; }
.win-burst { position: absolute; left: 50%; top: 42%; width: 0; height: 0; pointer-events: none; z-index: 1; }
.win-spark {
  position: absolute; left: 0; top: 0; width: 11px; height: 15px; border-radius: 2px;
  transform: translate(-50%, -50%); animation: win-fly 1.1s cubic-bezier(.15,.7,.3,1) forwards;
}
@keyframes win-fly {
  0%   { transform: translate(-50%, -50%) scale(.4); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(1); opacity: 0; }
}
.win-card {
  position: relative; z-index: 2; background: var(--cream); border-radius: 26px;
  box-shadow: var(--shadow); padding: 26px 22px; width: 100%; max-width: 400px;
  text-align: center; max-height: 88vh; overflow-y: auto;
  transform: scale(.92); transition: transform .3s cubic-bezier(.2,1.3,.4,1);
}
.win-back.show .win-card { transform: scale(1); }
.win-title {
  color: var(--red); font-size: 2.1rem; line-height: 1.05; margin: 2px 0 10px;
  opacity: 0; transform: translateY(10px) scale(.9); transition: opacity .3s ease, transform .3s cubic-bezier(.2,1.4,.4,1);
}
.win-title.in { opacity: 1; transform: none; }
.win-stars { display: flex; justify-content: center; gap: 10px; margin: 6px 0 4px; }
.win-star {
  font-size: 2.9rem; line-height: 1; color: var(--gold); display: inline-block;
  opacity: 0; transform: scale(0) rotate(-40deg); transform-origin: 50% 60%;
  /* a TRANSITION, not a keyframe animation: the landed state is a real applied
   * property, so an earned star is visible even if the transition never
   * visually runs (hidden tab, reduced motion). The overshoot easing is the
   * "pop". */
  transition: opacity .32s ease, transform .5s cubic-bezier(.2, 1.5, .4, 1);
}
.win-star.empty { opacity: .22; transform: none; color: #C9B78E; }
.win-star.land { opacity: 1; transform: none; }
.win-reward {
  margin: 14px 0 4px; max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height .4s ease, opacity .4s ease, margin .4s ease;
}
.win-card.rewarded .win-reward { max-height: 460px; opacity: 1; }
.win-reward-img {
  width: 100%; max-width: 240px; border-radius: 16px; display: block; margin: 0 auto 10px;
  box-shadow: 0 8px 22px rgba(59, 36, 21, .28); border: 3px solid #fff;
}
.win-fact { color: var(--ink); font-size: .92rem; line-height: 1.35; }
.win-fact strong { display: block; color: var(--green-deep); font-size: 1rem; margin-bottom: 3px; }
.win-go {
  margin-top: 16px; opacity: 0; transform: translateY(8px);
  transition: opacity .3s ease .05s, transform .3s ease .05s;
}
.win-card.rewarded .win-go { opacity: 1; transform: none; }

/* ---------- motion & a11y ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (min-width: 700px) {
  .wrap { max-width: 640px; }
  .visas { grid-template-columns: repeat(4, 1fr); }
}
/* narrow phones: give embedded games every pixel we can */
@media (max-width: 400px) {
  .wrap { padding: 0 10px; }
  .gamebox { padding: 12px 8px; }
}
