/* ====== Galaxy Base — kosmiczne, kreskówkowe UI ====== */

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

:root {
  --panel-bg: rgba(18, 22, 56, 0.94);
  --panel-border: #5d7cff;
  --gold1: #ffd34d;
  --gold2: #ff9d2e;
  --text: #ffffff;
  --font: "Comic Sans MS", "Segoe UI", "Trebuchet MS", sans-serif;
}

html, body { width: 100%; height: 100%; overflow: hidden; background: #0b1030; }
body { font-family: var(--font); color: var(--text); }

#canvas { position: fixed; inset: 0; display: block; cursor: grab; }
#canvas.placing { cursor: crosshair; }
#canvas.panning { cursor: grabbing; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }

.hidden { display: none !important; }

/* ---------- Górny pasek ---------- */
#topbar {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
#topbar .spacer { flex: 1; pointer-events: none; }

.pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel-bg);
  border: 3px solid var(--panel-border);
  border-radius: 999px;
  padding: 5px 14px 5px 9px;
  font-weight: bold; font-size: 15px;
  box-shadow: 0 3px 0 rgba(0,0,0,.35);
  white-space: nowrap;
}
.pill .ico { font-size: 17px; }
.pill small { opacity: .55; font-size: 11px; }
.pill.gold { border-color: #d9a514; }
.pill.purple { border-color: #9b5dff; }

.iconbtn {
  width: 42px; height: 42px; border-radius: 12px;
  border: 3px solid var(--panel-border);
  background: var(--panel-bg);
  font-size: 19px; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.35);
  transition: transform .08s;
}
.iconbtn:hover { transform: scale(1.08); }
.iconbtn:active { transform: scale(.95); }
.iconbtn { position: relative; }

.badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 4px;
  background: #e23a3a; border: 2px solid #fff; border-radius: 999px;
  font-size: 10px; font-weight: bold; line-height: 14px; text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

/* ---------- Dolny pasek narzędzi ---------- */
#toolbar {
  position: absolute; bottom: 16px; right: 16px;
  display: flex; gap: 12px;
}
.bigbtn {
  width: 76px; height: 76px; border-radius: 20px;
  border: 4px solid #7a4a00;
  background: linear-gradient(#ffd34d, #ff9d2e);
  font-size: 28px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 5px 0 #7a4a00, 0 8px 14px rgba(0,0,0,.4);
  transition: transform .08s;
  font-family: var(--font);
}
.bigbtn small { font-size: 12px; font-weight: bold; color: #5b3400; }
.bigbtn:hover { transform: translateY(-3px); }
.bigbtn:active { transform: translateY(2px); box-shadow: 0 2px 0 #7a4a00; }
.bigbtn.red { background: linear-gradient(#ff7b6b, #e23a3a); border-color: #7a0c00; }
.bigbtn.red small { color: #5e0800; }

/* ---------- Panel (dolna karta) ---------- */
#panel {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  width: min(780px, calc(100vw - 24px));
  max-height: 56vh; overflow-y: auto;
  background: var(--panel-bg);
  border: 4px solid var(--panel-border);
  border-radius: 20px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
#panel h2 { font-size: 19px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
#panel h2 .x { margin-left: auto; }

.xbtn {
  width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--panel-border);
  background: rgba(255,255,255,.08); color: #fff; font-size: 14px; cursor: pointer;
}
.xbtn:hover { background: rgba(255,90,90,.35); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }

.card {
  background: rgba(255,255,255,.07);
  border: 3px solid #3d52a8;
  border-radius: 14px;
  padding: 10px; cursor: pointer; text-align: center;
  transition: transform .08s, border-color .08s;
  position: relative;
}
.card:hover { transform: scale(1.04); border-color: #8aa2ff; }
.card .cicon { font-size: 30px; display: block; }
.card b { display: block; font-size: 13px; margin: 3px 0; }
.card .cost { display: block; font-size: 12px; color: var(--gold1); font-weight: bold; }
.card .cost.broke { color: #ff8585; }
.card .meta { display: block; font-size: 11px; opacity: .65; margin-top: 2px; }
.card.off { opacity: .45; filter: grayscale(.6); cursor: not-allowed; }
.card.off:hover { transform: none; }
.card .lock { display: block; font-size: 11px; color: #ffb3b3; font-weight: bold; margin-top: 2px; }

/* ---------- Wiersze (armia / informacje) ---------- */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.07);
  border: 2px solid #3d52a8; border-radius: 12px; padding: 8px 12px;
}
.row .ricon { font-size: 26px; }
.row .rbody { flex: 1; min-width: 0; }
.row .rbody b { font-size: 14px; }
.row .rbody small { display: block; font-size: 11px; opacity: .7; }
.costline { font-size: 13px; font-weight: 600; color: #d8b8ff; margin: 3px 0 1px; }
.costline.warn { color: #ffb3b3; }
.row .rcount { font-size: 15px; font-weight: bold; min-width: 34px; text-align: center; }
.row[data-act] { cursor: pointer; }
.row[data-act]:hover { border-color: #8aa2ff; }

.btn {
  font-family: var(--font);
  border: 3px solid #1d5c1d; border-radius: 11px;
  background: linear-gradient(#7ee04e, #3fae2a);
  color: #fff; font-weight: bold; font-size: 13px;
  padding: 7px 14px; cursor: pointer;
  box-shadow: 0 3px 0 #1d5c1d;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
  transition: transform .08s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #1d5c1d; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.gold { background: linear-gradient(#ffd34d, #ff9d2e); border-color: #7a4a00; box-shadow: 0 3px 0 #7a4a00; }
.btn.blue { background: linear-gradient(#6fa8ff, #3a6fe2); border-color: #173a8a; box-shadow: 0 3px 0 #173a8a; }
.btn.redbtn, .redbtn {
  font-family: var(--font);
  background: linear-gradient(#ff7b6b, #e23a3a); border: 3px solid #7a0c00;
  box-shadow: 0 3px 0 #7a0c00; color: #fff; font-weight: bold;
  border-radius: 11px; padding: 7px 14px; cursor: pointer; font-size: 13px;
}

.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.statline { font-size: 13px; margin: 2px 0; opacity: .9; }
.statline b { color: var(--gold1); }

.capbar { height: 16px; background: rgba(0,0,0,.4); border-radius: 8px; overflow: hidden; border: 2px solid #3d52a8; margin: 6px 0 10px; }
.capbar i { display: block; height: 100%; background: linear-gradient(#7ee04e, #3fae2a); border-radius: 6px; transition: width .2s; }

.queue { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.qitem { background: rgba(0,0,0,.35); border: 2px solid #3d52a8; border-radius: 10px; padding: 4px 10px; font-size: 12px; font-weight: bold; }

.note { font-size: 12px; opacity: .7; margin-top: 8px; text-align: center; }

.section { margin: 12px 0 8px; padding-top: 8px; border-top: 2px solid rgba(93,124,255,.35); }
.section h3 { font-size: 15px; margin-bottom: 8px; opacity: .95; }

.qrow {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.07);
  border: 2px solid #3d52a8; border-radius: 12px; padding: 8px 10px;
  margin-bottom: 8px;
}
.qrow.done { border-color: #4fd64f; }
.qrow.claimed { opacity: .55; }
.qrow .qicon { font-size: 24px; flex-shrink: 0; }
.qrow .qbody { flex: 1; min-width: 0; }
.qrow .qbody b { font-size: 13px; display: block; }
.qrow .qbody small { font-size: 11px; opacity: .75; display: block; }
.qrow .qreward { font-size: 11px; color: var(--gold1); font-weight: bold; margin-top: 2px; }
.qprog { height: 8px; background: rgba(0,0,0,.35); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.qprog i { display: block; height: 100%; background: linear-gradient(#7ee04e, #3fae2a); border-radius: 4px; transition: width .2s; }
.qrow .qact { flex-shrink: 0; }

.raidbox {
  background: rgba(226,58,58,.12); border: 3px solid #e23a3a; border-radius: 14px;
  padding: 12px; margin-bottom: 10px; text-align: center;
}
.raidbox .rw { font-size: 14px; margin: 4px 0; }
.raidbox .rw b { color: var(--gold1); }
.raidbox small { opacity: .75; font-size: 11px; display: block; margin-top: 4px; }

.modepill {
  display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: bold;
  background: rgba(255,255,255,.1); border: 2px solid #3d52a8; margin: 4px 0 8px;
}
.cat-head {
  font-size: 14px; font-weight: bold; margin: 14px 0 8px; padding-bottom: 4px;
  border-bottom: 2px solid rgba(93,124,255,.45); opacity: .95;
}
.cat-head:first-of-type { margin-top: 0; }
.limgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 12px; margin-top: 8px; }
.limgrid span:nth-child(odd) { opacity: .75; }
.limgrid span:nth-child(even) { font-weight: bold; color: var(--gold1); text-align: right; }

/* ---------- Pasek bitwy ---------- */
#battlebar {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center;
  background: var(--panel-bg); border: 4px solid #e23a3a; border-radius: 16px;
  padding: 8px 14px; box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.bb-box { text-align: center; min-width: 74px; }
.bb-box b { display: block; font-size: 17px; color: var(--gold1); }
#battlebar .btn { font-size: 13px; padding: 6px 12px; white-space: nowrap; }
#bb-speed { min-width: 72px; }

#unitbar {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center;
  background: var(--panel-bg); border: 4px solid var(--panel-border); border-radius: 18px;
  padding: 10px 14px;
}
#unitbar .label { font-size: 12px; opacity: .75; max-width: 130px; text-align: center; }
.chip {
  width: 64px; height: 64px; border-radius: 14px; cursor: pointer;
  border: 3px solid #3d52a8; background: rgba(255,255,255,.07);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 22px; position: relative; transition: transform .08s;
  font-family: var(--font); color: #fff;
}
.chip small { font-size: 13px; font-weight: bold; }
.chip:hover { transform: scale(1.07); }
.chip.sel { border-color: var(--gold1); background: rgba(255,211,77,.18); box-shadow: 0 0 12px rgba(255,211,77,.6); }
.chip.empty { opacity: .35; cursor: not-allowed; }

/* ---------- Baner raidu ---------- */
#raidbanner {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(#ff5b4d, #c01f1f);
  border: 4px solid #6d0000; border-radius: 14px;
  padding: 9px 22px; font-size: 17px; font-weight: bold;
  text-shadow: 0 2px 3px rgba(0,0,0,.5);
  animation: pulse 1s infinite;
  box-shadow: 0 6px 24px rgba(255,40,40,.45);
}
@keyframes pulse { 0%,100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.05); } }

/* ---------- Podpowiedź ---------- */
#hint {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  background: var(--panel-bg); border: 3px solid var(--gold1); border-radius: 999px;
  padding: 8px 12px 8px 18px; font-size: 14px; font-weight: bold;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.45);
  max-width: 90vw;
}
#hint-close { background: none; border: none; color: #fff; opacity: .6; cursor: pointer; font-size: 13px; }

#visit-banner {
  position: fixed; top: 54px; left: 50%; transform: translateX(-50%);
  z-index: 7500;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  justify-content: center;
  background: var(--panel-bg); border: 3px solid var(--gold1);
  border-radius: 14px; padding: 8px 16px;
  box-shadow: 0 6px 24px rgba(0,0,0,.55);
  pointer-events: auto;
  max-width: min(560px, 94vw);
  font-size: 13px; font-weight: bold;
}
.visit-off { opacity: .35; pointer-events: none !important; }
#hint-close:hover { opacity: 1; }

/* ---------- Modal ---------- */
#modal-wrap {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(5,8,25,.65);
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
}
#modal {
  background: var(--panel-bg); border: 4px solid var(--panel-border); border-radius: 22px;
  padding: 22px 26px; min-width: 320px; max-width: min(480px, 92vw);
  text-align: center; box-shadow: 0 14px 50px rgba(0,0,0,.6);
}
#modal h1 { font-size: 24px; margin-bottom: 10px; }
#modal .mline { font-size: 15px; margin: 5px 0; }
#modal .mline b { color: var(--gold1); }
#modal .btnrow { justify-content: center; margin-top: 16px; }

/* ---------- Toasty ---------- */
#toasts {
  position: fixed; bottom: 18px; left: 18px; z-index: 10001;
  display: flex; flex-direction: column; gap: 7px; max-width: 320px;
  pointer-events: none;
}
.toast {
  background: var(--panel-bg); border: 3px solid var(--panel-border);
  border-radius: 12px; padding: 8px 14px; font-size: 13px; font-weight: bold;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  animation: toastin .25s ease-out;
}
.toast.good { border-color: #4fd64f; }
.toast.bad { border-color: #ff5b4d; }
.toast.fade { opacity: 0; transition: opacity .5s; }
@keyframes toastin { from { transform: translateX(-30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Scrollbar ---------- */
#panel::-webkit-scrollbar { width: 10px; }
#panel::-webkit-scrollbar-thumb { background: #3d52a8; border-radius: 6px; }

/* ---------- Logowanie (Netlify) ---------- */
#auth-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(5, 8, 25, .88);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.auth-box {
  background: var(--panel-bg); border: 4px solid var(--panel-border);
  border-radius: 22px; padding: 28px 32px; max-width: min(400px, 92vw);
  box-shadow: 0 16px 60px rgba(0,0,0,.65); text-align: center;
}
.auth-box h2 { font-size: 22px; margin-bottom: 8px; }
.auth-sub { font-size: 13px; opacity: .85; margin-bottom: 18px; line-height: 1.45; }
.auth-box label {
  display: block; text-align: left; font-size: 12px; font-weight: bold;
  margin-bottom: 12px; text-transform: uppercase; letter-spacing: .5px; opacity: .9;
}
.auth-box input, .auth-inp {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px;
  border: 2px solid #3d52a8; border-radius: 10px; background: #0e1430;
  color: #fff; font-size: 15px; font-family: inherit; box-sizing: border-box;
}
.auth-box input:focus, .auth-inp:focus { outline: none; border-color: var(--gold1); }
.auth-hint { font-size: 11px; opacity: .65; margin-top: 14px; line-height: 1.4; }

/* ---------- Galaktyka ---------- */
#galaxy-wrap {
  position: fixed; inset: 0; z-index: 8000;
  background: #060818;
  opacity: 0;
  transform: scale(1.06);
  transition: opacity .4s ease, transform .45s ease;
}
#galaxy-wrap.galaxy-in {
  opacity: 1;
  transform: scale(1);
}
#galaxy-wrap.galaxy-out {
  opacity: 0;
  transform: scale(0.92);
}
#galaxy-canvas {
  position: absolute; inset: 0; z-index: 1;
  display: block; cursor: grab;
  touch-action: none;
}
#galaxy-hud {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 30;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  pointer-events: none;
}
#galaxy-hud > * { pointer-events: auto; }
.galaxy-title {
  font-size: 18px; font-weight: bold;
  background: var(--panel-bg); border: 3px solid var(--panel-border);
  border-radius: 12px; padding: 6px 14px;
}
.galaxy-sub {
  font-size: 13px; opacity: .85;
  background: rgba(18,22,56,.8); border-radius: 10px; padding: 5px 12px;
}
.galaxy-roster {
  flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  pointer-events: auto;
}
.galaxy-hint {
  font-size: 12px; line-height: 1.45; opacity: .9;
  background: rgba(120,40,40,.55); border: 2px solid rgba(255,120,120,.35);
  border-radius: 10px; padding: 8px 12px; max-width: 520px;
}
.gal-roster-btn { font-size: 12px; padding: 5px 10px; transition: box-shadow .15s, border-color .15s; }
.gal-roster-btn.active {
  border-color: var(--gold1);
  box-shadow: 0 0 14px rgba(255, 210, 63, .55);
  background: rgba(255, 210, 63, .18);
}
.gal-visit-preview {
  width: 96px; height: 96px; border-radius: 50%; margin: 8px auto 12px;
  box-shadow: 0 0 28px rgba(255,255,255,.25);
}
.gal-visit-stats { text-align: left; font-size: 14px; line-height: 1.7; margin: 10px 0; }
#galaxy-side {
  position: absolute; top: 70px; right: 16px; z-index: 60;
  width: min(280px, 90vw);
  background: var(--panel-bg); border: 4px solid var(--panel-border);
  border-radius: 18px; padding: 18px 16px 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.55);
  text-align: center;
  pointer-events: auto;
}
.gal-title { font-size: 18px; margin-bottom: 2px; }
.gal-user { font-size: 11px; opacity: .7; margin-bottom: 10px; }
.planet-edit { padding: 8px 4px 12px; text-align: left; }
.planet-edit label {
  display: block; font-size: 12px; font-weight: bold; margin: 10px 0 4px;
}
.planet-edit input[type="range"] { width: 100%; }
.pe-size-btns {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0 12px;
}
.pe-size-btn { font-size: 12px; padding: 8px 6px; }
.pe-size-btn.sel {
  border-color: var(--gold1);
  box-shadow: 0 0 10px rgba(255, 210, 63, .45);
  background: rgba(255, 210, 63, .15);
}
.pe-name-row {
  display: flex; gap: 8px; align-items: stretch; margin-bottom: 4px;
}
.pe-name-row .auth-inp { flex: 1; min-width: 0; }
.pe-name-row .btn { flex-shrink: 0; padding: 8px 12px; font-size: 12px; }
.planet-preview-wrap {
  height: 88px; overflow: hidden; display: flex; align-items: center;
  justify-content: center; margin: 10px 0 4px; isolation: isolate;
}
.planet-edit .gal-planet-preview { margin: 0; transform-origin: center center; }
.gal-planet-preview {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto;
  box-shadow: 0 0 20px rgba(255,255,255,.25);
}

#mission-rail {
  position: fixed; left: 8px; top: 50%; transform: translateY(-50%);
  z-index: 45; width: min(200px, 30vw); pointer-events: auto;
}
.mission-card {
  background: rgba(10, 18, 42, .9); border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px; padding: 10px 12px; font-size: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.45); backdrop-filter: blur(6px);
}
.mission-card.claimable { border-color: rgba(255, 211, 77, .55); }
.mission-card.daily { border-color: rgba(100, 180, 255, .35); }
.mc-head { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.mc-desc { opacity: .9; margin-bottom: 6px; line-height: 1.3; }
.mc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.btn.sm { padding: 4px 8px; font-size: 11px; min-height: 0; }

.stats-block { margin: 8px 0 14px; }
.stats-block h4 { margin: 0 0 6px; font-size: 13px; opacity: .85; }
.stat-row { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.stat-row b { color: var(--gold1); }

.off-time, .off-sim { text-align: center; margin: 6px 0; font-size: 14px; }
.off-grid { margin: 12px 0; }
.off-row { display: flex; justify-content: space-between; padding: 8px 10px; background: rgba(255,255,255,.06); border-radius: 8px; margin-bottom: 6px; font-size: 13px; }
.off-row b { color: var(--gold1); }

.qrow.current { border-left: 3px solid var(--gold1); }
.qrow.pinned { box-shadow: inset 0 0 0 1px rgba(255,211,77,.4); }
.section.locked { opacity: .45; pointer-events: none; }
.gal-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px;
  font-size: 12px; text-align: left; margin-bottom: 12px;
}
.gal-stats b { color: var(--gold1); }
.gal-note { font-size: 12px; opacity: .75; }
.gal-visit-btn {
  width: 100%; margin-top: 8px;
  pointer-events: auto; cursor: pointer;
  position: relative; z-index: 50;
}
.gal-x {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; color: #fff; font-size: 16px; cursor: pointer; opacity: .7;
}
.gal-x:hover { opacity: 1; }
