/* 天际疾行 · Skyline Rush */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: #120b08; }
body {
  font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: #f3e9dd;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* 暗角与颗粒 */
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(8, 4, 2, 0.55) 100%); }
.grain { position: absolute; inset: 0; pointer-events: none; opacity: 0.05; background-image: repeating-conic-gradient(rgba(255,255,255,0.6) 0 0.0001%, transparent 0 0.0002%); mix-blend-mode: overlay; }

/* 过载速度线 */
#speedlines { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.25s;
  background: repeating-conic-gradient(from 0deg at 50% 50%, transparent 0deg 3.2deg, rgba(255, 190, 120, 0.14) 3.4deg 3.7deg, transparent 3.9deg 7deg);
  mask-image: radial-gradient(circle at center, transparent 34%, black 78%);
  -webkit-mask-image: radial-gradient(circle at center, transparent 34%, black 78%);
}
#speedlines.on { opacity: 1; animation: spin 26s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- HUD ---- */
.hud { position: absolute; inset: 0; pointer-events: none; padding: max(18px, env(safe-area-inset-top)) 26px; display: flex; justify-content: space-between; align-items: flex-start; transition: opacity 0.3s; }
.hud.hidden { opacity: 0; }
.hud-left .brand { font-size: 12px; letter-spacing: 4px; opacity: 0.85; }
.hud-left .brand b { color: #ffb35c; }
.hud-left .brand span { margin-left: 6px; color: #8fd8ff; }
.dist-wrap { font-size: 52px; font-weight: 800; line-height: 1.05; text-shadow: 0 2px 18px rgba(0,0,0,0.6); font-variant-numeric: tabular-nums; }
.dist-wrap i { font-style: normal; font-size: 20px; opacity: 0.6; margin-left: 4px; }
.best { font-size: 13px; opacity: 0.75; letter-spacing: 1px; }
.best b { color: #ffd9a0; }

.hud-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.chip-row { display: flex; align-items: center; gap: 8px; font-size: 26px; font-weight: 700; text-shadow: 0 2px 12px rgba(0,0,0,0.6); }
.chip-ico { width: 16px; height: 16px; background: linear-gradient(135deg, #ffd9a0, #ff9a3c); border-radius: 3px; transform: rotate(45deg); box-shadow: 0 0 12px rgba(255, 170, 60, 0.9); }
.energy { width: 150px; height: 8px; border-radius: 6px; background: rgba(255,255,255,0.14); overflow: hidden; }
#energyFill { height: 100%; width: 0%; border-radius: 6px; background: linear-gradient(90deg, #ff9a3c, #ffd9a0); transition: width 0.2s; }
#energyFill.ready { animation: pulse 0.9s ease-in-out infinite; }
#energyFill.cooling { background: linear-gradient(90deg, #5a6472, #7d8794); animation: none; filter: grayscale(0.6); }
@keyframes pulse { 50% { filter: brightness(1.6); } }
#odHint { font-size: 11px; letter-spacing: 2px; opacity: 0.35; transition: opacity 0.2s; }
#odHint.ready { opacity: 1; color: #ffd9a0; text-shadow: 0 0 10px rgba(255, 190, 100, 0.8); }

/* ---- Toast ---- */
.toast { position: absolute; top: 22%; left: 50%; transform: translateX(-50%) translateY(-8px); background: rgba(20, 12, 8, 0.78); border: 1px solid rgba(255, 179, 92, 0.4); padding: 10px 22px; border-radius: 999px; font-size: 15px; letter-spacing: 2px; opacity: 0; transition: all 0.3s; pointer-events: none; backdrop-filter: blur(6px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- 全屏界面 ---- */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 6, 4, 0.45); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity 0.35s; }
.screen.visible { opacity: 1; pointer-events: auto; }
.panel { text-align: center; padding: 42px 56px; border-radius: 22px; background: rgba(18, 11, 8, 0.72); border: 1px solid rgba(255, 179, 92, 0.22); box-shadow: 0 30px 80px rgba(0,0,0,0.55); max-width: min(92vw, 560px); }

.kicker { font-size: 11px; letter-spacing: 6px; color: #8fd8ff; margin-bottom: 12px; }
h1 { font-size: 58px; font-weight: 900; letter-spacing: 10px; background: linear-gradient(180deg, #ffe3bd, #ff8f4a); -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: 0 10px 40px rgba(255, 130, 50, 0.35); }
.title-panel .sub { font-size: 14px; letter-spacing: 9px; color: #9aa7b8; margin: 6px 0 18px; }
.desc { font-size: 14.5px; line-height: 1.9; opacity: 0.82; margin-bottom: 24px; }

.btn { cursor: pointer; border: none; border-radius: 999px; font-size: 16px; font-weight: 700; letter-spacing: 3px; padding: 13px 40px; transition: transform 0.15s, box-shadow 0.2s; }
.btn.primary { background: linear-gradient(135deg, #ff9a3c, #ff6a2a); color: #fff7ee; box-shadow: 0 8px 30px rgba(255, 120, 40, 0.45); }
.btn.primary:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 12px 40px rgba(255, 130, 50, 0.6); }
.btn.ghost { background: rgba(255,255,255,0.08); color: #e8ddd0; border: 1px solid rgba(255,255,255,0.2); }
.btn.ghost:hover { background: rgba(255,255,255,0.15); }
#startBtn { font-size: 18px; padding: 15px 56px; margin-bottom: 26px; }

.keys { display: inline-flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.key-row { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; }
.key-row em { font-style: normal; opacity: 0.7; margin: 0 6px; }
.kbd { display: inline-block; min-width: 30px; padding: 3px 8px; border-radius: 6px; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.22); border-bottom-width: 2.5px; font-size: 11.5px; font-weight: 700; letter-spacing: 1px; }
.kbd.wide { padding: 3px 14px; }
.hint { font-size: 11.5px; opacity: 0.45; letter-spacing: 1px; }

/* 结算 */
.death-label { font-size: 14px; opacity: 0.65; letter-spacing: 2px; margin-bottom: 22px; }
.final-grid { display: flex; gap: 34px; justify-content: center; margin-bottom: 18px; }
.final-cell { display: flex; flex-direction: column; gap: 6px; }
.final-cell i { font-style: normal; font-size: 12px; letter-spacing: 3px; opacity: 0.55; }
.final-cell b { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; }
.final-cell b em { font-style: normal; font-size: 15px; opacity: 0.5; margin-left: 3px; }
.new-record { display: none; color: #ffd9a0; letter-spacing: 4px; font-size: 15px; text-shadow: 0 0 16px rgba(255, 190, 100, 0.9); margin-bottom: 18px; animation: pulse 1s ease-in-out infinite; }
.new-record.visible { display: block; }
.btn-row { display: flex; gap: 14px; justify-content: center; }
.pause-panel h2 { letter-spacing: 8px; margin-bottom: 24px; }

/* ---- 层级 ---- */
#hud { z-index: 10; pointer-events: none; }
#toast { z-index: 60; }
.screen { z-index: 20; }
#touchArea { z-index: 4; }
#touchUI { z-index: 30; }
#fsBtn { z-index: 55; }

/* ---- 触屏手势 ---- */
#touchArea { position: absolute; inset: 0; display: none; touch-action: none; }
#touchArea.on { display: block; }
#touchUI { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); display: none; flex-direction: column; align-items: flex-end; gap: 10px; }
#touchUI.on { display: flex; }

/* 冲刺按钮：玻璃质感方块，能量就绪时发光，冷却时变灰 */
.tdash {
  width: 76px; height: 76px; border-radius: 26px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: rgba(24, 16, 11, 0.34);
  border: 1px solid rgba(255, 190, 120, 0.32);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: rgba(255, 224, 190, 0.75);
  transition: transform 0.12s, box-shadow 0.25s, border-color 0.25s, color 0.25s, opacity 0.25s;
  padding-bottom: env(safe-area-inset-bottom);
}
.tdash-ico { font-size: 26px; line-height: 1; filter: grayscale(0.4); }
.tdash-lbl { font-size: 11px; letter-spacing: 2px; opacity: 0.7; }
.tdash:active { transform: scale(0.93); }
.tdash.ready { border-color: rgba(150, 215, 255, 0.85); color: #e2f4ff; box-shadow: 0 0 22px rgba(120, 195, 255, 0.45), inset 0 0 18px rgba(120, 195, 255, 0.14); }
.tdash.ready .tdash-ico { filter: none; }
.tdash.cool { opacity: 0.42; }

/* 首次上手的手势提示 */
.gesture-hint {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
  padding: 10px 14px; border-radius: 14px;
  background: rgba(20, 12, 8, 0.42); border: 1px solid rgba(255, 200, 140, 0.18);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 232, 205, 0.85); font-size: 12.5px; letter-spacing: 1px;
  opacity: 0; transform: translateY(6px); transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
}
.gesture-hint.show { opacity: 1; transform: translateY(0); }
.gesture-hint div { display: flex; align-items: center; gap: 8px; }
.gesture-hint b { font-size: 15px; color: #ffd9a0; width: 18px; text-align: center; }

/* 全屏按钮 */
.fs-btn {
  position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: 38px; height: 30px; border-radius: 10px;
  background: rgba(20, 12, 8, 0.34); border: 1px solid rgba(255, 200, 140, 0.22);
  color: rgba(255, 226, 196, 0.72); font-size: 15px; line-height: 1;
  cursor: pointer; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.2s, border-color 0.2s, color 0.2s;
  opacity: 0.55;
}
.fs-btn:hover { opacity: 1; border-color: rgba(255, 200, 140, 0.55); color: #ffe3bd; }
.fs-btn:active { transform: translateX(-50%) scale(0.94); }
.fs-btn.hide { opacity: 0; pointer-events: none; }

/* 竖屏提示 */
#rotateHint {
  position: absolute; inset: 0; z-index: 70; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 10px;
  background: rgba(10, 6, 4, 0.82); backdrop-filter: blur(6px);
  color: #ffd9a0; font-size: 15px; letter-spacing: 3px;
}
@media (pointer: coarse) and (orientation: portrait) {
  #rotateHint.show { display: flex; }
}
#rotateHint b { font-size: 34px; }

/* ---- 竞速模式：名次表 / 倒计时 / 受击红边 ---- */
.race-board {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%);
  z-index: 12; width: 196px; padding: 9px 11px 10px;
  border-radius: 12px; border: 1px solid rgba(255, 215, 170, 0.15);
  background: rgba(14, 9, 6, 0.42);
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.race-board.on { opacity: 1; }
.race-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; letter-spacing: 2px; opacity: 0.62;
  padding-bottom: 5px; margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  font-variant-numeric: tabular-nums;
}
.race-head b { font-size: 13px; color: #ffd9a0; letter-spacing: 0; }
.race-row {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; line-height: 1.9;
}
.race-row b { width: 11px; font-weight: 500; opacity: 0.5; font-variant-numeric: tabular-nums; }
.race-row i {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--c); box-shadow: 0 0 7px var(--c);
}
.race-row span { flex: 1; opacity: 0.9; }
.race-row em { font-style: normal; opacity: 0.55; font-variant-numeric: tabular-nums; }
.race-row.me b, .race-row.me span { opacity: 1; }
.race-row.me span { color: #9fe4ff; }

.countdown {
  position: absolute; inset: 0; z-index: 14; display: flex;
  align-items: center; justify-content: center;
  font-size: 118px; font-weight: 800; letter-spacing: 6px;
  color: #fff; text-shadow: 0 8px 44px rgba(0, 0, 0, 0.75), 0 0 60px rgba(255, 190, 120, 0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.14s;
}
.countdown.on { opacity: 0.96; }

.hit-flash {
  position: absolute; inset: 0; z-index: 9; pointer-events: none; opacity: 0;
  transition: opacity 0.08s;
  background: radial-gradient(ellipse at 50% 58%, rgba(255, 70, 40, 0) 38%, rgba(208, 40, 26, 0.72) 100%);
}

@media (max-width: 720px) {
  .race-board { width: 160px; padding: 7px 9px 8px; }
  .race-row { font-size: 11.5px; line-height: 1.75; }
  .countdown { font-size: 76px; }
}

/* ---- 技能系统：待释放槽 / buff 条 / 断电遮罩 ---- */
.skill-bar {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(8px);
  z-index: 13; opacity: 0; pointer-events: none; transition: opacity 0.22s, transform 0.22s;
}
.skill-bar.on { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; cursor: pointer; }
.skill-slot {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px 9px 14px; border-radius: 999px;
  background: rgba(16, 10, 8, 0.62); border: 1px solid rgba(255, 154, 92, 0.55);
  box-shadow: 0 0 26px rgba(255, 140, 70, 0.28), inset 0 0 18px rgba(255, 150, 80, 0.08);
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
}
.skill-slot b { font-size: 20px; line-height: 1; }
.skill-slot span { font-size: 15px; font-weight: 700; letter-spacing: 2px; color: #ffd9a0; }
.skill-slot em { font-style: normal; font-size: 11.5px; letter-spacing: 1px; opacity: 0.6; }

.buff-bar {
  position: absolute; left: 26px; bottom: 96px; z-index: 13;
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.buff {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 9px; border-radius: 999px;
  background: rgba(10, 14, 20, 0.55); border: 1px solid var(--c);
  font-size: 12px; letter-spacing: 1px; color: #eaf4ff;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.buff b { font-size: 14px; line-height: 1; }
.buff em { font-style: normal; font-variant-numeric: tabular-nums; opacity: 0.72; font-size: 11px; }

.blackout-mask {
  position: absolute; inset: 0; z-index: 8; pointer-events: none; opacity: 0;
  transition: opacity 0.35s;
  background: radial-gradient(circle at 50% 56%, rgba(4, 6, 12, 0.35) 0%, rgba(2, 3, 6, 0.95) 82%);
}
.blackout-mask::after {
  content: '断电干扰'; position: absolute; left: 50%; top: 18%; transform: translateX(-50%);
  font-size: 12px; letter-spacing: 5px; color: #c9a6ff; opacity: 0.85;
}

/* ---- 联机大厅 ---- */
.btn.wide { width: 100%; padding: 11px 30px; font-size: 14px; letter-spacing: 2px; }
.lobby-panel { width: min(94vw, 460px); }
.lobby-panel h2 { font-size: 30px; letter-spacing: 6px; margin-bottom: 20px; }
.lobby-setup { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.lobby-input {
  width: 100%; padding: 12px 16px; border-radius: 12px; font-size: 15px;
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f3e9dd; outline: none; text-align: center; letter-spacing: 2px;
  font-family: inherit;
}
.lobby-input:focus { border-color: rgba(143, 216, 255, 0.6); }
.lobby-input.code { letter-spacing: 6px; text-transform: uppercase; font-weight: 700; }
.lobby-join { display: flex; gap: 8px; align-items: stretch; }
.lobby-join .lobby-input { flex: 1; }
.lobby-join .btn { padding: 12px 22px; font-size: 14px; letter-spacing: 2px; }
.lobby-room { display: none; flex-direction: column; gap: 14px; }
.lobby-room.on { display: flex; }
.lobby-setup.off { display: none; }
.lobby-code { font-size: 13px; letter-spacing: 3px; opacity: 0.7; }
.lobby-code b {
  font-size: 26px; letter-spacing: 8px; color: #8fd8ff; margin-left: 8px;
  text-shadow: 0 0 20px rgba(120, 200, 255, 0.55); font-variant-numeric: tabular-nums;
}
.lobby-list { display: flex; flex-direction: column; gap: 7px; }
.lobby-player {
  display: flex; align-items: center; gap: 9px; padding: 9px 14px; border-radius: 11px;
  background: rgba(255, 255, 255, 0.055); border: 1px solid rgba(255, 255, 255, 0.1); font-size: 14px;
}
.lobby-player i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 9px var(--c); }
.lobby-player span { flex: 1; text-align: left; }
.lobby-player em { font-style: normal; font-size: 11px; opacity: 0.55; letter-spacing: 1px; }
.lobby-player.me { border-color: rgba(143, 216, 255, 0.45); }
.lobby-hint { font-size: 11.5px; opacity: 0.45; letter-spacing: 1px; }
.lobby-status { min-height: 18px; font-size: 12.5px; letter-spacing: 1px; color: #ffb98a; margin: 8px 0 12px; }

@media (max-width: 720px) {
  .skill-bar { bottom: 118px; }
  .skill-slot { padding: 7px 14px 7px 11px; }
  .skill-slot em { display: none; }
  .buff-bar { left: 14px; bottom: 118px; }
  .lobby-panel { padding: 28px 22px; }
  .lobby-panel h2 { font-size: 24px; }
}
