
/* =====================================
   CÀI ĐẶT CHUNG
===================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  background: #080d13;
  color: #fff;
  font-family: Arial, sans-serif;
  overflow-x: hidden;
}

/* =====================================
   VIDEO NỀN
===================================== */

.video-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

/* =====================================
   BỐ CỤC 4 CỔNG
===================================== */

.gateway {
  position: relative;
  z-index: 1;

  min-height: 100vh;
  display: flex;
  align-items: flex-end;
  justify-content: center;

  padding: 25px 18px 9vh;
}

.servers {
  width: 100%;
  max-width: 860px;

  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

/* =====================================
   KHUNG TRONG SUỐT
===================================== */

.server-card {
  --neon-color: #00ff88;
  --shield-color: #00ff88;
  --shield-dark: #073b29;
  --card-bg: rgba(6,23,19,.78);

  position: relative;
  isolation: isolate;
  overflow: hidden;

  min-width: 0;
  min-height: 250px;
  padding: 13px 9px 11px;

  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);

  background: var(--card-bg);

  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;

  cursor: pointer;

  transition:
    transform .3s ease,
    box-shadow .3s ease;
}

/* MÀU TỪNG CỔNG */

.uae,
.brazil {
  --neon-color: #00ff88;
  --shield-color: #00ff88;
  --shield-dark: #073b29;
  --card-bg: rgba(6,23,19,.78);
}

.singapore {
  --neon-color: #ff174f;
  --shield-color: #ff174f;
  --shield-dark: #470918;
  --card-bg: rgba(27,9,18,.78);
}

.usa {
  --neon-color: #ff174f;
  --shield-color: #ff174f;
  --shield-dark: #470918;
  --card-bg: rgba(11,13,32,.78);
}

/* =====================================
   VIỀN NEON 3 VỆT CHẠY
===================================== */

.border-neon {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.border-neon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.border-track {
  fill: none;
  stroke: var(--neon-color);
  stroke-width: 1;
  opacity: .24;
  vector-effect: non-scaling-stroke;
}

.border-runner {
  fill: none;
  stroke: var(--neon-color);
  stroke-width: 3;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;

  stroke-dasharray: 15 85 15 85 15 85;

  filter: drop-shadow(0 0 5px var(--neon-color));

  animation: borderChase 3s linear infinite;
}

@keyframes borderChase {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: -300;
  }
}

.server-card:nth-child(2) .border-runner {
  animation-delay: -.5s;
}

.server-card:nth-child(3) .border-runner {
  animation-delay: -1s;
}

.server-card:nth-child(4) .border-runner {
  animation-delay: -1.5s;
}

.server-card:hover {
  transform: translateY(-8px);
  box-shadow:
    0 0 12px var(--neon-color),
    0 0 25px rgba(0,0,0,.4);
}

/* =====================================
   TUYẾT RƠI KHẮP TOÀN BỘ KHUNG
===================================== */

.card-snow {
  position: absolute;
  inset: 0;
  z-index: 1;

  width: 100%;
  height: 100%;

  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}

.card-snow span {
  position: absolute;
  top: -8px;
  left: var(--snow-x);

  width: var(--snow-size);
  height: var(--snow-size);

  border-radius: 50%;
  background: rgba(255,255,255,.9);

  box-shadow:
    0 0 3px rgba(255,255,255,.65);

  opacity: 0;

  animation:
    cardSnowFall var(--snow-duration)
    linear infinite;

  animation-delay: var(--snow-delay);
}

@keyframes cardSnowFall {
  0% {
    transform: translate3d(0,-5px,0);
    opacity: 0;
  }

  12% {
    opacity: .65;
  }

  50% {
    transform: translate3d(
      var(--snow-drift),
      calc(var(--card-height) * .5),
      0
    );
    opacity: .7;
  }

  85% {
    opacity: .5;
  }

  100% {
    transform: translate3d(
      calc(var(--snow-drift) * -1),
      var(--card-height),
      0
    );
    opacity: 0;
  }
}

/* NỘI DUNG NẰM TRÊN TUYẾT */

.server-card > :not(.border-neon):not(.card-snow) {
  position: relative;
  z-index: 3;
}

/* =====================================
   VÒNG NEON QUANH QUỐC KỲ
===================================== */

