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

:root {
  --bg:        #1c1f30;
  --surface:   #22263a;
  --border:    #2e3348;
  --orange:    #f5621e;
  --orange-dk: #c44610;
  --text:      #e8eaf0;
  --muted:     #6b7280;
  --tag-bg:    #282c42;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-img img { display: block; height: 38px; width: auto; }

nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  margin-left: 1.5rem;
  transition: color .2s;
}
nav a:hover { color: var(--text); }

/* ── Main layout ─────────────────────────────────── */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: auto 1fr;
  gap: 0;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

/* ── Game title row ──────────────────────────────── */
.game-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.game-icon {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: var(--surface);
  flex-shrink: 0;
}

.game-title-block h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: .06em;
  line-height: 1;
  color: var(--text);
}

.game-title-block .byline {
  color: var(--muted);
  font-size: .875rem;
  margin-top: .3rem;
}

.game-title-block .byline a {
  color: var(--orange);
  text-decoration: none;
}
.game-title-block .byline a:hover { text-decoration: underline; }

/* ── Player column ───────────────────────────────── */
.player-col {
  min-width: 0;
  padding-right: 2rem;
}

.ruffle-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

ruffle-player, ruffle-embed {
  display: block;
  width: 100%;
  height: 100%;
}

/* Fullscreen button */
.fs-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0,0,0,.6);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  border-radius: 6px;
  padding: .35rem .65rem;
  font-size: .75rem;
  cursor: pointer;
  transition: background .2s;
  z-index: 10;
  backdrop-filter: blur(4px);
}
.fs-btn:hover { background: rgba(255,255,255,.15); }

/* Controls bar */
.controls {
  display: flex;
  gap: .75rem;
  margin-top: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: filter .2s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--orange);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.12); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--muted); }

/* Rating */
.rating {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .875rem;
  color: var(--muted);
}
.stars { color: var(--orange); letter-spacing: .05em; }

/* ── Sidebar ─────────────────────────────────────── */
.sidebar { min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: .08em;
  color: var(--orange);
  margin-bottom: .85rem;
}

.meta-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.meta-table td { padding: .35rem 0; vertical-align: top; }
.meta-table td:first-child { color: var(--muted); width: 42%; white-space: nowrap; }
.meta-table tr + tr td { border-top: 1px solid var(--border); }

.tags { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .25rem; }
.tag {
  background: var(--tag-bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: .2rem .65rem;
  font-size: .78rem;
  transition: color .2s, border-color .2s;
  cursor: pointer;
}
.tag:hover { color: var(--text); border-color: var(--muted); }

.desc { font-size: .9rem; line-height: 1.6; color: #b0b8c8; }
.desc p + p { margin-top: .6rem; }

/* ── How to play ─────────────────────────────────── */
.how-to li {
  font-size: .88rem;
  color: #b0b8c8;
  line-height: 1.5;
  padding: .3rem 0;
  padding-left: 1.1rem;
  position: relative;
}
.how-to li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--orange);
}
.how-to li + li { border-top: 1px solid var(--border); }

/* ── More Games ──────────────────────────────────── */
.more-games-section { margin-top: 1.5rem; }
.more-games-section h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.3rem;
  letter-spacing: .08em;
  color: var(--orange);
  margin-bottom: 1rem;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .85rem;
}

.game-thumb {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  transition: border-color .2s, transform .2s;
  cursor: pointer;
}
.game-thumb:hover {
  border-color: var(--orange);
  transform: translateY(-3px);
}

.game-thumb-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--bg);
}

/* Placeholder when no image is set */
.game-thumb-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--border);
  border-bottom: 1px solid var(--border);
}

.game-thumb-info {
  padding: .5rem .65rem .6rem;
}
.game-thumb-title {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-thumb-meta {
  font-size: .72rem;
  color: var(--muted);
  margin-top: .15rem;
}

/* ── Footer ──────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
    padding: 1rem 1rem 3rem;
  }
  .player-col { padding-right: 0; margin-bottom: 1.5rem; }
  .game-header { grid-column: 1; }
}

/* ── Fade-in ─────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.game-header  { animation: fadeUp .4s ease both; }
.player-col   { animation: fadeUp .4s .1s ease both; }
.sidebar      { animation: fadeUp .4s .2s ease both; }
