/**
 * HiYangPlus Gaming Platform Styles
 * All classes use prefix 'pg87-' for namespace isolation
 * Mobile-first responsive design with 430px max-width
 */

/* CSS Variables - 6-color palette */
:root {
  /* Primary palette */
  --pg87-primary: #FFDFBA;
  --pg87-secondary: #F8F8FF;
  --pg87-accent: #BAFFC9;
  --pg87-dark: #0E1621;
  --pg87-highlight: #AD1457;
  --pg87-light: #EEEEEE;

  /* Extended palette */
  --pg87-bg-primary: var(--pg87-dark);
  --pg87-bg-secondary: #1a2332;
  --pg87-text-primary: var(--pg87-secondary);
  --pg87-text-secondary: var(--pg87-primary);
  --pg87-border: rgba(255, 223, 186, 0.2);
  --pg87-shadow: rgba(14, 22, 33, 0.8);

  /* Typography */
  --pg87-font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --pg87-font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --pg87-space-xs: 0.4rem;
  --pg87-space-sm: 0.8rem;
  --pg87-space-md: 1.2rem;
  --pg87-space-lg: 1.6rem;
  --pg87-space-xl: 2.4rem;
  --pg87-space-xxl: 3.2rem;

  /* Border radius */
  --pg87-radius-sm: 0.4rem;
  --pg87-radius-md: 0.8rem;
  --pg87-radius-lg: 1.2rem;
  --pg87-radius-xl: 1.6rem;

  /* Transitions */
  --pg87-transition-fast: 0.2s ease;
  --pg87-transition-normal: 0.3s ease;
  --pg87-transition-slow: 0.5s ease;
}

/* Base reset and typography */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 62.5%; /* 1rem = 10px */
  scroll-behavior: smooth;
}

body {
  font-family: var(--pg87-font-primary);
  font-size: 1.4rem;
  line-height: 1.5;
  color: var(--pg87-text-primary);
  background: linear-gradient(135deg, var(--pg87-bg-primary) 0%, var(--pg87-bg-secondary) 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Mobile-first container */
.pg87-container {
  max-width: 430px;
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--pg87-space-sm);
}

.pg87-wrapper {
  position: relative;
  min-height: 100vh;
  padding-bottom: 8rem; /* Space for bottom nav */
}

/* Header styles */
.pg87-header {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: rgba(14, 22, 33, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--pg87-border);
  z-index: 1000;
  transition: all var(--pg87-transition-fast);
}

.pg87-header.scrolled {
  box-shadow: 0 2px 20px var(--pg87-shadow);
}

.pg87-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--pg87-space-sm) var(--pg87-space-md);
  height: 6rem;
}

.pg87-logo {
  display: flex;
  align-items: center;
  gap: var(--pg87-space-xs);
  text-decoration: none;
  color: var(--pg87-text-primary);
}

.pg87-logo-icon {
  width: 2.8rem;
  height: 2.8rem;
  background: linear-gradient(45deg, var(--pg87-primary), var(--pg87-accent));
  border-radius: var(--pg87-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  color: var(--pg87-dark);
}

.pg87-logo-text {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--pg87-primary);
}

.pg87-header-actions {
  display: flex;
  align-items: center;
  gap: var(--pg87-space-sm);
}

.pg87-btn {
  padding: var(--pg87-space-xs) var(--pg87-space-md);
  border: none;
  border-radius: var(--pg87-radius-md);
  font-size: 1.3rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--pg87-transition-fast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 4.4rem; /* Touch-friendly */
  min-width: 4.4rem;
}

