:root {
  --motion-instant: 100ms;
  --motion-fast: 160ms;
  --motion-base: 220ms;
  --motion-slow: 300ms;
  --ease-standard: cubic-bezier(.2, 0, 0, 1);
  --ease-enter: cubic-bezier(.16, 1, .3, 1);
  --ease-exit: cubic-bezier(.4, 0, 1, 1);
  --ease-emphasized: cubic-bezier(.2, .8, .2, 1);
}

:where(.button, button, .card, [role="button"], .nav-link) {
  transition-property: color, background-color, border-color, box-shadow, opacity, transform;
  transition-duration: var(--motion-fast);
  transition-timing-function: var(--ease-standard);
}

:where(.button, button, .card, [role="button"]):active {
  transform: translateY(1px) scale(.99);
  transition-duration: var(--motion-instant);
}

.stage2-home-hero {
  min-height: 540px;
  max-height: 680px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr);
  align-items: stretch;
  overflow: clip;
  border: 1px solid rgba(190, 112, 105, .22);
  border-radius: 16px;
  background: #100d0d;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

.stage2-home-copy {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 3.4vw, 52px);
  background: linear-gradient(90deg, #110e0e 72%, rgba(17, 14, 14, .76));
}

.stage2-home-kicker {
  margin: 0 0 16px;
  color: #d58e86;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.stage2-home-copy h1 {
  max-width: 660px;
  font-size: clamp(36px, 3.2vw, 52px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.025em;
}

.stage2-home-copy .stage2-home-lead {
  max-width: 610px;
  margin: 24px 0 0;
  color: #d2c7c5;
  font-size: clamp(17px, 1.3vw, 20px);
  line-height: 1.55;
}

.stage2-home-difference {
  max-width: 570px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.stage2-home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.hero-explore { margin-top: 28px; }
.hero-explore-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.hero-explore-head h2 { font-size: 15px; font-weight: 650; letter-spacing: -.015em; }
.hero-map-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 10px 6px 8px;
  border: 1px solid rgba(213, 142, 134, .28);
  border-radius: 10px;
  color: #dbc9c6;
  background: rgba(213, 142, 134, .07);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  transition: transform var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard);
}
.hero-map-compass {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
}
.hero-map-link:hover,
.hero-map-link:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(223, 143, 134, .55);
  color: #fff;
  background: rgba(213, 142, 134, .13);
  outline: none;
}
.hero-map-link:focus-visible { box-shadow: 0 0 0 3px rgba(213, 142, 134, .2); }
.hero-map-link:active { transform: translateY(1px); background: rgba(213, 142, 134, .17); }
.hero-explore-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.hero-explore-card {
  --explore-accent: #d58e86;
  min-width: 0;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--explore-accent) 25%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--explore-accent) 7%, rgba(255,255,255,.015));
  transition: transform var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard), box-shadow var(--motion-fast) var(--ease-standard);
}
.hero-explore-card:hover, .hero-explore-card:focus-visible { transform: translateY(-2px); border-color: color-mix(in srgb, var(--explore-accent) 46%, transparent); background: color-mix(in srgb, var(--explore-accent) 11%, rgba(255,255,255,.02)); box-shadow: 0 8px 20px rgba(0,0,0,.18); outline: none; }
.hero-explore-card:active { transform: translateY(1px) scale(.99); }
.hero-explore-town { --explore-accent: #dfb05f; }
.hero-explore-nation { --explore-accent: #72b8df; }
.hero-explore-people { --explore-accent: #70c69b; }
.hero-explore-online { --explore-accent: #8dd070; }
.hero-explore-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: var(--explore-accent); background: color-mix(in srgb, var(--explore-accent) 12%, transparent); }
.hero-explore-icon .icon { width: 18px; height: 18px; }
.hero-explore-card > span:last-child { min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: baseline; gap: 8px; flex: 1; }
.hero-explore-card small { color: #cbbfbd; font-size: 12px; }
.hero-stat-value { min-width: 2ch; color: #fff; font-size: 17px; font-variant-numeric: tabular-nums; text-align: right; }
.hero-stat-value.is-loading { color: transparent; border-radius: 4px; background: linear-gradient(90deg, rgba(255,255,255,.06), rgba(255,255,255,.14), rgba(255,255,255,.06)); background-size: 200% 100%; animation: hero-stat-shimmer 1.4s linear infinite; }
@keyframes hero-stat-shimmer { to { background-position: -200% 0; } }

.stage2-ip-button {
  min-height: 48px;
  gap: 12px;
}

.stage2-ip-button code {
  color: inherit;
  font-size: 13px;
}

.stage2-home-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 30px;
  color: var(--muted);
  font-size: 13px;
}

.stage2-home-meta strong { color: var(--text); }

.stage2-home-visual {
  position: relative;
  min-width: 0;
  aspect-ratio: auto;
  background: #171111;
}

.stage2-home-hero > .stage2-home-visual.home-news-slider {
  width: 100%;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  align-self: stretch;
}

.stage2-home-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #110e0e 0, transparent 24%), linear-gradient(0deg, rgba(5, 4, 4, .26), transparent 40%);
  pointer-events: none;
}

.stage2-home-visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.stage2-home-visual > picture { display: block; width: 100%; height: 100%; }
.stage2-home-visual .home-news-active,
body.compact-ui .stage2-home-visual .home-news-active {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100% !important;
  min-height: 100% !important;
  max-height: none !important;
  border: 0;
  border-radius: 0;
}
.stage2-home-visual .home-news-active-media { inset: 0; width: 100%; height: 100%; }
.stage2-home-visual .home-news-active-overlay {
  inset: 0;
  width: auto;
  height: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding: 38px 28px 72px 112px !important;
  text-align: right;
  background: linear-gradient(270deg, rgba(7, 6, 6, .82) 0%, rgba(7, 6, 6, .55) 48%, rgba(7, 6, 6, 0) 88%);
}
.stage2-home-visual .home-news-active h1,
.stage2-home-visual .home-news-active h2 { font-size: clamp(24px, 2.5vw, 38px); }
.stage2-home-visual .home-news-active .lead { max-width: 48ch; margin-left: auto; font-size: 14px; }
.stage2-home-visual .home-news-active .badge { align-self: flex-end; }
.stage2-home-visual .home-news-dots { z-index: 5; right: 28px; left: auto; transform: none; }

@media (min-width: 1024px) {
  .stage2-home-hero { height: 640px; min-height: 640px; max-height: 640px; }
}

.home-directions { display: grid; grid-template-columns: 180px minmax(0,1fr); gap: 18px; margin-top: 16px; padding: 18px; border: 1px solid rgba(190,112,105,.14); border-radius: 14px; background: rgba(15,12,12,.72); }
.home-directions-head p { margin: 0 0 5px; color: #c3837c; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.home-directions-head h2 { font-size: 22px; }
.home-directions-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.home-direction { --direction-accent: #d58e86; min-width: 0; display: grid; grid-template-columns: 34px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: inherit; background: rgba(255,255,255,.018); transition: transform var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard); }
.home-direction:hover, .home-direction:focus-visible { transform: translateY(-2px); background: color-mix(in srgb, var(--direction-accent) 9%, rgba(255,255,255,.02)); outline: 1px solid color-mix(in srgb, var(--direction-accent) 35%, transparent); }
.home-direction-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; color: var(--direction-accent); background: color-mix(in srgb, var(--direction-accent) 10%, transparent); }
.home-direction strong, .home-direction small { display: block; }
.home-direction strong { font-size: 13px; }
.home-direction small { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.home-direction-town { --direction-accent: #dfb05f; }.home-direction-nation { --direction-accent: #72b8df; }.home-direction-economy { --direction-accent: #70c69b; }.home-direction-war { --direction-accent: #d97b76; }

body[data-page="home"] .page[data-page="home"] > .hero { display: none; }

body[data-page="home"] .page[data-page="home"].active {
  display: flex;
  flex-direction: column;
}

body[data-page="home"] .stage2-home-hero { order: 1; }
body[data-page="home"] .home-world-layout { order: 2; }
body[data-page="home"] .home-world-columns { order: 3; }
body[data-page="home"] .home-directions { order: 4; }
body[data-page="home"] .home-start-panel { order: 5; }
body[data-page="home"] .wiki-section { order: 6; }
body[data-page="home"] .home-shops-compact { order: 7; }

body[data-page="home"] .home-world-layout { margin-top: 18px; }
body[data-page="home"] .wiki-section .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
body[data-page="home"] .wiki-section .card:nth-child(n + 7) { display: none; }

.cookie-consent {
  inset: auto 16px 16px auto;
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  transform: translateY(10px);
  animation: stage2-enter var(--motion-base) var(--ease-enter) forwards;
}

.cookie-consent-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 16px;
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,.48);
}

.cookie-consent-copy { display: block; }
.cookie-consent-icon, .cookie-consent-settings, .cookie-consent-toggle small { display: none; }
.cookie-consent h2 { font-size: 17px; }
.cookie-consent p { margin-top: 5px; font-size: 12px; line-height: 1.4; }
.cookie-consent-actions { padding: 0; border: 0; background: none; align-self: center; }
.cookie-consent-action-buttons { display: grid; grid-template-columns: 1fr; min-width: 146px; }
.cookie-consent-action-buttons .button { min-height: 36px; }
.cookie-consent-link { font-size: 11px; }

@keyframes stage2-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ui-toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.ui-toast {
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 14px;
  border: 1px solid rgba(190, 112, 105, .3);
  border-radius: 10px;
  color: var(--text);
  background: rgba(18, 14, 14, .96);
  box-shadow: 0 14px 38px rgba(0,0,0,.38);
  animation: stage2-enter var(--motion-base) var(--ease-enter) both;
}

.is-refreshing { opacity: .64; pointer-events: none; }
.is-refreshing::after { content: "Обновляем…"; position: absolute; inset: 12px 12px auto auto; color: var(--muted); font-size: 12px; }

.public-profile-page {
  --profile-gap: 14px;
  gap: var(--profile-gap);
}

.public-profile-hero {
  min-height: 220px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: end;
  padding: clamp(24px, 4vw, 46px);
  overflow: clip;
  border-radius: 16px;
}

.public-profile-hero-copy h1 { font-size: clamp(34px, 4vw, 58px); font-weight: 650; letter-spacing: -.04em; }
.public-profile-meta-row { max-width: 850px; }
.public-profile-grid { grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: var(--profile-gap); }
.public-profile-panel { padding: 24px; }
.public-profile-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.public-profile-metrics > div:first-child { grid-column: span 2; background: rgba(133, 75, 70, .12); }
.public-profile-empty, .event-feed-empty { min-height: 0; padding: 18px; }
.public-profile-unavailable { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 0; padding: 14px 18px; }

.store-product-grid { grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); gap: 14px; }
.store-product-card { overflow: clip; border-radius: 14px; }
.store-product-media { position: relative; aspect-ratio: 16 / 10; min-height: 0; background: radial-gradient(circle at 50% 35%, rgba(195, 105, 90, .18), transparent 42%), #0c0b0b; }
.store-product-media-empty::before {
  content: "";
  position: absolute;
  inset: 18% 24%;
  border: 1px solid rgba(205, 130, 111, .2);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(130, 65, 60, .18), rgba(20, 17, 17, .3));
  transform: rotate(-4deg);
}
.store-product-card:nth-child(3n + 2) .store-product-media-empty { background: radial-gradient(circle at 52% 38%, rgba(98, 126, 178, .2), transparent 44%), #0c0b0b; }
.store-product-card:nth-child(3n) .store-product-media-empty { background: radial-gradient(circle at 52% 38%, rgba(180, 132, 69, .2), transparent 44%), #0c0b0b; }
.store-product-body { display: flex; flex-direction: column; min-height: 250px; }
.store-product-footer { margin-top: auto; }
.store-product-card:hover { transform: translateY(-2px); border-color: rgba(209, 129, 114, .42); box-shadow: 0 18px 34px rgba(0,0,0,.28); }
.store-status:empty, .store-status[hidden] { display: none; }

.wiki-mobile-toc-toggle { display: none; width: 100%; margin: 0 0 12px; justify-content: space-between; }
.wiki-content :is(h2,h3,h4) { scroll-margin-top: calc(var(--topbar-height) + 18px); }

.market-secondary-toggle { display: inline-flex; margin-top: 8px; }
.market-filter-bottom { transform-origin: top; transition: opacity var(--motion-fast) var(--ease-standard), transform var(--motion-fast) var(--ease-enter); }
.market-filter-bottom[hidden] { display: none; }
.market-dashboard[data-state="loading"] .market-empty-state:not(.loading),
.market-dashboard[data-state="error"] .market-empty-state.loading,
.market-dashboard[data-state="empty"] .market-empty-state.loading,
.market-dashboard[data-state="success"] .market-empty-state { display: none !important; }

@media (max-width: 1023px) {
  .stage2-home-hero { grid-template-columns: 1fr; min-height: 0; max-height: none; }
  .stage2-home-copy { padding: 36px 28px; }
  .stage2-home-hero > .stage2-home-visual.home-news-slider { order: 2; width: 100%; max-width: 100%; min-width: 0; height: clamp(200px, 31vw, 280px) !important; min-height: 0 !important; max-height: 280px !important; align-self: auto; aspect-ratio: auto; }
  .stage2-home-visual::after { background: linear-gradient(0deg, #110e0e 0, transparent 48%); }
  .home-directions { grid-template-columns: 1fr; }
  .public-profile-grid { grid-template-columns: 1fr; }
  .wiki-mobile-toc-toggle { display: flex; }
  .doc-grid:has(.wiki-content) { display: flex; flex-direction: column; }
  .doc-grid:has(.wiki-content) .toc { order: -1; }
  .doc-grid:has(.wiki-content) .toc:not(.is-open) .toc-link { display: none; }
}

@media (max-width: 600px) {
  .topbar-actions .topbar-report-link { display: none; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 6px; padding-inline: 10px; }
  .topbar-breadcrumb { min-width: 0; }
  .topbar-server-group { min-width: 0; }
  .topbar-server-copy { max-width: 128px; }
  .topbar-server-copy span:not(.server-status-dot) { display: block; overflow: hidden; text-overflow: ellipsis; }

  .stage2-home-copy { padding: 22px 16px 24px; }
  .stage2-home-copy h1 { font-size: clamp(36px, 11vw, 46px); }
  .stage2-home-copy .stage2-home-lead { font-size: 17px; }
  .stage2-home-difference { display: none; }
  .stage2-home-actions { margin-top: 20px; }
  .stage2-home-actions { display: grid; grid-template-columns: 1fr; }
  .stage2-home-actions .button { width: 100%; }
  .stage2-home-meta { gap: 12px; }
  .hero-explore { margin-top: 22px; }
  .hero-explore-head { align-items: center; }
  .hero-map-link { min-height: 34px; padding: 5px 8px; font-size: 11px; }
  .hero-map-compass { width: 19px; height: 19px; }
  .hero-explore-card { min-height: 58px; padding: 8px; gap: 7px; }
  .hero-explore-icon { width: 30px; height: 30px; }
  .hero-explore-card small { font-size: 11px; }
  .hero-stat-value { font-size: 15px; }
  .stage2-home-hero > .stage2-home-visual.home-news-slider { height: clamp(160px, 46vw, 190px) !important; min-height: 0 !important; max-height: 190px !important; }
  .stage2-home-visual .home-news-active-overlay {
    align-items: flex-start;
    justify-content: flex-end;
    padding: 14px 14px 42px !important;
    text-align: left;
    background: linear-gradient(0deg, rgba(7, 6, 6, .86) 0%, rgba(7, 6, 6, .28) 66%, transparent 100%);
    opacity: 1;
  }
  .stage2-home-visual .home-news-active .badge { align-self: flex-start; }
  .stage2-home-visual .home-news-dots { right: 12px; }
  .stage2-home-visual .home-news-active h1,
  .stage2-home-visual .home-news-active h2 { font-size: 20px; }
  .stage2-home-visual .home-news-active .lead { display: none; }
  .home-directions { padding: 14px; }
  .home-directions-grid { grid-template-columns: 1fr; }
  .home-direction small { white-space: normal; }
  body[data-page="home"] .wiki-section .grid { grid-template-columns: 1fr; }
  body[data-page="home"] .wiki-section .card:nth-child(n + 4) { display: none; }

  .cookie-consent { right: 8px; bottom: 8px; width: calc(100vw - 16px); }
  .cookie-consent-card { grid-template-columns: 1fr; gap: 10px; padding: 13px; }
  .cookie-consent h2 { font-size: 15px; }
  .cookie-consent p { max-width: 46ch; }
  .cookie-consent-action-buttons { grid-template-columns: 1fr 1fr; }
  .cookie-consent-settings { display: none !important; }
  .ui-toast-stack { right: 8px; bottom: 8px; }
  .public-profile-hero { min-height: 0; grid-template-columns: 1fr; padding: 20px; }
  .public-profile-hero-copy h1 { font-size: 36px; }
  .public-profile-metrics { grid-template-columns: 1fr; }
  .public-profile-metrics > div:first-child { grid-column: auto; }
  .store-product-grid { grid-template-columns: 1fr; }
  .store-product-body { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-instant: 1ms;
    --motion-fast: 1ms;
    --motion-base: 1ms;
    --motion-slow: 1ms;
  }
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  :where(.button, button, .card, [role="button"]):active { transform: none; }
  .hero-stat-value.is-loading { animation: none; background: rgba(255,255,255,.08); }
}

.cookie-consent.cookie-consent-mode-settings {
  inset: 0;
  display: grid;
  width: auto;
  padding: 16px;
  place-items: center;
  overflow-y: auto;
  background: rgba(3, 2, 2, 0.72);
}

.cookie-consent-mode-settings .cookie-consent-card {
  width: min(760px, 100%);
  max-height: calc(100dvh - 32px);
  grid-template-columns: 1fr;
  overflow-y: auto;
}

.cookie-consent-mode-settings .cookie-consent-settings {
  display: grid !important;
}

.cookie-consent-mode-settings .cookie-consent-toggle small {
  display: block;
}

@media (max-width: 640px) {
  .cookie-consent.cookie-consent-mode-settings {
    right: 0;
    bottom: 0;
    width: auto;
    padding: 8px;
  }

  .cookie-consent-mode-settings .cookie-consent-settings {
    grid-template-columns: 1fr;
  }

  .cookie-consent-mode-settings .cookie-consent-toggle {
    min-height: 0;
  }
}
