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

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--bg);
  --bg-image: url("https://i.postimg.cc/Wb4zqm4j/image.png");
  background-image:
    linear-gradient(rgba(10, 15, 29, 0.74), rgba(10, 15, 29, 0.9)),
    var(--bg-image, none);
  background-size: cover;
  background-position: center;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; }
img { display: block; max-width: 100%; }
svg.i { width: 1em; height: 1em; flex: none; }
svg.i-dynmap { overflow: visible; }
.num { font-family: var(--font-title); font-weight: 400; letter-spacing: 0.01em; }

:focus-visible { outline: 2px solid var(--blue-2); outline-offset: 2px; border-radius: 6px; }

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Заглавие ---------- */
.title {
  font-family: var(--font-title);
  font-weight: 400;
  font-size: clamp(30px, 4.2vw, 46px);
  line-height: 1.02;
  letter-spacing: 0.01em;
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9), 0 6px 28px rgba(0, 0, 0, 0.85);
}
.title > span { display: block; }
.title .w { color: var(--flag-white); }
.title .g { color: var(--flag-green); }
.title .r { color: var(--flag-red); }
.title-sm { font-size: clamp(30px, 9vw, 44px); }
.title-xs { font-size: 22px; }

/* ---------- Горна част ---------- */
.top {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 16px 0;
  pointer-events: none;
}
.top::before {
  content: '';
  position: absolute;
  inset: 0 0 -56px 0;
  background:
    radial-gradient(ellipse 460px 140px at 50% 35%, rgba(6, 10, 22, 0.92), rgba(6, 10, 22, 0.65) 55%, transparent 80%),
    linear-gradient(rgba(6, 10, 22, 0.88), rgba(6, 10, 22, 0.55) 55%, transparent);
  z-index: -1;
}
.subtitle {
  margin-top: 8px;
  color: #e2e8f0;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95), 0 0 18px rgba(6, 10, 22, 0.9);
}
.search, .load-state, .load-state button { pointer-events: auto; }

