* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #2c3140;
  --paper: #fffaf0;
  --line: #2c3140;
  --accent: #e4573d;
  --accent2: #2f9e6e;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #10151c;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#scene { position: fixed; inset: 0; display: block; width: 100%; height: 100%; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */

#hud { position: fixed; inset: 0; pointer-events: none; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 14px; }
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 8px; }
.hud-right { align-items: flex-end; }

.gauge {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 250, 240, 0.9);
  border: 3px solid var(--line); border-radius: 999px;
  padding: 5px 12px 5px 10px;
  box-shadow: 0 3px 0 rgba(0,0,0,.2);
  font-size: 15px;
}
.gauge .bar { width: 130px; height: 13px; background: #d9d3c6; border-radius: 999px; overflow: hidden; }
.gauge .fill { height: 100%; width: 100%; background: #4cc86a; transition: width .12s linear; }
#hp-wrap.critical { animation: hpWarn .6s infinite alternate; }
@keyframes hpWarn { to { border-color: #e8503a; box-shadow: 0 3px 0 rgba(232,80,58,.5); } }

.cargo-row {
  display: flex; gap: 2px;
  background: rgba(255,250,240,.9);
  border: 3px solid var(--line); border-radius: 999px;
  padding: 3px 10px; font-size: 15px;
  box-shadow: 0 3px 0 rgba(0,0,0,.2);
}
.cargo-row .lost { opacity: .22; filter: grayscale(1); }

.fps {
  align-self: flex-start;
  background: rgba(20,24,30,.72); color: #8ef0a6;
  border-radius: 8px; padding: 2px 9px;
  font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.fps i { font-style: normal; font-size: 10px; opacity: .7; }

/* 双人模式：左上角各自的键位 */
.coop-hint { display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.coop-hint div {
  background: rgba(255,250,240,.9); border: 3px solid var(--line); border-radius: 999px;
  padding: 2px 12px; font-size: 12px; box-shadow: 0 3px 0 rgba(0,0,0,.2);
}
.coop-hint b { color: var(--accent); }
.coop-hint span { color: #5c6272; margin-left: 6px; }
.fps.mid { color: #ffd166; }
.fps.low { color: #ff7a6b; }

.hud-mid { flex: 1; text-align: center; }
.level-title {
  display: inline-block; background: rgba(44,49,64,.85); color: #fff;
  font-size: 13px; font-weight: 700; padding: 3px 12px; border-radius: 999px;
}
.chips { display: flex; gap: 6px; justify-content: center; margin-top: 6px; flex-wrap: wrap; }
.chip {
  background: rgba(255,250,240,.9); border: 3px solid var(--line); border-radius: 999px;
  padding: 3px 11px; font-size: 13px; font-weight: 700;
  box-shadow: 0 3px 0 rgba(0,0,0,.2); white-space: nowrap;
}

.compass {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,250,240,.9); border: 3px solid var(--line); border-radius: 999px;
  padding: 3px 12px 3px 8px; font-size: 12px; font-weight: 700;
  box-shadow: 0 3px 0 rgba(0,0,0,.2);
}
#compass-needle { font-size: 17px; color: var(--accent); transition: transform .12s linear; }

#minimap {
  border: 3px solid var(--line); border-radius: 10px;
  background: #2c3140; box-shadow: 0 3px 0 rgba(0,0,0,.25);
  image-rendering: auto;
}

#gearbox { position: absolute; left: 14px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.gear-box {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,250,240,.92); border: 3px solid var(--line); border-radius: 14px;
  padding: 7px 14px; box-shadow: 0 3px 0 rgba(0,0,0,.2);
}
.gear-box .rev { width: 110px; height: 14px; background: #d9d3c6; border-radius: 999px; overflow: hidden; }
#rev-fill { height: 100%; width: 0; background: #4cc86a; border-radius: 999px; transition: width .06s linear; }
.gear-no, .speed { display: flex; align-items: baseline; gap: 3px; }
.gear-no b { font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.speed b { font-size: 20px; line-height: 1; font-variant-numeric: tabular-nums; }
.gear-no span, .speed span { font-size: 11px; color: #7a8091; }

.shift-hint { font-size: 15px; font-weight: 800; padding: 3px 12px; border-radius: 999px; color: #fff; }
.shift-hint.up { background: #e8503a; animation: pulse .5s infinite alternate; }
.shift-hint.down { background: #3f7fd4; }
.shift-hint:empty { padding: 0; }
@keyframes pulse { to { opacity: .45; } }

.flash {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%);
  background: rgba(44,49,64,.88); color: #ffe066;
  font-size: 18px; font-weight: 800; padding: 8px 20px; border-radius: 999px;
  opacity: 0;
}
.flash.show { animation: flashIn 1.9s ease-out forwards; }
@keyframes flashIn {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  12% { opacity: 1; transform: translate(-50%, 0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* 联机：客机的房间大厅（居中，不像别的菜单那样靠左） */
#overlay.stage .panel.lobby { margin: 0 auto; }
.panel.lobby { width: min(520px, 100%); padding: 30px 28px; }
.panel.lobby h2 { font-size: 30px; margin: 10px 0 16px; }
.lobby-role {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: rgba(255,255,255,.06); border: 1px solid var(--edge); border-radius: 14px; padding: 12px 16px;
}
.lobby-role .oi { font-size: 30px; }
.lobby-role b { display: block; font-size: 18px; }
.lobby-role small { color: var(--dim); font-size: 13px; }
.lobby-host {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 16px 0 4px; font-size: 18px; font-weight: 800; color: var(--gold);
}
.lobby-host i {
  width: 10px; height: 10px; border-radius: 50%; background: var(--gold); flex: none;
  animation: netwaitPulse 1.2s ease-in-out infinite;
}

/* 联机：等对方加载地图 */
.netwait {
  position: absolute; left: 50%; top: 38%; transform: translateX(-50%);
  background: rgba(44,49,64,.9); color: #fff;
  font-size: 20px; font-weight: 800; padding: 12px 26px; border-radius: 999px;
  white-space: nowrap; pointer-events: none;
  animation: netwaitPulse 1.4s ease-in-out infinite;
}
@keyframes netwaitPulse { 50% { opacity: .7; } }

/* ---------- 触屏 ---------- */
#touch {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.pad-left, .pad-right { display: flex; gap: 10px; pointer-events: auto; }
.pad-mid { display: flex; flex-direction: column; gap: 8px; pointer-events: auto; }
.pedal {
  width: 78px; height: 78px; border-radius: 50%; font-size: 26px; color: var(--ink);
  background: rgba(255,250,240,.82); border: 4px solid var(--line);
  box-shadow: 0 5px 0 rgba(0,0,0,.2);
}
.gear-btn {
  width: 56px; height: 46px; border-radius: 12px; font-size: 17px; color: var(--ink);
  background: rgba(255,250,240,.82); border: 4px solid var(--line);
  box-shadow: 0 4px 0 rgba(0,0,0,.2);
}
.pedal:active, .gear-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.2); }

/* ---------- 面板：深色毛玻璃，背后是 3D 展示台 ---------- */
:root {
  --glass: rgba(13, 17, 24, .74);
  --glass2: rgba(255, 255, 255, .06);
  --edge: rgba(255, 255, 255, .12);
  --txt: #eef1f5;
  --dim: #9aa4b2;
  --hot: #ff7a3d;
  --hot2: #ffb347;
  --gold: #f5c451;
}
#overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 30% 50%, rgba(8,11,16,.55), rgba(8,11,16,.2) 70%);
  padding: 18px; overflow: auto;
}
/* 展示台模式：遮罩不挡鼠标（可以拖动画面转车），面板靠左 */
#overlay.stage { pointer-events: none; justify-content: flex-start; padding-left: max(18px, 5vw);
  background: linear-gradient(90deg, rgba(8,11,16,.72) 0%, rgba(8,11,16,.35) 38%, rgba(8,11,16,0) 60%); }
#overlay.stage .panel { pointer-events: auto; }
#overlay.stage .panel.wide { margin: 0 auto; }
#overlay.dim { background: rgba(8,11,16,.6); backdrop-filter: blur(4px); }

.panel {
  width: min(430px, 100%); color: var(--txt);
  background: var(--glass); backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--edge); border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.08);
  padding: 26px 24px; text-align: center;
  animation: panelIn .35s cubic-bezier(.2,.8,.2,1);
  /* 内容多的时候（装货界面开了双人提示）面板自己滚，不要被窗口上下截掉 */
  max-height: calc(100vh - 36px); overflow-y: auto; overscroll-behavior: contain;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.panel.wide { width: min(760px, 100%); }
.panel.side { width: min(420px, 100%); text-align: left; padding: 30px 28px; }
.panel h1 { font-size: 40px; letter-spacing: 6px; line-height: 1.05; }
.panel h2 { font-size: 24px; margin-bottom: 4px; letter-spacing: 1px; }
.sub { font-size: 14px; color: var(--dim); margin: 6px 0 14px; }
.stars { font-size: 30px; color: var(--gold); letter-spacing: 4px; text-shadow: 0 0 18px rgba(245,196,81,.45); }

/* 主菜单 */
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 62px; height: 62px; border-radius: 16px; flex: none; color: #fff;
  background: linear-gradient(135deg, var(--hot2), var(--hot) 55%, #d9432a);
  box-shadow: 0 10px 30px rgba(255,122,61,.4), inset 0 1px 0 rgba(255,255,255,.4);
  display: grid; place-items: center;
}
.brand-mark svg { width: 40px; height: 40px; }
.brand h1 {
  background: linear-gradient(180deg, #fff 30%, #c9d2dd);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-en { font-size: 12px; letter-spacing: 5px; color: var(--hot2); font-weight: 700; margin-top: 4px; }
.tagline { font-size: 14px; color: var(--dim); margin: 16px 0 18px; line-height: 1.6; }
.menu-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.menu-stats div {
  background: var(--glass2); border: 1px solid var(--edge); border-radius: 12px; padding: 10px 8px; text-align: center;
}
.menu-stats b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.menu-stats span { font-size: 11px; color: var(--dim); }
.menu-btns { display: flex; flex-direction: column; gap: 10px; }
.mbtn {
  font: inherit; color: var(--txt); cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--glass2); border: 1px solid var(--edge); border-radius: 14px;
  transition: transform .15s, background .15s, border-color .15s, box-shadow .15s;
}
.mbtn i {
  font-style: normal; width: 40px; height: 40px; flex: none; border-radius: 11px;
  display: grid; place-items: center; font-size: 18px; font-weight: 800;
  background: rgba(255,255,255,.08);
}
.mbtn span { flex: 1; }
.mbtn b { display: block; font-size: 17px; }
.mbtn small { font-size: 12px; color: var(--dim); }
.mbtn em { font-style: normal; font-size: 26px; color: var(--dim); transition: transform .15s; }
.mbtn:hover { background: rgba(255,255,255,.11); border-color: rgba(255,255,255,.25); transform: translateX(4px); }
.mbtn:hover em { transform: translateX(3px); color: var(--txt); }
.mbtn.primary { background: linear-gradient(135deg, var(--hot2), var(--hot) 50%, #e04b2c); border-color: transparent;
  box-shadow: 0 12px 30px rgba(255,122,61,.35); }
.mbtn.primary i { background: rgba(0,0,0,.18); }
.mbtn.primary small, .mbtn.primary em { color: rgba(255,255,255,.85); }
.mbtn.primary:hover { box-shadow: 0 16px 40px rgba(255,122,61,.5); }
.menu-foot { margin-top: 18px; font-size: 12px; color: var(--dim); }
.menu-foot b { color: var(--txt); }

/* 通用按钮 */
.menu-coin {
  display: inline-block; background: rgba(245,196,81,.12); border: 1px solid rgba(245,196,81,.4); color: var(--gold);
  border-radius: 999px; padding: 4px 16px; font-size: 16px; font-weight: 700; margin-bottom: 16px;
}
.btns { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.btns.row { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.btn {
  font: inherit; font-weight: 800; font-size: 16px; color: var(--txt);
  background: rgba(255,255,255,.08); border: 1px solid var(--edge); border-radius: 12px;
  padding: 11px 22px; cursor: pointer; transition: background .15s, transform .15s, box-shadow .15s;
}
.btn:hover { background: rgba(255,255,255,.14); }
.btn:active { transform: translateY(2px); }
.btn.primary { background: linear-gradient(135deg, var(--hot2), var(--hot) 50%, #e04b2c); border-color: transparent; color: #fff;
  box-shadow: 0 10px 26px rgba(255,122,61,.35); }
.btn.primary:hover { box-shadow: 0 14px 34px rgba(255,122,61,.5); }
.btn.ghost { background: transparent; }
.btn.small { font-size: 14px; padding: 8px 14px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* 选关 */
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin: 16px 0 18px; }
.level-card {
  font: inherit; color: var(--txt); text-align: left; cursor: pointer; position: relative; overflow: hidden;
  background: var(--glass2); border: 1px solid var(--edge); border-radius: 14px; padding: 14px;
  transition: transform .15s, border-color .15s, background .15s;
}
.level-card::after { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: var(--lv, var(--hot)); opacity: .9; }
.level-card:hover { transform: translateY(-3px); border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.1); }
.level-card.locked { opacity: .45; cursor: not-allowed; }
.level-card.locked:hover { transform: none; }
.lv-no {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  font-weight: 800; font-size: 14px; background: rgba(255,255,255,.1); margin-bottom: 8px;
}
.lv-name { font-weight: 800; font-size: 17px; }
.lv-name .tag {
  font-style: normal; font-size: 11px; font-weight: 700; vertical-align: 3px; margin-left: 6px;
  color: #10151c; background: linear-gradient(135deg, var(--hot2), var(--hot)); border-radius: 6px; padding: 1px 6px;
}
.lv-desc { font-size: 12px; color: var(--dim); margin: 4px 0 8px; line-height: 1.45; }
.lv-stars { color: var(--gold); font-size: 15px; letter-spacing: 2px; }
.lv-par { display: block; color: var(--dim); font-size: 11px; letter-spacing: 0; margin-top: 3px; }

/* 装货 */
.kicker { font-size: 12px; letter-spacing: 3px; color: var(--hot2); font-weight: 700; margin-bottom: 4px; }
.sec { font-size: 12px; color: var(--dim); letter-spacing: 2px; margin: 16px 0 8px; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt-grid.three { grid-template-columns: repeat(3, 1fr); }
.opt {
  font: inherit; color: var(--txt); cursor: pointer; text-align: left;
  background: var(--glass2); border: 1px solid var(--edge); border-radius: 12px; padding: 10px 11px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.opt .oi { font-size: 22px; }
.opt b { display: block; font-size: 14px; margin-top: 2px; }
.opt small { display: block; font-size: 11px; color: var(--dim); line-height: 1.4; margin-top: 3px; }
.opt:hover { background: rgba(255,255,255,.1); }
.opt.on { border-color: var(--hot); background: rgba(255,122,61,.14); box-shadow: 0 0 0 1px var(--hot) inset, 0 8px 24px rgba(255,122,61,.18); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; border: 2px solid rgba(255,255,255,.25);
  box-shadow: inset 0 -6px 10px rgba(0,0,0,.25), inset 0 4px 8px rgba(255,255,255,.3); transition: transform .15s;
}
.sw:hover { transform: scale(1.1); }
.sw.on { border-color: #fff; box-shadow: 0 0 0 3px var(--hot), inset 0 -6px 10px rgba(0,0,0,.25), inset 0 4px 8px rgba(255,255,255,.3); }
.summary { margin: 18px 0 6px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.summary div { background: var(--glass2); border: 1px solid var(--edge); border-radius: 10px; padding: 8px 6px; text-align: center; }
.summary b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.summary span { font-size: 10px; color: var(--dim); }
.summary .tip { grid-column: 1 / -1; text-align: left; font-size: 12px; color: var(--dim); line-height: 1.5; background: none; border: none; padding: 2px 0; }
/* .summary b 是 block（数字大字），提示里的 <b> 要改回行内，不然每个键名都单独占一行 */
.summary .tip b { display: inline; font-size: 12px; color: var(--txt); }
.summary .tip.coop { color: var(--dim); margin-top: 2px; }
.summary .tip.coop b { color: var(--hot2); }
#panel-load .btns.row { justify-content: flex-start; margin-top: 14px; }

/* 联机 */
.roomcode {
  display: flex; align-items: center; gap: 12px; margin: 14px 0 6px; padding: 12px 16px;
  background: rgba(255,122,61,.12); border: 1px solid var(--hot); border-radius: 14px;
}
.roomcode span { font-size: 12px; color: var(--dim); }
.roomcode b { font-size: 34px; letter-spacing: 8px; color: var(--hot2); font-variant-numeric: tabular-nums; }
.joinbar { display: flex; gap: 8px; }
.code-input {
  flex: 1; font: inherit; font-size: 22px; font-weight: 800; letter-spacing: 6px; text-align: center;
  text-transform: uppercase; color: var(--txt); background: var(--glass2);
  border: 1px solid var(--edge); border-radius: 12px; padding: 8px 10px;
}
.code-input::placeholder { font-size: 14px; letter-spacing: 2px; color: var(--dim); }
.netstatus { margin-top: 12px; font-size: 13px; color: var(--dim); min-height: 18px; }

.caption {
  position: fixed; right: max(18px, 4vw); bottom: 26px; text-align: right; pointer-events: none; color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,.6);
}
.caption b { display: block; font-size: 22px; letter-spacing: 2px; }
.caption span { font-size: 13px; opacity: .85; }

/* 车库 */
.up-list { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 18px; }
.up-row {
  display: flex; align-items: center; gap: 12px; background: var(--glass2);
  border: 1px solid var(--edge); border-radius: 14px; padding: 12px 14px; text-align: left;
}
.up-icon { font-size: 26px; }
.up-main { flex: 1; }
.up-main b { display: block; font-size: 16px; }
.up-main span { font-size: 12px; color: var(--dim); }
.dots { display: flex; gap: 4px; margin-top: 6px; }
.dots i { width: 22px; height: 7px; border-radius: 4px; background: rgba(255,255,255,.12); }
.dots i.on { background: linear-gradient(90deg, var(--hot2), var(--hot)); }

.stats { display: flex; flex-direction: column; gap: 6px; margin: 14px 0 16px; }
.stat {
  display: flex; justify-content: space-between; font-size: 15px; padding: 8px 14px;
  background: var(--glass2); border: 1px solid var(--edge); border-radius: 10px;
}

.help { text-align: left; font-size: 14px; line-height: 1.8; margin: 10px 0 18px; padding-left: 20px; }
.help b { color: var(--hot2); }

@media (max-width: 760px) {
  #overlay.stage { justify-content: center; align-items: flex-end; padding-left: 18px;
    background: linear-gradient(0deg, rgba(8,11,16,.8) 0%, rgba(8,11,16,0) 60%); }
  .caption { display: none; }
  .opt-grid.three { grid-template-columns: 1fr 1fr 1fr; }
  .summary { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .panel h1 { font-size: 30px; }
  #minimap { width: 120px; }
  .hud-mid { display: none; }
}

