:root {
  --ink: #eaf6ff;
  --dim: rgba(234, 246, 255, 0.62);
  --glass: rgba(6, 22, 36, 0.46);
  --edge: rgba(160, 220, 255, 0.22);
  --accent: #39e1ff;
  --gold: #ffcf4a;
  --hot: #ff6a3d;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0a2236;
  font-family: "Rajdhani", "Noto Sans TC", system-ui, sans-serif; color: var(--ink);
  -webkit-user-select: none; user-select: none; touch-action: none;
}
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

.panel {
  background: var(--glass); border: 1px solid var(--edge); border-radius: 14px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

#race { position: fixed; top: 16px; left: 16px; padding: 12px 16px; min-width: 210px; }
#race .label { font-size: 12px; letter-spacing: 0.12em; color: var(--dim); }
#race .big { font-size: 38px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; margin-bottom: 6px; }
#race .row { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; color: var(--dim); }
#race .row b { color: var(--ink); font-variant-numeric: tabular-nums; }

#mapWrap { position: fixed; top: 16px; right: 16px; padding: 8px; text-align: center; }
#minimap { width: 180px; height: 180px; display: block; border-radius: 50%; }
#heading { font-size: 14px; letter-spacing: 0.1em; margin-top: 4px; color: var(--dim); font-variant-numeric: tabular-nums; }

#dash {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 18px; padding: 10px 22px;
  background: var(--glass); border: 1px solid var(--edge); border-radius: 18px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
#speed { display: flex; align-items: baseline; gap: 6px; min-width: 128px; justify-content: flex-end; }
#spd { font-size: 54px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
#speed small { font-size: 13px; color: var(--dim); letter-spacing: 0.1em; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.barrow { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); font-family: "Noto Sans TC", sans-serif; }
.bar { width: 150px; height: 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #62f0a8, #39e1ff); border-radius: 6px; transition: width 0.08s linear; }
.bar.nitro i { background: linear-gradient(90deg, #ff9b3d, #ff3dbb); }
.bar.nitro.full i { box-shadow: 0 0 12px #ff5ad1; }
.bar.reload i { background: linear-gradient(90deg, #ff5a3d, #ffcf4a); transition: none; }
.bar.reload.full i { box-shadow: 0 0 12px #ffcf4a; }
.side { display: flex; flex-direction: column; gap: 4px; }
#aimInfo { font-size: 12px; color: #ffb59f; font-family: "Noto Sans TC", sans-serif; text-align: center; }
#weatherLabel { font-size: 12px; color: var(--dim); font-family: "Noto Sans TC", sans-serif; min-width: 60px; text-align: center; }

#toolbar { position: fixed; bottom: 22px; right: 16px; display: flex; flex-direction: column; gap: 8px; }
#toolbar button, #tbtns button {
  font: 600 14px "Noto Sans TC", sans-serif; color: var(--ink); cursor: pointer;
  background: var(--glass); border: 1px solid var(--edge); border-radius: 10px; padding: 8px 14px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
#toolbar button:hover { border-color: var(--accent); }
#toolbar button.off { opacity: 0.5; }

#toast {
  position: fixed; top: 22%; left: 50%; transform: translate(-50%, -10px); opacity: 0;
  font-size: 40px; font-weight: 700; letter-spacing: 0.06em; text-align: center; pointer-events: none;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.5); transition: opacity 0.25s, transform 0.25s;
  font-family: "Rajdhani", "Noto Sans TC", sans-serif; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast small { display: block; font-size: 18px; color: var(--dim); font-weight: 600; }
#toast.gold { color: var(--gold); }
#toast.cyan { color: var(--accent); }
#toast.hot { color: var(--hot); }

#wrongWay { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); font: 600 14px "Noto Sans TC", sans-serif; color: var(--dim); padding: 6px 12px; border-radius: 10px; background: var(--glass); }
#wrongWay b { color: var(--accent); }

#menu {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: flex-start;
  padding: 0 7vw; background: linear-gradient(90deg, rgba(3, 14, 26, 0.78) 0%, rgba(3, 14, 26, 0.35) 55%, rgba(3, 14, 26, 0) 100%);
}
.menuCard { max-width: 520px; }
.kicker { letter-spacing: 0.35em; font-size: 13px; color: var(--accent); font-weight: 700; }
h1 { font-size: clamp(54px, 9vw, 104px); margin: 4px 0 6px; line-height: 0.95; letter-spacing: 0.02em; font-weight: 700; text-shadow: 0 6px 40px rgba(57, 225, 255, 0.35); }
h1 span { display: block; font-family: "Noto Sans TC", sans-serif; font-size: 0.36em; letter-spacing: 0.6em; color: var(--dim); margin-top: 6px; }
.sub { font-family: "Noto Sans TC", sans-serif; color: var(--dim); font-size: 16px; line-height: 1.7; margin: 14px 0 20px; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; font-family: "Noto Sans TC", sans-serif; font-size: 14px; color: var(--dim); margin-bottom: 26px; }
kbd { display: inline-block; min-width: 26px; padding: 2px 7px; margin-right: 4px; text-align: center; border-radius: 6px; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.08); color: var(--ink); font: 600 13px "Rajdhani", sans-serif; }
#startBtn {
  font: 700 22px "Rajdhani", "Noto Sans TC", sans-serif; letter-spacing: 0.12em; color: #022033; cursor: pointer;
  padding: 14px 36px; border: none; border-radius: 14px; background: linear-gradient(90deg, #62f0a8, #39e1ff);
  box-shadow: 0 10px 40px rgba(57, 225, 255, 0.45); transition: transform 0.15s;
}
#startBtn:hover { transform: translateY(-2px) scale(1.02); }
.hint { margin-top: 14px; font-family: "Noto Sans TC", sans-serif; font-size: 13px; color: var(--dim); }

#pause { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(3, 14, 26, 0.5); font-size: 48px; font-weight: 700; letter-spacing: 0.1em; text-align: center; }
#pause small { display: block; font-size: 16px; color: var(--dim); font-family: "Noto Sans TC", sans-serif; }
#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #0a2236; font: 600 20px "Noto Sans TC", sans-serif; color: var(--dim); transition: opacity 0.6s; }
#loading.done { opacity: 0; pointer-events: none; }

#touch { position: fixed; inset: 0; pointer-events: none; }
#stick { position: absolute; left: 28px; bottom: 110px; width: 130px; height: 130px; border-radius: 50%; border: 2px solid var(--edge); background: rgba(6, 22, 36, 0.3); pointer-events: auto; }
#knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(57, 225, 255, 0.45); border: 2px solid var(--accent); }
#tbtns { position: absolute; right: 90px; bottom: 120px; display: flex; gap: 12px; pointer-events: auto; }
#tbtns button { width: 72px; height: 72px; border-radius: 50%; padding: 0; font-size: 15px; }
#tbtns button.on { border-color: var(--hot); background: rgba(255, 106, 61, 0.35); }

#battle { position: fixed; top: 16px; left: 16px; padding: 12px 16px; min-width: 230px; }
#battle .label { font-size: 12px; letter-spacing: 0.12em; color: var(--dim); }
#battle .label b { color: var(--gold); font-size: 15px; }
#battle .big { font-size: 38px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; margin-bottom: 6px; color: var(--gold); }
#battle .row { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; color: var(--dim); }
#battle .row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.hull { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--dim); font-family: "Noto Sans TC", sans-serif; }
.hull .bar { flex: 1; width: auto; height: 10px; }
.hull b { color: var(--ink); min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.bar.hp i { background: linear-gradient(90deg, #62f0a8, #39e1ff); transition: width 0.2s; }

#hurt { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(255, 30, 0, 0) 45%, rgba(255, 30, 0, 0.55) 100%); z-index: 1; }
#warn {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); padding: 8px 16px; border-radius: 10px;
  font: 700 16px "Noto Sans TC", sans-serif; color: #fff; background: rgba(200, 30, 20, 0.7); border: 1px solid #ff8a6a;
  animation: blink 0.5s steps(2) infinite; white-space: nowrap;
}
@keyframes blink { 50% { opacity: 0.45; } }

#markers { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.mk { position: absolute; left: 0; top: 0; width: 0; height: 0; color: #ff6a55; font: 600 12px "Rajdhani", "Noto Sans TC", sans-serif; }
.mk .tag { position: absolute; left: 0; bottom: 6px; transform: translateX(-50%); white-space: nowrap; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8); }
.mk .hpb { position: absolute; left: -22px; bottom: 0; width: 44px; height: 4px; border-radius: 3px; background: rgba(0, 0, 0, 0.45); overflow: hidden; }
.mk .hpb i { display: block; height: 100%; background: #ff4a3d; }
.mk .arr { display: none; position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; }
.mk .arr::before { content: ""; position: absolute; left: 3px; top: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 14px solid currentColor; }
.mk.off .arr { display: block; }
.mk.off .hpb { display: none; }
.mk.off .tag { bottom: auto; top: 12px; }
.mk.off .nm { display: none; }
.mk.boss { color: #ff3df0; }
.mk.boss .hpb { width: 80px; left: -40px; height: 6px; }
.mk.boss .hpb i { background: #ff3df0; }
.mk.lock { color: var(--gold); }
.mk.lock .hpb i { background: var(--gold); }

#over { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(3, 14, 26, 0.6); padding: 16px; z-index: 5; }
.overCard { text-align: center; background: var(--glass); border: 1px solid var(--edge); border-radius: 18px; padding: 26px 30px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.overCard h2 { font: 700 44px "Noto Sans TC", sans-serif; margin: 6px 0 16px; color: var(--hot); letter-spacing: 0.1em; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 26px; margin-bottom: 22px; font-family: "Noto Sans TC", sans-serif; }
.stats div { display: flex; flex-direction: column; }
.stats span { font-size: 12px; color: var(--dim); }
.stats b { font: 700 30px "Rajdhani", sans-serif; color: var(--gold); }
.stats small { font-size: 12px; color: var(--dim); }
.btns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: inherit; }
.overCard .btns { justify-content: center; }
#retryBtn, #raceBtn, #menuBtn, #startBtn { font: 700 20px "Rajdhani", "Noto Sans TC", sans-serif; letter-spacing: 0.1em; cursor: pointer; padding: 13px 28px; border-radius: 14px; transition: transform 0.15s; }
#retryBtn { color: #022033; border: none; background: linear-gradient(90deg, #ffcf4a, #ff6a3d); box-shadow: 0 10px 40px rgba(255, 106, 61, 0.4); }
.ghost { color: var(--ink); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--edge); }
#retryBtn:hover, #raceBtn:hover, #menuBtn:hover { transform: translateY(-2px); }

#tour { position: fixed; top: 16px; left: 16px; padding: 12px 16px; min-width: 230px; max-width: 280px; }
#tour .label, #tour .tlab { font-size: 12px; letter-spacing: 0.12em; color: var(--dim); }
#tour .label b { color: #62f0a8; }
#tour .big { font: 700 28px "Noto Sans TC", sans-serif; line-height: 1.2; margin: 2px 0 6px; color: var(--gold); }
#tour .row { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; color: var(--dim); font-family: "Noto Sans TC", sans-serif; }
#tour .row b { color: var(--ink); }
#tourListBtn { margin-top: 10px; width: 100%; font: 600 14px "Noto Sans TC", sans-serif; color: var(--ink); cursor: pointer; background: rgba(255, 207, 74, 0.14); border: 1px solid rgba(255, 207, 74, 0.5); border-radius: 10px; padding: 8px; }
#tourListBtn:hover { background: rgba(255, 207, 74, 0.25); }

#spot { position: fixed; right: 96px; top: 50%; transform: translateY(-50%); width: min(340px, calc(100vw - 32px)); padding: 18px 20px; z-index: 3; font-family: "Noto Sans TC", sans-serif; border-color: rgba(255, 207, 74, 0.45); }
#spot .kicker { letter-spacing: 0.15em; font-size: 12px; }
#spot h3 { font-size: 28px; margin: 4px 0 8px; color: var(--gold); }
#spot p { margin: 0 0 14px; color: var(--ink); line-height: 1.65; font-size: 15px; }
#spot .links { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
#spot .links a { display: block; text-align: center; padding: 11px 12px; border-radius: 12px; font-weight: 700; text-decoration: none; font-size: 15px; }
#spotWeb { color: #022033; background: linear-gradient(90deg, #ffcf4a, #ff9b3d); }
#spotMap { color: #022033; background: linear-gradient(90deg, #62f0a8, #39e1ff); }
#spot .btns { gap: 8px; }
#spot .btns button { flex: 1; font: 600 14px "Noto Sans TC", sans-serif; padding: 9px 10px; border-radius: 10px; cursor: pointer; color: var(--ink); background: rgba(255, 255, 255, 0.08); border: 1px solid var(--edge); }
#spot .btns button:disabled { opacity: 0.6; cursor: default; }

#tourList { position: fixed; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(3, 14, 26, 0.55); }
.tlCard { width: min(820px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: rgba(6, 22, 36, 0.88); border: 1px solid var(--edge); border-radius: 18px; padding: 16px 18px; font-family: "Noto Sans TC", sans-serif; }
.tlHead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tlHead h3 { margin: 4px 0 10px; font-size: 22px; }
.tlHead button, .tlFoot button { font: 600 14px "Noto Sans TC", sans-serif; padding: 6px 12px; border-radius: 10px; cursor: pointer; }
.tlBody { display: flex; gap: 16px; min-height: 0; flex: 1; }
#tourMap { width: 300px; height: auto; aspect-ratio: 360 / 560; border-radius: 12px; cursor: pointer; flex: none; align-self: flex-start; }
#tourItems { flex: 1; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-content: start; }
.ti { display: flex; align-items: center; gap: 8px; text-align: left; padding: 7px 9px; border-radius: 10px; cursor: pointer; color: var(--ink); background: rgba(255, 255, 255, 0.05); border: 1px solid transparent; font-family: inherit; }
.ti:hover { border-color: var(--edge); }
.ti .st { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: rgba(255, 255, 255, 0.12); }
.ti.v .st { background: #62f0a8; color: #022033; }
.ti.t { border-color: var(--gold); background: rgba(255, 207, 74, 0.12); }
.ti .tn { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ti .tn b { font-size: 14px; }
.ti .tn small { font-size: 11px; color: var(--dim); }
.ti .td { font-size: 12px; color: var(--dim); white-space: nowrap; }
.tlFoot { margin-top: 12px; font-size: 12px; color: var(--dim); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ghost.small { font-size: 12px !important; padding: 5px 10px !important; }

.mk.tl { color: #bdeeff; }
.mk.tl .hpb { display: none; }
.mk.tl .tag { font-family: "Noto Sans TC", sans-serif; font-size: 13px; }
.mk.tl.v { color: #62f0a8; }
.mk.tl.lock { color: var(--gold); }
.mk.tl.lock .tag { font-size: 15px; font-weight: 700; }
#tourBtn { font: 700 20px "Rajdhani", "Noto Sans TC", sans-serif; letter-spacing: 0.06em; cursor: pointer; padding: 13px 22px; border-radius: 14px; transition: transform 0.15s; }
#tourBtn:hover { transform: translateY(-2px); }

@media (max-width: 760px) {
  #tour { top: 10px; left: 10px; padding: 8px 12px; min-width: 150px; max-width: 190px; }
  #tour .big { font-size: 20px; }
  #tour .row { font-size: 12px; }
  #spot { top: auto; bottom: 140px; transform: none; right: 16px; left: 16px; width: auto; padding: 14px 16px; }
  #spot h3 { font-size: 22px; }
  #spot p { font-size: 13px; margin-bottom: 10px; }
  #spot .links { flex-direction: row; }
  #spot .links a { flex: 1; padding: 9px 6px; font-size: 13px; }
  .tlBody { flex-direction: column; overflow-y: auto; }
  #tourMap { width: 100%; max-width: 260px; align-self: center; }
  #tourItems { grid-template-columns: 1fr; overflow: visible; }
  #tourBtn { font-size: 16px; padding: 11px 18px; }
  #race, #battle { top: 10px; left: 10px; padding: 8px 12px; min-width: 150px; }
  #battle .big { font-size: 26px; }
  #battle .row { font-size: 12px; }
  #warn { font-size: 13px; top: auto; bottom: 150px; }
  .overCard h2 { font-size: 32px; }
  #retryBtn, #raceBtn, #menuBtn, #startBtn { font-size: 16px; padding: 11px 18px; }
  #race .big { font-size: 26px; }
  #race .row { font-size: 12px; }
  #mapWrap { top: 10px; right: 10px; padding: 5px; }
  #minimap { width: 110px; height: 110px; }
  #dash { bottom: 10px; padding: 8px 14px; gap: 10px; }
  #spd { font-size: 36px; }
  #speed { min-width: 80px; }
  .bar { width: 80px; }
  #weatherLabel, #aimInfo { display: none; }
  #toolbar { flex-direction: row; bottom: auto; top: 140px; right: 10px; flex-wrap: wrap; justify-content: flex-end; max-width: 200px; }
  #toolbar button { padding: 6px 9px; font-size: 12px; }
  #toast { font-size: 28px; }
  #menu { padding: 0 16px; background: rgba(3, 14, 26, 0.65); }
  .controls { font-size: 12px; }
  #wrongWay { top: auto; bottom: 86px; }
}
