:root {
  --bg: #07090d;
  --ink: #f3f6fb;
  --muted: #8b97ab;
  --line: rgba(255, 255, 255, 0.08);
  --panel: rgba(12, 16, 24, 0.72);
  --teal: #2fe0c8;
  --sand: #efb56a;
  --rose: #ff7a8a;
  --font: "Outfit", sans-serif;
  --display: "Syne", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --pad-x: clamp(16px, 4vw, 40px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100%;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
#root {
  position: relative;
  z-index: 1;
  min-height: 100%;
  min-height: 100dvh;
}

/* Atmosphere */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(47, 224, 200, 0.16), transparent 55%),
    radial-gradient(900px 600px at 88% 8%, rgba(239, 181, 106, 0.14), transparent 50%),
    linear-gradient(165deg, #07090d 0%, #0c121c 48%, #080a10 100%);
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  animation: float 18s var(--ease) infinite alternate;
  will-change: transform;
}
.b1 { width: min(42vw, 420px); height: min(42vw, 420px); left: -8%; top: -12%; background: rgba(47, 224, 200, 0.35); }
.b2 { width: min(36vw, 360px); height: min(36vw, 360px); right: -10%; top: 10%; background: rgba(239, 181, 106, 0.28); animation-duration: 22s; animation-delay: -4s; }
.b3 { width: min(28vw, 280px); height: min(28vw, 280px); left: 35%; bottom: -15%; background: rgba(255, 122, 138, 0.16); animation-duration: 26s; animation-delay: -8s; }
.grain {
  position: absolute;
  inset: 0;
  opacity: 0.08;
  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.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
@keyframes float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(3%, 4%, 0) scale(1.08); }
}

.rise { animation: rise 0.8s var(--ease-out) both; }
.rise-d1 { animation-delay: 0.08s; }
.rise-d2 { animation-delay: 0.16s; }
.rise-d3 { animation-delay: 0.24s; }
.rise-d4 { animation-delay: 0.32s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(22px) scale(0.985); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}

/* ========== GATE / LOGIN ========== */
.gate {
  min-height: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  padding:
    calc(24px + var(--safe-top))
    calc(var(--pad-x) + var(--safe-right))
    calc(20px + var(--safe-bottom))
    calc(var(--pad-x) + var(--safe-left));
}
.gate-hero {
  display: grid;
  align-content: center;
  gap: clamp(14px, 2.5vw, 28px);
  max-width: 920px;
  width: 100%;
}
.gate-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 550;
}
.gate-kicker i {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 0 rgba(47, 224, 200, 0.55);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 224, 200, 0.45); }
  70% { box-shadow: 0 0 0 12px rgba(47, 224, 200, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 224, 200, 0); }
}
.gate-brand {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.75rem, 12vw, 7.2rem);
  line-height: 0.92;
  letter-spacing: -0.045em;
  word-break: break-word;
}
.gate-brand em {
  font-style: normal;
  background: linear-gradient(120deg, var(--teal), #9af0e4 40%, var(--sand));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.gate-lead {
  margin: 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: clamp(0.98rem, 2.4vw, 1.25rem);
  line-height: 1.55;
  font-weight: 360;
}
.gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: stretch;
  margin-top: 4px;
  width: 100%;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  font-weight: 650;
  letter-spacing: 0.01em;
  transition: transform 0.2s var(--ease), filter 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover { transform: translateY(-2px); }
}
.btn:active { transform: translateY(0) scale(0.98); }
.btn-primary {
  background: linear-gradient(120deg, #fff, #dce7f5);
  color: #0a0e14;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.btn-discord {
  background: #5865f2;
  color: #fff;
  box-shadow: 0 16px 40px rgba(88, 101, 242, 0.35);
}
.btn-ghost {
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  min-height: 40px;
  padding: 0 14px;
  font-size: 0.9rem;
}
@media (hover: hover) and (pointer: fine) {
  .btn-ghost:hover { color: var(--ink); border-color: rgba(255,255,255,0.18); }
}
.gate-err {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 122, 138, 0.35);
  background: rgba(255, 122, 138, 0.1);
  color: #ffc4cb;
  max-width: 28rem;
  width: 100%;
  font-size: 0.92rem;
  line-height: 1.4;
}
.gate-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.72rem;
  font-family: var(--mono);
  opacity: 0.75;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 28px;
}

/* ========== PORTAL HUB ========== */
.hub {
  min-height: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}
.hub-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding:
    calc(14px + var(--safe-top))
    calc(var(--pad-x) + var(--safe-right))
    14px
    calc(var(--pad-x) + var(--safe-left));
  border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 13, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.hub-brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.1rem, 3.5vw, 1.35rem);
  letter-spacing: -0.03em;
  min-width: 0;
}
.hub-brand span {
  background: linear-gradient(120deg, var(--teal), var(--sand));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hub-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: none;
}
.hub-user img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  flex: none;
}
.hub-user .meta {
  text-align: right;
  min-width: 0;
}
.hub-user strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12rem;
}
.hub-user span {
  color: var(--muted);
  font-size: 0.72rem;
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12rem;
  display: block;
}

