/* Hub + Login: постапокалипсис · ЗлоЙЙЙ · MaraderZ */
:root {
  --apoc-ash: #c9b59a;
  --apoc-ember: #ff6a2a;
  --apoc-rad: #9dff6a;
  --apoc-blood: #8b1e1e;
  --apoc-steel: #6a7a72;
}

body.gate-open {
  overflow-x: hidden;
  overflow-y: hidden; /* скролл внутри #hub / #gate */
  background: #0a0806;
  min-height: 100%;
  min-height: 100dvh;
  height: 100%;
  height: 100dvh;
  padding-bottom: 0;
}

/* ===== Stage / atmosphere ===== */
.apoc-stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: #0a0806;
}

.apoc-map {
  position: absolute;
  inset: -4%;
  width: 108%;
  height: 108%;
  object-fit: cover;
  filter: saturate(0.55) contrast(1.15) brightness(0.42) sepia(0.35);
  transform: scale(1.04);
  animation: apocMapDrift 28s ease-in-out infinite alternate;
}

@keyframes apocMapDrift {
  from { transform: scale(1.04) translate3d(-1%, -0.5%, 0); }
  to { transform: scale(1.08) translate3d(1.2%, 0.8%, 0); }
}

.apoc-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 35%, transparent 20%, rgba(0,0,0,0.55) 70%, rgba(0,0,0,0.88) 100%),
    linear-gradient(180deg, rgba(40,18,8,0.35) 0%, transparent 35%, rgba(8,6,4,0.75) 100%);
  z-index: 2;
}

.apoc-scan {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0.08;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.45) 3px
  );
  mix-blend-mode: multiply;
  animation: apocScan 8s linear infinite;
}

@keyframes apocScan {
  from { transform: translateY(0); }
  to { transform: translateY(12px); }
}

.apoc-noise {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  animation: apocNoise 0.35s steps(2) infinite;
}

@keyframes apocNoise {
  0% { transform: translate(0,0); }
  50% { transform: translate(-1%, 1%); }
  100% { transform: translate(1%, -1%); }
}

.apoc-embers {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
}

.apoc-embers span {
  position: absolute;
  bottom: -8%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffc48a 0%, var(--apoc-ember) 45%, transparent 70%);
  opacity: 0.55;
  animation: apocEmber linear infinite;
  filter: blur(0.2px);
}

.apoc-embers span:nth-child(1) { left: 8%; animation-duration: 11s; animation-delay: 0s; }
.apoc-embers span:nth-child(2) { left: 22%; animation-duration: 14s; animation-delay: 2s; width: 4px; height: 4px; }
.apoc-embers span:nth-child(3) { left: 41%; animation-duration: 10s; animation-delay: 1s; }
.apoc-embers span:nth-child(4) { left: 58%; animation-duration: 16s; animation-delay: 3.5s; }
.apoc-embers span:nth-child(5) { left: 73%; animation-duration: 12s; animation-delay: 0.8s; width: 5px; height: 5px; }
.apoc-embers span:nth-child(6) { left: 88%; animation-duration: 13s; animation-delay: 4s; }

@keyframes apocEmber {
  0% { transform: translate3d(0,0,0) scale(0.6); opacity: 0; }
  10% { opacity: 0.7; }
  100% { transform: translate3d(-30px, -110vh, 0) scale(1.2); opacity: 0; }
}