.pg87-btn-primary {
  background: linear-gradient(45deg, var(--pg87-highlight), #c2185b);
  color: white;
  box-shadow: 0 2px 8px rgba(173, 20, 87, 0.3);
}

.pg87-btn-primary:hover {
  background: linear-gradient(45deg, #9c1448, var(--pg87-highlight));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(173, 20, 87, 0.4);
}

.pg87-btn-secondary {
  background: transparent;
  color: var(--pg87-primary);
  border: 2px solid var(--pg87-primary);
}

.pg87-btn-secondary:hover {
  background: var(--pg87-primary);
  color: var(--pg87-dark);
}

.pg87-menu-toggle {
  background: none;
  border: none;
  color: var(--pg87-primary);
  font-size: 2.4rem;
  cursor: pointer;
  padding: var(--pg87-space-xs);
  border-radius: var(--pg87-radius-sm);
  transition: all var(--pg87-transition-fast);
}

.pg87-menu-toggle:hover {
  background: rgba(255, 223, 186, 0.1);
}

/* Mobile menu */
.pg87-mobile-menu {
  position: fixed;
  top: 0;
  right: -100%;
  width: 80%;
  max-width: 320px;
  height: 100vh;
  background: var(--pg87-bg-secondary);
  backdrop-filter: blur(20px);
  z-index: 9999;
  transition: right var(--pg87-transition-normal);
  overflow-y: auto;
}

.pg87-mobile-menu.active {
  right: 0;
}

.pg87-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: all var(--pg87-transition-normal);
}

.pg87-menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

.pg87-menu-header {
  padding: var(--pg87-space-lg);
  border-bottom: 1px solid var(--pg87-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pg87-menu-close {
  background: none;
  border: none;
  color: var(--pg87-primary);
  font-size: 2.4rem;
  cursor: pointer;
}

.pg87-menu-nav {
  padding: var(--pg87-space-md);
}

.pg87-menu-item {
  display: block;
  padding: var(--pg87-space-md);
  color: var(--pg87-text-primary);
  text-decoration: none;
  border-radius: var(--pg87-radius-md);
  transition: all var(--pg87-transition-fast);
  margin-bottom: var(--pg87-space-xs);
}

.pg87-menu-item:hover {
  background: rgba(255, 223, 186, 0.1);
  color: var(--pg87-primary);
}

/* Main content */
.pg87-main {
  padding-top: 6rem; /* Account for fixed header */
  min-height: 100vh;
}

/* Hero carousel */
.pg87-hero {
  position: relative;
  margin-bottom: var(--pg87-space-xl);
}

.pg87-carousel {
  position: relative;
  overflow: hidden;
  border-radius: var(--pg87-radius-lg);
  margin: 0 var(--pg87-space-sm);
}

.pg87-slide {
  position: relative;
  width: 100%;
  height: 200px;
  background-size: cover;
  background-position: center;
  display: none;
  cursor: pointer;
}

.pg87-slide.active {
  display: block;
}

.pg87-slide-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--pg87-space-lg);
  background: linear-gradient(transparent, rgba(14, 22, 33, 0.9));
  color: white;
}

.pg87-slide-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: var(--pg87-space-xs);
  color: var(--pg87-primary);
}

.pg87-slide-desc {
  font-size: 1.2rem;
  opacity: 0.9;
}

.pg87-carousel-indicators {
  display: flex;
  justify-content: center;
  gap: var(--pg87-space-xs);
  padding: var(--pg87-space-sm);
}

.pg87-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 223, 186, 0.3);
  cursor: pointer;
  transition: all var(--pg87-transition-fast);
}

.pg87-indicator.active {
  background: var(--pg87-primary);
  transform: scale(1.2);
}

/* Typography */
.pg87-h1 {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--pg87-primary);
  margin-bottom: var(--pg87-space-lg);
  text-align: center;
  line-height: 1.2;
}

.pg87-h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--pg87-primary);
  margin-bottom: var(--pg87-space-md);
}

.pg87-h3 {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--pg87-secondary);
  margin-bottom: var(--pg87-space-sm);
}

.pg87-text {
  color: var(--pg87-text-primary);
  line-height: 1.6;
  margin-bottom: var(--pg87-space-md);
}

.pg87-text-sm {
  font-size: 1.2rem;
  color: var(--pg87-text-secondary);
}

/* Game grid */
.pg87-games-section {
  margin-bottom: var(--pg87-space-xxl);
}

