* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #0d0f14;
  color: #dde3ee;
}

/* ---------- auth ---------- */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: #161a23; border: 1px solid #2a3040; border-radius: 14px;
  padding: 28px;
}
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .sub { color: #8892a8; margin-bottom: 18px; font-size: 14px; }
.auth-card label { display: block; margin-bottom: 12px; font-size: 13px; color: #a8b2c8; }
.auth-card input[type="text"], .auth-card input[type="password"],
.auth-card input:not([type]) {
  width: 100%; margin-top: 4px; padding: 10px 12px;
  background: #0d0f14; border: 1px solid #2a3040; border-radius: 8px;
  color: #dde3ee; font-size: 15px;
}
.auth-card button {
  width: 100%; padding: 11px; margin-top: 6px;
  background: #3552c4; border: none; border-radius: 8px;
  color: #fff; font-size: 15px; cursor: pointer;
}
.auth-card button:hover { background: #3f60e0; }
.error {
  background: #4a1a1f; border: 1px solid #7a2a33; color: #ff9aa5;
  padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px;
}
.switch { margin-top: 16px; font-size: 13px; color: #8892a8; }
.switch a { color: #7da4ff; }
.factions { margin-bottom: 14px; }
.faction-opt {
  display: block; padding: 10px 12px; margin-top: 6px; cursor: pointer;
  background: #0d0f14; border: 1px solid #2a3040; border-radius: 8px;
}
.faction-opt:has(input:checked) { border-color: var(--fc); box-shadow: 0 0 0 1px var(--fc); }
.faction-opt input { margin-right: 8px; }
.faction-name { font-weight: 600; color: var(--fc); }
.faction-desc { display: block; font-size: 12px; color: #8892a8; margin-top: 3px; }

/* ---------- game ---------- */
.game-body { overflow: hidden; height: 100vh; display: flex; flex-direction: column; }
#topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 8px 14px; background: #12151d; border-bottom: 1px solid #2a3040;
  font-size: 14px; z-index: 5;
}
#game-title { font-weight: 700; color: #8892a8; }
#resbar { display: flex; gap: 14px; }
.res-item { display: flex; align-items: center; gap: 5px; }
.res-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
#me-info { margin-left: auto; color: #8892a8; }
#me-info .fac { font-weight: 600; }
#logout { color: #667; font-size: 13px; text-decoration: none; }
#logout:hover { color: #99a; }

#game { flex: 1; display: block; cursor: crosshair; }

#bottombar {
  display: flex; gap: 16px; align-items: center;
  padding: 8px 14px; min-height: 64px;
  background: #12151d; border-top: 1px solid #2a3040; font-size: 13px;
}
#sel-panel { color: #a8b2c8; min-width: 220px; flex: 1 1 0; }
/* прижата вправо: меняющийся текст слева (таймер найма) не сдвигает кнопки */
#action-panel { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; justify-content: flex-end; }
.act-btn {
  padding: 8px 12px; background: #1c2230; border: 1px solid #2f3850;
  border-radius: 8px; color: #dde3ee; cursor: pointer; font-size: 13px;
}
.act-btn:hover { background: #26304a; }
.act-btn .cost { display: block; font-size: 11px; color: #8892a8; }
.act-btn.active { border-color: #7da4ff; background: #26304a; }
.act-btn.disabled { opacity: 0.45; }
.act-btn.locked { opacity: 0.5; cursor: not-allowed; }
.act-btn.locked:hover { background: #1c2230; }
.act-btn.done { opacity: 0.65; color: #5fdd6f; cursor: default; }
.act-btn .lock { display: block; font-size: 11px; color: #d9a05f; }
.act-btn .lock:empty { display: none; }

/* ---------- diplomacy ---------- */
.hidden { display: none !important; }
#diplo-btn {
  background: #1c2230; border: 1px solid #2f3850; border-radius: 8px;
  color: #dde3ee; cursor: pointer; padding: 5px 10px; font-size: 13px; position: relative;
}
#diplo-btn:hover { background: #26304a; }
#diplo-badge:not(:empty) {
  background: #e05050; color: #fff; border-radius: 8px;
  font-size: 11px; padding: 0 5px; margin-left: 6px;
}
#diplo-panel {
  position: fixed; top: 52px; right: 12px; width: 320px; max-height: 70vh;
  overflow-y: auto; z-index: 8;
  background: #12151d; border: 1px solid #2a3040; border-radius: 12px; padding: 12px;
  font-size: 13px;
}
.diplo-head { font-weight: 700; margin-bottom: 10px; display: flex; }
#diplo-close { margin-left: auto; cursor: pointer; color: #667; }
#diplo-close:hover { color: #dde3ee; }
.diplo-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid #1e2432;
}
.diplo-dot { width: 8px; height: 8px; border-radius: 50%; background: #445; }
.diplo-dot.on { background: #5fdd6f; }
.diplo-name { font-weight: 600; }
.diplo-status { color: #8892a8; font-size: 12px; }
.diplo-row .act-btn { padding: 4px 8px; font-size: 12px; }
.diplo-empty { color: #667; padding: 12px 0; }
.diplo-exchange { margin-top: 12px; }
.dx-title { font-weight: 600; margin-bottom: 8px; }
.diplo-exchange select, .diplo-exchange input {
  background: #0d0f14; border: 1px solid #2a3040; border-radius: 8px;
  color: #dde3ee; padding: 6px 8px; font-size: 13px; margin-bottom: 6px;
}
#dx-inputs { display: flex; gap: 8px; flex-wrap: wrap; }
#dx-inputs label { font-size: 12px; color: #8892a8; }
#dx-inputs input { width: 90px; display: block; }
#dx-send {
  background: #3552c4; border: none; border-radius: 8px; color: #fff;
  padding: 7px 12px; font-size: 13px; cursor: pointer; margin-top: 4px;
}
#dx-send:hover { background: #3f60e0; }

/* ---------- metaprogression ---------- */
#meta-btn {
  background: #1c2230; border: 1px solid #2f3850; border-radius: 8px;
  color: #dde3ee; cursor: pointer; padding: 5px 10px; font-size: 13px;
}
#meta-btn:hover { background: #26304a; }
#meta-points-badge:not(:empty) {
  background: #3a3320; color: #ffd75f; border-radius: 8px;
  font-size: 11px; padding: 0 6px; margin-left: 6px;
}
#meta-panel {
  position: fixed; top: 52px; left: 50%; transform: translateX(-50%);
  width: 440px; max-width: 94vw; max-height: 80vh; overflow-y: auto; z-index: 30;
  background: #12151d; border: 1px solid #2a3040; border-radius: 12px; padding: 14px;
  font-size: 13px;
}
#meta-close { margin-left: auto; cursor: pointer; color: #667; }
#meta-close:hover { color: #dde3ee; }
#meta-balance { font-size: 20px; font-weight: 700; color: #ffd75f; margin-bottom: 4px; }
.meta-hint { color: #8892a8; font-size: 12px; margin-bottom: 10px; }
.meta-sec {
  font-weight: 700; margin: 12px 0 6px; padding-top: 10px;
  border-top: 1px solid #1e2432; display: flex; align-items: center; gap: 10px;
}
.meta-sec select {
  background: #0d0f14; border: 1px solid #2a3040; border-radius: 8px;
  color: #dde3ee; padding: 4px 8px; font-size: 12px; font-weight: 400;
}
.meta-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid #1e2432;
}
.meta-row .m-icon { font-size: 20px; width: 28px; text-align: center; }
.meta-row .m-body { flex: 1; min-width: 0; }
.meta-row .m-name { font-weight: 600; }
.meta-row .m-desc { color: #8892a8; font-size: 12px; }
.meta-row .m-pips { color: #ffd75f; font-size: 11px; letter-spacing: 2px; }
.meta-row .act-btn { padding: 5px 10px; font-size: 12px; white-space: nowrap; }
.meta-row .m-owned { color: #5fdd6f; font-size: 12px; white-space: nowrap; }
.meta-foot {
  margin-top: 12px; padding-top: 10px; border-top: 1px solid #1e2432;
  display: flex; align-items: center; gap: 10px;
}
#meta-reset-btn {
  background: #4a1a1f; border: 1px solid #7a2a33; border-radius: 8px;
  color: #ffb4bd; padding: 7px 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
#meta-reset-btn:hover { background: #5c2027; }
#defeat-meta { margin-bottom: 14px; font-size: 14px; color: #ffd75f; }
.defeat-faction {
  margin-bottom: 18px; font-size: 13px; color: #8892a8;
  display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.defeat-faction select {
  background: #0d0f14; border: 1px solid #2a3040; border-radius: 8px;
  color: #dde3ee; padding: 6px 8px; font-size: 13px;
}
#defeat-meta-btn {
  background: #1c2230; border: 1px solid #2f3850; border-radius: 8px;
  color: #ffd75f; padding: 6px 10px; font-size: 12px; cursor: pointer;
}
#defeat-meta-btn:hover { background: #26304a; }

/* ---------- defeat ---------- */
#defeat-overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(8, 9, 13, 0.88);
  display: flex; align-items: center; justify-content: center;
}
.defeat-card {
  background: #161a23; border: 1px solid #4a2a30; border-radius: 16px;
  padding: 36px 48px; text-align: center; max-width: 420px;
}
.defeat-card h1 { color: #ff6b7a; letter-spacing: 4px; margin-bottom: 10px; }
.defeat-card p { color: #8892a8; margin-bottom: 18px; }
#defeat-score { margin-bottom: 22px; font-size: 14px; }
#defeat-score .total { font-size: 26px; font-weight: 700; color: #ffd75f; display: block; margin-top: 8px; }
#respawn-btn {
  background: #3552c4; border: none; border-radius: 10px; color: #fff;
  padding: 12px 26px; font-size: 16px; cursor: pointer;
}
#respawn-btn:hover { background: #3f60e0; }

/* ---------- admin ---------- */
.admin-body { overflow-y: auto; }
.admin-wrap { max-width: 980px; margin: 0 auto; padding: 24px 16px 60px; }
.admin-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 6px; }
.admin-head h1 { font-size: 22px; }
.admin-head a { color: #7da4ff; font-size: 14px; margin-left: auto; }
.admin-user { color: #8892a8; font-size: 14px; }
.admin-note { color: #8892a8; font-size: 13px; margin-bottom: 16px; }
.admin-section {
  background: #12151d; border: 1px solid #2a3040; border-radius: 12px;
  padding: 16px; margin-bottom: 20px;
}
.admin-section h2 { font-size: 16px; margin-bottom: 10px; }
.admin-section .hint { font-size: 12px; color: #8892a8; font-weight: 400; }
.admin-section table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
.admin-section th, .admin-section td {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid #1e2432;
}
.admin-section th { color: #8892a8; font-weight: 500; }
.admin-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-form.col { flex-direction: column; align-items: stretch; }
.admin-form.col > div { display: flex; gap: 8px; }
.admin-form input, .admin-form select, .admin-form textarea {
  background: #0d0f14; border: 1px solid #2a3040; border-radius: 8px;
  color: #dde3ee; padding: 8px 10px; font-size: 13px;
}
.admin-form input.wide { flex: 1; min-width: 200px; }
.admin-form textarea { font-family: ui-monospace, monospace; resize: vertical; }
.admin-form button {
  background: #3552c4; border: none; border-radius: 8px; color: #fff;
  padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.admin-form button:hover { background: #3f60e0; }
.del-btn {
  background: none; border: 1px solid #4a2a30; border-radius: 6px;
  color: #c07080; cursor: pointer; padding: 2px 8px;
}
.del-btn:hover { background: #2a1518; }
#admin-msg { min-height: 20px; font-size: 13px; margin-bottom: 8px; }
#admin-msg.ok { color: #7dda8a; }
#admin-msg.err { color: #ff9aa5; }
.admin-section h3 { font-size: 14px; margin: 20px 0 8px; color: #aab4c8; }
.fac-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.fac-tab {
  background: #10141d; border: 1px solid #2a3245; border-radius: 8px;
  color: #dde3ee; padding: 8px 14px; font-size: 14px; cursor: pointer;
}
.fac-tab:hover { background: #1a2130; }
.fac-tab.active { background: #212b44; outline: 2px solid #4f6fe8; }
.fac-tab.new { border-style: dashed; color: #8fa4d8; }
.fac-tab code { color: #8892a8; font-size: 11px; }
.admin-form label.lbl {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #8892a8;
}
.admin-form label.lbl input { width: 90px; }
.admin-form button.danger { background: #7a2530; }
.admin-form button.danger:hover { background: #93303d; }
#f-spawn-box { margin: 10px 0 4px; font-size: 13px; color: #8892a8; }
#f-spawn-box summary { cursor: pointer; }
#f-spawn-box textarea {
  width: 100%; margin-top: 8px; background: #0d0f14; border: 1px solid #2a3040;
  border-radius: 8px; color: #dde3ee; padding: 8px 10px; font-size: 13px;
  font-family: ui-monospace, monospace; resize: vertical;
}
#admin-link { color: #ffd75f; font-size: 13px; text-decoration: none; margin-right: 10px; }

#toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: #4a1a1f; border: 1px solid #7a2a33; color: #ffb4bd;
  padding: 8px 16px; border-radius: 8px; font-size: 13px;
  opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 10;
}
#toast.show { opacity: 1; }
