/* URDrone — UI / HUD styles */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0b1220; --panel: #131c2e; --panel2: #1a2540;
  --ink: #e8eef8; --dim: #8fa0b8; --acc: #4ab8f6; --acc2: #ffd23e;
  --good: #2ee66b; --bad: #f2597a;
  --hud-bg: rgba(10, 16, 28, .55);
  font-size: 16px;
}
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
[hidden] { display: none !important; }
body {
  /* the gradient lives here so the (transparent) canvas can draw the menu drone over it */
  background: radial-gradient(120% 100% at 50% 0%, #16233d 0%, var(--bg) 70%);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------------- screens & panels ---------------- */
.screen {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto;
  background: transparent;              /* menu backdrop renders on the canvas below */
  touch-action: pan-y;
}
.screen.modal-like {
  background: rgba(5, 9, 17, .72); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.screen[hidden] { display: none; }
.menu-inner { max-width: 860px; margin: 0 auto; padding: 24px 18px 40px; }
.brand h1 { font-size: 2.6rem; letter-spacing: 1px; }
.brand h1 span { color: var(--acc); }
.brand .tagline { color: var(--dim); margin: 2px 0 18px; }
section { margin-bottom: 20px; }
section h2 { font-size: 1rem; color: var(--dim); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 10px; }
section h2 i {
  font-style: normal; display: inline-block; width: 22px; height: 22px; line-height: 22px;
  text-align: center; background: var(--acc); color: #05121f; border-radius: 50%; margin-right: 8px; font-weight: 700;
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.card {
  background: rgba(19, 28, 46, .42); backdrop-filter: blur(4px);
  border: 2px solid rgba(255, 255, 255, .12); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; transition: border .15s, transform .1s, background .15s;
}
.card:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, .3); }
.card.on { border-color: var(--acc); background: rgba(74, 184, 246, .14); }
.card h3 { font-size: 1.05rem; }
.card .tag { color: var(--acc2); font-size: .75rem; text-transform: uppercase; letter-spacing: 1px; }
.card p { color: var(--dim); font-size: .82rem; margin-top: 6px; line-height: 1.35; }
.card .spec { display: flex; gap: 10px; margin-top: 8px; font-size: .72rem; color: var(--ink); }
.card .spec b { color: var(--acc); }

.seg {
  display: inline-flex; background: rgba(19, 28, 46, .42); backdrop-filter: blur(4px);
  border: 2px solid rgba(255, 255, 255, .12); border-radius: 10px; padding: 4px; gap: 4px; flex-wrap: wrap;
}
.seg button {
  border: 0; background: transparent; color: var(--dim); font: inherit; cursor: pointer;
  padding: 8px 16px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.seg button small { font-size: .65rem; opacity: .75; }
.seg button.on { background: var(--acc); color: #05121f; font-weight: 700; }
.seg.tabs { margin-bottom: 12px; }

.btn {
  border: 2px solid var(--acc); border-radius: 10px; background: rgba(74, 184, 246, .16);
  backdrop-filter: blur(4px); color: var(--ink);
  font: inherit; font-weight: 700; padding: 12px 18px; cursor: pointer; margin: 4px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: rgba(74, 184, 246, .28); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: rgba(19, 28, 46, .42); border-color: rgba(255, 255, 255, .14); color: var(--ink); font-weight: 500; }
.btn.ghost:hover { border-color: var(--acc); background: rgba(74, 184, 246, .12); }
.menu-foot { margin-top: 6px; display: flex; flex-wrap: wrap; }
.gp-status { color: var(--dim); font-size: .78rem; margin-top: 10px; }
.gp-status.ok { color: var(--good); }
.credit { color: #4a5a72; font-size: .72rem; margin-top: 14px; }

/* ================= game-style main menu ================= */
.menu-inner { position: relative; min-height: 100%; }
.view { position: relative; z-index: 1; animation: viewIn .28s ease; }
.view[hidden] { display: none !important; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } }

/* the wireframe drone backdrop is drawn on the WebGL canvas — see main.js */
@media (prefers-reduced-motion: reduce) { .view, .brand-prop { animation: none; } }

/* --- home hero --- */
.hero { max-width: 440px; margin-top: 6px; }
.qs {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
  border: 2px solid var(--acc); border-radius: 16px; padding: 15px 20px; color: var(--ink);
  background: rgba(74, 184, 246, .15); backdrop-filter: blur(5px);
  box-shadow: 0 10px 30px rgba(74,184,246,.18); transition: transform .1s, box-shadow .2s, background .2s;
}
.qs:hover { transform: translateY(-2px); background: rgba(74,184,246,.26); box-shadow: 0 16px 38px rgba(74,184,246,.28); }
.qs:active { transform: scale(.98); }
.qs-play {
  flex: 0 0 46px; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.4rem; background: rgba(74,184,246,.18); color: var(--acc);
  border: 2px solid rgba(74,184,246,.45);
}
.qs-body { display: flex; flex-direction: column; line-height: 1.1; }
.qs-body b { font-size: 1.4rem; letter-spacing: 1px; }
.qs-body small { font-size: .8rem; font-weight: 600; color: var(--dim); margin-top: 3px; }

.menu-list { display: flex; flex-direction: column; gap: 8px; max-width: 440px; margin-top: 14px; }
.mbtn {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
  border: 2px solid rgba(255,255,255,.12); border-radius: 14px; padding: 12px 16px;
  font: inherit; color: var(--ink); background: rgba(19, 28, 46, .42); backdrop-filter: blur(4px);
  transition: border-color .15s, background .15s, transform .1s;
}
.mbtn:hover { border-color: var(--acc); background: rgba(74,184,246,.12); transform: translateX(3px); }
.mbtn:active { transform: scale(.99); }
.mbtn .mi { flex: 0 0 30px; width: 30px; text-align: center; font-size: 1.3rem; }
.mbtn .ml { flex: 1; display: flex; flex-direction: column; line-height: 1.15; }
.mbtn .ml b { font-size: 1rem; }
.mbtn .ml em { font-style: normal; color: var(--dim); font-size: .76rem; margin-top: 2px; }
.mbtn .ma { color: var(--dim); font-size: 1.3rem; }

/* --- sub-panels (hangar / challenge / settings) --- */
.view-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.view-title { font-size: 1.5rem; letter-spacing: 0; text-transform: none; color: var(--ink); }
.btn-back {
  border: 2px solid rgba(255,255,255,.16); background: rgba(19, 28, 46, .42); backdrop-filter: blur(4px);
  color: var(--ink); font: inherit; font-weight: 700; border-radius: 10px; padding: 8px 14px; cursor: pointer;
}
.btn-back:hover { border-color: var(--acc); background: rgba(74,184,246,.12); }
.btn-fly {
  display: block; width: 100%; max-width: 440px; margin: 22px 0 6px; cursor: pointer;
  border: 2px solid var(--good); border-radius: 14px; padding: 16px; font: inherit; font-weight: 800;
  font-size: 1.2rem; letter-spacing: 2px; color: var(--good);
  background: rgba(46, 230, 107, .13); backdrop-filter: blur(5px);
  box-shadow: 0 10px 26px rgba(46,230,107,.16); transition: transform .1s, background .2s;
}
.btn-fly:hover { background: rgba(46, 230, 107, .24); }
.btn-fly.race {
  border-color: var(--acc2); color: var(--acc2);
  background: rgba(255, 210, 62, .13); box-shadow: 0 10px 26px rgba(255,210,62,.16);
}
.btn-fly.race:hover { background: rgba(255, 210, 62, .24); }
.btn-fly:active { transform: scale(.98); }
.loadout {
  background: none; border: 0; color: var(--dim); font: inherit; font-size: .85rem;
  cursor: pointer; padding: 6px 0; text-align: left; margin-top: 4px;
}
.loadout b { color: var(--acc); }
.loadout:hover { color: var(--ink); }

/* --- brand logo: the same 3-blade prop as the cursor & favicon, larger --- */
.brand-row { display: flex; align-items: center; gap: 14px; }
.brand-prop {
  width: clamp(44px, 9vw, 62px); height: auto; flex: none;
  animation: propSpin 4s linear infinite;               /* matches the idle cursor turn rate */
  filter: drop-shadow(0 0 10px rgba(74, 184, 246, .3));
}
.brand-prop .bp-blades { fill: rgba(74, 184, 246, .28); stroke: #8ad3ff; stroke-width: 3.4; stroke-linejoin: round; }
.brand-prop .bp-hub { fill: #08111d; stroke: #8ad3ff; stroke-width: 3.4; }
.brand-prop .bp-dot { fill: #fff; }
@keyframes propSpin { to { transform: rotate(360deg); } }

/* rotating 3-blade prop cursor — main.js swaps --pc / --pcf frame by frame.
   `body.prop-cursor *` (0,1,1) outranks the .btn/.card `cursor:pointer` rules (0,1,0),
   so the prop replaces the hand cursor over buttons too; --pcf spins at 2× and is
   scoped to clickables (0,2,1), which in turn outranks the plain rule. */
body.prop-cursor, body.prop-cursor * { cursor: var(--pc, auto); }
body.prop-cursor :is(button, a, .card),
body.prop-cursor :is(button, a, .card) * { cursor: var(--pcf, pointer); }
body.prop-cursor input { cursor: text; }

.panel {
  background: var(--panel); border-radius: 16px; padding: 22px; text-align: center;
  width: min(92vw, 380px); box-shadow: 0 18px 60px rgba(0, 0, 0, .5);
  display: flex; flex-direction: column; gap: 6px; max-height: 90vh; overflow-y: auto;
}
.panel.wide { width: min(94vw, 620px); text-align: left; }
.panel h2 { margin-bottom: 8px; }
.panel .row { display: flex; justify-content: center; }
.panel .close { align-self: center; margin-top: 10px; }

/* ---------------- finish modal ---------------- */
.fin-stats { display: flex; justify-content: center; gap: 22px; margin: 10px 0; }
.fin-stats label { display: block; color: var(--dim); font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; }
.fin-stats span { font-size: 1.5rem; font-weight: 700; color: var(--acc2); }
.fin-name { display: flex; gap: 6px; justify-content: center; }
.fin-name input {
  flex: 1; min-width: 0; border: 1px solid #2a3a5a; border-radius: 10px; padding: 10px 12px;
  background: var(--bg); color: var(--ink); font: inherit;
}
.fin-saved { color: var(--good); font-weight: 700; padding: 6px; }

/* ---------------- leaderboard ---------------- */
.lb-list { min-height: 200px; }
.lb-list table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.lb-list th { color: var(--dim); text-transform: uppercase; font-size: .68rem; letter-spacing: 1px; text-align: left; padding: 6px 8px; }
.lb-list td { padding: 7px 8px; border-top: 1px solid #223252; }
.lb-list tr.me td { color: var(--acc2); font-weight: 700; }
.lb-list .rank { color: var(--acc); font-weight: 700; width: 34px; }
.lb-empty { color: var(--dim); text-align: center; padding: 40px 0; }

/* ---------------- help ---------------- */
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.help-grid h3 { color: var(--acc); font-size: .9rem; margin-bottom: 4px; }
.help-grid p { color: var(--dim); font-size: .84rem; line-height: 1.5; }

/* ---------------- changelog ---------------- */
.log-list { max-height: 55vh; overflow-y: auto; font-size: .85rem; }
.log-row { display: flex; gap: 12px; padding: 8px 2px; border-top: 1px solid #223252; line-height: 1.45; }
.log-row:first-child { border-top: 0; }
.log-v { color: var(--acc); font-weight: 700; min-width: 54px; }
.log-row span:last-child { color: var(--dim); }

/* ---------------- gamepad modal ---------------- */
.gp-live { color: var(--dim); font-size: .82rem; background: var(--bg); border-radius: 8px; padding: 10px; font-family: ui-monospace, monospace; }
.gp-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.gp-rows label { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.gp-rows input[type=range] { width: 45%; }
.gp-rows input[type=checkbox] { width: 20px; height: 20px; }

/* ---------------- HUD ---------------- */
/* HUD sits above the touch layer (z 20); it's click-through except the battery */
#hud { position: fixed; inset: 0; z-index: 25; pointer-events: none; font-variant-numeric: tabular-nums; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex;
  justify-content: space-between; align-items: flex-start; padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.hud-box { background: var(--hud-bg); border-radius: 10px; padding: 8px 12px; backdrop-filter: blur(3px); }
.hud-batt {
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .9rem;
  pointer-events: auto; cursor: pointer; min-width: 150px; min-height: 34px;
}
.batt-v { color: var(--dim); font-weight: 600; font-size: .78rem; }
.batt-v.batt-v-low { color: var(--bad); animation: blink 1s infinite; }
.batt-fill.batt-swap { background: var(--acc); animation: none; }
.batt-change { display: none; color: var(--bad); font-weight: 800; letter-spacing: 2px; animation: blink .35s infinite; white-space: nowrap; }
.hud-left { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.hud-dmg { display: flex; align-items: center; gap: 8px; padding: 6px 12px; }
.hud-dmg label { color: var(--dim); font-size: .6rem; letter-spacing: 1px; font-weight: 700; }
.dmg-shell { flex: 1; height: 10px; border: 2px solid var(--ink); border-radius: 4px; overflow: hidden; min-width: 90px; }
.dmg-fill { height: 100%; width: 100%; background: var(--good); transition: width .2s, background .3s; }
.dmg-fill.dmg-mid { background: #f6a94a; }
.dmg-fill.dmg-low { background: var(--bad); }
.hud-dmg.dmg-alert { animation: blink .4s infinite; }
.hud-batt.batt-empty .batt-shell, .hud-batt.batt-empty #battPct { animation: blink .35s infinite; }
.hud-batt.show-change .batt-shell, .hud-batt.show-change #battPct, .hud-batt.show-change .batt-v { display: none; }
.hud-batt.show-change .batt-change { display: inline; }
.batt-shell { width: 64px; height: 14px; border: 2px solid var(--ink); border-radius: 4px; overflow: hidden; }
.batt-fill { height: 100%; background: var(--good); width: 100%; transition: width .3s; }
.batt-fill.batt-mid { background: var(--acc2); }
.batt-fill.batt-low { background: var(--bad); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .35; } }

.hud-center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.hud-mode { background: var(--hud-bg); border-radius: 8px; padding: 3px 12px; font-size: .78rem; letter-spacing: 2px; color: var(--acc); font-weight: 700; }
.hud-arm { background: var(--hud-bg); border-radius: 8px; padding: 2px 10px; font-size: .68rem; letter-spacing: 2px; color: var(--dim); }
.hud-arm.armed { color: var(--good); }
.hud-arm.crash { color: var(--bad); font-weight: 700; animation: blink .6s infinite; }
.hud-timer { font-size: 1.7rem; font-weight: 800; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.hud-timer.returning { color: var(--acc2); }
.hud-lap { font-size: .8rem; font-weight: 700; color: var(--acc2); letter-spacing: 1px; }
.hud-msg {
  margin-top: 4px; font-size: 1rem; font-weight: 700; color: #fff; opacity: 0;
  transition: opacity .25s; text-shadow: 0 2px 8px rgba(0,0,0,.7); max-width: 60vw;
}
.hud-msg.show { opacity: 1; }
.hud-msg.good { color: var(--good); }
.hud-msg.bad { color: var(--bad); }

.hud-stats div { display: flex; align-items: baseline; gap: 6px; font-size: .82rem; }
.hud-stats label { color: var(--dim); font-size: .62rem; width: 28px; letter-spacing: 1px; }
.hud-stats span { font-weight: 700; min-width: 40px; text-align: right; }
.hud-stats em { font-style: normal; color: var(--dim); font-size: .62rem; }

.hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex;
  justify-content: space-between; align-items: flex-end; padding: 10px 14px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.stick-box {
  width: 88px; height: 88px; background: var(--hud-bg); border-radius: 12px; position: relative;
  backdrop-filter: blur(3px);
}
.stick-box label {
  position: absolute; bottom: -16px; left: 0; right: 0; text-align: center;
  font-size: .58rem; color: var(--dim); letter-spacing: 1px;
}
.stick-cross { position: absolute; inset: 8px; opacity: .35; }
.stick-cross::before, .stick-cross::after { content: ''; position: absolute; background: var(--ink); }
.stick-cross::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.stick-cross::after { top: 50%; left: 0; right: 0; height: 1px; }
.stick-dot {
  position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px;
  background: var(--acc); border-radius: 50%; box-shadow: 0 0 8px var(--acc);
}
.hud-stats .tele-row { margin-top: 2px; font-size: .72rem; }
.tele-row { display: flex; gap: 8px; align-items: baseline; }
.tele-row label { color: var(--dim); font-size: .6rem; width: 34px; letter-spacing: 1px; }
.tele-row span { min-width: 44px; text-align: right; font-weight: 600; }
.tele-row em { font-style: normal; color: var(--dim); font-size: .6rem; }
.src-lbl { margin-left: 10px; color: var(--acc) !important; font-weight: 700; }

/* ---------------- touch layer ---------------- */
#touchLayer { position: fixed; inset: 0; z-index: 20; pointer-events: none; display: none; }
#touchLayer.touch-on { display: block; pointer-events: auto; }
.vstick {
  position: absolute; bottom: calc(30px + env(safe-area-inset-bottom)); width: 130px; height: 130px;
  border: 2px solid rgba(255,255,255,.25); border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.vstick-left { left: 26px; }
.vstick-right { right: 26px; }
.vstick-knob {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px;
  border-radius: 50%; background: rgba(74,184,246,.5); border: 2px solid var(--acc);
}
.touch-btns {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 10px; pointer-events: auto;
}
body.touch-mode #hud .stick-box { display: none; }   /* virtual sticks replace HUD reticles */
.tbtn {
  border: 2px solid rgba(255,255,255,.32); background: var(--hud-bg); color: var(--ink);
  font: inherit; font-size: .72rem; font-weight: 700; border-radius: 10px; padding: 10px 14px;
}
.tbtn:active { background: var(--acc); color: #05121f; }

#speechBubble {
  position: fixed; display: none; z-index: 26; pointer-events: none;
  transform: translate(-50%, -130%);
  background: #fff; color: #d92b2b; font-weight: 900; font-size: 1.15rem;
  letter-spacing: 1px; padding: 8px 14px; border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  animation: oww-pop .18s ease-out;
}
#speechBubble::after {
  content: ''; position: absolute; left: 50%; bottom: -9px; margin-left: -7px;
  border: 7px solid transparent; border-top-color: #fff; border-bottom: 0;
}
@keyframes oww-pop { from { transform: translate(-50%, -130%) scale(.4); } }

#toast {
  position: fixed; top: 14%; left: 50%; transform: translateX(-50%);
  background: var(--panel2); color: var(--ink); border-radius: 12px; padding: 10px 18px;
  font-size: .9rem; z-index: 60; opacity: 0; pointer-events: none; transition: opacity .3s;
  box-shadow: 0 8px 30px rgba(0,0,0,.4); max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; }

/* (the wireframe drone re-centres and fades itself on narrow screens — main.js) */
@media (max-width: 760px) {
  .hero, .menu-list, .btn-fly { max-width: 100%; }
}

@media (max-width: 640px) {
  :root { font-size: 14.5px; }
  .brand h1 { font-size: 2rem; }
  .hud-stats .tele-row { display: none; }     /* keep phone HUD minimal */
  .stick-box { width: 64px; height: 64px; }
}
