/* assets/style.css - Full replacement with mobile fixes */

/* Base */
:root {
  --bg: #0b0f17;
  --card: #071622;
  --muted: #9fb0d6;
  --accent: #66a3ff;
  --success: #4ade80;
  --error: #ff6b6b;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

@media (max-width: 440px) { html { font-size: 15px; } }
@media (max-width: 360px) { html { font-size: 14px; } }

body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  color: #e9eef6;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #071025 0%, #081426 70%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  z-index: 1000;
}

.logo {
  font-weight: 800;
  color: #fff;
  font-size: 1.125rem;
  cursor: pointer;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search { position: relative; min-width: 220px; }

.search input {
  width: 220px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: #fff;
  font-size: 0.95rem;
}

.suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: 42px;
  background: #09111a;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.04);
  max-height: 220px;
  overflow: auto;
  box-shadow: 0 8px 24px rgba(2,6,23,0.6);
  display: none;
  z-index: 1001;
}

.suggest a {
  display: block;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  color: #d8e6ff;
}

.suggest a:hover { background: rgba(255,255,255,0.02); }

.burger {
  cursor: pointer;
  color: #dfefff;
  padding: 6px 10px;
  border-radius: 6px;
}

/* Overlay categories */
.cat-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2,6,12,0.82);
  z-index: 1500;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.cat-card {
  width: 100%;
  max-width: 680px;
  background: linear-gradient(180deg, #071622, #04110a);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 16px 40px rgba(2,6,23,0.7);
  border: 1px solid rgba(255,255,255,0.03);
  color: #dff1ff;
  position: relative;
}

.cat-card h3 { margin: 0 0 12px; font-size: 1.125rem; }

.cat-list { display: flex; flex-wrap: wrap; gap: 8px; }

.cat-list a {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  display: inline-block;
  color: #dfefff;
}

.cat-close {
  position: absolute;
  right: 15px;
  top: 15px;
  font-size: 20px;
  color: #fff;
  cursor: pointer;
  padding: 5px;
}

/* Container */
.container {
  max-width: 1120px;
  margin: 20px auto;
  padding: 0 16px;
  display: block;
}

/* Grid responsive */
.grid { display: grid; gap: 14px; }

@media (min-width: 320px) { .grid { grid-template-columns: repeat(1, 1fr); } }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .grid { grid-template-columns: repeat(4, 1fr); } }

/* Game card */
.game {
  display: block;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border-radius: 10px;
  padding: 8px;
  border: 1px solid rgba(255,255,255,0.03);
  overflow: hidden;
  position: relative;
  color: #fff;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.game:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.thumb-wrap {
  width: 100%;
  height: 0;
  padding-bottom: 66.6666%;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #05060a;
}

.thumb-wrap img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.play-overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(0,0,0,0.44);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  border: 3px solid rgba(255,255,255,0.9);
  box-shadow: 0 6px 18px rgba(2,6,20,0.6);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.game:hover .play-overlay {
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 8px 24px rgba(2,6,20,0.8);
}

.play-overlay svg {
  width: 24px;
  height: 24px;
  fill: #fff;
  opacity: 0.98;
  margin-left: 3px;
}

