:root {
  --bg: #0f1220;
  --bg-soft: #171b2e;
  --card: #1d2238;
  --card-hover: #252b47;
  --text: #eef0fa;
  --text-dim: #9aa1c2;
  --accent: #7c5cff;
  --accent-2: #00d4a6;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(124, 92, 255, 0.22), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(0, 212, 166, 0.14), transparent 55%),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.site-header {
  padding: 28px 24px 8px;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  font-size: 2.4rem;
  filter: drop-shadow(0 4px 12px rgba(124, 92, 255, 0.5));
}

.logo h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.pill {
  background: var(--bg-soft);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ---------- Grid ---------- */
main {
  flex: 1;
}

.grid-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  width: 100%;
}

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

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  animation: rise 0.45s ease both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

.game-card:hover {
  transform: translateY(-6px) scale(1.02);
  background: var(--card-hover);
  border-color: rgba(124, 92, 255, 0.55);
}

.game-card:hover .card-play {
  color: var(--accent-2);
}

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

.card-cover {
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #2a3055, #1a1f38);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  overflow: hidden;
}

.card-cover.no-image {
  color: rgba(255, 255, 255, 0.35);
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-body h3 {
  margin: 0;
  font-size: 1.05rem;
}

.card-body p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.4;
}

.badge {
  align-self: flex-start;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-2);
  border: 1px solid rgba(0, 212, 166, 0.4);
  border-radius: 999px;
  padding: 3px 10px;
}

.card-play {
  margin-top: auto;
  font-size: 0.85rem;
  color: var(--text-dim);
  transition: color 0.18s ease;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 70px 24px;
  background: var(--bg-soft);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
}

.empty-state.hidden { display: none; }

.empty-icon { font-size: 3.2rem; margin-bottom: 12px; }

.empty-state h2 { margin: 0 0 8px; }

.empty-state > p {
  color: var(--text-dim);
  margin: 0 0 20px;
}

.add-steps {
  max-width: 480px;
  margin: 0 auto 24px;
  padding-left: 22px;
  color: var(--text-dim);
  line-height: 2;
  text-align: left;
}

.add-steps code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.85em;
  color: var(--text);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  background: linear-gradient(90deg, var(--accent), #5a3df0);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.btn:hover { filter: brightness(1.12); transform: translateY(-1px); }

/* ---------- Player ---------- */
.play-view body,
body.play-view { display: flex; flex-direction: column; height: 100vh; min-height: 100vh; }

.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: var(--bg-soft);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.player-title {
  font-weight: 600;
  letter-spacing: 0.4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-header .btn-back { background: rgba(255, 255, 255, 0.1); }

.player-frame-wrap {
  flex: 1;
  padding: 16px;
  display: flex;
  min-height: 0;
}

body.play-view:fullscreen { padding: 0; }

.game-frame {
  flex: 1;
  border: none;
  border-radius: var(--radius);
  background: #000;
  box-shadow: var(--shadow);
  min-height: 0;
}

.player-error {
  margin: auto;
  color: var(--text-dim);
}

.player-error a { color: var(--accent-2); }

/* ---------- Footer ---------- */
.site-footer {
  padding: 18px 24px 28px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.site-footer code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: 6px;
  color: var(--text);
}

@media (max-width: 560px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .player-header { flex-wrap: wrap; }
}
