:root {
  --font-ui: Verdana, Arial, sans-serif;

  --bg: #0b0f14;
  --bg-soft: #10161d;

  --surface: #151b23;
  --surface-soft: #1b232d;
  --surface-muted: #232c38;

  --text: #f3f5f8;
  --text-soft: #a7b0bd;
  --text-muted: #8fa1ba;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-bright: rgba(243, 245, 248, 0.88);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --header-height: 64px;
  --sidebar-width: 178px;

  --transition: 180ms ease;

  --accent: #ffffff;
  --accent-soft: #c7ced9;

  --danger: #b85a67;
  --danger-strong: #903748;
  --danger-bg: rgba(56, 18, 18, 0.82);
  --danger-bg-hover: rgba(82, 24, 24, 0.88);
  --danger-border: rgba(122, 48, 48, 0.68);
  --danger-border-hover: rgba(165, 70, 70, 0.78);
  --danger-text: #f0bcbc;
  --danger-text-hover: #ffd6d6;

  --success: #5ba17a;
  --success-strong: #376b50;
  --success-bg: rgba(31, 115, 70, 0.68);
  --success-bg-hover: rgba(38, 135, 82, 0.78);
  --success-border: rgba(120, 190, 145, 0.40);
  --success-border-hover: rgba(130, 220, 160, 0.55);
  --success-text: #dfffe9;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.06), transparent 22%),
    radial-gradient(circle at top right, rgba(120, 138, 160, 0.08), transparent 18%),
    linear-gradient(180deg, #0b0f14 0%, #0f141b 42%, #111821 100%);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.5;
}

body.modal-open,
body.gm-modal-open,
body.wars-modal-open,
body.participant-modal-open,
body.avatar-cropper-open {
  overflow: hidden;
}

::selection {
  background: rgba(255, 255, 255, 0.22);
  color: #101317;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
  transition:
    color var(--transition),
    background var(--transition),
    border-color var(--transition),
    transform var(--transition),
    opacity var(--transition),
    box-shadow var(--transition);
}

form {
  margin: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

/* =========================================================
   Scrollbars
   ========================================================= */

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(143, 161, 186, .55) rgba(10, 14, 20, .55);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(10, 14, 20, .55);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    rgba(160, 176, 204, .62),
    rgba(100, 116, 145, .56)
  );
  border: 2px solid rgba(10, 14, 20, .75);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    rgba(190, 204, 228, .78),
    rgba(124, 143, 176, .72)
  );
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

/* =========================================================
   Header / shell / sidebar
   ========================================================= */

body.app-shell-public {
  --sidebar-width: 180px;
}

body.app-shell-chat {
  --sidebar-width: 160px;
}

.top-header {
  position: sticky;
  top: 0;
  z-index: 1200;
  min-height: var(--header-height);
  padding: 0 22px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  background: rgba(12, 16, 22, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
  box-shadow: none;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  min-width: 0;
}

.header-left h1 {
  margin: 0;
  color: var(--accent);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.header-username {
  color: var(--accent);
  font-weight: 700;
}

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  padding: 18px 14px 22px;
  overflow-y: auto;

  background: rgba(14, 19, 26, 0.94);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
  box-shadow: none;
}

.sidebar nav {
  height: 100%;
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;

  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar ul li {
  margin: 0;
}

.sidebar ul li a {
  min-height: 44px;
  padding: 0 14px;

  display: flex;
  align-items: center;

  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);

  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.25;
}

.sidebar ul li a:hover,
.sidebar ul li a:focus {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
  color: var(--text);
}

.sidebar-divider {
  height: 1px;
  margin: 8px 6px;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-empty {
  padding: 8px 10px;
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.35;
}

.sidebar-section-title,
.sidebar-note {
  padding: 8px 10px;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.sidebar-section-title {
  overflow-wrap: anywhere;
  color: var(--text);
}

.sidebar-note {
  font-weight: 600;
}

.sidebar ul li.sidebar-section-title a.sidebar-title-link {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.sidebar ul li.sidebar-section-title a.sidebar-title-link:hover,
.sidebar ul li.sidebar-section-title a.sidebar-title-link:focus {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
}

.sidebar-server-link {
  gap: 10px;
  min-height: 48px !important;
  padding: 6px 10px !important;
}

.sidebar-server-link.is-active {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
  color: var(--text);
}

.sidebar-server-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--surface-muted);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-server-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.sidebar-server-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-server-badge {
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;

  border-radius: 999px;
  padding: 1px 6px;
  background: rgba(221, 170, 70, 0.14);
  color: #f6d9a0;

  font-size: 0.68rem;
  line-height: 1.45;
}

.sidebar-server-badge.blocked {
  background: rgba(184, 90, 103, 0.16);
  color: #f1c3cb;
}

.app-main {
  position: relative;
  min-width: 0;
}

body.app-shell-game .app-main,
body.app-shell-wiki .app-main {
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--header-height));
  background: transparent;
}

body.app-shell-chat .app-main {
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--header-height));
  height: calc(100vh - var(--header-height));
  display: flex;
}

body.app-shell-public .app-main {
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--header-height));
  padding: 30px clamp(18px, 3vw, 36px) 42px;
  background: transparent;
}

body.homepage .sidebar {
  display: none !important;
}

body.homepage .app-main {
  margin-left: 0 !important;
}

/* =========================================================
   Profile
   ========================================================= */

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-btn {
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);

  display: flex;
  align-items: center;
  gap: 9px;

  cursor: pointer;
  box-shadow: none;
}

.profile-btn:hover,
.profile-btn:focus {
  background: transparent;
  color: var(--text);
  opacity: 0.82;
}

.avatar,
.user-info .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  object-fit: cover;
  box-shadow: none;
}

.nickname-in-header {
  color: var(--accent);
  font-size: 0.98rem;
  font-weight: 700;
}

