/* ============================================
   H5 Games Portal — Professional Design
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ── Variables ── */
:root {
  --bg: #0b0f1a;
  --bg-surface: #111827;
  --bg-card: #1a2235;
  --bg-elevated: #1f2a3d;
  --bg-input: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --text-muted: #475569;
  --accent: #60a5fa;
  --accent-bold: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 14px;
  --radius-lg: 20px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --max-w: 1280px;
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }

/* ── Ambient Background ── */
.bg-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(150px);
}

.bg-orb--indigo {
  width: 900px; height: 900px;
  background: rgba(59, 130, 246, 0.06);
  top: -35%; left: -15%;
}

.bg-orb--pink {
  width: 700px; height: 700px;
  background: rgba(139, 92, 246, 0.04);
  bottom: -25%; right: -10%;
}

.bg-orb--cyan {
  width: 500px; height: 500px;
  background: rgba(6, 182, 212, 0.03);
  top: 60%; left: 40%;
}

/* ── Header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 15, 26, 0.8);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border-bottom: 1px solid var(--border);
  height: 56px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent-bold), #818cf8);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.8rem;
  color: #fff;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.logo-text {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: -0.3px;
}

.logo-text span {
  color: var(--accent);
  font-weight: 800;
}

.logo-sub { display: none; }

/* Nav */
.nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.nav-link {
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--text-dim);
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  transition: all 0.15s;
  position: relative;
}

.nav-link:hover { color: var(--text); }

.nav-link.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.15rem;
  padding: 0.4rem;
  cursor: pointer;
}

/* ── Main Content ── */
.main-content {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 2rem 4rem;
}

/* ── Hero Section ── */
.hero {
  padding: 1.75rem 0 1.25rem;
}

.hero h1 {
  font-weight: 800;
  font-size: 2.5rem;
  letter-spacing: -1.5px;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 0.6rem;
}

.hero h1 .gradient {
  background: linear-gradient(135deg, #60a5fa, #818cf8, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 1rem;
  color: var(--text-dim);
  max-width: 450px;
  line-height: 1.6;
  margin-bottom: 1.75rem;
}

/* ── Search ── */
.search-box {
  position: relative;
  width: 100%;
}

.search-box i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  border-color: rgba(129, 140, 248, 0.4);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.search-box input::placeholder { color: var(--text-muted); }

/* ── Grid Header ── */
.grid-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-top: 0.5rem;
}

.section-title {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.3px;
}

.game-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.no-results {
  text-align: center;
  padding: 6rem 1rem;
  color: var(--text-muted);
}

.no-results i { font-size: 2rem; margin-bottom: 1rem; opacity: 0.2; display: block; }
.no-results p { font-size: 0.875rem; }

/* ── Game Grid ── */
.game-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

/* ── Game Card ── */
.game-card {
  position: relative;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: var(--bg-elevated);
  cursor: pointer;

  /* reveal animation */
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.6s var(--ease),
              transform 0.6s var(--ease);
}

.game-card.revealed {
  opacity: 1;
  transform: scale(1);
}

/* Hover — card lifts with glow ring */
.game-card:hover {
  box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.3),
              0 20px 50px -10px rgba(0, 0, 0, 0.6);
}

/* ── Image fills entire card ── */
.card-img-wrapper {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.card-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s var(--ease),
              filter 0.5s ease;
}

/* Hover — slow cinematic zoom + slight brighten */
.game-card:hover .card-img-wrapper img {
  transform: scale(1.1);
  filter: brightness(1.15) saturate(1.1);
}

/* Dark gradient from bottom for text readability */
.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg,
    rgba(11, 15, 26, 0.9) 0%,
    rgba(11, 15, 26, 0.35) 40%,
    transparent 65%);
  z-index: 1;
  transition: opacity 0.3s;
}

.game-card:hover .card-overlay {
  background: linear-gradient(0deg,
    rgba(11, 15, 26, 0.95) 0%,
    rgba(11, 15, 26, 0.5) 45%,
    rgba(11, 15, 26, 0.15) 100%);
}

/* Play button — centered, scales up on hover */
.play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  width: 58px;
  height: 58px;
  background: var(--accent-bold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  z-index: 3;
  transition: all 0.35s var(--ease);
  box-shadow: 0 6px 24px var(--accent-glow);
}

.play-icon i {
  color: #fff;
  font-size: 1.1rem;
  margin-left: 3px;
}

