:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e6e8f0;
  --border-hover: #d3d7e6;
  --text: #1a1d29;
  --muted: #6b7280;
  --prose: #33384a;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --brand-soft-hover: #e3e9ff;
  --on-soft: #4338ca;
  --input-bg: #ffffff;
  --hover: #f1f2f7;
  --chip: #f0f1f6;
  --header-bg: rgba(255, 255, 255, 0.85);
  --toast-bg: #1f2430;
  --accent: #2563eb;
  --good: #16a34a;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e1016;
  --surface: #171a22;
  --border: #2a2f3c;
  --border-hover: #3a4150;
  --text: #e7e9f0;
  --muted: #9aa1b2;
  --prose: #c4c8d4;
  --brand: #6366f1;
  --brand-dark: #4f46e5;
  --brand-soft: #20233a;
  --brand-soft-hover: #2a2e4a;
  --on-soft: #c7d2fe;
  --input-bg: #1e222c;
  --hover: #232833;
  --chip: #232833;
  --header-bg: rgba(14, 16, 22, 0.82);
  --toast-bg: #2a2f3c;
  --accent: #60a5fa;
  --good: #34d399;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
header.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.top-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo .dot { color: var(--brand); }
.top-spacer { flex: 1; }
.nav-link {
  color: var(--muted);
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
}
.nav-link:hover { color: var(--text); text-decoration: none; }

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--brand);
  color: #fff;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--hover); }
.btn.subtle { background: var(--brand-soft); color: var(--on-soft); }
.btn.subtle:hover { background: var(--brand-soft-hover); }
.btn.sm { padding: 6px 12px; font-size: 14px; }
.btn.pill { border-radius: 999px; }

/* Light/dark toggle */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { background: var(--hover); border-color: var(--border-hover); }

/* Layout */
main { max-width: 1080px; margin: 0 auto; padding: 28px 20px 80px; }
.hidden { display: none !important; }

/* Hero */
.hero {
  text-align: center;
  padding: 40px 16px 26px;
}
.hero h1 {
  font-size: clamp(30px, 5vw, 46px);
  letter-spacing: -0.03em;
  margin: 0 0 12px;
  line-height: 1.1;
}
.hero p { color: var(--muted); font-size: 18px; max-width: 620px; margin: 0 auto; }
.hero .badge {
  display: inline-block;
  background: var(--brand-soft);
  color: var(--on-soft);
  font-weight: 600;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 18px;
}

/* Game grid */
.section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 40px 0 16px;
}
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.game-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--border-hover);
}
.game-card .ic { font-size: 34px; }
.game-card h3 { margin: 12px 0 6px; font-size: 19px; }
.game-card p { margin: 0; color: var(--muted); font-size: 14px; }
.game-card.soon { opacity: 0.7; cursor: default; }
.game-card.soon:hover { transform: none; box-shadow: none; }

/* Puzzle-of-the-Day tile (same footprint as a game card, but highlighted) */
.game-card.daily-tile {
  background: linear-gradient(150deg, var(--brand), var(--brand-dark));
  border-color: transparent;
  color: #fff;
}
.game-card.daily-tile h3 { color: #fff; }
.game-card.daily-tile p { color: rgba(255, 255, 255, 0.85); }
.daily-cta {
  display: inline-block;
  margin-top: 12px;
  font-weight: 700;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 10px;
  border-radius: 999px;
}
.soon-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--chip);
  border-radius: 6px;
  padding: 2px 7px;
  margin-top: 10px;
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 20px; }

/* Builder layout */
.builder { display: grid; grid-template-columns: 300px 1fr; gap: 22px; align-items: start; }
@media (max-width: 800px) { .builder { grid-template-columns: 1fr; } }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field select, .field input[type="number"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  background: var(--input-bg);
  color: var(--text);
}
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  text-transform: capitalize;
}
.seg button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.preview-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-wrap canvas, .preview-wrap img { max-width: 100%; height: auto; border-radius: 6px; }
.preview-empty { color: var(--muted); text-align: center; }

.opt-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: var(--input-bg);
  color: var(--text);
  resize: vertical;
  line-height: 1.5;
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.usage-note { color: var(--muted); font-size: 14px; margin-top: 12px; }
.locked-hint {
  display: flex; align-items: center; gap: 8px;
  background: var(--brand-soft); color: var(--on-soft);
  padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 500;
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 400px;
  padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.modal h2 { margin: 0 0 4px; font-size: 22px; }
.modal .sub { color: var(--muted); margin: 0 0 20px; font-size: 15px; }
.modal .field input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 10px; font-family: inherit; font-size: 15px;
  background: var(--input-bg); color: var(--text);
}
.modal .switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.form-error { color: var(--danger); font-size: 14px; margin: 8px 0 0; min-height: 18px; }

/* Pricing */
.pricing { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .pricing { grid-template-columns: 1fr; } }
.plan { border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; background: var(--surface); }
.plan.featured { border-color: var(--brand); box-shadow: var(--shadow); position: relative; }
.plan h3 { margin: 0; font-size: 18px; }
.plan .price { font-size: 34px; font-weight: 800; margin: 10px 0; }
.plan .price span { font-size: 15px; font-weight: 500; color: var(--muted); }
.plan ul { list-style: none; padding: 0; margin: 16px 0; }
.plan li { padding: 6px 0; padding-left: 26px; position: relative; font-size: 15px; }
.plan li::before { content: '✓'; position: absolute; left: 0; color: var(--good); font-weight: 700; }
.plan .tag {
  position: absolute; top: -12px; right: 18px; background: var(--brand);
  color: #fff; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 999px;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--toast-bg); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; z-index: 100; box-shadow: var(--shadow);
}

footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 28px 20px;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: center;
  margin-bottom: 14px;
}
.footer-links .nav-link { font-size: 14px; }
.footer-copy { font-size: 13px; }

/* Legal / policy pages */
.legal {
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 44px;
  box-shadow: var(--shadow);
}
.legal h1 { font-size: 30px; letter-spacing: -0.02em; margin: 0 0 8px; }
.legal h2 { font-size: 18px; margin: 28px 0 8px; }
.legal p, .legal li { color: var(--prose); font-size: 15.5px; }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 6px; }
.legal .muted { color: var(--muted); font-size: 14px; margin-top: 0; }
@media (max-width: 640px) { .legal { padding: 28px 22px; } }