.hub-main {
  padding:
    clamp(22px, 4vw, 56px)
    calc(var(--pad-x) + var(--safe-right))
    calc(72px + var(--safe-bottom))
    calc(var(--pad-x) + var(--safe-left));
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.hub-intro {
  margin-bottom: clamp(20px, 3.5vw, 44px);
}
.hub-intro h1 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: clamp(1.75rem, 6vw, 3.1rem);
  letter-spacing: -0.035em;
  line-height: 1.05;
}
.hub-intro p {
  margin: 0;
  color: var(--muted);
  max-width: 36rem;
  font-size: clamp(0.95rem, 2.4vw, 1.05rem);
  line-height: 1.5;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}
.mod {
  position: relative;
  grid-column: span 6;
  min-height: 200px;
  padding: 24px 22px 64px;
  border: 1px solid var(--line);
  background:
    linear-gradient(160deg, rgba(255,255,255,0.04), transparent 45%),
    var(--panel);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow: hidden;
  text-align: left;
  width: 100%;
  transition: transform 0.35s var(--ease), border-color 0.35s ease, box-shadow 0.35s ease;
  isolation: isolate;
}
.mod:nth-child(1) { grid-column: span 7; min-height: 260px; }
.mod:nth-child(2) { grid-column: span 5; min-height: 260px; }
.mod:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.mod::before {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 70%;
  height: 90%;
  background: radial-gradient(circle, var(--glow, rgba(47,224,200,0.22)), transparent 68%);
  opacity: 0.85;
  transform: translate3d(10%, 10%, 0);
  transition: transform 0.6s var(--ease), opacity 0.4s ease;
  z-index: -1;
}
@media (hover: hover) and (pointer: fine) {
  .mod:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  }
  .mod:hover::before { transform: translate3d(-4%, -6%, 0) scale(1.08); opacity: 1; }
  .mod:hover .mod-go {
    background: var(--ink);
    color: #0a0e14;
    border-color: transparent;
    transform: translate(2px, -2px);
  }
}
.mod:active {
  transform: scale(0.985);
}
.mod[data-kind="frakm"] { --glow: rgba(47, 224, 200, 0.28); }
.mod[data-kind="todo"] { --glow: rgba(239, 181, 106, 0.28); }
.mod[data-kind="admin"] { --glow: rgba(255, 122, 138, 0.22); }
.mod[data-kind="tickets"] { --glow: rgba(130, 170, 255, 0.28); }

.mod-index {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 20px;
}
.mod h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: clamp(1.35rem, 4.5vw, 2rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  padding-right: 8px;
}
.mod p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  max-width: 34ch;
  font-size: 0.95rem;
}
.mod-go {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  transition: background 0.25s ease, transform 0.35s var(--ease), border-color 0.25s ease;
}
.mod.loading {
  pointer-events: none;
  opacity: 0.7;
}
.mod.loading .mod-go {
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: calc(16px + var(--safe-left));
  right: calc(16px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  z-index: 50;
  padding: 12px 16px;
  background: rgba(20, 24, 34, 0.94);
  border: 1px solid var(--line);
  color: var(--ink);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: rise 0.35s var(--ease-out);
  max-width: min(360px, calc(100vw - 32px - var(--safe-left) - var(--safe-right)));
  margin-left: auto;
  font-size: 0.92rem;
  line-height: 1.4;
}

/* Tablet */
@media (max-width: 960px) {
  .mod:nth-child(1),
  .mod:nth-child(2),
  .mod {
    grid-column: span 6;
    min-height: 200px;
  }
}

/* Phone / small */
@media (max-width: 720px) {
  .gate {
    padding-top: calc(28px + var(--safe-top));
  }
  .gate-actions .btn {
    width: 100%;
    min-height: 52px;
  }
  .gate-foot {
    flex-direction: column;
    gap: 6px;
  }

  .hub-top {
    padding-top: calc(12px + var(--safe-top));
    padding-bottom: 12px;
  }
  .hub-user .meta { display: none; }
  .hub-user .btn-ghost {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.82rem;
  }
  .hub-intro p {
    font-size: 0.95rem;
  }

  .module-grid {
    gap: 12px;
  }
  .mod,
  .mod:nth-child(1),
  .mod:nth-child(2) {
    grid-column: span 12;
    min-height: 0;
    padding: 20px 18px 60px;
  }
  .mod-index { margin-bottom: 14px; }
  .mod p { max-width: none; }
  .mod-go {
    width: 42px;
    height: 42px;
    right: 14px;
    bottom: 14px;
  }

  .b1, .b2, .b3 {
    filter: blur(48px);
    opacity: 0.4;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .gate-brand {
    font-size: clamp(2.35rem, 14vw, 3rem);
  }
  .hub-brand {
    font-size: 1.05rem;
  }
  .hub-user img {
    width: 32px;
    height: 32px;
  }
}

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