/* Jay Run. Mobile first (390x844, down to 360 wide). Deep blue and gold, the colours of Sapienta; the halls are a
   three.js canvas and the rest is a thin layer on top. */
:root {
  --font: "Baloo 2", ui-rounded, system-ui, sans-serif;
  --ink: #1b2140; --ink-soft: #4a5378;
  --navy: #141a36; --navy-2: #222b5a; --gold: #e2b33a; --gold-2: #f6d77a; --red: #e8453c; --good: #49c46a;
}
* { touch-action: manipulation; box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--navy); color: var(--ink); font-family: var(--font); overflow: hidden; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
[hidden] { display: none !important; }

/* the shared title screen: a hall of Sapienta at night, gold on deep blue */
#mm {
  --sg-bg: radial-gradient(ellipse 90% 40% at 50% 36%, rgba(226, 179, 58, 0.22), transparent 70%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 64px),
    linear-gradient(180deg, #0c1028 0%, #1a2250 45%, #232c62 70%, #10142e 100%);
  --sg-ink: #f2ecda; --sg-ink-soft: #c2bda8;
  --sg-title: #f6d77a; --sg-title-shadow: 0 2px 0 #8a6416, 0 4px 0 #2a1e08, 0 0 18px rgba(226, 179, 58, 0.35);
  --sg-accent: #e2b33a; --sg-accent-ink: #1b1608;
  --sg-card: rgba(20, 26, 58, 0.92); --sg-card-ink: #f2ecda; --sg-line: rgba(226, 179, 58, 0.3);
  --sg-font: var(--font);
}
.sg-sheet {
  --sg-ink: #1b2140; --sg-ink-soft: #3d4668;
  --sg-accent: #2a4fa8; --sg-accent-ink: #fff;
  --sg-card: rgba(255, 255, 255, 0.95); --sg-card-ink: #1b2140; --sg-line: rgba(27, 33, 64, 0.18);
  --sg-sheet-bg: #fbf8ef; --sg-sheet-ink: #1b2140;
  --sg-font: var(--font);
}
#mm .sg-play { box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), inset 0 -5px 0 rgba(120, 80, 0, 0.3), 0 5px 0 #8a6416; }