.game-card:hover .play-icon {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Card text — always visible at bottom */
.card-body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.85rem 1rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.card-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.card-category {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 500;
  text-transform: capitalize;
}

/* ── Badges ── */
.badge {
  position: absolute;
  top: 10px; left: 10px;
  z-index: 4;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.6rem;
  color: #fff;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.badge--hot  { background: rgba(248, 113, 113, 0.85); }
.badge--new  { background: rgba(52, 211, 153, 0.85); }
.badge--fire { background: rgba(251, 191, 36, 0.85); color: #000; }

/* ── Footer ── */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border);
  padding: 3.5rem 2rem 1.5rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr 1fr 1fr;
  gap: 2.5rem;
  max-width: var(--max-w);
  margin: 0 auto;
}

.footer-col h4 {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 1rem;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.footer-col a {
  display: block;
  padding: 0.3rem 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: color 0.15s;
}

.footer-col a:hover { color: var(--text); }

.footer-col p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.footer-bottom {
  text-align: center;
  padding-top: 2rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  max-width: var(--max-w);
  margin-left: auto;
  margin-right: auto;
}

/* ── Responsive ── */
@media (max-width: 1279px) {
  .game-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 1023px) {
  .game-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-grid { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 2rem; }
}

@media (max-width: 767px) {
  .game-grid { grid-template-columns: repeat(2, 1fr); gap: 0.65rem; }
  .site-header { height: 54px; }
  .header-inner { padding: 0 1rem; }

  .nav {
    display: none;
    position: absolute;
    top: 54px; left: 0; right: 0;
    flex-direction: column;
    background: rgba(11, 15, 26, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--border);
    padding: 0.6rem;
  }

  .nav.open { display: flex; }
  .mobile-menu-btn { display: block; }

  .main-content { padding: 0 1rem 3rem; }
  .hero { padding: 1.25rem 0 1rem; }
  .search-box { max-width: 100%; }
  .grid-header { margin-bottom: 1rem; }
}

@media (max-width: 479px) {
  .game-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .footer-grid { grid-template-columns: 1fr; }
  .card-body { padding: 0.65rem 0.75rem; }
  .card-title { font-size: 0.78rem; }
  .card-category { font-size: 0.62rem; }
  .play-icon { width: 46px; height: 46px; }
  .play-icon i { font-size: 0.9rem; }
  .badge { top: 7px; left: 7px; font-size: 0.55rem; padding: 3px 7px; }
}

/* ── Gameplay Page ── */
.gameplay-container {
  position: relative;
  z-index: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem 2rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  transition: color 0.15s;
}

.back-link:hover { color: var(--accent); }

.game-info {
  display: flex;
  align-items: flex-start;
  gap: 2.5rem;
  padding: 2rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 2.5rem;
}

.game-info-thumb {
  width: 160px;
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.game-info-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.game-info-details { flex: 1; padding-top: 0.25rem; }

.game-info-details h1 {
  font-weight: 800;
  font-size: 1.65rem;
  color: var(--text);
  letter-spacing: -0.8px;
  margin-bottom: 0.4rem;
  line-height: 1.2;
}

.game-info-details p {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-bottom: 0.25rem;
  line-height: 1.5;
}

.game-description {
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  max-width: 500px;
}

.btn-play {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 2rem;
  background: var(--accent-bold);
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  border-radius: 11px;
  transition: all 0.2s;
  letter-spacing: -0.1px;
}

.btn-play:hover {
  background: #5558e6;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow), 0 0 0 1px rgba(99,102,241,0.2);
}

.btn-play i { font-size: 0.7rem; }

/* ── Fullscreen Overlay ── */
.game-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--bg-surface);
}

.game-overlay.active { display: block; }

.game-overlay-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: none;
  background: var(--bg-surface);
}

.game-overlay-iframe.loaded { display: block; }

/* Loading screen */
.game-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  z-index: 1;
  transition: opacity 0.5s ease;
}

.game-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-icon {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 22px;
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.loading-title {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  margin-bottom: 0.35rem;
  letter-spacing: -0.3px;
}

.loading-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.loading-bar {
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-bold), #818cf8);
  transition: width 0.3s ease;
}

/* Recommended */
.recommended-section { margin-top: 2.5rem; }
.recommended-section .section-title { margin-bottom: 1.25rem; }
.recommended-section .game-grid { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 767px) {
  .game-info {
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.25rem;
  }
  .game-info-thumb { width: 100px; }
  .game-info-details h1 { font-size: 1.25rem; }
  .game-description { max-width: 100%; }
  .gameplay-container { padding: 1rem; }
  .recommended-section .game-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Utilities ── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
