/*! POPCORN DRIFT ui.css - every screen that is not the race.
   Vocabulary is the park's (shared/docs/UI-DESIGN-STANDARD.md, 2026-09-17):
   one paddock scene as the stage, cream cards, dark-wood chips, a wooden sign
   for titles, and ONE honey-yellow button per screen for the main action.
   style.css keeps the base, the touch pads and the in-race chrome. */

/* ---- tokens (standard §2.3) ------------------------------------------------ */
:root {
  --ui-cream-0: #fffdf7; --ui-cream-1: #fff8e8; --ui-cream-2: #f6e8c8;
  --ui-ink: #3a2c12; --ui-muted: #806d4d; --ui-faint: #93805f;
  --ui-gold: #f5a91b; --ui-gold-dark: #9d6508;
  --ui-blue: #2e8fd6; --ui-green: #35ad58; --ui-danger: #d94b52;
  --ui-radius-sm: 11px; --ui-radius-md: 18px; --ui-radius-lg: 24px;
  --ui-shadow-card: 0 10px 30px rgba(60,40,20,.24), 0 3px 0 rgba(184,121,15,.12), inset 0 2px 0 rgba(255,255,255,.6);
  --ui-speed-fast: 160ms; --ui-speed: 220ms;
  --wood-bg: rgba(50,32,14,.66); --wood-edge: rgba(255,230,160,.35); --wood-fg: #fff5dc; --wood-hi: #ffd45e;
  /* the park dock: collapsed it is one 40px button in the top-right corner; the
     topbar leaves that much room and never reads the live (expanding) width */
  --dock-gap: calc(var(--park-dock-rest-w, 40px) + 22px);
}
/* the shared sheets (social.js / share.js) expose variable hooks: set variables,
   never restyle their classes (standard §2.3) */
:root {
  --soc-sheet: linear-gradient(rgba(255,253,247,.98), rgba(255,248,232,.96)); --soc-edge: #fff;
  --soc-ink: #3a2c12; --soc-secfg: #6b5327;
  --soc-card: linear-gradient(rgba(255,255,255,.85), rgba(255,250,240,.85)); --soc-cardfg: #3a2c12;
  --soc-accent: #f5a91b; --soc-live: #35c15f; --soc-radius: 16px;
}
/* share.js injects its own .pshare rule at mount(), after this file: the hook
   needs an id to outrank it, the way the standard's reference (#roomShare) does */
#wrShare.pshare { --pshare-bg: linear-gradient(rgba(255,253,247,.95), rgba(255,248,232,.92)); --pshare-fg: #3a2c12;
  --pshare-accent: #b8790f; --pshare-btn: rgba(255,252,244,.95);
  border: 2.5px solid #fff; border-radius: var(--ui-radius-md); box-shadow: var(--ui-shadow-card); }

/* ---- the scene ------------------------------------------------------------- */
#overlay { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; color: var(--ui-ink);
  background: linear-gradient(rgba(255,250,238,.02), rgba(60,40,20,.26) 88%), url("assets/scenes/lobby_bg_wide.webp?v=1") center 58% / cover no-repeat fixed;
  padding: 0; }
@media (orientation: portrait) {
  #overlay { background-image: linear-gradient(rgba(255,250,238,.02), rgba(60,40,20,.3) 90%), url("assets/scenes/lobby_bg_tall.webp?v=1"); background-position: center top; }
}
/* iOS refuses background-attachment:fixed on a scroller: paint the scene on a
   fixed pseudo element instead so it never scrolls with the content */
