:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f6;
  --text: #1a1c24;
  --text-muted: #6b7280;
  --border: #e3e6ee;
  --primary: #6366f1;
  --primary-hover: #4f52e0;
  --accent: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 10px 30px rgba(20, 24, 50, 0.08);
  --shadow-sm: 0 4px 12px rgba(20, 24, 50, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --num: #6366f1;
  --word: #10b981;
  --other: #f59e0b;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d26;
  --surface-2: #232733;
  --text: #e8eaf1;
  --text-muted: #9aa1b1;
  --border: #2b3040;
  --primary: #818cf8;
  --primary-hover: #93a0ff;
  --accent: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  transition: background 0.3s ease, color 0.3s ease;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--text);
}

.brand .logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  padding: 7px;
  box-sizing: border-box;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.theme-toggle {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  transition: transform 0.2s ease, background 0.2s ease;
}

.theme-toggle:hover {
  transform: rotate(20deg);
  background: var(--border);
}

.btn-back {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-back:hover {
  color: var(--primary);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--primary);
  color: #fff;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: var(--primary-hover);
}

.btn:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-outline {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--surface-2);
}

.btn-block {
  width: 100%;
}

/* ===== Hero ===== */
.hero {
  padding: 70px 0 34px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
  background: linear-gradient(120deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto;
}

/* ===== Sections ===== */
.section {
  padding: 34px 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 22px;
}

.section-title .dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.section-title .dot.num { background: var(--num); }
.section-title .dot.word { background: var(--word); }
.section-title .dot.other { background: var(--other); }

.section-title .count {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== Game cards grid ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.card.num::before { background: var(--num); }
.card.word::before { background: var(--word); }
.card.other::before { background: var(--other); }

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.card .icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  background: var(--surface-2);
}

.card.num .icon { color: var(--num); }
.card.word .icon { color: var(--word); }
.card.other .icon { color: var(--other); }

.card h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  flex: 1;
}

.card .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.tag.difficulty {
  background: color-mix(in srgb, var(--warning) 15%, transparent);
  color: var(--warning);
}

.card .play {
  margin-top: 4px;
}

.best-score {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.best-score strong {
  color: var(--accent);
}

/* ===== Footer ===== */
.site-footer {
  margin-top: auto;
  padding: 30px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .hero {
    padding: 44px 0 24px;
  }
  .grid {
    grid-template-columns: 1fr;
  }
}
