/* ---------- Design tokens ---------- */
:root {
  /* Light theme: Wheely sky — light blue with Wheely-blue, car-red and orange accents */
  --bg: #e9f5fb;
  --bg-glow-1: rgba(46, 154, 216, 0.16);
  --bg-glow-2: rgba(245, 145, 58, 0.13);
  --bg-glow-3: rgba(224, 67, 56, 0.08);
  --card: #ffffff;
  --card-hover: #fbfdff;
  --text: #21333f;
  --text-dim: #64798a;
  --border: rgba(33, 51, 63, 0.12);
  --header-bg: rgba(233, 245, 251, 0.85);
  --accent: #2387c4;
  --accent-2: #f5913a;
  --accent-3: #e04338;
  --btn-text: #ffffff;
  --thumb-bg: #ddedf6;
  --radius: 14px;
  --shadow: 0 10px 28px rgba(35, 90, 130, 0.16);
  --shadow-big: 0 18px 50px rgba(35, 90, 130, 0.22);
  --max-width: 1180px;
}

[data-theme="dark"] {
  /* Dark theme: Wheely night sky — deep blue with glowing accents */
  --bg: #15222d;
  --bg-glow-1: rgba(46, 154, 216, 0.18);
  --bg-glow-2: rgba(245, 145, 58, 0.1);
  --bg-glow-3: rgba(224, 67, 56, 0.08);
  --card: #1e2f3d;
  --card-hover: #243a4b;
  --text: #e9f1f7;
  --text-dim: #97aab9;
  --border: rgba(255, 255, 255, 0.1);
  --header-bg: rgba(21, 34, 45, 0.85);
  --accent: #4db5ed;
  --accent-2: #f5913a;
  --accent-3: #e8584d;
  --btn-text: #122029;
  --thumb-bg: #1a2a37;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-big: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 85% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(900px 500px at 5% -5%, var(--bg-glow-2), transparent 60%),
    radial-gradient(1300px 700px at 50% 110%, var(--bg-glow-3), transparent 65%),
    linear-gradient(165deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 86%, var(--accent)) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.25s, color 0.25s;
}

main { flex: 1; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none !important;
}

.brand-logo { height: 28px; width: auto; display: block; }

/* The logo artwork is black; flip it to white on the dark theme */
[data-theme="dark"] .brand-logo { filter: invert(1); }

.header-nav { display: flex; align-items: center; gap: 12px; }

.team-link,
.back-link {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-dim);
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: color 0.2s, border-color 0.2s;
}

.team-link:hover,
.back-link:hover {
  color: var(--text);
  border-color: var(--accent);
  text-decoration: none;
}

.theme-toggle {
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  transform: rotate(15deg);
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* ---------- Game grid ---------- */
/* 4 columns; featured cards span 2, so one row fits 2 featured = 4 regular */
.game-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 22px;
  padding: 40px 0 72px;
}

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

.game-card.featured .card-name { font-size: 1.35rem; padding-bottom: 16px; }

.game-card.featured .card-thumb,
.game-card.featured .card-thumb-placeholder {
  aspect-ratio: 16 / 9;
}

.game-card.featured .card-thumb-placeholder { font-size: 4rem; }

.game-card {
  position: relative;
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none !important;
  color: var(--text);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.game-card:hover {
  transform: translateY(-5px);
  background: var(--card-hover);
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 28px color-mix(in srgb, var(--accent) 30%, transparent);
}

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

.card-thumb-placeholder {
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Game name overlaid on the bottom of the picture */
.card-name {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
  padding: 34px 14px 12px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.35) 55%, transparent);
  pointer-events: none;
}

/* Category appears under the name on hover */
.card-cat {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.85);
  max-height: 0;
  opacity: 0;
  transform: translateY(4px);
  transition: max-height 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

/* Short description appears below the category on hover */
.card-desc {
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.9);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(4px);
  transition: max-height 0.22s ease, opacity 0.22s ease, transform 0.22s ease;
}

.game-card:hover .card-cat,
.game-card:focus-visible .card-cat {
  max-height: 1.4em;
  opacity: 1;
  transform: translateY(0);
}

.game-card:hover .card-desc,
.game-card:focus-visible .card-desc {
  max-height: 3em;
  opacity: 1;
  transform: translateY(0);
  margin-top: 4px;
}

/* ---------- Play page ---------- */
/* Single centered column: a compact title + small action buttons row above a
   large game window. The game is sized from the viewport height so it's the
   same size on every page and the footer stays visible. */
.play-main {
  max-width: 1600px;
  padding: 10px 24px;
}

.play-head {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 8px;
}

.play-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.play-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-fullscreen {
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--btn-text);
  background: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition: filter 0.15s;
}

.btn-fullscreen:hover { filter: brightness(1.08); }

.btn-walkthrough {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--accent-3);
  background: transparent;
  border: 1px solid var(--accent-3);
  border-radius: 999px;
  padding: 5px 13px;
  text-decoration: none !important;
  transition: background 0.15s, color 0.15s;
}

.btn-walkthrough:hover {
  background: var(--accent-3);
  color: #fff;
}

/* The hidden attribute must win over the display rules above. */
[hidden] { display: none !important; }

.player-stage {
  display: flex;
  justify-content: center;
  width: 100%;
}

/* Decorative frame around the game window. Its width is derived from the
   viewport height (minus the fixed page chrome) so the 4:3 frame is exactly
   the same size on every game page and hugs the game with no extra bars. */
.player-frame {
  --chrome: 212px;
  width: calc((100vh - var(--chrome)) * 4 / 3);
  max-width: min(100%, calc(100vw - 48px));
  padding: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 55%, var(--accent-3) 100%);
  border-radius: 18px;
  box-shadow: var(--shadow-big);
}

.player-container {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.player-container ruffle-player,
.player-container .player-iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

/* Small caption under the game. Fixed height so 1- vs 2-line descriptions
   don't shift the footer. */
.game-description {
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
  max-width: 70ch;
  margin: 8px auto 0;
  min-height: 2.3em;
}

.player-error {
  color: #cfc9d8;
  text-align: center;
  padding: 60px 20px;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 14px 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.footer-inner p { margin: 0; }

@media (max-width: 900px) {
  .game-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .game-grid { gap: 14px; padding-top: 24px; }
  .game-card.featured .card-name { font-size: 1.1rem; }
  .player-frame { padding: 6px; border-radius: 16px; }
  .footer-inner { justify-content: center; text-align: center; }
}
