:root { --ink: #1d2340; --pink: #e6337a; --yellow: #ffd23f; --blue: #2b6cb0; --red: #e8304a; --cream: #fff7e6; --logo: Impact, "Haettenschweiler", "Arial Narrow Bold", "Arial Black", sans-serif; --ui: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f2d4c0; color: var(--ink); font-family: var(--ui); -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
#c { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
[hidden] { display: none !important; }
a { color: var(--blue); }

/* ---------- buttons & panels ---------- */
.btn { font: 800 16px/1 var(--ui); color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 11px 16px; box-shadow: 0 4px 0 var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .08s; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.btn.big { font-size: 22px; padding: 14px 22px; font-family: var(--logo); letter-spacing: .5px; font-weight: 400; }
.btn.big small { font: 700 12px var(--ui); opacity: .85; margin-left: 6px; }
.btn.pink { background: var(--pink); color: #fff; }
.btn.round { width: 46px; height: 46px; padding: 0; border-radius: 50%; font-size: 20px; }
.soundbtn { position: fixed; z-index: 30; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
.soundbtn.off { background: #ccc; text-decoration: line-through; }
.screen { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 16px; pointer-events: none; }
.screen > * { pointer-events: auto; }
.panel { background: rgba(255, 247, 230, .94); border: 4px solid var(--ink); border-radius: 26px; box-shadow: 0 10px 0 var(--ink), 0 20px 50px rgba(29,35,64,.35); padding: 22px 24px; max-width: min(760px, 100%); max-height: calc(100dvh - 32px); overflow: auto; text-align: center; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.panel h2 { font: 400 34px/1 var(--logo); margin: 0 0 12px; letter-spacing: .5px; }
.panel h2 small { font: 700 14px var(--ui); opacity: .7; margin-left: 6px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 12px 0 0; }
.muted { opacity: .72; font-size: 14px; }
.foot { font-size: 13px; margin: 14px 0 0; }

/* ---------- logo ---------- */
.logo { font: 400 clamp(46px, 11vw, 88px)/.85 var(--logo); margin: 0 0 8px; display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 0 14px; letter-spacing: 1px; }
.logo span { color: var(--yellow); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); }
.logo span:nth-child(2) { color: var(--pink); }
.logo em { font-style: normal; color: #fff; background: var(--blue); border: 4px solid var(--ink); border-radius: 14px; padding: 4px 10px 2px; font-size: .6em; transform: rotate(-6deg); box-shadow: 0 5px 0 var(--ink); }
.tag { font-weight: 800; margin: 6px 0 12px; }
.menu { max-width: 600px; }
.menu .btn.big { font-size: 34px; padding: 16px 40px; margin-top: 4px; }

.wise { position: relative; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 10px 14px; margin: 6px auto 16px; max-width: 480px; font-weight: 700; font-size: 15px; display: flex; flex-direction: column; gap: 3px; }
.wise::after { content: ""; position: absolute; left: 34px; bottom: -14px; border: 12px solid transparent; border-top-color: var(--ink); border-bottom: 0; }
.wise-who { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--pink); }
.wise.small { font-size: 13px; margin-top: 14px; }

/* ---------- select ---------- */
.select { max-width: 880px; }
.roster { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.gcard { position: relative; font: 700 13px var(--ui); color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 10px 6px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 3px 0 var(--ink); border-top: 10px solid var(--c); }
.gcard b { font: 400 22px var(--logo); letter-spacing: .5px; }
.gcard i { font-style: normal; opacity: .7; font-size: 11px; }
.gcard .gnum { position: absolute; top: 4px; right: 6px; font: 400 14px var(--logo); color: var(--c); }
.gcard.on { background: var(--yellow); transform: translateY(-3px); box-shadow: 0 6px 0 var(--ink); }
.ginfo { margin: 14px auto 6px; max-width: 560px; }
.ginfo h3 { font: 400 40px/1 var(--logo); margin: 0; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.ginfo .gang { margin: 2px 0; font-weight: 800; }
.ginfo .line { font-style: italic; margin: 4px 0 10px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; text-align: left; font-weight: 800; font-size: 13px; }
.bar { height: 12px; border: 2px solid var(--ink); border-radius: 8px; background: #fff; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--yellow)); }
.diffs { display: inline-flex; border: 3px solid var(--ink); border-radius: 14px; overflow: hidden; margin-top: 12px; }
.diffs button { font: 800 14px var(--ui); border: 0; background: #fff; color: var(--ink); padding: 10px 12px; cursor: pointer; border-right: 2px solid var(--ink); }
.diffs button:last-child { border-right: 0; }
.diffs button.on { background: var(--blue); color: #fff; }
.select { background: rgba(255,247,230,.88); }
@media (min-width: 1000px) { #results { justify-content: flex-end; padding-right: 3vw; } .results { width: min(540px, 46vw); } #select { justify-content: flex-start; padding-left: 4vw; } .select { max-width: 560px; } .roster { grid-template-columns: repeat(4, 1fr); } }

/* ---------- how ---------- */
.how { text-align: left; max-width: 820px; }
.how h2, .how > .btn { display: block; text-align: center; margin-left: auto; margin-right: auto; }
.how .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.how h3 { font: 400 22px var(--logo); margin: 10px 0 4px; letter-spacing: .5px; }
.how ul { margin: 0; padding-left: 18px; line-height: 1.45; }
.c1 { color: #1f87e0; font-weight: 900; } .c2 { color: #e07800; font-weight: 900; } .c3 { color: #d62fb6; font-weight: 900; }

/* ---------- boards ---------- */
.board { width: min(560px, 100%); }
.tabs { display: inline-flex; border: 3px solid var(--ink); border-radius: 14px; overflow: hidden; }
.tabs button { font: 800 15px var(--ui); border: 0; background: #fff; color: var(--ink); padding: 9px 16px; cursor: pointer; border-right: 2px solid var(--ink); }
.tabs button:last-child { border-right: 0; }
.tabs button.on { background: var(--pink); color: #fff; }
.blist, .rtable { list-style: none; padding: 0; margin: 10px 0; text-align: left; }
.blist li, .rtable li { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 12px; font-weight: 700; border-left: 8px solid var(--c, #ccc); background: #fff; margin: 5px 0; border-top: 2px solid rgba(29,35,64,.12); }
.blist li.muted { display: block; border-left: 0; text-align: center; }
.blist b, .rtable b { font: 400 22px var(--logo); }
.blist i { font-style: normal; opacity: .6; font-size: 12px; }
.blist em, .rtable i { font-style: normal; font-variant-numeric: tabular-nums; font-weight: 800; }
.rtable li.me { background: var(--yellow); }

/* ---------- results & podium ---------- */
.results { width: min(620px, 100%); }
.rhead { display: flex; gap: 16px; align-items: center; justify-content: center; text-align: left; }
.rhead h2 { margin: 0 0 4px; }
.rhead p { margin: 2px 0; }
.rplace { font: 400 74px/1 var(--logo); color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; background: var(--blue); border: 4px solid var(--ink); border-radius: 20px; padding: 6px 14px; box-shadow: 0 6px 0 var(--ink); }
.rplace.p1 { background: var(--yellow); color: var(--pink); } .rplace.p2 { background: #d9dde8; } .rplace.p3 { background: #e0965a; }
.rlaps { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 700; opacity: .8; }
.pb { background: var(--pink); color: #fff; border-radius: 8px; padding: 1px 6px; font-weight: 900; }
.rboard { font-weight: 800; }
.nameform label { font-weight: 800; display: block; }
.nameform input { font: 700 17px var(--ui); padding: 10px 12px; border: 3px solid var(--ink); border-radius: 12px; width: min(260px, 60vw); }
.podium { flex-direction: column; justify-content: flex-start; padding-top: max(24px, env(safe-area-inset-top)); }
.podtitle { font: 400 clamp(44px, 10vw, 90px)/1 var(--logo); color: var(--yellow); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink); margin: 0 0 10px; animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
.wise.pod { max-width: 520px; }

.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(29,35,64,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.pausep { display: flex; flex-direction: column; gap: 10px; min-width: 260px; }

/* ---------- loading ---------- */
#loading { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, #fff2c9, #ffc6a0 55%, #f08aa8); transition: opacity .6s; }
#loading.gone { opacity: 0; pointer-events: none; }
.loadbox { text-align: center; font-weight: 800; padding: 20px; }
.spinner { width: 54px; height: 54px; margin: 16px auto; border-radius: 50%; border: 7px solid rgba(29,35,64,.15); border-top-color: var(--pink); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; font-family: var(--logo); }
#hud.done .h-tc, #hud.done .map, #hud.done .spd { opacity: 0; transition: opacity .5s; }
.h-tl { position: absolute; left: max(14px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); }
.pos { font: 400 clamp(56px, 10vw, 104px)/1 var(--logo); color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); }
.pos small { font-size: .42em; vertical-align: top; margin-left: 2px; }
.pos.p1 { color: var(--yellow); } .pos.p2 { color: #e3e8f2; } .pos.p3 { color: #f0a868; }
.pos.bump { animation: pop .35s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes pop { from { transform: scale(1.5) rotate(-6deg); } to { transform: none; } }
.lapc { font-size: clamp(20px, 3.4vw, 30px); color: #fff; -webkit-text-stroke: 2.5px var(--ink); paint-order: stroke fill; margin-top: -2px; letter-spacing: 1px; }
.lapc b { color: var(--yellow); font-weight: 400; }
.h-tc { position: absolute; left: 50%; top: max(10px, env(safe-area-inset-top)); transform: translateX(-50%); text-align: center; }
.itemslot { width: clamp(70px, 11vw, 96px); height: clamp(70px, 11vw, 96px); border: 4px solid var(--ink); border-radius: 22px; background: rgba(255,255,255,.72); box-shadow: 0 5px 0 var(--ink), inset 0 0 0 4px rgba(255,210,63,.6); display: flex; align-items: center; justify-content: center; position: relative; margin: 0 auto; }
.itemslot img { width: 92%; height: 92%; object-fit: contain; filter: drop-shadow(0 2px 0 rgba(29,35,64,.4)); }
.itemslot.ready { background: rgba(255,210,63,.85); animation: ready 1s ease-in-out infinite; }
.itemslot.rolling img { animation: roll .14s linear infinite; }
@keyframes ready { 50% { transform: scale(1.06); } }
@keyframes roll { 50% { transform: translateY(-6px) scale(.9); } }
.itemslot span { position: absolute; right: -8px; bottom: -8px; font-size: 22px; color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.itemname { font: 800 13px var(--ui); color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 6px var(--ink); margin-top: 8px; }
.h-tr { position: absolute; right: max(14px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); text-align: right; }
.time { font: 400 clamp(24px, 4vw, 38px)/1 var(--logo); color: #fff; -webkit-text-stroke: 2.5px var(--ink); paint-order: stroke fill; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.laps { font: 800 13px/1.35 var(--ui); color: #fff; text-shadow: 0 1px 0 var(--ink), 0 0 4px var(--ink); font-variant-numeric: tabular-nums; }
.tof { margin-top: 6px; font-size: 26px; color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; display: inline-flex; align-items: center; gap: 6px; }
.tof b { font-weight: 400; } .tof small { font-size: 15px; }
.tof .tf { width: 30px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe9a3, #e3a51e 60%, #a96d06); border: 2.5px solid var(--ink); position: relative; }
.tof .tf::before, .tof .tf::after { content: ""; position: absolute; top: 3px; border: 6px solid transparent; }
.tof .tf::before { left: -11px; border-right-color: #ffe08a; } .tof .tf::after { right: -11px; border-left-color: #ffe08a; }
.tof.full { color: var(--yellow); }
.map { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); width: clamp(110px, 17vw, 190px); height: auto; aspect-ratio: 1; filter: drop-shadow(0 3px 0 rgba(29,35,64,.35)); }
.spd { position: absolute; right: max(70px, calc(env(safe-area-inset-right) + 70px)); bottom: max(14px, env(safe-area-inset-bottom)); font: 400 clamp(34px, 5vw, 52px)/1 var(--logo); color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; font-variant-numeric: tabular-nums; }
.spd small { font-size: .38em; margin-left: 4px; }
.pausebtn { position: absolute; pointer-events: auto; right: max(12px, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); font: 900 16px var(--ui); }
.banner { position: fixed; z-index: 12; left: 50%; top: 26%; transform: translate(-50%, -50%) scale(.6); font: 400 clamp(30px, 6.5vw, 64px)/1 var(--logo); color: #fff; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); white-space: nowrap; opacity: 0; pointer-events: none; letter-spacing: 1px; }
.banner.show { animation: bannerIn .45s cubic-bezier(.2, 1.7, .4, 1) forwards; }
.banner.big { font-size: clamp(40px, 9vw, 92px); }
.banner.gold { color: var(--yellow); } .banner.pink { color: #ff7ab0; } .banner.red { color: #ff5a6e; } .banner.blue { color: #8fd0ff; } .banner.hot { color: #ffb347; } .banner.tea { color: #f6d6a8; }
@keyframes bannerIn { to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.count { position: fixed; z-index: 12; left: 50%; top: 42%; transform: translate(-50%, -50%); font: 400 clamp(90px, 22vw, 220px)/1 var(--logo); color: var(--yellow); -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; text-shadow: 0 10px 0 var(--ink); opacity: 0; pointer-events: none; }
.count.show { animation: countIn .9s ease-out forwards; }
.count.go { color: #4fe07a; }
@keyframes countIn { 0% { opacity: 0; transform: translate(-50%, -50%) scale(2.2); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.8); } }

#bubbles { position: fixed; inset: 0; z-index: 9; pointer-events: none; overflow: hidden; }
.bub { position: absolute; left: 0; top: 0; white-space: nowrap; transform-origin: 50% 100%; will-change: transform; }
.bub.tag { font: 800 12px var(--ui); color: #fff; background: var(--c); border: 2px solid var(--ink); border-radius: 10px; padding: 2px 8px; }
.bub.say { font: 800 15px var(--ui); color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 6px 10px; box-shadow: 0 3px 0 var(--ink); }
.bub.say::after { content: ""; position: absolute; left: 50%; bottom: -11px; margin-left: -8px; border: 9px solid transparent; border-top-color: var(--ink); border-bottom: 0; }

/* ---------- touch controls ---------- */
#touch { position: fixed; inset: 0; z-index: 11; pointer-events: none; }
.t-steer { position: absolute; left: 0; top: 30%; bottom: 0; width: 55%; pointer-events: auto; touch-action: none; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: calc(max(14px, env(safe-area-inset-bottom)) + 4px); }
.t-steer span { font: 800 11px var(--ui); color: #fff; text-shadow: 0 1px 2px var(--ink); opacity: .8; margin-top: 6px; }
.t-steer.on span { opacity: 0; }
.t-steer .track { width: 150px; height: 46px; border-radius: 23px; background: rgba(255,255,255,.25); border: 3px solid rgba(29,35,64,.5); display: flex; align-items: center; justify-content: center; margin-left: 30%; }
.t-steer .knob { width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.85); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }
.t-btn { position: absolute; pointer-events: auto; touch-action: none; font: 400 20px/1 var(--logo); letter-spacing: 1px; color: #fff; border: 4px solid var(--ink); border-radius: 50%; box-shadow: 0 5px 0 var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; }
.t-btn small { font: 800 9px var(--ui); -webkit-text-stroke: 0; opacity: .9; margin-top: 2px; }
.t-btn.on { transform: translateY(4px) scale(.96); box-shadow: 0 1px 0 var(--ink); }
.t-drift { width: 104px; height: 104px; right: max(16px, env(safe-area-inset-right)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 56px); background: var(--pink); font-size: 24px; }
.t-item { width: 84px; height: 84px; right: calc(max(16px, env(safe-area-inset-right)) + 112px); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 120px); background: var(--yellow); color: var(--ink); -webkit-text-stroke: 0; }
.t-brake { width: 62px; height: 62px; right: calc(max(16px, env(safe-area-inset-right)) + 124px); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 30px); background: #8a90a8; font-size: 14px; }
@media (pointer: coarse) { .spd { display: none; } .map { left: max(8px, env(safe-area-inset-left)); bottom: auto; top: calc(max(10px, env(safe-area-inset-top)) + 104px); width: 92px; } .pausebtn { top: calc(max(10px, env(safe-area-inset-top)) + 100px); transform: none; } .soundbtn { bottom: auto; top: calc(max(10px, env(safe-area-inset-top)) + 154px); right: max(12px, env(safe-area-inset-right)); } }
@media (pointer: coarse) and (orientation: portrait) { .t-steer { width: 50%; } .t-steer .track { width: 120px; margin-left: 0; } .t-steer .knob { width: 48px; height: 48px; } }
@media (max-width: 640px) {
  .panel { padding: 16px 14px; border-radius: 20px; }
  .roster { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .gcard { padding: 8px 2px 6px; } .gcard b { font-size: 17px; } .gcard i { display: none; }
  .how .cols { grid-template-columns: 1fr; }
  .rplace { font-size: 52px; }
  .menu .btn.big { font-size: 28px; }
  .diffs button { font-size: 12px; padding: 9px 7px; }
}
@media (max-height: 500px) { .logo { font-size: 44px; } .wise { display: none; } .panel { padding: 12px 16px; } .menu .wise { display: none; } }
@media (prefers-reduced-motion: reduce) { .itemslot.ready, .pos.bump, .podtitle { animation: none; } }
