:root {
  color-scheme: dark;
  --bg: #060913;
  --bg-gradient: radial-gradient(circle at 50% -10%, #0d1629 0%, #060913 70%);
  --panel: rgba(13, 20, 38, 0.72);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-hover: rgba(19, 30, 58, 0.85);
  --text: #f8fafc;
  --text-dim: #cbd5e1;
  --muted: #94a3b8;
  --cyan: #00f2fe;
  --cyan-glow: rgba(0, 242, 254, 0.35);
  --pink: #ff2e63;
  --pink-glow: rgba(255, 46, 99, 0.35);
  --gold: #fbbf24;
  --gold-glow: rgba(251, 191, 36, 0.35);
  --purple: #a855f7;
  --purple-glow: rgba(168, 85, 247, 0.35);
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  background-image: var(--bg-gradient);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Background Ambient Glow Mesh */
.portal-bg-mesh {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.portal-bg-mesh::before,
.portal-bg-mesh::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.35;
  pointer-events: none;
}

.portal-bg-mesh::before {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, rgba(0, 242, 254, 0.22) 0%, rgba(99, 102, 241, 0.12) 50%, transparent 70%);
  top: -120px;
  left: 10%;
}

.portal-bg-mesh::after {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.22) 0%, rgba(255, 46, 99, 0.1) 50%, transparent 70%);
  bottom: 5%;
  right: 10%;
}

.portal-container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 18px 22px 60px;
  position: relative;
  z-index: 1;
}

/* ================= 1. HEADER ================= */
.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: rgba(13, 20, 38, 0.65);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  margin-bottom: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.portal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.portal-brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.25), rgba(168, 85, 247, 0.3));
  border: 1.5px solid rgba(0, 242, 254, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px var(--cyan-glow);
}

.portal-brand-logo svg {
  width: 24px;
  height: 24px;
  color: var(--cyan);
}

.portal-brand-text h1 {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #ffffff 40%, #00f2fe 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.portal-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.portal-brand-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.portal-nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-badge-tag {
  background: rgba(16, 185, 129, 0.12);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.quick-badge-tag .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
  animation: pulseBeacon 1.6s infinite;
}

@keyframes pulseBeacon {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.4); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

/* ================= 2. GAMES HUB SECTION ================= */
.games-hub-section {
  margin-bottom: 48px;
}

.hub-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 26px;
  flex-wrap: wrap;
  gap: 16px;
}

.hub-title-group h2 {
  font-size: 26px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.02em;
}

.hub-title-group p {
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 3px;
}

.filter-pills-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-pill {
  background: rgba(13, 20, 38, 0.6);
  border: 1px solid var(--panel-border);
  color: var(--muted);
  padding: 6px 16px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-pill:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.filter-pill.active {
  background: rgba(0, 242, 254, 0.14);
  color: var(--cyan);
  border-color: rgba(0, 242, 254, 0.4);
  box-shadow: 0 0 14px rgba(0, 242, 254, 0.2);
}

/* ================= 3. MODERN GAME CARDS GRID ================= */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 22px;
}

.game-card {
  background: rgba(13, 20, 38, 0.68);
  border: 1.5px solid var(--panel-border);
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  text-decoration: none;
  color: inherit;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.game-card.ready {
  cursor: pointer;
}

.game-card.coming-game {
  cursor: pointer;
  opacity: 0.85;
}

.game-card:hover {
  transform: translateY(-7px);
  background: rgba(18, 28, 54, 0.82);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6);
}

.game-card.ready:hover {
  border-color: rgba(0, 242, 254, 0.5);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65), 0 0 28px rgba(0, 242, 254, 0.22);
}

.game-card.ready[data-name="Cờ Vua Online"]:hover {
  border-color: rgba(168, 85, 247, 0.55);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65), 0 0 28px rgba(168, 85, 247, 0.22);
}

/* Status badge top right */
.card-status-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: rgba(6, 12, 24, 0.85);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  backdrop-filter: blur(8px);
}

.card-status-badge .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
  animation: pulseBeacon 1.5s infinite;
}

.card-status-badge.coming {
  border-color: rgba(255, 255, 255, 0.12);
  color: #94a3b8;
}

/* Card Visual Media */
.card-media {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.35s ease;
}

.game-card:hover .card-media {
  transform: scale(1.02);
}

.card-svg {
  width: 90px;
  height: 90px;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.6));
}

.game-card:hover .card-svg {
  transform: scale(1.08) rotate(-1deg);
}

/* Card Media Backgrounds */
.caro-bg {
  background: radial-gradient(circle at center, #0f244a 0%, #060b17 100%);
}

.chess-bg {
  background: radial-gradient(circle at center, #261646 0%, #090614 100%);
}

.bship-bg {
  background: radial-gradient(circle at center, #0a273b 0%, #040e16 100%);
}

.connect4-bg {
  background: radial-gradient(circle at center, #35152f 0%, #0d060c 100%);
}

.xiangqi-bg {
  background: radial-gradient(circle at center, #361f10 0%, #110904 100%);
}

.go-bg {
  background: radial-gradient(circle at center, #1d2533 0%, #080d15 100%);
}

.rps-bg {
  background: radial-gradient(circle at center, #37173b 0%, #0f0612 100%);
}

.hockey-bg {
  background: radial-gradient(circle at center, #0a283c 0%, #040f17 100%);
}

/* Card Info Body */
.card-info {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-meta {
  margin-bottom: 6px;
}

.card-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--cyan);
  background: rgba(0, 242, 254, 0.1);
  border: 1px solid rgba(0, 242, 254, 0.25);
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.03em;
}

.card-tag.chess-tag {
  color: #c084fc;
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.3);
}

.card-tag.muted-tag {
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.08);
}

.card-title {
  font-size: 16.5px;
  font-weight: 800;
  color: #fff;
  line-height: 1.3;
  margin-bottom: 6px;
  transition: color 0.2s ease;
}

.game-card.ready:hover .card-title {
  color: var(--cyan);
}

.game-card.ready[data-name="Cờ Vua Online"]:hover .card-title {
  color: #c084fc;
}

.card-desc {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* Card Action Bar */
.card-action-bar {
  margin-top: auto;
}

.btn-play {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #00f2fe 0%, #0284c7 100%);
  color: #04101e;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px rgba(0, 242, 254, 0.3);
  transition: all 0.25s ease;
}

.btn-play.chess-btn {
  background: linear-gradient(135deg, #c084fc 0%, #9333ea 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.3);
}

.game-card:hover .btn-play {
  box-shadow: 0 6px 20px var(--cyan-glow);
}

.game-card[data-name="Cờ Vua Online"]:hover .btn-play {
  box-shadow: 0 6px 20px var(--purple-glow);
}

.btn-coming {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

/* ================= 4. FOOTER ================= */
.portal-footer {
  text-align: center;
  padding-top: 28px;
  border-top: 1px solid var(--panel-border);
  color: var(--muted);
  font-size: 12.5px;
}

.portal-footer p {
  margin-bottom: 8px;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.footer-link {
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: var(--cyan);
}

/* Toast popup */
.portal-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(40px);
  background: rgba(13, 20, 38, 0.95);
  border: 1.5px solid rgba(0, 242, 254, 0.45);
  color: #fff;
  padding: 10px 22px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 24px rgba(0, 242, 254, 0.25);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(12px);
}

.portal-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 768px) {
  .portal-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .portal-nav-actions {
    width: 100%;
    justify-content: space-between;
  }
  .hub-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .games-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
}

@media (max-width: 520px) {
  .portal-container {
    padding: 14px 14px 40px;
  }
  .games-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .card-media {
    height: 120px;
  }
}