.game h3 { margin: 10px 0 4px; font-size: 1rem; color: #fff; }
.game p { margin: 0; color: #c8d6ff; opacity: 0.9; font-size: 0.9rem; }

/* Loader / end text */
#loader { display: none; text-align: center; padding: 14px; color: #cdd6e8; }
#end { display: none; text-align: center; padding: 18px; color: #aebcd5; }

/* Top button */
#topBtn {
  position: fixed;
  right: 18px;
  bottom: 18px;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: #1f2937;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(3,6,23,0.6);
  transition: background 0.3s ease;
  z-index: 999;
}

#topBtn:hover { background: #2d3748; }

/* Game page layout - FIXED FOR MOBILE */
.game-container {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.game-page {
  background: linear-gradient(180deg, #071022, #06111b);
  padding: 18px;
  border-radius: 10px;
  color: #fff;
  flex: 1 1 640px;
  min-width: 300px;
}

.game-page h1 { margin: 0 0 8px; font-size: 1.25rem; }
.game-page .meta { color: var(--muted); margin-bottom: 12px; }
.game-page .meta a { color: var(--accent); }
.game-page .desc { margin-top: 14px; color: #cfe0ff; line-height: 1.6; }

/* Game embed - FIXED FOR MOBILE */
.game-embed-wrapper {
  position: relative;
  margin: 14px 0;
}

.game-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}

.game-embed iframe,
.game-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Fullscreen styles */
.game-embed.is-fullscreen,
.game-embed.fake-fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  padding-bottom: 0 !important;
  z-index: 9999 !important;
  border-radius: 0 !important;
}

body.fullscreen-active {
  overflow: hidden !important;
}

/* Fullscreen button */
.fs-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.04);
  color: #fff;
  margin-top: 12px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.fs-btn:hover { background: rgba(255,255,255,0.08); }

/* Sidebar */
.game-sidebar {
  width: 260px;
  min-width: 200px;
  flex-shrink: 0;
}

.share-box,
.related-games {
  background: linear-gradient(180deg, #081426, #07121a);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.share-box h4,
.related-games h4 { margin: 0 0 8px; color: #fff; }

#shareBox { display: flex; flex-direction: column; gap: 8px; }

#shareBox .secondary,
#shareBox a.secondary {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  color: #dff1ff;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.03);
  transition: background 0.3s ease;
  cursor: pointer;
  text-decoration: none;
}

#shareBox .secondary:hover,
#shareBox a.secondary:hover { background: rgba(255,255,255,0.05); }

/* Related games */
.rel {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  text-decoration: none;
}

.rel img {
  width: 72px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.rel span { color: #cde1ff; font-size: 0.9rem; }

/* Page content */
.page-content {
  background: linear-gradient(180deg, #071022, #06111b);
  padding: 24px;
  border-radius: 10px;
  color: #fff;
}

.page-content h1 { margin: 0 0 20px; font-size: 1.5rem; }
.page-content .content { color: #cfe0ff; line-height: 1.7; }
.page-content .content p { margin-bottom: 16px; }
.page-content .content a { color: var(--accent); }
.page-content .content h2 { margin-top: 24px; margin-bottom: 12px; }
.page-content .content ul, .page-content .content ol { margin-bottom: 16px; padding-left: 24px; }

/* Footer */
.site-footer {
  padding: 18px;
  background: linear-gradient(180deg, #06101a, #02060a);
  text-align: center;
  color: var(--muted);
  margin-top: 30px;
}

.site-footer a { color: #8db9ff; margin: 0 8px; }

/* Admin styles */
.admin-wrap {
  max-width: 980px;
  margin: 28px auto;
  padding: 18px;
  background: var(--card);
  border-radius: 10px;
  color: #eaf2ff;
  border: 1px solid rgba(255,255,255,0.03);
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-wrap h2 { margin: 0 0 12px; color: #fff; }
.admin-wrap a { color: #8db9ff; }
.admin-nav { display: flex; gap: 10px; flex-wrap: wrap; }
.admin-nav a { color: #8db9ff; }

/* Admin stats */
.admin-stats {
  display: flex;
  gap: 15px;
  margin: 15px 0;
  flex-wrap: wrap;
}

.stat-box {
  background: rgba(255,255,255,0.02);
  padding: 15px 20px;
  border-radius: 8px;
  text-align: center;
  min-width: 100px;
}

.stat-num {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
}

.stat-label {
  font-size: 0.85rem;
  color: #9fb0d6;
}

/* Admin filters */
.admin-filters {
  margin: 15px 0;
  padding: 12px;
  background: rgba(255,255,255,0.02);
  border-radius: 8px;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.status-badge.published {
  background: rgba(74, 222, 128, 0.2);
  color: #4ade80;
}

.status-badge.draft {
  background: rgba(255, 107, 107, 0.2);
  color: #ff6b6b;
}

/* Admin tables */
table { width: 100%; border-collapse: collapse; margin-top: 12px; }

table tr td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  vertical-align: middle;
  color: #cde0ff;
}

table thead td {
  font-weight: 600;
  color: #fff;
  font-size: 0.9rem;
}

/* Admin forms */
form input, form textarea, form select {
  width: 100%;
  padding: 10px;
  margin: 6px 0;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.04);
  background: rgba(255,255,255,0.02);
  color: #fff;
  font-size: 1rem;
}

form select {
  background-color: #1a2332;
  cursor: pointer;
}

form select option {
  background-color: #1a2332;
  color: #fff;
}

button {
  padding: 9px 14px;
  border-radius: 8px;
  border: none;
  background: #2b6cb0;
  color: #fff;
  cursor: pointer;
  transition: background 0.3s ease;
}

button:hover { background: #3182ce; }

/* Flash messages */
.flash-message {
  padding: 12px 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  font-size: 0.95rem;
}

.flash-success {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.flash-error {
  background: rgba(255, 107, 107, 0.15);
  color: #ff6b6b;
  border: 1px solid rgba(255, 107, 107, 0.3);
}

/* Admin section */
.admin-section {
  margin: 15px 0;
  padding: 15px;
  background: rgba(255,255,255,0.02);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.03);
}

.admin-section h3 {
  margin-top: 0;
  margin-bottom: 12px;
  color: #fff;
  font-size: 1.1rem;
}

/* Pagination */
.pagination {
  margin-top: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pagination a {
  padding: 8px 12px;
  background: rgba(255,255,255,0.02);
  border-radius: 6px;
  color: #8db9ff;
}

.pagination a:hover {
  background: rgba(255,255,255,0.05);
}

.page-info {
  color: #9fb0d6;
  font-size: 0.9rem;
}

/* Remove global underlines */
a { text-decoration: none !important; }
a:hover { text-decoration: none !important; }

/* Fade-in animation */
.fade-in {
  opacity: 0;
  animation: fadeIn 0.6s ease-in-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .container { padding: 0 12px; }
  .site-header { padding: 10px 12px; }
  
  .search { min-width: 140px; }
  .search input { width: 140px; }
  
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .admin-nav {
    width: 100%;
    justify-content: space-between;
  }
  
  .admin-wrap {
    margin: 20px 12px;
    padding: 14px;
  }
  
  table { font-size: 13px; display: block; overflow-x: auto; }
  table tr td { padding: 8px 6px; }
  
  .game-container {
    flex-direction: column;
  }
  
  .game-sidebar {
    width: 100%;
  }
  
  /* Mobile game embed fixes */
  .game-embed {
    padding-bottom: 75%; /* 4:3 for better mobile visibility */
  }
  
  .game-page {
    padding: 14px;
    min-width: 100%;
  }
  
  .game-page h1 { font-size: 1.1rem; }
  
  .fs-btn {
    width: 100%;
    justify-content: center;
  }
  
  .admin-stats {
    flex-direction: column;
  }
  
  .stat-box {
    width: 100%;
  }
  
  .admin-filters form {
    flex-direction: column;
  }
  
  .admin-filters input,
  .admin-filters select,
  .admin-filters button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .game h3 { font-size: 0.95rem; }
  .game p { font-size: 0.85rem; }
  
  .play-overlay {
    width: 40px;
    height: 40px;
  }
  
  .play-overlay svg {
    width: 18px;
    height: 18px;
  }
  
  .rel img {
    width: 60px;
    height: 40px;
  }
  
  .rel span { font-size: 0.85rem; }
  
  .header-right { gap: 8px; }
  .search { min-width: auto; }
  .search input { width: 120px; }
}