:root {
  --red: #e4002b; --amber: #ffae3b; --cyan: #38c8ff; --green: #5aff96;
  --ink: #e9edf2; --dim: rgba(233, 237, 242, .55); --glass: rgba(14, 18, 26, .55); --line: rgba(255, 255, 255, .12);
  --sans: "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --num: "Bahnschrift", "DIN Alternate", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #04060a; color: var(--ink); font-family: var(--sans); overflow: hidden; user-select: none; }
#app { position: fixed; inset: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, .55) 100%); }
#letterbox i { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height .9s cubic-bezier(.7, 0, .2, 1); pointer-events: none; z-index: 2; }
#letterbox i:first-child { top: 0; } #letterbox i:last-child { bottom: 0; }
#letterbox.on i { height: 5.5vh; }

.overlay { position: absolute; opacity: 0; pointer-events: none; transition: opacity .7s ease, transform .9s cubic-bezier(.2, .8, .2, 1); z-index: 5; }
.overlay.show { opacity: 1; }
.glass { background: var(--glass); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .35); }

/* 标题 */
.tc-kicker { font: 600 12px/1 var(--num); letter-spacing: .5em; color: var(--dim); }
.tc-logo { font: 800 clamp(64px, 11vw, 168px)/1 var(--num); letter-spacing: -.02em; margin: 18px 0 8px; background: linear-gradient(180deg, #fff 30%, #9aa6b4); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tc-logo span { color: var(--red); -webkit-text-fill-color: var(--red); }
.tc-logo.sm { font-size: clamp(48px, 7vw, 104px); margin: 0; }
.tc-sub { font-size: clamp(16px, 1.8vw, 26px); letter-spacing: .3em; font-weight: 300; }
.tc-line { width: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--red), transparent); margin: 26px auto 0; transition: width 2.5s ease .4s; }
#titleCard { inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; transform: scale(1.04); }
#titleCard.show { transform: scale(1); }
#titleCard.show .tc-line { width: 46vw; }

/* 章节 */
#chapter { left: 5vw; top: 9vh; display: flex; align-items: center; gap: 16px; transform: translateX(-30px); }
#chapter.show { transform: none; }
.ch-n { font: 700 54px/1 var(--num); color: transparent; -webkit-text-stroke: 1.2px rgba(255, 255, 255, .75); }
.ch-t b { display: block; font-size: 26px; font-weight: 600; letter-spacing: .08em; }
.ch-t small { display: block; font: 600 11px var(--num); letter-spacing: .45em; color: var(--red); margin-top: 6px; }
#chapter::before { content: ""; position: absolute; left: -5vw; top: 50%; width: 4vw; height: 2px; background: var(--red); }

/* 字幕 */
#subtitle { position: absolute; left: 50%; bottom: 10.5vh; transform: translateX(-50%); width: min(980px, 86vw); text-align: center; z-index: 6; pointer-events: none; }
#subtitle span { display: inline-block; padding: 10px 22px; font-size: clamp(15px, 1.35vw, 21px); line-height: 1.6; letter-spacing: .04em; background: rgba(5, 8, 12, .55); border-radius: 8px; backdrop-filter: blur(6px); opacity: 0; transform: translateY(10px); transition: opacity .45s, transform .45s; text-shadow: 0 1px 2px #000; }
#subtitle span.show { opacity: 1; transform: none; }
#subtitle span em { font-style: normal; color: var(--amber); }

/* 参数卡 */
#specs { right: 5vw; top: 50%; transform: translate(30px, -50%); display: grid; gap: 14px; }
#specs.show { transform: translate(0, -50%); }
.spec { padding: 14px 22px 12px; border-left: 2px solid var(--red); background: linear-gradient(90deg, rgba(228, 0, 43, .12), transparent); min-width: 220px; }
.spec b { font: 700 44px/1 var(--num); }
.spec i { font: 500 18px var(--num); font-style: normal; margin-left: 4px; color: var(--dim); }
.spec small { display: block; margin-top: 6px; font-size: 13px; color: var(--dim); letter-spacing: .1em; }

