/**
 * VSS Multi-Game Platform Unified Navigation & Styling SDK
 * Provides unified top banner navigation and harmonious dark slate palette across all games
 */

:root {
  --vss-bg: #0f172a;
  --vss-header-bg: #0f172a;
  --vss-card-bg: #1e293b;
  --vss-border: rgba(255, 255, 255, 0.08);
  --vss-primary: #38bdf8;
  --vss-primary-hover: #0ea5e9;
  --vss-text: #f8fafc;
  --vss-muted: #94a3b8;
  --vss-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ==========================================================================
   1. Unified Top Banner Navigation Bar (Cross-Platform Global Header)
   ========================================================================== */
.portal-nav,
.vss-global-nav {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 20px;
  font-family: var(--vss-font);
  box-sizing: border-box;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.portal-nav-inner,
.vss-global-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-sizing: border-box;
}

.portal-brand,
.vss-global-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.18rem;
  font-weight: 800;
  color: #ffffff;
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}

.portal-brand:hover,
.vss-global-brand:hover {
  opacity: 0.9;
}

.portal-brand span.logo-icon,
.vss-global-brand span.logo-icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 2px 8px rgba(56, 189, 248, 0.5));
}

.portal-nav-links,
.vss-global-links {
  display: flex;
  align-items: center;
  gap: 14px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px 4px;
}

.portal-nav-links::-webkit-scrollbar,
.vss-global-links::-webkit-scrollbar {
  display: none;
}

.portal-nav-links a,
.vss-global-links a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 6px;
}

.portal-nav-links a:hover,
.vss-global-links a:hover {
  color: #38bdf8;
  background: rgba(255, 255, 255, 0.06);
}

.portal-nav-links a.active,
.vss-global-links a.active {
  color: #38bdf8;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.portal-user-badge,
.vss-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  user-select: none;
}

.portal-user-badge:hover,
.vss-user-badge:hover {
  border-color: #38bdf8;
  color: #ffffff;
  background: rgba(56, 189, 248, 0.12);
  transform: translateY(-1px);
}

@media (max-width: 960px) {
  .portal-nav,
  .vss-global-nav {
    padding: 8px 12px;
  }
  .portal-nav-inner,
  .vss-global-nav-inner {
    gap: 8px;
  }
  .portal-brand span:not(.logo-icon),
  .vss-global-brand span:not(.logo-icon) {
    display: none;
  }
  .portal-nav-links,
  .vss-global-links {
    gap: 8px;
  }
  .portal-nav-links a,
  .vss-global-links a {
    font-size: 0.84rem;
    padding: 3px 6px;
  }
  .portal-user-badge,
  .vss-user-badge {
    padding: 4px 10px;
    font-size: 0.78rem;
  }
}

/* ==========================================================================
   2. Page Colors & Theme Harmonization (Matching Homepage #0f172a)
   ========================================================================== */
body {
  background-color: #0f172a !important;
  color: #f8fafc;
}

/* Harmonize game secondary toolbars */
header:not(.portal-nav):not(.vss-global-nav) {
  position: relative !important;
  top: auto !important;
  background: #0f172a !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: none !important;
}

/* Harmonize dark theme variables across all games */
[data-theme="dark"],
[data-theme="wood"],
[data-theme="classic"],
[data-theme="tournament"] {
  --bg-color: #0f172a !important;
  --body-bg: #0f172a !important;
  --header-bg: #0f172a !important;
  --card-bg: #1e293b !important;
  --border-color: rgba(255, 255, 255, 0.08) !important;
}

/* Keep board game controls clear & sleek */
.sub-toolbar,
.game-controls-card,
.arena-sidebar,
.move-history-card,
.pvp-panel {
  background: #1e293b !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  color: #f8fafc !important;
}

.main-tabs {
  background: rgba(30, 41, 59, 0.7) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* ==========================================================================
   3. Interactive Brand / Drawer Support (Backwards Compatibility)
   ========================================================================== */
.vss-brand-interactive {
  cursor: pointer;
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 8px;
  transition: background 0.2s ease, transform 0.1s ease;
  user-select: none;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
}

.vss-brand-interactive:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.vss-brand-interactive:active {
  transform: scale(0.98);
}

.vss-nav-chevron {
  font-size: 0.72rem;
  opacity: 0.75;
  margin-left: 2px;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-block;
}

.vss-brand-interactive.is-open .vss-nav-chevron {
  transform: rotate(180deg);
}

.vss-hub-pill {
  display: none;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 12px;
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.3);
  margin-left: 4px;
  line-height: 1.4;
  vertical-align: middle;
}