.pg87-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--pg87-space-lg);
  padding: 0 var(--pg87-space-sm);
}

.pg87-game-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--pg87-space-xs);
  padding: 0 var(--pg87-space-sm);
}

.pg87-game-card {
  aspect-ratio: 1;
  background: var(--pg87-bg-secondary);
  border-radius: var(--pg87-radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--pg87-transition-fast);
  border: 1px solid var(--pg87-border);
  position: relative;
}

.pg87-game-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border-color: var(--pg87-primary);
}

.pg87-game-card.hovered {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(255, 223, 186, 0.2);
}

.pg87-game-image {
  width: 100%;
  height: 70%;
  object-fit: cover;
  background: linear-gradient(45deg, var(--pg87-accent), var(--pg87-primary));
}

.pg87-game-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--pg87-space-xs);
  background: rgba(14, 22, 33, 0.9);
  color: var(--pg87-primary);
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Content sections */
.pg87-content-section {
  margin-bottom: var(--pg87-space-xxl);
  padding: 0 var(--pg87-space-sm);
}

.pg87-card {
  background: var(--pg87-bg-secondary);
  border-radius: var(--pg87-radius-lg);
  padding: var(--pg87-space-lg);
  margin-bottom: var(--pg87-space-lg);
  border: 1px solid var(--pg87-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.pg87-card-header {
  display: flex;
  align-items: center;
  gap: var(--pg87-space-sm);
  margin-bottom: var(--pg87-space-md);
}

.pg87-card-icon {
  width: 2.4rem;
  height: 2.4rem;
  background: linear-gradient(45deg, var(--pg87-primary), var(--pg87-accent));
  border-radius: var(--pg87-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pg87-dark);
  font-size: 1.2rem;
}

/* Promotional links */
.pg87-promo-link {
  color: var(--pg87-highlight);
  text-decoration: none;
  font-weight: 600;
  transition: all var(--pg87-transition-fast);
  cursor: pointer;
}

.pg87-promo-link:hover {
  color: var(--pg87-primary);
  text-decoration: underline;
}

.pg87-promo-btn {
  background: linear-gradient(45deg, var(--pg87-highlight), #c2185b);
  color: white;
  padding: var(--pg87-space-sm) var(--pg87-space-lg);
  border-radius: var(--pg87-radius-md);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: var(--pg87-space-xs);
  transition: all var(--pg87-transition-fast);
  cursor: pointer;
  border: none;
  font-size: 1.4rem;
}

.pg87-promo-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(173, 20, 87, 0.4);
}

/* Bottom navigation */
.pg87-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: 6.4rem;
  background: linear-gradient(135deg, var(--pg87-bg-secondary) 0%, var(--pg87-bg-primary) 100%);
  border-top: 1px solid var(--pg87-border);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: var(--pg87-space-xs) 0;
  transition: transform var(--pg87-transition-normal);
}

.pg87-bottom-nav.hidden {
  transform: translateX(-50%) translateY(100%);
}

.pg87-bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--pg87-space-xs);
  text-decoration: none;
  color: var(--pg87-text-secondary);
  padding: var(--pg87-space-xs);
  border-radius: var(--pg87-radius-md);
  transition: all var(--pg87-transition-fast);
  min-width: 6rem;
  cursor: pointer;
}

.pg87-bottom-nav-item:hover,
.pg87-bottom-nav-item.active {
  color: var(--pg87-primary);
  background: rgba(255, 223, 186, 0.1);
  transform: translateY(-2px);
}

.pg87-bottom-nav-icon {
  font-size: 2.4rem;
  transition: all var(--pg87-transition-fast);
}

.pg87-bottom-nav-item:hover .pg87-bottom-nav-icon,
.pg87-bottom-nav-item.active .pg87-bottom-nav-icon {
  transform: scale(1.1);
}

.pg87-bottom-nav-label {
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
}

/* Footer */
.pg87-footer {
  background: var(--pg87-bg-secondary);
  border-top: 1px solid var(--pg87-border);
  padding: var(--pg87-space-xl) var(--pg87-space-sm) var(--pg87-space-xxl);
  margin-top: var(--pg87-space-xxl);
}