.profile-popup {
  position: fixed;
  top: calc(var(--header-height) + 10px);
  right: 24px;
  z-index: 1510;

  width: min(360px, calc(100vw - 32px));
  padding: 0;
  display: none;
  overflow: hidden;

  background: rgba(21, 27, 35, 0.98);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: none;
}

.profile-popup.active {
  display: block !important;
  animation: profile-popup-drop 0.18s cubic-bezier(0.59, 0.12, 0.41, 1.1);
}

@keyframes profile-popup-drop {
  0% {
    transform: translateY(-10px) scale(0.96);
    opacity: 0;
  }

  100% {
    transform: none;
    opacity: 1;
  }
}

.profile-popup-inner {
  padding: 24px 24px 20px;

  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.popup-avatar-wrap {
  position: relative;
  width: 78px;
  height: 78px;
  margin-bottom: 4px;
  cursor: pointer;
}

.popup-avatar {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--surface-muted);
  object-fit: cover;
  box-shadow: none;
  transition: filter var(--transition), transform var(--transition);
}

.popup-avatar-wrap:hover .popup-avatar {
  filter: brightness(0.7);
  transform: scale(1.02);
}

.popup-avatar-edit {
  position: absolute;
  top: 50%;
  left: 50%;

  width: 42px;
  height: 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;
  background: rgba(17, 17, 17, 0.72);
  color: #fff;

  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.popup-avatar-wrap:hover .popup-avatar-edit {
  opacity: 1;
}

.popup-avatar-edit svg {
  width: 28px;
  height: 28px;
}

.nickname-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 2px;
}

.profile-nickname-input {
  min-width: 48px;
  max-width: 180px;
  padding: 4px 8px;

  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);

  font-size: 1.08rem;
  font-weight: 700;
  text-align: center;
  outline: none;
}

.profile-nickname-input[readonly] {
  cursor: default;
}

.profile-nickname-input.editing {
  border-color: rgba(255, 255, 255, 0.22);
  background: var(--surface-soft);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
}

.nickname-btns {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nickname-btn {
  width: 28px;
  height: 28px;
  padding: 0;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--accent-soft);

  cursor: pointer;
}

.nickname-btn:hover,
.nickname-btn:focus {
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent);
}

.nickname-btn svg {
  width: 17px;
  height: 17px;
  pointer-events: none;
}

.profile-popup-login {
  color: var(--text-soft);
  font-size: 0.96rem;
  text-align: center;
}

.profile-popup-logout {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  margin-top: 4px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border: 1px solid var(--text);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);

  font-size: 0.96rem;
  font-weight: 700;
}

.profile-popup-logout:hover,
.profile-popup-logout:focus {
  background: #f3f5f8;
  border-color: #f3f5f8;
  color: #111111;
}

.profile-avatar-upload {
  display: none !important;
}

/* =========================================================
   Buttons
   ========================================================= */

button,
.btn-main,
.toggle-btn,
.modal button,
.modal .btn-main,
.modal .toggle-btn {
  width: auto;
  min-height: 34px;
  margin: 0;
  padding: 0 12px;
  box-sizing: border-box;

  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  color: #eef2f7;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  font: inherit;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  text-align: center;
  text-decoration: none;

  cursor: pointer;
  box-shadow: none;
  text-shadow: none;
  transform: none;

  transition:
    background .14s ease,
    border-color .14s ease,
    color .14s ease,
    opacity .14s ease,
    box-shadow .14s ease;
}

button:hover,
button:focus,
.btn-main:hover,
.btn-main:focus,
.toggle-btn:hover,
.toggle-btn:focus,
.modal button:hover,
.modal button:focus,
.modal .btn-main:hover,
.modal .btn-main:focus,
.modal .toggle-btn:hover,
.modal .toggle-btn:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.17);
  color: #fff;
  outline: none;
  text-decoration: none;
  transform: none;
  box-shadow: none;
}

.btn-main:not(.btn-alt):not(.btn-pencil):not(.btn-folder):not(.btn-red):not(.btn-danger):not(.btn-delete):not(.delete-btn):not(.btn-green),
.modal .btn-main:not(.btn-alt):not(.btn-pencil):not(.btn-folder):not(.btn-red):not(.btn-danger):not(.btn-delete):not(.delete-btn):not(.btn-green) {
  border-color: rgba(243, 245, 248, 0.88);
  background: #f3f5f8;
  color: #111821;
}

.btn-main:not(.btn-alt):not(.btn-pencil):not(.btn-folder):not(.btn-red):not(.btn-danger):not(.btn-delete):not(.delete-btn):not(.btn-green):hover,
.btn-main:not(.btn-alt):not(.btn-pencil):not(.btn-folder):not(.btn-red):not(.btn-danger):not(.btn-delete):not(.delete-btn):not(.btn-green):focus,
.modal .btn-main:not(.btn-alt):not(.btn-pencil):not(.btn-folder):not(.btn-red):not(.btn-danger):not(.btn-delete):not(.delete-btn):not(.btn-green):hover,
.modal .btn-main:not(.btn-alt):not(.btn-pencil):not(.btn-folder):not(.btn-red):not(.btn-danger):not(.btn-delete):not(.delete-btn):not(.btn-green):focus {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.28);
  color: #f3f5f8;
}

.btn-main.btn-alt,
.btn-main.btn-pencil,
.btn-main.btn-folder,
.btn-alt,
.modal .btn-main.btn-alt,
.modal .btn-main.btn-pencil,
.modal .btn-main.btn-folder,
.modal .btn-alt {
  background: rgba(255, 255, 255, 0.035);
  color: #dbe5f1;
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow: none;
}