.apoc-rad-pulse {
  position: absolute;
  left: 50%;
  top: 18%;
  width: min(520px, 90vw);
  height: min(220px, 35vh);
  transform: translateX(-50%);
  z-index: 2;
  background: radial-gradient(ellipse at center, rgba(157,255,106,0.12), transparent 65%);
  animation: apocRad 5.5s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes apocRad {
  from { opacity: 0.35; filter: blur(8px); }
  to { opacity: 0.85; filter: blur(18px); }
}

/* wall photos still work if present */
.apoc-stage .wall-photo {
  z-index: 5;
  opacity: 0.72;
  filter: drop-shadow(0 12px 20px rgba(0,0,0,0.65)) sepia(0.25) contrast(1.05);
}
.apoc-stage .wall-brand { display: none; }
.apoc-stage .wall-dust { display: none; }
.apoc-stage .wall-veil { display: none; }

/* ===== Brand strip ===== */
.apoc-brand {
  position: relative;
  z-index: 2;
  text-align: center;
  margin: 0 0 18px;
  padding-top: 4px;
}

.apoc-brand .stamp {
  display: inline-block;
  margin: 0 0 6px;
  padding: 4px 12px;
  border: 1px dashed rgba(232,165,75,0.45);
  color: var(--apoc-rad);
  font-family: var(--font-stamp);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  transform: rotate(-1.5deg);
  background: rgba(0,0,0,0.25);
  animation: apocStampFlicker 4.2s steps(2) infinite;
}

@keyframes apocStampFlicker {
  0%, 92%, 100% { opacity: 1; }
  93% { opacity: 0.35; }
  95% { opacity: 1; }
  97% { opacity: 0.5; }
}

.apoc-brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.4rem, 10vw, 3.6rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand);
  text-shadow:
    0 0 24px rgba(255,106,42,0.35),
    0 2px 0 #3a1808,
    0 10px 28px rgba(0,0,0,0.65);
  line-height: 1.05;
}

.apoc-brand .byline {
  margin: 8px 0 0;
  font-family: var(--font-stamp);
  color: var(--apoc-ash);
  font-size: clamp(0.85rem, 2.8vw, 1rem);
  letter-spacing: 0.04em;
}

.apoc-brand .hunt {
  margin: 10px auto 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(139,30,30,0.55), rgba(80,20,10,0.35));
  border: 1px solid rgba(255,80,60,0.35);
  color: #ffd0c4;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  box-shadow: 0 0 18px rgba(255,60,40,0.18);
}

.apoc-brand .hunt img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(255,80,40,0.5));
}

.apoc-clans {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
}

.apoc-clans .clan {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 72px;
}

.apoc-clans .clan img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
  animation: apocClanPulse 3.8s ease-in-out infinite alternate;
}

.apoc-clans .clan.enemy img {
  filter: grayscale(0.35) drop-shadow(0 0 8px rgba(255,60,40,0.35));
  animation-delay: 0.6s;
}

@keyframes apocClanPulse {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-2px) scale(1.04); }
}

.apoc-clans .clan span {
  font-family: var(--font-stamp);
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.apoc-clans .vs {
  font-family: var(--font-display);
  color: var(--apoc-ember);
  letter-spacing: 0.2em;
  font-size: 0.85rem;
  text-shadow: 0 0 12px rgba(255,106,42,0.45);
}

/* ===== Panels ===== */
#hub.hub-page,
#gate {
  z-index: 20;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  place-items: start center;
  align-content: start;
}

#hub.hub-page.show {
  display: grid;
}

.hub-box,
.gate-box {
  width: min(640px, 100%);
  margin: 12px auto 20px;
  background:
    linear-gradient(165deg, rgba(48,36,26,0.88), rgba(18,13,10,0.94)),
    repeating-linear-gradient(135deg, transparent, transparent 10px, rgba(0,0,0,0.04) 11px);
  border: 1px solid rgba(232,165,75,0.28);
  border-radius: 6px;
  padding: 22px 18px 16px;
  box-shadow:
    0 24px 60px rgba(0,0,0,0.65),
    inset 0 1px 0 rgba(255,220,160,0.1),
    0 0 0 1px rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
}

.hub-box::before,
.gate-box::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, transparent 40%, rgba(255,180,80,0.05) 50%, transparent 60%);
  animation: apocSheen 7s ease-in-out infinite;
}

@keyframes apocSheen {
  0%, 100% { transform: translateX(-30%); opacity: 0; }
  40% { opacity: 1; }
  70% { transform: translateX(30%); opacity: 0; }
}

.hub-box > *,
.gate-box > * {
  position: relative;
  z-index: 1;
}