#overlay::before { content: ""; position: fixed; inset: 0; z-index: -1; background: inherit; }
#overlay { background-attachment: scroll; }
.scr { position: relative; z-index: 1; display: flex; flex-direction: column; width: 100%; min-height: 100%; flex: 1 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
@media (prefers-reduced-motion: no-preference) {
  .scr:not(.hidden), .modal-card { animation: uiEnter var(--ui-speed) cubic-bezier(.2,.75,.2,1) both; }
  @keyframes uiEnter { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
}

/* ---- loading --------------------------------------------------------------- */
#loading { position: relative; z-index: 2; width: min(330px, 82vw); margin: auto; color: var(--wood-fg); text-align: center;
  text-shadow: 0 1px 4px rgba(60,35,10,.6); }
#loading strong { display: block; font-size: clamp(24px, 6vw, 38px); font-weight: 900; letter-spacing: 3px; color: #fff;
  text-shadow: 0 3px 0 #b8500f, 0 8px 22px rgba(60,35,10,.55); }
#loading p { margin: 14px 0 10px; font-size: 12px; font-weight: 800; letter-spacing: 1px; }
.loadTrack { height: 9px; overflow: hidden; border-radius: 99px; background: rgba(50,32,14,.5); border: 1.5px solid var(--wood-edge); }
.loadTrack i { display: block; width: 2%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffe08a, #f5a91b); transition: width .2s ease; }
.loadMark { position: relative; width: 58px; height: 48px; margin: 0 auto 12px; }
.loadMark span { position: absolute; width: 29px; height: 29px; border-radius: 48% 52% 45% 55%; background: var(--ui-cream-0);
  box-shadow: 0 3px 8px rgba(60,35,10,.35); animation: pop .85s infinite alternate ease-in-out; }
.loadMark span:nth-child(1) { left: 2px; bottom: 0; } .loadMark span:nth-child(2) { left: 16px; top: 0; animation-delay: -.25s; } .loadMark span:nth-child(3) { right: 0; bottom: 2px; animation-delay: -.5s; }
@keyframes pop { to { transform: translateY(-6px) rotate(8deg); background: #ffe08a; } }

/* ---- components ------------------------------------------------------------ */
.card { position: relative; padding: 14px 16px; border-radius: var(--ui-radius-md); border: 2.5px solid #fff;
  background: linear-gradient(rgba(255,253,247,.95), rgba(255,248,232,.92)); box-shadow: var(--ui-shadow-card); color: var(--ui-ink); }
.card-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 15px; font-weight: 900; letter-spacing: .3px; color: #6b5327; text-transform: none; }
.card-title::before { content: ""; display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 3px; transform: rotate(45deg);
  background: linear-gradient(#ffd84a, #f5a91b); box-shadow: 0 0 0 3px rgba(245,169,27,.2); }
.card-title svg { color: #c98a1a; }
.listHead > span:first-child { margin-right: auto; }

/* dark-wood chip: text that sits on the scene (account, rating, status) */
.chip { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; padding: 4px 14px 4px 5px; border-radius: 999px;
  border: 1.5px solid var(--wood-edge); background: var(--wood-bg); color: var(--wood-fg); font-weight: 800; font-size: 14px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 6px 18px rgba(60,40,20,.28); }
.chip.wood { padding: 0 14px; margin: 0; font-size: 13px; }
.chip b { color: #fff; font-size: 15px; }
.chip-face { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; overflow: hidden;
  background: var(--wood-fg); border: 2px solid #ffe9a8; }
.chip-face img { display: block; width: 100%; height: 100%; object-fit: contain; }
.chip-col { display: flex; flex-direction: column; gap: 1px; min-width: 0; line-height: 1.15; }
.chip-col span { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #ffe9a8; }
.chip-x { min-height: 28px; height: 28px; padding: 0 10px; margin-left: 2px; border-radius: 999px; border: 1.5px solid var(--wood-edge);
  background: rgba(255,255,255,.14); color: var(--wood-fg); font-size: 11px; font-weight: 900; letter-spacing: .04em; cursor: pointer; }
.chip-x:hover { background: rgba(255,255,255,.28); }
/* the guest's name box lives INSIDE a chip: same silhouette as the signed-in one */
.name-chip { cursor: text; }
.name-chip #nameInput { width: 132px; min-width: 0; padding: 2px 0; border: 0; background: none; color: #fff; font-size: 15px; font-weight: 800; outline: none; }
.name-chip #nameInput::placeholder { color: rgba(255,245,220,.55); font-weight: 700; }
.name-chip:focus-within { border-color: var(--wood-hi); box-shadow: 0 0 0 3px rgba(255,212,94,.25), 0 6px 18px rgba(60,40,20,.28); }

/* wooden sign: page and room titles */
.sign { display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px; padding: 8px 22px; border-radius: 16px;
  background: linear-gradient(#a8743f, #7a4f26); border: 3px solid #d0a06a; color: var(--wood-fg); text-shadow: 0 2px 0 rgba(60,35,10,.6);
  box-shadow: 0 6px 0 #5a3618, 0 12px 26px rgba(60,35,10,.35), inset 0 2px 0 rgba(255,255,255,.25); }
.sign.center { align-self: center; align-items: center; margin-bottom: 14px; }
.sign h1, .sign h2 { margin: 0; color: #ffe9a8; letter-spacing: 1.5px; line-height: 1.05; }
.sign h2 { font-size: clamp(20px, 2.6vw, 26px); font-weight: 900; }
.sign h2 em { font-style: normal; color: var(--wood-hi); }
.sign-eyebrow, .brand-eyebrow { font-size: 10px; font-weight: 900; letter-spacing: .2em; color: rgba(255,233,168,.75); }

/* buttons */
button, input, select { font: inherit; }
.btn-sec { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 8px 16px; border-radius: 16px;
  border: 2.5px solid #fff; background: rgba(255,252,244,.94); color: var(--ui-ink); font-weight: 900; font-size: 15px; cursor: pointer;
  box-shadow: 0 5px 0 rgba(150,110,40,.22), 0 10px 22px rgba(60,40,20,.22); transition: transform var(--ui-speed-fast), background var(--ui-speed-fast), box-shadow var(--ui-speed-fast); }
.btn-sec:hover { background: #fff; transform: translateY(-1px); }
.btn-sec:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(150,110,40,.22); }
.btn-sec:disabled { opacity: .5; cursor: default; box-shadow: none; transform: none; }
.btn-sec svg { flex: none; color: #c98a1a; }
.btn-sec.on { background: linear-gradient(#ffe08a, #f5a91b); border-color: #ffedb0; color: #5a3800; }
.btn-sec.on svg { color: #7a4a00; }
.btn-sec.danger { color: var(--ui-danger); }
.btn-sec.danger svg { color: var(--ui-danger); }
select.btn-sec { padding-right: 34px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b5327' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; }
.btn-gold-sm { min-height: 36px; padding: 6px 14px; border-radius: 11px; border: 2px solid #ffedb0; background: linear-gradient(#ffe08a, #f5a91b);
  color: #5a3800; font-weight: 900; font-size: 13px; cursor: pointer; box-shadow: 0 3px 0 #c9871a; }
.btn-gold-sm:active { transform: translateY(2px); box-shadow: 0 1px 0 #c9871a; }
.btn-gold-sm:disabled { opacity: .5; cursor: default; }
/* THE main action: one per screen */
.btn-play { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 66px;
  padding: 10px 26px; border-radius: 22px; border: 3px solid #fff3c9; background: linear-gradient(#ffe08a, #f5a91b); color: #5a3800;
  font-size: 24px; font-weight: 900; letter-spacing: 2px; cursor: pointer; text-shadow: 0 1px 0 rgba(255,255,255,.4);
  box-shadow: 0 9px 0 #c9871a, 0 18px 34px rgba(120,70,10,.36), inset 0 2px 0 rgba(255,255,255,.55); transition: transform var(--ui-speed-fast), box-shadow var(--ui-speed-fast); }
.btn-play:active { transform: translateY(4px); box-shadow: 0 5px 0 #c9871a, 0 10px 24px rgba(120,70,10,.3); }
.btn-play:disabled { opacity: .55; cursor: default; }
.btn-play > svg { flex: none; width: 26px; height: 26px; color: #b8500f; filter: drop-shadow(0 1px 0 #fff3c9); }
.btn-play .play-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.btn-play small { display: block; margin-top: 3px; font-size: 12.5px; font-weight: 800; letter-spacing: 0; color: #8a5a10; }
.btn-play small:empty { display: none; }
.btn-play::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(115deg, transparent 32%, rgba(255,255,255,.55) 46%, rgba(255,255,255,.2) 52%, transparent 64%);
  background-size: 260% 100%; animation: sheen 3.4s ease-in-out infinite; }
@keyframes sheen { 0% { background-position: 120% 0; } 55% { background-position: -60% 0; } 100% { background-position: -60% 0; } }
/* READY is a promise, not a start: green */
.btn-play.ready { background: linear-gradient(#6fdc6f, #2faa4a); color: #fff; border-color: #d9f7de; text-shadow: 0 1px 0 rgba(0,60,20,.3);
  box-shadow: 0 9px 0 #1f7d34, 0 18px 34px rgba(20,80,30,.35), inset 0 2px 0 rgba(255,255,255,.4); }
.btn-play.ready > svg { color: #fff; filter: none; }
.linkBtn { background: none; border: 0; padding: 0; min-height: 0; color: var(--ui-blue); font-size: 13px; font-weight: 900; cursor: pointer; }
.linkBtn:hover { text-decoration: underline; }
.row { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.hint { margin: 8px 0 0; font-size: 12px; line-height: 1.5; color: var(--ui-faint); }
.hint:empty { display: none; }
.hint.status { min-height: 18px; text-align: center; color: var(--wood-fg); font-weight: 800; text-shadow: 0 1px 4px rgba(60,35,10,.6); }
.gBtn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; width: 100%; min-height: 46px; padding: 8px 16px; border-radius: 14px;
  border: 2px solid rgba(150,115,55,.22); background: #fff; color: #1f2430; font-weight: 700; font-size: 14px; cursor: pointer; box-shadow: 0 3px 0 rgba(150,110,40,.14); }
.gBtn:hover { background: #f7f7fa; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(46,143,214,.78); outline-offset: 3px; }

/* ---- 大廳 (landing) --------------------------------------------------------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 0 var(--dock-gap) 6px 0; }
.brand { padding: 6px 20px; }
.brand h1 { font-size: clamp(20px, 2.4vw, 30px); letter-spacing: 3px; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.stage-row { display: flex; align-items: flex-start; justify-content: center; gap: clamp(12px, 1.4vw, 20px); width: 100%; max-width: 1480px; margin: auto; padding: 6px 0; }
/* left rail: one tile per EXISTING mode, bilingual (standard §3.1) */
.rail { flex: none; width: clamp(176px, 15vw, 224px); display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 22px;
  border: 1.5px solid rgba(255,230,160,.28); background: linear-gradient(rgba(70,44,18,.8), rgba(45,28,12,.88));
  box-shadow: 0 14px 40px rgba(50,30,10,.35), inset 0 1px 0 rgba(255,255,255,.12); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.rail-btn { position: relative; display: flex; align-items: center; gap: 11px; min-height: 52px; padding: 8px 12px; border-radius: 15px; border: 1.5px solid transparent;
  background: transparent; color: #fff1cf; text-align: left; text-decoration: none; cursor: pointer; transition: background .12s, transform .08s; }
.rail-btn:hover { background: rgba(255,255,255,.1); transform: translateX(2px); }
.rail-btn .ricon { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: rgba(255,255,255,.12); color: #ffe08a; }
.rail-btn .rtxt { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; gap: 2px; }
.rail-btn .rtxt b { font-size: 15px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-btn .rtxt i { font-style: normal; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,241,207,.62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-btn.primary { background: linear-gradient(#ffe08a, #f5a91b); border-color: #ffedb0; color: #5a3800; box-shadow: 0 6px 18px rgba(245,169,27,.45), inset 0 2px 0 rgba(255,255,255,.45); }
.rail-btn.primary .ricon { background: rgba(255,255,255,.35); color: #7a4a00; }
.rail-btn.primary .rtxt i { color: rgba(90,56,0,.7); }
.rail-btn.primary:hover { transform: translateY(-1px); background: linear-gradient(#fff0bb, #ffbe3d); }
.rail-sep { height: 1px; margin: 4px 6px; background: rgba(255,230,160,.18); }
/* the open stage: the player's own kart stands on the grid, the main button at its wheels */
.stage { position: relative; container-type: inline-size; flex: 1 1 auto; min-width: 0; max-width: 700px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cast { position: relative; width: 100%; height: clamp(150px, 26vh, 250px); pointer-events: none; }
.hero-kart { position: absolute; left: 50%; bottom: 0; height: 100%; width: auto; max-width: none; transform: translateX(-50%); object-fit: contain; object-position: bottom center;
  filter: drop-shadow(0 14px 16px rgba(60,35,10,.42)); animation: idle 6s ease-in-out infinite; }
@keyframes idle { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-5px); } }
.hero-tag { position: absolute; left: calc(50% - clamp(210px, 38cqw, 330px)); top: 8%; width: clamp(120px, 18cqw, 180px); margin: 0; text-align: center;
  color: #fff; font-weight: 900; font-size: clamp(14px, 2cqw, 20px); line-height: 1.25; transform: rotate(-6deg);
  text-shadow: 0 2px 0 rgba(120,70,20,.6), 0 6px 16px rgba(60,35,10,.55); }
.cta { width: min(580px, 100%); display: flex; flex-direction: column; gap: 10px; }
.sec-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.sec-row.two { grid-template-columns: 1fr 1.6fr; }
.sec-row .btn-sec { flex-direction: column; gap: 4px; min-height: 64px; padding: 8px 10px; line-height: 1.1; }
.sec-row .btn-sec small { font-size: 11px; font-weight: 800; color: var(--ui-faint); }
.sec-row .btn-sec b { display: flex; align-items: center; gap: 6px; }
.hint-line { margin: 0; text-align: center; font-size: 12px; font-weight: 800; color: var(--wood-fg); text-shadow: 0 1px 4px rgba(60,35,10,.65); }
.side { flex: none; width: clamp(240px, 22vw, 300px); display: flex; flex-direction: column; gap: 12px; }
.fc-faces { display: flex; margin: 2px 0 10px; }
.fc-faces img { width: 40px; height: 40px; margin-left: -10px; border-radius: 50%; border: 2.5px solid #fff; background: var(--ui-cream-1); object-fit: contain; box-shadow: 0 3px 8px rgba(60,40,20,.2); }
.fc-faces img:first-child { margin-left: 0; }
.friendLine { width: 100%; text-align: left; justify-content: flex-start; font-size: 13.5px; line-height: 1.3; }
.friendLine.anon { border-color: #ffedb0; background: linear-gradient(rgba(255,240,187,.9), rgba(255,224,138,.9)); color: #5a3800; }
#passportSignIn { margin-top: 8px; }
.tools-card { display: flex; flex-direction: column; gap: 8px; }
.siteLinks { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; }
.siteLinks a { color: var(--ui-muted); font-size: 12px; font-weight: 800; text-decoration: none; border-bottom: 1.5px solid transparent; }
.siteLinks a:hover { color: var(--ui-ink); border-bottom-color: var(--ui-gold); }
.lobby-foot { display: flex; justify-content: center; margin-top: 16px; padding-bottom: 4px; }
/* 分級標示 (遊戲軟體分級管理辦法 §11-13): legal, fixed Chinese, 60x60 mark */
.ratingMark { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 14px; border: 2px solid #fff;
  background: rgba(255,253,247,.9); text-align: left; box-shadow: 0 4px 12px rgba(60,40,20,.2); }
.ratingMark img { flex: none; width: 60px; height: 60px; }
.ratingMark p { margin: 0; max-width: 300px; font-size: 11px; line-height: 1.55; color: var(--ui-muted); }
.ratingMark b { color: var(--ui-ink); font-weight: 900; }
.ratingMark span { display: block; }

/* ---- full-page shell: setup / lobby / room ---------------------------------- */
.shell-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; width: 100%; max-width: 1180px; margin: 0 auto 14px; padding-right: var(--dock-gap); }
.head-right { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; justify-content: flex-end; min-width: 0; }
.head-right .chip { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; line-height: 44px; }
.shell-body { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 1180px; margin: 0 auto; flex: 1 0 auto; }
/* the main action is pinned where a thumb can reach it, and never scrolls away */
.action-bar { position: sticky; bottom: 0; z-index: 3; display: flex; justify-content: center; width: 100%; max-width: 1180px; margin: 14px auto 0;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0;
  background: linear-gradient(rgba(50,32,14,.0), rgba(50,32,14,.62) 42%); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.action-bar .btn-play { max-width: 560px; }

/* setup: drivers, tracks, difficulty */
.driver-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.driverCard { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px 10px; border-radius: 16px; border: 2.5px solid rgba(150,115,55,.18);
  background: rgba(255,255,255,.55); color: var(--ui-ink); cursor: pointer; transition: transform var(--ui-speed-fast), border-color var(--ui-speed-fast), box-shadow var(--ui-speed-fast); }
.driverCard:hover { transform: translateY(-2px); border-color: #ffd45e; }
.driverCard img { width: 100%; max-width: 108px; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(60,35,10,.28)); }
.driverCard.sel { border-color: #f5a91b; background: linear-gradient(rgba(255,240,187,.95), rgba(255,224,138,.85)); box-shadow: 0 0 0 3px rgba(245,169,27,.25), 0 8px 18px rgba(120,70,10,.2); }
.dcName { display: block; font-weight: 900; font-size: 14px; margin: 2px 0 4px; }
.stat { display: flex; align-items: center; gap: 6px; width: 100%; font-size: 10px; font-weight: 800; color: var(--ui-muted); }
.stat i { width: 38px; text-align: right; font-style: normal; }
.stat em { flex: 1; height: 6px; border-radius: 3px; overflow: hidden; background: rgba(150,115,55,.18); }
.stat b { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #ffd84a, #f5a91b); }
.track-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.track-grid.dim { opacity: .45; pointer-events: none; }
.trackCard { display: flex; flex-direction: row; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 14px; text-align: left; border: 2.5px solid rgba(150,115,55,.18);
  background: rgba(255,255,255,.55); color: var(--ui-ink); cursor: pointer; transition: transform var(--ui-speed-fast), border-color var(--ui-speed-fast); }
.trackCard:hover { transform: translateY(-2px); border-color: #ffd45e; }
.trackCard.sel { border-color: #f5a91b; background: linear-gradient(rgba(255,240,187,.95), rgba(255,224,138,.85)); box-shadow: 0 0 0 3px rgba(245,169,27,.25); }
.tcThumb { flex: none; width: 72px; aspect-ratio: 1; border-radius: 10px; image-rendering: pixelated; border: 2px solid #fff; box-shadow: 0 3px 8px rgba(60,40,20,.18); }
.tcName { font-size: 13px; font-weight: 900; line-height: 1.15; }
.tcMeta { margin-left: auto; }
.tcMeta { font-size: 10.5px; font-weight: 800; color: var(--ui-faint); }
.seg { display: flex; gap: 8px; }
.seg .btn-sec { flex: 1; min-height: 46px; }

/* online lobby */
.lobbyActions { display: flex; flex-direction: column; gap: 10px; width: min(640px, 100%); margin: 0 auto 4px; }
.lobbyActions button:disabled, .lobbyActions input:disabled { opacity: .55; cursor: default; }
.lobbyActions .sec-row .btn-sec { flex-direction: row; min-height: 54px; font-size: 15px; }
.joinGroup { display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 5px 6px 5px 14px; cursor: text; }
.joinGroup > svg { flex: none; }
#codeInput { flex: 1; min-width: 0; width: 100%; padding: 6px 2px; border: 0; background: transparent; text-align: center; outline: none;
  font-size: 18px; font-weight: 900; letter-spacing: 4px; text-transform: uppercase; color: var(--ui-ink); }
#codeInput::placeholder { color: rgba(110,85,45,.45); letter-spacing: 0; font-size: 14px; font-weight: 800; }
.lobby-body .friendLine { width: min(640px, 100%); margin: 0 auto; }
.liveDot { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 900; letter-spacing: .08em; color: var(--ui-green); }
.liveDot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #35c15f; box-shadow: 0 0 0 4px rgba(53,193,95,.18); }
#roomList { display: flex; flex-direction: column; gap: 8px; }
#roomList .hint, #boardList .hint { margin: 0; padding: 14px 0; text-align: center; }
.roomRow { display: grid; grid-template-columns: 1.1fr 2fr auto auto; gap: 8px 14px; align-items: center; min-height: 58px; padding: 10px 16px; border-radius: 14px;
  border: 2.5px solid rgba(150,115,55,.18); background: rgba(255,255,255,.6); color: var(--ui-ink); text-align: left; font-size: 14px; font-weight: 800; cursor: pointer;
  transition: transform var(--ui-speed-fast), border-color var(--ui-speed-fast); }
.roomRow:hover:not(:disabled) { transform: translateY(-1px); border-color: #ffd45e; background: #fff; }
.roomRow:disabled { opacity: .55; cursor: default; }
.roomRow b { font-weight: 900; }
.roomRow span { color: var(--ui-muted); }
.roomRow .seats { display: inline-flex; align-items: center; gap: 5px; color: var(--ui-ink); font-variant-numeric: tabular-nums; }
.roomRow em { justify-self: end; font-style: normal; font-size: 11px; font-weight: 900; letter-spacing: .06em; padding: 4px 10px; border-radius: 999px; color: #fff; background: var(--ui-green); }
.roomRow em.racing { background: #b98a2a; }
table.board { width: 100%; border-collapse: collapse; font-size: 13.5px; font-weight: 800; }
table.board th { color: var(--ui-faint); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; text-align: right; padding: 4px 8px; font-weight: 900; }
table.board td { padding: 7px 8px; text-align: right; border-top: 1.5px solid rgba(150,115,55,.14); color: var(--ui-ink); font-variant-numeric: tabular-nums; }
table.board th:nth-child(2), table.board td.bName { text-align: left; }
table.board td:first-child, table.board th:first-child { text-align: left; color: var(--ui-faint); width: 3em; }
table.board tr.me td { color: var(--ui-gold-dark); font-weight: 900; background: rgba(255,224,138,.35); }

/* waiting room */
.wr-body { flex-direction: row; align-items: flex-start; }
.wr-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.wr-side { flex: none; width: clamp(280px, 30vw, 360px); display: flex; flex-direction: column; gap: 12px; }
#wrSlots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.slotCard { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 124px; padding: 10px 6px; border-radius: 16px;
  border: 2.5px solid rgba(150,115,55,.18); background: rgba(255,255,255,.55); color: var(--ui-ink); font-size: 13px; font-weight: 900; }
.slotCard img { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 5px 6px rgba(60,35,10,.25)); }
.slotCard span { font-size: 11px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: var(--ui-green); }
.slotCard.khost { border-color: #f5a91b; background: linear-gradient(rgba(255,240,187,.95), rgba(255,224,138,.85)); }
.slotCard.khost span { color: #9d6508; }
.slotCard.kplayer span.wait { color: var(--ui-faint); }
.slotCard.kopen, .slotCard.kclosed, .slotCard.kbot { color: var(--ui-faint); }
.slotCard.kopen { border-style: dashed; cursor: pointer; }
.slotCard.kclosed { opacity: .5; cursor: pointer; }
.slotCard.kbot { cursor: pointer; }
.slotCard.kbot i, .slotCard.kopen i, .slotCard.kclosed i { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: rgba(150,115,55,.12); color: var(--ui-muted); }
.slotCard[onclick], .slotCard.kopen:hover, .slotCard.kclosed:hover, .slotCard.kbot:hover { border-color: #ffd45e; }
.slotCard span.plus { color: var(--ui-blue); }
.char-row { display: flex; gap: 8px; flex-wrap: wrap; }
.charDot { flex: 1 1 0; min-width: 52px; max-width: 72px; aspect-ratio: 1; padding: 4px; border-radius: 14px; border: 2.5px solid rgba(150,115,55,.18); background: rgba(255,255,255,.55); cursor: pointer; }
.charDot img { width: 100%; height: 100%; object-fit: contain; }
.charDot:hover { border-color: #ffd45e; }
.charDot.sel { border-color: #f5a91b; background: linear-gradient(rgba(255,240,187,.95), rgba(255,224,138,.85)); box-shadow: 0 0 0 3px rgba(245,169,27,.25); }
.setup-row { display: flex; flex-direction: column; gap: 8px; }
.setup-row .btn-sec, .setup-row select { width: 100%; justify-content: flex-start; }
.setup-row .hint { margin: 0; font-size: 13px; color: var(--ui-muted); }
.setup-row .hint b { color: var(--ui-ink); }

/* ---- results / pause / share card: cream modals ------------------------------ */
#results { justify-content: center; align-items: center; }
.modal-card { position: relative; width: min(560px, 100%); margin: auto; padding: clamp(20px, 3vw, 30px); border-radius: var(--ui-radius-lg); border: 3px solid #fff;
  background: linear-gradient(rgba(255,253,247,.97), rgba(255,248,232,.95)); box-shadow: 0 24px 60px rgba(60,35,10,.4), inset 0 2px 0 rgba(255,255,255,.7);
  color: var(--ui-ink); text-align: center; display: flex; flex-direction: column; align-items: center; }
.modal-card h3 { margin: 16px 0 6px; font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: var(--ui-faint); }
#resTable { width: 100%; }
#resTable table { width: 100%; border-collapse: collapse; }
#resTable td { padding: 9px 12px; font-size: 15px; font-weight: 800; color: var(--ui-ink); border-bottom: 1.5px solid rgba(150,115,55,.14); text-align: left; }
#resTable td:first-child { width: 3.2em; }
#resTable td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#resTable .rk { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-size: 12px; font-weight: 900; color: var(--ui-muted); background: rgba(150,115,55,.12); }
#resTable tr:first-child .rk { color: #5a3800; background: linear-gradient(#ffe08a, #f5a91b); box-shadow: 0 2px 0 #c9871a; }
#resTable tr.me td { background: rgba(255,224,138,.35); }
#resTable tr.me td:first-child { border-radius: 10px 0 0 10px; } #resTable tr.me td:last-child { border-radius: 0 10px 10px 0; }
#resTable .pts { color: var(--ui-green); font-weight: 900; }
#pause, #cardModal, #boardModal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 18px; overflow-y: auto;
  background: rgba(40,26,12,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.cardPanel { max-width: 440px; }
#cardImg { display: block; width: min(360px, 68vw); height: auto; aspect-ratio: 1; margin: 0 auto; border-radius: 18px; border: 3px solid #fff; background: var(--ui-cream-2);
  box-shadow: 0 10px 24px rgba(60,35,10,.3); -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
#resCard:disabled { opacity: .55; cursor: default; }
.modal-x { position: absolute; top: 12px; right: 12px; min-height: 40px; padding: 6px 14px; }
#boardModal .modal-card { align-items: stretch; text-align: left; }
#boardModal .sign.center { align-self: center; }

/* ---- responsive ------------------------------------------------------------ */
@media (min-width: 821px) and (max-height: 900px) {
  .cast { height: clamp(110px, 18vh, 170px); }
  .btn-play { min-height: 56px; font-size: 21px; }
}
@media (min-width: 821px) and (min-height: 521px) and (max-height: 560px) {
  .cast { height: 40px; } .hero-kart, .hero-tag { display: none; }
}
@media (max-width: 1180px) {
  .rail-btn .rtxt i { display: none; }
  .side { width: clamp(200px, 20vw, 260px); }
}
/* phones, and any window too short to hold three columns: one column, one scroller (standard §4) */
@media (max-width: 820px), (max-height: 520px) {
  .scr { padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .rail { display: none; }
  .topbar { padding: 0 var(--dock-gap) 4px 0; gap: 8px; }
  .brand { padding: 5px 14px; }
  .brand h1 { font-size: 19px; letter-spacing: 2px; }
  .topbar-right { flex: 1 1 auto; }
  .name-chip #nameInput { width: 110px; }
  .stage-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .stage { max-width: none; }
  .cast { height: clamp(140px, 28vh, 220px); }
  .hero-tag { left: 2%; top: 0; width: 120px; font-size: 14px; }
  .cta { width: 100%; }
  .btn-play { min-height: 60px; font-size: 21px; }
  .sec-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .sec-row .btn-sec { min-height: 58px; font-size: 13.5px; }
  .side { width: 100%; max-width: none; }
  .lobby-foot { margin-top: 12px; }
  .ratingMark { width: 100%; }
  .shell-head { margin-bottom: 10px; }
  .head-right { flex: 1 1 100%; justify-content: space-between; }
  .trackCard { flex-direction: column; text-align: center; gap: 5px; padding: 8px; }
  .tcThumb { width: 100%; max-width: 92px; }
  .tcName { font-size: 12px; text-align: center; }
  .tcMeta { margin-left: 0; }
  .sign h2 { font-size: 19px; }
  .driver-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .driverCard { padding: 6px 4px 8px; }
  .driverCard .stat { display: none; }
  .dcName { font-size: 11.5px; margin: 0; }
  .track-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .sec-row.two { grid-template-columns: 1fr; }
  .roomRow { grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 12px; }
  .roomRow span:first-of-type { grid-column: 1 / 2; font-size: 12px; }
  .roomRow em { grid-column: 2; grid-row: 1; }
  .roomRow .seats { grid-column: 2; grid-row: 2; justify-self: end; }
  .wr-body { flex-direction: column; align-items: stretch; }
  .wr-side { width: 100%; }
  #wrSlots { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .slotCard { min-height: 96px; padding: 8px 2px; font-size: 11.5px; }
  .slotCard img { width: 44px; height: 44px; }
  .action-bar { margin-top: 10px; }
}
@media (max-width: 480px) {
  .driver-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sec-row { grid-template-columns: 1fr 1fr; }
  .sec-row .btn-sec:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .hero-tag { display: none; }
  .row .btn-sec { flex: 1 1 40%; }
}
/* landscape phone: everything shrinks, nothing is hidden that has no other door */
@media (max-height: 520px) {
  .cast { height: clamp(78px, 24vh, 120px); }
  .hero-tag { display: none; }
  .btn-play { min-height: 46px; font-size: 18px; letter-spacing: 1px; }
  .sec-row .btn-sec { min-height: 42px; }
  .sec-row .btn-sec small { display: none; }
  .brand h1 { font-size: 17px; }
  .lobby-foot { margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn-play::after, .hero-kart { animation: none !important; }
  .scr:not(.hidden), .modal-card { animation: none !important; }
}

/* touch targets: every menu button is at least 44px, except the small pill
   that lives INSIDE a 44px chip and the inline text link */
#overlay button:not(.chip-x):not(.linkBtn), .modal-card button { min-height: 44px; }

/* the shared ping chip (shared/client/conn-status.js) defaults to the bottom-left
   corner, which is the minimap here and the steering pads on a phone: it sits
   top-centre in the sky instead, clear of the HUD cards at every width (the
   reconnect banner that uses the same spot hides the chip while it shows).
   html body: the shared rules are injected after this sheet and would win. */
html body .pcs-rtt { left: 50%; bottom: auto; transform: translateX(-50%); top: max(10px, env(safe-area-inset-top)); }
