/* ── Reset & Variables ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #050914;
  --bg-card:      rgba(8, 20, 55, 0.85);
  --bg-card-alt:  rgba(5, 14, 40, 0.9);
  --bg-input:     rgba(10, 25, 70, 0.8);
  --border:       rgba(40, 100, 220, 0.25);
  --border-bright:rgba(60, 150, 255, 0.5);
  --text:         #c8d8f0;
  --text-dim:     #5a7aa0;
  --text-bright:  #e8f2ff;
  --accent:       #4a9eff;
  --accent-hover: #6cb2ff;
  --accent2:      #00d4aa;
  --danger:       #ff4466;
  --danger-hover: #ff6680;
  --success:      #00cc88;
  --warning:      #ffaa22;
  --metal:        #b8c8e0;
  --crystal:      #7ac8ff;
  --deuterium:    #66ffcc;
  --energy:       #ffd166;
  --radius:       6px;
  --shadow:       0 4px 24px rgba(0, 20, 80, 0.6);
  --topbar-h:     58px;
  --nav-h:        44px;
}

html { font-size: 14px; }

/* ── Registration-locked modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
  animation: fadeIn .2s ease;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  box-shadow: 0 0 40px rgba(255, 68, 102, 0.35), var(--shadow);
  padding: 2.5rem 2rem;
  max-width: 360px;
  width: 90%;
  text-align: center;
  animation: slideUp .25s ease;
}
.modal-icon {
  font-size: 3rem;
  margin-bottom: .75rem;
  line-height: 1;
}
.modal-box h2 {
  color: var(--danger);
  margin: 0 0 .75rem;
  font-size: 1.3rem;
  letter-spacing: .05em;
}
.modal-box p {
  color: var(--text);
  line-height: 1.6;
  margin: 0 0 1.5rem;
}
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(10, 30, 90, 0.4) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(5, 20, 60, 0.5) 0%, transparent 50%);
}

/* Subtle starfield via box-shadow would be too heavy; use a dot pattern */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.15) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.10) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 25%, rgba(255,255,255,0.12) 0%, transparent 100%),
    radial-gradient(1px 1px at 75% 70%, rgba(255,255,255,0.08) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 40%, rgba(255,255,255,0.10) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 15% 85%, rgba(255,255,255,0.12) 0%, transparent 100%),
    radial-gradient(1px 1px at 45% 90%, rgba(255,255,255,0.08) 0%, transparent 100%),
    radial-gradient(1px 1px at 65% 5%, rgba(255,255,255,0.12) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Auth Screen ────────────────────────────────────────────────────────────── */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

.auth-box {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow), 0 0 60px rgba(74, 158, 255, 0.1);
}

.auth-box h1 {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
  letter-spacing: 2px;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 1.75rem;
  font-size: 0.85rem;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 0.6rem;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.auth-tab:hover:not(.active) { color: var(--text); }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
  transition: border-color 0.2s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.15);
}

textarea { resize: vertical; min-height: 80px; }

select option { background: #0a1840; }

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  min-height: 1.2em;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #001a0e;
}
.btn-success:hover:not(:disabled) { filter: brightness(1.15); }

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-ghost {
  background: transparent;
  border-color: var(--border-bright);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* ── Topbar ─────────────────────────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(5, 10, 30, 0.96);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
  z-index: 100;
  backdrop-filter: blur(8px);
}

#planet-selector select {
  width: auto;
  min-width: 180px;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  background: var(--bg-input);
  border-color: var(--border-bright);
}

#resources-bar {
  display: flex;
  gap: 1.25rem;
  flex: 1;
  justify-content: center;
}

.res-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.res-icon { font-size: 1.05rem; }

.res-label {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.res-value { font-weight: 600; }
.res-rate  { color: var(--text-dim); font-size: 0.78rem; }

.res-metal     .res-value { color: var(--metal); }
.res-crystal   .res-value { color: var(--crystal); }
.res-deuterium .res-value { color: var(--deuterium); }
.res-energy    .res-value { color: var(--energy); }

.res-cap-warn .res-value { color: var(--warning); }
.res-energy-low .res-value,
.res-energy-low .res-rate { color: var(--danger); }

#player-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

#player-name { color: var(--accent2); font-weight: 600; }

/* ── Navigation ─────────────────────────────────────────────────────────────── */
#main-nav {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(5, 12, 35, 0.97);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  padding: 0 0.5rem;
  z-index: 99;
  overflow-x: auto;
  scrollbar-width: none;
}
#main-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-dim);
  padding: 0 1rem;
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-btn:hover { color: var(--text); }

