/* Kings of Space — Command Bridge UI */
@import url('https://fonts.googleapis.com/css2?family=Exo+2:wght@400;500;600;700&family=Orbitron:wght@500;600;700&display=swap');

:root {
  --bg: #060a12;
  --bg-deep: #03060c;
  --panel: rgba(8, 14, 26, 0.78);
  --panel-solid: #0c1422;
  --panel-edge: rgba(180, 140, 70, 0.35);
  --text: #e8ecf4;
  --muted: #8b95a8;
  --link: #f0c14d;
  --link-hover: #ffe08a;
  --gold: #e8b86d;
  --gold-dim: #a67c3a;
  --metal: #e0c060;
  --crystal: #5ec8ff;
  --deut: #5ed4b8;
  --energy: #f0d060;
  --ok: #6dcf7a;
  --bad: #e85a5a;
  --border: rgba(120, 140, 170, 0.28);
  --menu-w: 168px;
  --mobile-nav-h: 54px;
  --font: 'Exo 2', Tahoma, sans-serif;
  --font-display: 'Orbitron', 'Exo 2', sans-serif;
  --radius: 4px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { height: 100dvh; }

body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(60, 90, 140, 0.22), transparent 55%),
    linear-gradient(180deg, rgba(6, 10, 18, 0.55), rgba(6, 10, 18, 0.88)),
    url('/skins/kos/ui/starfield-dense.png'),
    url('/skins/kos/bg.jpg');
  background-attachment: fixed, fixed, fixed, fixed;
  background-size: cover, cover, 512px, cover;
  background-position: center, center, center, center;
}

a { color: var(--link); font-weight: 600; text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--link-hover); }

.hidden,
[hidden] { display: none !important; }

/* ——— Auth ——— */
.auth-screen {
  min-height: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  position: relative;
  overflow: hidden;
}

.auth-screen::before {
  content: '';
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 30% 40%, rgba(232, 184, 109, 0.12), transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(94, 200, 255, 0.08), transparent 45%);
  animation: auth-drift 18s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes auth-drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(-2%, 3%) scale(1.05); }
}

.auth-frame {
  position: relative;
  width: min(420px, 94vw);
  padding: 28px 26px 24px;
  border: 1px solid var(--panel-edge);
  background:
    linear-gradient(160deg, rgba(18, 28, 48, 0.92), rgba(8, 12, 22, 0.94));
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  animation: panel-in 0.55s var(--ease) both;
}

.auth-frame::before {
  content: '';
  position: absolute;
  top: 0; left: 12%; right: 12%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.85;
}

.auth-card { width: 100%; }

.auth-card__head {
  text-align: center;
  margin-bottom: 22px;
}

.auth-card__head h1 {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 4vw, 1.7rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold);
  text-shadow: 0 2px 24px rgba(232, 184, 109, 0.35);
}

.auth-card__head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.logo-ring {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 52px;
  padding: 0 12px;
  border: 1px solid var(--panel-edge);
  border-radius: 50%;
  background:
    radial-gradient(circle at 40% 30%, rgba(232, 184, 109, 0.25), transparent 60%),
    rgba(0, 0, 0, 0.45);
  color: var(--gold);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  box-shadow: inset 0 0 20px rgba(232, 184, 109, 0.12);
}

.logo-ring--sm {
  min-width: 34px;
  height: 34px;
  font-size: 0.65rem;
  padding: 0 8px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field span {
  display: block;
  margin-bottom: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
input.input-text,
select,
textarea,
.yard-amount,
.planet-switch {
  width: 100%;
  color: var(--text);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 11px;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
select:focus,
textarea:focus,
.yard-amount:focus,
.planet-switch:focus {
  outline: none;
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 2px rgba(232, 184, 109, 0.15);
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  border: 1px solid #9a7438;
  border-radius: var(--radius);
  color: #1a1208;
  font: 600 0.8rem var(--font);
  letter-spacing: 0.03em;
  padding: 9px 16px;
  background: linear-gradient(180deg, #f0d48a 0%, #d4a04a 48%, #b07828 100%);
  box-shadow: 0 2px 0 #6a4818, inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: filter 0.15s, transform 0.1s;
}

.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; filter: none; transform: none; }

.btn--primary { width: 100%; margin-top: 6px; }
.btn--ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-color: var(--border);
  box-shadow: none;
  margin-top: 10px;
  width: 100%;
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--gold-dim); color: var(--gold); }
.btn--sm { padding: 5px 10px; font-size: 0.72rem; width: auto; margin: 0; }

/* ——— Game shell ——— */
.game {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: panel-in 0.4s var(--ease) both;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  background:
    linear-gradient(180deg, rgba(14, 20, 34, 0.96), rgba(8, 12, 20, 0.92));
  border-bottom: 1px solid var(--panel-edge);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.topbar__main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
}

.topbar__head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
  flex: 1 1 auto;
}