.btn-main.btn-alt:hover,
.btn-main.btn-alt:focus,
.btn-main.btn-pencil:hover,
.btn-main.btn-pencil:focus,
.btn-main.btn-folder:hover,
.btn-main.btn-folder:focus,
.btn-alt:hover,
.btn-alt:focus,
.modal .btn-main.btn-alt:hover,
.modal .btn-main.btn-alt:focus,
.modal .btn-main.btn-pencil:hover,
.modal .btn-main.btn-pencil:focus,
.modal .btn-main.btn-folder:hover,
.modal .btn-main.btn-folder:focus,
.modal .btn-alt:hover,
.modal .btn-alt:focus {
  background: rgba(255, 255, 255, 0.075);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.btn-main.btn-red,
.btn-main.btn-danger,
.btn-main.btn-delete,
.btn-red,
.btn-danger,
.btn-delete,
.delete-btn,
.modal .btn-main.btn-red,
.modal .btn-main.btn-danger,
.modal .btn-main.btn-delete,
.modal .btn-red,
.modal .btn-danger,
.modal .btn-delete,
.modal .delete-btn {
  border: 1px solid var(--danger-border) !important;
  background: var(--danger-bg) !important;
  color: var(--danger-text) !important;
  box-shadow: 0 0 0 1px rgba(150, 70, 70, 0.08) inset !important;
}

.btn-main.btn-red:hover,
.btn-main.btn-red:focus,
.btn-main.btn-danger:hover,
.btn-main.btn-danger:focus,
.btn-main.btn-delete:hover,
.btn-main.btn-delete:focus,
.btn-red:hover,
.btn-red:focus,
.btn-danger:hover,
.btn-danger:focus,
.btn-delete:hover,
.btn-delete:focus,
.delete-btn:hover,
.delete-btn:focus,
.modal .btn-main.btn-red:hover,
.modal .btn-main.btn-red:focus,
.modal .btn-main.btn-danger:hover,
.modal .btn-main.btn-danger:focus,
.modal .btn-main.btn-delete:hover,
.modal .btn-main.btn-delete:focus,
.modal .btn-red:hover,
.modal .btn-red:focus,
.modal .btn-danger:hover,
.modal .btn-danger:focus,
.modal .btn-delete:hover,
.modal .btn-delete:focus,
.modal .delete-btn:hover,
.modal .delete-btn:focus {
  border-color: var(--danger-border-hover) !important;
  background: var(--danger-bg-hover) !important;
  color: var(--danger-text-hover) !important;
}

.btn-main.btn-green,
.btn-green,
.modal .btn-main.btn-green,
.modal .btn-green {
  border: 1px solid var(--success-border) !important;
  background: var(--success-bg) !important;
  color: var(--success-text) !important;
}

.btn-main.btn-green:hover,
.btn-main.btn-green:focus,
.btn-green:hover,
.btn-green:focus,
.modal .btn-main.btn-green:hover,
.modal .btn-main.btn-green:focus,
.modal .btn-green:hover,
.modal .btn-green:focus {
  border-color: var(--success-border-hover) !important;
  background: var(--success-bg-hover) !important;
  color: #fff !important;
}

.btn-main.btn-small,
.btn-small,
.modal .btn-main.btn-small,
.modal .btn-small {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 10px;
  font-size: 12px;
}

.btn-main[disabled],
button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =========================================================
   Forms
   ========================================================= */

.lbl,
label {
  display: block;
  margin: 8px 0;
  color: #dbe5f1;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
textarea,
select,
.inp {
  width: 100%;
  max-width: 100%;
  min-height: 34px;
  box-sizing: border-box;
  padding: 7px 9px;

  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: #0f141b;
  color: #f3f5f8;

  font: inherit;
  box-shadow: none;
  outline: none;

  transition:
    border-color var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

input[type="file"] {
  padding: 8px 10px;
  color: #9fb0ca;
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus,
.inp:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: 0;
}

/* =========================================================
   Switches
   ========================================================= */

.switch-field {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.switch-field input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-ui {
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 46px;

  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.08);

  transition:
    background .18s ease,
    border-color .18s ease,
    transform .18s ease;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;

  width: 20px;
  height: 20px;

  border-radius: 50%;
  background: #f4f6fb;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);

  transition: transform .18s ease;
}

.switch-field input[type="checkbox"]:checked + .switch-ui {
  background: #dfe4ef;
  border-color: #dfe4ef;
}

.switch-field input[type="checkbox"]:checked + .switch-ui::after {
  transform: translateX(20px);
  background: #141a22;
}

.switch-label {
  font-size: 14px;
  font-weight: 600;
}

/* =========================================================
   Common cards / layout helpers
   ========================================================= */

.subtitle,
.muted,
.descr,
.fleet-sub,
.fleet-sub-col,
.stats-value {
  color: var(--text-soft) !important;
}

.ui-card,
.gm-launch-card,
.gm-modal-card,
.gm-lists,
.army-stats-card,
.navy-stats-card,
.type-icons-card,
.fleet-card,
.agent-card,
.ship-mini-card,
.auth-card,
.gm-settings,
.sidebar-right,
.modal-content {
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 14px !important;
  background: rgba(18, 24, 32, 0.94) !important;
  box-shadow: none !important;
}

.ui-card-soft,
.stats-item,
.gm-template-card {
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.025) !important;
  box-shadow: none !important;
}

.timeline-style-minister {
  background: rgba(21, 27, 35, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 4px solid rgba(255, 255, 255, 0.72);
  border-radius: 12px;
  box-shadow: none;
  color: var(--text);
}

.main-content.army-scrollable,
.main-content.navy-scrollable {
  padding: 28px 26px 40px !important;
}

/* =========================================================
   Modals
   ========================================================= */

.modal,
.modal-bg,
.floating-modal,
.moderation-modal,
.wars-modal,
.avatar-cropper-modal {
  overscroll-behavior: contain;
}

/* =========================================================
   1. Старый формат:
   .modal-bg — фон
   .modal — внутреннее окно
   ========================================================= */

.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 3000;

  width: 100%;
  height: 100dvh;
  padding: 12px 16px;
  box-sizing: border-box;

  display: flex;
  align-items: flex-start;
  justify-content: center;

  overflow-y: auto;
  overflow-x: hidden;

  background: rgba(3, 6, 10, 0.72);
  backdrop-filter: blur(4px);
}

.modal-bg[hidden] {
  display: none !important;
}

/* ВАЖНО: внутри .modal-bg класс .modal — это НЕ фон, а карточка */
.modal-bg > .modal {
  width: min(680px, calc(100vw - 32px));
  max-width: 100%;
  min-width: 0;
  max-height: calc(100dvh - 24px);

  margin: 0 auto;
  padding: 20px 22px;
  box-sizing: border-box;

  display: flex !important;
  flex-direction: column;

  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;

  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  background: rgba(14, 19, 26, 0.98);
  color: #eef2f7;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
}

/* Размеры старых внутренних окон */
.modal-bg > .modal.modal-narrow {
  width: min(460px, calc(100vw - 32px));
}

.modal-bg > .modal.modal-medium {
  width: min(760px, calc(100vw - 32px));
}

.modal-bg > .modal.modal-wide {
  width: min(1040px, calc(100vw - 32px));
}

.modal-bg > .modal.modal-xl {
  width: min(1180px, calc(100vw - 32px));
}

.modal-bg > .modal.modal-template-edit {
  width: min(980px, calc(100vw - 32px));
}

/* =========================================================
   2. Новый формат:
   .modal — сам фон
   .modal-content — внутреннее окно
   ========================================================= */

body > .modal,
.app-main > .modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3000;

  width: 100%;
  height: 100dvh;
  padding: 12px 16px;
  box-sizing: border-box;

  align-items: flex-start;
  justify-content: center;

  overflow-y: auto;
  overflow-x: hidden;

  background: rgba(3, 6, 10, 0.72);
  backdrop-filter: blur(4px);
}

body > .modal.active,
.app-main > .modal.active {
  display: flex !important;
}

body > .modal[hidden],
.app-main > .modal[hidden] {
  display: none !important;
}

.modal-content,
.floating-modal-dialog,
.moderation-modal-dialog,
.wars-modal-dialog,
.avatar-cropper-dialog {
  width: min(680px, calc(100vw - 32px));
  max-width: 100%;
  min-width: 0;
  max-height: calc(100dvh - 24px);

  margin: 0 auto;
  padding: 20px 22px;
  box-sizing: border-box;

  display: flex;
  flex-direction: column;

  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;

  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 16px;
  background: rgba(14, 19, 26, 0.98);
  color: #eef2f7;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
}

.modal-content-narrow,
.modal-narrow.modal-content,
.floating-modal-dialog.modal-narrow,
.moderation-modal-dialog.modal-narrow,
.wars-modal-dialog.modal-narrow {
  width: min(460px, calc(100vw - 32px));
}

.modal-content-medium,
.modal-medium.modal-content,
.floating-modal-dialog.modal-medium,
.moderation-modal-dialog.modal-medium,
.wars-modal-dialog.modal-medium {
  width: min(760px, calc(100vw - 32px));
}

.modal-content-wide,
.modal-wide.modal-content,
.floating-modal-dialog.modal-wide,
.moderation-modal-dialog.modal-wide,
.wars-modal-dialog.modal-wide {
  width: min(1040px, calc(100vw - 32px));
}

.modal-content-xl,
.modal-xl.modal-content,
.floating-modal-dialog.modal-xl,
.moderation-modal-dialog.modal-xl,
.wars-modal-dialog.modal-xl {
  width: min(1180px, calc(100vw - 32px));
}

/* =========================================================
   3. Особые модалки проекта
   ========================================================= */

.floating-modal,
.moderation-modal,
.wars-modal,
.avatar-cropper-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;

  width: 100%;
  height: 100dvh;
  padding: 12px 16px;
  box-sizing: border-box;

  display: none;
  align-items: flex-start;
  justify-content: center;

  overflow-y: auto;
  overflow-x: hidden;

  background: rgba(3, 6, 10, 0.72);
  backdrop-filter: blur(4px);
}

