/* STAR LEAGUE — neon on deep space. Signature element: the fuel crystal bar that
   physically cracks and dims as it empties. */
:root {
  --ink: #04060f;
  --cyan: #6ee7ff;
  --crystal: #78ffdc;
  --amber: #ffd75e;
  --red: #ff5e5e;
  --panel: rgba(8, 14, 30, 0.92);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
html, body { height: 100%; overflow: hidden; background: var(--ink); font-family: 'Courier New', monospace; color: #cfe8ff; touch-action: none; -ms-touch-action: none; overscroll-behavior: none; }
canvas#game { position: fixed; inset: 0; touch-action: none; -ms-touch-action: none; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Title ---------- */
#title {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 0;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(20,40,80,0.6), transparent 60%),
    radial-gradient(ellipse at 30% 70%, rgba(10,20,60,0.4), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(40,20,60,0.3), transparent 55%),
    linear-gradient(180deg, #020810, #06101e 40%, #0a1428);
  z-index: 30; padding: 20px; overflow-y: auto;
}
.titleHero { flex-shrink: 0; margin-bottom: 4px; }
.titleLogo {
  width: min(720px, 92vw); height: auto; display: block;
  filter: drop-shadow(0 4px 30px rgba(180,150,60,0.3)) drop-shadow(0 0 60px rgba(60,100,200,0.2));
  max-height: 40vh;
  object-fit: contain;
}
.titleTag {
  color: #8a9fc0; letter-spacing: 0.32em; font-size: 11px; text-align: center;
  margin-bottom: 20px; text-transform: uppercase;
}
.titleForm {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: rgba(6,14,30,0.7); border: 1px solid rgba(180,150,60,0.15);
  padding: 24px 28px; border-radius: 8px; width: min(340px, 90vw);
  backdrop-filter: blur(8px);
}
#title input {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(180,150,60,0.3);
  color: #e0dcc8; padding: 12px 16px; font-size: 15px; width: 100%;
  font-family: inherit; letter-spacing: 0.08em; border-radius: 4px;
  transition: border-color 0.2s;
}
#title input:focus { outline: none; border-color: #c4a84a; box-shadow: 0 0 12px rgba(180,150,60,0.3); }
#title input::placeholder { color: #5a6880; }
.titleRow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; width: 100%; }
.btn {
  background: transparent; border: 1px solid var(--cyan); color: var(--cyan);
  padding: 12px 22px; font-size: 14px; letter-spacing: 0.14em;
  text-shadow: 0 0 8px rgba(110, 231, 255, 0.6); border-radius: 4px;
  transition: all 0.2s;
}
.btn:hover, .btn:focus-visible { background: rgba(110, 231, 255, 0.12); outline: none; }
.btn.gold {
  border-color: #c4a84a; color: #e8d48a;
  text-shadow: 0 0 10px rgba(200,170,60,0.5);
  background: linear-gradient(180deg, rgba(200,170,60,0.08), rgba(180,140,40,0.03));
  flex: 1;
}
.btn.gold:hover { background: linear-gradient(180deg, rgba(200,170,60,0.2), rgba(180,140,40,0.08)); }
.btn.ghost { border-color: #2a3a52; color: #6a7e98; text-shadow: none; font-size: 12px; padding: 8px 14px; }
.btn.ghost:hover { border-color: #4a5a72; color: #9ab0c8; }
#authMsg { color: #e8755e; font-size: 12px; min-height: 16px; text-align: center; }
#loadMsg { color: #6a7e98; font-size: 11px; min-height: 14px; }
.titleFooter { color: #2a3a52; font-size: 9px; letter-spacing: 0.2em; margin-top: 16px; }
#splashGate { text-align: center; }
#splashGate .titleLogo { transition: transform 0.3s, filter 0.3s; }
#splashGate:hover .titleLogo { transform: scale(1.02); filter: drop-shadow(0 4px 40px rgba(200,170,60,0.5)) drop-shadow(0 0 80px rgba(60,100,200,0.3)); }
.splashText {
  color: #c4a84a; font-size: 16px; letter-spacing: 0.35em; margin-top: 16px;
  animation: splashPulse 2s ease-in-out infinite;
  text-shadow: 0 0 20px rgba(200,170,60,0.4);
}
@keyframes splashPulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }
#loginPanel { display: flex; flex-direction: column; align-items: center; gap: 0; animation: fadeIn 0.5s ease; }
.titleLogoSmall {
  width: min(280px, 70vw); height: auto; display: block; margin-bottom: 12px;
  filter: drop-shadow(0 2px 16px rgba(180,150,60,0.25));
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (min-width: 1200px) {
  .titleLogo { width: min(800px, 60vw); max-height: 45vh; }
  .titleForm { width: 380px; padding: 28px 32px; }
}
@media (max-width: 480px) {
  .titleLogo { max-height: 30vh; }
  .titleForm { padding: 18px 16px; }
  .titleTag { font-size: 9px; letter-spacing: 0.2em; }
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }

/* Arc HUD — bottom center semicircle */
.hudArc {
  position: fixed; top: max(36px, calc(env(safe-area-inset-top) + 32px)); right: 10px;
  pointer-events: auto; z-index: 12;
}
.hudGold { color: #e8d48a; text-shadow: 0 0 8px rgba(200,170,60,0.4); }
.hudBlue { color: #8ab8e0; }
.hudDot { color: #2a3a52; margin: 0 4px; }
.hudArcBody {
  display: flex; align-items: flex-end; justify-content: center;
  position: relative;
}
.hudArcCenter { flex-shrink: 0; }
#hudStatusLine {
  max-width: 440px; margin: 2px auto 0; text-align: center;
  font: 12px monospace; color: rgba(217,140,255,0.9);
  line-height: 1.35; white-space: normal; word-break: normal;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8); pointer-events: none;
}
@media (max-width: 700px) { #hudStatusLine { max-width: 260px; font-size: 10px; } }
#minimap {
  display: block; width: 440px; height: 360px;
}
.hudCargoCorner {
  position: absolute; bottom: 8px; right: 6px; text-align: right;
}
.hudCargoCorner .hudStatLabel { font-size: 7px; letter-spacing: 0.12em; color: #4a6080; display: block; }
.hudCargoCorner .hudStatVal { font-size: 14px; font-weight: bold; font-family: 'Courier New', monospace; color: var(--cyan); text-shadow: 0 0 6px rgba(110,231,255,0.4); }
.hudArcBottom {
  text-align: center; padding: 4px 12px 8px;
  background: linear-gradient(180deg, rgba(6,14,30,0.8), rgba(6,14,30,0.95));
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
}
.hudWeaponBtn {
  background: none; border: 1px solid rgba(110,231,255,0.3); color: var(--cyan);
  padding: 6px 20px; font-family: inherit; font-size: 14px; letter-spacing: 0.12em;
  cursor: pointer; border-radius: 3px;
  text-shadow: 0 0 6px rgba(110,231,255,0.5);
}
.hudWeaponBtn:hover { background: rgba(110,231,255,0.1); }
.hudCargoBadge { color: #8ab8e0; font-size: 13px; letter-spacing: 0.08em; }
.hudCargoBadge b { color: var(--cyan); font-size: 14px; }
.hudDockBtns {
  display: flex; justify-content: center; gap: 8px; padding: 4px 0;
  height: 32px; align-items: center;
}
.hudDockBtns .miniBtn { padding: 5px 16px; font-size: 12px; }

/* Top buttons */
.hudTopBtns {
  display: flex; gap: 6px; z-index: 13; justify-content: center;
  padding: 4px 0;
}

/* Toast + warnings */
#toast {
  position: fixed; top: max(60px, calc(env(safe-area-inset-top) + 50px)); left: 50%; transform: translateX(-50%);
  background: rgba(6,14,30,0.9); border: 1px solid rgba(110,231,255,0.3); padding: 8px 20px;
  color: var(--cyan); font-size: 13px; letter-spacing: 0.1em; z-index: 20;
  border-radius: 4px; white-space: nowrap; pointer-events: none;
}
#radWarn {
  position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  color: #ff7a5e; font-size: 14px; letter-spacing: 0.15em; z-index: 15;
  text-shadow: 0 0 12px rgba(255,100,50,0.6); animation: flicker 0.5s infinite;
}
#homeHint {
  position: fixed; top: max(34px, calc(env(safe-area-inset-top) + 24px)); left: 50%; transform: translateX(-50%);
  color: #8dffd9; font-size: 12px; letter-spacing: 0.12em; z-index: 14;
}
#meltBtn {
  position: fixed; top: max(56px, calc(env(safe-area-inset-top) + 46px)); left: 50%; transform: translateX(-50%);
  background: rgba(255,94,94,0.15); border: 1px solid var(--red); color: var(--red);
  padding: 6px 16px; font-family: inherit; font-size: 11px; cursor: pointer; z-index: 14;
  border-radius: 3px;
}
.miniBtn {
  background: rgba(6,14,30,0.8); border: 1px solid rgba(110,231,255,0.25); color: #8ab8e0;
  padding: 6px 12px; font-family: inherit; font-size: 10px; letter-spacing: 0.1em;
  cursor: pointer; border-radius: 3px;
}
.miniBtn:hover { background: rgba(110,231,255,0.1); color: var(--cyan); }

/* Mobile controls — hidden on desktop */
#miniHud {
  position: fixed; bottom: calc(10px + env(safe-area-inset-bottom)); right: 10px;
  display: none; flex-direction: column; gap: 6px; z-index: 13;
}
.touchBtns {
  position: fixed; bottom: calc(10px + env(safe-area-inset-bottom)); left: 10px;
  display: none; flex-direction: column; gap: 6px; z-index: 13;
}
@media (max-width: 768px) {
  #miniHud, .touchBtns { display: flex; }
  .hudArc { width: 100vw; }
  #minimap { width: 260px; height: 260px; }
}
@media (max-width: 480px) {
  #minimap { width: 200px; height: 200px; }
}
@media (min-width: 769px) {
  #miniHud, .touchBtns { display: none !important; }
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(4, 6, 15, 0.86); z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px;
}
.overlay h2 { color: var(--cyan); letter-spacing: 0.24em; font-size: 22px; text-shadow: 0 0 16px rgba(110, 231, 255, 0.5); }
.panel { background: var(--panel); border: 1px solid rgba(110, 231, 255, 0.35); padding: 20px; width: min(420px, 92vw); max-height: 76vh; overflow-y: auto; }

#toast {
  position: fixed; top: 22%; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--amber); color: var(--amber);
  padding: 10px 22px; letter-spacing: 0.16em; font-size: 14px; z-index: 15; pointer-events: none;
  white-space: nowrap;
}
#toast.pop { animation: pop 0.25s ease-out; }
@keyframes pop { 0% { transform: translateX(-50%) scale(0.7); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }

#deadOverlay { background: rgba(40, 6, 10, 0.55); pointer-events: none; }
#deadMsg { color: var(--red); font-size: 18px; letter-spacing: 0.14em; text-shadow: 0 0 14px rgba(255, 94, 94, 0.8); }

#homeHint { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  color: #8dffd9; font-size: 12px; letter-spacing: 0.14em; text-shadow: 0 0 10px rgba(120, 255, 220, 0.7); pointer-events: none; }

.meltItem {
  display: flex; justify-content: space-between; width: 100%; padding: 12px 14px; margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(120, 255, 220, 0.4); color: #cfe8ff; font-size: 13px;
}
.meltItem:hover { background: rgba(120, 255, 220, 0.1); }
.meltFuel { color: var(--crystal); }
.meltEmpty { color: #8aa8c8; text-align: center; padding: 10px; }
#meltNote { font-size: 11px; color: #c99; margin-bottom: 12px; line-height: 1.5; }

.lbTabs { display: flex; gap: 8px; margin-bottom: 12px; }
.lbTab { flex: 1; padding: 8px; background: transparent; border: 1px solid #47617e; color: #8aa8c8; font-size: 11px; letter-spacing: 0.1em; }
.lbTab.active { border-color: var(--amber); color: var(--amber); }
.lbRow { display: flex; justify-content: space-between; padding: 8px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); font-size: 13px; }
.lbLoading { color: #8aa8c8; text-align: center; padding: 14px; }

.howList { font-size: 13px; line-height: 1.9; color: #b8d8f2; }
.howList b { color: var(--cyan); }
.howList .k { color: var(--amber); }

@media (prefers-reduced-motion: reduce) {
  #fuelFill.crit, #meltBtn { animation: none; }
}

/* ---------- Mini HUD (bottom-right corner) ---------- */
#miniHud {
  position: fixed; bottom: calc(14px + env(safe-area-inset-bottom)); right: 14px;
  display: flex; flex-direction: column; gap: 8px; z-index: 11; pointer-events: auto;
}
#miniHud button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 62px; height: 62px; border-radius: 8px;
  background: rgba(8, 14, 30, 0.88); border: 1px solid rgba(110, 231, 255, 0.5);
  color: var(--cyan); font-family: inherit; font-size: 11px; letter-spacing: 0.08em;
  gap: 4px; user-select: none; -webkit-user-select: none; cursor: pointer;
}
#miniHud button:active { background: rgba(110, 231, 255, 0.15); }
#miniShieldBtn { border-color: #6ecbff; color: #6ecbff; }
#miniWeaponBtn { border-color: var(--amber); color: var(--amber); }
#miniWeaponLabel { font-size: 16px; font-weight: 700; }
.miniLabel { font-size: 9px; opacity: 0.7; }
.miniBarBg { width: 44px; height: 5px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.miniBarFill { height: 100%; background: #6ecbff; transition: width 0.15s linear; width: 0; }

/* Radiation warning */
#radWarn {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  color: #e8c020; font-size: 16px; letter-spacing: 0.2em; text-shadow: 0 0 14px rgba(232, 192, 32, 0.8);
  pointer-events: none; animation: flicker 0.6s infinite; z-index: 12;
}
#loadMsg { color: #8aa8c8; font-size: 12px; min-height: 16px; letter-spacing: 0.1em; }

/* Touch buttons adjusted for mini HUD coexistence */
.touchBtns { right: 88px; }

/* ---------- Team / Squad panel ---------- */
.teamPanel { max-width: 420px; width: 92vw; }
.teamPanel h3 { margin: 0; }
.teamMember {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 13px;
}
.teamMember .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.teamMember .dot.on { background: #6eff8e; box-shadow: 0 0 6px #6eff8e; }
.teamMember .dot.off { background: #4a5568; }
.teamMember .role { font-size: 9px; color: #ffd75e; letter-spacing: 0.1em; margin-left: 6px; }
.teamMember .stats { color: #64748b; font-size: 11px; }
.teamMember .kickBtn { font-size: 10px; padding: 2px 8px; border-color: #ff5e5e; color: #ff5e5e; cursor: pointer; background: none; }
.teamEntry {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 13px;
}
.teamEntry .tag { color: #ffd75e; font-size: 11px; margin-right: 6px; }
.teamEntry .joinBtn { font-size: 10px; padding: 3px 10px; cursor: pointer; background: none; border: 1px solid var(--cyan); color: var(--cyan); }
.teamEntry .joinBtn:active { background: rgba(110,231,255,0.15); }
.teamColor { width: 12px; height: 12px; border-radius: 2px; display: inline-block; margin-right: 6px; }

/* Shop items */
.shopItem {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 13px;
}
.shopItem .cost { color: var(--amber); font-size: 11px; }
.shopItem .sp { color: #d98cff; font-size: 11px; margin-left: 6px; }
.shopItem button { font-size: 10px; padding: 4px 12px; background: none; border: 1px solid var(--cyan); color: var(--cyan); cursor: pointer; font-family: inherit; }
.shopItem button:active { background: rgba(110,231,255,0.15); }

/* Mission items */
.missionItem {
  padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 13px;
}
.missionItem .desc { color: #cfe8ff; }
.missionItem .prog { color: #64748b; font-size: 11px; margin-top: 3px; }
.missionItem .rewards { color: var(--amber); font-size: 10px; }
.missionItem .progBar { height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.missionItem .progFill { height: 100%; background: var(--cyan); }
@media (max-width: 640px) {
  #minimap { width: 100px; height: 100px; }
  #hudPts { font-size: 19px; }
  .hudTL { width: 40vw; }
}
