* { box-sizing: border-box; }
:root {
  --bg: #0f172a;
  --surface: #111827;
  --surface-2: #0b1022;
  --text: #e5e7eb;
  --text-weak: #94a3b8;
  --primary: #3b82f6;
  --shadow-light: rgba(255,255,255,0.06);
  --shadow-dark: rgba(0,0,0,0.65);
  --elev: 12px;
}
.theme-light {
  --bg: #e9eef8;
  --surface: #f3f6fd;
  --surface-2: #eef3fe;
  --text: #1f2937;
  --text-weak: #6b7280;
  --primary: #2563eb;
  --shadow-light: rgba(255,255,255,0.9);
  --shadow-dark: rgba(0,0,0,0.18);
}
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: min(560px, 92vw) 1fr;
  grid-template-areas:
    'nav nav'
    'main sidebar';
  align-items: start;
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  scroll-behavior: smooth;
}
/* Navbar */
.navbar {
  grid-area: nav;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  margin: 30px 24px 50px 24px;
  background: var(--surface);
  border: 1px solid rgba(0,0,0,0.04);
  border-radius: 14px;
  box-shadow: 10px 10px var(--elev) var(--shadow-dark), -10px -10px var(--elev) var(--shadow-light);
}
.navbar .brand {
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.navbar .logo {
  font-weight: 700;
  letter-spacing: 0.4px;
}
.navbar .slogan {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-weak);
}
.navbar .links a {
  color: var(--text);
  text-decoration: none;
  margin-left: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.04);
  background: var(--surface);
  box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}
.navbar .links a:hover, .navbar .links a:focus {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 8px 10px 16px var(--shadow-dark), -8px -10px 16px var(--shadow-light);
}
.card {
  grid-area: main;
  width: min(560px, 92vw);
  background: var(--surface);
  border: 1px solid rgba(0,0,0,0.04);
  border-radius: 14px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 10px 10px var(--elev) var(--shadow-dark), -10px -10px var(--elev) var(--shadow-light);
  justify-self: center;
}
h1 {
  margin: 0 0 10px 0;
  font-size: 1.5rem;
  letter-spacing: 0.2px;
}
p {
  margin: 10px 0 22px 0;
  color: var(--text-weak);
  line-height: 1.55;
}
.notice {
  font-size: 1rem;
  font-weight: bold;
  color: #f87171;
  margin-bottom: 16px;
}
a.cta {
  display: inline-block;
  padding: 12px 18px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}
a.cta:focus, a.cta:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 10px 12px var(--elev) var(--shadow-dark), -10px -12px var(--elev) var(--shadow-light);
}
.small {
  margin-top: 14px;
  font-size: 0.9rem;
  color: var(--text-weak);
}
/* Sidebar */
.sidebar {
  grid-area: sidebar;
  width: min(420px, 90vw);
  margin: 16px;
  margin-left: 24px;
  background: var(--surface-2);
  border: 1px solid rgba(0,0,0,0.04);
  border-radius: 12px;
  padding: 18px 16px;
  box-shadow: 10px 10px var(--elev) var(--shadow-dark), -10px -10px var(--elev) var(--shadow-light);
  position: static;
  height: fit-content;
}
.sidebar h2 {
  margin: 0 0 6px 0;
  font-size: 1.1rem;
}
.sidebar h3 {
  margin: 14px 0 6px 0;
  font-size: 1rem;
  color: var(--text-weak);
}
.sidebar ul {
  margin: 6px 0 10px 18px;
}
.sidebar li {
  margin: 6px 0;
}
/* Game styles */
.game {
  margin-top: 18px;
  text-align: left;
}
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.game .hint {
  color: #9ca3af;
  font-size: 0.9rem;
}
.game .score {
  font-variant-numeric: tabular-nums;
}
.canvas-wrap {
  background: var(--surface-2);
  border: 1px solid rgba(0,0,0,0.04);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 8px 8px 14px var(--shadow-dark), inset -8px -8px 14px var(--shadow-light);
  transition: box-shadow 200ms ease;
}
.canvas-wrap:hover {
  box-shadow: inset 10px 10px 18px var(--shadow-dark), inset -10px -10px 18px var(--shadow-light);
}
canvas#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
}

/* Cards grid */
.cards {
  grid-column: 2;
  display: grid;
  gap: 16px;
  margin: 16px 24px 0 24px;
}
.info-card {
  background: var(--surface);
  border: 1px solid rgba(0,0,0,0.04);
  border-radius: 12px;
  padding: 16px 14px;
  box-shadow: 8px 8px var(--elev) var(--shadow-dark), -8px -8px var(--elev) var(--shadow-light);
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.info-card:hover, .info-card:focus-within {
  transform: translateY(-2px);
  box-shadow: 10px 12px var(--elev) var(--shadow-dark), -10px -12px var(--elev) var(--shadow-light);
}
.info-card h3 {
  margin: 0 0 8px 0;
}
.info-card p, .info-card li {
  color: var(--text-weak);
}

/* Theme toggle */
.theme-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.06);
  background: var(--surface);
  color: var(--text);
  box-shadow: 8px 8px 18px var(--shadow-dark), -8px -8px 18px var(--shadow-light);
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}
.theme-toggle:focus, .theme-toggle:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 10px 12px 22px var(--shadow-dark), -10px -12px 22px var(--shadow-light);
}

/* Responsive layout: stack on small screens */
@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
    grid-template-areas:
      'nav'
      'main'
      'sidebar';
    justify-items: center;
  }
  .navbar {
    margin: 12px 12px 16px 12px;
    padding: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .navbar .brand {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
  }
  .navbar .slogan {
    font-size: 0.9rem;
  }
  .navbar .links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  .navbar .links a {
    margin-left: 0;
    flex: 1 1 120px;
    text-align: center;
  }
  .cards {
    width: min(680px, 92vw);
    grid-column: 1;
    margin: 16px 0 16px 0;
  }
  .sidebar {
    width: min(680px, 92vw);
    margin: 0 0 24px 0;
    position: static;
    max-height: none;
    right: auto;
    top: auto;
    overflow: visible;
  }
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  html, body { scroll-behavior: auto; }
}
