/* style.css — jeden plik, bez frameworka.
   Układ jest mobile-first: telefon dostaje mapę na cały ekran i wysuwany arkusz od dołu,
   tablet (od 700 px) i komputer (od 1000 px) — stałą kolumnę z panelem obok mapy.
   Wszystkie odstępy liczą się z bezpiecznych obszarów (notch, pasek gestów).
   Ikony to symbole SVG z index.html (<svg class="ic"><use href="#i-…"/></svg>). */

:root {
  --bg:      #060a14;
  --bg2:     #0a1020;
  --panel:   #0f182b;
  --panel2:  #152238;
  --glass:   rgba(13, 21, 38, 0.86);
  --line:    rgba(126, 158, 214, 0.15);
  --line2:   rgba(126, 158, 214, 0.30);
  --txt:     #e2eaf8;
  --dim:     #8ea3c6;
  --dim2:    #5f7292;
  --acc:     #38e8ff;
  --acc2:    #6f8bff;
  --gold:    #ffcb6b;
  --good:    #6ee7a0;
  --bad:     #ff7d8f;
  --violet:  #c08cff;

  /* powierzchnie — osobne zmienne, żeby jasny motyw mógł je podmienić */
  --input:   #0a1120;
  --hover:   rgba(255, 255, 255, 0.04);
  --hover2:  rgba(255, 255, 255, 0.08);
  --surf:    rgba(255, 255, 255, 0.035);
  --track:   rgba(255, 255, 255, 0.08);
  --cardbg:  linear-gradient(180deg, rgba(24, 38, 66, 0.92), rgba(12, 19, 35, 0.94));
  --hudbg:   linear-gradient(180deg, rgba(6, 10, 20, 0.97), rgba(6, 10, 20, 0.80));
  --sidebg:  linear-gradient(180deg, rgba(20, 32, 55, 0.985), rgba(10, 16, 30, 0.995));
  --barbg:   rgba(6, 10, 20, 0.97);
  --modalbg: linear-gradient(180deg, #16233c, #0d1424);
  --toastbg: rgba(20, 32, 55, 0.97);
  --packbg:  linear-gradient(180deg, rgba(38, 55, 92, 0.5), rgba(16, 26, 46, 0.5));

  --r:  14px;
  --r2: 20px;
  --sh: 0 10px 34px rgba(0, 0, 0, 0.55);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --tap: 44px;                     /* najmniejszy sensowny cel dla palca */
  --fs: 15px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Atrybut hidden musi wygrywać z każdym display z reguł niżej — inaczej ekran startowy
   i plansza gry pokazują się jednocześnie. */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg);
  color: var(--txt);
  font: var(--fs)/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body::before {                      /* mgławica w tle, jedna na całą aplikację */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60% 45% at 78% 12%, rgba(111, 139, 255, 0.16), transparent 70%),
    radial-gradient(50% 40% at 12% 82%, rgba(192, 140, 255, 0.13), transparent 70%),
    radial-gradient(45% 35% at 50% 50%, rgba(56, 232, 255, 0.06), transparent 70%);
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
b, strong { font-weight: 650; }
.num, .stat b, td.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--dim); }
.good { color: var(--good); }
.bad  { color: var(--bad); }
.gold { color: var(--gold); }

/* ikony */
.ic { width: 1.15em; height: 1.15em; flex: 0 0 auto; vertical-align: -0.2em; fill: none; }
button .ic { pointer-events: none; }

/* ============================ EKRAN STARTOWY ============================ */

.screen {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; overflow-x: hidden;
  padding: calc(var(--sat) + 28px) 18px calc(var(--sab) + 28px);
  display: flex; align-items: flex-start; justify-content: center;
}
/* Wyśrodkowanie przez marginesy auto: gdy treść jest wyższa niż okno (karta „Gra online"
   dochodzi po załadowaniu), nie przycina góry jak align-items: center, tylko zaczyna od góry. */
.screen > .startInner { margin: auto 0; }

