/* Орбита — стили */
:root {
  --bg: #050814;
  --panel: rgba(9, 14, 32, 0.84);
  --card: rgba(255, 255, 255, 0.045);
  --card-h: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9edff;
  --muted: #8e99bf;
  --accent: #7dd3fc;
  --accent2: #a78bfa;
  --gold: #fbbf24;
  --danger: #fda4af;
  --font: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
h2, h3, p { margin: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- раскладка ---------- */

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  height: 100vh;
  height: 100dvh;
}

.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
#scene.is-hot { cursor: pointer; }

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

@media (max-width: 880px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 42vh 1fr;
    grid-template-rows: 42dvh 1fr;
  }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
}

/* ---------- сцена: верх ---------- */

.brand {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  left: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}
.brand .ico { width: 16px; height: 16px; color: var(--gold); }

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(18px + env(safe-area-inset-top)) 16px 0;
  text-align: center;
  pointer-events: none;
}
.hud__label { font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--muted); }
.hud__energy {
  font-size: clamp(34px, 5.2vw, 56px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 28px rgba(125, 211, 252, 0.35), 0 2px 10px rgba(0, 0, 0, 0.65);
}
.hud__rates {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}
.hud__rates b { color: var(--text); font-weight: 600; }
.hud__sep { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); opacity: 0.7; }

.boost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #fef3c7;
  background: rgba(120, 80, 10, 0.45);
  border: 1px solid rgba(251, 191, 36, 0.5);
  box-shadow: 0 0 22px rgba(251, 191, 36, 0.25);
  animation: boostPulse 1.4s ease-in-out infinite;
}
.boost .ico { width: 16px; height: 16px; color: var(--gold); }
.boost b { font-variant-numeric: tabular-nums; min-width: 2.2em; text-align: right; }
@keyframes boostPulse {
  50% { box-shadow: 0 0 32px rgba(251, 191, 36, 0.5); }
}

.iconbtn {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  right: 16px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  background: rgba(10, 15, 34, 0.6);
  border: 1px solid var(--line);
  transition: color 0.15s, background 0.15s;
}
.iconbtn:hover { color: var(--text); background: rgba(255, 255, 255, 0.1); }

.hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 74px);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(10, 15, 34, 0.72);
  border: 1px solid var(--line);
  pointer-events: none;
  animation: hintPulse 1.8s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { opacity: 0.55; transform: translate(-50%, 74px) scale(1); }
  50% { opacity: 1; transform: translate(-50%, 66px) scale(1.04); }
}

.starinfo {
  position: absolute;
  left: 18px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(250px, 62vw);
  pointer-events: none;
}
.starinfo__name { font-size: 13px; font-weight: 600; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }
.starinfo__next { margin-top: 5px; font-size: 11px; color: var(--muted); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8); }

.bar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin-top: 7px; }
.bar i {
  display: block;
  height: 100%;
  transform-origin: left;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: transform 0.25s ease-out;
}
.starinfo .bar { background: rgba(255, 255, 255, 0.18); }

/* ---------- уведомления ---------- */

