:root { --dc: "Arial Narrow", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif; --ui: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif; --acc: #ffd24a; --blue: #2f6bff; --red: #ff3b3b; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: #fff; font-family: var(--ui); user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* —— 执法记录仪风格 HUD —— */
#hud { position: fixed; inset: 0; pointer-events: none; font-family: var(--dc); font-weight: 700; text-shadow: 0 0 3px #000, 1px 1px 2px #000; }
#dc-top { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); text-align: center; font-size: clamp(13px, 1.7vw, 22px); line-height: 1.25; letter-spacing: .5px; }
#mini { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + clamp(40px, 4.8vw, 62px)); left: 50%; transform: translateX(-50%); width: min(36vw, 560px); height: auto; opacity: .92; }
#dc-speed { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: 46px; font-size: clamp(15px, 1.9vw, 24px); }
#status { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: 78px; font: 600 13px var(--ui); line-height: 1.5; }
#status b { color: var(--acc); } #status .bad { color: var(--red); }
#dc-ind { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); font-size: clamp(14px, 1.7vw, 22px); white-space: nowrap; }
#dc-ind span { margin: 0 8px; opacity: .55; }
#dc-ind span::before { content: ""; display: inline-block; width: .7em; height: .7em; border-radius: 50%; background: #555; margin-right: 6px; }
#dc-ind span.on { opacity: 1; } #dc-ind span.on::before { background: #35d04a; box-shadow: 0 0 6px #35d04a; }
#dc-id { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: 12px; text-align: right; font-size: clamp(13px, 1.6vw, 21px); line-height: 1.3; }
#shift { position: absolute; left: max(14px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); font: 600 13px/1.55 var(--ui); }
#shift b { color: var(--acc); } #shift b.bad { color: var(--red); }
#track { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: 92px; font: 600 12px var(--ui); opacity: .8; max-width: 40vw; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#radio { position: absolute; left: max(14px, env(safe-area-inset-left)); top: 104px; width: min(36vw, 420px); font: 500 14px/1.45 var(--ui); display: flex; flex-direction: column; gap: 5px; }
#radio div { background: rgba(8, 12, 20, .62); border-left: 3px solid var(--blue); padding: 5px 9px; border-radius: 0 6px 6px 0; animation: rin .25s ease-out; transition: opacity .6s; }
#radio div.warn { border-color: var(--red); } #radio div.good { border-color: #35d04a; } #radio div.old { opacity: 0; }
#radio b { color: #9ec1ff; margin-right: 6px; }
@keyframes rin { from { transform: translateX(-14px); opacity: 0; } }

#side { position: absolute; right: max(14px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); width: min(30vw, 330px); display: flex; flex-direction: column; gap: 8px; }
.panel { background: rgba(6, 14, 30, .78); border: 1px solid rgba(120, 160, 255, .45); border-radius: 8px; padding: 9px 11px; font: 500 13px/1.6 "SF Mono", Menlo, Consolas, var(--ui); text-shadow: none; }
.panel h4 { margin: 0 0 4px; font: 700 12px var(--ui); letter-spacing: 2px; color: #9ec1ff; }
.panel .row { display: flex; justify-content: space-between; gap: 10px; } .panel .row span:first-child { opacity: .65; }
.panel .bad { color: var(--red); font-weight: 700; } .panel .ok { color: #58e06d; } .panel .hl { color: var(--acc); font-weight: 700; }
.bar { height: 6px; background: rgba(255, 255, 255, .15); border-radius: 3px; overflow: hidden; margin: 3px 0 2px; } .bar i { display: block; height: 100%; background: var(--acc); }

#banner { position: absolute; left: 50%; top: 27%; transform: translate(-50%, -50%); font: 800 clamp(22px, 3.6vw, 46px) var(--ui); letter-spacing: 3px; padding: 8px 26px; background: rgba(0, 0, 0, .45); border-top: 2px solid var(--acc); border-bottom: 2px solid var(--acc); white-space: nowrap; animation: bin .3s ease-out; }
#banner.warn { border-color: var(--red); color: #ffd9d9; } #banner.good { border-color: #35d04a; color: #dcffe2; }
@keyframes bin { from { transform: translate(-50%, -50%) scale(1.25); opacity: 0; } }
#bottom { position: absolute; left: 50%; bottom: 46px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(70vw, 760px); }
#prompt { font: 600 15px/1.6 var(--ui); text-align: center; }
#prompt kbd, .card kbd { display: inline-block; min-width: 22px; padding: 1px 6px; margin: 0 3px; border: 1px solid rgba(255, 255, 255, .7); border-radius: 5px; background: rgba(0, 0, 0, .5); font: 700 13px var(--dc); text-align: center; text-shadow: none; }
#progress { width: min(46vw, 420px); height: 22px; background: rgba(0, 0, 0, .55); border: 1px solid rgba(255, 255, 255, .5); border-radius: 11px; position: relative; overflow: hidden; }
#progress i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #2f6bff, #6fa0ff); }
#progress span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 600 12px var(--ui); }

#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .35s; }
#fade.on { opacity: 1; }
#toast { position: fixed; left: 50%; top: 12%; transform: translateX(-50%); font: 600 14px var(--ui); background: rgba(0, 0, 0, .6); padding: 6px 14px; border-radius: 16px; opacity: 0; transition: opacity .4s; pointer-events: none; }
#toast.on { opacity: 1; }

/* —— 菜单 / 结算卡片 —— */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 30%, rgba(14, 26, 54, .78), rgba(0, 0, 0, .9)); overflow: auto; touch-action: pan-y; padding: 12px; }
#result, #pause { background: rgba(0, 0, 0, .55); }
.card { width: min(92vw, 520px); max-height: 94vh; overflow: auto; background: rgba(10, 16, 30, .94); border: 1px solid rgba(120, 160, 255, .4); border-radius: 14px; padding: 20px 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); font-size: 14px; line-height: 1.65; user-select: text; -webkit-user-select: text; }
.card.wide { width: min(96vw, 1060px); }
.card h1 { margin: 0; font-size: clamp(26px, 4vw, 44px); letter-spacing: 6px; text-align: center; }
.card h1 small { display: block; font-size: 13px; letter-spacing: 3px; opacity: .6; font-weight: 500; margin-top: 2px; }
.card h2 { margin: 0 0 8px; font-size: 20px; } .card h3 { margin: 14px 0 6px; font-size: 13px; letter-spacing: 2px; color: #9ec1ff; }
.card .good { color: #58e06d; } .card .bad { color: var(--red); } .card .hl { color: var(--acc); font-weight: 700; }
.card .row { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed rgba(255, 255, 255, .12); padding: 2px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-top: 12px; }
.box { background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 10px 12px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { flex: 1 1 150px; border: 1px solid rgba(255, 255, 255, .25); border-radius: 9px; padding: 8px 10px; cursor: pointer; background: rgba(255, 255, 255, .04); }
.opt b { display: block; } .opt small { opacity: .7; font-size: 12px; line-height: 1.4; display: block; }
.opt.sel { border-color: var(--acc); background: rgba(255, 210, 74, .13); } .opt.lock { opacity: .42; cursor: not-allowed; }
button.btn { font: 700 15px var(--ui); color: #fff; background: #1e3f9a; border: 1px solid #6f9dff; border-radius: 9px; padding: 9px 18px; cursor: pointer; }
button.btn:hover { background: #2a55c9; } button.btn.go { background: #c98a12; border-color: #ffd24a; font-size: 18px; padding: 12px 34px; letter-spacing: 4px; }
button.btn.sm { font-size: 12px; padding: 4px 10px; font-weight: 600; } button.btn:disabled { opacity: .4; cursor: not-allowed; }
.card input[type=text] { font: 600 14px var(--ui); background: rgba(255, 255, 255, .08); color: #fff; border: 1px solid rgba(255, 255, 255, .3); border-radius: 6px; padding: 4px 8px; width: 150px; }
.card input[type=range] { width: 130px; vertical-align: middle; }
.center { text-align: center; margin-top: 14px; } .muted { opacity: .65; font-size: 12px; }
.xpbar { height: 8px; background: rgba(255, 255, 255, .12); border-radius: 4px; overflow: hidden; } .xpbar i { display: block; height: 100%; background: linear-gradient(90deg, #2f6bff, #9ec1ff); }
.keys { columns: 2; column-gap: 18px; font-size: 13px; } .keys div { break-inside: avoid; }

/* —— 手机虚拟按键 —— */
#touch { position: absolute; inset: 0; font-family: var(--ui); text-shadow: none; }
#touch button { pointer-events: auto; font: 700 13px var(--ui); color: #fff; background: rgba(10, 20, 40, .5); border: 1px solid rgba(255, 255, 255, .55); border-radius: 12px; min-width: 56px; height: 46px; padding: 0 8px; }
#touch button.on { background: rgba(255, 210, 74, .55); } #touch button.big { background: rgba(30, 63, 154, .6); min-width: 68px; height: 56px; font-size: 15px; }
#touch .tl { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: 118px; display: flex; flex-wrap: wrap; gap: 8px; width: 200px; }
#touch .tr { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: 100px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; width: 216px; }
#touch .only-p, #touch .only-c, #touch .only-s, #touch .only-br { display: none; }
#touch.g-p .only-p, #touch.g-c .only-c, #touch.g-s .only-s, #touch.ex .only-e, #touch.g-c.br .only-br { display: block; }
#touch button.sm { min-width: 46px; height: 36px; font-size: 11px; opacity: .8; }
#touch .steer { display: none; width: 88px; height: 64px; font-size: 22px; } #touch.nosense .steer { display: block; }
#touch .hint { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); font-size: 11px; opacity: .55; white-space: nowrap; }
#rotate { display: none; position: fixed; inset: 0; background: #000; align-items: center; justify-content: center; font-size: 20px; z-index: 99; }
@media (pointer: coarse) and (orientation: portrait) { #rotate { display: flex; } }
@media (max-height: 520px) { #radio { top: 70px; font-size: 12px; width: 34vw; } .panel { font-size: 11px; padding: 6px 8px; } #side { width: 30vw; } #status { bottom: 66px; font-size: 11px; } #bottom { bottom: 40px; } #prompt { font-size: 12px; } }

/* 中弹：屏幕边缘一闪红 */
#hurt { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 180px 70px rgba(200, 0, 0, .8); opacity: 0; transition: opacity .5s ease-out; }
#hurt.on { opacity: 1; transition: none; }
/* 菜单里的拦停要领 */
.rule { margin: 10px 0 4px; padding: 8px 10px; border-left: 3px solid var(--red); background: rgba(255, 60, 60, .09); line-height: 1.55; }
.rule b { color: #ffd24a; }