.flag-ring {
  --ring-color: var(--neon-color);

  width: 96px;
  height: 96px;
  position: relative;

  display: grid;
  place-items: center;

  border-radius: 50%;
  margin-bottom: 12px;

  isolation: isolate;
  overflow: visible;
}

.flag-ring::before {
  content: "";
  position: absolute;
  inset: 2px;

  border-radius: 50%;
  border: 1px solid var(--ring-color);

  opacity: .35;
  box-shadow: 0 0 12px var(--ring-color);
}

.flag-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;

  border-radius: 50%;

  background: conic-gradient(
    transparent 0deg,
    transparent 175deg,
    var(--ring-color) 230deg,
    white 250deg,
    var(--ring-color) 270deg,
    transparent 300deg,
    transparent 360deg
  );

  -webkit-mask: radial-gradient(
    farthest-side,
    transparent calc(100% - 5px),
    #000 calc(100% - 4px)
  );

  mask: radial-gradient(
    farthest-side,
    transparent calc(100% - 5px),
    #000 calc(100% - 4px)
  );

  filter: drop-shadow(0 0 5px var(--ring-color));

  animation: orbitSpin 2.5s linear infinite;
  animation-delay: var(--ring-delay, 0s);

  pointer-events: none;
}

@keyframes orbitSpin {
  to {
    transform: rotate(360deg);
  }
}

/* =====================================
   QUẢ CẦU QUỐC KỲ
===================================== */

.flag-ball {
  --flag-url: url("https://flagcdn.com/w320/ae.png");

  position: relative;

  width: 77px;
  height: 77px;

  border-radius: 50%;
  overflow: hidden;
  isolation: isolate;

  background: #151515;
  z-index: 3;

  transform: translateZ(0);

  box-shadow:
    0 7px 14px rgba(0,0,0,.5),
    inset -8px -8px 16px rgba(0,0,0,.4);
}

.flag-ball[data-country="ae"] {
  --flag-url: url("https://flagcdn.com/w320/ae.png");
}

.flag-ball[data-country="sg"] {
  --flag-url: url("https://flagcdn.com/w320/sg.png");
}

.flag-ball[data-country="br"] {
  --flag-url: url("https://flagcdn.com/w320/br.png");
}

.flag-ball[data-country="us"] {
  --flag-url: url("https://flagcdn.com/w320/us.png");
}

.sphere-surface {
  position: absolute;
  inset: 0;
  border-radius: 50%;

  background-image: var(--flag-url);
  background-repeat: repeat-x;
  background-size: 154px 100%;
  background-position: 0 center;

  animation: smoothFlagRotate 6s linear infinite;
}

@keyframes smoothFlagRotate {
  from {
    background-position-x: 0;
  }
  to {
    background-position-x: -154px;
  }
}

.sphere-shading {
  position: absolute;
  inset: 0;
  border-radius: 50%;

  background: radial-gradient(
    ellipse at 37% 35%,
    transparent 25%,
    rgba(0,0,0,.15) 48%,
    rgba(0,0,0,.65) 90%,
    rgba(0,0,0,.85) 100%
  );

  pointer-events: none;
}

.sphere-highlight {
  position: absolute;
  inset: 0;
  border-radius: 50%;

  background: radial-gradient(
    ellipse at 30% 22%,
    rgba(255,255,255,.35),
    transparent 48%
  );

  pointer-events: none;
}

/* =====================================
   CHỮ SERVER
===================================== */