/* Trzy warstwy gwiazd z gradientów — zero plików graficznych, płynny dryf. */
.sky { position: fixed; inset: -10%; pointer-events: none; z-index: 0; overflow: hidden; }
.sky i {
  position: absolute; inset: 0; display: block; background-repeat: repeat;
  animation: drift linear infinite;
}
.sky .l1 {
  background-image:
    radial-gradient(1px 1px at 20px 30px, #fff 60%, transparent),
    radial-gradient(1px 1px at 140px 80px, #cfe3ff 60%, transparent),
    radial-gradient(1.5px 1.5px at 90px 150px, #fff 60%, transparent),
    radial-gradient(1px 1px at 210px 190px, #a9c9ff 60%, transparent),
    radial-gradient(1px 1px at 60px 230px, #fff 60%, transparent);
  background-size: 260px 260px; opacity: .55; animation-duration: 160s;
}
.sky .l2 {
  background-image:
    radial-gradient(1.6px 1.6px at 50px 60px, #fff 60%, transparent),
    radial-gradient(1.2px 1.2px at 170px 130px, #ffe9b0 60%, transparent),
    radial-gradient(1.2px 1.2px at 300px 40px, #fff 60%, transparent),
    radial-gradient(2px 2px at 240px 250px, #cfe3ff 60%, transparent);
  background-size: 380px 320px; opacity: .75; animation-duration: 110s;
}
.sky .l3 {
  background-image:
    radial-gradient(2.4px 2.4px at 120px 200px, #fff 60%, transparent),
    radial-gradient(2px 2px at 420px 90px, #9ad8ff 60%, transparent),
    radial-gradient(2.8px 2.8px at 330px 330px, #fff 60%, transparent);
  background-size: 540px 460px; opacity: .9; animation-duration: 80s;
}
@keyframes drift { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-12%, 6%, 0); } }

.startInner { width: min(480px, 100%); position: relative; z-index: 1; }

.logo { text-align: center; margin-bottom: 20px; }

.logoMark {
  display: block; width: 104px; height: 104px; margin: 0 auto 16px; position: relative;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, #b8f3ff 0%, #4fc0ee 28%, #1f6fb8 55%, #0e2d62 78%, #081a3c 100%);
  box-shadow: 0 0 0 1px rgba(56, 232, 255, 0.35), 0 0 60px rgba(56, 232, 255, 0.30), inset -14px -12px 30px rgba(2, 8, 24, 0.7);
}
.logoMark::before {                 /* światła miast po nocnej stronie */
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background:
    radial-gradient(2px 2px at 66% 58%, #ffe9a8, transparent 70%),
    radial-gradient(2px 2px at 72% 66%, #ffe9a8, transparent 70%),
    radial-gradient(1.5px 1.5px at 60% 70%, #ffe9a8, transparent 70%),
    radial-gradient(2px 2px at 78% 52%, #ffd77a, transparent 70%);
  opacity: .9;
}
.logoMark .ring {                   /* pierścień planetarny */
  position: absolute; left: -26%; top: 44%; width: 152%; height: 26%;
  border: 2.5px solid rgba(255, 203, 107, 0.8); border-radius: 50%;
  transform: rotate(-16deg); box-shadow: 0 0 18px rgba(255, 203, 107, 0.35);
}
.logoMark .moon {                   /* księżyc na orbicie */
  position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px;
  border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #9fb3cf 60%, #4c5d7a);
  animation: orbit 14s linear infinite;
}
@keyframes orbit {
  from { transform: rotate(0deg) translateX(74px) rotate(0deg); }
  to   { transform: rotate(360deg) translateX(74px) rotate(-360deg); }
}

.logo h1 {
  margin: 0; font-size: 30px; letter-spacing: 0.28em; font-weight: 300; line-height: 1.15;
  text-indent: 0.28em;
}
.logo h1 span { display: block; font-weight: 800; color: var(--acc); font-size: 34px; text-shadow: 0 0 24px rgba(56, 232, 255, 0.35); }
.tagline { color: var(--dim); margin: 12px 0 0; font-size: 14px; }

.pitch { list-style: none; margin: 16px auto 0; padding: 0; display: grid; gap: 6px; max-width: 360px; text-align: left; }
.pitch li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--dim); }
.pitch .ic { color: var(--acc); width: 18px; height: 18px; }

.startCard {
  background: var(--cardbg);
  border: 1px solid var(--line2); border-radius: var(--r2);
  padding: 18px; box-shadow: var(--sh); backdrop-filter: blur(10px);
}

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--dim); margin-bottom: 7px; }
.field .hint { display: block; color: var(--dim2); font-size: 12px; margin-top: 6px; }
.field input {
  width: 100%; height: var(--tap); padding: 0 14px;
  background: var(--input); border: 1px solid var(--line2); border-radius: var(--r);
  outline: none;
}
.field input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(56, 232, 255, 0.12); }
.field select {
  width: 100%; height: var(--tap); padding: 0 14px; color: var(--txt);
  background: var(--input); border: 1px solid var(--line2); border-radius: var(--r);
  outline: none;
}
.field select:focus { border-color: var(--acc); }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1 1 0; min-width: 0; min-height: var(--tap); padding: 6px 6px; border-radius: var(--r);
  background: var(--input); border: 1px solid var(--line2); color: var(--dim);
  font-size: 13.5px; line-height: 1.15;
}
.seg button.on { background: rgba(56, 232, 255, 0.14); border-color: var(--acc); color: var(--acc); font-weight: 600; }

.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(180deg, #35d6ff, #1f8ff0);
  color: #04101f; font-weight: 700; border-radius: var(--r);
  height: var(--tap); padding: 0 18px;
  box-shadow: 0 6px 20px rgba(31, 143, 240, 0.35);
}
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: 0.45; box-shadow: none; }
.big { width: 100%; height: 52px; font-size: 16px; }

.ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--hover); border: 1px solid var(--line2);
  border-radius: var(--r); height: var(--tap); padding: 0 14px; color: var(--txt);
}
.ghost:active { background: var(--hover2); }
.ghost:disabled { opacity: 0.4; }
.ghost.danger { color: var(--bad); border-color: rgba(255, 125, 143, 0.4); }

.link { display: inline-flex; align-items: center; gap: 6px; color: var(--acc); padding: 8px 4px; font-size: 13.5px; }

.saveList { margin-top: 12px; display: grid; gap: 8px; }
.saveRow {
  display: flex; align-items: center; gap: 10px;
  background: var(--surf); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px 12px; text-align: left;
}
.saveRow b { display: block; font-size: 14px; }
.saveRow small { color: var(--dim); font-size: 12px; }
.saveRow .go { margin-left: auto; flex: 0 0 auto; }

.startLinks { display: flex; justify-content: space-between; margin-top: 10px; flex-wrap: wrap; gap: 4px 10px; }
.startCard.online { margin-top: 14px; }
.cardTitle { margin: 0 0 6px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.cardTitle .ic { color: var(--acc); }
.olMsg { border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-bottom: 10px; border: 1px solid var(--line2); }
.olMsg.bad { color: var(--bad); border-color: rgba(255, 125, 143, 0.4); background: rgba(255, 125, 143, 0.08); }
.olMsg.good { color: var(--good); border-color: rgba(110, 231, 160, 0.4); background: rgba(110, 231, 160, 0.08); }
.olUser { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; font-size: 14px; }
.olUser > span { display: inline-flex; align-items: center; gap: 6px; }
.olUser a.link { text-decoration: none; }
.madeby { text-align: center; color: var(--dim2); font-size: 12px; margin-top: 18px; }

/* ============================ UKŁAD GRY ============================ */

#app { position: fixed; inset: 0; display: flex; flex-direction: column; z-index: 1; }

/* --- pasek górny --- */
#hud {
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 12px) 8px calc(var(--sal) + 12px);
  background: var(--hudbg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px); position: relative; z-index: 8;
}
.hudRow { display: flex; align-items: center; gap: 10px; }
.hudHouse { display: flex; align-items: center; gap: 9px; min-width: 0; }
.houseMark {
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--acc), #1f8ff0);
  box-shadow: 0 0 12px rgba(56, 232, 255, 0.35);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.houseTxt { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.hudHouse b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shield {
  font-size: 11px; color: var(--good); display: inline-flex; align-items: center; gap: 4px; width: fit-content;
  border: 1px solid rgba(110, 231, 160, 0.4); border-radius: 20px; padding: 1px 8px; white-space: nowrap;
}
.hudTurn { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 13px; white-space: nowrap; }
.iconBtn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line2);
  background: var(--hover); display: grid; place-items: center; color: var(--txt);
}
.iconBtn .ic { width: 20px; height: 20px; }

.hudStats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 9px; }
.stat {
  display: flex; align-items: center; gap: 7px; min-width: 0;
  background: var(--surf); border: 1px solid var(--line); border-radius: 11px; padding: 6px 8px;
}
.stat .ic { width: 17px; height: 17px; color: var(--dim2); }
.stat div { min-width: 0; }
.stat label { display: block; font-size: 9.5px; color: var(--dim2); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.stat b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.goalWrap { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.goalBar { flex: 1; height: 5px; background: var(--track); border-radius: 3px; overflow: hidden; }
.goalBar i { display: block; height: 100%; width: 0; border-radius: 3px;
  background: linear-gradient(90deg, var(--acc), var(--gold)); transition: width 0.5s ease; }
.goalTxt { font-size: 11px; color: var(--dim); white-space: nowrap; }

/* --- środek --- */
#stage { flex: 1; position: relative; display: flex; min-height: 0; }

#mapWrap { flex: 1; position: relative; min-width: 0; touch-action: none; background: radial-gradient(120% 90% at 50% 40%, #0b1324 0%, #050811 100%); }
#map { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; }
#map text { pointer-events: none; }

/* Migotanie gwiazd — tylko część z nich, żeby nie obciążać telefonu. */
@keyframes tw { 0%, 100% { opacity: var(--o, .5); } 45% { opacity: calc(var(--o, .5) * .25); } }
#map .tw { animation: tw 4.5s ease-in-out infinite; }

.mapTop { position: absolute; top: 10px; left: calc(var(--sal) + 10px); right: 60px; display: flex; gap: 8px; pointer-events: none; }
.sectorTabs { display: flex; gap: 6px; pointer-events: auto; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.sectorTabs::-webkit-scrollbar { display: none; }
.sectorTabs button {
  flex: 0 0 auto; height: 32px; padding: 0 12px; border-radius: 18px; font-size: 12.5px; white-space: nowrap;
  background: var(--glass); border: 1px solid var(--line2); color: var(--dim);
  backdrop-filter: blur(6px); display: inline-flex; align-items: center; gap: 5px;
}
.sectorTabs button.on { color: var(--acc); border-color: var(--acc); background: rgba(56, 232, 255, 0.12); }
.sectorTabs button.locked { opacity: 0.65; }
.sectorTabs .ic { width: 13px; height: 13px; }

.mapTools { position: absolute; right: calc(var(--sar) + 10px); top: 10px; display: grid; gap: 6px; }
.mapTools button {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--glass); border: 1px solid var(--line2); color: var(--dim);
  backdrop-filter: blur(6px);
}
.mapTools .ic { width: 18px; height: 18px; }

/* pasek floty nad arkuszem */
.fleetStrip {
  position: absolute; left: 0; right: 0; bottom: 8px;
  display: flex; gap: 8px; padding: 0 calc(var(--sar) + 10px) 0 calc(var(--sal) + 10px); overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.fleetStrip::-webkit-scrollbar { display: none; }
.shipChip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  background: var(--glass); border: 1px solid var(--line2);
  border-radius: 22px; padding: 6px 12px 6px 9px; font-size: 12.5px; color: var(--txt);
  backdrop-filter: blur(6px);
}
.shipChip.on { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc), 0 0 16px rgba(56, 232, 255, 0.25); }
.shipChip .ic { width: 16px; height: 16px; color: var(--acc); }
.shipChip .ic.fly { color: var(--gold); animation: pulse 1.6s infinite; }
.shipChip small { color: var(--dim); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* --- panel boczny / arkusz --- */
.side {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  max-height: 60%; display: flex; flex-direction: column;
  background: var(--sidebg);
  border-top: 1px solid var(--line2);
  border-radius: var(--r2) var(--r2) 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.6);
  transform: translateY(101%);
  transition: transform 0.28s cubic-bezier(0.22, 0.7, 0.3, 1);
}
.side.open { transform: translateY(0); }
.sideGrip { padding: 8px 0 4px; display: flex; justify-content: center; cursor: grab; flex: 0 0 auto; }
.sideGrip i { width: 42px; height: 4px; border-radius: 3px; background: var(--line2); display: block; }
.sideBody { overflow-y: auto; overflow-x: hidden; padding: 4px 14px calc(16px + var(--sab)); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* --- pasek dolny --- */
#bar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px calc(var(--sar) + 10px) calc(8px + var(--sab)) calc(var(--sal) + 10px);
  background: var(--barbg); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px); position: relative; z-index: 7;
}
.tab {
  flex: 1 1 0; min-width: 0; height: 48px; border-radius: 12px; color: var(--dim);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tab .ic { width: 21px; height: 21px; }
.tab span { font-size: 10.5px; }
.tab.on { color: var(--acc); background: rgba(56, 232, 255, 0.1); }
.next { flex: 0 0 auto; height: 48px; padding: 0 16px; }
.next .ic { width: 16px; height: 16px; fill: currentColor; }

/* ============================ ZAWARTOŚĆ PANELI ============================ */

.panelHead { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0 12px; }
.panelHead h2 { margin: 0; font-size: 19px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.panelHead h2 .ic { color: var(--acc); width: 20px; height: 20px; }
.panelHead .sub { color: var(--dim); font-size: 12.5px; margin-top: 2px; }
.panelHead .badge { margin-left: auto; }

.badge {
  font-size: 11px; padding: 3px 9px; border-radius: 20px; display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line2); color: var(--dim); white-space: nowrap;
}
.badge.mine { color: var(--acc); border-color: rgba(56, 232, 255, 0.5); background: rgba(56, 232, 255, 0.1); }
.badge.warn { color: var(--gold); border-color: rgba(255, 203, 107, 0.45); }
.badge.bad  { color: var(--bad); border-color: rgba(255, 125, 143, 0.45); }
.badge.type { font-weight: 600; }

.card {
  background: var(--surf); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px; margin-bottom: 10px;
}
.card h3 { margin: 0 0 8px; font-size: 12.5px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card h3 .ic { width: 15px; height: 15px; color: var(--dim2); }
.desc { color: var(--dim); font-size: 13px; margin: 0 0 10px; }

.kv { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 13.5px; min-width: 0; }
.kv span { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--dim); }
.kv b { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- tabela rynku --- */
.market { width: 100%; border-collapse: collapse; font-size: 13.5px; table-layout: fixed; }
.market th {
  font-size: 10.5px; color: var(--dim2); text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 600; text-align: right; padding: 0 0 6px;
}
.market th:first-child { text-align: left; width: 42%; }
.market td { padding: 7px 0 7px 4px; border-top: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; vertical-align: middle; }
.market td:first-child { text-align: left; padding-left: 0; }
.market tr.sel td { background: rgba(56, 232, 255, 0.07); }
.market .gname { display: flex; align-items: center; gap: 7px; min-width: 0; }
.market .gname > span { min-width: 0; }
.market .gdot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; box-shadow: 0 0 8px currentColor; }
.market .hold { font-size: 11px; color: var(--acc); white-space: nowrap; }
.market .trend { font-size: 10.5px; white-space: nowrap; }
/* pasek „cena względem normy": środek to cena bazowa, lewo tanio, prawo drogo */
.pbar { position: relative; height: 4px; border-radius: 2px; background: var(--track); margin-top: 5px; overflow: hidden; }
.pbar::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--dim2); }
.pbar i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.pbar i.cheap { right: 50%; background: var(--good); }
.pbar i.dear  { left: 50%; background: var(--bad); }

/* --- suwak transakcji --- */
.trade { margin-top: 10px; border-top: 1px dashed var(--line2); padding-top: 12px; }
.tradeHead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.tradeHead b { font-size: 15px; }
.tradeHead .seg { margin-left: auto; }
.qtyRow { display: flex; align-items: center; gap: 8px; }
.qtyRow input[type=range] { flex: 1; accent-color: var(--acc); height: var(--tap); min-width: 0; }
.qtyBox {
  min-width: 76px; text-align: center; font-variant-numeric: tabular-nums; line-height: 1.1;
  background: var(--input); border: 1px solid var(--line2); border-radius: 10px; padding: 8px 6px; font-size: 15px;
}
.qtyQuick { display: flex; gap: 6px; margin-top: 8px; }
.qtyQuick button { flex: 1; height: 34px; border-radius: 9px; background: var(--hover); border: 1px solid var(--line); font-size: 12px; color: var(--dim); }
.tradeSum { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.tradeSum > div { min-width: 0; }
.tradeSum .val { font-size: 15px; font-variant-numeric: tabular-nums; }
.tradeSum button { margin-left: auto; flex: 0 0 auto; }

/* --- listy --- */
.list { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }   /* minmax(0): długi tekst w wierszu nie rozpycha panelu */
.row {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%; min-width: 0;
  background: var(--surf); border: 1px solid var(--line);
  border-radius: var(--r); padding: 9px 12px; min-height: var(--tap); color: var(--txt);
}
.row:active { background: var(--hover2); }
.row.on { border-color: var(--acc); background: rgba(56, 232, 255, 0.08); }
.row .ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 auto;
  background: var(--hover2); font-size: 14px; font-weight: 700; color: var(--dim); }
.row .ico .ic { width: 18px; height: 18px; }
.row .ico.acc { color: var(--acc); background: rgba(56, 232, 255, 0.12); }
.row .ico.gold { color: var(--gold); background: rgba(255, 203, 107, 0.12); }
.row .ico.good { color: var(--good); background: rgba(110, 231, 160, 0.12); }
.row .body { min-width: 0; flex: 1; overflow: hidden; }
.row .body b, .row .body small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.row .body b { font-size: 14px; }
.row .body small { color: var(--dim); font-size: 12px; }
.row .end { margin-left: auto; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; flex: 0 0 auto; }
.row .end .ic { width: 14px; height: 14px; }
.row.locked { opacity: 0.55; }

.btnRow { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btnRow > * { flex: 1 1 auto; }

.progress { height: 4px; background: var(--track); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--acc2), var(--acc)); }

