:root { color-scheme: dark; }
html, body { height: 100%; margin: 0; }
body { background: #000; overflow: hidden; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial; }
#app { width: 100%; height: 100%; position: relative; }

/* ---------------- Top Navigation ---------------- */
.top-action-bar{
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9999;

  display: inline-flex;
  align-items: stretch;
  gap: 0;

  border-radius: 16px;
  padding: 3px;

  background: rgba(2, 6, 23, .72);
  border: 1px solid rgba(125, 211, 252, .46);
  backdrop-filter: blur(14px);

  box-shadow:
    0 18px 55px rgba(0,0,0,.62),
    0 0 32px rgba(56,189,248,.24),
    inset 0 1px 0 rgba(255,255,255,.08);
}

.top-action-btn{
  min-height: 42px;
  border: 0;
  margin: 0;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  color: #f8fafc;
  background: transparent;
  text-decoration: none;
  cursor: pointer;

  font-family: inherit;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .02em;

  transition:
    background .18s ease,
    color .18s ease,
    box-shadow .18s ease,
    transform .18s ease;
}

.top-action-help{
  width: 42px;
  border-radius: 13px 7px 7px 13px;
  font-size: 19px;
  font-weight: 950;
  color: #e0f2fe;
  background: linear-gradient(135deg, rgba(56,189,248,.20), rgba(139,92,246,.14));
  box-shadow: inset -1px 0 0 rgba(255,255,255,.09);
}

.top-action-back{
  gap: 7px;
  padding: 0 15px 0 13px;
  border-radius: 7px 13px 13px 7px;
  white-space: nowrap;
}

.top-action-arrow{
  color: #7dd3fc;
  font-size: 15px;
  line-height: 1;
}

.top-action-btn:hover{
  color: #fff;
  background: rgba(56,189,248,.16);
  box-shadow: 0 0 22px rgba(56,189,248,.18) inset;
}

.top-action-bar:hover{
  border-color: rgba(125,211,252,.82);
  box-shadow:
    0 20px 60px rgba(0,0,0,.68),
    0 0 42px rgba(56,189,248,.34),
    inset 0 1px 0 rgba(255,255,255,.10);
}

.top-action-btn:active{
  transform: translateY(1px);
}

/* ---------------- Help Modal ---------------- */
#helpModalBack{
  position: fixed;
  inset: 0;

  display: none;
  align-items: center;
  justify-content: center;

  z-index: 15000;

  padding: 18px;
  background: rgba(0,0,0,.74);
  backdrop-filter: blur(8px);
}

#helpModal{
  position: relative;

  width: min(820px, 100%);
  max-height: min(86vh, 820px);
  overflow: auto;

  border-radius: 24px;
  padding: 24px;

  color: #f8fafc;
  background:
    radial-gradient(circle at 18% 0%, rgba(56,189,248,.20), transparent 32%),
    radial-gradient(circle at 88% 8%, rgba(139,92,246,.20), transparent 34%),
    linear-gradient(145deg, rgba(15,23,42,.98), rgba(2,6,23,.98));

  border: 1px solid rgba(148,163,184,.22);

  box-shadow:
    0 32px 95px rgba(0,0,0,.78),
    0 0 60px rgba(56,189,248,.14);
}

.help-kicker{
  display: inline-flex;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(56,189,248,.12);
  border: 1px solid rgba(56,189,248,.24);
  color: #bae6fd;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .06em;
  text-transform: uppercase;
}

#helpModal h2{
  margin: 0 40px 8px 0;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -.04em;
}

.help-intro{
  margin: 0 0 20px;
  color: rgba(226,232,240,.86);
  line-height: 1.55;
}

.help-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.help-section{
  padding: 16px;
  border-radius: 18px;
  background: rgba(15,23,42,.62);
  border: 1px solid rgba(148,163,184,.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

.help-section h3{
  margin: 0 0 12px;
  font-size: 17px;
}

.help-section ul{
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: rgba(226,232,240,.86);
  line-height: 1.48;
  font-size: 14px;
}

.help-section b{
  color: #fff;
}

.help-footer{
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: 16px;
  color: rgba(226,232,240,.78);
  background: rgba(2,6,23,.52);
  border: 1px solid rgba(148,163,184,.13);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

#helpCloseBtn{
  position: absolute;
  top: 14px;
  right: 16px;

  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 13px;

  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.76);

  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

#helpCloseBtn:hover{
  color: #fff;
  background: rgba(56,189,248,.15);
}

@media (max-width: 820px), (max-height: 680px){
  .top-action-bar{
    top: 10px;
    right: 10px;
  }

  .top-action-btn{
    min-height: 38px;
    font-size: 11px;
  }

  .top-action-help{
    width: 38px;
    font-size: 17px;
  }

  .top-action-back{
    padding-inline: 11px;
  }
}

@media (max-width: 460px){
  .top-action-back span:not(.top-action-arrow){
    display: none;
  }

  .top-action-back{
    width: 38px;
    padding: 0;
  }

  .help-grid{
    grid-template-columns: 1fr;
  }

  #helpModal{
    padding: 20px;
  }
}

