/* Coco's French Quest — "Affiche" style: a 1930s French travel poster.
   One committed look: sand paper, navy ink, poster red, mustard gold, cream. */
:root {
  --navy: #1f3a5f;
  --navy-deep: #13263f;
  --red: #d9443a;
  --red-deep: #a8302a;
  --mustard: #efc456;
  --gold: #e2a63b;
  --cream: #fffaf0;
  --sand: #f6e4b3;
  --paper: #f3e2bb;
  --muted: #5d6a7d;
  --line: #e2cf9f;
  --display: 'Bricolage Grotesque', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Instrument Sans', 'Segoe UI', system-ui, sans-serif;
  --radius: 16px;
  --shadow: 0 4px 0 var(--navy);
  /* Sky palette (changes with the player's local time, see data-sky below) */
  --ray-a: var(--mustard); --ray-b: var(--sand);
  --sky-fade: 243, 226, 187;
  --cloud: var(--cream); --cloud-shade: #e9dcc0; --city: var(--navy-deep);
  --sun: #f7d27a;
  color-scheme: light;
}
:root[data-sky="dawn"] { --ray-a: #f2b49c; --ray-b: #fbe2cf; --sky-fade: 251, 226, 207; --cloud: #fff3ea; --cloud-shade: #f1cdbd; --sun: #f9c98a; }
:root[data-sky="dusk"] { --ray-a: #e8875d; --ray-b: #f6c590; --sky-fade: 246, 197, 144; --cloud: #fbdcb8; --cloud-shade: #e6a77f; --sun: #f06b3f; }
:root[data-sky="night"] { --ray-a: #1a3152; --ray-b: #223d63; --sky-fade: 26, 49, 82; --cloud: #3a5379; --cloud-shade: #2b4266; --city: #08121f; }
/* Night/dusk extras in the scene */
.s-stars, .s-moon, .s-sun, .s-window, .e-glow { opacity: 0; transition: opacity 1.2s ease; }
.s-stars circle, .s-twinkle { fill: #fff7dd; }
.s-twinkle { animation: twinkle 3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes twinkle { 50% { opacity: .2; transform: scale(.5); } }
.s-moon { fill: #fff3cf; }
.s-sun { fill: var(--sun); }
.s-window { fill: #ffd36b; }
.e-glow { fill: url(#flameGlow); }
:root[data-sky="night"] .s-stars, :root[data-sky="night"] .s-moon, :root[data-sky="night"] .s-window { opacity: 1; }
:root[data-sky="night"] .e-glow { opacity: 1; }
:root[data-sky="night"] .backdrop::after { opacity: .25; }
:root[data-sky="dusk"] .s-sun, :root[data-sky="dawn"] .s-sun { opacity: 1; }
:root[data-sky="dusk"] .s-window { opacity: .7; }
:root[data-sky="dusk"] .s-stars { opacity: .35; }
:root[data-sky="dusk"] .e-glow { opacity: .5; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.5 var(--body);
  color: var(--navy-deep);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  background-color: rgb(var(--sky-fade));
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .1 0 0 0 .11 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    radial-gradient(120% 80% at 50% 0%, #f8ecca 0%, transparent 60%);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h2, h3 { margin: 0 0 6px; font-family: var(--display); letter-spacing: -.005em; }
h2 { font-weight: 800; font-size: 1.5rem; line-height: 1.1; text-wrap: balance; }
h3 { font-weight: 800; font-size: 1.02rem; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }

/* ---------- Icons ---------- */
.ic { width: 100%; height: 100%; display: block; overflow: visible; }
.i-main { fill: var(--navy); }
.i-accent { fill: var(--red); }
.i-gold { fill: var(--mustard); }
.i-light { fill: var(--cream); }
.i-basket { fill: #b97b1d; }
.i-line { fill: none; stroke: var(--navy); stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; }
.i-accent-line { fill: none; stroke: var(--red); stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; }
.i-light-line { fill: none; stroke: var(--cream); stroke-width: 4.5; stroke-linecap: round; }
.i-pretzel { fill: none; stroke: #b97b1d; stroke-width: 8; stroke-linecap: round; }
.i-waffle { fill: none; stroke: #b97b1d; stroke-width: 3.5; }
.i-baguette-cut { fill: none; stroke: #b97b1d; stroke-width: 3.5; stroke-linecap: round; }
.i-gold-line { fill: none; stroke: var(--mustard); stroke-width: 3; stroke-linecap: round; }
.i-brown-line { fill: none; stroke: #b97b1d; stroke-width: 2.5; stroke-linecap: round; }
.i-line-light { fill: none; stroke: var(--cream); stroke-width: 2; }
.i-vein { fill: none; stroke: var(--red-deep); stroke-width: 2.5; stroke-linecap: round; }
.i-tail-light { fill: none; stroke: var(--cream); stroke-width: 7; stroke-linecap: round; }
.i-tail { fill: none; stroke: var(--navy); stroke-width: 7; stroke-dasharray: 5 5; }
.i-text { font: 800 26px var(--display); fill: var(--navy); }
.i-text-xs { font-size: 12px; letter-spacing: .08em; }
.i-text-xxs { font-size: 8.5px; letter-spacing: .06em; }
.i-text-sm { font-size: 19px; }
.i-text-light { fill: var(--cream); }
.i-text-gold { fill: var(--mustard); }
.medal.locked { filter: grayscale(1); opacity: .45; }
[data-icon] { display: inline-block; }

/* ---------- Backdrop: the whole app lives in a poster sky ---------- */
.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background: repeating-conic-gradient(from -4deg at 50% 100%, var(--ray-a) 0 9deg, var(--ray-b) 9deg 18deg); }
.backdrop::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(90% 55% at 50% 100%, transparent 40%, rgba(var(--sky-fade), .45) 100%); }
.backdrop .m-sky { position: absolute; inset: 0; width: 100%; height: 100%; }
.balloon-layer { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.balloon-layer .m-balloon { position: absolute; left: 0; top: 0; height: 300px; width: auto; aspect-ratio: 320 / 462;
  overflow: visible; transform-origin: 50% 0; will-change: transform; visibility: hidden; }

/* ---------- Layout ---------- */
.app { position: relative; z-index: 2; max-width: 560px; margin: 0 auto; padding: 10px 16px 120px; }
.topbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 5; padding: 8px 0 14px; }
.topbar::before { content: ''; position: absolute; z-index: -1; top: 0; bottom: 0; left: -16px; right: -16px;
  background: linear-gradient(rgba(var(--sky-fade), .97) 72%, rgba(var(--sky-fade), 0)); }
.level-chip { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--cream); border: 2.5px solid var(--navy); border-radius: var(--radius); padding: 6px 12px 6px 6px; box-shadow: var(--shadow); }
.level-num { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px;
  background: var(--red); color: var(--cream); font: 800 1.35rem/1 var(--display); }
.level-meta { flex: 1; display: grid; gap: 3px; min-width: 0; }
.rank { font: 800 .98rem/1.1 var(--display); }
.xpbar { height: 10px; background: var(--sand); border-radius: 99px; overflow: hidden; border: 2px solid var(--navy); }
.xpfill { display: block; height: 100%; width: 0; background: var(--navy); transition: width .8s cubic-bezier(.2, .9, .3, 1.2); }
.xptext { font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.streak { display: flex; align-items: center; gap: 3px; font: 800 1.2rem/1 var(--display);
  background: var(--cream); border: 2.5px solid var(--navy); border-radius: var(--radius); padding: 0 11px 0 7px; height: 56px; box-shadow: var(--shadow); }
.streak .flame { width: 28px; height: 28px; animation: flicker 1.3s ease-in-out infinite; transform-origin: 50% 90%; }
.streak.cold .flame { filter: grayscale(1); opacity: .5; animation: none; }
@keyframes flicker { 50% { transform: scale(1.1, 1.16) rotate(-4deg); } }
.icon-btn { width: 50px; height: 56px; flex: none; display: grid; place-items: center; padding: 11px;
  border-radius: var(--radius); border: 2.5px solid var(--navy); background: var(--cream); box-shadow: var(--shadow); }
.icon-btn > *, .icon-btn span { width: 26px; height: 26px; }
.icon-btn:active, .level-chip:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--navy); }

.tab { display: none; animation: tabIn .3s ease; }
.tab.active { display: block; }
@keyframes tabIn { from { opacity: 0; transform: translateY(6px); } }

.card { background: var(--cream); border: 2.5px solid var(--navy); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.cards { display: grid; margin-top: 16px; }
.intro-card p { margin: 4px 0; color: var(--muted); }
.intro-card .tour { color: var(--red-deep); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Open sky on the Focus tab (the balloon floats here) ---------- */
.poster { position: relative; height: clamp(250px, 36vh, 400px); cursor: pointer; border-radius: 20px; --balloon-top: 62; --balloon-cx: .5; }
.poster:focus-visible { outline-offset: -3px; }
.ticket { background: var(--cream); border: 2.5px solid var(--navy); border-radius: 20px; box-shadow: 0 5px 0 var(--navy); padding: 16px 14px 18px; }
.bubble { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 2; text-align: center;
  background: var(--cream); border: 2.5px solid var(--navy); border-radius: 14px; padding: 6px 14px 7px;
  width: max-content; max-width: calc(100% - 28px); box-shadow: 0 3px 0 var(--navy); }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -9px; width: 14px; height: 14px; background: var(--cream);
  border-right: 2.5px solid var(--navy); border-bottom: 2.5px solid var(--navy); transform: translateX(-50%) rotate(45deg); }
.bubble b { display: block; font: 800 1rem/1.25 var(--display); }
.bubble small { color: var(--muted); font-size: .85rem; }
.bubble.pop { animation: pop .4s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
@keyframes popSide { from { transform: scale(.6); opacity: 0; } }

/* Scene + balloon artwork */
.grain { filter: url(#grainA); }
.s-cloud { fill: var(--cloud); } .s-cloud-shade { fill: var(--cloud-shade); }
.s-ground { fill: var(--navy); } .s-city { fill: var(--city); } .s-sparkle { fill: var(--cream); }
.s-cloud, .s-cloud-shade, .s-city { transition: fill 1.2s ease; }
.e-navy { fill: var(--navy); } .e-gore { fill: none; stroke: var(--navy-deep); stroke-width: 2.5; opacity: .7; }
.e-band { fill: var(--mustard); } .e-red { fill: var(--red); } .e-star { fill: var(--mustard); }
.e-shade { fill: url(#dotsDark); } .e-light { fill: var(--cream); opacity: .12; }
.e-skirt { fill: var(--red); } .e-rope { fill: none; stroke: var(--navy-deep); stroke-width: 2; }
.e-burner { fill: var(--navy-deep); }
.e-flame-out { fill: var(--red); } .e-flame-in { fill: var(--mustard); } .e-flame-core { fill: var(--cream); }
.m-balloon.is-out .e-flame-out { fill: #5d7fae; } .m-balloon.is-out .e-flame-in { fill: #a9c4e6; } .m-balloon.is-out .e-flame-core { fill: #e9f2fb; }
.e-basket { fill: #b97b1d; } .e-rim { fill: #8e5c14; } .e-weave { fill: none; stroke: #8e5c14; stroke-width: 2; opacity: .8; }
.coco .r-happy, .coco .r-book, .coco .r-tear { display: none; }
.coco.is-happy .r-happy { display: inline; }
.coco.is-happy .r-eye { display: none; }
.coco.is-focus .r-book, .coco.is-sad .r-tear { display: inline; }
.c-foot, .c-brow, .c-band, .c-stem, .c-happy-line, .c-page-line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.c-body, .c-wing { fill: var(--cream); }
.c-shade { fill: url(#dotsA); } .c-wing-shade { fill: url(#dotsA); opacity: .8; }
.c-belly { fill: #f4ddb2; }
.c-beret { fill: var(--navy); } .c-band { stroke: #2f5285; stroke-width: 3; } .c-stem { stroke: var(--navy); stroke-width: 4; }
.c-scarf, .c-comb, .c-wattle, .c-tail3 { fill: var(--red); }
.c-tail1 { fill: var(--navy); } .c-tail2 { fill: var(--cream); }
.c-beak { fill: var(--gold); } .c-beak-low { fill: #b97b1d; }
.c-sclera { fill: #fff; } .c-pupil { fill: var(--navy); } .c-glint { fill: #fff; }
.c-brow, .c-happy-line { stroke: var(--navy); stroke-width: 4; }
.c-cheek { fill: #f08f7f; opacity: .55; }
.c-tear { fill: #5fa8e6; }
.c-book-cover { fill: var(--red); } .c-book-page { fill: var(--cream); } .c-page-line { stroke: var(--navy); stroke-width: 2; opacity: .5; }

/* ---------- Timer ---------- */
.timer { text-align: center; }
.time { font: 800 clamp(3.2rem, 15vw, 4.6rem)/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--navy-deep); }
.track { height: 12px; margin: 10px auto 6px; max-width: 300px; background: var(--cream); border: 2.5px solid var(--navy); border-radius: 99px; overflow: hidden; }
.track span { display: block; height: 100%; width: 0; background: repeating-linear-gradient(-45deg, var(--red) 0 8px, var(--red-deep) 8px 16px); transition: width .4s linear; }
.time-sub { color: var(--muted); font-weight: 600; }

/* ---------- Controls ---------- */
.controls { display: grid; gap: 14px; margin-top: 14px; }
#runControls { grid-template-columns: 1fr 1fr; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { border: 2.5px solid var(--navy); background: var(--cream); border-radius: 99px; padding: 6px 13px; font-weight: 700;
  box-shadow: 0 3px 0 var(--navy); font-variant-numeric: tabular-nums; }
.chip.active { background: var(--navy); color: var(--sand); }
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--navy); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 2.5px solid var(--navy); border-radius: var(--radius); padding: 13px 18px; font: 800 1.12rem/1.1 var(--display);
  box-shadow: 0 5px 0 var(--navy); transition: transform .08s, box-shadow .08s; background: var(--cream); color: var(--navy-deep); }
.btn .ic, .btn [data-icon] { width: 22px; height: 22px; flex: none; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--navy); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-go { background: var(--red); color: var(--cream); font-size: 1.32rem; letter-spacing: .01em; }
.btn-go:hover { background: #e14f45; }
.btn-blue { background: var(--navy); color: var(--sand); }
.btn-red { background: var(--red); color: var(--cream); }
.btn-ghost .i-light { fill: var(--sand); }
.btn.small { font-size: .95rem; padding: 10px 14px; }

/* ---------- Today cards ---------- */
.goal-card { display: flex; align-items: center; gap: 14px; }
.goal-card p, .challenge-card p { margin: 0; color: var(--muted); }
.mini-ring { position: relative; width: 64px; height: 64px; flex: none; }
.mini-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.mini-ring span { position: absolute; inset: 0; display: grid; place-items: center; font: 800 .9rem var(--display); }
.mr-bg { fill: none; stroke: var(--sand); stroke-width: 6; }
.mr-fg { fill: none; stroke: var(--red); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.challenge-card { display: flex; gap: 14px; align-items: center; background: #fdf0c9; }
.challenge-card.done { background: #eef3e4; }
.ch-icon { width: 54px; height: 54px; flex: none; }
.ch-body { flex: 1; min-width: 0; }
.reward { font: 700 .72rem var(--body); background: var(--navy); color: var(--sand); border-radius: 99px; padding: 2px 8px; margin-left: 4px; vertical-align: middle; }
.progress { height: 10px; background: var(--cream); border: 2px solid var(--navy); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--mustard); transition: width .8s ease; }
.challenge-card.done .progress span { background: var(--navy); }
.word { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.gender { flex: none; min-width: 52px; height: 52px; padding: 0 8px; display: grid; place-items: center; border-radius: 12px;
  font: 800 1.1rem var(--display); border: 2.5px solid var(--navy); transform: rotate(-4deg); }
.g-masc { background: var(--navy); color: var(--sand); }
.g-fem { background: var(--red); color: var(--cream); }
.g-elided, .g-verb { background: var(--mustard); color: var(--navy-deep); font-size: .95rem; }
.word b { display: block; font: 800 1.45rem/1.15 var(--display); color: var(--navy); }
.word small { color: var(--muted); }
.word-ex { margin: 10px 0 0; font-style: italic; }

/* ---------- Voyage map ---------- */
.map-card { padding: 10px; }
.map-scroll { overflow-x: auto; border-radius: 10px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.world { display: block; width: max(760px, 210%); height: auto; }
.m-sea { fill: #bfd0d6; } .m-wave { fill: none; stroke: #9db6bf; stroke-width: 2; stroke-linecap: round; }
.m-equator { stroke: #8fa9b3; stroke-width: 1.5; stroke-dasharray: 4 6; }
.m-label { font: 800 8px var(--display); letter-spacing: .2em; fill: #7d98a3; }
.m-land { fill: var(--sand); stroke: var(--navy); stroke-width: 1.4; stroke-linejoin: round; }
.m-land-shadow { fill: var(--navy); opacity: .25; }
.m-compass circle { fill: var(--cream); stroke: var(--navy); stroke-width: 2; }
.m-compass path { fill: var(--red); } .m-compass text { font: 800 11px var(--display); fill: var(--navy); }
.m-route-ahead { fill: none; stroke: var(--navy); stroke-width: 2; stroke-dasharray: 2 5; stroke-linecap: round; opacity: .6; }
.m-route-done { fill: none; stroke: var(--red); stroke-width: 3; stroke-linecap: round; }
.m-stop { cursor: pointer; outline: none; }
.m-hit { fill: transparent; }
.m-dot { stroke: var(--navy); stroke-width: 2; }
.m-stop.visited .m-dot { fill: var(--mustard); }
.m-dot-in { fill: var(--navy); }
.m-stop.current .m-dot { fill: var(--red); }
.m-stop.locked .m-dot { fill: var(--cream); }
.m-stop.selected .m-dot, .m-stop:focus-visible .m-dot { stroke: var(--red); stroke-width: 4; }
.m-stop.current.selected .m-dot { stroke: var(--navy-deep); }
.m-bob { animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.city-card { display: flex; gap: 14px; align-items: flex-start; padding: 12px 6px 4px; }
.city-icon { width: 56px; height: 56px; flex: none; }
.city-card b { display: block; font: 800 1.2rem/1.2 var(--display); }
.city-card small { color: var(--red-deep); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.city-card p { margin: 4px 0 0; color: var(--muted); }
.city-card.locked .city-icon { opacity: .5; }
.stops { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stop button { width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; padding: 6px 10px 6px 6px;
  background: var(--cream); border: 2px solid var(--navy); border-radius: 12px; box-shadow: 0 2px 0 var(--navy); }
.stop-icon { width: 30px; height: 30px; flex: none; }
.stop-name { flex: 1; min-width: 0; font-weight: 700; font-size: .88rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-lvl { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.stop.current button { background: var(--navy); color: var(--sand); }
.stop.current .stop-lvl { color: var(--mustard); font-weight: 700; }
.stop.locked button { background: rgba(255, 250, 240, .82); border-style: dashed; box-shadow: none; color: var(--muted); }
.stop.locked .stop-icon { opacity: .45; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
.stat { text-align: center; padding: 10px 8px; }
.stat-icon { width: 32px; height: 32px; display: block; margin: 0 auto 4px; }
.stat b { display: block; font: 800 1.5rem/1.2 var(--display); font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.bars { position: relative; height: 160px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; padding: 0 0 22px; margin-top: 8px; }
.bar-col { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.bar-col span { position: absolute; bottom: -22px; font-size: .8rem; color: var(--muted); text-transform: capitalize; }
.bar-col.today span { color: var(--red-deep); font-weight: 700; }
.bar { width: 100%; min-height: 4px; background: var(--sand); border: 2px solid var(--navy); border-radius: 8px 8px 3px 3px; position: relative; transition: height .8s ease; }
.bar.hit { background: var(--navy); }
.bar em { position: absolute; top: -20px; left: 0; right: 0; text-align: center; font-style: normal; font-size: .75rem; font-weight: 700; }
.goal-line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--red); margin-bottom: 22px; z-index: 1; pointer-events: none; }
.goal-line span { position: absolute; left: 0; top: -18px; font-size: .7rem; color: var(--red-deep); font-weight: 700; }
.heatmap-wrap { overflow-x: auto; }
.heatmap { display: grid; grid-auto-flow: column; grid-template-columns: repeat(12, 1fr); grid-template-rows: repeat(7, auto); gap: 4px; margin-top: 8px; min-width: 260px; }
.heatmap i, .legend i { display: block; aspect-ratio: 1; border-radius: 3px; border: 1.5px solid rgba(31, 58, 95, .25); }
.h0 { background: var(--cream); } .h1 { background: #f6dc97; } .h2 { background: var(--mustard); } .h3 { background: var(--red); } .h4 { background: var(--navy); }
.heatmap .future { visibility: hidden; }
.heatmap .today { border: 2px solid var(--red-deep); }
.legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 8px; font-size: .75rem; color: var(--muted); }
.legend i { width: 14px; }

/* ---------- Badges ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0 14px; }
.badge { text-align: center; padding: 12px 10px; }
.badge:not(.got) { background: #f7efdb; box-shadow: 0 2px 0 var(--navy); border-style: dashed; }
.b-icon { width: 64px; height: 64px; display: block; margin: 0 auto 4px; }
.badge.got .b-icon { animation: sway 3s ease-in-out infinite; transform-origin: 50% 0; }
@keyframes sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
.badge b { display: block; font: 800 1rem/1.2 var(--display); }
.badge small { color: var(--muted); font-size: .8rem; }

/* ---------- Leaderboard ---------- */
.seg { display: inline-flex; gap: 4px; margin-top: 8px; background: var(--sand); border: 2.5px solid var(--navy); border-radius: 99px; padding: 3px; }
.seg-btn { border: 0; background: none; border-radius: 99px; padding: 6px 14px; font-weight: 700; color: var(--muted); }
.seg-btn.active { background: var(--navy); color: var(--sand); }
.board { list-style: none; padding: 0; margin: 0; }
.row-entry { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 12px; }
.row-entry.me { background: #fdf0c9; }
.row-entry .pos { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 50%;
  font: 800 1.05rem var(--display); border: 2.5px solid var(--navy); background: var(--cream); }
.pos.gold { background: var(--mustard); } .pos.silver { background: #d9dde3; } .pos.bronze { background: #e0a46c; }
.row-entry .who { flex: 1; min-width: 0; display: grid; }
.row-entry .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--display); font-weight: 800; }
.row-entry .who small { color: var(--muted); }
.row-entry .mins { font: 800 1.05rem var(--display); color: var(--red-deep); white-space: nowrap; font-variant-numeric: tabular-nums; }
.board .gap { text-align: center; color: var(--muted); margin: -6px 0 6px; }
.board-note { text-align: center; color: var(--muted); margin: 8px 0 16px; }
.board-note:not(:empty) { background: var(--cream); border: 2px solid var(--navy); border-radius: 12px; padding: 8px 12px; }

/* ---------- Bottom nav ---------- */
.bottomnav { position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 10;
  width: min(528px, calc(100% - 32px)); display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--cream); border: 2.5px solid var(--navy); border-radius: 20px; box-shadow: 0 5px 0 var(--navy); padding: 5px; }
.nav-btn { background: none; border: 0; border-radius: 14px; padding: 5px 0 4px; font: 700 .7rem var(--body); display: grid; justify-items: center; gap: 2px; color: var(--muted); }
.nav-btn span { width: 26px; height: 26px; }
.nav-btn:not(.active) .ic { filter: saturate(.75); }
.nav-btn.active { background: var(--sand); color: var(--navy-deep); box-shadow: inset 0 0 0 2px var(--navy); }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(19, 38, 63, .55); animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal-card { width: min(420px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--cream); border: 2.5px solid var(--navy);
  border-radius: 22px; padding: 22px; box-shadow: 0 7px 0 var(--navy); display: grid; gap: 12px; text-align: center; animation: pop2 .4s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop2 { from { transform: scale(.7); opacity: 0; } }
.modal-card p { margin: 0; color: var(--muted); }
.modal-art { width: 76px; height: 76px; margin: 0 auto; animation: bob 2.6s ease-in-out infinite; }
.modal-card label { display: grid; gap: 4px; text-align: left; font-weight: 700; }
.modal-card input:not([type=checkbox]), .modal-card select { border: 2.5px solid var(--navy); border-radius: 12px; padding: 10px 12px; background: #fff; font-weight: 500; }
.modal-card label.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.modal-card label.check input { width: 20px; height: 20px; accent-color: var(--red); }
.danger { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border-top: 2px dashed var(--line); padding-top: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.account-box { grid-column: 1 / -1; display: grid; gap: 8px; text-align: left; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 12px; }
.account-box h3 { margin: 0; }
.link-btn { background: none; border: 0; color: var(--navy); font-weight: 700; text-decoration: underline; padding: 4px; }
.note { font-size: .85rem; }
.form-error { color: var(--red-deep) !important; font-weight: 700; min-height: 1em; margin: 0; }
.result h2 { font-size: 2.3rem; color: var(--red); }
.xp-lines { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.xp-lines li { display: flex; justify-content: space-between; background: #fff; border: 2px solid var(--navy); border-radius: 10px; padding: 8px 12px; animation: slideIn .4s backwards; }
.xp-lines b { color: var(--red-deep); font-variant-numeric: tabular-nums; }
@keyframes slideIn { from { transform: translateX(-20px); opacity: 0; } }
.xp-total { font: 800 1.35rem var(--display); color: var(--navy); }
.levelup { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--navy); color: var(--sand);
  border: 2.5px solid var(--navy); border-radius: 14px; padding: 12px; animation: pop2 .5s .4s backwards cubic-bezier(.3, 1.6, .5, 1); }
.levelup .lu-icon { width: 56px; height: 56px; flex: none; background: var(--sand); border-radius: 12px; padding: 6px; }
.levelup b { color: var(--mustard); }
.levelup small { display: block; opacity: .85; }
.lu-big { font: 800 1.35rem var(--display); color: #fff; }
.new-badges { display: grid; gap: 8px; }
.nb { display: flex; align-items: center; gap: 10px; text-align: left; background: #fff; border: 2px solid var(--navy); border-radius: 12px; padding: 8px 12px;
  animation: pop2 .4s backwards cubic-bezier(.3, 1.6, .5, 1); }
.nb > span { width: 46px; height: 46px; flex: none; }
.nb small { display: block; color: var(--muted); }

/* ---------- Confetti & toast ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--drift), 110vh) rotate(var(--spin)); } }
.toast { position: fixed; left: 50%; bottom: 104px; transform: translate(-50%, 20px); z-index: 70; opacity: 0; pointer-events: none;
  background: var(--navy-deep); color: var(--sand); padding: 10px 18px; border-radius: 12px; font-weight: 600; transition: .3s; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 520px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
/* Short phones: keep "Commencer !" above the bottom nav without scrolling. */
@media (max-height: 760px) {
  /* Bubble moves beside the balloon so the balloon can use the full height of the sky. */
  .poster { height: clamp(180px, 28vh, 250px); --balloon-top: 4; --balloon-cx: .68; }
  .bubble { left: 4px; top: 22%; transform: none; text-align: left; max-width: 50%; }
  .bubble::after { left: auto; right: -9px; bottom: auto; top: 50%; transform: translateY(-50%) rotate(-45deg); }
  .bubble.pop { animation-name: popSide; }
  .ticket { padding: 12px 12px 14px; }
  .time { font-size: 2.9rem; }
  .track { margin: 6px auto 4px; }
  .controls { gap: 10px; margin-top: 10px; }
  .chips { gap: 6px; }
  .chip { padding: 4px 11px; font-size: .92rem; }
  .btn-go { padding: 10px 18px; }
}
@media (max-width: 360px) { .stops { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
