/* Lumba Balik Kampung: "Malaysian highway at sunset".
   Menus are green highway signboards, actions are toll-sign yellow, Ready is a toll lane light.
   Type: Overpass (open font based on highway sign lettering). */

@font-face { font-family: 'Overpass'; font-weight: 600; font-style: normal; font-display: swap; src: url('/fonts/overpass-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Overpass'; font-weight: 800; font-style: normal; font-display: swap; src: url('/fonts/overpass-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'Overpass'; font-weight: 900; font-style: normal; font-display: swap; src: url('/fonts/overpass-latin-900-normal.woff2') format('woff2'); }
@font-face { font-family: 'Overpass'; font-weight: 900; font-style: italic; font-display: swap; src: url('/fonts/overpass-latin-900-italic.woff2') format('woff2'); }

:root {
  --sign: #0b6e4f; /* highway sign green */
  --sign-deep: #074d37;
  --toll: #ffc93c; /* toll sign yellow */
  --toll-deep: #c99100;
  --coral: #ff6b4a; /* sunset, alerts */
  --dusk: #2e1f4f; /* night sky, Ghost */
  --ink: #1b1a2e;
  --line: #ffffff;
  --lamp-on: #36e27b;
  --lamp-off: #ff4d4d;
  --font: 'Overpass', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-weight: 600;
  color: #fff;
  background: var(--dusk);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button, input { font-family: inherit; }
:focus-visible { outline: 3px solid var(--toll); outline-offset: 2px; }

/* ---------- sunset scene behind menus ---------- */
.scene {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: linear-gradient(#3b2a6b 0%, #8e3d77 34%, #ff7e5f 62%, #ffc26b 82%);
}
.sun { position: absolute; left: 62%; bottom: 23%; width: 22vmin; height: 22vmin; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #fff6c9, #ffd46b 60%, #ff9a4d); box-shadow: 0 0 80px 30px rgba(255, 196, 107, 0.45); }
.scene svg { position: absolute; left: 0; width: 100%; }
.far { bottom: 15%; height: 18%; fill: #7a3f7f; opacity: 0.8; }
.near { bottom: 11%; height: 26%; }
.near .hill { fill: #3c2457; }
.near .palm, .near .house { fill: #2a173f; }
.road { position: absolute; left: 0; right: 0; bottom: 0; height: 12%; background: #2b2b3a; border-top: 4px solid #ffc93c; }
.dashes { position: absolute; left: 0; right: 0; top: 46%; height: 5px;
  background: repeating-linear-gradient(90deg, #fff 0 48px, transparent 48px 104px); opacity: 0.8; }
.mini-car { position: absolute; bottom: 52%; left: -80px; width: 70px; height: 30px;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 30'%3E%3Cpath d='M4 22v-7a4 4 0 0 1 4-4h6l9-9h22l10 9h7a4 4 0 0 1 4 4v7z' fill='%23ff6b4a'/%3E%3Cpath d='M25 10l6-6h7v6zM41 10V4h4l6 6z' fill='%23dff3ff'/%3E%3Ccircle cx='17' cy='23' r='6' fill='%231b1a2e'/%3E%3Ccircle cx='53' cy='23' r='6' fill='%231b1a2e'/%3E%3Ccircle cx='17' cy='23' r='2.4' fill='%23ccc'/%3E%3Ccircle cx='53' cy='23' r='2.4' fill='%23ccc'/%3E%3C/svg%3E");
  animation: drive 9s linear infinite; }
@keyframes drive { to { transform: translateX(calc(100vw + 160px)); } }
@media (prefers-reduced-motion: reduce) { .mini-car { animation: none; left: 12%; } }
body.racing .scene { display: none; }

/* ---------- signs ---------- */
.sign {
  background: var(--sign);
  border: 3px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 0 0 4px var(--sign), 0 14px 30px rgba(20, 8, 40, 0.35);
  padding: 16px 18px;
  margin: 4px;
}
.sign h3 { margin: 0 0 10px; font-size: 17px; font-weight: 900; letter-spacing: 0.2px; }

/* ---------- menu screens (home / join) ---------- */
.screen { min-height: 100vh; min-height: 100dvh; padding: 18px 16px 15vh; margin: 0 auto; }
.menu { max-width: 980px; display: grid; gap: 22px; align-content: center; }
.hero { display: grid; gap: 14px; justify-items: start; }
.title-sign { padding: 18px 24px 16px; transform: rotate(-1.2deg); }
.title-sign h1 { margin: 0; font-weight: 900; font-size: clamp(34px, 7vw, 60px); line-height: 0.98; letter-spacing: -0.5px; }
.title-sign.small h1 { font-size: clamp(28px, 6vw, 46px); }
.dest { display: flex; align-items: baseline; gap: 10px; margin-top: 10px; font-size: clamp(16px, 2.6vw, 22px); font-weight: 800; }
.dest b { background: var(--toll); color: var(--ink); padding: 1px 10px 0; border-radius: 6px; font-weight: 900; }
.dest-arrow { font-size: 1.2em; }
.hero-line { margin: 0; max-width: 34ch; font-size: 18px; line-height: 1.45; text-shadow: 0 2px 10px rgba(46, 31, 79, 0.6); }
.form-sign { display: grid; gap: 12px; align-self: center; width: 100%; max-width: 440px; justify-self: center; }
label { display: block; font-weight: 800; font-size: 14px; }
.opt { font-weight: 600; opacity: 0.75; }
input {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font-size: 17px; font-weight: 800;
  border: 0; border-radius: 10px; background: #fff; color: var(--ink);
  box-shadow: inset 0 -3px 0 #d5e3dc;
}
input::placeholder { color: #8b97a0; font-weight: 600; }
input:focus { outline: 3px solid var(--toll); outline-offset: 0; }
.link { color: #fff; text-align: center; font-weight: 800; }
.err { color: #ffe0d6; background: rgba(255, 107, 74, 0.25); border-radius: 8px; margin: 0; font-size: 14px; padding: 0 10px; min-height: 0; }
.err:not(:empty) { padding: 8px 10px; }
.hint { font-size: 13px; opacity: 0.85; margin: 8px 0 0; line-height: 1.4; }
.muted { opacity: 0.7; font-weight: 600; }
@media (min-width: 760px) and (orientation: landscape), (min-width: 900px) {
  .menu { grid-template-columns: 1.15fr 1fr; align-items: center; }
}

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 12px; padding: 12px 18px; font-size: 16px; font-weight: 900; cursor: pointer;
  color: var(--ink); background: #fff; box-shadow: 0 4px 0 #b9c7c0; transition: transform 0.06s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b9c7c0; }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn.primary { background: var(--toll); box-shadow: 0 5px 0 var(--toll-deep); }
.btn.primary:active { box-shadow: 0 2px 0 var(--toll-deep); }
.btn.wa { background: #25d366; color: #052e17; box-shadow: 0 5px 0 #128c4a; }
.btn.ghost { background: rgba(255, 255, 255, 0.14); color: #fff; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55); }
.btn.ghost:active { box-shadow: inset 0 0 0 2px #fff; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn.big { width: 100%; padding: 16px; font-size: 20px; }
/* Ready: a toll lane light that turns green */
.btn.ready { background: var(--toll); box-shadow: 0 5px 0 var(--toll-deep); display: flex; align-items: center; justify-content: center; gap: 12px; }
.btn.ready::before { content: ''; width: 18px; height: 18px; border-radius: 50%; background: var(--lamp-off); box-shadow: 0 0 0 3px var(--ink), 0 0 12px var(--lamp-off); }
.btn.ready.on { background: #12291f; color: #d7ffe6; box-shadow: 0 5px 0 #050e0a, inset 0 0 0 2px var(--lamp-on); }
.btn.ready.on::before { background: var(--lamp-on); box-shadow: 0 0 0 3px #050e0a, 0 0 16px var(--lamp-on); }
.row { display: flex; gap: 8px; }
.row > .btn { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > .btn { flex: 1 1 auto; }
.col { display: flex; flex-direction: column; gap: 14px; }
.col-gap { display: flex; flex-direction: column; gap: 12px; }

/* ---------- lobby ---------- */
.screen.wide { max-width: 1000px; padding-bottom: 14vh; }
.bar { display: flex; align-items: center; gap: 10px; margin: 2px 4px 14px; }
.bar-title { flex: 1; min-width: 0; }
.room-name { font-size: clamp(24px, 4vw, 34px); font-weight: 900; line-height: 1.05; text-shadow: 0 3px 0 rgba(46, 31, 79, 0.5); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { font-size: 14px; opacity: 0.9; }
.lobby-grid { display: grid; gap: 14px; }
.lobby-grid > *, .col > * { min-width: 0; } /* long rows (quick chat) scroll inside, not the page */
html, body { overflow-x: hidden; }
.ready-card { text-align: center; }
/* place picker: three little posters */
.place-title { text-align: left; }
.places { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.place { position: relative; border: 0; padding: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 10; cursor: pointer; color: #fff; text-align: left;
  background-size: cover; background-position: center bottom; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35); }
.place span { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; font-weight: 900; font-size: 12px; line-height: 1.1;
  background: linear-gradient(transparent, rgba(27, 26, 46, 0.85)); }
.place[aria-checked='true'] { box-shadow: 0 0 0 3px var(--toll), 0 0 14px rgba(255, 201, 60, 0.7); }
.place[aria-checked='true']::after { content: '✓'; position: absolute; top: 4px; right: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--toll); color: var(--ink); font-weight: 900; font-size: 13px; display: grid; place-items: center; }
.place:disabled { cursor: default; }
.place:disabled:not([aria-checked='true']) { opacity: 0.55; }
.place.kl { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 100'%3E%3Cdefs%3E%3ClinearGradient id='s' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%231d1b4b'/%3E%3Cstop offset='.6' stop-color='%23b2457a'/%3E%3Cstop offset='1' stop-color='%23ff9a5a'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='160' height='100' fill='url(%23s)'/%3E%3Cg fill='%23292355'%3E%3Crect x='6' y='52' width='16' height='48'/%3E%3Crect x='26' y='40' width='14' height='60'/%3E%3Cpath d='M58 100V30q4-10 8 0v70zM72 100V30q4-10 8 0v70z'/%3E%3Cpath d='M68 24l0-12 1 0 0 12zM76 24l0-12 1 0 0 12z'/%3E%3Crect x='96' y='46' width='18' height='54'/%3E%3Cpath d='M128 100V40h6v-8h2v-14h1v14h2v8h6v60z'/%3E%3Crect x='148' y='56' width='12' height='44'/%3E%3C/g%3E%3Cg fill='%23ffd56b'%3E%3Crect x='9' y='58' width='3' height='3'/%3E%3Crect x='15' y='66' width='3' height='3'/%3E%3Crect x='29' y='48' width='3' height='3'/%3E%3Crect x='34' y='60' width='3' height='3'/%3E%3Crect x='61' y='44' width='2' height='3'/%3E%3Crect x='75' y='54' width='2' height='3'/%3E%3Crect x='100' y='54' width='3' height='3'/%3E%3Crect x='106' y='64' width='3' height='3'/%3E%3C/g%3E%3Cpath d='M0 84h160v16H0z' fill='%2333334a'/%3E%3Cpath d='M0 84h160v2H0z' fill='%23ffc93c'/%3E%3C/svg%3E"); }
.place.karak { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 100'%3E%3Cdefs%3E%3ClinearGradient id='s' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%239fd8d4'/%3E%3Cstop offset='1' stop-color='%23eef7f2'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='160' height='100' fill='url(%23s)'/%3E%3Cpath d='M0 60l30-30 22 18 30-34 28 26 22-14 28 22v52H0z' fill='%2389b8b0'/%3E%3Crect y='50' width='160' height='8' fill='%23fff' opacity='.6'/%3E%3Cpath d='M0 74l24-18 26 12 30-20 30 18 24-12 26 16v30H0z' fill='%234f8f6f'/%3E%3Cg fill='%23356b4e'%3E%3Ccircle cx='14' cy='80' r='10'/%3E%3Ccircle cx='34' cy='78' r='12'/%3E%3Ccircle cx='120' cy='79' r='11'/%3E%3Ccircle cx='146' cy='81' r='10'/%3E%3C/g%3E%3Cpath d='M0 86l160-8v22H0z' fill='%2340404f'/%3E%3Cpath d='M0 86l160-8v2L0 88z' fill='%23c9d1d9'/%3E%3C/svg%3E"); }
.place.kampung { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 100'%3E%3Cdefs%3E%3ClinearGradient id='s' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%234fb3f0'/%3E%3Cstop offset='1' stop-color='%23e6f6ff'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='160' height='100' fill='url(%23s)'/%3E%3Cpath d='M0 64q40-22 80-6t80-8v50H0z' fill='%2378c060'/%3E%3Cg fill='%2399d36b'%3E%3Crect y='70' width='160' height='3'/%3E%3Crect y='76' width='160' height='3'/%3E%3C/g%3E%3Cg transform='translate(104 50)'%3E%3Crect x='-12' y='16' width='2' height='10' fill='%235b3a1e'/%3E%3Crect x='10' y='16' width='2' height='10' fill='%235b3a1e'/%3E%3Crect x='-14' y='4' width='28' height='14' fill='%23b7793f'/%3E%3Cpath d='M-19 5h38L0-9z' fill='%237c2d12'/%3E%3C/g%3E%3Cpath d='M30 82l2-40h2l2 40z' fill='%238b5a2b'/%3E%3Cpath d='M33 42c-10-2-17 2-21 8 7-3 13-4 21-5zM33 42c10-3 18 1 22 6-8-3-14-3-22-4zM33 42c-4-7-11-9-17-8 6 2 11 5 16 9z' fill='%232f855a'/%3E%3Cpath d='M0 84q80-6 160 0v16H0z' fill='%239a6436'/%3E%3Cellipse cx='60' cy='91' rx='14' ry='3' fill='%235c3a1e'/%3E%3Cellipse cx='126' cy='93' rx='10' ry='2.5' fill='%235c3a1e'/%3E%3C/svg%3E"); }
.ready-status { font-weight: 800; font-size: 16px; margin-bottom: 12px; }
.players { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.players li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(0, 0, 0, 0.18); border-radius: 10px; }
.players li.off { opacity: 0.45; }
/* the player's car, painted in their colour */
.players .dot { width: 34px; height: 16px; flex: none; border-radius: 0;
  -webkit-mask: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 30'%3E%3Cpath d='M4 22v-7a4 4 0 0 1 4-4h6l9-9h22l10 9h7a4 4 0 0 1 4 4v7zM11 23a6 6 0 1 0 12 0 6 6 0 1 0-12 0M47 23a6 6 0 1 0 12 0 6 6 0 1 0-12 0'/%3E%3C/svg%3E");
          mask: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 30'%3E%3Cpath d='M4 22v-7a4 4 0 0 1 4-4h6l9-9h22l10 9h7a4 4 0 0 1 4 4v7zM11 23a6 6 0 1 0 12 0 6 6 0 1 0-12 0M47 23a6 6 0 1 0 12 0 6 6 0 1 0-12 0'/%3E%3C/svg%3E"); }
.players .nm { flex: 1; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players .rd { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; opacity: 0.85; }
.players .rd::before { content: ''; width: 11px; height: 11px; border-radius: 50%; background: var(--lamp-off); box-shadow: 0 0 6px var(--lamp-off); }
.players .rd.yes { opacity: 1; color: #d7ffe6; }
.players .rd.yes::before { background: var(--lamp-on); box-shadow: 0 0 8px var(--lamp-on); }
.players .kick { background: rgba(255, 255, 255, 0.12); border: 0; color: #fff; border-radius: 8px; padding: 4px 8px; font-weight: 800; cursor: pointer; }
.host-tools { display: flex; flex-direction: column; gap: 10px; }
.share-link { font-weight: 800; font-size: 15px; background: #fff; color: var(--sign-deep); padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; word-break: break-all; }
.chat-log { height: 190px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; background: rgba(0, 0, 0, 0.22); border-radius: 10px; font-size: 15px; line-height: 1.35; }
.chat-log .msg b { color: var(--toll); }
.chat-log .sys { opacity: 0.7; font-size: 13px; }
.quick { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; scrollbar-width: none; }
.quick button, .quick-pop button { flex: none; border: 0; background: #fff; color: var(--ink); border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 800; cursor: pointer; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { margin: 0; }
.board, .results { margin: 0; padding-left: 26px; }
.board li { padding: 5px 0; font-weight: 800; }

/* ---------- results ---------- */
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 0 0 18px; }
.podium .step { width: min(30%, 170px); text-align: center; }
.podium .car { height: 30px; margin: 0 auto 6px; width: 64px;
  -webkit-mask: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 30'%3E%3Cpath d='M4 22v-7a4 4 0 0 1 4-4h6l9-9h22l10 9h7a4 4 0 0 1 4 4v7zM11 23a6 6 0 1 0 12 0 6 6 0 1 0-12 0M47 23a6 6 0 1 0 12 0 6 6 0 1 0-12 0'/%3E%3C/svg%3E");
          mask: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 70 30'%3E%3Cpath d='M4 22v-7a4 4 0 0 1 4-4h6l9-9h22l10 9h7a4 4 0 0 1 4 4v7zM11 23a6 6 0 1 0 12 0 6 6 0 1 0-12 0M47 23a6 6 0 1 0 12 0 6 6 0 1 0-12 0'/%3E%3C/svg%3E"); }
.podium .pname { font-weight: 900; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 2px 6px rgba(46, 31, 79, 0.7); }
.podium .block { margin-top: 6px; border-radius: 10px 10px 0 0; background: var(--toll); color: var(--ink); font-weight: 900; font-size: 30px; display: grid; place-items: center; box-shadow: inset 0 -6px 0 var(--toll-deep); }
.podium .p1 .block { height: 92px; }
.podium .p2 .block { height: 66px; background: #e7eef0; box-shadow: inset 0 -6px 0 #b6c4c8; }
.podium .p3 .block { height: 48px; background: #f0b27a; box-shadow: inset 0 -6px 0 #c47f45; }
.results li { padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.15); }
.results li.me { background: rgba(255, 201, 60, 0.18); border-radius: 8px; padding-left: 6px; }
.results .r-name { font-weight: 900; }
.results .r-meta { font-size: 13px; opacity: 0.85; }
.fun { display: grid; gap: 6px; margin-bottom: 12px; font-size: 16px; font-weight: 800; }

/* ---------- landscape lobby ---------- */
@media (orientation: landscape) and (min-width: 640px) {
  .lobby-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  #l-orient { display: none; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .screen { padding: 10px 16px 10vh; }
  .menu { gap: 14px; }
  .sign { padding: 12px 14px; }
  .hero-line { font-size: 15px; }
  .title-sign h1 { font-size: 36px; }
  .players li { padding: 6px 10px; }
  .chat-log { height: 140px; }
  .podium .p1 .block { height: 64px; }
  .podium .p2 .block { height: 46px; }
  .podium .p3 .block { height: 34px; }
}

/* ---------- race HUD ---------- */
#s-race { position: fixed; inset: 0; padding: 0; max-width: none; min-height: 0; overflow: hidden; background: #ffb470; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#game { position: absolute; inset: 0; }
#game canvas { display: block; }
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud-top { position: absolute; top: max(8px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); display: flex; align-items: center; gap: 12px; }
/* position: a route-number shield */
.pos { flex: none; min-width: 64px; padding: 6px 10px 10px; text-align: center; font-weight: 900; font-size: 20px; color: var(--ink);
  background: var(--toll); border: 3px solid var(--ink); clip-path: polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%); }
/* progress: a little road to the kampung */
.prog { position: relative; flex: 1; height: 30px; }
.prog-line { position: absolute; left: 0; right: 24px; top: 9px; height: 12px; background: #2b2b3a; border-radius: 6px; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
  background-image: repeating-linear-gradient(90deg, transparent 0 10px, rgba(255, 255, 255, 0.7) 10px 18px); background-size: 100% 2px; background-repeat: repeat-x; background-position: 0 5px; }
.prog-end { position: absolute; right: 0; top: 2px; font-size: 20px; }
.prog .pd { position: absolute; top: 9px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; border: 2px solid #fff; transition: left 0.1s linear; }
.prog .pd.me { width: 20px; height: 20px; top: 5px; margin-left: -10px; border: 3px solid var(--ink); box-shadow: 0 0 0 2px #fff; z-index: 2; }
.prog .pd.gh { opacity: 0.35; }
.warn { flex: none; width: 34px; height: 30px; display: grid; place-items: end center; padding-bottom: 2px; font-weight: 900; font-size: 18px; color: var(--ink);
  background: var(--toll); clip-path: polygon(50% 0, 100% 100%, 0 100%); animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.ghost-list { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 46px); right: 12px; font-size: 13px; font-weight: 800; text-shadow: 0 1px 3px #000; text-align: right; max-width: 45%; }
.r-chat { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 54px); left: max(10px, env(safe-area-inset-left)); max-width: 55%; display: flex; flex-direction: column; gap: 4px; }
.r-chat div { background: rgba(27, 26, 46, 0.7); font-size: 14px; padding: 4px 10px; border-radius: 8px; transition: opacity 0.6s; width: fit-content; }
.r-chat div b { color: var(--toll); }
.countdown { position: absolute; top: 18%; left: 0; right: 0; text-align: center; font-size: 110px; font-weight: 900; font-style: italic; color: var(--toll);
  -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); }
.countdown.pop { animation: pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes pop { from { transform: scale(1.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.banner { position: absolute; top: 22%; left: 50%; transform: translateX(-50%); max-width: 80%; text-align: center; font-weight: 900; font-size: 18px;
  background: var(--sign); border: 3px solid #fff; box-shadow: 0 0 0 3px var(--sign), 0 10px 24px rgba(0, 0, 0, 0.3); border-radius: 12px; padding: 8px 16px; }
.tap-hint { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 52px); left: 50%; transform: translateX(-50%); background: rgba(27, 26, 46, 0.75); padding: 6px 14px; border-radius: 999px; font-weight: 800; transition: opacity 1s; white-space: nowrap; }
.hud-bottom { position: absolute; left: max(10px, env(safe-area-inset-left)); right: max(14px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 10px; }
.qwrap { position: relative; pointer-events: auto; }
.qbtn { width: 52px; height: 52px; border-radius: 50%; border: 3px solid #fff; font-size: 22px; background: rgba(27, 26, 46, 0.6); }
.qbtn { position: relative; }
.badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--coral); color: #fff; font-size: 12px; font-weight: 900; display: grid; place-items: center; border: 2px solid #fff; }
/* in-race chat: a small sign-style panel above the chat button */
.chat-pop { position: absolute; bottom: 62px; left: 0; width: min(340px, 70vw); max-height: 62vh; display: flex; flex-direction: column; gap: 6px; padding: 8px;
  background: var(--sign); border: 3px solid #fff; box-shadow: 0 0 0 3px var(--sign), 0 10px 24px rgba(0, 0, 0, 0.3); border-radius: 12px; pointer-events: auto; }
.chat-log.mini { height: auto; min-height: 60px; max-height: 26vh; font-size: 14px; }
.chat-pop .quick { padding: 2px 0; }
.chat-pop .chat-form input { padding: 9px 10px; font-size: 16px; }
.hud-btn { flex: none; pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; background: rgba(27, 26, 46, 0.6); font-size: 18px; cursor: pointer; }
.music-btn.off { opacity: 0.75; }
/* mic: grey when off, live red with a pulse when on */
.mic-btn { position: relative; }
.hud-btn.mic-btn:not(.on) { opacity: 0.7; }
.btn.mic-btn.on { background: var(--coral); color: #fff; box-shadow: 0 0 0 2px #fff, 0 0 14px rgba(255, 107, 74, 0.8); }
.hud-btn.mic-btn.on { background: var(--coral); box-shadow: 0 0 12px rgba(255, 107, 74, 0.9); animation: micpulse 1.4s ease-in-out infinite; }
@keyframes micpulse { 50% { box-shadow: 0 0 2px rgba(255, 107, 74, 0.4); } }
.players .mic { font-size: 14px; }
/* item slot: a yellow diamond warning sign */
.item-wrap { margin-left: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.item-name { font-size: 13px; font-weight: 900; text-shadow: 0 1px 3px #000; min-height: 1em; text-align: center; }
.item { position: relative; isolation: isolate; pointer-events: auto; width: 84px; height: 84px; border: 0; background: none; font-size: 34px; cursor: pointer; color: var(--ink); font-weight: 900; }
.item::before { content: ''; position: absolute; inset: 12px; z-index: -1; background: var(--toll); border: 4px solid var(--ink); border-radius: 10px; transform: rotate(45deg); box-shadow: 0 0 0 3px #fff; }
.item:disabled { font-size: 24px; color: rgba(27, 26, 46, 0.6); cursor: default; }
.item:disabled::before { background: rgba(255, 255, 255, 0.55); border-color: rgba(27, 26, 46, 0.5); }
.item.pulse::before { animation: glow 0.9s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 3px #fff, 0 0 22px 6px var(--toll); } }
.ghost-panel { flex: 0 1 380px; pointer-events: auto; background: var(--dusk); border: 3px solid #fff; box-shadow: 0 0 0 3px var(--dusk); border-radius: 12px; padding: 8px 10px; }
.hp-title { font-size: 12px; font-weight: 800; margin-bottom: 5px; }
.energy { height: 8px; background: rgba(255, 255, 255, 0.18); border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.energy div { height: 100%; width: 0; background: linear-gradient(90deg, #a78bfa, #f0abfc); transition: width 0.15s; }
.drops { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.drops button { border: 0; border-radius: 9px; padding: 5px 2px; background: #fff; font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; gap: 4px; }
.drops button small { font-size: 11px; font-weight: 900; color: var(--dusk); }
.drops button:disabled { opacity: 0.35; }
.rotate { display: none; }
@media (orientation: portrait) {
  .rotate { display: grid; place-items: center; position: fixed; inset: 0; z-index: 9999; background: linear-gradient(#3b2a6b, #ff7e5f); color: #fff; padding: 24px; }
  .rotate .sign small { display: block; margin-top: 10px; font-size: 14px; font-weight: 700; opacity: .85; }
  .rotate .sign { text-align: center; font-size: 22px; font-weight: 900; max-width: 280px; }
  .rot-icon { font-size: 54px; display: inline-block; animation: turn 1.6s ease-in-out infinite; }
}
@keyframes turn { 40%, 100% { transform: rotate(-90deg); } }
@media (orientation: landscape) and (max-height: 520px) {
  .countdown { font-size: 80px; top: 14%; }
  .item { width: 74px; height: 74px; font-size: 30px; }
  .qbtn { width: 46px; height: 46px; }
}

/* connection lost / slow: shown instead of a frozen screen */
.netlost { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; background: rgba(27, 26, 46, 0.55); pointer-events: none; }
.netlost.soft { background: none; place-items: start center; padding-top: 70px; }
.netlost .sign { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 90vw; font-size: 15px; }
.netlost b { font-size: 17px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.3); border-top-color: var(--toll); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); border: 2px solid #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px; font-weight: 800; z-index: 50; max-width: 90%; }
