* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #03040a;
  color: #e6eeff;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#space {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#space.dragging { cursor: grabbing; }

#hud {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
}

.res-row {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.res {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: rgba(10, 16, 32, 0.72);
  border: 1px solid rgba(120, 180, 255, 0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 14px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.res .icon { font-size: 15px; color: #7bb8ff; }
#res-alloy .icon { color: #ffb36b; }
#res-rate .icon { color: #9df7b6; }
.res .val { font-size: 18px; font-weight: 600; letter-spacing: 0.3px; }
.res .lbl { font-size: 11px; opacity: 0.6; text-transform: uppercase; letter-spacing: 1px; }

.planet-info {
  background: rgba(10, 16, 32, 0.72);
  border: 1px solid rgba(120, 180, 255, 0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 14px;
  border-radius: 10px;
  text-align: right;
  pointer-events: auto;
}
.pname { font-size: 14px; font-weight: 600; color: #9ec6ff; }
.plvl { font-size: 11px; opacity: 0.65; margin-top: 2px; }

#launcher {
  position: fixed;
  bottom: 16px;
  left: 16px;
  background: rgba(10, 16, 32, 0.78);
  border: 1px solid rgba(120, 180, 255, 0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 14px;
  border-radius: 10px;
  z-index: 10;
  min-width: 220px;
}
.launch-hint { font-size: 11px; opacity: 0.55; text-transform: uppercase; letter-spacing: 1.2px; }
.launch-cost { margin-top: 4px; font-size: 13px; color: #ffb36b; font-variant-numeric: tabular-nums; }
.bp-slot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(120, 180, 255, 0.12);
}
.bp-label { font-size: 10px; opacity: 0.5; text-transform: uppercase; letter-spacing: 1.2px; }
.bp-name { font-size: 13px; font-weight: 600; color: #c8e0ff; margin-top: 2px; }
.bp-stats { font-size: 11px; opacity: 0.7; margin-top: 2px; font-variant-numeric: tabular-nums; }

#sidebar {
  position: fixed;
  top: 80px;
  right: 16px;
  bottom: 16px;
  width: 300px;
  background: rgba(10, 16, 32, 0.78);
  border: 1px solid rgba(120, 180, 255, 0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-row {
  display: flex;
  border-bottom: 1px solid rgba(120, 180, 255, 0.12);
}
.tab {
  flex: 1;
  padding: 12px 8px;
  background: none;
  border: none;
  color: #e6eeff;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s, background 0.15s;
  font-family: inherit;
}
.tab:hover { opacity: 0.8; }
.tab.active {
  opacity: 1;
  background: rgba(120, 180, 255, 0.08);
  box-shadow: inset 0 -2px 0 #7bb8ff;
}

.tab-pane {
  display: none;
  padding: 14px;
  overflow-y: auto;
  flex: 1;
}
.tab-pane.active { display: block; }
.tab-pane::-webkit-scrollbar { width: 6px; }
.tab-pane::-webkit-scrollbar-thumb { background: rgba(120, 180, 255, 0.2); border-radius: 3px; }

.up-item {
  background: rgba(20, 30, 55, 0.6);
  border: 1px solid rgba(120, 180, 255, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.up-item:hover { border-color: rgba(120, 180, 255, 0.3); }
.up-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.up-name { font-size: 13px; font-weight: 600; color: #c8e0ff; }
.up-lvl { font-size: 10px; opacity: 0.6; font-variant-numeric: tabular-nums; }
.up-desc { font-size: 11px; opacity: 0.65; margin-bottom: 8px; line-height: 1.4; }
.up-buy {
  width: 100%;
  padding: 7px;
  background: linear-gradient(180deg, #2c4680, #1d3160);
  border: 1px solid rgba(120, 180, 255, 0.3);
  border-radius: 6px;
  color: #e6eeff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.up-buy:hover:not(:disabled) { background: linear-gradient(180deg, #375aa0, #243c78); transform: translateY(-1px); }
.up-buy:disabled { opacity: 0.4; cursor: not-allowed; }
.up-buy .cost { opacity: 0.85; margin-left: 4px; }

.bp-list { margin-bottom: 12px; }
.bp-item {
  background: rgba(20, 30, 55, 0.6);
  border: 1px solid rgba(120, 180, 255, 0.1);
  border-left: 3px solid var(--rarity, #7bb8ff);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.12s;
}
.bp-item:hover { border-color: var(--rarity, #7bb8ff); transform: translateX(2px); }
.bp-item.selected { background: rgba(120, 180, 255, 0.12); }
.bp-item-name { font-size: 12px; font-weight: 600; color: var(--rarity, #c8e0ff); }
.bp-item-stats { font-size: 10px; opacity: 0.7; margin-top: 2px; font-variant-numeric: tabular-nums; }

.bp-roll {
  border-top: 1px solid rgba(120, 180, 255, 0.12);
  padding-top: 12px;
}
#btn-roll {
  width: 100%;
  padding: 10px;
  background: linear-gradient(180deg, #4a3080, #2e1d58);
  border: 1px solid rgba(180, 130, 255, 0.35);
  border-radius: 6px;
  color: #e6eeff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.5px;
  transition: all 0.12s;
}
#btn-roll:hover:not(:disabled) { background: linear-gradient(180deg, #5a3da0, #3e2770); transform: translateY(-1px); }
#btn-roll:disabled { opacity: 0.4; cursor: not-allowed; }
.bp-roll-hint { font-size: 10px; opacity: 0.5; text-align: center; margin-top: 6px; }

.disc-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  opacity: 0.7;
  margin-bottom: 10px;
}
.disc-progress {
  height: 6px;
  background: rgba(120, 180, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.disc-fill {
  height: 100%;
  background: linear-gradient(90deg, #7bb8ff, #b48aff);
  width: 0%;
  transition: width 0.3s;
  box-shadow: 0 0 8px rgba(123, 184, 255, 0.6);
}
.disc-label { font-size: 11px; opacity: 0.65; font-variant-numeric: tabular-nums; }
.disc-log {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(120, 180, 255, 0.1);
  font-size: 11px;
  opacity: 0.75;
  line-height: 1.5;
  max-height: 240px;
  overflow-y: auto;
}
.disc-log-item { margin-bottom: 6px; padding-left: 10px; border-left: 2px solid rgba(120, 180, 255, 0.25); }
.disc-log-item .t { color: #9ec6ff; font-weight: 600; }

#toast-stack {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  pointer-events: none;
  z-index: 20;
}
.toast {
  background: rgba(10, 16, 32, 0.92);
  border: 1px solid rgba(120, 180, 255, 0.35);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  animation: toastIn 0.25s ease-out, toastOut 0.4s ease-in 3.6s forwards;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  max-width: 360px;
  text-align: center;
}
.toast.rare { border-color: #b48aff; box-shadow: 0 0 22px rgba(180, 138, 255, 0.35); }
.toast.epic { border-color: #ffb36b; box-shadow: 0 0 22px rgba(255, 179, 107, 0.4); }
.toast.event { border-color: #9df7b6; box-shadow: 0 0 22px rgba(157, 247, 182, 0.3); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-12px); }
}

@media (max-width: 720px) {
  #sidebar {
    width: auto;
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 16px;
    height: 46%;
  }
  #launcher {
    bottom: auto;
    top: 80px;
    left: 16px;
    right: 16px;
    min-width: 0;
  }
}
