/* ArcadeBlack - CrazyGames-like portal - mobile-first, plain CSS */

:root {
  --bg: #0f0f12;
  --bg-elevated: #16161c;
  --bg-card: #1c1c24;
  --text: #e8e8ed;
  --text-muted: #9898a6;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --border: #2a2a34;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --container-max: 1560px;
  --header-h: 56px;
  --categories-h: 44px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 10px 16px;
  min-height: var(--header-h);
}

.logo {
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.logo:hover {
  color: var(--accent);
  text-decoration: none;
}

.search-form {
  flex: 1;
  min-width: 0;
  max-width: 420px;
  position: relative;
  margin: 0 auto;
}
.search-input {
  width: 100%;
  padding: 10px 44px 10px 14px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}
.search-input::placeholder {
  color: var(--text-muted);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}
.search-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 12px;
  font-size: 0.85rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.search-btn:hover {
  background: var(--accent-hover);
}
.search-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 280px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.search-suggestions:not([hidden]) {
  display: block;
}
.search-suggestions a {
  display: block;
  padding: 10px 14px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.search-suggestions a:last-child {
  border-bottom: none;
}
.search-suggestions a:hover,
.search-suggestions a:focus {
  background: var(--bg-card);
  text-decoration: none;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  text-decoration: none;
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
}
.btn-small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

/* Categories nav - horizontal scroll on mobile */
.categories-nav {
  border-top: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.categories-nav::-webkit-scrollbar {
  height: 4px;
}
.categories-nav::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.categories-list {
  display: flex;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 8px 16px;
  min-width: max-content;
}
.categories-list a {
  display: block;
  padding: 8px 14px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  white-space: nowrap;
}
.categories-list a:hover,
.categories-list a:focus {
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
}
.categories-list a.active {
  background: var(--accent);
  color: #fff;
}

/* ---- Main content ---- */
.main-content {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: calc(100vh - var(--header-h) - var(--categories-h) - 120px);
}

.content-layout {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr;
  grid-template-areas:
    "main";
}
.sidebar-left {
  grid-area: left;
  display: none;
}
.games-area {
  grid-area: main;
}
.sidebar-right {
  grid-area: right;
  display: none;
}

@media (min-width: 1024px) {
  .content-layout {
    grid-template-columns: 200px 1fr 220px;
    grid-template-areas: "left main right";
  }
  .sidebar-left,
  .sidebar-right {
    display: block;
  }
}

.sidebar-left h3,
.sidebar-right h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 10px;
}
.filter-list,
.mini-list {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
}
.filter-list li,
.mini-list li {
  margin-bottom: 4px;
}
.filter-list a,
.mini-list a {
  display: block;
  padding: 6px 0;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
}
.filter-list a:hover,
.filter-list a:focus,
.mini-list a:hover,
.mini-list a:focus {
  color: var(--accent);
  text-decoration: none;
}
.filter-list a.active {
  color: var(--accent);
  font-weight: 500;
}

.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}
.tag-chip {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.8rem;
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: 999px;
  text-decoration: none;
}
.tag-chip:hover,
.tag-chip:focus {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

/* Featured carousel */
.featured-section {
  margin-bottom: 28px;
}
.carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
.carousel-item {
  flex: 0 0 280px;
  scroll-snap-align: start;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
}
.carousel-item img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}
.carousel-title {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  font-weight: 600;
  font-size: 0.95rem;
}
.carousel-item:hover .carousel-title,
.carousel-item:focus .carousel-title {
  background: linear-gradient(transparent, rgba(99, 102, 241, 0.9));
}

@media (min-width: 768px) {
  .carousel-item {
    flex: 0 0 380px;
  }
  .carousel-item img {
    height: 220px;
  }
}

.section-title {
  font-size: 1.25rem;
  margin: 0 0 16px;
  font-weight: 600;
}

/* Game grid */
.game-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 520px) {
  .game-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 768px) {
  .game-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
  }
}
@media (min-width: 1200px) {
  .game-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

.game-card {
  margin: 0;
}
.game-card-link {
  display: block;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s;
}
.game-card-link:hover,
.game-card-link:focus {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
}
.game-card-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.game-card-thumb-wrap {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--bg-elevated);
}
.game-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.game-card-title {
  display: block;
  padding: 10px 12px 2px;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}
.game-card-meta {
  display: block;
  padding: 0 12px 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.game-card-play {
  position: absolute;
  bottom: 12px;
  right: 12px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
}
.game-card-link:hover .game-card-play,
.game-card-link:focus .game-card-play {
  opacity: 1;
  transform: translateY(0);
}

.more-link-wrap {
  margin-top: 24px;
  text-align: center;
}

.games-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.sort-form {
  margin: 0;
}
.sort-select {
  padding: 8px 12px;
  font-size: 0.9rem;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.sort-select:focus {
  outline: none;
  border-color: var(--accent);
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

/* Skeleton loading (appended to game grid while fetching) */
.game-card-skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton 1s ease-in-out infinite;
  border-radius: var(--radius-lg);
  aspect-ratio: 4 / 3;
  min-height: 120px;
}
@keyframes skeleton {
  to { background-position: 200% 0; }
}

.infinite-sentinel {
  height: 20px;
  margin-top: 20px;
}
.load-more-status {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 12px;
}

/* ---- Game play page ---- */
.game-page .main-content {
  padding-top: 16px;
}
.game-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
  grid-template-areas:
    "embed"
    "left"
    "right"
    "info";
}
.game-embed-area {
  grid-area: embed;
}
.game-rail-left {
  grid-area: left;
}
.game-rail-right {
  grid-area: right;
  display: none;
}
.game-info {
  grid-area: info;
}

@media (min-width: 1024px) {
  .game-layout {
    grid-template-columns: 200px 1fr 200px;
    grid-template-areas: "left embed right";
    gap: 24px;
  }
  .game-info {
    grid-column: 2;
  }
  .game-rail-right {
    display: block;
  }
}

.game-sticky-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.game-title {
  font-size: 1.35rem;
  margin: 0;
  font-weight: 700;
}
.game-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.iframe-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
  max-height: 75vh;
}
.iframe-wrap iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}
.iframe-wrap.is-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
}

.game-info {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
}
.game-description {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.game-meta {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.game-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.game-rail-list {
  margin-bottom: 0;
}
.game-rail-list li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.game-rail-list img {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}
.game-rail-list span {
  font-size: 0.9rem;
}

/* ---- Footer ---- */
.site-footer {
  margin-top: auto;
  padding: 24px 16px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}
.footer-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  text-align: center;
}
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
}
.footer-nav a {
  color: var(--text-muted);
}
.footer-nav a:hover {
  color: var(--text);
}
.footer-copy {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Error page */
.error-page {
  padding: 40px 20px;
  text-align: center;
}
.error-page h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}
.error-page pre {
  text-align: left;
  overflow: auto;
  max-width: 100%;
  font-size: 0.85rem;
  color: var(--text-muted);
}