.floating-modal.active,
.moderation-modal.active,
.wars-modal.active,
.avatar-cropper-modal.active {
  display: flex !important;
}

.wars-modal-dialog {
  width: min(1040px, calc(100vw - 32px));
  min-height: 0;
}

.wars-modal-dialog.modal-narrow {
  width: min(440px, calc(100vw - 32px));
}

.wars-modal-dialog > form:not([hidden]) {
  flex: 1 1 auto;
  min-height: 0;

  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wars-modal-dialog .wars-modal-head,
.wars-modal-dialog .wars-modal-foot {
  flex-shrink: 0;
}

.wars-modal-dialog .wars-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* =========================================================
   4. Внутренние части модалок
   ========================================================= */

.modal-body,
.wars-modal-body,
.floating-modal-body,
.moderation-modal-body,
.avatar-cropper-body {
  min-height: 0;
  overflow-y: auto;
}

.modal-head,
.floating-modal-head,
.moderation-modal-head,
.wars-modal-head,
.avatar-cropper-head {
  flex: 0 0 auto;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  margin: 0 0 14px;
  padding-bottom: 12px;

  border-bottom: 1px solid rgba(255, 255, 255, 0.08);

  color: #f3f5f8;
  font-size: 15px;
  font-weight: 950;
  line-height: 1.2;
}

.modal-title {
  margin: 0 0 12px;
  padding-bottom: 10px;

  border-bottom: 1px solid rgba(255, 255, 255, 0.08);

  color: #f3f5f8;
  font-size: 18px;
  font-weight: 950;
  line-height: 1.2;
}

.modal-foot,
.floating-modal-foot,
.moderation-modal-foot,
.wars-modal-foot,
.avatar-cropper-foot {
  flex: 0 0 auto;

  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;

  margin-top: 14px;
  padding-top: 12px;

  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-actions {
  margin-top: 12px;

  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

body.modal-open,
body.gm-modal-open,
body.wars-modal-open,
body.participant-modal-open,
body.avatar-cropper-open {
  overflow: hidden;
}

/* =========================================================
   5. Адаптив модалок
   ========================================================= */

@media (max-width: 760px) {
  .modal-bg,
  body > .modal,
  .app-main > .modal,
  .floating-modal,
  .moderation-modal,
  .wars-modal,
  .avatar-cropper-modal {
    padding: 14px;
  }

  .modal-bg > .modal,
  .modal-content,
  .floating-modal-dialog,
  .moderation-modal-dialog,
  .wars-modal-dialog,
  .avatar-cropper-dialog {
    width: calc(100vw - 28px) !important;
    max-height: calc(100dvh - 28px);
    margin: 0 auto !important;
    padding: 18px;
  }
}

@media (max-width: 560px) {
  .modal-actions,
  .modal-foot,
  .floating-modal-foot,
  .moderation-modal-foot,
  .wars-modal-foot,
  .avatar-cropper-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-actions .btn-main,
  .modal-actions button,
  .modal-foot .btn-main,
  .modal-foot button,
  .floating-modal-foot .btn-main,
  .floating-modal-foot button,
  .moderation-modal-foot .btn-main,
  .moderation-modal-foot button,
  .wars-modal-foot .btn-main,
  .wars-modal-foot button,
  .avatar-cropper-foot .btn-main,
  .avatar-cropper-foot button {
    width: 100%;
  }
}

/* =========================================================
   GM dashboard shared
   ========================================================= */

.gm-dashboard-container {
  display: grid !important;
  grid-template-columns: minmax(560px, 1.45fr) minmax(260px, 0.72fr);
  gap: 20px;
  align-items: start;
  margin-top: 20px;
  overflow-x: hidden;
}

.gm-lists {
  min-width: 0;
  padding: 18px 20px;
  border-radius: 16px;
}

.gm-panel-shell {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.gm-lists-panel {
  display: grid;
  gap: 16px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.gm-lists-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin: 0;
  padding-bottom: 2px;
}

.gm-lists-kicker,
.gm-project-kicker,
.gm-season-kicker {
  margin-bottom: 5px;
  color: #8fa1ba;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .1em;
}

.gm-lists-head h3,
.gm-project-head h3,
.gm-season-head h3,
.gm-map-head h3,
.gm-military-head h3,
.gm-force-modal-head h3 {
  margin: 0;
  color: #f3f5f8;
  font-size: 20px;
  font-weight: 900;
  line-height: 1.15;
}

.gm-lists-section {
  display: grid;
  gap: 10px;
}

.gm-lists-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.gm-lists-section-head h4 {
  margin: 0;
  color: #f3f5f8;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.25;
}

.gm-lists-section-head p {
  margin: 4px 0 0;
  color: #8fa1ba;
  font-size: 12px;
  line-height: 1.35;
}

.gm-section-divider {
  height: 1px;
  margin: 0;
  border: 0;
  background: rgba(255, 255, 255, 0.09);
}

.gm-country-add-btn {
  width: 30px;
  min-width: 30px;
  max-width: 30px;
  height: 30px;
  min-height: 30px;
  max-height: 30px;
  flex: 0 0 30px;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  aspect-ratio: 1 / 1;

  border-radius: 9px;
  border: 1px solid rgba(243, 245, 248, 0.88);
  background: #f3f5f8;
  color: #111821;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  text-shadow: none;
}

.gm-country-add-btn:hover,
.gm-country-add-btn:focus {
  background: transparent;
  color: #f3f5f8;
  border-color: rgba(255, 255, 255, 0.28);
  outline: none;
}

.country-flags-list,
.gm-country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin: 0;
  align-items: stretch;
}

.flag-user-wrap,
.gm-country-card {
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.027);

  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  align-items: start;
  justify-items: stretch;
  position: relative;

  transition:
    background .16s ease,
    border-color .16s ease,
    transform .16s ease;
}

.gm-country-card:hover {
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(255, 255, 255, 0.13);
  transform: translateY(-1px);
}

.gm-country-card-free {
  background: rgba(255, 255, 255, 0.018);
}

.flag-btn,
.gm-country-flag-btn {
  width: 100%;
  margin: 0;
  padding: 0;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  display: block;
  cursor: pointer;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
}

.gm-country-flag-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1.55 / 1;
  display: block;
  overflow: hidden;

  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.035);
}