@media (min-width: 681px) {
  .vss-hub-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
  }
}

/* Backdrop Overlay */
.vss-nav-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.vss-nav-backdrop.is-active {
  opacity: 1;
  visibility: visible;
}

/* Main Drawer / Popover Window */
.vss-nav-drawer {
  position: fixed;
  top: 60px;
  left: 20px;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 9001;
  transform: translateY(-8px) scale(0.97);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s ease;
  overflow: hidden;
  font-family: var(--vss-font);
}

.vss-nav-drawer.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.vss-drawer-drag-handle {
  display: none;
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  margin: 10px auto 4px auto;
}

.vss-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.vss-drawer-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vss-drawer-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 6px;
}

.vss-drawer-subtitle {
  font-size: 0.75rem;
  color: #94a3b8;
}

.vss-drawer-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #94a3b8;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.18s ease;
}

.vss-drawer-close:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #f8fafc;
}

.vss-drawer-list {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vss-game-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.18s ease;
  position: relative;
}

.vss-game-card:hover:not(.is-disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(96, 165, 250, 0.4);
  transform: translateY(-1px);
}

.vss-game-card.is-active {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(96, 165, 250, 0.5);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

.vss-game-card.is-disabled {
  opacity: 0.55;
  cursor: default;
  background: rgba(0, 0, 0, 0.12);
  border-style: dashed;
}

.vss-card-icon {
  font-size: 1.65rem;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.vss-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.vss-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.vss-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vss-card-desc {
  font-size: 0.74rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vss-card-badge {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.vss-card-badge.is-current {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.35);
}

.vss-card-badge.is-action {
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
  border: 1px solid rgba(96, 165, 250, 0.4);
  transition: all 0.15s ease;
}

.vss-game-card:hover .vss-card-badge.is-action {
  background: #2563eb;
  color: #ffffff;
  border-color: #3b82f6;
}

.vss-drawer-footer {
  padding: 10px 14px 12px 14px;
  background: rgba(0, 0, 0, 0.18);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.vss-footer-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.18s ease;
}

.vss-footer-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
}

@media (max-width: 680px) {
  .vss-nav-drawer {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    border-radius: 20px 20px 0 0;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.28s ease;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .vss-nav-drawer.is-open {
    transform: translateY(0);
  }

  .vss-drawer-drag-handle {
    display: block;
  }

  .vss-drawer-header {
    padding-top: 6px;
  }
}

/* ==========================================================================
   VSS Immersive Fullscreen System
   ========================================================================== */
body.vss-immersive-mode .portal-nav,
body.vss-immersive-mode .vss-global-nav,
body.vss-immersive-mode header:not(.game-guide-header),
body.vss-immersive-mode .match-sub-header,
body.vss-immersive-mode .main-tabs,
body.vss-immersive-mode .match-tabs-strip,
body.vss-immersive-mode .site-footer,
body.vss-immersive-mode footer,
body.vss-immersive-mode .site-bottom-links,
body.vss-immersive-mode .game-editorial-section {
  display: none !important;
}

body.vss-immersive-mode {
  overflow-x: hidden;
  margin: 0 !important;
  padding: 0 !important;
}

body.vss-immersive-mode main,
body.vss-immersive-mode .arena-container {
  padding-top: 6px !important;
  padding-bottom: 6px !important;
  min-height: 100vh !important;
  box-sizing: border-box !important;
}

/* Floating exit pill button */
.vss-immersive-exit-btn {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 999999;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #e2e8f0;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 24px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.vss-immersive-exit-btn:hover {
  background: rgba(30, 41, 59, 0.95);
  color: #38bdf8;
  border-color: #38bdf8;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.25);
}

.vss-immersive-exit-btn:active {
  transform: translateY(1px);
}

@media (max-width: 768px) {
  .vss-immersive-exit-btn {
    top: 8px;
    right: 10px;
    font-size: 0.72rem;
    padding: 4px 10px;
  }
}

