:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1f2430;
  --muted: #667085;
  --accent: #5b6ee1;
  --accent-2: #7c5cff;
  --border: #e6e8f0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 20px rgba(16, 24, 40, 0.06);
  --shadow-hover: 0 8px 30px rgba(16, 24, 40, 0.12);
  --puzzle: #5b6ee1;
  --arcade: #f59e0b;
  --action: #ef4444;
  --classic: #10b981;
  --strategy: #8b5cf6;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand .logo { color: var(--accent); }
.site-nav { display: flex; gap: 18px; font-size: 0.95rem; }
.site-nav a { color: var(--muted); font-weight: 500; }
.site-nav a:hover { color: var(--text); text-decoration: none; }

/* ---------- Layout ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.hero { padding: 40px 0 8px; }
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0 0 10px;
  letter-spacing: -0.03em;
}
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 640px; margin: 0 0 6px; }
.section { padding: 28px 0; }
.section-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0 0 16px;
  letter-spacing: -0.02em;
}

/* ---------- Game grid / cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 18px;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  color: var(--text);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); text-decoration: none; }
.card-thumb {
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  background: linear-gradient(135deg, #eef0ff, #e9fbf3);
}
.card-body { padding: 12px 14px 14px; }
.card-title { font-weight: 700; font-size: 1.05rem; margin: 0 0 4px; }
.card-desc { color: var(--muted); font-size: 0.85rem; margin: 0 0 10px; }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
}
.badge-puzzle { background: var(--puzzle); }
.badge-arcade { background: var(--arcade); }
.badge-action { background: var(--action); }
.badge-classic { background: var(--classic); }
.badge-strategy { background: var(--strategy); }

/* ---------- Game page ---------- */
.game-page { padding: 24px 0 48px; }
.breadcrumb { font-size: 0.85rem; color: var(--muted); margin-bottom: 14px; }
.breadcrumb a { color: var(--muted); }
.game-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.game-head h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0; letter-spacing: -0.02em; }
.game-desc { color: var(--muted); max-width: 720px; font-size: 1.02rem; margin: 12px 0 0; }

/* ---------- Ad slot placeholder ---------- */
.ad-slot {
  margin: 20px 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: #98a2b3;
  font-size: 0.82rem;
  padding: 16px;
  background: #fbfbfd;
}

/* ---------- Game area ---------- */
.game-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
canvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #0f1420;
  touch-action: none;
}
.hud { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.hud .stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 16px;
  font-size: 0.9rem;
  font-weight: 600;
}
.hud .stat span { color: var(--accent); font-weight: 800; }
.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  touch-action: manipulation;
}
.btn:hover { background: var(--bg); border-color: #c9cfe0; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); }
.game-msg { font-weight: 700; min-height: 1.4em; color: var(--accent); text-align: center; }
.hint { color: var(--muted); font-size: 0.85rem; text-align: center; }

/* ---------- How to play / related ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-top: 22px;
}
.panel h2 { margin: 0 0 10px; font-size: 1.2rem; }
.panel ul { margin: 0; padding-left: 20px; }
.panel li { margin: 5px 0; }
.related-row { display: flex; gap: 12px; flex-wrap: wrap; }
.related-row a {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
}
.related-row a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ---------- Static pages ---------- */
.prose { max-width: 720px; }
.prose h2 { margin-top: 28px; }
.prose p, .prose li { color: var(--muted); }
.prose a { color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 40px;
}
.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
}
.footer-inner nav { display: flex; gap: 16px; }
.footer-inner a { color: var(--muted); }

@media (max-width: 560px) {
  .header-inner { flex-wrap: wrap; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card-thumb { font-size: 2.4rem; }
  .game-area { padding: 12px; }
}

/* ---------- Language toggle ---------- */
.lang-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.lang-toggle:hover { background: var(--bg); border-color: var(--accent); }
