/* 飆車吧！ — chunky, bright and outlined, like the games homepage */
/* the zh-TW round font is 來釣魚吧！'s, next door (/fish/ behind the homepage, the root on a bare Node server) */
@font-face { font-family: 'LetsFish Round'; src: url('../../fish/fonts/letsfish-round.woff2') format('woff2'), url('../../fonts/letsfish-round.woff2') format('woff2'); font-display: swap; }

:root {
  --ink: #22163a; --ink2: #4b3b68; --cream: #fff7e6; --cream2: #ffeccb;
  --sun: #ffd23f; --coral: #ff5d8f; --sea: #3fa7ff; --mint: #5bd96a; --grape: #8c5cff; --orange: #ff8a3d;
  --title: 'Lilita One', 'LetsFish Round', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --font: 'LetsFish Round', 'Fredoka', 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', system-ui, sans-serif;
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --vw: 100vw; --vh: 100vh;
}
* { box-sizing: border-box; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; touch-action: none; }
body { background: #ff9a5c; color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
input, textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
[hidden] { display: none !important; }
input, button, select { font: inherit; }
button { touch-action: manipulation; }

/* the whole game lives in #app; on a phone held upright it's turned a quarter round */
#app { position: fixed; left: 0; top: 0; width: var(--vw); height: var(--vh); overflow: hidden; }
html.turned #app { width: var(--vh); height: var(--vw); transform-origin: 0 0; transform: rotate(90deg) translateY(-100%); }
html.turned { --safe-l: env(safe-area-inset-top, 0px); --safe-r: env(safe-area-inset-bottom, 0px); --safe-t: 0px; --safe-b: 0px; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; touch-action: none; }
/* scrolling panes can still be dragged up and down */
.tabpane, .modal-body, .room-wrap, .chat-log, .pause-box, .results { touch-action: pan-y; }
/* A rotated pane scrolls along the screen's horizontal axis on portrait phones. */
html.turned :is(.tabpane, .modal-body, .room-wrap, .chat-log, .pause-box, .results) { touch-action: pan-x pan-y; }

/* ------------------------------------------------------------ bits */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; color: var(--ink); font: 600 16px var(--font); cursor: pointer; box-shadow: 0 4px 0 var(--ink); transition: transform .06s, box-shadow .06s; text-decoration: none; white-space: nowrap; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--coral); color: #fff; text-shadow: 0 2px 0 var(--ink); font: 400 19px var(--title); letter-spacing: .5px; }
.btn.ghost { background: rgba(255, 255, 255, .85); }
.btn.big { padding: 11px 24px; font-size: 22px; width: 100%; }
.btn.small { padding: 5px 12px; font-size: 14px; border-radius: 11px; box-shadow: 0 3px 0 var(--ink); }
.btn.tiny { padding: 1px 8px; font-size: 14px; border-radius: 9px; box-shadow: 0 2px 0 var(--ink); }
.btn.on { background: var(--mint); }
.panel { background: var(--cream); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 8px 0 var(--ink); }
.card { background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 12px 14px; margin-top: 12px; box-shadow: 0 4px 0 rgba(34, 22, 58, .25); }
.card h2 { margin: 0 0 8px; font: 400 22px var(--title); letter-spacing: .5px; }
.card h2 small { font: 600 13px var(--font); color: var(--ink2); margin-left: 6px; }
.row { display: flex; align-items: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.row .label { width: 40px; flex: none; font-weight: 700; font-size: 15px; color: var(--ink2); }
.seg { display: inline-flex; flex-wrap: wrap; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; background: #fff; }
.seg button { border: 0; border-right: 2px solid var(--ink); background: transparent; padding: 5px 11px; font-weight: 700; font-size: 15px; cursor: pointer; color: var(--ink); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--sun); }
.seg.locked button { cursor: default; }
.seg.locked button:not(.on) { color: #a99cb8; }
.seg.many { flex-wrap: nowrap; } .seg.many button { padding: 5px 8px; min-width: 32px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; cursor: pointer; margin: 4px 10px 4px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--coral); }
.mobile-controls h4 { margin: 0 0 8px; font-weight: 700; font-size: 16px; }
.control-schemes { display: flex; gap: 8px; }
.control-schemes .btn { flex: 1; min-width: 0; flex-direction: column; gap: 3px; padding: 9px 8px; }
.control-schemes small { font-size: 12px; font-weight: 500; }
.mobile-controls .note { margin: 10px 0 0; }
.mobile-controls [data-recenter] { margin-top: 8px; }
.room-controls { padding: 12px 14px; }
.field { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.field input, .join input, #chat-in { flex: 1; min-width: 0; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; font-size: 17px; color: var(--ink); outline: none; }
.field input:focus, .join input:focus, #chat-in:focus { border-color: var(--coral); }
.badge { display: inline-block; padding: 1px 10px; border: 2px solid var(--ink); border-radius: 999px; background: var(--mint); font-size: 13px; font-weight: 700; }
.badge.private { background: #ddd3ee; }
.slider { display: flex; flex-direction: column; gap: 2px; font-weight: 700; font-size: 15px; margin: 6px 0; }
.slider input, .slider select { accent-color: var(--coral); }
.slider select { padding: 4px 8px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; font-weight: 700; }

/* ------------------------------------------------------------ the menu */
.screen { position: absolute; inset: 0; z-index: 2; overflow: hidden; }
#menu .home { position: absolute; left: calc(14px + var(--safe-l)); top: calc(12px + var(--safe-t)); z-index: 3; }
.logo { position: absolute; left: calc(28px + var(--safe-l)); top: calc(58px + var(--safe-t)); pointer-events: none; }
.logo h1 { margin: 0; font: 400 clamp(48px, 8vw, 104px)/1 var(--title); color: var(--sun); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); transform: rotate(-4deg) skewX(-6deg); letter-spacing: 3px; animation: wobble 3.2s ease-in-out infinite; }
.logo p { margin: 14px 0 0 6px; font-weight: 700; font-size: 18px; color: #fff; text-shadow: 0 2px 0 var(--ink), 0 0 10px rgba(0, 0, 0, .3); }
@keyframes wobble { 50% { transform: rotate(-1deg) skewX(-6deg) scale(1.03); } }
.menu-panel { position: absolute; right: calc(18px + var(--safe-r)); top: calc(18px + var(--safe-t)); bottom: calc(18px + var(--safe-b)); width: min(480px, calc(100% - 36px)); display: flex; flex-direction: column; padding: 12px 14px 14px; }
.tabs { display: flex; gap: 6px; flex: none; }
.tab { flex: 1; padding: 8px 6px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; font: 400 18px var(--title); letter-spacing: .5px; color: var(--ink2); cursor: pointer; white-space: nowrap; }
.tab[data-tab="opts"] { flex: 0 0 52px; }
.tab.on { background: var(--sun); color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.tabpane { flex: 1; overflow-y: auto; padding: 4px 2px 6px; margin-top: 8px; scrollbar-width: thin; }
.online .buttons { gap: 6px; }
.join { display: inline-flex; gap: 6px; flex: 1; justify-content: flex-end; min-width: 150px; }
.join input { max-width: 92px; text-transform: uppercase; text-align: center; letter-spacing: 3px; font-weight: 700; }
.rooms-head { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-weight: 700; color: var(--ink2); font-size: 14px; }
.rooms { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.rooms .empty { margin: 6px 0; color: var(--ink2); font-size: 14px; }
.room-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 3px solid var(--ink); border-radius: 13px; background: var(--cream); cursor: pointer; }
.room-item:hover { background: #fff3c4; }
.room-item .ri-name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-item .ri-name small { display: block; font-weight: 500; color: var(--ink2); font-size: 12.5px; }
.room-item .ri-st { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 2px solid var(--ink); background: var(--mint); }
.room-item .ri-st.racing { background: var(--sun); }

/* track cards */
.tracks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 4px; }
.tcard { position: relative; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; cursor: pointer; background: #ddd; aspect-ratio: 16 / 10; }
.tcard img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tcard span { position: absolute; left: 0; right: 0; bottom: 0; padding: 1px 3px; background: rgba(34, 22, 58, .78); color: #fff; font-size: 12.5px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tcard.special { background: linear-gradient(135deg, #ff7eb6, #ffd23f 35%, #5cc8ff 70%, #8c5cff); display: grid; place-items: center; }
.tcard.special b { font-size: 26px; margin-bottom: 14px; }
.tcard.on { outline: 4px solid var(--sun); outline-offset: -1px; box-shadow: 0 0 0 2px var(--ink); }
.tcard.on::after { content: '✔'; position: absolute; right: 4px; top: 1px; color: var(--sun); font-size: 18px; -webkit-text-stroke: 1px var(--ink); }
.tracks.locked .tcard { cursor: default; }

/* the customiser */
.looks h4, .rides h4, .opts h4, .modal-body h4 { margin: 12px 0 6px; font: 400 18px var(--title); letter-spacing: .5px; }
.animals { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.animal { display: flex; flex-direction: column; align-items: center; padding: 3px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; cursor: pointer; font-size: 13px; }
.animal img, .animal .ph { width: 64px; height: 64px; object-fit: contain; display: block; }
.animal .ph { display: grid; place-items: center; font-size: 30px; background: radial-gradient(circle, #ffe9c4 30%, transparent 32%); }
.animal.on { background: var(--sun); box-shadow: 0 3px 0 var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; font-weight: 700; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--sun); box-shadow: 0 3px 0 var(--ink); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 32px; height: 32px; border: 3px solid var(--ink); border-radius: 50%; cursor: pointer; padding: 0; }
.swatch.on { outline: 4px solid var(--sun); outline-offset: 1px; transform: scale(1.12); }
/* the other parts: one icon each (showing what you have on) that opens a
   little picker under the row, as in 來釣魚吧！'s lobby */
.look-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; }
.look-btn { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; padding: 6px 0 4px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; box-shadow: 0 3px 0 var(--ink); color: var(--ink); cursor: pointer; transition: transform .08s, box-shadow .08s; }
.look-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--ink); }
.look-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.look-btn.open { background: var(--sun); }
.look-btn small { font-weight: 700; font-size: 12px; white-space: nowrap; }
.look-ic { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--ink); background: var(--cream2); font-size: 18px; font-style: normal; line-height: 1; }
.look-ic.emoji { border: 0; background: none; font-size: 26px; }
.look-pop { position: relative; margin-top: 12px; padding: 8px 10px 10px; background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); animation: lp-in .14s ease-out; }
.look-pop::before { content: ''; position: absolute; top: -11px; left: calc(var(--ax, 30px) - 10px); border: 10px solid transparent; border-top: 0; border-bottom-color: var(--ink); }
.look-pop::after { content: ''; position: absolute; top: -7px; left: calc(var(--ax, 30px) - 7px); border: 7px solid transparent; border-top: 0; border-bottom-color: #fff; }
@keyframes lp-in { from { opacity: 0; transform: translateY(-6px); } }
.lp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.lp-head b { font: 400 17px var(--title); letter-spacing: .5px; }
.lp-cur { font-size: 13px; font-weight: 700; color: var(--ink2); }
.lp-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.lp-opt { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 4px 2px 3px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; color: var(--ink); cursor: pointer; transition: transform .08s; }
.lp-opt:hover { transform: translateY(-2px); }
.lp-opt.on { background: var(--sun); box-shadow: 0 3px 0 var(--ink); }
.lp-opt b { font-size: 24px; line-height: 1.15; font-weight: 400; }
.lp-opt span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.lp-colors { display: flex; flex-wrap: wrap; }
.lp-colors .lp-opt { padding: 3px; border-radius: 50%; }
.lp-opt .dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); }
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.rcard { display: flex; flex-direction: column; align-items: stretch; text-align: left; border: 3px solid var(--ink); border-radius: 14px; background: #fff; padding: 4px 8px 8px; cursor: pointer; font-family: var(--font); color: var(--ink); }
.rcard img, .rcard .ph { width: 100%; height: 96px; object-fit: contain; display: block; }
.rcard b { font-size: 16px; }
.rcard small { font-size: 12px; color: var(--ink2); min-height: 1.4em; }
.rcard.on { background: #fff5c8; box-shadow: 0 3px 0 var(--ink), inset 0 0 0 3px var(--sun); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; margin-top: 4px; }
.stat { display: flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; color: var(--ink2); }
.stat span { width: 28px; flex: none; }
.stat i { flex: 1; height: 7px; border-radius: 4px; background: #e8e0f0; overflow: hidden; border: 1.5px solid var(--ink); }
.stat em { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--sun), var(--coral)); }
.note { font-size: 13px; color: var(--ink2); }
.howto { margin: 4px 0; padding-left: 18px; font-size: 14px; line-height: 1.55; color: var(--ink2); }
.howto b { color: var(--ink); }
.howto .c1 { color: #2a8fd8; } .howto .c2 { color: #e8781a; } .howto .c3 { color: #b03ad8; }

/* ------------------------------------------------------------ the room */
#room { background: linear-gradient(180deg, rgba(255, 138, 61, .45), rgba(140, 92, 255, .6)); overflow-y: auto; }
.room-wrap { max-width: 1200px; margin: 0 auto; padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) calc(16px + var(--safe-b)) calc(14px + var(--safe-l)); min-height: 100%; display: flex; flex-direction: column; gap: 12px; }
.room-head { display: flex; align-items: center; gap: 12px; padding: 8px 12px; flex-wrap: wrap; }
.room-title { flex: 1; min-width: 140px; display: flex; align-items: center; gap: 10px; }
.room-title h2 { margin: 0; font: 400 24px var(--title); letter-spacing: .5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-code { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 700; color: var(--ink2); }
.room-code b { font: 400 28px var(--title); letter-spacing: 4px; color: var(--coral); -webkit-text-stroke: 1.5px var(--ink); }
.room-main { display: grid; grid-template-columns: 1fr 420px; gap: 12px; flex: 1; min-height: 0; }
.grid-col { padding: 10px 12px; align-self: start; }
.grid-col h3, .settings h3, .scores h3 { margin: 0 0 8px; font: 400 22px var(--title); letter-spacing: .5px; }
.grid-col h3 small, .settings h3 small { font: 600 13px var(--font); color: var(--ink2); }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seat { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 3px solid var(--ink); border-radius: 15px; background: #fff; min-height: 66px; position: relative; }
.seat img, .seat .ph { width: 54px; height: 54px; object-fit: contain; flex: none; }
.seat .ph { display: grid; place-items: center; font-size: 30px; }
.seat .who { flex: 1; min-width: 0; }
.seat .who b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .who small { color: var(--ink2); font-size: 12px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .rdy { font-size: 12px; font-weight: 700; color: #a99cb8; flex: none; }
.seat.ready { background: #eaffea; }
.seat.ready .rdy { color: #2f9a3a; }
.seat .pts { position: absolute; right: 8px; bottom: 3px; font-size: 11px; font-weight: 700; color: var(--coral); }
.seat.bot { background: #f6f0ff; color: var(--ink2); }
.seat.empty { background: transparent; border-style: dashed; color: #8b7fa0; justify-content: center; font-weight: 700; }
.seat.me { box-shadow: inset 0 0 0 3px var(--sun); }
.seat .kick { position: absolute; right: 6px; top: 6px; }
.watchers { margin-top: 8px; color: var(--ink2); font-weight: 600; }
.room-side { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.settings { padding: 10px 12px 12px; }
.go-row { display: flex; gap: 8px; margin-top: 8px; }
.go-row .btn.big { font-size: 20px; }
.wait { margin: 8px 0 0; text-align: center; font-weight: 700; color: var(--ink2); }
.scores { padding: 10px 12px; }
.board { margin: 0; padding-left: 22px; }
.board li { padding: 2px 0; }
.board li span { float: right; color: var(--ink2); font-weight: 700; }
.board li.me b { color: var(--coral); }
.last { margin-top: 6px; }
.last small { color: var(--ink2); font-weight: 700; }
.lr { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.lr i { font-style: normal; width: 20px; height: 20px; border-radius: 50%; background: var(--sun); border: 2px solid var(--ink); display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.lr span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr em { font-style: normal; color: var(--ink2); font-size: 12.5px; }
.chatbox { flex: 1; min-height: 200px; display: flex; flex-direction: column; padding: 10px; }
.chatbox .chat-log { flex: 1; overflow-y: auto; font-size: 15px; line-height: 1.45; padding: 2px 4px; min-height: 100px; max-height: 36vh; }
.chatbox .line.sys { color: #8b7fa0; font-size: 13.5px; }
.chatbox form { display: flex; gap: 6px; margin-top: 6px; }
.modal { position: absolute; inset: 0; z-index: 8; background: rgba(34, 22, 58, .6); display: grid; place-items: center; padding: 12px; }
.modal-box { width: min(620px, 100%); max-height: 94%; display: flex; flex-direction: column; padding: 10px 12px; }
.modal-box .tabs { align-items: center; }
.modal-box .close { flex: none; }
.modal-body { overflow-y: auto; margin-top: 8px; }

/* ------------------------------------------------------------ loading and toasts */
.loading { position: absolute; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 14px; background: #ff9a5c; color: #fff; font-weight: 700; font-size: 18px; transition: opacity .3s; text-shadow: 0 2px 0 var(--ink); }
.loading { --loading-accent: var(--ink); }
.loading.gone { opacity: 0; pointer-events: none; }
.spin { width: 56px; height: 56px; border: 7px solid rgba(255, 255, 255, .3); border-top-color: var(--sun); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toasts { position: absolute; left: 50%; top: calc(16px + var(--safe-t)); transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 9px 18px; border: 3px solid var(--ink); border-radius: 14px; background: var(--cream); font-weight: 700; box-shadow: 0 4px 0 var(--ink); animation: toast 3.4s forwards; }
.toast.bad { background: #ffd6dc; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-10px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ------------------------------------------------------------ the race */
#hud { position: absolute; inset: 0; z-index: 5; pointer-events: none; color: #fff; font-family: var(--font); text-shadow: 0 2px 0 rgba(0, 0, 0, .45); }
#hud .speedlines { position: absolute; inset: -10%; opacity: 0; background: repeating-conic-gradient(from 0deg at 50% 46%, rgba(255, 255, 255, .55) 0deg 1.2deg, transparent 1.2deg 9deg); -webkit-mask: radial-gradient(ellipse at 50% 46%, transparent 32%, #000 70%); mask: radial-gradient(ellipse at 50% 46%, transparent 32%, #000 70%); animation: lines .18s steps(2) infinite; transition: opacity .25s; }
@keyframes lines { 50% { transform: rotate(4deg); } }
#hud .ink { position: absolute; inset: 0; opacity: 0; }
#hud .ink i { position: absolute; border-radius: 48% 52% 45% 55% / 55% 45% 55% 45%; background: radial-gradient(circle at 40% 35%, #3a2a4a, #120a1a 70%); box-shadow: 12px 18px 0 -6px #120a1a, -14px -10px 0 -8px #1a1024; }
#hud .ink.on { animation: ink var(--ink, 4.5s) ease-in forwards; }
@keyframes ink { 0% { opacity: 0; transform: scale(.6); } 6% { opacity: .96; transform: scale(1.04); } 10% { transform: none; } 70% { opacity: .9; } 100% { opacity: 0; transform: translateY(6%); } }
.tags { position: absolute; inset: 0; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; font-weight: 700; font-size: 15px; white-space: nowrap; will-change: transform; }
.tag span { padding: 1px 8px; border-radius: 9px; background: rgba(34, 22, 58, .6); }
.h-tl { position: absolute; left: calc(14px + var(--safe-l)); top: calc(10px + var(--safe-t)); display: flex; flex-direction: column; gap: 2px; }
.lap { display: flex; align-items: baseline; gap: 6px; }
.lap small { font-weight: 700; font-size: 15px; }
.lap b { font: 400 40px/1 var(--title); color: var(--sun); -webkit-text-stroke: 2.5px var(--ink); paint-order: stroke fill; }
.clock { font: 400 22px/1 var(--title); letter-spacing: 1px; -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; font-variant-numeric: tabular-nums; }
.itembox { position: absolute; left: 50%; top: calc(8px + var(--safe-t)); transform: translateX(-50%); width: 86px; height: 86px; border: 4px solid var(--ink); border-radius: 22px; background: rgba(255, 247, 230, .5); box-shadow: 0 5px 0 var(--ink), inset 0 0 0 4px rgba(255, 255, 255, .6); display: grid; place-items: center; }
.itembox.full { background: rgba(255, 247, 230, .92); }
.itembox.rolling { animation: shake .12s infinite; }
.itembox.pop { animation: pop .35s ease-out; }
.item-in { font-size: 52px; line-height: 1; text-shadow: none; filter: drop-shadow(0 3px 0 rgba(34, 22, 58, .4)); }
.item-n { position: absolute; right: -10px; bottom: -8px; font: 400 24px var(--title); font-style: normal; color: var(--sun); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.item-key { position: absolute; left: -8px; bottom: -8px; width: 24px; height: 24px; border-radius: 7px; background: #fff; color: var(--ink); text-shadow: none; border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.item-key:empty { display: none; }
@keyframes shake { 50% { transform: translateX(-50%) rotate(4deg); } }
@keyframes pop { 0% { transform: translateX(-50%) scale(1.35); } 100% { transform: translateX(-50%) scale(1); } }
.place { position: absolute; right: calc(16px + var(--safe-r)); top: calc(6px + var(--safe-t)); display: flex; align-items: baseline; --pc: #fff; }
.place b { font: 400 92px/1 var(--title); color: var(--pc); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); font-style: italic; }
.place small { font: 400 28px var(--title); margin-left: 4px; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
.place.bump { animation: bump .35s ease-out; }
@keyframes bump { 0% { transform: scale(1.4) rotate(-6deg); } 100% { transform: none; } }
.standings { position: absolute; left: calc(12px + var(--safe-l)); top: calc(90px + var(--safe-t)); display: flex; flex-direction: column; gap: 3px; }
.st { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; padding: 1px 10px 1px 2px; border-radius: 12px; background: rgba(34, 22, 58, .5); width: fit-content; }
.st i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 12px; border: 2px solid var(--ink); text-shadow: 0 1px 0 rgba(0, 0, 0, .6); }
.st.me { background: rgba(255, 210, 63, .5); outline: 2px solid var(--sun); }
.st.done span::after { content: ' 🏁'; }
.st.gap { background: none; padding: 0 0 0 9px; font-size: 13px; line-height: .7; color: rgba(255, 255, 255, .85); text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.minimap { position: absolute; left: calc(10px + var(--safe-l)); bottom: calc(10px + var(--safe-b)); width: 190px; height: 190px; border-radius: 20px; background: rgba(34, 22, 58, .3); }
.speedo { position: absolute; right: calc(18px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); text-align: right; }
.speedo b { font: 400 54px/1 var(--title); -webkit-text-stroke: 2.5px var(--ink); paint-order: stroke fill; font-variant-numeric: tabular-nums; }
.speedo small { font-weight: 700; margin-left: 4px; }
.spark-bar { width: 140px; height: 10px; margin: 4px 0 0 auto; border-radius: 6px; background: rgba(34, 22, 58, .55); border: 2px solid var(--ink); overflow: hidden; }
.spark-bar i { display: block; height: 100%; width: 0; background: #bfe8ff; transition: width .08s; }
.spark-bar i.t1 { background: #4fc3ff; } .spark-bar i.t2 { background: #ff9a2e; } .spark-bar i.t3 { background: linear-gradient(90deg, #d65cff, #ff5ad1); }
.count { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); font: 400 130px var(--title); color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); opacity: 0; }
.count.go { color: #7cf07c; }
.count.on { animation: count 1s ease-out forwards; }
@keyframes count { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1.7); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; } }
.announce { position: absolute; left: 0; right: 0; top: 24%; text-align: center; opacity: 0; transform: scale(.7); transition: opacity .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.announce.on { opacity: 1; transform: none; }
.announce .big { font: 400 clamp(36px, 6.5vw, 72px)/1.05 var(--title); color: var(--sun); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ink); letter-spacing: 2px; }
.announce .small { margin-top: 6px; font-weight: 700; font-size: 20px; }
.announce.good .big { color: #7cf07c; } .announce.bad .big { color: #ff8a95; } .announce.final .big { color: #ff9f1c; animation: wobble .7s ease-in-out infinite; }
.wrongway { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); font: 400 34px var(--title); color: #ff5d6d; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; opacity: 0; }
.wrongway.on { opacity: 1; animation: pulse .4s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: translateX(-50%) scale(1.1); } }
.spec { position: absolute; left: 50%; bottom: calc(16px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 14px; background: rgba(34, 22, 58, .75); font-weight: 700; font-size: 17px; pointer-events: auto; }
/* in the sky: the bottle rockets in hand and the sights */
.ammo { position: absolute; left: 50%; top: calc(104px + var(--safe-t)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 3px 10px 5px; border: 3px solid var(--ink); border-radius: 14px; background: rgba(34, 22, 58, .5); }
.ammo[hidden] { display: none; }
.ammo-pips { display: flex; gap: 4px; }
.ammo-pips i { font-style: normal; font-size: 24px; line-height: 1.1; filter: grayscale(1) brightness(.6); opacity: .45; transition: opacity .15s, filter .15s, transform .15s; }
.ammo-pips i.on { filter: drop-shadow(0 2px 0 rgba(34, 22, 58, .6)); opacity: 1; }
.ammo b { display: block; width: 74px; height: 6px; border-radius: 4px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.ammo s { display: block; height: 100%; width: 0; background: var(--sun); text-decoration: none; }
.ammo.shot { animation: ammoshot .25s ease-out; }
@keyframes ammoshot { 0% { scale: 1.15; } 100% { scale: 1; } }
.reticle { position: absolute; left: 0; top: 0; width: 64px; height: 64px; will-change: transform; }
.reticle[hidden] { display: none; }
.reticle i { position: absolute; inset: 0; border: 4px solid #ff4d5e; border-radius: 50%; box-shadow: 0 0 0 3px var(--ink), inset 0 0 0 3px var(--ink); animation: lockspin 2.4s linear infinite; -webkit-mask: conic-gradient(#000 0 60deg, transparent 60deg 90deg, #000 90deg 150deg, transparent 150deg 180deg, #000 180deg 240deg, transparent 240deg 270deg, #000 270deg 330deg, transparent 330deg); mask: conic-gradient(#000 0 60deg, transparent 60deg 90deg, #000 90deg 150deg, transparent 150deg 180deg, #000 180deg 240deg, transparent 240deg 270deg, #000 270deg 330deg, transparent 330deg); }
.reticle.new i { animation: lockin .3s ease-out, lockspin 2.4s linear .3s infinite; }
@keyframes lockspin { to { transform: rotate(360deg); } }
@keyframes lockin { 0% { transform: scale(2); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
/* a short screen: the rockets beside the item box, out of the announcements' way */
html.short .ammo { top: calc(12px + var(--safe-t)); left: calc(50% + 42px); transform: none; }
html.short #hud.touchy .ammo { left: calc(50% + 2px); }
html.short .ammo-pips i { font-size: 19px; }
#hud.watching .itembox, #hud.watching .speedo, #hud.watching .touch, #hud.watching .ammo, #hud.watching .reticle { display: none !important; }
#hud .chat { position: absolute; left: calc(212px + var(--safe-l)); bottom: calc(12px + var(--safe-b)); width: min(380px, 40%); }
#hud .chat-log .line { font-size: 14px; font-weight: 600; padding: 1px 8px; border-radius: 8px; background: rgba(34, 22, 58, .5); margin-top: 3px; width: fit-content; max-width: 100%; transition: opacity 1s; }
#hud .chat-log .line.sys { color: #e6dcf2; font-size: 13px; }
#hud .chat-log .line.old { opacity: 0; }
#hud.chatting .chat-log .line.old { opacity: 1; }
.chat-in { pointer-events: auto; width: 100%; margin-top: 6px; padding: 7px 12px; border: 3px solid var(--ink); border-radius: 12px; font-size: 16px; color: var(--ink); background: #fff; outline: none; }
.results { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(34, 22, 58, .55); pointer-events: auto; overflow-y: auto; }
.res-in { text-align: center; padding: 12px; }
.res-title { font: 400 clamp(44px, 8vw, 92px)/1 var(--title); color: #e8e0f4; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); letter-spacing: 3px; animation: wobble 2.2s ease-in-out infinite; }
.res-title.win { color: var(--sun); }
.results table { margin: 12px auto 0; border-collapse: separate; border-spacing: 0 4px; font-weight: 700; font-size: 17px; }
.res-cols { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; column-gap: 18px; }
.res-cols table { margin: 12px 0 0; }
.res-in.many .results table, .res-in.many table { font-size: 14px; border-spacing: 0 2px; }
.res-in.many td { padding: 2px 9px; }
.res-in.many td.pl { font-size: 18px; }
.res-in.many td.nm { min-width: 110px; }
.results td { padding: 4px 12px; background: rgba(34, 22, 58, .78); }
.results td:first-child { border-radius: 12px 0 0 12px; } .results td:last-child { border-radius: 0 12px 12px 0; }
.results td.pl { font: 400 24px var(--title); color: var(--sun); }
.results td.nm { text-align: left; min-width: 150px; }
.results td.tm { font-variant-numeric: tabular-nums; color: #e6dcf2; }
.results td.pt { color: #7cf07c; }
.results tr.me td { background: rgba(255, 170, 40, .85); }
.res-back { margin-top: 12px; font-weight: 700; opacity: .9; }
.pause { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(34, 22, 58, .55); pointer-events: auto; }
.pause-box { width: min(440px, 92%); max-height: 94%; overflow-y: auto; padding: 16px 18px; border: 4px solid var(--ink); border-radius: 22px; background: var(--cream); color: var(--ink); text-shadow: none; box-shadow: 0 8px 0 var(--ink); display: flex; flex-direction: column; gap: 6px; }
.pause-box h2 { margin: 0; font: 400 30px var(--title); }
.pause-note { margin: 0; font-weight: 600; color: var(--ink2); }
.keys { font-size: 13px; color: var(--ink2); line-height: 1.5; margin: 4px 0; }

/* touch: a steering pad on the left, buttons under the right thumb */
.touch { position: absolute; inset: 0; pointer-events: auto; touch-action: none; --b: clamp(58px, 17vh, 86px); --d: clamp(84px, 26vh, 124px); }
.t-steer { position: absolute; left: 0; top: 30%; bottom: 0; width: 50%; }
.t-steer .t-track { position: absolute; left: calc(var(--safe-l) + 30px); bottom: 22%; width: 200px; height: 18px; border-radius: 10px; background: rgba(34, 22, 58, .35); border: 3px solid rgba(255, 255, 255, .5); }
.t-steer .t-knob { position: absolute; left: calc(var(--safe-l) + 30px + 100px - 45px); bottom: calc(22% - 22px); width: 90px; height: 60px; border-radius: 22px; background: rgba(255, 247, 230, .85); border: 3px solid var(--ink); color: var(--ink); text-shadow: none; display: grid; place-items: center; font-weight: 700; font-size: 16px; transition: transform .05s; }
.t-steer.on .t-track, .t-steer.on .t-knob { left: calc(var(--x) - 100px); }
.t-steer.on .t-knob { left: calc(var(--x) - 45px); background: var(--sun); }
.touch.tilting .t-steer { display: none; }
.t-recenter { position: absolute; left: calc(var(--safe-l) + 30px); bottom: 22%; text-shadow: none; }
.t-btn { position: absolute; width: var(--b); height: var(--b); border-radius: 50%; border: 3px solid var(--ink); background: rgba(255, 247, 230, .82); color: var(--ink); text-shadow: none; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; box-shadow: 0 4px 0 var(--ink); }
.t-btn b { font-size: 15px; } .t-btn small { font-size: 11px; font-weight: 700; color: var(--ink2); }
.t-btn.on { background: var(--sun); transform: translateY(3px) scale(.95); box-shadow: 0 1px 0 var(--ink); }
.t-drift { right: calc(3vw + var(--safe-r)); bottom: calc(6vh + var(--safe-b)); width: var(--d); height: var(--d); background: rgba(255, 93, 143, .88); }
.t-drift b { color: #fff; font-size: 20px; text-shadow: 0 2px 0 var(--ink); } .t-drift small { color: #fff; }
.t-item { right: calc(3vw + var(--d) + 3vw + var(--safe-r)); bottom: calc(6vh + var(--d) * .55 + var(--safe-b)); background: rgba(92, 200, 255, .9); }
.t-back { right: calc(3vw + var(--d) + 3vw + var(--b) + 2vw + var(--safe-r)); bottom: calc(6vh + var(--d) * .9 + var(--safe-b)); width: calc(var(--b) * .78); height: calc(var(--b) * .78); }
.t-back b { font-size: 12px; }
.t-brake { right: calc(3vw + var(--d) + 3vw + var(--safe-r)); bottom: calc(4vh + var(--safe-b) - var(--b) * .25); width: calc(var(--b) * .85); height: calc(var(--b) * .85); }
.t-gas { right: calc(3vw + var(--safe-r) + (var(--d) - var(--b)) / 2); bottom: calc(6vh + var(--d) + 4vh + var(--safe-b)); background: rgba(91, 217, 106, .9); }
.t-top { position: absolute; right: calc(120px + var(--safe-r)); top: calc(8px + var(--safe-t)); display: flex; gap: 8px; }
.t-mini { width: 46px; height: 46px; border-radius: 14px; border: 3px solid var(--ink); background: rgba(255, 247, 230, .85); font-size: 20px; padding: 0; box-shadow: 0 3px 0 var(--ink); }
.t-mini.on { background: var(--sun); }
#hud.touchy .minimap { width: 120px; height: 120px; left: auto; right: calc(10px + var(--safe-r)); bottom: auto; top: calc(96px + var(--safe-t)); }
#hud.touchy .speedo { display: none; }
#hud.touchy .chat { left: calc(12px + var(--safe-l)); bottom: auto; top: 46%; width: 34%; }
#hud.touchy .chat-in { display: none; }
#hud.touchy .standings { top: calc(80px + var(--safe-t)); }
#hud.touchy .st { font-size: 12px; } #hud.touchy .st i { width: 18px; height: 18px; font-size: 10px; }
#hud.touchy .itembox, #hud.touchy .ammo { left: calc(50% - 40px); }

/* ------------------------------------------------------------ smaller screens */
@media (max-width: 980px) {
  .room-main { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .menu-panel { width: min(430px, 60%); }
  .logo h1 { font-size: 46px; }
  .logo p { font-size: 14px; }
  .tracks { grid-template-columns: repeat(4, 1fr); }
}
/* short screens (landscape phones, and phones turned sideways): everything smaller; screen.js sets html.short */
html.short .logo { top: calc(46px + var(--safe-t)); left: calc(18px + var(--safe-l)); }
html.short .logo h1 { font-size: 44px; -webkit-text-stroke: 4px var(--ink); text-shadow: 0 5px 0 var(--ink); }
html.short .logo p { margin-top: 8px; font-size: 13px; }
html.short .garage-hint { display: none; }
html.short .menu-panel { top: calc(8px + var(--safe-t)); bottom: calc(8px + var(--safe-b)); right: calc(8px + var(--safe-r)); width: min(440px, 58%); padding: 8px 10px; border-width: 3px; border-radius: 18px; box-shadow: 0 5px 0 var(--ink); }
html.short .tab { padding: 5px 4px; font-size: 15px; border-radius: 11px; }
html.short .tab[data-tab="opts"] { flex-basis: 40px; }
html.short .card { padding: 8px 10px; margin-top: 8px; }
html.short .card h2 { font-size: 18px; margin-bottom: 4px; }
html.short .row { margin: 5px 0; gap: 6px; }
html.short .seg button { padding: 3px 8px; font-size: 13px; } html.short .seg.many button { padding: 3px 5px; min-width: 26px; }
html.short .btn { padding: 6px 12px; font-size: 14px; }
html.short .btn.primary { font-size: 16px; }
html.short .btn.big { padding: 8px 16px; font-size: 18px; }
html.short .field input, html.short .join input, html.short #chat-in { padding: 5px 9px; font-size: 15px; }
html.short .tcard span { font-size: 11px; }
html.short .animals { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
html.short .animal img, html.short .animal .ph { width: 52px; height: 52px; }
html.short .rgrid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
html.short .rcard img, html.short .rcard .ph { height: 70px; }
html.short .room-wrap { gap: 8px; padding-top: calc(8px + var(--safe-t)); }
html.short .room-head { padding: 5px 10px; gap: 8px; }
html.short .room-title h2 { font-size: 19px; }
html.short .room-code b { font-size: 22px; }
html.short .room-main { grid-template-columns: 1fr 1fr; gap: 8px; }
html.short .seats { grid-template-columns: 1fr 1fr; gap: 5px; }
html.short .seat { min-height: 48px; padding: 3px 6px; }
html.short .seat img, html.short .seat .ph { width: 40px; height: 40px; }
html.short .grid-col h3, html.short .settings h3, html.short .scores h3 { font-size: 18px; margin-bottom: 4px; }
html.short .chatbox { min-height: 150px; }
html.short .lap b { font-size: 30px; }
html.short .clock { font-size: 17px; }
html.short .itembox { width: 66px; height: 66px; border-radius: 18px; }
html.short .item-in { font-size: 38px; }
html.short .place b { font-size: 64px; }
html.short .place small { font-size: 20px; }
html.short .count { font-size: 96px; }
html.short .announce .small { font-size: 16px; }
html.short .results table { font-size: 14px; }
html.short .results td { padding: 2px 8px; }
html.short .res-title { font-size: 44px; }
html.short .res-in.many table { font-size: 12.5px; } html.short .res-in.many td { padding: 1px 7px; } html.short .res-in.many td.pl { font-size: 15px; } html.short .res-in.many .res-title { font-size: 34px; }
html.short #hud .minimap { width: 120px; height: 120px; left: auto; right: calc(10px + var(--safe-r)); bottom: auto; top: calc(78px + var(--safe-t)); }
html.short #hud .standings { top: calc(70px + var(--safe-t)); }
html.short #hud .st { font-size: 11.5px; padding-right: 7px; } html.short #hud .st i { width: 17px; height: 17px; font-size: 10px; }
html.short #hud .speedo b { font-size: 38px; }
html.short #hud .spark-bar { width: 100px; }