.load-state {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
.load-state button {
  color: var(--blue-2);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(148, 163, 184, 0.3);
  border-top-color: var(--blue-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Ъгли ---------- */
.corner { position: fixed; z-index: 10; }
.tl { top: 18px; left: 18px; }
.tr { top: 18px; right: 18px; }
.bl { bottom: 18px; left: 18px; }
.br { bottom: 18px; right: 18px; }
.bc { bottom: 18px; left: 50%; transform: translateX(-50%); }

.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(10, 15, 29, 0.72);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.pill b { color: var(--text); font-size: 15px; }

.pill-discord { border-color: rgba(88, 101, 242, 0.45); background: rgba(30, 36, 92, 0.55); color: #c7d2fe; }
.pill-discord svg { width: 18px; height: 18px; color: #a5b4fc; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.dot-on { background: var(--green); box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }

.top-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(10, 15, 29, 0.72);
  border: 1px solid rgba(59, 130, 246, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-weight: 600;
  transition: border-color var(--t), background var(--t);
}
.top-btn svg { width: 17px; height: 17px; color: var(--gold); }
.top-btn:hover { border-color: var(--blue-2); background: rgba(30, 58, 138, 0.45); }

.zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(10, 15, 29, 0.72);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.zoom button {
  display: grid;
  place-items: center;
  height: 36px;
  min-width: 36px;
  border-radius: 9px;
  color: var(--text);
  transition: background var(--t);
}
.zoom button svg { width: 18px; height: 18px; }
.zoom button:hover { background: rgba(148, 163, 184, 0.12); }
.zoom .zoom-center { display: flex; gap: 8px; padding: 0 12px; font-weight: 600; }
.zoom .zoom-center svg { color: var(--blue-2); }

.credit {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 14px 0 5px;
  border-radius: 999px;
  background: rgba(10, 15, 29, 0.72);
  border: 1px solid var(--card-border);
  color: var(--muted);
  font-size: 13px;
}
.credit img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.credit strong { color: var(--text); font-weight: 700; }

/* ---------- Бутони ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, 0.06);
  text-decoration: none;
  white-space: nowrap;
  transition: border-color var(--t), background var(--t), color var(--t), transform var(--t);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { border-color: rgba(148, 163, 184, 0.4); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #1a1205; }
.btn-gold:hover:not(:disabled) { background: #fbbf24; border-color: #fbbf24; }
.btn-discord { color: var(--blue-2); border-color: rgba(59, 130, 246, 0.55); background: rgba(59, 130, 246, 0.12); }
.btn-discord:hover { background: rgba(59, 130, 246, 0.22); border-color: var(--blue-2); }
.btn-lg { height: 48px; font-size: 16px; padding: 0 22px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--muted);
  transition: color var(--t), background var(--t);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--text); background: rgba(148, 163, 184, 0.12); }
.icon-btn.ok { color: var(--green); }

/* ---------- Toast ---------- */
.toasts {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  font-weight: 600;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.toast.in { opacity: 1; transform: none; }
.toast svg { width: 16px; height: 16px; color: var(--green); }
.toast-err svg { color: var(--red); }

/* ---------- Телефон / тесни екрани (1:1 HUD без припокриване) ---------- */
.mobile-screen { display: none; }

@media (max-width: 820px) {
  html, body {
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .top {
    padding: calc(10px + env(safe-area-inset-top, 0px) + 42px) 12px 0;
  }
  .top::before {
    inset: 0 0 -44px 0;
  }
  .title {
    font-size: clamp(25px, 7vw, 36px);
  }
  .subtitle {
    margin-top: 5px;
    font-size: 13px;
    line-height: 1.35;
  }
  .tl { top: calc(10px + env(safe-area-inset-top, 0px)); left: 10px; }
  .tr { top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; }
  .bl { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); left: 10px; }
  .br { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); right: 10px; }

  .pill,
  .top-btn {
    height: 34px;
    padding: 0 11px;
    gap: 6px;
    font-size: 12px;
  }
  .pill b { font-size: 13.5px; }
  .top-btn svg { width: 15px; height: 15px; }

  .zoom {
    padding: 4px;
    gap: 2px;
    border-radius: 12px;
  }
  .zoom button {
    height: 32px;
    min-width: 32px;
    border-radius: 8px;
  }
  .zoom button svg { width: 16px; height: 16px; }
  .zoom .zoom-center {
    padding: 0 9px;
    gap: 5px;
    font-size: 12px;
  }

  .credit {
    height: 36px;
    padding: 0 11px 0 4px;
    gap: 7px;
    font-size: 11.5px;
  }
  .credit img { width: 26px; height: 26px; }

  .toasts {
    bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    width: max-content;
    max-width: calc(100vw - 24px);
  }
  .toast {
    padding: 9px 14px;
    font-size: 13px;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .top {
    padding-top: calc(10px + env(safe-area-inset-top, 0px) + 38px);
  }
  .title { font-size: clamp(23px, 6.8vw, 30px); }
  .subtitle { font-size: 12px; }
  .tl, .tr { max-width: calc(50vw - 14px); }
  .pill, .top-btn {
    height: 32px;
    padding: 0 9px;
    gap: 5px;
    font-size: 11px;
  }
  .pill b { font-size: 12.5px; }
  .zoom button { height: 30px; min-width: 30px; }
  .zoom .zoom-center { padding: 0 7px; gap: 4px; font-size: 11px; }
  .credit {
    height: 34px;
    padding: 0 9px 0 4px;
    gap: 6px;
    font-size: 10.5px;
    max-width: calc(100vw - 178px);
  }
  .credit span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .credit img { width: 24px; height: 24px; flex: none; }
}

.noscript { position: fixed; inset: auto 0 50% 0; text-align: center; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