.gm-country-flag-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.country-flag,
.empty-flag {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
  border-radius: 0;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

.empty-flag {
  position: relative;
}

.empty-flag::before {
  content: "—";
  width: 100%;
  height: 100%;

  display: flex;
  align-items: center;
  justify-content: center;

  color: #8fa1ba;
  font-weight: 900;
}

.flag-btn:focus .gm-country-flag-shell,
.flag-btn:hover .gm-country-flag-shell {
  border-color: rgba(243, 245, 248, 0.54);
}

.gm-country-card-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
  justify-items: center;
}

.flag-country-name {
  max-width: 100%;
  margin: 0;
  color: #eef2f7;
  font-size: 11.5px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flag-country-owner {
  max-width: 100%;
  color: #8fa1ba;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gm-list-empty,
.gm-template-empty,
.folder-empty {
  grid-column: 1 / -1;
  padding: 14px;

  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.018);
  color: #8fa1ba;

  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.players-no-country,
.gm-players-no-country {
  max-width: none;
  margin: 0;
  padding: 0;
  list-style: none;

  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-start;
}

.player-no-country {
  min-width: 0;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 0;
  display: block;
}

.no-country-btn,
.gm-player-pill {
  max-width: 190px;
  min-height: 34px;
  margin: 0;
  padding: 4px 10px 4px 5px;

  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  color: #eef2f7;

  display: inline-flex;
  align-items: center;
  gap: 8px;

  font: inherit;
  cursor: pointer;
  box-shadow: none;
  text-shadow: none;
}

.no-country-btn:hover,
.no-country-btn:focus,
.gm-player-pill:hover,
.gm-player-pill:focus {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.14);
  color: #fff;
  outline: none;
}

.gm-player-pill-avatar {
  width: 24px;
  height: 24px;
  min-width: 24px;

  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: #f3f5f8;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.gm-player-pill-name {
  min-width: 0;
  color: inherit;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gm-launch-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.gm-launch-card {
  width: 100%;
  min-height: 58px;
  margin: 0;
  padding: 12px 14px;

  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;

  text-align: left;
  background: rgba(14, 19, 26, 0.94) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  border-radius: 14px !important;
  box-shadow: none !important;
}

.gm-launch-card[data-open-modal] {
  cursor: pointer;
}

.gm-launch-card[data-open-modal]:hover,
.gm-launch-card[data-open-modal]:focus {
  background: rgba(20, 27, 37, 0.96) !important;
  border-color: rgba(255, 255, 255, 0.16) !important;
}

.gm-launch-card[data-open-modal] .btn-main {
  display: none;
}

.gm-launch-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.gm-launch-card .gm-template-preview {
  display: none;
}

.gm-launch-card .modal-actions {
  margin-top: 0;
  justify-content: flex-start;
}

.gm-launch-card[data-open-modal] > .btn-main,
.gm-launch-card[data-open-modal] > .modal-actions,
.gm-launch-card[data-open-modal] > .modal-actions > button,
.gm-launch-card[data-open-modal] > button {
  display: none !important;
}

/* =========================================================
   Details / folders / entity lists
   ========================================================= */

details > summary {
  list-style: none;
}

details > summary::-webkit-details-marker {
  display: none;
}

.folder-stack,
.gm-modal-stack,
.gm-template-stack,
.gm-entity-list {
  display: grid;
  gap: 14px;
}

.folder-summary,
.gm-entity-summary,
.gm-template-summary,
.gm-force-template-summary,
.province-field-summary {
  min-height: 52px;
  padding: 13px 15px;
  list-style: none;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #f3f5f8;

  transition:
    background .14s ease,
    border-color .14s ease;
}

.folder-summary:hover,
.gm-entity-summary:hover,
.gm-template-summary:hover,
.gm-force-template-summary:hover,
.province-field-summary:hover {
  background: rgba(255, 255, 255, 0.035);
}

.folder-title,
.gm-entity-title,
.gm-template-name {
  min-width: 0;
  color: #f3f5f8;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gm-entity-card,
.gm-template-details,
.gm-force-template,
.province-field-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.026);
  overflow: hidden;
}

.gm-entity-summary-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.gm-entity-meta {
  color: rgba(230, 236, 242, 0.7);
  font-size: .9rem;
  text-align: right;
}

.gm-entity-card form {
  padding: 0 14px 14px;
}

.gm-entity-media {
  width: 38px;
  height: 38px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);

  overflow: hidden;
  flex: 0 0 auto;
}