.hub-box .notif-chat-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 30;
  pointer-events: auto;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(232,165,75,0.45);
  color: var(--apoc-ash, #c9b59a);
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}
.hub-box .notif-chat-btn:hover {
  color: var(--brand, #e8a54b);
  border-color: rgba(255,106,42,0.55);
  background: rgba(20,12,8,0.75);
}

.hub-kicker {
  margin: 0 42px 4px 0;
  font-family: var(--font-stamp);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--apoc-rad);
}

.hub-box > h1,
.gate-box > h1 {
  margin: 0 42px 6px 0;
  font-size: clamp(1.35rem, 4.5vw, 1.7rem);
}

.hub-box .hub-sub,
.gate-box > p {
  margin: 0 0 14px;
}

/* ===== Hub cards with icons ===== */
.hub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hub-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
  text-align: left;
  background:
    linear-gradient(145deg, rgba(42,30,22,0.95), rgba(22,16,12,0.98));
  border: 1px solid rgba(74,58,44,0.95);
  color: var(--fg);
  border-radius: 6px;
  padding: 12px 12px;
  cursor: pointer;
  text-decoration: none;
  overflow: hidden;
  transition: border-color .18s, transform .18s, box-shadow .18s, background .18s;
}

.hub-card::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, rgba(232,165,75,0.12), transparent 70%);
  pointer-events: none;
}

.hub-card:hover,
.hub-card:focus-visible {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.4), 0 0 18px rgba(255,106,42,0.12);
  outline: none;
}

.hub-card:active {
  transform: translateY(0);
}

.hub-card .ico {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(232,165,75,0.18);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.hub-card .ico img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
  transition: transform .2s ease;
}

.hub-card:hover .ico img {
  transform: scale(1.08) rotate(-3deg);
}

.hub-card .txt {
  min-width: 0;
}

.hub-card strong {
  display: block;
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 2px;
  font-size: 0.95rem;
}

.hub-card span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-family: var(--font-stamp);
  line-height: 1.35;
}

.hub-card.admin-only .ico {
  box-shadow: inset 0 0 0 1px rgba(157,255,106,0.08);
}

.hub-card.is-disabled,
.hub-card.is-disabled:hover,
.hub-card.is-disabled:focus-visible,
.hub-card.is-disabled:active {
  opacity: 0.42;
  filter: grayscale(0.55);
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

body.viewer-role .hub-card.admin-only {
  border-style: dashed;
  opacity: 0.72;
}

.hub-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}

.hub-actions .ghost-link {
  color: var(--apoc-ash);
  text-decoration: none;
  font-family: var(--font-stamp);
  font-size: 0.82rem;
  border-bottom: 1px dotted rgba(201,181,154,0.4);
}

.hub-actions .ghost-link:hover {
  color: var(--brand);
}

.hub-foot {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(74,58,44,0.7);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-stamp);
  font-size: 0.68rem;
  color: var(--faint);
  letter-spacing: 0.04em;
}

.hub-foot .mark {
  color: var(--apoc-rad);
}

/* ===== Login gate extras ===== */
.gate-box {
  width: min(420px, 100%);
}

.gate-box .apoc-brand {
  margin-bottom: 16px;
}

.gate-box .apoc-brand h1 {
  font-size: clamp(2rem, 9vw, 2.8rem);
}

.gate-hazard {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px 10px;
  background: rgba(139,30,30,0.22);
  border: 1px solid rgba(255,80,60,0.28);
  font-family: var(--font-stamp);
  font-size: 0.78rem;
  color: #ffc8b8;
}

.gate-hazard img {
  width: 20px;
  height: 20px;
}

.gate-role label {
  transition: border-color .15s, background .15s, transform .15s;
}

.gate-role label:hover {
  border-color: rgba(232,165,75,0.55);
  transform: translateY(-1px);
}

.gate-box .row input {
  background: rgba(10,8,6,0.75);
  border-color: rgba(74,58,44,0.95);
}

.gate-box button#gateBtn {
  background: linear-gradient(180deg, #c9782e, #8a4a18);
  border: 1px solid #e8a54b;
  box-shadow: 0 0 16px rgba(255,106,42,0.2);
}