/* 冲程 */
#strokePanel { left: 4vw; top: 50%; transform: translate(-20px, -50%); padding: 16px 18px; width: 260px; }
#strokePanel.show { transform: translate(0, -50%); }
.sp-h { font: 600 11px var(--num); letter-spacing: .25em; color: var(--dim); margin-bottom: 8px; }
.sp-ring { position: relative; width: 220px; height: 220px; margin: 0 auto; }
.sp-ring canvas { width: 220px; height: 220px; }
.sp-name { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.sp-name b { font-size: 34px; letter-spacing: .1em; }
.sp-name small { font: 600 10px var(--num); letter-spacing: .3em; color: var(--dim); }
.sp-valves { display: flex; justify-content: space-around; margin-top: 10px; font-size: 13px; }
.vl i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #333; margin-right: 6px; vertical-align: 0; transition: background .2s, box-shadow .2s; }
.vl.on i { background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }
#vEx.on i { background: #ff7a4a; box-shadow: 0 0 10px #ff7a4a; }
.vl span { color: var(--dim); }
.sp-back { margin-top: 10px; font-size: 12.5px; color: var(--cyan); text-align: center; opacity: 0; transition: opacity .3s; padding: 6px; border: 1px dashed rgba(56, 200, 255, .5); border-radius: 8px; }
.sp-back.on { opacity: 1; }

/* 图表 */
#pvPanel { right: 4vw; top: 50%; transform: translate(20px, -50%); width: min(460px, 34vw); padding: 14px 16px; }
#pvPanel.show, #bsfcPanel.show { transform: translate(0, -50%); }
.ph { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.ph small { font-size: 11px; color: var(--dim); font-weight: 400; margin-left: 8px; }
#pv { width: 100%; height: 280px; display: block; }
.pv-foot { display: flex; gap: 18px; font-size: 13px; color: var(--dim); margin-top: 6px; }
.pv-foot b { color: var(--amber); font: 700 18px var(--num); margin-left: 4px; }
.dim { opacity: .55; }
#bsfcPanel { left: 4vw; top: 50%; transform: translate(-20px, -50%); width: min(600px, 44vw); padding: 14px 16px; }
#bsfc { width: 100%; height: 360px; display: block; }

/* 模式 HUD */
#modeHud { left: 3vw; bottom: 17vh; width: 330px; padding: 12px 14px 10px; transform: translateY(20px); }
#modeHud.show { transform: none; }
body.interactive #modeHud { bottom: 3vh; }
.mh-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
#modeName { font-size: 20px; font-weight: 700; letter-spacing: .08em; transition: color .4s; }
.mh-title small { font: 600 10px var(--num); letter-spacing: .3em; color: var(--dim); }
#modeSvg { width: 100%; display: block; }
#modeSvg rect { fill: rgba(255, 255, 255, .04); stroke: rgba(255, 255, 255, .25); stroke-width: 1; transition: all .4s; }
#modeSvg text { fill: var(--dim); font-size: 13px; text-anchor: middle; font-family: var(--sans); transition: fill .4s; }
#modeSvg text.small { font-size: 10px; text-anchor: start; }
#modeSvg circle { fill: none; stroke: rgba(255, 255, 255, .3); stroke-width: 1.5; transition: all .4s; }
#modeSvg .links path { fill: none; stroke: rgba(255, 255, 255, .12); stroke-width: 3; stroke-linecap: round; transition: stroke .4s; }
#modeSvg .links path.on { stroke-dasharray: 6 7; animation: dash .5s linear infinite; stroke-width: 3.5; filter: drop-shadow(0 0 4px currentColor); }
#modeSvg .links path.rev { animation-direction: reverse; }
#modeSvg .links path.e { stroke: var(--amber); color: var(--amber); }
#modeSvg .links path.b { stroke: var(--cyan); color: var(--cyan); }
#modeSvg .links path.g { stroke: var(--green); color: var(--green); }
#modeSvg g.on rect { fill: rgba(255, 255, 255, .1); stroke: #fff; }
#modeSvg g.on text { fill: #fff; }
#modeSvg g.on circle { fill: var(--amber); stroke: var(--amber); }
@keyframes dash { to { stroke-dashoffset: -13; } }
.mh-legend { font-size: 11px; color: var(--dim); display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.lg { width: 14px; height: 3px; border-radius: 2px; display: inline-block; margin-left: 6px; }
.lg.e { background: var(--amber); } .lg.b { background: var(--cyan); } .lg.g { background: var(--green); }

/* 仪表 */
#statsHud { right: 3vw; bottom: 17vh; width: 230px; padding: 14px 16px; transform: translateY(20px); }
#statsHud.show { transform: none; }
body.interactive #statsHud { bottom: auto; top: 3vh; right: 352px; }
.st-speed { display: flex; align-items: baseline; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 8px; }
.st-speed b { font: 700 52px/1 var(--num); }
.st-speed small { font: 500 14px var(--num); color: var(--dim); }
.st-row { display: flex; align-items: baseline; font-size: 13px; color: var(--dim); margin: 4px 0; }
.st-row span { flex: 1; }
.st-row b { font: 600 18px var(--num); color: var(--ink); margin-right: 4px; }
.st-row small { font: 11px var(--num); }
.st-soc { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); margin-top: 8px; }
.st-soc .bar { flex: 1; height: 6px; background: rgba(255, 255, 255, .1); border-radius: 3px; overflow: hidden; }
.st-soc .bar i { display: block; height: 100%; width: 60%; background: linear-gradient(90deg, var(--cyan), var(--green)); transition: width .3s; }
.st-soc b { font: 600 13px var(--num); color: var(--ink); width: 36px; text-align: right; }
.st-note { font-size: 10.5px; color: var(--dim); opacity: .7; margin-top: 8px; }

/* 片尾 */
#endCard { inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; background: radial-gradient(ellipse at center, rgba(4, 6, 10, .55), transparent 70%); }
#endCard.show { pointer-events: auto; }
.ec-line { font-size: clamp(16px, 1.7vw, 24px); letter-spacing: .2em; font-weight: 300; }
.ec-modes { display: flex; gap: 10px; }
.ec-modes span { padding: 6px 14px; border-radius: 99px; font-size: 13px; border: 1px solid currentColor; }
.b { color: var(--cyan); } .g { color: var(--green); } .e { color: var(--amber); }

/* 按钮 */
.btn { font: 500 14px var(--sans); color: var(--ink); border: 1px solid var(--line); background: rgba(255, 255, 255, .06); padding: 10px 20px; border-radius: 99px; cursor: pointer; transition: all .2s; letter-spacing: .05em; }
.btn:hover { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .3); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 8px 30px rgba(228, 0, 43, .35); }
.btn.primary:hover { background: #ff1744; transform: translateY(-1px); }
.btn.big { font-size: 18px; padding: 15px 34px; }
.btn.sm { font-size: 12.5px; padding: 7px 14px; }
.btn.ghost { background: transparent; }

/* 开始 */
#startScreen { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; text-align: center; background: radial-gradient(ellipse at 50% 60%, rgba(30, 6, 12, .6), rgba(2, 3, 6, .92) 70%); transition: opacity .8s; }
#startScreen.hide { opacity: 0; pointer-events: none; }
.ss-btns { display: flex; gap: 14px; justify-content: center; margin: 38px 0 22px; }
.ss-note { font-size: 13px; color: var(--dim); letter-spacing: .05em; margin-top: 8px; }
#playBtn:disabled { opacity: .4; cursor: wait; }

/* 控制条 */
#controls { position: absolute; left: 50%; bottom: 1.4vh; transform: translateX(-50%); width: min(1100px, 92vw); display: none; align-items: center; gap: 14px; z-index: 8; padding: 8px 14px; border-radius: 99px; background: rgba(8, 10, 14, .55); backdrop-filter: blur(10px); border: 1px solid var(--line); transition: opacity .5s; }
body.video #controls { display: flex; }
body.video.idle #controls { opacity: 0; }
body.video.idle { cursor: none; }
.icon { width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; font-size: 14px; }
.icon:hover { background: rgba(255, 255, 255, .18); }
#cTime { font: 500 13px var(--num); color: var(--dim); white-space: nowrap; min-width: 98px; }
#cBar { position: relative; flex: 1; height: 22px; cursor: pointer; }
#cBar::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .15); }
#cFill { position: absolute; left: 0; top: 10px; height: 3px; border-radius: 2px; background: var(--red); width: 0; box-shadow: 0 0 10px rgba(228, 0, 43, .6); }
#cTicks i { position: absolute; top: 7px; width: 2px; height: 9px; background: rgba(255, 255, 255, .45); }
#cTicks i:hover::after, #cTicks i.tip::after { content: attr(data-t); position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; padding: 4px 8px; background: rgba(0, 0, 0, .75); border-radius: 6px; }
#cHover { position: absolute; bottom: 24px; transform: translateX(-50%); font-size: 12px; padding: 4px 8px; background: rgba(0, 0, 0, .75); border-radius: 6px; white-space: nowrap; display: none; }

/* 标注 */
#calloutLines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }
#calloutLines line { stroke: rgba(255, 255, 255, .75); stroke-width: 1; }
#calloutLines circle { fill: #fff; }
#callouts { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.co { position: absolute; transform: translate(-50%, -50%); padding: 6px 12px; border-left: 2px solid var(--red); background: rgba(8, 10, 14, .62); backdrop-filter: blur(6px); white-space: nowrap; opacity: 0; transition: opacity .4s; }
.co.show { opacity: 1; }
.co b { display: block; font-size: 14px; font-weight: 600; }
.co small { font: 11px var(--num); color: var(--dim); letter-spacing: .06em; }
#hoverTip { position: absolute; z-index: 9; pointer-events: none; padding: 5px 10px; font-size: 12.5px; border-radius: 6px; background: rgba(8, 10, 14, .8); border: 1px solid var(--line); display: none; white-space: nowrap; }

/* 交互面板 */
#panel { position: absolute; right: 18px; top: 18px; bottom: 18px; width: 316px; padding: 16px 16px; z-index: 8; overflow-y: auto; transform: translateX(360px); transition: transform .7s cubic-bezier(.2, .8, .2, 1); }
body.interactive #panel { transform: none; }
.pn-h b { display: block; font-size: 18px; letter-spacing: .08em; }
.pn-h small { display: block; font-size: 11.5px; color: var(--dim); margin-top: 4px; }
.pn-sec { margin-top: 16px; }
.pn-sec label { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 8px; }
.pn-sec label b { color: var(--ink); font: 600 14px var(--num); }
.pn-sec.row { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button, .tg { flex: 1; font: 500 12.5px var(--sans); padding: 8px 6px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); color: var(--dim); cursor: pointer; transition: all .2s; white-space: nowrap; }
.seg button:hover, .tg:hover { color: var(--ink); background: rgba(255, 255, 255, .1); }
.seg button.on, .tg.on { color: #fff; background: rgba(228, 0, 43, .3); border-color: rgba(228, 0, 43, .8); }
.seg button.b.on { background: rgba(56, 200, 255, .22); border-color: var(--cyan); }
.seg button.g.on { background: rgba(90, 255, 150, .18); border-color: var(--green); }
.seg button.e.on { background: rgba(255, 174, 59, .22); border-color: var(--amber); }
.toggles { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
input[type=range] { width: 100%; accent-color: var(--red); }

/* 信息卡 */
#infoCard { position: absolute; left: 24px; top: 24px; width: 360px; padding: 18px 20px; z-index: 9; opacity: 0; transform: translateY(-10px); pointer-events: none; transition: all .35s; }
#infoCard.show { opacity: 1; transform: none; pointer-events: auto; }
#infoCard .x { position: absolute; right: 10px; top: 8px; border: none; background: none; color: var(--dim); font-size: 22px; cursor: pointer; }
.ic-tag { font: 600 10.5px var(--num); letter-spacing: .3em; color: var(--red); }
.ic-name { font-size: 20px; font-weight: 700; margin: 6px 0 10px; }
.ic-desc { font-size: 13.5px; line-height: 1.75; color: rgba(233, 237, 242, .85); }
.ic-spec { margin: 12px 0 0; padding: 0; list-style: none; }
.ic-spec li { font-size: 12.5px; padding: 6px 0; border-top: 1px solid var(--line); color: var(--dim); }
.ic-spec li::before { content: "▸ "; color: var(--red); }
.ic-btns { display: flex; gap: 8px; margin-top: 12px; }
body.interactive #modeHud, body.interactive #statsHud { opacity: 1; }

/* 小窗口自适应：缩小信息面板，保证 3D 画面可见 */
@media (max-width: 1280px), (max-height: 720px) {
  #modeHud, #statsHud, #strokePanel, #pvPanel, #bsfcPanel, #panel, #infoCard, #specs, #chapter { zoom: .72; }
  #subtitle span { font-size: 14px; padding: 6px 14px; }
}
@media (max-width: 900px), (max-height: 520px) {
  #modeHud, #statsHud, #strokePanel, #pvPanel, #bsfcPanel, #panel, #infoCard, #specs, #chapter { zoom: .55; }
}