.gm-entity-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.gm-entity-media-fallback {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.55);
}

/* =========================================================
   GM forms / grids
   ========================================================= */

.gm-form,
fieldset,
.dev-fields {
  margin-bottom: 20px;
  padding: 10px;

  background: #10161d;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #eef2f7;
}

legend {
  padding: 0 5px;
  color: #ddd;
  font-weight: bold;
}

.gm-form-grid,
.gm-template-fields,
.gm-template-field-create,
.gm-template-create {
  display: grid;
  gap: 12px;
}

.gm-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gm-form-grid .full {
  grid-column: 1 / -1;
}

.gm-template-card-head,
.gm-template-card-head-inner,
.gm-template-inline-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.gm-template-inline-actions {
  justify-content: flex-start;
}

.gm-form-note {
  color: rgba(230, 236, 242, 0.72);
  font-size: .93rem;
  line-height: 1.45;
  padding: 10px 12px;

  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

/* =========================================================
   Popups
   ========================================================= */

.flag-popup {
  display: none;
  position: fixed;
  z-index: 1200;
  left: 0;
  top: 0;
  right: auto;
  bottom: auto;

  min-width: 210px;
  max-width: min(94vw, 760px);
  padding: 0;
  overflow: visible;

  background: transparent;
  border-radius: 14px;
  box-shadow: none;
  color: #eee;

  pointer-events: auto;
  opacity: 0;
  transform: translateY(6px);

  transition:
    opacity .17s cubic-bezier(.55, .15, .45, 1),
    transform .22s cubic-bezier(.65, .15, .45, 1);
}

.flag-popup.active {
  display: block !important;
  opacity: 1;
  transform: translateY(0);
}

.flag-popup-inner {
  width: min(94vw, 620px);
  max-width: 100%;
  max-height: calc(100vh - 24px);
  margin: 0;
  padding: 14px;

  overflow-y: auto;
  overflow-x: hidden;

  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(14, 19, 26, 0.98);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);

  display: flex;
  flex-direction: column;
  align-items: stretch;
}

#no-country-popup .flag-popup-inner {
  width: min(94vw, 420px);
}

.flag-popup-username {
  margin: 0 0 12px;
  padding: 0 2px 10px;

  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f3f5f8;

  font-size: 15px;
  font-weight: 900;
  line-height: 1.25;
  text-align: left;
  background: none;
}

.flag-popup-links-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 10px;
}

.flag-popup-links-row,
.flag-popup-links-single {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 10px;
}

.flag-popup-link,
.flag-popup-links-row .flag-popup-link {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  height: auto;
  margin: 0;
  padding: 0 10px;

  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
  color: #eef2f7;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  font: inherit;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
  text-align: center;
  text-decoration: none;

  cursor: pointer;
  box-sizing: border-box;
}

