/* Reset & base styles */
:root {
  --bg: #080a12;
  --panel: rgba(17, 22, 38, 0.92);
  --panel-2: rgba(23, 30, 50, 0.9);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f6f8ff;
  --muted: #aeb8cf;
  --blue: #31a8ff;
  --mint: #36e7b5;
  --pink: #ff4fa3;
  --yellow: #ffd66b;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(49, 168, 255, 0.28), transparent 34rem),
    radial-gradient(circle at 92% 12%, rgba(255, 79, 163, 0.22), transparent 30rem),
    linear-gradient(135deg, #080a12 0%, #101827 42%, #10121d 100%);
  line-height: 1.6;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.78), transparent 78%);
}

a { text-decoration: none; color: inherit; }

img, iframe {
  max-width: 100%;
  display: block;
}

.container {
  width: min(92%, 1180px);
  margin: 34px auto 54px;
  position: relative;
}

.container::before {
  content: "Roblox Game Finder";
  display: inline-flex;
  margin-bottom: 14px;
  padding: 7px 12px;
  border: 1px solid rgba(54, 231, 181, 0.35);
  border-radius: 999px;
  background: rgba(54, 231, 181, 0.1);
  color: #caffee;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

/* Titles */
.page-title,
.ranking-header h1 {
  max-width: 980px;
  margin: 0 0 12px;
  font-size: clamp(2rem, 5vw, 4.3rem);
  line-height: 1.08;
  letter-spacing: 0;
  text-wrap: balance;
}

.page-title {
  padding: 0 0 8px;
  text-align: left;
}

.subtitle {
  max-width: 780px;
  margin: 0 0 26px;
  color: var(--muted);
  text-align: left;
  font-size: 0.98rem;
}

.ranking-header {
  margin-bottom: 22px;
}

.ranking-header h2 {
  display: inline-flex;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 214, 107, 0.12);
  color: var(--yellow);
  font-size: 0.95rem;
}

.ranking-header .subtitle {
  margin-top: 10px;
}

/* Controls */
.controls {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.controls form {
  display: flex;
  gap: 10px;
  min-width: 0;
}

.controls select,
.controls input[type="text"] {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  outline: none;
  background: rgba(6, 10, 20, 0.8);
  color: var(--text);
  font-size: 0.95rem;
}

.controls input[type="text"] { flex: 1; min-width: 0; }

.controls select:focus,
.controls input[type="text"]:focus {
  border-color: rgba(49, 168, 255, 0.75);
  box-shadow: 0 0 0 3px rgba(49, 168, 255, 0.16);
}

.controls button,
.btn-detail,
.btn-play {
  min-height: 46px;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  color: #06101e;
  background: linear-gradient(135deg, var(--mint), var(--blue));
  font-size: 0.92rem;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  transition: transform 0.18s ease, filter 0.18s ease, border-color 0.18s ease;
}

.controls button:hover,
.btn-play:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

/* Genres and filters */
.genres,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 30px;
}

.filters { justify-content: flex-start; }

.genres a,
.filters a,
.pagination .page-buttons a,
.footer-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: #dce5f7;
  font-size: 0.84rem;
  font-weight: 700;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.genres a.active,
.genres a:hover,
.filters a.active,
.filters a:hover,
.pagination .page-buttons a.active,
.pagination .page-buttons a:hover {
  border-color: rgba(255, 214, 107, 0.75);
  background: var(--yellow);
  color: #16130b;
  transform: translateY(-1px);
}

/* Game cards */
.game-list {
  display: grid;
  gap: 22px;
}

.game-card {
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(26, 34, 56, 0.96), rgba(12, 16, 29, 0.96));
  box-shadow: var(--shadow);
}

.game-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.game-title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  font-weight: 800;
}

.game-title .rank {
  min-width: 42px;
  padding: 4px 10px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--pink), var(--yellow));
  color: #120914;
  font-size: 1rem;
  text-align: center;
}

.game-title .title-text {
  overflow-wrap: anywhere;
  font-size: clamp(1.12rem, 2.2vw, 1.45rem);
  line-height: 1.25;
}

.game-title .update-date {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.game-content {
  display: grid;
  grid-template-columns: minmax(280px, 46%) minmax(0, 1fr);
}

.game-card:nth-child(odd) .game-content {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 46%);
}

.game-card:nth-child(odd) .thumb { grid-column: 2; grid-row: 1; }
.game-card:nth-child(odd) .info { grid-column: 1; grid-row: 1; }

.thumb {
  min-width: 0;
  background: #060913;
}

.thumb img,
.thumb iframe,
.detail-image img,
.detail-image iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: cover;
}

.info {
  min-width: 0;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.info p.desc,
.info-block .desc,
.english-desc {
  color: #dce5f7;
  font-size: 0.98rem;
  line-height: 1.75;
}

.info p.desc {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info a.read-more {
  align-self: flex-start;
  color: #8bdcff;
  font-size: 0.92rem;
  font-weight: 800;
}

.info a.read-more:hover {
  color: var(--mint);
}

/* Stats */
.stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.stats span {
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: #d8e1f6;
}

.stats .score {
  border-color: rgba(54, 231, 181, 0.35);
  background: rgba(54, 231, 181, 0.12);
  color: #bfffe9;
  font-size: 1.08rem;
  font-weight: 900;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-detail {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.btn-detail:hover {
  border-color: rgba(49, 168, 255, 0.6);
  transform: translateY(-1px);
}

.btn-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
}

/* Pagination */
.pagination {
  margin: 38px 0;
  text-align: center;
}

.pagination .page-buttons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.pagination .page-buttons a {
  min-width: 40px;
}

.pagination .page-info {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Detail page */
.detail-image {
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stats-grid .item {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.stats-grid .label {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.stats-grid .value {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 1.04rem;
  font-weight: 900;
}

.info-block {
  margin-bottom: 8px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.info-block hr {
  margin: 22px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.english-desc {
  margin-top: 24px;
  color: var(--muted);
}

/* Ranking table */
.ranking-table {
  width: 100%;
  overflow: hidden;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.ranking-table th,
.ranking-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.ranking-table th {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 0.84rem;
  text-transform: uppercase;
}

.ranking-table td {
  color: #e8eefc;
}

.ranking-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.035);
}

.ranking-table tbody tr:hover {
  background: rgba(49, 168, 255, 0.1);
}

.ranking-table a {
  color: #aee6ff;
  font-weight: 800;
}

/* Footer Links */
.footer-links {
  width: min(92%, 1180px);
  margin: 0 auto;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.footer-links a:hover {
  border-color: rgba(49, 168, 255, 0.55);
  background: rgba(49, 168, 255, 0.16);
  color: #eaf8ff;
  transform: translateY(-1px);
}

@media (max-width: 820px) {
  .container { margin-top: 24px; }

  .controls {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .controls form {
    flex-direction: column;
  }

  .game-content,
  .game-card:nth-child(odd) .game-content {
    grid-template-columns: 1fr;
  }

  .game-card:nth-child(odd) .thumb,
  .game-card:nth-child(odd) .info {
    grid-column: auto;
    grid-row: auto;
  }

  .game-title {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .game-title .update-date {
    grid-column: 1 / -1;
    white-space: normal;
  }

  .info,
  .info-block {
    padding: 18px;
  }

  .ranking-table {
    display: block;
    overflow-x: auto;
  }
}

@media (max-width: 520px) {
  .container::before {
    font-size: 0.72rem;
  }

  .genres a,
  .filters a,
  .footer-links a {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .actions .btn-play,
  .btn-detail {
    width: 100%;
  }
}
