/* RoRiii M1 look test - UI. One type family (Fredoka, SIL OFL, self-hosted), one warm palette, one motion language. */
@font-face { font-family: 'Fredoka'; font-weight: 500; font-display: block; src: url('fonts/fredoka-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-display: block; src: url('fonts/fredoka-latin-700-normal.woff2') format('woff2'); }
:root {
  --cream: #fff4e3; --cream-2: #ffe6c4; --ink: #3a2316; --ink-2: #7a5238; --ink-3: #a47b5c;
  --orange: #ff7a3d; --orange-hi: #ffa15a; --orange-d: #c24d17;
  --blue: #2f9cff; --blue-hi: #72c3ff; --blue-d: #1b62b4;
  --honey: #ffc83d; --honey-d: #c68710;
  --pop: cubic-bezier(.34, 1.56, .64, 1); --out: cubic-bezier(.2, .8, .2, 1);
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px); --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --u: min(1vh, 1vw * 0.5);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f3b988; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body { font-family: 'Fredoka', ui-rounded, system-ui, sans-serif; color: var(--ink); font-weight: 500; }
#gl { position: fixed; left: 0; top: 0; display: block; touch-action: none; }
#app { position: fixed; inset: 0; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }

/* ---------- text over the 3D view */
.lit { color: var(--cream); text-shadow: 0 .09em 0 rgba(58, 35, 22, .55), 0 .15em .45em rgba(58, 35, 22, .35); }

/* ---------- chunky buttons */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .45em; font-weight: 700; letter-spacing: .02em;
  color: #fff; font-size: 21px; line-height: 1; padding: .72em 1.5em .78em; border-radius: 999px;
  background: linear-gradient(180deg, var(--orange-hi), var(--orange) 62%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), inset 0 -3px 0 rgba(0, 0, 0, .08), 0 5px 0 var(--orange-d), 0 12px 22px rgba(90, 35, 5, .32);
  text-shadow: 0 2px 0 rgba(120, 40, 5, .35); transition: transform .12s var(--out), box-shadow .12s var(--out); }
.btn:active, .btn.press { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), 0 1px 0 var(--orange-d), 0 5px 12px rgba(90, 35, 5, .3); }
.btn.alt { color: var(--ink); background: linear-gradient(180deg, #fffaf1, var(--cream-2)); text-shadow: none;
  box-shadow: inset 0 2px 0 #fff, 0 5px 0 #d9b48c, 0 12px 22px rgba(90, 35, 5, .22); }
.btn.alt:active { box-shadow: inset 0 2px 0 #fff, 0 1px 0 #d9b48c, 0 5px 12px rgba(90, 35, 5, .2); }
.icon { width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(180deg, #fffaf1, var(--cream-2)); box-shadow: inset 0 2px 0 #fff, 0 4px 0 #d3a97d, 0 8px 16px rgba(80, 35, 5, .22);
  transition: transform .12s var(--out), box-shadow .12s var(--out); }
.icon:active { transform: translateY(3px); box-shadow: inset 0 2px 0 #fff, 0 1px 0 #d3a97d, 0 4px 10px rgba(80, 35, 5, .2); }
.icon svg { width: 26px; height: 26px; fill: var(--ink); }

/* ---------- segmented switch (WILD | TOY and friends) */
.seg { position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; border-radius: 999px;
  background: rgba(58, 35, 22, .34); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .25), 0 1px 0 rgba(255, 255, 255, .35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.seg button { position: relative; z-index: 1; font-weight: 700; font-size: 15px; letter-spacing: .06em; color: rgba(255, 244, 227, .82); padding: .62em 1.05em .66em; border-radius: 999px; white-space: nowrap; transition: color .2s; }
.seg button.on { color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.seg .thumb { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; border-radius: 999px; transition: transform .32s var(--pop), width .32s var(--pop), background .2s;
  background: linear-gradient(180deg, var(--orange-hi), var(--orange)); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), 0 3px 0 var(--orange-d); }
.seg.toy .thumb { background: linear-gradient(180deg, var(--blue-hi), var(--blue)); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45), 0 3px 0 var(--blue-d); }
.seg.light { background: rgba(122, 82, 56, .16); box-shadow: inset 0 2px 4px rgba(90, 50, 20, .18); backdrop-filter: none; }
.seg.light button { color: var(--ink-2); }
.seg.light button.on { color: #fff; }

/* ---------- HUD */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
#tags { z-index: 1; } #count, #banner { z-index: 3; } #title, #card { z-index: 4; } #pause, #results { z-index: 10; }
#hud .top { position: absolute; left: calc(14px + var(--sl)); right: calc(14px + var(--sr)); top: calc(10px + var(--st)); display: flex; align-items: flex-start; gap: 12px; }
#hud .top > * { pointer-events: auto; }
.place { font-weight: 700; line-height: .9; min-width: 96px; transform-origin: 20% 60%; }
.place .n { font-size: 50px; }
.place .suf { font-size: 24px; margin-left: 1px; }
.place .of { font-size: 18px; opacity: .85; margin-left: 4px; }
.place.gold .n, .place.gold .suf { color: #ffd65a; }
.place.bump { animation: bump .42s var(--pop); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.28) rotate(-4deg); } 100% { transform: scale(1); } }
.progress { position: relative; flex: 1; max-width: 360px; margin: 16px auto 0; height: 12px; border-radius: 999px;
  background: rgba(58, 35, 22, .3); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .25), 0 1px 0 rgba(255, 255, 255, .35); }
.progress .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: linear-gradient(90deg, rgba(255, 244, 227, .5), rgba(255, 244, 227, .85)); }
.progress .dot { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; border: 3px solid #fff4e3; box-shadow: 0 2px 0 rgba(0, 0, 0, .25); transition: transform .2s; }
.progress .dot.me { width: 24px; height: 24px; margin: -12px 0 0 -12px; border-width: 4px; z-index: 2; }
.progress .flag { position: absolute; right: -14px; top: 50%; width: 22px; height: 22px; margin-top: -11px; border-radius: 6px; border: 3px solid #fff4e3;
  background: conic-gradient(#2b2330 0 25%, #fff4e3 0 50%, #2b2330 0 75%, #fff4e3 0) 0 0 / 8px 8px; box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.hud-right { display: flex; align-items: center; gap: 10px; }
#hint { position: absolute; left: 50%; bottom: calc(16px + var(--sb)); transform: translateX(-50%); font-weight: 700; font-size: 19px; letter-spacing: .02em; white-space: nowrap;
  padding: .55em 1.2em .6em; border-radius: 999px; background: rgba(58, 35, 22, .42); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: opacity .5s; }
#hint b { color: #ffd65a; }
#hint.gone { opacity: 0; }

/* ---------- name tags */
#tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); font-weight: 700; font-size: 13px; letter-spacing: .03em; color: #fff; white-space: nowrap;
  padding: .28em .75em .32em; border-radius: 999px; text-shadow: 0 1px 0 rgba(0, 0, 0, .22); will-change: transform; }
.tag::after { content: ''; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: inherit; }
.tag.me { font-size: 15px; padding: .3em .85em .34em; }
/* a runner too high for the HUD band wears its tag under its feet, arrow up */
.tag.below::after { bottom: auto; top: -5px; border-top: 0; border-bottom: 5px solid; border-bottom-color: inherit; }
.res-sub b { font-weight: 700; color: var(--ink); }

/* ---------- countdown + banner */
/* the countdown sits in the open field ahead of the pack, clear of the START gantry */
#count { position: absolute; top: 0; bottom: 0; left: 44%; right: 0; display: grid; place-items: center; pointer-events: none; }
#count span { font-weight: 700; font-size: min(26vh, 150px); line-height: 1; color: var(--cream); -webkit-text-stroke: 3px rgba(58, 35, 22, .25);
  text-shadow: 0 7px 0 var(--orange-d), 0 14px 30px rgba(58, 35, 22, .45); animation: countIn .7s var(--pop) both; }
#count span.go { color: #ffd65a; text-shadow: 0 7px 0 var(--honey-d), 0 14px 30px rgba(58, 35, 22, .45); }
@keyframes countIn { 0% { transform: scale(.2) rotate(-10deg); opacity: 0; } 55% { transform: scale(1.12) rotate(2deg); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
#banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none; }
#banner span { display: inline-block; font-weight: 700; font-size: min(15vh, 84px); color: #fff; letter-spacing: .03em; padding: .08em .6em .14em; border-radius: .5em;
  background: linear-gradient(180deg, var(--orange-hi), var(--orange)); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .4), 0 7px 0 var(--orange-d), 0 18px 36px rgba(80, 30, 5, .35);
  text-shadow: 0 3px 0 rgba(120, 40, 5, .3); animation: bannerIn .6s var(--pop) both; }
@keyframes bannerIn { 0% { transform: scale(.3) rotate(-6deg); opacity: 0; } 100% { transform: scale(1) rotate(-2deg); opacity: 1; } }

/* ---------- title (returning players) */
/* title: logo top-left over open sky, the pack centre stage, the START gantry right of centre, the button in the right thumb zone */
#title { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-end; padding: 0 calc(30px + var(--sr)) calc(24px + var(--sb)) 0; }
#title .logo { position: absolute; top: calc(20px + var(--st)); left: calc(28px + var(--sl)); right: auto; text-align: left; font-weight: 700; font-size: min(12.5vh, 60px); line-height: .95; }
#title .logo small { display: block; font-size: .36em; letter-spacing: .22em; margin-top: .5em; opacity: .92; }
#title .btn { font-size: 26px; animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ---------- first launch: pick your style */
#card { position: absolute; inset: 0; background: radial-gradient(46% 30% at 50% 0%, rgba(92, 48, 20, .34), rgba(92, 48, 20, 0) 100%), linear-gradient(180deg, rgba(255, 214, 160, 0) 45%, rgba(92, 48, 20, .38) 100%); }
#card .head { position: absolute; top: calc(14px + var(--st)); left: 0; right: 0; text-align: center; }
#card h1 { margin: 0; font-weight: 700; font-size: min(11vh, 62px); line-height: 1; }
#card p { margin: .35em 0 0; font-size: min(5vh, 23px); font-weight: 500; }
#card .choices { position: absolute; left: calc(18px + var(--sl)); right: calc(18px + var(--sr)); bottom: calc(16px + var(--sb)); display: flex; gap: 4%; justify-content: center; }
.choice { width: min(44%, 340px); padding: 12px 16px 14px; border-radius: 26px; text-align: left; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px;
  color: #fff; transition: transform .16s var(--out), opacity .3s, filter .3s; }
.choice.wild { background: linear-gradient(180deg, var(--orange-hi), var(--orange) 70%); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), 0 6px 0 var(--orange-d), 0 16px 30px rgba(90, 35, 5, .35); }
.choice.toy { background: linear-gradient(180deg, var(--blue-hi), var(--blue) 70%); box-shadow: inset 0 3px 0 rgba(255, 255, 255, .45), 0 6px 0 var(--blue-d), 0 16px 30px rgba(10, 40, 90, .35); }
.choice b { font-size: min(9vh, 38px); font-weight: 700; letter-spacing: .05em; line-height: 1; text-shadow: 0 2px 0 rgba(0, 0, 0, .18); }
.choice span { grid-column: 1; font-size: min(4.2vh, 16px); opacity: .95; }
.choice i { grid-row: 1 / span 2; grid-column: 2; width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .25); display: grid; place-items: center; font-style: normal; }
.choice i svg { width: 22px; height: 22px; fill: #fff; }
.choice:active { transform: translateY(4px) scale(.98); }
.choice.chosen { animation: chosen .5s var(--pop) both; }
.choice.faded { opacity: 0; transform: scale(.9); }
@keyframes chosen { 0% { transform: scale(1); } 40% { transform: scale(1.1); } 100% { transform: scale(1.04); } }

/* ---------- sheets: pause / results */
.scrim { position: absolute; inset: 0; background: rgba(58, 30, 12, .38); display: grid; place-items: center; animation: fade .2s both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet { width: min(560px, 88vw); max-height: calc(100vh - 24px); overflow: auto; padding: 18px 24px 20px; border-radius: 30px; color: var(--ink);
  background: linear-gradient(180deg, #fffaf1, var(--cream) 60%, var(--cream-2)); box-shadow: inset 0 3px 0 #fff, 0 8px 0 #d8b187, 0 24px 50px rgba(60, 25, 5, .4);
  animation: sheetIn .38s var(--pop) both; }
@keyframes sheetIn { from { transform: translateY(24px) scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { margin: 0 0 10px; font-weight: 700; font-size: 30px; text-align: center; letter-spacing: .02em; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 7px 0; border-top: 2px dashed rgba(164, 123, 92, .25); }
.row:first-of-type { border-top: 0; }
.row label { font-weight: 700; font-size: 17px; }
.row label small { display: block; font-weight: 500; font-size: 13px; color: var(--ink-3); }
.row .seg button { font-size: 13px; padding: .6em .85em .62em; }
.btns { display: flex; justify-content: center; gap: 14px; margin-top: 14px; }
.btns .btn { font-size: 19px; }

/* results: a side panel, the podium stays in view on the left */
#results { place-items: center end; padding-right: calc(16px + var(--sr)); background: linear-gradient(90deg, rgba(58, 30, 12, 0) 35%, rgba(58, 30, 12, .42)); }
#results .sheet { width: min(400px, 44vw); display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: center; padding: 16px 20px 18px; }
#results .btns .btn { font-size: 17px; padding: .68em 1.1em .72em; }
.medal { grid-row: 1 / span 2; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 46px; line-height: 1;
  font-size: 38px; box-shadow: inset 0 4px 0 rgba(255, 255, 255, .5), inset 0 -6px 0 rgba(0, 0, 0, .12), 0 6px 0 rgba(0, 0, 0, .18); animation: medal .7s var(--pop) both .1s; }
.medal small { font-size: .42em; align-self: start; margin-top: 1.1em; margin-left: .04em; }
.medal { grid-auto-flow: column; }
.medal.p1 { background: radial-gradient(circle at 35% 30%, #ffe68a, #ffbf2e 60%, #e79a12); }
.medal.p2 { background: radial-gradient(circle at 35% 30%, #f2f6ff, #b9c6e0 60%, #8f9dbd); }
.medal.p3 { background: radial-gradient(circle at 35% 30%, #ffd2ae, #e39360 60%, #b86a39); }
.medal.p4, .medal.dnf { background: radial-gradient(circle at 35% 30%, #e9d8c5, #b89b80 60%, #8e725a); }
@keyframes medal { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }
.res-title { font-weight: 700; font-size: 29px; line-height: 1; }
.res-sub { font-size: 14px; color: var(--ink-2); line-height: 1.25; }
.order { grid-column: 1 / span 2; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.order span { font-weight: 700; font-size: 12px; color: #fff; padding: .36em .72em .42em; border-radius: 999px; box-shadow: 0 3px 0 rgba(0, 0, 0, .16); }
#results .btns { grid-column: 1 / span 2; margin-top: 10px; }
.ring { width: 20px; height: 20px; border-radius: 50%; background: conic-gradient(#fff var(--p, 0%), rgba(255, 255, 255, .35) 0); -webkit-mask: radial-gradient(circle, transparent 5px, #000 6px); mask: radial-gradient(circle, transparent 5px, #000 6px); }

/* ---------- loading + rotate */
#loading { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(120% 90% at 70% 30%, #ffd9a3, #f7a86e 55%, #d9744a); z-index: 30; transition: opacity .5s; }
#loading.done { opacity: 0; pointer-events: none; }
#loading .box { text-align: center; width: min(420px, 80vw); }
#loading .box .btn { margin-top: 24px; font-size: 22px; }
#loading .logo { font-weight: 700; font-size: min(13vh, 60px); line-height: .95; color: var(--cream); text-shadow: 0 5px 0 rgba(150, 60, 20, .45), 0 12px 30px rgba(90, 30, 5, .35); }
#loading .logo small { display: block; font-size: .34em; letter-spacing: .24em; margin-top: .55em; }
#loading .bar { margin: 26px auto 0; height: 16px; border-radius: 999px; background: rgba(90, 40, 15, .28); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .25); overflow: hidden; }
#loading .bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(180deg, #fff6e6, #ffd9a0); transition: width .25s var(--out); }
#rotate { position: absolute; inset: 0; z-index: 40; display: none; place-items: center; text-align: center; padding: 30px;
  background: radial-gradient(120% 80% at 50% 30%, #ffd9a3, #f7a86e 60%, #d9744a); color: var(--cream); }
#rotate .phone { width: 64px; height: 108px; border-radius: 14px; border: 6px solid var(--cream); margin: 0 auto 26px; position: relative; animation: turn 2.2s var(--out) infinite;
  box-shadow: 0 6px 0 rgba(150, 60, 20, .35); }
#rotate .phone::after { content: ''; position: absolute; left: 50%; bottom: 6px; width: 16px; height: 4px; margin-left: -8px; border-radius: 2px; background: var(--cream); }
@keyframes turn { 0%, 20% { transform: rotate(0); } 55%, 100% { transform: rotate(-90deg); } }
#rotate h2 { margin: 0; font-weight: 700; font-size: 30px; line-height: 1.05; text-shadow: 0 4px 0 rgba(150, 60, 20, .4); }
#rotate p { margin: 10px 0 0; font-size: 17px; opacity: .95; }
@media (orientation: portrait) { #rotate.armed { display: grid; } }

#fps { position: absolute; left: calc(8px + var(--sl)); bottom: 6px; font: 600 12px/1.25 ui-monospace, Menlo, monospace; color: #fff; background: rgba(40, 20, 10, .55); padding: 4px 8px; border-radius: 8px; pointer-events: none; white-space: pre; z-index: 50; }

@media (max-height: 360px) {
  .place .n { font-size: 42px; } .icon { width: 42px; height: 42px; } .seg button { font-size: 14px; padding: .55em .9em .6em; }
}
@media (prefers-reduced-motion: reduce) { #count span, #banner span, .sheet, .medal, #title .btn, .place.bump, #rotate .phone { animation-duration: .01s !important; animation-iteration-count: 1 !important; } }
body.reduce #count span, body.reduce #banner span, body.reduce .sheet, body.reduce .medal, body.reduce #title .btn, body.reduce .place.bump { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
#btnSound .off { display: none; } #btnSound.muted .off { display: inline; } #btnSound.muted .on { display: none; }