/* the title's picture: Jay in an arch of the Great Hall */
.title-art { position: relative; width: min(100%, 340px); height: 100%; margin: 0 auto; border-radius: 170px 170px 18px 18px; overflow: hidden; background: #1b2350;
  box-shadow: 0 0 0 3px #e2b33a, 0 0 0 6px #5a4210, 0 10px 24px -12px rgba(0, 0, 0, 0.8); }
.title-bg { position: absolute; inset: 0; background: var(--pic, none) center 40% / cover no-repeat; }
.title-bg::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse 60% 55% at 45% 62%, rgba(255, 220, 140, 0.22), transparent 70%), linear-gradient(180deg, rgba(14, 18, 44, 0.15) 0%, rgba(14, 18, 44, 0.25) 55%, rgba(14, 18, 44, 0.85) 100%); }
.title-jay { position: absolute; left: 0; bottom: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; animation: bob 0.5s ease-in-out infinite alternate; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.5)); }
.title-jay:not([src]) { visibility: hidden; }
.title-name { position: absolute; left: 50%; top: 9%; transform: translateX(-50%); padding: 2px 12px; border-radius: 999px; background: rgba(12, 16, 40, 0.8); color: #f6d77a; font: 800 14px/1.4 var(--font); white-space: nowrap; box-shadow: 0 0 0 1.5px rgba(226, 179, 58, 0.6); }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .title-jay { animation: none; } }

/* ---------- a run ---------- */
.play { position: fixed; inset: 0; background: var(--navy); touch-action: none; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.vig { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.2s; background: radial-gradient(ellipse at 50% 55%, rgba(90, 20, 110, 0) 42%, rgba(90, 20, 110, 0.6) 100%); }
.speed { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s; background: radial-gradient(ellipse at 50% 45%, rgba(255, 200, 120, 0) 50%, rgba(255, 190, 90, 0.35) 100%); }
.speed.on { opacity: 1; }
.hud { position: absolute; left: 0; right: 0; top: 0; padding: var(--sg-corner-top) 10px 0 var(--sg-corner-left); display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-mid { flex: 1 1 auto; min-width: 0; text-align: center; pointer-events: none; }
.score { display: block; white-space: nowrap; font: 800 clamp(36px, 11.5vw, 46px)/1 var(--font); color: #fff; text-shadow: 0 3px 0 rgba(10, 12, 30, 0.6); -webkit-text-stroke: 2px rgba(10, 12, 30, 0.55); paint-order: stroke fill; font-variant-numeric: tabular-nums; }
.score::after { content: " m"; font-size: 22px; }
.bestpill { display: inline-block; margin-top: 2px; padding: 1px 10px; border-radius: 999px; background: rgba(10, 12, 30, 0.6); color: #f6d77a; font: 700 13px/1.4 var(--font); }
.bestpill:empty { display: none; }
.coins { flex: none; min-width: 62px; height: 44px; padding: 0 12px 0 8px; display: flex; align-items: center; gap: 6px; border-radius: 14px; background: rgba(12, 16, 40, 0.78); color: #f6d77a; box-shadow: 0 0 0 1.5px rgba(226, 179, 58, 0.55); font: 800 20px/1 var(--font); font-variant-numeric: tabular-nums; }
.coins.pop { animation: pop 0.2s ease-out; }
@keyframes pop { 0% { transform: scale(1.22); } 100% { transform: scale(1); } }
.coin { display: inline-block; flex: none; width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 32%, #fff3a8 0 22%, #f2c21a 24% 62%, #c4900c 64%); box-shadow: inset 0 -2px 0 rgba(150, 90, 0, 0.5), 0 0 0 2px #a87408; }
/* power-ups running: a chip each with the time left as a ring */
.pows { position: absolute; left: 0; right: 0; top: calc(var(--sg-corner-top) + 72px); display: flex; justify-content: center; gap: 8px; pointer-events: none; }
.pow { --k: 1; display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 4px; border-radius: 999px; background: rgba(12, 16, 40, 0.8); color: #fff; font: 800 15px/1 var(--font); box-shadow: 0 0 0 1.5px rgba(226, 179, 58, 0.5); }
.pow i { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 17px; background: conic-gradient(#f6d77a calc(var(--k) * 360deg), rgba(255, 255, 255, 0.15) 0); }
.pow i b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #1b2350; }
.banner { position: absolute; left: 50%; top: 26%; margin: 0; padding: 6px 18px 8px; border-radius: 999px; transform: translateX(-50%) scale(0.5); opacity: 0; pointer-events: none; background: #141a36; color: #f6d77a; font: 800 24px/1.1 var(--font); box-shadow: 0 0 0 2px rgba(226, 179, 58, 0.7), 0 4px 0 #07080f; white-space: nowrap; }
.banner.show { animation: banner 1.7s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes banner { 0% { opacity: 0; transform: translateX(-50%) scale(0.5); } 12% { opacity: 1; transform: translateX(-50%) scale(1); } 80% { opacity: 1; transform: translateX(-50%) scale(1); } 100% { opacity: 0; transform: translateX(-50%) scale(0.9); } }
.obtip { position: absolute; left: 50%; top: calc(26% + 50px); width: min(88vw, 340px); margin: 0; padding: 8px 14px; border-radius: 14px; transform: translateX(-50%); opacity: 0; pointer-events: none; background: rgba(12, 16, 40, 0.88); color: #fff; font: 700 16px/1.3 var(--font); text-align: center; box-shadow: 0 0 0 1.5px rgba(226, 179, 58, 0.4); }
.obtip.show { animation: obtip 3.4s ease forwards; }
@keyframes obtip { 0% { opacity: 0; transform: translateX(-50%) translateY(8px); } 10%, 82% { opacity: 1; transform: translateX(-50%) translateY(0); } 100% { opacity: 0; transform: translateX(-50%) translateY(-4px); } }
.warn { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 40px); margin: 0; padding: 6px 16px; border-radius: 999px; transform: translateX(-50%); background: rgba(90, 20, 110, 0.9); color: #fff; font: 800 16px/1.2 var(--font); white-space: nowrap; opacity: 0; transition: opacity 0.2s; pointer-events: none; box-shadow: 0 0 0 1.5px rgba(255, 120, 140, 0.6); }
.warn.on { opacity: 1; animation: throb 0.5s ease-in-out infinite alternate; }
@keyframes throb { to { transform: translateX(-50%) scale(1.05); } }
.toast { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 40px); flex-direction: column-reverse; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; pointer-events: none; }
.toast p { margin: 0; padding: 6px 14px; border-radius: 12px; background: #f6d77a; color: #1b1608; font: 800 15px/1.25 var(--font); box-shadow: 0 4px 0 #8a6416; animation: toast 3s ease forwards; text-align: center; max-width: 86vw; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.hint { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); transform: translateX(-50%); width: min(88vw, 320px); padding: 10px 14px; border-radius: 16px; background: rgba(12, 16, 40, 0.82); color: #fff; text-align: center; pointer-events: none; box-shadow: 0 0 0 1.5px rgba(226, 179, 58, 0.45); }
.hint p { margin: 2px 0; font: 700 17px/1.3 var(--font); }
.hint b { color: #f6d77a; }
@media (prefers-reduced-motion: reduce) { .warn.on { animation: none; } .banner.show, .toast p, .obtip.show { animation-duration: 0.01s; animation-delay: 0s; } .toast p { animation: none; } .banner.show { animation: none; opacity: 1; transform: translateX(-50%); } }

/* the end of a run */
.over { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(8, 10, 26, 0.55); }
.over .card { width: min(100%, 360px); padding: 18px 18px 16px; border-radius: 22px; background: linear-gradient(180deg, #232c62, #171e44); color: #f2ecda; text-align: center; box-shadow: 0 0 0 2px #e2b33a, 0 0 0 5px #3a2c0c, 0 16px 34px -12px rgba(0, 0, 0, 0.8); animation: card 0.32s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes card { from { transform: scale(0.85); opacity: 0; } }
.o-cause { margin: 0; font: 700 16px/1.3 var(--font); color: #c2bda8; }
.o-score { margin: 2px 0; font: 800 58px/1 var(--font); color: #f6d77a; text-shadow: 0 3px 0 #5a4210; font-variant-numeric: tabular-nums; }
.o-score::after { content: " m"; font-size: 26px; }
.o-best { margin: 0 0 10px; font: 700 15px/1.3 var(--font); color: #f2ecda; min-height: 20px; }
.o-best.new { color: #7affb0; }
.o-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.o-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px; border-radius: 999px; background: rgba(0, 0, 0, 0.25); font: 700 15px/1.3 var(--font); }
.o-goals { display: grid; gap: 6px; margin: 0 0 12px; text-align: left; }
.o-goal { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.22); font: 700 14px/1.25 var(--font); }
.o-goal small { color: #c2bda8; font: 700 13px/1.2 var(--font); }
.o-goal.done { background: rgba(122, 255, 176, 0.16); box-shadow: inset 0 0 0 1.5px rgba(122, 255, 176, 0.5); }
.o-goal .bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.o-goal .bar i { display: block; height: 100%; background: #f6d77a; border-radius: 3px; }
.o-retry { width: 100%; min-height: 56px; border: 0; border-radius: 16px; background: #e2b33a; color: #1b1608; font: 800 22px/1 var(--font); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), 0 5px 0 #8a6416; }
.o-retry:active { transform: translateY(2px); box-shadow: 0 3px 0 #8a6416; }
.o-actions { display: flex; gap: 8px; margin-top: 12px; }
.o-actions button { flex: 1; min-height: 46px; border: 0; border-radius: 14px; background: rgba(255, 255, 255, 0.1); color: #f2ecda; font: 800 17px/1 var(--font); box-shadow: inset 0 0 0 1.5px rgba(226, 179, 58, 0.45); }
.nogl { position: fixed; inset: auto 16px 40% 16px; padding: 16px; border-radius: 16px; background: #fff; text-align: center; font: 700 17px/1.4 var(--font); }

/* the shop */
.shop { display: grid; gap: 12px; }
.shop h3 { margin: 4px 2px 0; font: 800 13px/1.3 var(--font); letter-spacing: 0.06em; text-transform: uppercase; color: #5a4a1a; }
.shop-top { display: flex; align-items: center; gap: 12px; }
.shop-top img { width: 112px; height: 112px; border-radius: 16px; background: linear-gradient(180deg, #2a3466, #141a36); box-shadow: 0 0 0 2px #e2b33a; }
.shop-top p { margin: 0; font: 700 15px/1.35 var(--font); }
.shop-wallet { display: inline-flex; align-items: center; gap: 6px; font: 800 20px/1 var(--font); }
.shop-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.look { position: relative; min-height: 64px; padding: 8px 10px; border: 0; border-radius: 14px; background: #fff; text-align: left; box-shadow: inset 0 0 0 1.5px rgba(27, 33, 64, 0.16); display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.look b { font: 800 15px/1.2 var(--font); }
.look small { font: 700 13px/1.2 var(--font); color: #4a5378; display: flex; align-items: center; gap: 4px; }
.look small .coin { width: 14px; height: 14px; }
.look.on { background: #fdf3d0; box-shadow: inset 0 0 0 2.5px #e2b33a; }
.look.cant { opacity: 0.62; }
.goals { display: grid; gap: 8px; }
.goals p { margin: 0; font: 700 15px/1.35 var(--font); }
.goal-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px 12px; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 1.5px rgba(27, 33, 64, 0.16); font: 700 15px/1.3 var(--font); }
.goal-row small { color: #4a5378; font: 700 13px/1.2 var(--font); }
.goal-row .bar { grid-column: 1 / -1; height: 7px; border-radius: 4px; background: rgba(27, 33, 64, 0.1); overflow: hidden; }
.goal-row .bar i { display: block; height: 100%; background: #e2b33a; }

/* a new place of Sapienta: a bigger, longer banner */
.banner.big { top: 22%; padding: 10px 22px 12px; font-size: 28px; background: linear-gradient(180deg, #1c2450, #10142c); box-shadow: 0 0 0 2px #e2b33a, 0 0 28px rgba(246, 215, 122, 0.45), 0 4px 0 #07080f; max-width: calc(100vw - 32px); white-space: normal; text-align: center; }
.banner small { display: block; margin-bottom: 2px; color: #fff; font: 700 13px/1.2 var(--font); letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; }
.banner.big.show { animation-duration: 2.5s; }
.o-next { margin: -4px 0 10px; font: 700 14px/1.3 var(--font); color: #c8cce0; }
.o-next b { color: #f6d77a; }
/* the Places sheet */
.places { display: grid; gap: 8px; }
.places > p { margin: 0 0 4px; font: 700 15px/1.35 var(--font); }
.place-row { display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: center; padding: 8px; border-radius: 14px; background: #fff; box-shadow: inset 0 0 0 1.5px rgba(27, 33, 64, 0.16); }
.place-pic { --pic: none; display: block; width: 76px; height: 57px; border-radius: 9px; background: var(--pic) center / cover, linear-gradient(160deg, #2a3a7a, #6a7ab0 60%, #22284a); box-shadow: inset 0 0 0 2px rgba(226, 179, 58, 0.8); }
.place-row.locked .place-pic { background: linear-gradient(160deg, #3a3e52, #22242e); filter: none; }
.place-row.locked .place-pic::after { content: "?"; display: grid; place-items: center; height: 100%; color: #8a8ea6; font: 800 26px/1 var(--font); }
.place-txt { display: grid; gap: 2px; font: 700 15px/1.25 var(--font); }
.place-txt small { color: #4a5378; font: 700 12.5px/1.25 var(--font); }