.flag-popup-link:hover,
.flag-popup-link:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.17);
  color: #fff;
  outline: none;
}

.flag-edit-form,
#flag-edit-form {
  max-width: 100%;
  max-height: calc(100vh - 210px);
  margin-top: 10px;
  padding: 12px;

  overflow: auto;
  overflow-x: hidden;

  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  box-sizing: border-box;
}

.flag-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* =========================================================
   Traits / resource rows
   ========================================================= */

.traits-head-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.traits-add-panel {
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  margin: 10px 0 12px;
}

.traits-list-shell,
.gm-resource-list-shell {
  max-height: 62vh;
  overflow: auto;
  padding-right: 4px;
}

.traits-list,
.gm-resource-card-grid {
  list-style: none;
  margin: 0;
  padding: 0;
}

.traits-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trait-row {
  width: 100%;
  padding: 10px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: #eef2f7;

  cursor: pointer;
  text-align: left;
}

.trait-row:hover,
.trait-row:focus {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.14);
}

.trait-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.trait-row-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  flex: 0 0 22px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  color: #aeb7c5;
  font-weight: 800;
}

.trait-row-name {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trait-row-meta {
  font-size: 12px;
  color: #aeb7c5;
  white-space: nowrap;
}

.trait-icon-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.trait-icon-preview {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);

  display: flex;
  align-items: center;
  justify-content: center;

  overflow: hidden;
  flex: 0 0 46px;
}

.trait-icon-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.trait-icon-empty {
  color: #aeb7c5;
  font-weight: 900;
}

/* =========================================================
   Army / navy / agency shared polish
   ========================================================= */

.army-stats-header,
.navy-stats-header,
.fleet-head,
.gm-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.army-stats-title,
.navy-stats-title,
.fleet-title,
.tic-title {
  color: var(--text) !important;
  font-weight: 700;
}

.army-stats-grid,
.navy-stats-grid {
  display: grid !important;
  gap: 14px !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.stats-item {
  padding: 16px 18px !important;
}

.stats-item .lbl,
.stats-item .mobil-label {
  margin-bottom: 8px;
}

.stats-item-full {
  grid-column: 1 / -1;
}

.doctrine-card,
.stats-item.doctrine-card {
  background: rgba(255, 255, 255, 0.03) !important;
}

.type-icons-card,
.fleet-card {
  padding: 18px 20px !important;
}

.top-row {
  display: grid !important;
  gap: 16px !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.tic-actions,
.ship-summary-grid,
.head-actions.compact {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.fleet-sub-col > div {
  margin: 0 0 8px;
}

.fleet-sub-col > div:last-child {
  margin-bottom: 0;
}

.features-list {
  margin: 8px 0 0;
  padding-left: 18px;
}

.ships-grid,
.agents-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px !important;
}

.ship-mini-card {
  padding: 16px !important;
}

.ship-mini-card-main,
.agent-main {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.ship-icon-box,
.agent-portrait-box {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 10px !important;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.ship-icon-img,
.agent-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.action-menu-wrap {
  position: relative;
}

.action-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  padding: 8px;

  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(15, 20, 27, 0.98);
  box-shadow: none;
  z-index: 40;
}

.action-menu-btn {
  width: 100%;
  justify-content: flex-start;
  min-height: 38px;
  padding: 0 12px;

  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 10px;
}

.action-menu-btn:hover,
.action-menu-btn:focus {
  background: rgba(255, 255, 255, 0.06);
}

.action-menu-btn-danger {
  color: #f1c3cb;
}

/* =========================================================
   Development modal
   ========================================================= */

.dev-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.dev-field {
  display: flex;
  align-items: center;
}

.dev-field img {
  width: 24px;
  height: 24px;
  margin-right: 8px;
}

.dev-results {
  margin-top: 10px;
}

.hidden {
  display: none;
}

#dev-toggle,
#dev-modal {
  display: none !important;
}

/* =========================================================
   Toasts
   ========================================================= */

.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1500;

  padding: 14px 20px;

  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text);
  box-shadow: none;

  opacity: 0;
  pointer-events: none;
  transform: translateY(-12px);

  transition:
    opacity var(--transition),
    transform var(--transition);
}

.toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.toast-container {
  position: fixed;
  top: 22px;
  right: 20px;
  z-index: 1500;

  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;

  pointer-events: none;
}

.site-toast {
  min-width: 240px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 13px 18px;

  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text);
  box-shadow: none;

  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.4;

  opacity: 0;
  transform: translateX(24px);

  transition:
    opacity var(--transition),
    transform var(--transition);

  pointer-events: auto;
}

.site-toast.show {
  opacity: 1;
  transform: translateX(0);
}

.site-toast.success {
  background: #234632;
}

.site-toast.info {
  background: #263a59;
}

.site-toast.error,
.site-toast.danger {
  background: #5b242f;
}

/* =========================================================
   Legal / auth
   ========================================================= */

body.legal-shell .app-main,
body.auth-shell .app-main {
  margin-left: 0 !important;
}

body.legal-shell .app-main {
  padding: 34px clamp(18px, 4vw, 48px) 28px;
}

.legal-page,
.legal-document {
  width: min(920px, 100%);
  margin: 0 auto;
  color: var(--text);
}

.legal-card {
  padding: clamp(24px, 3vw, 38px);

  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(22, 29, 38, 0.96), rgba(15, 21, 29, 0.96));
}

.legal-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.legal-title {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.55rem, 3vw, 2.15rem);
  line-height: 1.18;
  letter-spacing: 0;
}

.legal-meta {
  margin: 10px 0 0;
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.5;
}

.legal-body {
  display: grid;
  gap: 22px;
  color: #dbe1ea;
  font-size: 1rem;
  line-height: 1.74;
}

.legal-intro,
.legal-section {
  min-width: 0;
}

