/* ピット＆レーサー（ブラウザ版）。色は Roblox 版 client/Ui.luau と同じ */
:root {
  --panel: rgba(10, 12, 18, 0.72);
  --sub: #aaaabb;
  --text: #ddddee;
  --off: #2a2e38;
  --accent: #ffcc33;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0f1116; color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif; font-size: 14px; }
.mono, .speed, .last-panel b { font-family: "Roboto Mono", "Consolas", monospace; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#labels, #hud, #overlay { position: fixed; inset: 0; pointer-events: none; }
#overlay > * { pointer-events: auto; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; background: #0f1116; font-size: 20px; color: var(--sub); }

/* 他車の略号 */
.car-tag { position: absolute; left: 0; top: 0; background: rgba(0, 0, 0, 0.55); color: #fff; font-weight: bold; font-size: 12px;
  padding: 1px 4px 1px 2px; white-space: nowrap; will-change: transform; }
.car-tag i { display: inline-block; width: 3px; height: 12px; margin-right: 3px; vertical-align: -2px; }

/* ---- HUD ---- */
.hud-scaled { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.panel { position: absolute; background: var(--panel); border-radius: 6px; }
.sub { color: var(--sub); }
.pos-panel { left: 16px; top: 16px; width: 190px; height: 104px; }
.pos-panel .l1 { position: absolute; left: 14px; top: 12px; }
.pos-panel .l2 { position: absolute; left: 14px; top: 72px; }
.pos-panel .pos { position: absolute; left: 64px; top: 4px; font-size: 36px; }
.pos-panel .pos small { font-size: 18px; color: var(--sub); }
.pos-panel .lap { position: absolute; left: 64px; top: 66px; font-size: 22px; }
.last-panel { left: 16px; top: 130px; width: 190px; height: 40px; }
.last-panel span { position: absolute; left: 14px; top: 12px; font-size: 13px; }
.last-panel b { position: absolute; left: 74px; top: 9px; font-size: 18px; }
.speed-panel { left: 50%; bottom: 16px; width: 220px; height: 60px; margin-left: -110px; }
.speed-panel .speed { position: absolute; left: 20px; top: 2px; width: 140px; text-align: center; font-size: 30px; }
.speed-panel .kmh { position: absolute; left: 142px; top: 14px; }
.speed-panel .assist { position: absolute; left: 0; top: 40px; width: 100%; text-align: center; font-size: 12px; }
.off-track { position: absolute; left: 50%; bottom: 84px; width: 150px; margin-left: -75px; height: 30px; line-height: 26px; text-align: center;
  font-weight: bold; font-size: 18px; color: #ffaa46; background: rgba(20, 12, 6, 0.9); border: 2px solid #ff8c28; border-radius: 6px; }
.drs-panel { left: 50%; bottom: 16px; width: 64px; height: 60px; margin-left: 120px; }
.drs-lamp { position: absolute; left: 6px; top: 8px; width: 52px; height: 32px; line-height: 32px; text-align: center; font-weight: bold; font-size: 16px; border-radius: 3px; }
.slip { position: absolute; left: 0; top: 44px; width: 64px; text-align: center; font-weight: bold; font-size: 11px; }
.mode-panel { right: 16px; bottom: 52px; width: 180px; height: 64px; }
.mode-panel .sub { position: absolute; left: 12px; top: 6px; font-size: 13px; }
.modes { position: absolute; left: 12px; top: 28px; display: flex; gap: 6px; }
.mode { width: 50px; height: 28px; line-height: 28px; text-align: center; border-radius: 3px; font-size: 13px; }
.talk-panel { right: 16px; bottom: 122px; width: 180px; height: 58px; }
.talk-panel .sub { position: absolute; left: 8px; top: 4px; font-size: 11px; }
.talks { position: absolute; left: 8px; top: 18px; display: grid; grid-template-columns: 86px 86px; font-size: 11px; line-height: 13px; }
.talk i { font-style: normal; color: var(--accent); margin-right: 3px; }
.ai-banner { position: absolute; left: 50%; bottom: 84px; width: 380px; margin-left: -190px; height: 26px; line-height: 26px; text-align: center;
  font-weight: bold; color: #8fd18f; background: var(--panel); border-radius: 6px; }
.link { position: absolute; right: 16px; top: 50px; font-size: 12px; text-align: right; }
.sc-box { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); min-width: 300px; max-width: 520px; padding: 10px 24px;
  background: rgba(10, 10, 6, 0.85); text-align: center; }
.sc-box .bar { position: absolute; top: 0; bottom: 0; width: 8px; background: var(--c); }
.sc-box .bar.l { left: 0; } .sc-box .bar.r { right: 0; }
.sc-title { display: block; font-size: 26px; color: var(--c); }
.sc-sub { font-size: 14px; color: #eee; margin-top: 4px; }
.sc-lamp { position: absolute; top: 18px; width: 52px; height: 52px; margin-left: -26px; border-radius: 50%; background: rgba(10, 10, 6, 0.85); }
.sc-lamp i { position: absolute; left: 7px; top: 7px; width: 38px; height: 38px; border-radius: 50%; }
.radio-box { position: absolute; left: 50%; top: 110px; transform: translateX(-50%); width: 560px; max-width: calc(100% - 40px); height: 78px;
  background: rgba(8, 10, 14, 0.88); border: 3px solid #fff; text-align: center; }
.radio-box .from { font-size: 12px; color: #9999aa; margin-top: 4px; }
.radio-box .text { display: block; font-size: 30px; line-height: 34px; }
.radio-box .rsub { font-size: 14px; }
.sent-talk { position: absolute; left: 50%; bottom: 140px; width: 300px; margin-left: -150px; height: 28px; line-height: 28px; text-align: center;
  font-weight: bold; font-size: 15px; color: #8fd18f; background: var(--panel); border-radius: 6px; }
.pit-note { position: absolute; left: 50%; top: 20%; width: 560px; margin-left: -280px; padding: 14px; text-align: center; font-weight: bold; font-size: 22px;
  color: var(--accent); background: var(--panel); border-radius: 6px; }
.pit-note small { font-size: 16px; color: #dde; }
.lights { left: 50%; top: 24px; width: 300px; height: 70px; margin-left: -150px; display: flex; justify-content: space-around; align-items: center; }
.lamp { width: 40px; height: 40px; border-radius: 50%; background: #333; }
.lights-note { position: absolute; left: 50%; top: 104px; width: 300px; margin-left: -150px; text-align: center; }
.go { position: absolute; left: 50%; top: 44px; width: 300px; margin-left: -150px; text-align: center; font-weight: bold; font-size: 42px; color: #50ff78; }
.note { position: absolute; left: 50%; top: 34%; width: 300px; margin: -26px 0 0 -150px; padding: 8px; text-align: center; font-weight: bold; font-size: 18px;
  background: var(--panel); border-radius: 6px; }
.help { right: 16px; bottom: 184px; width: 246px; padding: 6px 12px; white-space: pre-line; font-size: 13px; line-height: 1.4; color: #e6e6e6; }
.help-hint { position: absolute; right: 0; bottom: 186px; width: 90px; font-size: 13px; opacity: 0.5; }
/* ひとりのとき */
.solo-gaps { left: 16px; top: 176px; width: 230px; height: 44px; padding: 4px 10px; line-height: 18px; }
.solo-gaps b { display: block; }
.solo-car { left: 16px; top: 226px; width: 230px; height: 128px; }
.cap { position: absolute; left: 10px; top: 2px; font-size: 11px; color: #9999aa; }
.solo-car .tire-name { position: absolute; left: 112px; top: 22px; font-size: 12px; }
.solo-car .tire-note { position: absolute; left: 112px; top: 40px; width: 92px; font-size: 11px; color: #ccccdd; line-height: 13px; }
.solo-car .wing-note { position: absolute; left: 104px; top: 84px; font-size: 11px; color: #ffb030; }
.solo-car .fw { position: absolute; left: 24px; top: 20px; width: 68px; height: 6px; }
.solo-car .fw i { position: absolute; top: 0; width: 50%; height: 100%; }
.solo-car .floor { position: absolute; left: 40px; top: 28px; width: 36px; height: 80px; }
.solo-car .rw { position: absolute; left: 34px; top: 112px; width: 48px; height: 7px; }
.wh { position: absolute; width: 18px; height: 28px; line-height: 28px; text-align: center; font-weight: bold; font-size: 9px; color: #111; }
.wh-wear { position: absolute; width: 30px; text-align: center; font-size: 9px; }
.solo-car .bat { position: absolute; left: 208px; top: 22px; width: 12px; height: 86px; border: 1px solid #888899; }
.solo-car .bat i { position: absolute; left: 0; bottom: 0; width: 10px; }
.bat-cap { position: absolute; left: 200px; top: 110px; width: 28px; text-align: center; font-size: 9px; color: #ccccdd; }
.solo-pit { left: 16px; top: 360px; width: 230px; height: 96px; }
.solo-pit .hint { position: absolute; left: 84px; top: 2px; font-size: 11px; color: #9999aa; }
.solo-pit .row { position: absolute; left: 8px; display: flex; gap: 5px; }
.solo-pit .tires { top: 24px; } .solo-pit .repairs { top: 58px; }
.btn { width: 68px; height: 26px; line-height: 26px; text-align: center; font-size: 11px; border-radius: 3px; }
.solo-wx { left: 16px; top: 462px; width: 230px; height: 78px; }
.solo-wx .wx-text { position: absolute; left: 62px; top: 2px; width: 165px; font-size: 11px; color: #ccccdd; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.solo-wx .graph { position: absolute; left: 8px; top: 22px; }
.solo-wx .wet { position: absolute; left: 206px; top: 22px; width: 12px; height: 40px; border: 1px solid #555c6c; }
.solo-wx .wet i { position: absolute; left: 0; bottom: 0; width: 10px; background: #4a90d9; }
.solo-wx .wet u { position: absolute; left: -3px; width: 16px; height: 2px; background: var(--accent); }
.solo-wx .ticks { position: absolute; left: 8px; top: 63px; width: 190px; display: flex; justify-content: space-between; font-size: 9px; color: #777788; }
/* 雨と運転席 */
.rain-shade { position: absolute; inset: 0; background: #141e32; opacity: 0; }
.rain { position: absolute; inset: 0; }
.cockpit .halo-bar { position: absolute; left: 50%; top: 0; width: 18px; height: 42%; margin-left: -9px; background: #15171b; }
.cockpit .halo-top { position: absolute; left: -15%; top: -21%; width: 130%; height: 30%; border-radius: 50%; background: #15171b; }
.cockpit .wheel { position: absolute; left: 50%; bottom: -14vmin; width: 57vmin; height: 39vmin; border-radius: 50%; background: #222; border: 3px solid #111; }
.cockpit .wheel i { position: absolute; left: 50%; top: 4px; width: 8px; height: 12px; margin-left: -4px; background: #e8423a; }

/* ---- タイトル・結果 ---- */
.shade { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); display: grid; place-items: center; overflow: auto; }
.card { background: rgba(20, 23, 31, 0.96); border-radius: 10px; padding: 16px 30px 20px; }
.title-card { width: min(880px, 96vw); }
.card h1 { text-align: center; margin: 0; font-size: 34px; }
.card h2 { text-align: center; margin: 0 0 10px; font-size: 26px; }
.title-card > .sub { text-align: center; color: #aab; margin: 6px 0 10px; }
button { font: inherit; color: #fff; background: #3a4050; border: 0; border-radius: 6px; padding: 6px 14px; cursor: pointer; }
button:hover { filter: brightness(1.15); }
.title-card .online { display: block; margin: 0 auto 12px; width: 260px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 34px; }
.opts label { display: block; }
.opts span { display: block; font-size: 13px; color: #aab; margin-bottom: 2px; }
select { width: 100%; font: inherit; color: #fff; background: #2a2e38; border: 0; border-radius: 6px; padding: 6px 8px; }
.title-card .start, .result-card .again { display: block; margin: 14px auto 0; width: 280px; font-size: 20px; padding: 10px; background: #27a05a; }
.title-card .keys { font-size: 12px; color: #aab; line-height: 1.5; }
.result-card { width: min(900px, 96vw); }
table.result { width: 100%; border-collapse: separate; border-spacing: 0 1px; font-size: 13px; }
table.result th { text-align: left; color: #aab; font-weight: bold; padding: 2px 6px; }
table.result td { background: rgba(30, 34, 44, 0.7); padding: 2px 6px; }
table.result tr.mine td { background: rgba(60, 52, 20, 0.9); }
table.result .dot { display: inline-block; width: 10px; height: 11px; margin-right: 4px; vertical-align: -1px; }
.chart-title { font-weight: bold; margin: 10px 0 4px 50px; }
.result-card .chart { display: block; margin: 0 auto; background: #0e1016; }

/* ---- オプション ---- */
.opt-btn { position: absolute; right: 16px; top: 14px; width: 96px; height: 28px; padding: 0; font-size: 13px; background: #2a2e38; }
.opt-panel { position: absolute; right: 16px; top: 48px; width: 300px; padding: 10px 14px; background: rgba(20, 23, 31, 0.97); border-radius: 8px; }
.opt-panel label { display: block; margin-top: 10px; font-size: 13px; }
.opt-panel input[type=range] { width: 100%; }
.opt-panel .close { display: block; margin: 10px 0 0 auto; }

/* ---- ピット画面 ---- */
.pit-screen { position: absolute; inset: 0; background: transparent; overflow: hidden; }
.pit-root { position: absolute; left: 0; top: 0; width: 1280px; height: 870px; transform-origin: 0 0; }
.pit-cams { position: absolute; left: 0; top: 0; bottom: 0; padding: 10px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.pit-cams .cam-cap { font-size: 13px; color: #8b90a0; }
.pit-cams .cam { width: 100%; aspect-ratio: 4 / 3; border: 1px solid #2a2f3c; border-radius: 6px; }
.pit-head { position: absolute; background: #0a0c10; display: flex; align-items: center; }
.pit-name { width: 130px; padding-left: 16px; font-weight: bold; color: #ffcc33; }
.pit-hlap { width: 170px; font-weight: bold; font-size: 22px; }
.pit-htime { width: 170px; }
.pit-hphase { width: 520px; text-align: center; font-weight: bold; color: #ffcc33; border-radius: 4px; padding: 3px 0; }
.pit-hback { width: 120px; text-align: center; font-size: 13px; color: #99ccff; }
.pit-hlink { width: 130px; text-align: center; font-size: 13px; border-radius: 4px; padding: 3px 0; margin-left: 10px; }
.pit-section { position: absolute; background: #181b23; border: 1px solid #2a2f3c; border-radius: 8px; }
.pit-title { position: absolute; left: 12px; top: 6px; color: #8b90a0; }
.pit-section > canvas { position: absolute; left: 0; top: 0; }
.pit-map-note { position: absolute; left: 14px; bottom: 8px; font-size: 12px; color: #8b90a0; }
.pit-tower { position: absolute; left: 6px; top: 4px; width: 498px; border-collapse: collapse; font-size: 14px; }
.pit-tower th { font-size: 12px; color: #8b90a0; font-weight: normal; text-align: left; border-bottom: 1px solid #2a2f3c; height: 20px; }
.pit-tower td { height: 25px; white-space: nowrap; }
.pit-tower .r { text-align: right; padding-right: 6px; }
.pit-tower .tire { padding-left: 14px; }
.pit-tower tr.me td { background: #3a3220; color: #ffe08a; font-weight: bold; }
.pit-tower .sw { display: inline-block; width: 4px; height: 14px; margin-right: 6px; vertical-align: -2px; }
.pit-tower .tdot { display: inline-block; width: 18px; height: 18px; line-height: 13px; border: 3px solid; border-radius: 50%; background: #111;
  text-align: center; font-style: normal; font-weight: bold; font-size: 11px; margin-right: 6px; vertical-align: middle; box-sizing: border-box; }
.pit-wx-title { position: absolute; font-size: 13px; line-height: 15px; }
.pit-wx-legend { position: absolute; font-size: 12px; color: #8b90a0; }
.small { color: #8b90a0; font-size: 13px; }
.pit-card { position: absolute; background: #11141a; border-radius: 6px; overflow: hidden; }
.pit-lines { position: absolute; font-size: 14px; line-height: 1.55; }
.pit-lines.big { line-height: 1.45; }
.pit-lines .g { font-size: 22px; }
.pit-pred { border-left: 3px solid #ffcc33; }
.pit-predict { position: absolute; left: 10px; top: 0; right: 6px; line-height: 28px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pit-carfig { position: absolute; }
.pit-carfig > div { position: absolute; }
.cf-front { left: 90px; top: 0; width: 20px; text-align: center; font-size: 11px; color: #ccccdd; }
.cf-fw { left: 48px; top: 12px; width: 104px; height: 10px; }
.cf-fw i { position: absolute; top: 0; width: 50%; height: 100%; }
.cf-floor { left: 72px; top: 22px; width: 56px; height: 138px; border: 1px solid #777; }
.cf-rw { left: 64px; top: 170px; width: 72px; height: 12px; }
.cf-wh { line-height: 46px; text-align: center; font-weight: bold; font-size: 12px; color: #111; }
.cf-barbg { background: #262b36; }
.cf-bar { height: 5px; }
.cf-left { text-align: center; font-size: 11px; color: #ccccdd; }
.cf-bat { left: 178px; top: 30px; width: 18px; height: 132px; border: 1px solid #888899; }
.cf-bat i { position: absolute; left: 0; bottom: 0; width: 16px; }
.cf-batcap { left: 173px; top: 166px; width: 28px; text-align: center; font-size: 11px; color: #ccccdd; }
.cf-battxt { left: 171px; top: 180px; width: 32px; text-align: center; font-size: 11px; color: #ccccdd; }
.pit-label { position: absolute; line-height: 26px; font-size: 13px; }
.pit-btn { position: absolute; background: #232833; border-radius: 6px; text-align: center; line-height: 26px; font-size: 13px; cursor: pointer; user-select: none; }
.pit-btn:hover, .pit-radio:hover { filter: brightness(1.2); }
.pit-rule { position: absolute; font-size: 12px; color: #8b90a0; line-height: 14px; }
.pit-angval { position: absolute; text-align: center; font-weight: bold; line-height: 26px; }
.pit-radio { position: absolute; background: #232833; border-radius: 6px; padding: 4px 8px; cursor: pointer; user-select: none; font-size: 14px; }
.pit-radio .k { color: #8b90a0; font-size: 12px; }
.pit-radio .rs { font-size: 12px; color: #8b90a0; margin-top: 2px; }
.pit-sent { position: absolute; font-size: 13px; color: #ffcc33; }
.pit-from { position: absolute; font-size: 14px; line-height: 28px; padding-left: 6px; border-radius: 4px; }
.pit-work-shade { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; }
.pit-work-card { width: 560px; padding: 10px 20px 16px; background: #181b23; border: 2px solid #ffcc33; border-radius: 10px; }
.pit-work-title { font-weight: bold; font-size: 22px; color: #ffcc33; }
.pit-work-card .pit-rule { position: static; margin: 4px 0 6px; }
.pit-work-text { text-align: center; font-size: 16px; min-height: 48px; }
.pit-ask-warn { border: 3px solid #a3282a; border-radius: 6px; padding: 8px; text-align: center; font-size: 16px; }
.pit-ask-cap { text-align: center; color: #8b90a0; margin: 12px 0 4px; }
.pit-ask-row { display: flex; justify-content: center; gap: 25px; }
.pit-ask-btn { width: 120px; height: 50px; line-height: 50px; text-align: center; border: 2px solid #3fb950; border-radius: 6px; cursor: pointer; font-size: 16px; }
.pit-ask-ok, .pit-ask-skip { margin-top: 20px; width: 150px; height: 44px; line-height: 44px; text-align: center; border-radius: 6px; cursor: pointer; background: #2d5fa8; }
.pit-ask-skip { background: #232833; }

/* ---- ロビー ---- */
.lobby { position: absolute; inset: 0; background: rgba(15, 17, 22, 0.97); overflow: auto; }
.lobby-root { width: min(980px, 96vw); margin: 20px auto; }
.lobby-head { display: flex; align-items: center; gap: 16px; background: #0a0c10; border-radius: 8px; padding: 8px 16px; }
.lobby-title { color: #ffcc33; font-size: 18px; flex: 1; }
.lobby-name input, .lobby-list input { font: inherit; color: #fff; background: #11141a; border: 0; border-radius: 6px; padding: 6px 10px; }
.lobby-conn { font-size: 13px; padding: 4px 10px; border-radius: 4px; }
.lobby-list, .lobby-room { margin-top: 10px; background: #181b23; border-radius: 8px; padding: 12px 20px; }
.lobby-list h3 { margin: 6px 0; font-size: 16px; }
.lobby-list .row { display: flex; gap: 10px; margin-bottom: 8px; }
.lobby-list .room-name { width: 360px; }
.lobby .lobby-note { font-size: 12px; color: #8b90a0; }
.lobby .dim { color: #8b90a0; }
table.rooms, table.slots { width: 100%; border-collapse: separate; border-spacing: 0 3px; font-size: 14px; }
table.rooms th, table.slots th { text-align: left; font-size: 12px; color: #8b90a0; font-weight: normal; }
table.rooms td, table.slots td { background: rgba(32, 36, 47, 0.7); padding: 3px 6px; height: 30px; }
table.slots tr.closed td { opacity: 0.45; }
table.slots .sw { display: inline-block; width: 12px; height: 14px; margin-right: 6px; vertical-align: -2px; }
table.slots select { width: auto; padding: 3px 6px; font-size: 12px; }
.seat { width: 200px; padding: 3px 6px; font-size: 13px; }
.seat.free { background: #2d5fa8; } .seat.taken { background: #2a2e38; } .seat.mine { background: #6a5a10; }
.seat:disabled { cursor: default; filter: none; }
.room-top { display: flex; align-items: center; gap: 20px; }
.room-top .r-title { font-size: 20px; } .room-top .r-code { font-size: 20px; color: #ffcc33; }
.room-top .leave { margin-left: auto; }
.r-master { font-size: 12px; color: #8b90a0; margin: 4px 0 8px; }
.r-settings { display: inline-flex; gap: 8px; vertical-align: top; }
.r-settings label span { display: block; font-size: 12px; color: #8b90a0; }
.r-settings select { width: 150px; }
.r-forecast { display: inline-block; margin-left: 12px; padding: 4px 8px; background: #11141a; border-radius: 6px; width: 310px; position: relative; vertical-align: top; }
.r-forecast .fc-text { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 200px; }
.r-forecast .reroll { position: absolute; right: 6px; top: 3px; font-size: 11px; padding: 2px 6px; }
.r-forecast .fc-ticks { display: flex; justify-content: space-between; font-size: 9px; color: #8b90a0; width: 290px; }
.room-bottom { display: flex; align-items: center; gap: 16px; }
.room-bottom .r-status { flex: 1; font-size: 13px; color: #8b90a0; }
.room-bottom .start { width: 310px; font-size: 18px; padding: 10px; background: #27a05a; }
.room-bottom .toLobby { width: 310px; font-size: 16px; padding: 10px; }
.room-bottom .rejoin { background: #2d5fa8; }
.pit-cams .cam { position: relative; }
.pit-cams .cam-speed { position: absolute; right: 8px; bottom: 6px; padding: 2px 8px; background: rgba(10, 12, 18, 0.72); border-radius: 4px; font-size: 13px; color: #ddddee; }
.pit-cams .cam-speed b { font-family: "Roboto Mono", "Consolas", monospace; font-size: 22px; color: #fff; }

/* 常に出す FPS（1秒あたりのコマ数）。60 前後なら緑、40 未満は赤 */
#fps { position: fixed; right: 6px; bottom: 4px; z-index: 9999; pointer-events: none; font: bold 12px/1 monospace; padding: 3px 6px; border-radius: 4px; background: rgba(0,0,0,0.55); color: #8fd18f; }