.nav-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.msg-badge {
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  padding: 0.05rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ── Content Area ───────────────────────────────────────────────────────────── */
#content {
  margin-top: calc(var(--topbar-h) + var(--nav-h));
  padding: 1.25rem;
  min-height: calc(100vh - var(--topbar-h) - var(--nav-h));
  position: relative;
  z-index: 1;
  max-width: var(--content-max-width, 1200px);
  margin-left: auto;
  margin-right: auto;
}

.tab-pane { animation: fadeIn 0.2s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.card-header .card-title { margin: 0; padding: 0; border: none; }

/* ── Grid Layouts ───────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem; }

/* ── Building / Ship Cards ──────────────────────────────────────────────────── */
.item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.2s;
}

.item-card:hover { border-color: var(--border-bright); }

.item-card.in-queue { border-color: var(--accent); background: rgba(74, 158, 255, 0.06); }
.item-card.insufficient { opacity: 0.6; }
.item-card.energy-risk {
  border-color: var(--warning);
  box-shadow: 0 0 0 1px rgba(255, 170, 34, 0.35);
}
.item-card.energy-risk:hover { border-color: var(--warning); }

.energy-risk-hint {
  color: var(--warning);
  background: rgba(255, 170, 34, 0.12);
  border: 1px solid rgba(255, 170, 34, 0.35);
  border-radius: 4px;
  padding: 0.3rem 0.45rem;
}

.item-icon { font-size: 1.6rem; line-height: 1; }
.item-name { font-weight: 600; font-size: 0.95rem; color: var(--text-bright); }
.item-level { color: var(--text-dim); font-size: 0.82rem; }

.item-cost {
  display: flex;
  gap: 0.6rem;
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.cost-metal    { color: var(--metal); }
.cost-crystal  { color: var(--crystal); }
.cost-deuterium{ color: var(--deuterium); }
.cost-missing  { opacity: 0.5; text-decoration: line-through; }

.item-time { color: var(--text-dim); font-size: 0.8rem; }

.ov-trend {
  display: inline-block;
  width: 1rem;
  text-align: center;
  font-weight: 700;
  margin-right: 0.2rem;
}

.ov-trend-good { color: var(--success); }
.ov-trend-warn { color: var(--warning); }
.ov-trend-bad { color: var(--danger); }
.ov-trend-neutral { color: var(--text-dim); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  background: var(--bg-card-alt);
}

tbody tr:hover { background: rgba(74, 158, 255, 0.04); }

td.right, th.right { text-align: right; }
td.center, th.center { text-align: center; }

/* ── Progress / Timer ───────────────────────────────────────────────────────── */
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px;
  transition: width 1s linear;
}

.timer {
  font-family: 'Courier New', monospace;
  color: var(--accent2);
  font-size: 0.85rem;
  font-weight: 600;
}

.queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  gap: 1rem;
}

.queue-item:last-child { border: none; }

/* ── Overview ───────────────────────────────────────────────────────────────── */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.planet-coords {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 1px;
}

.planet-info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.planet-info-row:last-child { border: none; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-home    { background: rgba(0, 212, 170, 0.15); color: var(--accent2); border: 1px solid rgba(0,212,170,0.3); }
.badge-info    { background: rgba(74, 158, 255, 0.15); color: var(--accent);  border: 1px solid rgba(74,158,255,0.3); }
.badge-warn    { background: rgba(255, 170, 34, 0.15); color: var(--warning); border: 1px solid rgba(255,170,34,0.3); }
.badge-danger  { background: rgba(255, 68, 102, 0.15); color: var(--danger);  border: 1px solid rgba(255,68,102,0.3); }
.badge-success { background: rgba(0, 212, 100, 0.15);  color: var(--success); border: 1px solid rgba(0,212,100,0.3); }

/* ── Ship cost preview ─────────────────────────────────────────────────────── */
.cost-preview {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
}
.cost-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}
.cost-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.15rem 0;
}
.cost-label  { width: 7rem; color: var(--text-muted); }
.cost-need   { font-weight: 600; min-width: 5.5rem; text-align: right; }
.cost-have   { font-size: 0.78rem; }
.cost-ok     { color: var(--success); }
.cost-nok    { color: var(--danger); }

/* ── Fleet mission types ───────────────────────────────────────────────────── */
.mission-attack    { color: var(--danger); }
.mission-transport { color: var(--accent2); }
.mission-colonize  { color: var(--success); }
.mission-spy       { color: var(--warning); }
.mission-recycle   { color: var(--metal); }
.mission-defend    { color: var(--accent); }

