
:root {
  --bg: #0d1020;
  --surface: #161b30;
  --surface-2: #1f2543;
  --line: #2b3253;
  --text: #e9ecf8;
  --muted: #9aa3c4;
  --accent: #2ea3ff;
  --action: #ff7a6b;
  --puzzle: #4fd8c4;
  --arcade: #ffc857;

  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  color-scheme: dark;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* NAVBAR */

.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto minmax(220px, 420px) 1fr;
  align-items: center;
  gap: 1.25rem 2rem;
  padding: 0.875rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(13, 16, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.logo {
  display: block;
  line-height: 0;
}

.logo img {
  display: block;
  width: auto;
  height: 3.25rem;
}

.search {
  position: relative;
}

.search svg {
  position: absolute;
  top: 50%;
  left: 0.9rem;
  width: 1.1rem;
  height: 1.1rem;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
}

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

.search input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(46, 163, 255, 0.25);
}

.filters {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.filter {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filter:hover {
  color: var(--text);
  border-color: var(--muted);
}

.filter[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #0d1020;
}

/* MAIN */

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 2.5rem) 4rem;
}

.count {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

/* BENTO GRID */

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));

  /* Square grid cells */
  grid-auto-rows: clamp(140px, calc(min(25vw, 320px) - 32px), 288px);

  grid-auto-flow: dense;
  gap: 16px;
  align-items: stretch;
}

/* GAME CARDS */

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;

  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: inherit;
  text-decoration: none;

  transition: border-color 0.2s;
}

/* BENTO SIZES */

.card.featured {
  grid-column: span 2;
  grid-row: span 2;
}

.card.wide {
  grid-column: span 2;
  grid-row: span 2;
}

.card.tall {
  grid-column: span 1;
  grid-row: span 1;
}

.card:hover,
.card:focus-visible {
  border-color: var(--accent);
}

/* THUMBNAILS */

.card .thumb {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--surface-2);
}

.card .thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.35s ease;
}

.card:hover .thumb img,
.card:focus-visible .thumb img {
  transform: scale(1.06);
}

/* CARD INFORMATION */

.card .card-body {
  display: flex;
  flex: 0 0 60px;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  height: 60px;
  min-width: 0;
  padding: 0.65rem 0.8rem;
  overflow: hidden;
}

.card-title {
  margin: 0;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.chip::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--tone, var(--muted));
}

.chip[data-category="Action"] {
  --tone: var(--action);
}

.chip[data-category="Puzzle"] {
  --tone: var(--puzzle);
}

.chip[data-category="Arcade"] {
  --tone: var(--arcade);
}

/* EMPTY STATES */

.message {
  max-width: 34rem;
  margin: 3rem auto;
  padding: 2rem;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 14px;
  text-align: center;
}

.message h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.message p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.message code {
  padding: 0.1rem 0.4rem;
  background: var(--surface-2);
  border-radius: 4px;
  font-size: 0.9em;
}

.message .filter {
  color: var(--text);
}

[hidden] {
  display: none !important;
}

/* TABLET */

@media (max-width: 860px) {
  .navbar {
    grid-template-columns: auto 1fr;
  }

  .filters {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.1rem;
  }

  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: calc(33.333vw - 30px);
    gap: 12px;
  }
}

/* MOBILE */

@media (max-width: 520px) {
  .navbar {
    grid-template-columns: 1fr;
  }

  .logo img {
    height: 2.75rem;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: calc(50vw - 21px);
    gap: 10px;
  }

  .card.featured,
  .card.wide {
    grid-column: span 2;
    grid-row: span 2;
  }

  .card.tall {
    grid-column: span 1;
    grid-row: span 1;
  }

  .card .card-body {
    padding: 0.5rem;
    gap: 0.25rem;
  }

  .card-title {
    font-size: 0.9rem;
  }

  .chip {
    font-size: 0.7rem;
  }
}

/* PLAY PAGE */

.play-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1.25rem;
}

.play-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.player {
  --ar: 1.3333;
  --stage-h: clamp(320px, calc(100vh - 15rem), 820px);
  width: min(100%, calc(var(--stage-h) * var(--ar)));
  margin: 0 auto;
}

.stage {
  position: relative;
  aspect-ratio: var(--ar);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
}

.stage iframe {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.stage:fullscreen,
.stage:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}

/* Portrait games keep their shape in fullscreen instead of stretching. */
.player.portrait .stage:fullscreen iframe {
  inset: auto;
  top: 50%;
  left: 50%;
  width: min(100vw, calc(100vh * var(--ar)));
  height: min(100vh, calc(100vw / var(--ar)));
  transform: translate(-50%, -50%);
}

.player.portrait .stage:-webkit-full-screen iframe {
  inset: auto;
  top: 50%;
  left: 50%;
  width: min(100vw, calc(100vh * var(--ar)));
  height: min(100vh, calc(100vw / var(--ar)));
  transform: translate(-50%, -50%);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 14px 14px;
}

/* BUTTONS */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.1rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn:hover {
  border-color: var(--muted);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0d1020;
}

.btn-primary:hover {
  border-color: var(--accent);
  filter: brightness(1.1);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.message .btn {
  margin-top: 0.25rem;
}

/* ACCESSIBILITY */

@media (prefers-reduced-motion: reduce) {
  .thumb img,
  .card,
  .filter,
  .btn {
    transition: none;
  }

  .card:hover .thumb img,
  .card:focus-visible .thumb img {
    transform: none;
  }
}