.topbar__logout {
  width: auto;
  margin: 0;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.brand__text strong {
  display: block;
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.brand__text span {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.planet-switch {
  flex: 0 1 148px;
  max-width: 168px;
  width: auto;
  min-width: 0;
  padding: 4px 8px;
  font-size: 0.72rem;
}

.resources {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  width: 100%;
  flex: 1 1 100%;
  max-height: min(10dvh, 42px);
}

.res-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  padding: 5px 6px 7px;
  border-radius: 4px;
  border: 1px solid rgba(120, 140, 170, 0.22);
  background:
    linear-gradient(180deg, rgba(18, 26, 42, 0.92), rgba(8, 12, 20, 0.96));
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.res-chip:hover {
  border-color: var(--panel-edge);
  box-shadow: inset 0 0 0 1px rgba(232, 184, 109, 0.12);
}

.res-chip__icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.res-chip__icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.res-chip__val {
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.res-chip--metal .res-chip__val { color: var(--metal); }
.res-chip--crystal .res-chip__val { color: var(--crystal); }
.res-chip--deut .res-chip__val { color: var(--deut); }
.res-chip--energy .res-chip__val { color: var(--energy); font-size: 0.68rem; }

.storage-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  margin: 0;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 0;
  overflow: hidden;
}

.storage-bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  border-radius: 0;
  transition: width 0.6s var(--ease);
}

.res-chip--metal .storage-bar > i { background: linear-gradient(90deg, #8a7030, var(--metal)); }
.res-chip--crystal .storage-bar > i { background: linear-gradient(90deg, #2a7098, var(--crystal)); }
.res-chip--deut .storage-bar > i { background: linear-gradient(90deg, #2a8878, var(--deut)); }

.layout {
  display: grid;
  grid-template-columns: var(--menu-w) 1fr;
  gap: 12px;
  padding: 12px;
  flex: 1;
  min-height: 0;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
  height: fit-content;
  position: sticky;
  top: 76px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font: 600 0.8rem var(--font);
  letter-spacing: 0.02em;
  padding: 9px 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.nav-btn:hover {
  background: rgba(232, 184, 109, 0.08);
  color: var(--gold);
}

.nav-btn.is-active {
  color: var(--gold);
  background: linear-gradient(90deg, rgba(232, 184, 109, 0.18), rgba(232, 184, 109, 0.04));
  border-color: var(--panel-edge);
  box-shadow: inset 3px 0 0 var(--gold);
}

.nav-btn__mark {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
  flex-shrink: 0;
}

.nav-btn.is-active .nav-btn__mark { opacity: 1; box-shadow: 0 0 8px var(--gold); }

.nav-btn__text--short { display: none; }

.content { min-width: 0; }

.footer {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.55);
  color: var(--muted);
  font-size: 0.75rem;
}

.badge {
  padding: 2px 8px;
  border: 1px solid rgba(109, 207, 122, 0.4);
  border-radius: 999px;
  color: var(--ok);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.badge--live {
  animation: live-pulse 2.4s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(109, 207, 122, 0.35); }
  50% { box-shadow: 0 0 0 4px rgba(109, 207, 122, 0); }
}

/* ——— Content ——— */
.page-head {
  margin: 0 0 12px;
  padding: 14px 16px;
  text-align: left;
  background:
    linear-gradient(135deg, rgba(28, 40, 64, 0.9), rgba(12, 18, 32, 0.85));
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.page-head::after {
  content: '';
  position: absolute;
  right: -20%;
  top: -40%;
  width: 50%;
  height: 180%;
  background: radial-gradient(circle, rgba(232, 184, 109, 0.1), transparent 70%);
  pointer-events: none;
}

.page-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text);
  position: relative;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  position: relative;
}

.panel {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: panel-in 0.45s var(--ease) both;
}

.panel__title {
  margin: 0;
  padding: 10px 14px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(180deg, rgba(32, 48, 72, 0.9), rgba(16, 24, 40, 0.9));
  border-bottom: 1px solid var(--border);
  color: var(--gold);
}

.panel > :not(.panel__title) {
  padding: 12px 14px;
}

.overview-hero {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  align-items: center;
}

.overview-planet {
  width: 128px;
  height: 128px;
  margin: 0 auto;
  border-radius: 50%;
  background:
    url('/skins/kos/ui/planet-hero.jpg') center / cover,
    radial-gradient(circle at 35% 30%, #6a90c8, #1a3050 55%, #0a1528 100%);
  border: 2px solid rgba(232, 184, 109, 0.35);
  box-shadow:
    0 0 0 4px rgba(0, 0, 0, 0.35),
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 0 32px rgba(94, 200, 255, 0.15);
  animation: planet-spin 60s linear infinite;
}

.overview-planet--moon {
  background:
    url('/skins/kos/ui/moon-hero.jpg') center / cover,
    radial-gradient(circle at 40% 35%, #c8d0dc, #4a5568 60%, #1a2030 100%);
  filter: none;
  box-shadow:
    0 0 0 4px rgba(0, 0, 0, 0.35),
    0 12px 40px rgba(0, 0, 0, 0.5),
    0 0 28px rgba(180, 200, 220, 0.2);
  animation: none;
}

@keyframes planet-spin {
  from { filter: hue-rotate(0deg); }
  to { filter: hue-rotate(8deg); }
}

.overview-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0;
}

.stat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat dt { color: var(--muted); margin: 0; font-size: 0.75rem; }
.stat dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat--highlight dd { color: var(--gold); }

.queue-banner {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(40, 80, 50, 0.25);
  border: 1px solid rgba(109, 207, 122, 0.3);
  font-size: 0.85rem;
}

.queue-banner--idle {
  background: rgba(0, 0, 0, 0.25);
  border-color: var(--border);
  color: var(--muted);
}

.tech-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tech-card {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.tech-card:hover {
  border-color: var(--panel-edge);
  background: rgba(20, 30, 48, 0.55);
  transform: translateX(2px);
}

.tech-card__icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #060a12;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.tech-card__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tech-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 0.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  letter-spacing: 0;
}

.tech-reqs {
  margin: 0.35rem 0 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: #f0c878;
  background: rgba(200, 140, 40, 0.08);
  border-left: 2px solid rgba(200, 140, 40, 0.45);
  border-radius: 0 4px 4px 0;
}
.tech-reqs--warn {
  margin: 0 0 0.75rem;
  color: #ffb0b0;
  background: rgba(220, 80, 80, 0.08);
  border-left-color: rgba(220, 80, 80, 0.5);
}
.tech-reqs strong { color: #fff; font-weight: 700; }

.tech-card__name {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.level-badge {
  color: var(--muted);
  font-size: 0.75rem;
}

.tech-card__head { display: contents; }

.tech-card > .tech-card__icon {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: start;
}

.tech-card > .tech-card__title,
.tech-card > .tech-card__icon + div:not(.pills):not(.tech-reqs):not(.tech-card__foot) {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
}

.tech-card > .pills {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
}

.tech-card > .tech-reqs {
  grid-column: 1 / -1;
  grid-row: 3;
}

.tech-card__foot {
  grid-column: 3;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.pills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.pill {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}
.pill--metal { color: var(--metal); border-color: rgba(224, 192, 96, 0.35); }
.pill--crystal { color: var(--crystal); border-color: rgba(94, 200, 255, 0.35); }
.pill--deut { color: var(--deut); border-color: rgba(94, 212, 184, 0.35); }
.pill--time { color: var(--gold); border-color: rgba(232, 184, 109, 0.35); }

.galaxy-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
  transition: background 0.15s;
}

.galaxy-row:hover { background: rgba(255, 255, 255, 0.03); }
.galaxy-row.is-home { outline: 1px solid rgba(109, 207, 122, 0.45); background: rgba(40, 80, 50, 0.15); }
.galaxy-row.is-ally { outline: 1px solid rgba(94, 200, 255, 0.4); }
.galaxy-row.is-admin { outline: 1px solid rgba(212, 175, 55, 0.45); }
.galaxy-row__pos { color: var(--muted); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.galaxy-row__meta { display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: 0.75rem; }
.galaxy-row__meta .tag { color: var(--ok); }
.galaxy-row__meta .moon { color: var(--crystal); }
.galaxy-row__meta .debris { color: var(--metal); }
.galaxy-actions { display: flex; flex-wrap: wrap; gap: 4px; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-inline input { width: 64px; }

.fleet-form label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.ship-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  margin: 10px 0;
}

.panel__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.fleet-inv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.fleet-inv-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.82rem;
}

.fleet-inv-card__icon img {
  width: 28px;
  height: 28px;
  display: block;
}

.fleet-inv-card__count {
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.fleet-empire-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.fleet-empire-row {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
}

.fleet-empire-row.is-active {
  border-color: rgba(232, 184, 109, 0.4);
}

.fleet-empire-row__head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.fleet-empire-row__ships {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fleet-inv-chip {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(0, 0, 0, 0.35);
}

.ship-input {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.8rem;
}

.event-list { list-style: none; margin: 0; padding: 0; }
.event-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.msg-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 12px;
}

.msg-list { list-style: none; margin: 0; padding: 0; max-height: 62vh; overflow: auto; }
.msg-item {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.15s;
}
.msg-item:hover,
.msg-item.unread { background: rgba(232, 184, 109, 0.08); }
.msg-item.unread strong { color: var(--gold); }
.msg-preview { color: var(--muted); font-size: 0.75rem; }
.msg-body { white-space: pre-wrap; line-height: 1.45; }
.msg-detail { padding: 4px; }

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: var(--radius);
}
.table th {
  background: linear-gradient(180deg, rgba(32, 48, 72, 0.95), rgba(16, 24, 40, 0.95));
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: left;
}
.table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(0, 0, 0, 0.2);
}
.table tbody tr:hover td { background: rgba(232, 184, 109, 0.06); }

.stats-rank { color: var(--gold); font-weight: 700; width: 2.5rem; font-family: var(--font-display); }

.muted { color: var(--muted); }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  padding: 12px 18px;
  background: rgba(8, 12, 20, 0.95);
  border: 1px solid var(--panel-edge);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  max-width: 90vw;
  box-shadow: var(--shadow);
  animation: panel-in 0.3s var(--ease);
}
.toast.is-error { border-color: var(--bad); color: #ffb0b0; }

.tab-bar { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tab-btn, .mission-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  padding: 8px 12px;
  font: 600 0.75rem var(--font);
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.tab-btn:hover, .mission-btn:hover { border-color: var(--gold-dim); }
.tab-btn.is-active, .mission-btn.is-active {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(232, 184, 109, 0.12);
}
.yard-foot { display: flex; gap: 8px; align-items: center; }
.yard-amount { width: 68px; padding: 6px 8px; }
.wizard-step { display: none; }
.wizard-step.is-active { display: block; animation: panel-in 0.35s var(--ease); }
.mission-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.empire-table { font-size: 0.8rem; }
.linkish {
  background: none;
  border: none;
  color: var(--link);
  cursor: pointer;
  font-weight: 600;
  padding: 0;
  font: inherit;
}
.phalanx-out { margin-top: 0.75rem; white-space: pre-wrap; font-size: 0.75rem; }
.battle-round { color: var(--gold); margin-top: 0.5rem; font-weight: 700; }
.battle-summary { color: var(--ok); margin-top: 0.35rem; }
.battle-loss { color: #ffb0b0; }

.wizard { display: grid; gap: 0.75rem; }
.wizard-step:not(.is-active) { display: none; }
.mission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.ship-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}
.empire-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.empire-table { min-width: 720px; }
.panel:has(.table),
.panel:has(.admin-table) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.topbar { position: sticky; top: 0; z-index: 20; }
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6b7280;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.live-dot.is-on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.settings-grid { display: grid; gap: 1rem; max-width: 420px; }

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}
.admin-stat {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(12, 18, 30, 0.65);
}
.admin-stat span {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-stat strong { font-size: 1rem; color: var(--gold); }
.admin-panel { margin-bottom: 0.85rem; }
.admin-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.admin-panel__head .panel__title { margin: 0; }
.admin-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.admin-planet-line { margin: 0.25rem 0; }
.admin-form { display: grid; gap: 0.85rem; }
.admin-form__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.65rem;
}
.admin-field--wide { grid-column: 1 / -1; max-width: 420px; }
.admin-quick { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.admin-table { min-width: 520px; }
.admin-user-row { cursor: pointer; }
.admin-user-row:hover { background: rgba(212, 175, 55, 0.08); }
.admin-user-row.is-active { background: rgba(212, 175, 55, 0.16); }
.admin-profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  margin: 0.35rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.admin-profile-meta strong { color: var(--text); }
.admin-snapshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
.admin-stat-list {
  list-style: none;
  padding: 0;
  margin: 0.35rem 0 0;
  display: grid;
  gap: 0.2rem;
  max-height: 180px;
  overflow: auto;
}
.admin-stat-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.82rem;
}
.admin-stat-list strong { color: var(--gold); }
.fuel-box p { margin: 0.25rem 0; }
.fuel-box.is-ok strong { color: var(--ok); }
.fuel-box.is-bad strong { color: #ffb0b0; }

.buddy-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.buddy-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

@media (max-width: 900px) {
  body.game-open {
    overflow: hidden;
    height: 100dvh;
    position: fixed;
    width: 100%;
  }

  .game {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .topbar {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 6px 8px;
    padding-top: max(6px, env(safe-area-inset-top));
  }

  .topbar__head {
    width: 100%;
    gap: 6px;
  }

  .topbar__main { width: 100%; flex: none; }

  .brand {
    min-width: 0;
    flex: 1;
  }

  .brand__text strong {
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 38vw;
  }

  .brand__text span {
    font-size: 0.68rem;
  }

  .planet-switch {
    flex: 0 1 96px;
    max-width: 108px;
    min-height: 32px;
    padding: 3px 6px;
    font-size: 0.65rem;
  }

  .topbar__logout {
    padding: 4px 8px;
    min-height: 32px;
    font-size: 0.68rem;
  }

  .resources {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    width: 100%;
    max-height: min(10dvh, 36px);
  }

  .res-chip {
    min-width: 0;
    padding: 4px 4px 6px;
    gap: 3px;
  }

  .res-chip__icon {
    width: 14px;
    height: 14px;
  }

  .res-chip__val { font-size: 0.66rem; }
  .res-chip--energy .res-chip__val { font-size: 0.6rem; }

  .storage-bar { height: 2px; }

  .layout {
    grid-template-columns: 1fr;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 8px;
    padding-bottom: calc(8px + var(--mobile-nav-h) + env(safe-area-inset-bottom));
    gap: 0;
    max-width: none;
  }

  .content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 30;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    margin: 0;
    height: auto;
    min-height: var(--mobile-nav-h);
    border-radius: 12px 12px 0 0;
    border: none;
    border-top: 1px solid var(--panel-edge);
    background: rgba(6, 10, 18, 0.97);
    backdrop-filter: blur(12px);
    box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.5);
  }

  .sidebar::-webkit-scrollbar { display: none; }

  .nav-btn {
    width: auto;
    min-height: 44px;
    min-width: 52px;
    white-space: nowrap;
    flex: 0 0 auto;
    font-size: 0.7rem;
    padding: 6px 10px;
    justify-content: center;
    text-align: center;
    flex-direction: column;
    gap: 2px;
  }

  .nav-btn__mark { display: none; }

  .nav-btn__text--full { display: none; }
  .nav-btn__text--short { display: inline; }

  .nav-btn.is-active {
    box-shadow: inset 0 -2px 0 var(--gold);
    background: linear-gradient(180deg, rgba(232, 184, 109, 0.16), rgba(232, 184, 109, 0.04));
  }

  .footer {
    display: none;
  }

  .page-head {
    padding: 12px;
    margin-bottom: 10px;
  }

  .page-head h2 { font-size: 0.95rem; }

  .panel > :not(.panel__title) {
    padding: 10px 12px;
  }

  .panel__title {
    padding: 8px 12px;
    font-size: 0.7rem;
  }

  .msg-layout { grid-template-columns: 1fr; }
  .msg-list { max-height: 38vh; }

  .overview-hero {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 12px;
  }

  .overview-planet {
    width: 96px;
    height: 96px;
  }

  .overview-stats { width: 100%; }

  .tech-card { grid-template-columns: 48px 1fr; gap: 8px; }

  .tech-card > .tech-card__icon { grid-row: 1; width: 48px; height: 48px; }

  .tech-card > .tech-card__title,
  .tech-card > .tech-card__icon + div:not(.pills):not(.tech-reqs):not(.tech-card__foot) {
    grid-column: 2;
    grid-row: 1;
  }

  .tech-card > .pills {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .tech-card > .tech-reqs { grid-row: 3; }

  .tech-card__foot {
    grid-column: 1 / -1;
    grid-row: auto;
    align-items: stretch;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .tech-card__foot .btn { flex: 1 1 auto; min-width: 120px; }

  .fleet-form .inline-form,
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .field-inline {
    width: 100%;
    justify-content: space-between;
  }

  .field-inline input { flex: 1; max-width: none; width: auto; }

  .fleet-form input,
  .fleet-form select,
  .fleet-form textarea {
    min-width: 0;
    width: 100%;
  }

  .fleet-form label { margin-bottom: 10px; }

  .galaxy-row {
    grid-template-columns: 32px 1fr;
    gap: 6px;
    padding: 10px 8px;
  }

  .galaxy-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .galaxy-actions .btn {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }

  .galaxy-row__meta { font-size: 0.72rem; }

  .tab-bar { gap: 4px; }
  .tab-btn, .mission-btn {
    flex: 1 1 auto;
    min-height: 40px;
    text-align: center;
  }

  .mission-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ship-grid {
    grid-template-columns: 1fr;
  }

  .ship-input { padding: 10px; }

  .btn {
    min-height: 44px;
    padding: 10px 14px;
  }

  .btn--sm {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 0.78rem;
  }

  input,
  select,
  textarea {
    font-size: 16px;
    min-height: 44px;
  }

  textarea { min-height: 96px; }

  .admin-form__grid {
    grid-template-columns: 1fr;
  }

  .admin-field--wide { max-width: none; }

  .admin-snapshot-grid {
    grid-template-columns: 1fr;
  }

  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-grid { max-width: none; }

  .buddy-list li {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .buddy-list .btn { width: 100%; }

  .toast {
    bottom: calc(var(--mobile-nav-h) + 12px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 24px);
  }

  .auth-card {
    width: 100%;
    max-width: 420px;
    padding: 20px 16px;
  }

  .auth-card .btn { min-height: 48px; }
}

@media (max-width: 480px) {
  .resources {
    max-height: min(10dvh, 34px);
  }

  .res-chip__val { font-size: 0.62rem; }
  .res-chip--energy .res-chip__val { font-size: 0.56rem; }

  .admin-stats {
    grid-template-columns: 1fr;
  }

  .galaxy-actions .btn {
    flex: 1 1 100%;
  }

  .mission-grid {
    grid-template-columns: 1fr;
  }

  .nav-btn {
    min-width: 48px;
    font-size: 0.65rem;
    padding: 6px 8px;
  }
}

.uni-banner {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.45;
}
.uni-banner p { margin: 0.25rem 0; }
.uni-banner--freeze {
  background: rgba(127, 29, 29, 0.35);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: #fecaca;
}
.uni-banner--news {
  background: rgba(30, 58, 95, 0.45);
  border: 1px solid rgba(94, 200, 255, 0.35);
  color: #dbeafe;
}
.auth-news {
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
  color: var(--muted);
  text-align: left;
}
.auth-news p { margin: 0.35rem 0; }
.auth-news__freeze { color: #fca5a5; }
.report-title { font-weight: 700; margin: 0.5rem 0; color: #e2e8f0; }
.battle-line { font-family: ui-monospace, monospace; font-size: 0.85rem; color: #cbd5e1; padding-left: 0.25rem; }
.msg-body .battle-summary { color: #93c5fd; margin: 0.35rem 0; }
.msg-body .battle-loss { color: #fca5a5; }