/* ── Messages ───────────────────────────────────────────────────────────────── */
.msg-row {
  display: flex;
  gap: 1rem;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s;
  align-items: center;
}


/* ── Tickets ────────────────────────────────────────────────────────────────── */
.ticket-type-row {
  display: flex;
  gap: 0.75rem;
}

.ticket-type-option {
  cursor: pointer;
}

.ticket-type-option input[type="radio"] {
  display: none;
}

.ticket-type-btn {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ticket-type-btn:hover {
  background: rgba(74, 158, 255, 0.08);
  border-color: var(--accent);
}

.ticket-type-btn.active {
  background: rgba(74, 158, 255, 0.15);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ── Changelog ──────────────────────────────────────────────────────────────── */
.changelog-release { margin-bottom: 1.2rem; }
.changelog-release:last-child { margin-bottom: 0; }
.changelog-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}
.changelog-list {
  list-style: disc;
  padding-left: 1.6rem;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.6;
}
.changelog-list li { margin-bottom: 0.15rem; }

/* ── Future Levels Preview ──────────────────────────────────────────────────── */
.future-levels { margin-top: 0.3rem; }
.future-levels summary { cursor: pointer; user-select: none; }
.future-levels summary:hover { color: var(--accent); }
.future-levels-list { margin-top: 0.3rem; }
.future-level-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.78rem;
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--border);
}
.future-level-row:last-child { border-bottom: none; }
.future-lvl { font-weight: 600; min-width: 4.5rem; }