/* ---------------- HUD (Desktop default) ---------------- */
#hud{
  position: fixed; left: 12px; top: 12px; z-index: 6;
  display: grid; gap: 10px;
  background: rgba(0,0,0,.40);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 12px 12px 10px;
  backdrop-filter: blur(6px);
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
  user-select: none;
  width: min(440px, calc(100vw - 24px));
}

#hudHeader{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}
#hudHeader .title{
  font-weight: 800;
  letter-spacing: .02em;
  opacity: .95;
}
#hudToggleBtn{
  appearance:none;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  color:#fff;
  border-radius: 12px;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
  outline: none;
}
#hudToggleBtn:hover{ background: rgba(255,255,255,.11); }

#hudGrab{
  display:none;
  height: 4px;
  width: 46px;
  margin: -2px auto 0;
  border-radius: 999px;
  background: rgba(255,255,255,.25);
}
#hudBody{
  display: grid;
  gap: 10px;
}

#hud .row { display: grid; gap: 6px; }
#hud label { font-size: 12px; opacity: .8; display: flex; justify-content: space-between; gap: 12px; }
#hud input[type="range"], #hud input[type="date"] { width: 100%; }
#hud .btns { display: flex; gap: 10px; flex-wrap: wrap; }
#hud button, #hud select, #hud input[type="date"]{
  appearance: none;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  color: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
}
#hud input[type="date"]{ cursor: text; }
#hud button:hover, #hud select:hover { background: rgba(255,255,255,.11); }
#hud .hint { font-size: 11px; opacity: .65; line-height: 1.35; }

#transferPanel{
  display: grid;
  gap: 6px;
  padding: 10px 10px 8px;
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
}
#transferPanel .h{
  font-weight: 800;
  font-size: 12px;
  opacity: .95;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
#transferBadge{
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(0,0,0,.25);
  opacity: .9;
  white-space: nowrap;
}
#transferGrid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 12px;
  opacity: .92;
}
#transferGrid .k{ opacity: .7; font-size: 11px; }
#transferGrid .v{ font-weight: 700; }

/* ---------------- Tooltip ---------------- */
#tooltip{
  position: fixed; z-index: 10; pointer-events: none;
  display: none;
  max-width: 360px;
  background: rgba(0,0,0,.82);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  transform: translate(14px, 12px);
}
#tooltip .t { font-weight: 800; margin-bottom: 4px; }
#tooltip .s { font-size: 12px; opacity: .9; line-height: 1.35; }

/* ---------------- Modal ---------------- */
#modalBack {
  position: fixed; inset: 0; z-index: 20;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.72);
}
#modal {
  width: min(560px, calc(100vw - 28px));
  border-radius: 16px;
  background: radial-gradient(circle at top, rgba(30,35,50,.95), rgba(5,6,10,.95));
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 22px 70px rgba(0,0,0,.70);
  padding: 16px 18px 18px;
  position: relative;
}
#modal h2 { margin: 0 0 6px; font-size: 20px; }
#modal .meta { font-size: 13px; opacity: .85; line-height: 1.45; }
#modal .grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  font-size: 13px;
}
#modal .card {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px;
  padding: 10px 12px;
}
#modal .k { opacity: .7; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
#modal .v { font-weight: 650; margin-top: 4px; }
#closeBtn {
  position: absolute; top: 8px; right: 10px;
  border: 0; background: transparent; color: rgba(255,255,255,.75);
  font-size: 22px; cursor: pointer;
  padding: 4px 8px; border-radius: 10px;
}
#closeBtn:hover { color: #fff; background: rgba(255,255,255,.07); }

/* ---------------- Labels ---------------- */
#labels{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 7;
}
.lbl{
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.18);
  backdrop-filter: blur(4px);
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.lbl .sub{
  opacity: .78;
  margin-left: 8px;
  font-size: 10px;
}
.lbl.rocket{
  background: rgba(0,0,0,.65);
  border: 1px solid rgba(34,211,238,.55);
  box-shadow: 0 12px 38px rgba(0,0,0,.55);
}
.lbl.rocket .sub{ opacity: .9; }

/* ---------------- Mobile: Bottom Sheet HUD ---------------- */
@media (max-width: 820px), (max-height: 680px) {
  #hud{
    left: 10px;
    right: 10px;
    top: auto;
    bottom: 10px;
    width: auto;
    border-radius: 18px;
    padding: 10px 10px 8px;
    max-height: min(62vh, 520px);
  }
  #hudGrab{ display:block; }
  #hudBody{
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: min(56vh, 460px);
    padding-right: 2px;
  }
  #hud.collapsed #hudBody{ display: none; }

  #hud button, #hud select, #hud input[type="date"]{
    padding: 10px 12px;
    font-size: 13px;
  }
  #transferGrid{
    grid-template-columns: 1fr;
  }

  /* Tooltip auf Mobile komplett weg (Hover gibt’s da eh nicht) */
  #tooltip{ display: none !important; }
}

@media (max-width: 420px){
  #hud .btns{ gap: 8px; }
  #hud button, #hud select{ flex: 1 1 auto; }
  #modal .grid{ grid-template-columns: 1fr; }
}