.toasts {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  width: min(340px, calc(100% - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(12, 18, 40, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: toastIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.toast.is-out { animation: toastOut 0.3s ease-in both; }
.toast .ico { width: 22px; height: 22px; color: var(--gold); }
.toast__t { font-size: 13.5px; font-weight: 700; }
.toast__d { font-size: 12px; color: var(--muted); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ---------- панель ---------- */

.goal {
  margin: 14px 12px 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.11), rgba(167, 139, 250, 0.11));
  border: 1px solid rgba(125, 211, 252, 0.2);
}
.goal__top {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.goal__text { margin-top: 2px; font-size: 14px; font-weight: 600; }

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  margin: 0 12px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}
.tab {
  position: relative;
  padding: 8px 2px;
  border-radius: 9px;
  font-size: clamp(11px, 3.1vw, 12.5px);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: #06101f; background: linear-gradient(135deg, #7dd3fc, #a78bfa); }
.tab__badge {
  position: absolute;
  top: 3px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}

.tabs__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
  -webkit-overflow-scrolling: touch;
}
.tabpane { display: none; }
.tabpane.is-active { display: block; }

.seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  padding: 4px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}
.seg button { padding: 6px 0; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.seg button:hover { color: var(--text); }
.seg button.is-active { background: rgba(255, 255, 255, 0.13); color: var(--text); }

.list { display: flex; flex-direction: column; gap: 8px; }

/* карточка покупки */
.item {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, opacity 0.15s;
}
.item > *:not(.item__fill) { position: relative; }
.item:not(.is-poor):not(:disabled):hover {
  background: var(--card-h);
  border-color: rgba(255, 255, 255, 0.22);
  border-color: color-mix(in srgb, var(--c) 45%, transparent);
}
.item:not(.is-poor):not(:disabled):active { transform: scale(0.985); }
.item.is-shake { animation: shake 0.3s; }
@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.item__fill {
  position: absolute;
  inset: 0;
  transform-origin: left;
  transform: scaleX(0);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03));
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 18%, transparent), color-mix(in srgb, var(--c) 5%, transparent));
  transition: transform 0.2s ease-out;
  pointer-events: none;
}
.item--up .item__name { white-space: normal; line-height: 1.25; }
.item.is-poor { opacity: 0.66; }
.item.is-poor .item__icon { filter: saturate(0.55); }
.item.is-locked { opacity: 0.5; cursor: default; }
.item.is-locked .item__icon { color: var(--muted); }
.item__icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--c);
  background: rgba(255, 255, 255, 0.06);
  background: color-mix(in srgb, var(--c) 13%, transparent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 28%, transparent);
}
.item__icon .ico { width: 26px; height: 26px; }
.item__main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item__title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.item__name { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__n { flex: none; font-size: 13px; font-weight: 700; color: var(--c); font-variant-numeric: tabular-nums; }
.item__sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.item__cost { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.item__qty { min-height: 15px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.item__price {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.08);
  background: color-mix(in srgb, var(--c) 20%, transparent);
}
.item.is-poor .item__price, .item.is-locked .item__price { background: rgba(255, 255, 255, 0.07); color: var(--muted); }
.item__price .ico { width: 13px; height: 13px; color: var(--gold); fill: currentColor; stroke: none; }

.empty { padding: 22px 14px; text-align: center; font-size: 13px; color: var(--muted); }
.footnote { margin: 12px 2px 0; font-size: 12px; color: var(--muted); }

/* карточки разделов */
.card {
  padding: 16px;
  margin-bottom: 12px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
}
.card h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 15px; }
.card h3 .ico { color: var(--gold); }
.card p { margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.card p b { color: var(--text); }
.card__label { margin: 2px 0 10px; font-size: 13px; font-weight: 600; }
.card__note { margin: 6px 0 12px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stat-big { display: flex; align-items: center; gap: 10px; font-size: 34px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-big .ico { width: 32px; height: 32px; color: var(--accent2); }
.card--finale { border-color: rgba(251, 191, 36, 0.25); background: rgba(251, 191, 36, 0.04); }
.card--finale .bar { margin: 0 0 12px; }
.card--finale .bar i { background: linear-gradient(90deg, #fde68a, #fbbf24); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  transition: filter 0.15s, transform 0.08s;
}
.btn:hover { filter: brightness(1.18); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }
.btn--primary { color: #06101f; background: linear-gradient(135deg, #7dd3fc, #a78bfa); border-color: transparent; }
.btn--gold { color: #1c1302; background: linear-gradient(135deg, #fde68a, #fbbf24); border-color: transparent; }
.btn--danger { color: var(--danger); background: rgba(253, 164, 175, 0.12); border-color: rgba(253, 164, 175, 0.3); }
.stack { display: flex; flex-direction: column; gap: 8px; }

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-variant-numeric: tabular-nums; text-align: right; }

.ach { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.ach__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  opacity: 0.45;
}
.ach__item.is-on { opacity: 1; background: rgba(251, 191, 36, 0.06); border-color: rgba(251, 191, 36, 0.3); }
.ach__item .ico { width: 22px; height: 22px; color: var(--muted); }
.ach__item.is-on .ico { color: var(--gold); }
.ach__name { font-size: 13px; font-weight: 600; }
.ach__desc { font-size: 11.5px; color: var(--muted); }

/* ---------- вспышка и окна ---------- */

.flash {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.5s ease;
}
.flash.is-on { opacity: 1; transition-duration: 0.25s; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 5, 14, 0.74);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade 0.2s both;
}
.modal__box {
  width: min(100%, 440px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 22px;
  border-radius: 20px;
  background: #0c1228;
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.modal__title { margin-bottom: 10px; font-size: 20px; font-weight: 700; }
.modal__body { font-size: 14px; color: #b9c2e4; }
.modal__body p { margin-bottom: 10px; }
.modal__body b { color: var(--text); }
.modal__stats { margin: 4px 0 12px; }
.modal__actions { display: flex; gap: 8px; margin-top: 16px; }
.modal__actions .btn { flex: 1; }
.form-error { min-height: 18px; margin-top: 6px; font-size: 12.5px; color: var(--danger); }
.ta {
  display: block;
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  resize: vertical;
  word-break: break-all;
}
.ta:focus { outline: 2px solid rgba(125, 211, 252, 0.5); outline-offset: 1px; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
}

@media (max-width: 880px) {
  /* на телефоне уведомления ложатся на верх панели, а не на звезду */
  .toasts {
    position: fixed;
    top: calc(42vh + 8px);
    top: calc(42dvh + 8px);
    left: 12px;
    right: 12px;
    bottom: auto;
    width: auto;
    align-items: stretch;
  }
  .toast { padding: 8px 12px; background: #101737; }
}

@media (max-width: 420px) {
  .ach { grid-template-columns: 1fr; }
  .hud__rates { font-size: 13px; gap: 8px; }
  .brand { left: 14px; letter-spacing: 0.2em; }
}

@media (prefers-reduced-motion: reduce) {
  .hint, .boost { animation: none; }
  .bar i, .item__fill { transition: none; }
}
