:root {
  --bg: #0b0e14;
  --bg-raised: #131826;
  --bg-card: #161c2c;
  --border: #232b40;
  --text: #e8ecf5;
  --text-dim: #8a94ab;
  --accent: #8b5cf6;
  --accent-2: #6366f1;
  --gold: #fbbf24;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 14, 20, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.logo {
  font-size: 22px;
  font-weight: 800;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.logo em { color: var(--accent); font-style: normal; }

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 540px;
}

#search {
  width: 100%;
  padding: 10px 14px 10px 38px;
  font-size: 15px;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 99px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-54%);
  font-size: 18px;
  color: var(--text-dim);
  pointer-events: none;
}

.header-meta {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 14px;
  white-space: nowrap;
}

/* ---------- controls ---------- */
.controls {
  max-width: 1500px;
  margin: 18px auto 0;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.tabs { display: flex; gap: 8px; }

.tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); border-color: var(--accent); }
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.sort-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 14px;
}

#sort {
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

/* ---------- letter bar ---------- */
.letterbar {
  max-width: 1500px;
  margin: 14px auto 0;
  padding: 0 20px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.letterbar button {
  min-width: 34px;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
}
.letterbar button:hover { color: var(--text); background: var(--bg-raised); }
.letterbar button.active {
  color: #fff;
  background: var(--accent);
}

/* ---------- recent row ---------- */
.recent-section {
  max-width: 1500px;
  margin: 22px auto 0;
  padding: 0 20px;
}
.recent-section h2 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.recent-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.recent-card {
  flex: 0 0 150px;
  text-decoration: none;
  color: var(--text);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: transform 0.15s, border-color 0.15s;
}
.recent-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.recent-card .art { height: 72px; font-size: 26px; }
.recent-card .recent-title {
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- grid ---------- */
main {
  max-width: 1500px;
  margin: 0 auto;
  padding: 10px 20px 60px;
}

.result-meta {
  margin: 16px 0 12px;
  font-size: 14px;
  color: var(--text-dim);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.art {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  letter-spacing: 0.02em;
  user-select: none;
}

.card-body { padding: 10px 12px 12px; }

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}

.card-sub {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.35);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: all 0.15s;
}
.fav-btn:hover { transform: scale(1.15); color: var(--gold); }
.fav-btn.faved { color: var(--gold); }

#sentinel { height: 2px; }

.empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-dim);
}
.empty-icon { font-size: 52px; margin-bottom: 10px; }

.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
}

/* ---------- player page ---------- */
.player-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  white-space: nowrap;
  transition: border-color 0.15s;
}
.back-link:hover { border-color: var(--accent); }

.player-title {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.player-actions { display: flex; gap: 8px; }

.icon-btn {
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.faved { color: var(--gold); border-color: var(--gold); }

.frame-wrap {
  flex: 1;
  position: relative;
  background: #000;
}

#game-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .header-inner { flex-wrap: wrap; gap: 10px; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; }
  .header-meta { font-size: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .art { height: 88px; font-size: 30px; }
  .sort-wrap { margin-left: 0; }
  .player-title { font-size: 14px; }
  .icon-btn, .back-link { padding: 6px 10px; font-size: 13px; }
}