.rankBar { height: 4px; border-radius: 2px; background: var(--track); margin-top: 5px; overflow: hidden; }
.rankBar i { display: block; height: 100%; border-radius: 2px; }

/* portret planety */
.portraitWrap { position: relative; border-radius: var(--r); overflow: hidden; margin-bottom: 10px;
  background: radial-gradient(120% 100% at 50% 20%, #0d1730 0%, #050811 100%); border: 1px solid var(--line); }
.portrait { display: block; width: 100%; height: auto; }
.portraitTags { position: absolute; left: 8px; right: 8px; bottom: 8px; display: flex; flex-wrap: wrap; gap: 5px; }
.portraitTags .badge { background: rgba(5, 8, 17, 0.75); backdrop-filter: blur(4px); }

/* statek: mała sylwetka w nagłówku */
.shipHero { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.shipHero svg { width: 64px; height: 40px; flex: 0 0 auto; }
.shipHero .spec { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; font-size: 12.5px; color: var(--dim); }
.shipHero .spec b { color: var(--txt); font-variant-numeric: tabular-nums; }

/* --- sklep --- */
.pack { border: 1px solid var(--line2); border-radius: var(--r); padding: 14px; margin-bottom: 10px;
  background: var(--packbg); }
.pack.have { border-color: rgba(110, 231, 160, 0.45); }
.packTop { display: flex; align-items: baseline; gap: 10px; }
.packTop b { font-size: 16px; }
.packTop .price { margin-left: auto; color: var(--gold); font-weight: 650; white-space: nowrap; }
.pack .tag { color: var(--dim); font-size: 12.5px; margin: 4px 0 8px; }
.pack ul { margin: 0 0 12px; padding-left: 18px; color: var(--dim); font-size: 13px; }
.pack li { margin: 3px 0; }
.fairplay { font-size: 12px; color: var(--dim2); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }

/* --- okno modalne --- */
.modalWrap { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 18px; }
.modalBack { position: absolute; inset: 0; background: rgba(3, 6, 14, 0.72); backdrop-filter: blur(3px); }
.modal {
  position: relative; width: min(480px, 100%); max-height: 84vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--modalbg);
  border: 1px solid var(--line2); border-radius: var(--r2); padding: 18px; box-shadow: var(--sh);
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.modal h2 { margin: 0 0 6px; font-size: 20px; padding-right: 36px; display: flex; align-items: center; gap: 8px; }
.modal h2 .ic { color: var(--acc); width: 22px; height: 22px; }
.modal .close { position: absolute; right: 10px; top: 10px; width: 34px; height: 34px; border-radius: 10px; color: var(--dim); display: grid; place-items: center; }
.modal .close .ic { width: 18px; height: 18px; }

.report { display: grid; gap: 8px; }
.reportLine { display: flex; gap: 9px; font-size: 13.5px; align-items: flex-start; }
.reportLine .ic { width: 16px; height: 16px; margin-top: 2px; color: var(--dim); }
.reportLine.ok .ic { color: var(--good); }
.reportLine.warn .ic { color: var(--gold); }
.reportLine.bad .ic { color: var(--bad); }
.reportLine.rival .ic { color: var(--violet); }
.reportLine.note .ic { color: var(--acc); }
.row .ico.bad { color: var(--bad); background: rgba(255, 125, 143, 0.12); }

.bigNum { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* --- powiadomienie --- */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + var(--sab)); transform: translateX(-50%);
  background: var(--toastbg); border: 1px solid var(--line2); color: var(--txt);
  padding: 10px 16px; border-radius: 22px; font-size: 13.5px; z-index: 40;
  box-shadow: var(--sh); max-width: 90vw; text-align: center;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* Wąski telefon: cztery kafelki w rzędzie się nie mieszczą, idą w dwa rzędy. */
@media (max-width: 430px) {
  .hudStats { grid-template-columns: repeat(2, 1fr); gap: 5px; }
  .stat { padding: 4px 8px; }
  .stat b { font-size: 14px; }
  .hudHouse b { font-size: 13.5px; }
}

/* ============================ TABLET (od 700 px) ============================ */

@media (min-width: 700px) {
  :root { --fs: 15.5px; }
  .startInner { width: min(560px, 100%); }
  .hudStats { grid-template-columns: repeat(4, minmax(120px, 200px)); }
  .goalWrap { max-width: 820px; }
  .stat b { font-size: 15px; }

  .side {
    position: relative; inset: auto; width: 340px; max-height: none; height: 100%;
    border-radius: 0; border-top: 0; border-left: 1px solid var(--line2);
    transform: none; box-shadow: none; flex: 0 0 auto;
  }
  .side.empty { display: none; }
  .sideGrip { display: none; }
  .sideBody { padding: 16px 16px 24px; }
  .fleetStrip { bottom: 12px; }
  #bar { justify-content: flex-start; }
  .tab { flex: 0 0 92px; }
  .next { margin-left: auto; padding: 0 22px; }
  .toast { bottom: calc(90px + var(--sab)); }
}

/* ============================ KOMPUTER (od 1000 px) ============================ */

@media (min-width: 1000px) {
  .screen { padding: 40px; }
  .startInner { width: min(1040px, 100%); display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; }
  .logo { text-align: left; margin: 0; }
  .logoMark { margin: 0 0 22px; width: 128px; height: 128px; }
  .logoMark .moon { animation-duration: 16s; }
  @keyframes orbit {
    from { transform: rotate(0deg) translateX(90px) rotate(0deg); }
    to   { transform: rotate(360deg) translateX(90px) rotate(-360deg); }
  }
  .logo h1 { font-size: 40px; }
  .logo h1 span { font-size: 46px; }
  .tagline { font-size: 16px; }
  .pitch { margin-left: 0; max-width: 420px; }
  .pitch li { font-size: 14px; }
  .madeby { grid-column: 1 / -1; }
  .startCard.online { grid-column: 1 / -1; margin-top: 0; }

  #hud { padding-left: calc(var(--sal) + 18px); padding-right: calc(var(--sar) + 18px); }
  .side { width: 400px; }
  .sideBody { padding: 18px 18px 28px; }
  .tab { flex: 0 0 100px; height: 50px; }
  .tab span { font-size: 11px; }
  .next { height: 50px; padding: 0 26px; font-size: 15.5px; }
  .modal { width: min(520px, 100%); }
}

/* ============================ SZEROKI EKRAN (od 1400 px) ============================ */

@media (min-width: 1400px) {
  :root { --fs: 16px; }
  .side { width: 460px; }
  .hudStats { grid-template-columns: repeat(4, minmax(140px, 220px)); }
  .stat { padding: 8px 10px; }
  .stat b { font-size: 16px; }
  .market { font-size: 14px; }
}

/* Telefon w poziomie: pasek górny musi zjeść mniej wysokości, panel boczny idzie na bok. */
@media (max-height: 480px) and (orientation: landscape) {
  #hud { padding-top: calc(var(--sat) + 4px); padding-bottom: 4px; }
  .hudStats { grid-template-columns: repeat(4, 1fr); margin-top: 4px; }
  .stat { padding: 3px 8px; }
  .stat label { display: none; }
  .goalWrap { display: none; }
  .side {
    position: relative; inset: auto; width: 320px; max-height: none; height: 100%;
    border-radius: 0; border-top: 0; border-left: 1px solid var(--line2); transform: none; box-shadow: none; flex: 0 0 auto;
  }
  .side.empty { display: none; }
  .sideGrip { display: none; }
  #bar { padding-top: 4px; padding-bottom: calc(4px + var(--sab)); }
  .tab { height: 40px; flex: 0 0 80px; }
  .tab span { display: none; }
  .next { height: 40px; margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- jasny motyw ----------
   Przełącznik: ekran startowy → „Motyw jasny", w grze Menu → Motyw. Zapis w localStorage
   (kupiec.theme); atrybut data-theme na <html> ustawia skrypt w <head>, zanim cokolwiek się narysuje.
   Mapa zostaje ciemna w obu motywach — to kosmos; jasne są panele, HUD, okna i ekran startowy. */
:root[data-theme="light"] {
  --bg:      #eef2fa;
  --bg2:     #e3e9f5;
  --panel:   #ffffff;
  --panel2:  #f4f7fc;
  --glass:   rgba(255, 255, 255, 0.88);
  --line:    rgba(40, 70, 130, 0.14);
  --line2:   rgba(40, 70, 130, 0.30);
  --txt:     #15213a;
  --dim:     #56678a;
  --dim2:    #8593ad;
  --acc:     #0b7fa3;
  --acc2:    #3f5bd6;
  --gold:    #9a6a0c;
  --good:    #1f8a4c;
  --bad:     #b8364c;
  --violet:  #7a4fd6;
  --sh:      0 10px 34px rgba(20, 40, 80, 0.14);
  --input:   #ffffff;
  --hover:   rgba(20, 40, 80, 0.05);
  --hover2:  rgba(20, 40, 80, 0.10);
  --surf:    rgba(20, 40, 80, 0.04);
  --track:   rgba(20, 40, 80, 0.10);
  --cardbg:  linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 247, 252, 0.96));
  --hudbg:   linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(255, 255, 255, 0.88));
  --sidebg:  linear-gradient(180deg, rgba(255, 255, 255, 0.985), rgba(244, 247, 252, 0.995));
  --barbg:   rgba(255, 255, 255, 0.97);
  --modalbg: linear-gradient(180deg, #ffffff, #f2f5fb);
  --toastbg: rgba(255, 255, 255, 0.97);
  --packbg:  linear-gradient(180deg, rgba(230, 238, 252, 0.7), rgba(244, 247, 252, 0.7));
}
:root[data-theme="light"] body::before { opacity: 0.45; }
:root[data-theme="light"] .sky { opacity: 0.12; }
:root[data-theme="light"] .logo h1 span { text-shadow: none; }
:root[data-theme="light"] .primary { color: #ffffff; background: linear-gradient(180deg, #1aa7d6, #1569d4); box-shadow: 0 6px 20px rgba(21, 105, 212, 0.28); }
:root[data-theme="light"] .portraitTags .badge { background: rgba(255, 255, 255, 0.85); }
/* Kolory domów, towarów i typów planet są pastelowe (pod ciemne tło). W jasnym motywie
   na białych panelach i w oknach przyciemniamy je filtrem — mapa (zawsze ciemna) zostaje bez zmian. */
:root[data-theme="light"] .side [style*="color:"],
:root[data-theme="light"] .modal [style*="color:"],
:root[data-theme="light"] .side .badge.type,
:root[data-theme="light"] .side .gname .gdot { filter: brightness(0.62) saturate(1.5); }
:root[data-theme="light"] .side .portraitWrap [style*="color:"] { filter: none; }

/* ---------- herby i barwy ---------- */
.herb { width: 1.2em; height: 1.2em; fill: none; flex: 0 0 auto; }
.houseMark { display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--hc, var(--acc)), color-mix(in srgb, var(--hc, var(--acc)) 55%, #1f4fb0)); }
.houseMark .herb { width: 16px; height: 16px; }
.row .ico .herb { width: 20px; height: 20px; }
.herb.big { width: 48px; height: 48px; }
.herbPreview { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.herbGrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.herbBtn { height: 48px; border-radius: 10px; background: var(--surf); border: 1px solid var(--line); display: grid; place-items: center; }
.herbBtn .herb { width: 26px; height: 26px; }
.herbBtn.on { border-color: var(--acc); background: rgba(56, 232, 255, 0.12); }
.barwaGrid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.barwaBtn { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; box-shadow: 0 0 0 1px var(--line2); }
.barwaBtn.on { border-color: var(--txt); box-shadow: 0 0 0 2px var(--acc); }
.saveHint { display: flex; gap: 7px; align-items: flex-start; font-size: 12.5px; color: var(--dim); margin: 10px 0 0; line-height: 1.4; }
.saveHint .ic { flex: 0 0 auto; margin-top: 2px; color: var(--gold); }
.saveHint .link { display: inline; padding: 0; height: auto; font-size: inherit; }