.legal-section {
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.legal-section h2 {
  margin: 0 0 14px;
  color: var(--text);
  font-size: clamp(1.08rem, 1.8vw, 1.28rem);
  line-height: 1.35;
  letter-spacing: 0;
}

.legal-intro p,
.legal-section p,
.legal-summary p,
.legal-note p,
.legal-warning p {
  margin: 0 0 14px;
}

.legal-intro p:last-child,
.legal-section p:last-child,
.legal-summary p:last-child,
.legal-note p:last-child,
.legal-warning p:last-child {
  margin-bottom: 0;
}

.legal-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 16px;
  padding-left: 22px;
}

.legal-list:last-child {
  margin-bottom: 0;
}

.legal-list li {
  padding-left: 4px;
}

.legal-summary,
.legal-note,
.legal-warning {
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left-width: 4px;
  border-radius: 10px;
}

.legal-summary {
  border-left-color: rgba(199, 206, 217, 0.72);
  background: rgba(255, 255, 255, 0.045);
}

.legal-note {
  border-left-color: rgba(126, 196, 250, 0.58);
  background: rgba(126, 196, 250, 0.07);
}

.legal-warning {
  border-left-color: rgba(184, 90, 103, 0.68);
  background: rgba(184, 90, 103, 0.08);
}

.legal-summary strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.95rem;
}

.legal-note h2,
.legal-warning h2 {
  margin-top: 0;
}

.legal-contact-line a {
  color: #9ccdf5;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* =========================================================
   Footer / cookies
   ========================================================= */

.site-footer {
  margin-left: var(--sidebar-width);
  padding: 18px 24px 28px;
  color: var(--text-soft);
}

body.homepage .site-footer,
body.legal-shell .site-footer,
body.auth-shell .site-footer {
  margin-left: 0;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
  font-size: 0.88rem;
}

.site-footer-links a {
  color: var(--text-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-footer-links a:hover,
.site-footer-links a:focus {
  color: var(--text);
}

.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1800;

  display: flex;
  align-items: center;
  gap: 14px;

  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 14px 16px;

  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(15, 20, 27, 0.98);
  color: var(--text);
}

.cookie-banner[hidden] {
  display: none;
}

.cookie-banner-text {
  flex: 1 1 auto;
  color: #dbe1ea;
  font-size: 0.92rem;
  line-height: 1.45;
}

.cookie-banner-link {
  flex: 0 0 auto;
  color: #7ec4fa;
  font-weight: 700;
  text-decoration: underline;
}

.cookie-banner-button {
  flex: 0 0 auto;
  min-height: 36px;
  background: #f3f5f8;
  color: #111111;
  border-color: #f3f5f8;
}

.cookie-banner-button:hover,
.cookie-banner-button:focus {
  background: transparent;
  color: var(--text);
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1120px) {
  .gm-dashboard-container {
    grid-template-columns: 1fr;
  }

  .gm-panel-shell {
    width: 100%;
  }
}

@media (max-width: 980px) {
  .gm-dashboard-container,
  .top-row {
    grid-template-columns: 1fr !important;
  }

  .army-stats-grid,
  .navy-stats-grid,
  .gm-form-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 900px) {
  .top-header {
    padding: 0 16px;
  }

  .header-left h1 {
    font-size: 1rem;
  }

  .sidebar {
    position: sticky;
    top: var(--header-height);
    width: auto;
    height: auto;
    padding: 12px 16px 16px;

    border-right: none;
    border-bottom: 1px solid var(--border);
    background: rgba(14, 19, 26, 0.96);
    box-shadow: none;

    overflow-x: auto;
    overflow-y: hidden;
  }

  .sidebar nav {
    height: auto;
  }

  .sidebar ul {
    width: max-content;
    flex-direction: row;
    gap: 10px;
  }

  .sidebar-divider {
    width: 1px;
    height: 38px;
    margin: 0 2px;
    flex: 0 0 1px;
  }

  .sidebar-empty {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 0 12px;
    white-space: nowrap;
  }

  .sidebar-section-title,
  .sidebar-note {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 0 12px;
    white-space: nowrap;
  }

  .sidebar ul li a {
    min-height: 38px;
    padding: 0 14px;
    white-space: nowrap;
    background: var(--surface);
  }

  .sidebar-server-link {
    min-width: 160px;
  }

  body.app-shell .app-main,
  body.app-shell-game .app-main,
  body.app-shell-wiki .app-main,
  body.app-shell-public .app-main {
    margin-left: 0 !important;
  }

  body.app-shell-chat .app-main {
    margin-left: 0 !important;
    min-height: calc(100vh - var(--header-height) - 68px);
    height: calc(100vh - var(--header-height) - 68px);
  }

  body.app-shell-public .app-main {
    padding-top: 20px;
  }

  .site-footer {
    margin-left: 0;
  }

  .cookie-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .cookie-banner-button {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .gm-lists {
    padding: 13px;
  }

  .gm-lists-panel {
    padding: 0;
    border-radius: 0;
  }

  .country-flags-list,
  .gm-country-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  }

  .flag-popup-links-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flag-popup-links-row,
  .flag-popup-links-single {
    grid-template-columns: 1fr;
  }

  .main-content.army-scrollable,
  .main-content.navy-scrollable,
  .gm-dashboard-container {
    padding: 20px 16px 32px !important;
  }

  .modal.active,
  .modal-bg {
    padding: 14px;
  }
}

@media (max-width: 640px) {
  .top-header {
    min-height: 58px;
    gap: 12px;
  }

  .profile-btn {
    padding-right: 8px;
  }

  .nickname-in-header {
    display: none;
  }

  .profile-popup {
    right: 12px;
    left: 12px;
    width: auto;
  }

  .site-toast,
  .toast {
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 560px) {
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-actions .btn-main,
  .modal-actions button {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .country-flags-list,
  .gm-country-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gm-lists-head {
    align-items: stretch;
  }
}