:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #0f141d;
  color: #f1f3f6;
  --muted: #aab4c4;
  --subtle: #8e9aaf;
  --line: #273142;
  --surface: #161e2a;
  --surface-hover: #1c2635;
  --gold: #ffc578;
  --mono: "Cascadia Mono", Consolas, monospace;

  /* Brand / Platform colors */
  --c-telegram: #29b6f6;
  --c-discord: #818cf8;
  --c-youtube: #f87171;
  --c-android: #4ade80;
  --c-ios: #e2e8f0;
  --c-widget: #fbbf24;
  --c-web: #60a5fa;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

.wrap { width: min(1220px, calc(100% - 48px)); margin-inline: auto; }
.sr-only, .icon-defs {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Header */
.site-header { border-bottom: 1px solid #222c3b; background: rgba(15, 20, 29, 0.9); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 100; }
.header-inner { display: flex; justify-content: space-between; align-items: center; min-height: 68px; gap: 16px; }
.brand { display: inline-flex; gap: 11px; align-items: center; font-weight: 750; font-size: 1.05rem; letter-spacing: -.02em; }
.brand strong { color: var(--gold); }

.header-nav { display: flex; align-items: center; gap: 18px; }
.bot-contact-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 8px;
  background: rgba(41, 182, 246, 0.08);
  border: 1px solid rgba(41, 182, 246, 0.28);
  color: #7dd3fc;
  font-size: .83rem;
  font-weight: 600;
  font-family: var(--mono);
  transition: all .15s ease;
}
.bot-contact-badge:hover {
  background: rgba(41, 182, 246, 0.18);
  border-color: #38bdf8;
  color: #fff;
  transform: translateY(-1px);
}
.bot-contact-badge .icon { width: 15px; height: 15px; }

.nav-about { color: var(--muted); font-size: .88rem; font-weight: 550; padding: 6px 4px; transition: color .15s ease; }
.nav-about:hover { color: #fff; }

/* Hero */
.hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: 330px;
  margin-top: 26px;
  overflow: hidden;
  padding: clamp(28px, 4.5vw, 56px);
  border: 1px solid #363028;
  border-radius: 20px;
  background: radial-gradient(ellipse at 78% 45%, #30241a, #1d1d21 42%, #141a24 75%);
}
.hero-copy { position: relative; z-index: 1; max-width: 630px; }
.hero-kicker, .eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 650 .72rem/1.4 var(--mono);
  letter-spacing: .12em;
  color: var(--gold);
}
.hero-kicker > span, .eyebrow > span {
  width: 7px;
  height: 7px;
  flex: none;
  transform: rotate(45deg);
  border-radius: 1px;
  background: currentColor;
}
.hero h1 {
  margin-top: 10px;
  font-size: clamp(2.8rem, 6.2vw, 4.8rem);
  font-weight: 850;
  line-height: 1.05;
  letter-spacing: -.065em;
}
.hero h1 em { font-style: normal; color: var(--gold); }
.hero-description { max-width: 500px; margin-top: 16px; color: #b8c1ce; font-size: 1.02rem; line-height: 1.55; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 20px 24px; margin-top: 26px; }
.primary-button, .secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  border-radius: 9px;
  padding: 10px 18px;
  font-size: .88rem;
  font-weight: 700;
  transition: all .15s ease;
}
.primary-button { background: var(--gold); color: #21170d; box-shadow: 0 3px 18px rgba(219, 152, 51, 0.2); }
.primary-button:hover { background: #ffd79f; transform: translateY(-1px); }
.primary-button .icon { width: 16px; height: 16px; }

.hero-stats { display: flex; align-items: center; gap: 16px; }
.hero-stats span { display: grid; gap: 1px; color: #a6b0bf; font-size: .72rem; line-height: 1.15; }
.hero-stats span + span { padding-left: 16px; border-left: 1px solid #3c3836; }
.hero-stats strong { color: #f8e2bf; font: 750 1.15rem/1.1 var(--mono); }
.hero-visual { position: absolute; inset: 0 0 0 auto; display: grid; width: min(52%, 580px); place-items: center; }
.hero-visual img { width: 100%; height: auto; }
.map-label {
  position: absolute;
  right: 22px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c99f73;
  font: .64rem var(--mono);
  letter-spacing: .13em;
}
.map-label span { width: 16px; height: 1px; background: #a67c52; }

/* Catalog Section */
.catalog { padding: 40px 0 36px; scroll-margin-top: 30px; }
.catalog-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px 24px; }
.catalog-heading h2 {
  margin: 6px 0;
  font-size: clamp(1.8rem, 3.8vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -.045em;
  line-height: 1.15;
}
.catalog-heading p:not(.eyebrow) { color: var(--muted); font-size: .94rem; line-height: 1.5; }

/* Search Bar (Clean & Elegant) */
.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(380px, 100%);
  min-height: 46px;
  padding-inline: 14px 8px;
  border: 1px solid #323d4f;
  border-radius: 10px;
  background: #131923;
  color: var(--muted);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search:focus-within { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 3px 12px rgba(0,0,0,0.3); }
.search-icon { width: 18px; height: 18px; color: #8290a4; flex-shrink: 0; }
.search input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f1f3f6;
  font-size: .92rem;
}
.search input::placeholder { color: #768498; }
.search input::-webkit-search-cancel-button { display: none; }

.clear-search {
  display: grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
}
.clear-search:hover { background: #222d3d; color: #fff; }

/* Toolbar & Dropdown Filters */
.catalog-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 18px 0 24px;
}

.filters-dropdown-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 18px;
}

.select-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-label {
  font: 700 .74rem var(--mono);
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.select-box {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.select-box select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  min-height: 40px;
  padding: 0 36px 0 13px;
  border: 1px solid #2e394b;
  border-radius: 9px;
  background: #141b25;
  color: #f1f3f6;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.select-box select:hover {
  border-color: #50617a;
  background: #17212e;
}

.select-box select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 3px 10px rgba(0,0,0,0.3);
}

.select-box select.has-value {
  border-color: #996733;
  background: #241c15;
  color: var(--gold);
}

.select-box select option {
  background: #141b25;
  color: #f1f3f6;
}

.select-box .chevron-icon {
  position: absolute;
  right: 11px;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: #8290a4;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  transition: transform .15s ease, stroke .15s ease;
}

.select-box select:focus + .chevron-icon {
  stroke: var(--gold);
}

.reset-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px dashed #3a475c;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}

.reset-filter-btn:hover {
  border-color: #ef4444;
  color: #f87171;
  background: rgba(239, 68, 68, 0.08);
}
.reset-filter-btn .icon {
  width: 13px;
  height: 13px;
}

.icon-tg { color: var(--c-telegram); }
.icon-ds { color: var(--c-discord); }
.icon-yt { color: var(--c-youtube); }
.icon-and { color: var(--c-android); }
.icon-ios { color: var(--c-ios); }

.result-count { color: var(--subtle); font: .76rem var(--mono); }

/* ==========================================
   CARDS GRID & HOMOGENEOUS CARD DESIGN
   ========================================== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 16px;
}

.card {
  --cat-accent: #ffc578;
  --cat-bg: #291f16;
  --cat-line: #523b24;

  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: transform .15s ease, border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #4b5a70;
  background: var(--surface-hover);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35);
}

/* Category Accent Styles */
.card[data-category="bases"] { --cat-accent: #86efac; --cat-bg: #15291b; --cat-line: #275232; }
.card[data-category="scout"] { --cat-accent: #38bdf8; --cat-bg: #102434; --cat-line: #1d4e70; }
.card[data-category="bots"] { --cat-accent: #2dd4bf; --cat-bg: #112624; --cat-line: #1d524e; }
.card[data-category="wars"] { --cat-accent: #fb923c; --cat-bg: #2b1b14; --cat-line: #543122; }
.card[data-category="raids"] { --cat-accent: #facc15; --cat-bg: #2d2612; --cat-line: #57481b; }
.card[data-category="attack"] { --cat-accent: #ffc578; --cat-bg: #291f16; --cat-line: #523b24; }
.card[data-category="upgrade"] { --cat-accent: #93c5fd; --cat-bg: #162438; --cat-line: #294870; }
.card[data-category="tools"] { --cat-accent: #d8b4fe; --cat-bg: #241c33; --cat-line: #4a3869; }
.card[data-category="creative"] { --cat-accent: #f472b6; --cat-bg: #2e1724; --cat-line: #5e2844; }
.card[data-category="wiki"] { --cat-accent: #fde047; --cat-bg: #292415; --cat-line: #544820; }

.card[data-top="true"] {
  border-color: #483d30;
}

/* 1. Header */
.card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.card-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--cat-line);
  border-radius: 10px;
  background: var(--cat-bg);
  color: var(--cat-accent);
  flex-shrink: 0;
}
.card-icon .icon { width: 20px; height: 20px; }

.card-title-wrap {
  flex: 1;
  min-width: 0;
}
.card-title {
  font-size: 1.05rem;
  font-weight: 750;
  line-height: 1.25;
  color: #fff;
  letter-spacing: -.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-subtitle {
  display: block;
  margin-top: 3px;
  font-size: .74rem;
  color: var(--subtle);
  font-weight: 550;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 5px;
  background: #242c38;
  border: 1px solid #3d4a5c;
  color: #ccd6e4;
  font-size: .68rem;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
}
.card-badge.is-top-badge {
  background: #332415;
  border-color: #694520;
  color: #ffc578;
}

/* 2. Platforms Row */
.card-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}
.platform-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: .68rem;
  font-weight: 650;
  line-height: 1.2;
}
.platform-pill .icon { width: 12px; height: 12px; }

.platform-pill.badge-telegram { background: #122838; color: #7dd3fc; border: 1px solid #1a4966; }
.platform-pill.badge-discord { background: #1c2038; color: #c7d2fe; border: 1px solid #373e6b; }
.platform-pill.badge-youtube { background: #2c1618; color: #fca5a5; border: 1px solid #61272b; }
.platform-pill.badge-android { background: #142a1b; color: #86efac; border: 1px solid #235930; }
.platform-pill.badge-ios { background: #1e2633; color: #f1f5f9; border: 1px solid #3c4a5f; }
.platform-pill.badge-widget { background: #2d2112; color: #fde68a; border: 1px solid #5e431f; }
.platform-pill.badge-web { background: #142436; color: #93c5fd; border: 1px solid #23476e; }
.platform-pill.badge-pwa { background: #142b29; color: #5eead4; border: 1px solid #225954; }

/* 3. Description */
.card-description {
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.48;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 4. Tags */
.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: auto;
  margin-bottom: 14px;
}
.tag-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: #121822;
  border: 1px solid #242e3d;
  color: #8c98ab;
  font-size: .68rem;
  font-weight: 550;
}

/* 5. Footer and Buttons */
.card-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid #222b38;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-stores {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2px;
}
.primary-card-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 9px;
  background: #1e2736;
  border: 1px solid #354357;
  color: #fff;
  font-size: .85rem;
  font-weight: 650;
  transition: all .14s ease;
}
.primary-card-btn:hover {
  background: #273448;
  border-color: #556784;
  color: var(--cat-accent);
}
.primary-card-btn .icon { width: 14px; height: 14px; color: var(--cat-accent); }

.store-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: .72rem;
  font-weight: 600;
  background: #141b25;
  border: 1px solid #2d3848;
  color: #b0bccd;
  transition: all .14s ease;
}
.store-btn:hover {
  background: #1f2a3a;
  color: #fff;
}
.store-btn .icon { width: 12px; height: 12px; }
.store-btn.store-android:hover { color: #86efac; border-color: #2b703e; }
.store-btn.store-ios:hover { color: #f1f5f9; border-color: #64748b; }
.store-btn.store-discord:hover { color: #c7d2fe; border-color: #434e80; }

.empty {
  padding: 44px 18px;
  text-align: center;
  border: 1px dashed #3a475a;
  border-radius: 14px;
  color: var(--muted);
}
.empty h3 { margin: 8px 0; color: #f1f3f6; }
.empty .icon { color: var(--gold); }
.secondary-button { margin-top: 16px; background: #1c2635; border: 1px solid #37475d; }
.secondary-button:hover { background: #243245; }

/* Footer */
.site-footer { border-top: 1px solid #212a37; margin-top: auto; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding-block: 28px 36px; }
.footer-brand-wrap { max-width: 520px; }
.footer-brand-wrap p { margin-top: 6px; color: var(--muted); font-size: .84rem; line-height: 1.55; }
.footer-bot-note { color: #94a3b8; font-size: .82rem; margin-top: 6px; }
.footer-bot-note a { color: #38bdf8; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

.footer-actions { flex-shrink: 0; }
.back-to-top {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border-radius: 9px;
  background: #18212e;
  border: 1px solid #2e3a4d;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 600;
  transition: all .15s ease;
}
.back-to-top:hover {
  background: #232e3f;
  border-color: #4c5e78;
  color: #fff;
  transform: translateY(-2px);
}
.back-to-top .icon { width: 15px; height: 15px; }

/* Responsive */
@media (max-width: 1050px) {
  .hero { padding-left: clamp(24px, 4vw, 44px); }
  .hero h1 { font-size: clamp(2.9rem, 6.8vw, 4.4rem); }
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 870px) {
  .wrap { width: calc(100% - 36px); }
  .hero { min-height: 290px; }
  .hero-description { max-width: 380px; }
  .hero-visual { right: -6%; opacity: .7; }
  .map-label { display: none; }
  .filters-dropdown-bar { gap: 10px 14px; }
}

@media (max-width: 650px) {
  .wrap { width: calc(100% - 28px); }
  .header-inner { min-height: 60px; }
  .hero { margin-top: 16px; padding: 24px 18px; border-radius: 16px; }
  .hero h1 { font-size: clamp(2.4rem, 9.2vw, 3.4rem); }
  .hero-description { max-width: 320px; font-size: .95rem; }
  .hero-visual { display: none; }
  .hero-actions { gap: 14px; margin-top: 20px; }
  .hero-stats { gap: 10px; }
  .hero-stats span + span { padding-left: 10px; }
  .catalog-heading { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
  .cards-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

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