.pg87-footer-section {
  margin-bottom: var(--pg87-space-lg);
}

.pg87-footer-title {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--pg87-primary);
  margin-bottom: var(--pg87-space-md);
}

.pg87-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pg87-space-md);
  margin-bottom: var(--pg87-space-lg);
}

.pg87-footer-link {
  color: var(--pg87-text-primary);
  text-decoration: none;
  font-size: 1.2rem;
  transition: color var(--pg87-transition-fast);
}

.pg87-footer-link:hover {
  color: var(--pg87-primary);
}

.pg87-partners {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pg87-space-md);
  justify-content: center;
  margin: var(--pg87-space-lg) 0;
}

.pg87-partner {
  width: 4rem;
  height: 4rem;
  background: var(--pg87-bg-primary);
  border-radius: var(--pg87-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--pg87-primary);
  border: 1px solid var(--pg87-border);
}

.pg87-copyright {
  text-align: center;
  font-size: 1rem;
  color: var(--pg87-text-secondary);
  opacity: 0.7;
}

/* Back to top button */
.pg87-back-to-top {
  position: fixed;
  bottom: 8rem;
  right: var(--pg87-space-sm);
  width: 4.4rem;
  height: 4.4rem;
  background: linear-gradient(45deg, var(--pg87-primary), var(--pg87-accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pg87-dark);
  font-size: 1.8rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all var(--pg87-transition-fast);
  z-index: 999;
  border: none;
}

.pg87-back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.pg87-back-to-top:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 223, 186, 0.3);
}

/* Utility classes */
.pg87-text-center { text-align: center; }
.pg87-text-left { text-align: left; }
.pg87-text-right { text-align: right; }

.pg87-mb-sm { margin-bottom: var(--pg87-space-sm); }
.pg87-mb-md { margin-bottom: var(--pg87-space-md); }
.pg87-mb-lg { margin-bottom: var(--pg87-space-lg); }
.pg87-mb-xl { margin-bottom: var(--pg87-space-xl); }

.pg87-mt-sm { margin-top: var(--pg87-space-sm); }
.pg87-mt-md { margin-top: var(--pg87-space-md); }
.pg87-mt-lg { margin-top: var(--pg87-space-lg); }

.pg87-flex { display: flex; }
.pg87-flex-col { flex-direction: column; }
.pg87-items-center { align-items: center; }
.pg87-justify-center { justify-content: center; }
.pg87-justify-between { justify-content: space-between; }

.pg87-hidden { display: none; }
.pg87-visible { display: block; }

/* Loading states */
.pg87-loading {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--pg87-border);
  border-top: 2px solid var(--pg87-primary);
  border-radius: 50%;
  animation: pg87-spin 1s linear infinite;
}

@keyframes pg87-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
  .pg87-game-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--pg87-space-xs);
  }

  .pg87-slide {
    height: 180px;
  }

  .pg87-slide-title {
    font-size: 1.6rem;
  }

  .pg87-h1 {
    font-size: 2rem;
  }

  .pg87-h2 {
    font-size: 1.8rem;
  }
}

@media (min-width: 769px) {
  .pg87-bottom-nav {
    display: none;
  }

  .pg87-wrapper {
    padding-bottom: 0;
  }
}

/* Animation utilities */
.pg87-fade-in {
  animation: pg87-fadeIn 0.5s ease-in-out;
}

@keyframes pg87-fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.pg87-slide-in {
  animation: pg87-slideIn 0.3s ease-out;
}

@keyframes pg87-slideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

/* Page load animation */
body.loaded .pg87-fade-in {
  animation: pg87-fadeIn 0.6s ease-out;
}

/* Focus styles for accessibility */
.pg87-btn:focus,
.pg87-menu-toggle:focus,
.pg87-game-card:focus {
  outline: 2px solid var(--pg87-primary);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --pg87-border: rgba(255, 223, 186, 0.4);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}