/* Shared site chrome: left nav, menu button, panels switch, home page. */
:root {
  --site-nav-w: 240px;
  --site-paper: #efe5cc;
  --site-ink: #2a2f3a;
  --site-soft: #6b6656;
  --site-navy: #1f3566;
  --site-gold: #d6a531;
  --site-card: rgba(255, 252, 242, 0.7);
  --site-hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --site-body: "Nunito", system-ui, -apple-system, sans-serif;
}

/* Menu button: sits in the empty left column of each page header. */
.nav-toggle {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 16px;
  z-index: 30;
  width: 40px;
  height: 40px;
  padding: 9px;
  border: 0;
  border-radius: 50%;
  background: var(--site-card);
  box-shadow: inset 0 0 0 1px rgba(42, 47, 58, 0.12);
  color: var(--site-ink);
  cursor: pointer;
}
.nav-toggle:hover { box-shadow: inset 0 0 0 1.5px var(--site-gold); }
.nav-toggle svg, .nav-close svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* The nav itself */
.site-nav {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: min(var(--site-nav-w), 82vw);
  display: flex;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 12px 16px;
  background: var(--site-paper);
  box-shadow: 1px 0 0 rgba(42, 47, 58, 0.1), 6px 0 24px rgba(60, 45, 15, 0.12);
  font-family: var(--site-body);
  transform: translateX(-105%);
  transition: transform 0.25s ease;
  overflow-y: auto;
}
.nav-open .site-nav { transform: none; }

.nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 12px 8px;
}
.nav-brand {
  font-family: var(--site-hand);
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--site-navy);
  text-decoration: none;
}
.nav-close {
  width: 36px;
  height: 36px;
  padding: 9px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--site-soft);
  cursor: pointer;
}
.nav-close:hover { background: rgba(214, 165, 49, 0.22); }

.nav-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  color: var(--site-ink);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}
.nav-link:hover { background: rgba(255, 252, 242, 0.6); }
.nav-link[aria-current="page"] { background: var(--site-card); box-shadow: inset 0 0 0 1px rgba(42, 47, 58, 0.08); }
.nav-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 3px;
  background: var(--site-gold);
}
.nav-link img { width: 28px; height: 28px; border-radius: 7px; flex: none; }
.nav-home-icon {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 7px;
  background:
    linear-gradient(var(--site-navy), var(--site-navy)) 6px 6px / 7px 7px no-repeat,
    linear-gradient(var(--site-navy), var(--site-navy)) 15px 6px / 7px 7px no-repeat,
    linear-gradient(var(--site-navy), var(--site-navy)) 6px 15px / 7px 7px no-repeat,
    linear-gradient(var(--site-gold), var(--site-gold)) 15px 15px / 7px 7px no-repeat,
    var(--site-card);
}

.nav-foot { margin-top: auto; padding: 16px 4px 0; border-top: 1px solid rgba(42, 47, 58, 0.1); }
.nav-switch {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--site-ink);
  font: 600 0.9rem var(--site-body);
  cursor: pointer;
}
.nav-switch-track {
  position: relative;
  width: 40px;
  height: 24px;
  flex: none;
  border-radius: 12px;
  background: rgba(42, 47, 58, 0.18);
  transition: background 0.2s;
}
.nav-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fffaf0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.nav-switch[aria-checked="true"] .nav-switch-track { background: var(--site-navy); }
.nav-switch[aria-checked="true"] .nav-switch-track::after { transform: translateX(16px); }
.nav-note { margin: 4px 6px 0; font-size: 0.75rem; color: var(--site-soft); }

/* Phones and small tablets: the nav is a drawer over the page. */
.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(31, 53, 102, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
@media (max-width: 899.98px) {
  .nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
}

/* Wide screens: the open nav is a sidebar beside the page. */
@media (min-width: 900px) {
  .site-nav { box-shadow: 1px 0 0 rgba(42, 47, 58, 0.1); }
  body { transition: padding-left 0.25s ease; }
  .nav-open body { padding-left: var(--site-nav-w); }
  .nav-open .nav-toggle { display: none; }
}

/* "Scores & settings" off: show just the game. */
.panels-hidden .panel { display: none !important; }

/* Home page */
.home-intro {
  max-width: 420px;
  margin: 10px auto 0;
  text-align: center;
  color: var(--site-soft);
  font-size: 0.95rem;
  line-height: 1.5;
}
.game-list {
  list-style: none;
  width: 100%;
  max-width: 760px;
  margin: 24px auto 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 14px;
}
.game-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 18px;
  background: var(--site-card);
  box-shadow: 0 1px 0 rgba(42, 47, 58, 0.06), inset 0 0 0 1px rgba(42, 47, 58, 0.08);
  color: var(--site-ink);
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.game-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(60, 45, 15, 0.1), inset 0 0 0 1px rgba(214, 165, 49, 0.6); }
.game-card img { width: 72px; height: 72px; border-radius: 16px; flex: none; }
.game-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.game-title { font-family: var(--site-hand); font-size: 1.7rem; font-weight: 700; line-height: 1; color: var(--site-navy); }
.game-blurb { font-size: 0.86rem; line-height: 1.4; color: var(--site-ink); }
.game-meta { font-size: 0.75rem; font-weight: 600; color: var(--site-soft); }

@media (prefers-reduced-motion: reduce) {
  .site-nav, .nav-backdrop, body, .game-card { transition: none !important; }
}
