:root {
  --bg: #edf2f8;
  --panel: #ffffff;
  --ink: #16243a;
  --ink-soft: #4f6480;
  --line: #d7e1ee;
  --brand: #005b7a;
  --brand-soft: #dff2f7;
  --brand-strong: #003d57;
  --radius: 14px;
  --header-h: 68px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% -20%, #cce8f3 10%, transparent 45%),
    radial-gradient(circle at 100% 0%, #e3ebf8 10%, transparent 50%),
    var(--bg);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  line-height: 1.55;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1rem;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  color: var(--brand-strong);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.95rem;
}

.top-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.top-nav a {
  text-decoration: none;
  color: var(--ink);
  padding: 0.48rem 0.72rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.94rem;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.top-nav a:hover,
.top-nav a:focus-visible {
  background: var(--brand-soft);
  border-color: #b8deea;
  outline: none;
}

.top-nav a.is-active {
  background: var(--brand);
  color: #fff;
}

.main-content {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem;
}

.hero,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.hero {
  padding: 1.5rem;
  margin-bottom: 1rem;
  background:
    linear-gradient(135deg, #d8eff7, #eef5fb 60%),
    var(--panel);
}

.eyebrow {
  margin: 0;
  color: var(--brand-strong);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.79rem;
  font-weight: 700;
}

h1,
h2,
h3 {
  margin-top: 0;
  line-height: 1.2;
}

.hero h1 {
  margin: 0.4rem 0 0.65rem;
  max-width: 20ch;
}

.hero-cta {
  display: inline-block;
  margin-top: 0.3rem;
  color: #fff;
  background: var(--brand);
  text-decoration: none;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
}

.panel {
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
}

.game-card {
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
  padding: 0.95rem;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.game-card:hover,
.game-card:focus-visible {
  outline: none;
  transform: translateY(-1px);
  border-color: #9cc6d4;
  box-shadow: 0 10px 26px rgba(22, 36, 58, 0.09);
}

.game-card.is-active {
  border-color: #5ea5bc;
  box-shadow: inset 0 0 0 1px #5ea5bc;
}

.game-card h3 {
  margin-bottom: 0.3rem;
}

.game-card p {
  margin: 0;
  color: var(--ink-soft);
}

.play-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.play-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.play-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ghost-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  background: #fff;
  padding: 0.55rem 0.85rem;
}

.game-shell {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #f2f7fd;
}

#game-frame {
  display: block;
  width: 100%;
  min-height: calc(100vh - var(--header-h) - 240px);
  border: 0;
  background: #fff;
}

body.is-playing .hero,
body.is-playing .library-panel,
body.is-playing .notes {
  display: none;
}

body.is-playing .main-content {
  max-width: none;
  padding: 0;
}

body.is-playing #play.panel {
  margin: 0;
  border: 0;
  padding: 0;
  background: transparent;
}

body.is-playing .game-shell {
  border: 0;
  border-radius: 0;
  background: transparent;
}

body.is-playing .play-head {
  display: none;
}

body.is-playing #game-frame {
  min-height: calc(100svh - var(--header-h));
  border-radius: 0;
}

.notes {
  color: var(--ink-soft);
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1rem;
  text-align: center;
  color: var(--ink-soft);
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 0.45rem;
}

.footer-links a {
  color: var(--brand);
}

@media (max-width: 860px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  #game-frame {
    min-height: 67vh;
  }

  body.is-playing .site-header {
    gap: 0.45rem;
    padding: 0.45rem 0.55rem;
  }

  body.is-playing .top-nav {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.1rem;
  }

  body.is-playing .top-nav a {
    white-space: nowrap;
    font-size: 0.86rem;
    padding: 0.35rem 0.58rem;
  }

  body.is-playing .play-head {
    display: none;
  }

  body.is-playing .play-head h2 {
    font-size: 1rem;
  }

  body.is-playing .play-actions {
    width: 100%;
  }

  body.is-playing .ghost-btn {
    font-size: 0.86rem;
    padding: 0.4rem 0.62rem;
  }

  body.is-playing #game-frame {
    min-height: calc(100svh - var(--header-h));
  }
}
