:root {
  --accent: #ffcf4d;
  --accent-2: #ff5b48;
  --ink: #f4f1e7;
  --panel: rgba(10, 12, 10, 0.72);
  --stroke: rgba(255, 255, 255, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #06070a; color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif; overflow: hidden; }
canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }
.hidden-hud #hud { opacity: 0; pointer-events: none; }

/* ---------- loading ---------- */
#loading {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 700px at 50% 0%, rgba(255,207,77,0.10), transparent 60%),
    linear-gradient(160deg, #0b0d10 0%, #14120c 45%, #05070a 100%);
  transition: opacity .7s ease;
}
#loading.gone { opacity: 0; pointer-events: none; }
.load-inner { width: min(640px, 88vw); text-align: center; padding: 30px 0; }
.load-kicker { letter-spacing: .32em; font-size: 12px; color: var(--accent); opacity: .85; }
.load-inner h1 { margin: 12px 0 6px; font-size: clamp(44px, 9vw, 96px); letter-spacing: .02em; line-height: .95;
  font-weight: 900; color: #f6f1e4; text-shadow: 0 6px 40px rgba(255,190,60,.22); }
.load-inner h1 span { color: var(--accent); }
.load-sub { color: #b9b4a6; letter-spacing: .12em; margin: 0 0 26px; font-size: 13px; }
.load-track { height: 6px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
#load-bar { height: 100%; width: 2%; background: linear-gradient(90deg, var(--accent), #ff8a3d); transition: width .3s ease; }
#load-text { margin-top: 10px; font-size: 13px; color: #cfc9b8; }
.load-stats { display: flex; justify-content: center; gap: 34px; margin: 26px 0 24px; }
.load-stats b { display: block; font-size: 26px; color: var(--accent); font-variant-numeric: tabular-nums; }
.load-stats i { font-style: normal; font-size: 11px; letter-spacing: .18em; color: #99937f; }
.load-actions button {
  border: 1px solid rgba(255,207,77,.6); background: linear-gradient(180deg, rgba(255,207,77,.18), rgba(255,207,77,.05));
  color: #ffe9a8; padding: 14px 46px; font-size: 16px; letter-spacing: .18em; border-radius: 999px;
  cursor: pointer; transition: .2s; font-weight: 700;
}
.load-actions button:disabled { opacity: .45; cursor: progress; }
.load-actions button:not(:disabled):hover { background: var(--accent); color: #1a1405; box-shadow: 0 10px 40px rgba(255,207,77,.35); }
.load-foot { margin-top: 22px; font-size: 11px; color: #6f6a5c; letter-spacing: .04em; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; transition: opacity .3s; }
#topbar { position: absolute; top: 18px; left: 22px; right: 22px; display: flex; justify-content: space-between; align-items: center; }
.brand { font-weight: 900; font-size: 22px; letter-spacing: .06em; text-shadow: 0 2px 14px rgba(0,0,0,.6); }
.brand span { color: var(--accent); }
.chips { display: flex; gap: 10px; }
.chip { background: var(--panel); border: 1px solid var(--stroke); padding: 7px 14px; border-radius: 999px;
  font-size: 12px; letter-spacing: .1em; backdrop-filter: blur(8px); color: #e9e4d4; }
.chip[data-mode="drive"] { border-color: rgba(255,91,72,.5); color: #ffb1a6; }
.chip[data-mode="walk"] { border-color: rgba(138,215,255,.5); color: #b7e7ff; }

#location-badge { position: absolute; left: 22px; bottom: 190px; background: var(--panel); border-left: 3px solid var(--accent);
  padding: 10px 16px; border-radius: 6px; backdrop-filter: blur(8px); }
.lb-kicker { font-size: 10px; letter-spacing: .22em; color: #9d9786; }
#location-name { font-size: 16px; font-weight: 700; margin-top: 3px; }

#compass-wrap { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); text-align: center; }
#compass-arrow { font-size: 30px; color: var(--accent); text-shadow: 0 0 18px rgba(255,207,77,.65); transition: transform .12s linear; }
.compass-meta { display: flex; gap: 10px; justify-content: center; font-size: 11px; color: #d8d2c0; letter-spacing: .06em; margin-top: -4px; }

#speedo { position: absolute; right: 22px; bottom: 96px; text-align: right; }
.speed-num b { font-size: 46px; font-weight: 900; color: #fff; font-variant-numeric: tabular-nums; line-height: 1;
  text-shadow: 0 4px 22px rgba(0,0,0,.55); }
.speed-num i { font-style: normal; font-size: 11px; letter-spacing: .18em; color: #a9a392; margin-left: 6px; }
.health { margin-top: 8px; width: 180px; margin-left: auto; }
.health span { font-size: 10px; letter-spacing: .16em; color: #9d9786; }
.health-track { height: 6px; background: rgba(255,255,255,.12); border-radius: 99px; margin-top: 4px; overflow: hidden; }
#health-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #8dff6a, #ffcf4d); transition: width .25s; }

#minimap-wrap { position: absolute; right: 22px; top: 74px; padding: 6px; background: var(--panel);
  border: 1px solid var(--stroke); border-radius: 10px; backdrop-filter: blur(8px); }
#minimap { display: block; width: 220px; height: 220px; border-radius: 6px; }
.mini-label { text-align: center; font-size: 10px; letter-spacing: .2em; color: #8f8a7b; padding-top: 4px; }

#controls { position: absolute; left: 22px; bottom: 22px; display: grid; gap: 5px; font-size: 12px; color: #c7c2b1;
  background: var(--panel); border: 1px solid var(--stroke); padding: 12px 16px; border-radius: 10px; backdrop-filter: blur(8px); }
kbd { display: inline-block; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  border-radius: 4px; padding: 1px 6px; font-size: 11px; font-family: inherit; color: #fff; margin-right: 4px; }

#target-panel { position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--panel);
  border: 1px solid rgba(255,207,77,.4); border-radius: 999px; padding: 8px 18px; font-size: 12px; color: #e9e2cd; }
#target-panel span { color: var(--accent); margin-right: 8px; letter-spacing: .1em; }

/* ---------- search ---------- */
#search-panel { position: fixed; inset: 0; z-index: 30; background: rgba(4,6,8,.55); backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; }
.search-box { width: min(660px, 90vw); background: rgba(14,16,15,.94); border: 1px solid var(--stroke); border-radius: 16px;
  padding: 18px 20px; box-shadow: 0 30px 90px rgba(0,0,0,.6); }
.search-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.search-title { font-size: 20px; font-weight: 800; }
.search-title small { display: block; font-weight: 400; font-size: 12px; color: #8f8a7b; margin-top: 4px; letter-spacing: .06em; }
#close-search { background: none; border: none; color: #8f8a7b; font-size: 18px; cursor: pointer; }
#search-input { width: 100%; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.15); color: #fff;
  border-radius: 10px; padding: 13px 16px; font-size: 15px; outline: none; }
#search-input:focus { border-color: rgba(255,207,77,.6); }
#search-results { margin-top: 10px; max-height: 46vh; overflow: auto; }
.result { display: flex; justify-content: space-between; gap: 12px; padding: 11px 12px; border-radius: 8px; cursor: pointer; }
.result:hover { background: rgba(255,207,77,.14); }
.result.hero .rn { color: var(--accent); }
.rn { font-size: 14px; }
.rt { font-size: 11px; color: #8f8a7b; letter-spacing: .06em; white-space: nowrap; }
.empty { color: #8f8a7b; padding: 18px 6px; font-size: 13px; }
.search-hint { margin-top: 10px; font-size: 11px; color: #6f6a5c; letter-spacing: .06em; }

/* ---------- big map ---------- */
#bigmap { position: fixed; inset: 0; z-index: 30; background: rgba(4,6,8,.9); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
#bigmap-canvas { width: min(78vh, 78vw); height: min(78vh, 78vw); border: 1px solid var(--stroke); border-radius: 12px; }
.bigmap-label { position: absolute; bottom: 26px; font-size: 12px; letter-spacing: .2em; color: #8f8a7b; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; top: 120px; transform: translateX(-50%); z-index: 25; background: rgba(10,12,10,.9);
  border: 1px solid rgba(255,207,77,.35); color: #f3ecd8; padding: 10px 20px; border-radius: 999px; font-size: 13px;
  letter-spacing: .04em; opacity: 0; transition: opacity .25s, top .25s; pointer-events: none; }
#toast.show { opacity: 1; top: 130px; }

@media (max-width: 820px) {
  #minimap-wrap { top: auto; bottom: 150px; right: 14px; }
  #minimap { width: 140px; height: 140px; }
  #controls { display: none; }
  #speedo { bottom: 26px; right: 14px; }
}

/* ---- mobile controls ---- */
#mobile-ui { display: none; }
@media (hover: none) and (pointer: coarse) {
  #mobile-ui { display: block; }
  #controls { display: none; }
  #joy {
    position: fixed; left: 26px; bottom: 30px; width: 132px; height: 132px;
    border-radius: 50%; background: rgba(12,16,22,0.42);
    border: 1px solid rgba(120,220,255,0.35); touch-action: none; z-index: 30;
    backdrop-filter: blur(6px);
  }
  #joy-knob {
    position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px;
    border-radius: 50%; background: radial-gradient(circle at 40% 35%, rgba(120,220,255,0.9), rgba(30,120,190,0.75));
    box-shadow: 0 0 18px rgba(80,200,255,0.5);
  }
  #mobile-actions {
    position: fixed; right: 20px; bottom: 34px; display: flex; flex-direction: column; gap: 10px; z-index: 30;
  }
  #mobile-actions button {
    width: 78px; height: 52px; border-radius: 14px; font-size: 15px; font-weight: 600;
    color: #d9f4ff; background: rgba(12,16,22,0.55); border: 1px solid rgba(120,220,255,0.35);
    backdrop-filter: blur(6px);
  }
  #mobile-actions button:active { background: rgba(80,200,255,0.28); }
  #minimap-wrap { top: 92px !important; right: 12px !important; bottom: auto !important; transform: scale(0.62); transform-origin: top right; }
  #speedo { left: 50% !important; right: auto !important; bottom: 108px !important; transform: translateX(-50%) scale(0.86); }
  #location-badge { bottom: 180px !important; }
}