.region {
  color: #bbb;
  font-family: Georgia, serif;
  font-size: 8px;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.server-card h2 {
  color: #ffc000;
  font-family: Georgia, serif;
  font-size: 18px;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

/* =====================================
   THÔNG SỐ
===================================== */

.stats {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 4px;

  margin-top: auto;
  margin-bottom: 14px;
}

.stats > div {
  flex: 1;
  min-width: 0;

  font-size: 8px;
  font-family: monospace;
  color: #aaa;
}

.stats strong {
  display: block;
  color: #ffc400;
  font-size: 9px;
  margin-top: 5px;
}

/* =====================================
   SHIELD LOADING THEO MÀU CỔNG
===================================== */

.shield-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.shield-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;

  height: 12px;
  margin-top: 6px;
}

.shield-loading span {
  display: block;

  width: 5px;
  height: 11px;
  flex: 0 0 5px;

  border-radius: 1px;
  background: var(--shield-dark);

  animation: shieldColorLoad 2.4s linear infinite;
}

.shield-loading span:nth-child(1) {
  animation-delay: 0s;
}
.shield-loading span:nth-child(2) {
  animation-delay: .15s;
}
.shield-loading span:nth-child(3) {
  animation-delay: .30s;
}
.shield-loading span:nth-child(4) {
  animation-delay: .45s;
}
.shield-loading span:nth-child(5) {
  animation-delay: .60s;
}
.shield-loading span:nth-child(6) {
  animation-delay: .75s;
}
.shield-loading span:nth-child(7) {
  animation-delay: .90s;
}
.shield-loading span:nth-child(8) {
  animation-delay: 1.05s;
}

@keyframes shieldColorLoad {
  0%, 12% {
    background: var(--shield-dark);
    box-shadow: none;
  }

  18%, 55% {
    background: var(--shield-color);
    box-shadow:
      0 0 5px var(--shield-color),
      0 0 10px var(--shield-color);
  }

  75%, 100% {
    background: var(--shield-dark);
    box-shadow: none;
  }
}

/* =====================================
   ACCESS - 5 SAO VÀNG SÁNG
===================================== */

.access-stars {
  color: #ffe600 !important;
  font-size: 12px !important;
  letter-spacing: 0;

  text-shadow:
    0 0 3px #fff3a0,
    0 0 7px #ffdf00,
    0 0 14px #ffbb00,
    0 0 20px rgba(255,180,0,.7);

  animation: starGlow 2s ease-in-out infinite alternate;
}

@keyframes starGlow {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.35);
  }
}

/* =====================================
   NÚT TRẮNG NGẮN HƠN - FONT CAMBRIA
===================================== */

.server-btn {
  display: block;

  width: 78%;
  margin-left: auto;
  margin-right: auto;
  padding: 9px 4px;

  background: #fff;
  color: #111;

  border-radius: 6px;
  text-decoration: none;

  font-family: Cambria, "Times New Roman", serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .2px;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;

  transition: .3s;
}

.server-btn:hover {
  background: #ffc400;
  transform: scale(1.05);
  box-shadow: 0 0 20px #ffc400;
}

.server-btn:focus-visible,
.server-card:focus-visible {
  outline: 2px solid #ffc400;
  outline-offset: 3px;
}

/* =====================================
   TABLET
===================================== */

@media (max-width: 950px) {
  .gateway {
    padding-bottom: 30px;
  }

  .servers {
    max-width: 600px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }
}

/* =====================================
   ĐIỆN THOẠI
===================================== */

@media (max-width: 550px) {
  .gateway {
    padding: 38vh 10px 20px;
  }

  .servers {
    gap: 10px;
  }

  .server-card {
    min-height: 240px;
    padding: 12px 6px 10px;
    border-radius: 15px;
  }

  .flag-ring {
    width: 80px;
    height: 80px;
    margin-bottom: 12px;
  }

  .flag-ball {
    width: 65px;
    height: 65px;
  }

  .sphere-surface {
    background-size: 130px 100%;
    animation-name: smoothFlagRotateMobile;
  }

  .region {
    font-size: 8px;
    letter-spacing: .5px;
  }

  .server-card h2 {
    font-size: 16px;
  }

  .stats > div {
    font-size: 7px;
  }

  .stats strong {
    font-size: 8px;
  }

  .access-stars {
    font-size: 10px !important;
  }

  .shield-loading {
    gap: 1px;
  }

  .shield-loading span {
    width: 4px;
    height: 10px;
    flex-basis: 4px;
  }

  /* NÚT TRẮNG NGẮN TRÊN ĐIỆN THOẠI */
  .server-btn {
    width: 84%;
    padding: 9px 3px;
    font-family: Cambria, "Times New Roman", serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
  }
}

@keyframes smoothFlagRotateMobile {
  from {
    background-position-x: 0;
  }
  to {
    background-position-x: -130px;
  }
}

/* =====================================
   GIẢM CHUYỂN ĐỘNG NẾU CẦN
===================================== */

@media (prefers-reduced-motion: reduce) {
  .border-runner,
  .flag-ring::after,
  .sphere-surface,
  .card-snow span,
  .shield-loading span,
  .access-stars {
    animation: none;
  }
}
