:root { --ink: #fff; --bg: #1b1d2b; --y: #ffe14d; --pink: #ff4d6d; --font: "Trebuchet MS", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif, "Noto Color Emoji"; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

/* the floating stick under your thumb */
#stick { position: fixed; left: -45px; top: -45px; width: 90px; height: 90px; border-radius: 50%; border: 3px solid rgba(255,255,255,.45); background: rgba(0,0,0,.12); pointer-events: none; z-index: 5; }
#stick i { position: absolute; left: 25px; top: 25px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.7); box-shadow: 0 2px 6px rgba(0,0,0,.3); }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
#hud button { pointer-events: auto; }
.tl { position: absolute; left: max(10px, env(safe-area-inset-left)); top: max(8px, env(safe-area-inset-top)); text-shadow: 0 2px 0 #000, 0 0 6px rgba(0,0,0,.6); }
#pos { font-size: 44px; font-weight: 900; line-height: 1; color: var(--y); transition: transform .15s; font-style: italic; }
#pos.up { transform: scale(1.25); }
#pos sup { font-size: 20px; } #pos small { font-size: 18px; color: #fff; margin-left: 4px; }
#cpn { font-weight: 800; font-size: 15px; margin-top: 2px; }
#clock { font-size: 14px; opacity: .9; font-variant-numeric: tabular-nums; }
#map { position: absolute; right: max(10px, env(safe-area-inset-right)); top: calc(max(8px, env(safe-area-inset-top)) + 52px); width: 92px; height: 106px; border: 3px solid #fff; border-radius: 10px; background: #1b1d2b; box-shadow: 0 3px 10px rgba(0,0,0,.4); opacity: .95; }
.tr { position: absolute; right: max(10px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top)); display: flex; gap: 6px; }
.icon { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(20,22,36,.7); font-size: 20px; }
#wanted { position: absolute; left: 50%; top: max(10px, env(safe-area-inset-top)); transform: translateX(-50%); background: linear-gradient(90deg, #d7263d, #2155ff); padding: 6px 14px; border-radius: 99px; font-weight: 900; font-size: 14px; white-space: nowrap; animation: flash .5s infinite alternate; margin-top: 58px; }
@keyframes flash { to { filter: brightness(1.4); } }
#count { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-size: 120px; font-weight: 900; font-style: italic; color: var(--y); text-shadow: 0 6px 0 #000; }
#itemBtn { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); width: 92px; height: 92px; border-radius: 22px; border: 4px solid rgba(255,255,255,.5); background: rgba(20,22,36,.6); display: flex; flex-direction: column; align-items: center; justify-content: center; }
#itemBtn #itemIcon { font-size: 44px; line-height: 1; }
#itemBtn small { position: absolute; right: 0; bottom: 100%; margin-bottom: 6px; font-size: 13px; font-weight: 800; white-space: nowrap; text-shadow: 0 2px 0 #000; }
#itemBtn.has { border-color: var(--y); background: rgba(40,30,0,.6); }
#itemBtn.has.ready { animation: ready .6s infinite alternate; }
#itemBtn.rolling { border-color: #fff; }
@keyframes ready { to { box-shadow: 0 0 0 6px rgba(255,225,77,.35); } }
#ctlHint { position: absolute; left: 0; right: 120px; bottom: max(10px, env(safe-area-inset-bottom)); margin: 0; text-align: center; font-size: 12px; opacity: .75; text-shadow: 0 1px 0 #000; }
.t-touch, .t-keys, .t-pad { display: none; }
body.touch:not(.pad) .t-touch, body:not(.touch):not(.pad) .t-keys, body.pad .t-pad { display: inline; }
#toast { position: fixed; left: 50%; top: 24%; transform: translate(-50%, -50%) scale(.8); opacity: 0; transition: opacity .2s, transform .2s; font-weight: 900; font-size: 20px; text-align: center; padding: 8px 16px; background: rgba(20,22,36,.75); border-radius: 12px; pointer-events: none; z-index: 6; white-space: nowrap; max-width: 94vw; }
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#toast.big { font-size: 34px; font-style: italic; color: var(--y); background: none; text-shadow: 0 3px 0 #000, 0 0 12px rgba(0,0,0,.6); }
#toast.warn { color: #fff; background: linear-gradient(90deg, #d7263d, #2155ff); }

/* screens */
.screen, .screen-o { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 8; overflow: auto; }
.screen { background: radial-gradient(ellipse at 50% 30%, rgba(27,29,43,.55), rgba(27,29,43,.92)); }
.screen-o { background: rgba(15,16,26,.72); align-items: flex-start; padding-top: max(16px, env(safe-area-inset-top)); }
.card { width: min(420px, 100%); background: #262a3f; border: 3px solid #3c4262; border-radius: 22px; padding: 18px 18px 14px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.45); margin: auto; }
h1 { margin: 2px 0 4px; font-size: 54px; font-style: italic; font-weight: 900; letter-spacing: 1px; color: var(--y); text-shadow: 0 4px 0 #000; line-height: 1; }
h1 span { color: var(--pink); }
h2 { margin: 0 0 10px; }
.tag { margin: 6px 0 10px; font-size: 16px; }
.how { text-align: left; padding: 0 0 0 4px; margin: 0 0 12px; list-style: none; font-size: 14px; line-height: 1.4; }
.how li { margin: 4px 0; }
.btn { display: block; width: 100%; min-height: 52px; margin: 8px 0; border-radius: 14px; border: 0; background: #3c4262; font-weight: 800; font-size: 18px; box-shadow: 0 4px 0 #15172a; }
.btn.go { background: var(--y); color: #1b1d2b; font-size: 21px; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #15172a; }
.controls { font-size: 12.5px; opacity: .8; margin: 10px 0 6px; line-height: 1.4; }
.mark { margin: 6px 0 0; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 13px; opacity: .9; }
.mini { min-height: 44px; padding: 0 14px; border-radius: 12px; border: 2px solid #4a5175; background: transparent; font-weight: 700; font-size: 14px; }
.row { display: flex; gap: 8px; justify-content: center; margin: 6px 0; }
.end { padding-top: 12px; }
.res { display: flex; align-items: center; justify-content: center; gap: 14px; }
#endPlace { font-size: 64px; font-weight: 900; font-style: italic; color: var(--y); text-shadow: 0 4px 0 #000; line-height: 1; }
#endPlace sup { font-size: 26px; }
#endLine { font-size: 17px; font-weight: 800; margin: 0; text-align: left; }
#standings { list-style: none; padding: 0; margin: 8px 0; font-size: 14px; }
#standings li { display: flex; align-items: center; gap: 8px; padding: 3px 8px; border-radius: 8px; }
#standings li.me { background: rgba(255,225,77,.18); }
#standings b { width: 18px; } #standings i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
#standings span { flex: 1; text-align: left; } #standings em { font-style: normal; font-variant-numeric: tabular-nums; opacity: .85; }
#vote p { margin: 8px 0 4px; font-size: 14px; font-weight: 700; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { flex: none; min-height: 40px; padding: 0 12px; border-radius: 99px; border: 2px solid #4a5175; background: #2f3450; font-size: 13px; font-weight: 700; white-space: nowrap; }
#want { margin: 6px auto; display: block; font-size: 13px; }
.noted { font-size: 13px; } .noted a, .links a { color: var(--y); }
#more { margin-top: 6px; }

@media (min-width: 900px) and (pointer: fine) {
  #pos { font-size: 56px; } #cpn { font-size: 18px; } #clock { font-size: 16px; }
  #map { width: 160px; height: 185px; top: 66px; }
  #itemBtn { width: 108px; height: 108px; right: 24px; bottom: 24px; }
  #ctlHint { font-size: 14px; }
}

/* garage */
#garage { margin: 4px 0 6px; }
.ghead { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; margin: 0 2px 4px; }
.ghead span { color: var(--y); font-weight: 800; }
.karts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.kart { position: relative; padding: 2px 0 3px; border-radius: 10px; border: 2px solid #3c4262; background: #1f2236; font-size: 10.5px; font-weight: 800; line-height: 1.1; min-height: 64px; }
.kart img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: contain; }
.kart.on { border-color: var(--y); background: #3a3520; }
.kart.locked img { filter: grayscale(1) brightness(.45); }
.kart.locked em { position: absolute; left: 0; right: 0; top: 14px; font-style: normal; font-size: 11px; color: #fff; text-shadow: 0 1px 0 #000; }
#kartInfo { margin: 5px 0 0; font-size: 13px; min-height: 17px; opacity: .9; }
/* sound panel */
.srow { display: flex; align-items: center; gap: 10px; margin: 12px 0; text-align: left; }
.srow label { flex: 0 0 120px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.srow input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--y); }
.srow input[type=range] { flex: 1; accent-color: var(--y); height: 28px; }
.snote { font-size: 12px; opacity: .7; }
/* result: rep and a new kart */
#repLine { margin: 4px 0; font-size: 14px; font-weight: 800; color: var(--y); }
#unlocked { display: flex; align-items: center; gap: 10px; background: linear-gradient(90deg, #3a3520, #262a3f); border: 2px solid var(--y); border-radius: 14px; padding: 6px 10px; margin: 6px 0; text-align: left; animation: pop .4s ease-out; }
#unlocked img { width: 96px; height: 64px; object-fit: contain; }
#unlocked b { display: block; font-size: 16px; } #unlocked small { display: block; font-size: 12px; opacity: .85; margin-bottom: 4px; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
#dmg { width: 92px; height: 9px; margin-top: 5px; border-radius: 9px; background: rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.7); overflow: hidden; }
#dmg i { display: block; height: 100%; width: 100%; background: #3ddc84; transition: width .2s; }
#dmg.mid i { background: #ffd23f; } #dmg.bad i { background: #ff3b3b; animation: flash .3s infinite alternate; }
.btn.cup { background: linear-gradient(90deg, #6b4dff, #2f8cff); }
#endLine small { display: block; font-size: 13px; font-weight: 700; opacity: .8; }
#standings em small { color: var(--y); font-weight: 800; margin-right: 4px; }
#cupGo { margin: 6px auto; display: block; font-size: 14px; border-color: #6b7cff; }
#cardImg { display: block; width: 100%; max-height: calc(100dvh - 130px); object-fit: contain; border-radius: 12px; }
.mini.go { background: var(--y); color: #1b1d2b; border-color: var(--y); }

/* The trophy shelf on the title. */
#shelf { margin: 6px 0 0; font-size: 14px; } #shelf span { margin-left: 6px; font-weight: 800; } #shelf small { display: block; opacity: .75; }
.btn.couch { background: linear-gradient(90deg, #1f9d6b, #2fb8ff); }

/* Couch lobby: four seats. */
.card.wide { width: min(720px, 100%); }
.seats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
@media (max-width: 560px) { .seats { grid-template-columns: repeat(2, 1fr); } }
.seat { border: 3px dashed #3c4262; border-radius: 14px; padding: 8px 4px; min-height: 128px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: #1f2236; }
.seat.on { border-style: solid; background: #2c3150; }
.seat b { display: inline-block; min-width: 38px; padding: 2px 8px; border-radius: 8px; background: #3c4262; color: #1b1d2b; font-weight: 900; }
.seat img { width: 100%; max-width: 120px; aspect-ratio: 3 / 2; object-fit: contain; }
.seat span { font-weight: 800; font-size: 14px; } .seat small { opacity: .7; font-size: 12px; } .seat em { opacity: .6; font-style: normal; font-size: 14px; }

/* Couch race: a HUD panel per player over their part of the split screen. */
#seatHud { display: none; }
body.couch #seatHud { display: block; position: absolute; inset: 0; }
body.couch #hud .tl, body.couch #itemBtn, body.couch #ctlHint { display: none; }
body.couch #map { left: 50%; top: 50%; right: auto; transform: translate(-50%, -50%); width: 110px; height: 127px; z-index: 2; }
body.couch #wanted { top: auto; bottom: 8px; margin: 0; }
#couchClock { display: none; }
body.couch #couchClock { display: block; position: absolute; left: 50%; top: 6px; transform: translateX(-50%); font-weight: 900; font-size: 18px; padding: 2px 10px; border-radius: 9px; background: rgba(20,22,36,.7); }
.shud { position: absolute; overflow: hidden; }
.sh-tl { position: absolute; left: 10px; top: 8px; text-shadow: 0 2px 0 #000, 0 0 6px rgba(0,0,0,.6); }
.sh-p { display: inline-block; padding: 1px 8px; border-radius: 8px; color: #1b1d2b; font-weight: 900; font-size: 16px; text-shadow: none; vertical-align: top; margin-right: 6px; }
.sh-pos { font-size: 36px; font-weight: 900; font-style: italic; color: var(--y); line-height: 1; } .sh-pos sup { font-size: 16px; }
.sh-cp { display: block; font-weight: 800; font-size: 14px; }
.sh-dmg { width: 84px; height: 8px; margin-top: 4px; border-radius: 9px; background: rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.7); overflow: hidden; }
.sh-dmg i { display: block; height: 100%; width: 100%; background: #3ddc84; transition: width .2s; }
.sh-dmg.mid i { background: #ffd23f; } .sh-dmg.bad i { background: #ff3b3b; animation: flash .3s infinite alternate; }
.sh-item { position: absolute; right: 10px; bottom: 10px; width: 70px; height: 70px; border-radius: 18px; border: 3px solid rgba(255,255,255,.4); background: rgba(20,22,36,.6); display: flex; align-items: center; justify-content: center; }
.sh-item span { font-size: 36px; line-height: 1; }
.sh-item small { position: absolute; right: 0; bottom: 100%; margin-bottom: 4px; font-size: 13px; font-weight: 800; white-space: nowrap; text-shadow: 0 2px 0 #000; }
.sh-item.has { border-color: var(--y); background: rgba(40,30,0,.6); } .sh-item.has.ready { animation: ready .6s infinite alternate; } .sh-item.rolling { border-color: #fff; }
.sh-toast { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%) scale(.8); opacity: 0; transition: opacity .2s, transform .2s; font-weight: 900; font-size: 18px; padding: 6px 12px; background: rgba(20,22,36,.75); border-radius: 10px; white-space: nowrap; }
.sh-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.sh-toast.big { font-size: 28px; font-style: italic; color: var(--y); background: none; text-shadow: 0 3px 0 #000; }
.sh-toast.warn { color: #fff; background: linear-gradient(90deg, #d7263d, #2155ff); }
.sh-tv { position: absolute; left: 10px; top: 8px; margin: 0; font-weight: 900; text-shadow: 0 2px 0 #000; }

body.couch #hud .tr { display: none; }
body.couch #couchClock { top: calc(50% - 98px); }
.shud.right .sh-tl { left: auto; right: 10px; text-align: right; } .shud.right .sh-p { margin: 0 0 0 6px; float: right; } .shud.right .sh-dmg { margin-left: auto; }
.shud.left .sh-item { right: auto; left: 10px; } .shud.left .sh-item small { right: auto; left: 0; }