.gate-box button#gateBtn:hover {
  filter: brightness(1.08);
}

.gate-tools {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.gate-hard-reload {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(180, 150, 90, 0.45);
  background: rgba(18, 14, 10, 0.92);
  color: #e0d0b0;
  font: 600 12px/1 Oswald, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 4px;
  -webkit-tap-highlight-color: transparent;
}

.gate-hard-reload:hover,
.gate-hard-reload:focus-visible {
  border-color: rgba(232, 165, 75, 0.7);
  color: #ffe6a8;
  outline: none;
}

.gate-hard-reload:disabled {
  opacity: 0.65;
  cursor: wait;
}

.gate-hard-hint {
  font-family: var(--font-stamp);
  font-size: 0.72rem;
  color: var(--faint, #7a6a55);
  letter-spacing: 0.03em;
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
  #hub.hub-page,
  #gate {
    align-items: stretch;
    place-items: start stretch;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px calc(14px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .hub-box,
  .gate-box {
    width: 100%;
    max-height: none;
    margin: 0 auto 12px;
    padding: 14px 12px 12px;
  }

  .gate-box .apoc-brand {
    margin-bottom: 10px;
  }

  .gate-box .apoc-brand h1 {
    font-size: clamp(1.7rem, 8vw, 2.2rem);
    letter-spacing: 0.12em;
  }

  .gate-box .apoc-brand .byline {
    font-size: 0.8rem;
  }

  .gate-box .apoc-brand .hunt {
    margin-top: 8px;
    padding: 5px 10px;
    font-size: 0.65rem;
    letter-spacing: 0.06em;
  }

  .gate-box > h1 {
    margin: 0 0 4px;
    font-size: 1.2rem;
  }

  .gate-box > p {
    margin: 0 0 10px;
    font-size: 0.85rem;
  }

  .gate-hazard {
    margin-bottom: 10px;
    padding: 7px 9px;
    font-size: 0.72rem;
  }

  .gate-role {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 8px 0 12px;
  }

  .gate-role label {
    min-height: 44px;
    justify-content: center;
    padding: 8px 6px;
    font-size: 0.85rem;
  }

  .gate-box .row {
    display: grid;
    gap: 8px;
  }

  .gate-box .row input,
  .gate-box .row button#gateBtn {
    width: 100%;
    min-height: 46px;
    font-size: 16px; /* iOS: без автозума */
  }

  .gate-tools {
    margin-top: 10px;
    flex-direction: column;
    align-items: stretch;
  }

  .gate-hard-reload {
    width: 100%;
    min-height: 44px;
  }

  .gate-hard-hint {
    text-align: center;
  }

  .hub-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .hub-card {
    grid-template-columns: 44px 1fr;
    padding: 11px 10px;
    min-height: 64px;
  }

  .hub-card .ico {
    width: 44px;
    height: 44px;
  }

  .hub-card .ico img {
    width: 30px;
    height: 30px;
  }

  .apoc-clans .clan img {
    width: 36px;
    height: 36px;
  }

  .apoc-stage .wall-photo.p5,
  .apoc-stage .wall-photo.p7,
  .apoc-stage .wall-photo.p2 {
    display: none;
  }

  .apoc-brand .hunt {
    letter-spacing: 0.08em;
    font-size: 0.7rem;
  }

  .hub-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hub-actions .ghost,
  .hub-actions button {
    width: 100%;
    min-height: 44px;
  }

  .hub-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

@media (max-width: 380px) {
  .apoc-brand h1 {
    letter-spacing: 0.1em;
  }
  .hub-card strong {
    font-size: 0.88rem;
  }
  .gate-role {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .apoc-map,
  .apoc-scan,
  .apoc-noise,
  .apoc-embers span,
  .apoc-rad-pulse,
  .hub-box::before,
  .gate-box::before,
  .apoc-brand .stamp,
  .apoc-clans .clan img {
    animation: none !important;
  }
}