/* ── Online Status Dot ──────────────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 4px var(--success); }
.status-dot.idle   { background: var(--warning); box-shadow: 0 0 4px var(--warning); }
.status-dot.offline { background: #556; }

/* ── Highscore ──────────────────────────────────────────────────────────────── */
.hs-my-rank {
  padding: 0.5rem 0.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.hs-my-rank strong { color: var(--text); }

.hs-table { width: 100%; }
.hs-col-rank { width: 3.5rem; text-align: center; }

.hs-row-me  { background: rgba(74, 158, 255, 0.07); }
.hs-name    { font-weight: 500; }
.hs-name-me { color: var(--accent); }
.hs-you-badge { margin-left: 0.35rem; vertical-align: middle; }

.hs-points { font-weight: 600; color: var(--accent2); }

/* ── Hilfe ─────────────────────────────────────────────────────────────────── */
.help-lead {
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.help-toc-card {
  background: linear-gradient(180deg, rgba(74, 158, 255, 0.08), rgba(255, 255, 255, 0.02));
}

.help-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.help-section {
  scroll-margin-top: 1rem;
}

.help-flow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
}

.help-flow-step {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.help-list {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.45rem;
}

.help-note {
  margin-top: 0.6rem;
  color: var(--accent2);
  font-size: 0.86rem;
}

.help-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.55rem;
}

.help-kpi {
  background: rgba(74, 158, 255, 0.06);
  border: 1px solid rgba(74, 158, 255, 0.2);
  border-radius: var(--radius);
  padding: 0.55rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.help-kpi span {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.help-kpi strong {
  color: var(--text);
  font-size: 0.95rem;
}

.help-mini-title {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.help-text {
  margin: 0.2rem 0;
  line-height: 1.5;
}

.msg-row:hover { background: rgba(74, 158, 255, 0.06); }
.msg-row.unread { background: rgba(74, 158, 255, 0.05); }
.msg-row.unread .msg-subject { color: var(--text-bright); font-weight: 600; }

.msg-type-icon { font-size: 1.2rem; min-width: 1.5rem; }
.msg-subject   { flex: 1; font-size: 0.9rem; }
.msg-from      { color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; }
.msg-date      { color: var(--text-dim); font-size: 0.78rem; white-space: nowrap; }

.msg-detail { padding: 0.5rem 0; line-height: 1.6; }
.msg-detail pre {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.82rem;
  color: var(--text);
  font-family: inherit;
}

/* ── Galaxy view ────────────────────────────────────────────────────────────── */
.galaxy-pos   { color: var(--text-dim); font-size: 0.85rem; }
.galaxy-empty { color: var(--text-dim); font-style: italic; }
.galaxy-own   { color: var(--accent2); }

/* ── Toast notifications ────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  z-index: 1000;
  max-width: 360px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.25s ease;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.toast-success { border-color: rgba(0, 204, 136, 0.5); }
.toast-danger  { border-color: rgba(255, 68, 102, 0.5); }
.toast-warning { border-color: rgba(255, 170, 34, 0.5); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: none; }
}

/* ── Utilities ──────────────────────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1        { gap: 0.5rem; }
.gap-2        { gap: 1rem; }
.mt-1         { margin-top: 0.5rem; }
.mt-2         { margin-top: 1rem; }
.mb-1         { margin-bottom: 0.5rem; }
.mb-2         { margin-bottom: 1rem; }
.dim          { color: var(--text-dim); font-style: italic; }
.bold         { font-weight: 700; }
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warn    { color: var(--warning); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-sm      { font-size: 0.82rem; }
.hidden       { display: none !important; }

.separator {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
}

.loading::after { content: '...'; animation: dots 1.2s steps(3, end) infinite; }
@keyframes dots { 0%,20%{content:'.'} 40%{content:'..'} 60%,100%{content:'...'} }

/* ── Admin Panel ────────────────────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 220px;
  min-width: 220px;
  background: rgba(5, 12, 35, 0.98);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  position: fixed;
  top: 0;
  bottom: 0;
  overflow-y: auto;
}

.admin-sidebar .logo {
  padding: 0 1.25rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.admin-nav-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0.65rem 1.25rem;
  cursor: pointer;
  font-size: 0.9rem;
  text-align: left;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.admin-nav-item:hover { color: var(--text); background: rgba(74,158,255,0.05); }
.admin-nav-item.active { color: var(--accent); border-left-color: var(--accent); background: rgba(74,158,255,0.08); }

.admin-content {
  margin-left: 220px;
  padding: 1.5rem;
  flex: 1;
}

.admin-mobile-bar {
  display: none;
}

.admin-hamburger {
  font-size: 1.3rem;
  padding: 0.3rem 0.65rem;
  line-height: 1;
}

.admin-mobile-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}

.admin-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 149;
  backdrop-filter: blur(2px);
  animation: fadeIn .18s ease;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-header h2 { font-size: 1.2rem; color: var(--text-bright); }

.admin-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-action-row .btn {
  flex: 0 1 auto;
  max-width: 100%;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stat-label {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 0.35rem;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --topbar-h: 146px; }
  #topbar {
    height: var(--topbar-h);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'planet player'
      'resources resources';
    align-items: start;
    gap: 0.45rem 0.7rem;
    padding: 0.45rem 0.75rem;
  }
  #planet-selector {
    grid-area: planet;
    min-width: 0;
  }
  #planet-selector select {
    width: 100%;
    min-width: 0;
  }
  #player-menu {
    grid-area: player;
    margin-left: 0;
    justify-self: end;
    white-space: nowrap;
  }
  #resources-bar {
    grid-area: resources;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem 0.55rem;
    align-items: center;
    justify-content: stretch;
    flex: 0 0 auto;
  }
  .res-label, .res-rate { display: none; }
  .res-item {
    font-size: 0.82rem;
    min-width: 0;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.2rem 0.4rem;
  }
  #content { padding: 0.75rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  /* Sidebar hidden by default on mobile — slides in as overlay */
  .admin-sidebar {
    display: block;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-content { margin-left: 0; padding: 0.75rem; }
  .admin-mobile-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: rgba(5, 12, 35, 0.97);
    position: sticky;
    top: 0;
    z-index: 10;
    margin: -0.75rem -0.75rem 1rem;
  }
}

@media (max-width: 480px) {
  :root { --topbar-h: 170px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  #topbar {
    gap: 0.35rem 0.55rem;
    padding: 0.4rem 0.6rem;
  }
  #resources-bar { gap: 0.3rem 0.45rem; }
  .res-item { font-size: 0.8rem; }
}

/* ── Tech Tree ──────────────────────────────────────────────────────────────── */
.tt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.tt-item {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  transition: border-color 0.2s;
}

.tt-item:hover { border-color: var(--border-bright); }

.tt-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.tt-item-name {
  font-weight: 600;
  color: var(--text-bright);
  font-size: 0.9rem;
}

.tt-toggle { font-size: 0.75rem; min-width: 28px; }

.tt-stats {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
}

.tt-details {
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.tt-req, .tt-unlocks { margin-bottom: 0.4rem; }

.tt-req-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.tt-req-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 0.15rem 0;
}

.tt-req-item-ok { color: var(--success); }
.tt-req-item-nok { color: var(--danger); }

.tt-req-arrow { color: var(--accent); font-weight: bold; }
.tt-req-level { color: var(--warning); font-weight: 600; margin-left: auto; font-size: 0.78rem; }
.tt-req-state { font-size: 0.76rem; margin-left: 0.35rem; }
