:root {
  --bg: #f4f6fa;
  --text: #222;
  --text-soft: #555;
  --card-bg: #ffffff;
  --label: #666;
  --input-border: #d0d4dc;
  --input-bg: #ffffff;
  --shadow: rgba(0, 0, 0, 0.06);
  --primary: #4a7dff;
  --primary-hover: #3a66d6;
  --link: #2c5be0;
  --border: #e3e6ec;
  --success: #2ea44f;
  --error: #d73a49;
  --warning-bg: #fff8db;
  --warning-border: #f0c14b;
  --warning-text: #6a4a00;
}
[data-theme="dark"] {
  --bg: #14171d;
  --text: #e8eaed;
  --text-soft: #b8bcc6;
  --card-bg: #20242c;
  --label: #aab0bc;
  --input-border: #3a4150;
  --input-bg: #20242c;
  --shadow: rgba(0, 0, 0, 0.4);
  --primary: #6a96ff;
  --primary-hover: #5a8dff;
  --link: #80a8ff;
  --border: #2a2f38;
  --success: #3fb950;
  --error: #f85149;
  --warning-bg: #3a2f10;
  --warning-border: #8a6b1f;
  --warning-text: #f0d68c;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Apple SD Gothic Neo', -apple-system, BlinkMacSystemFont,
               'Segoe UI', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  padding: 8px 12px;
  background: var(--primary);
  color: white;
  border-radius: 4px;
  z-index: 1000;
}
.skip-link:focus { left: 8px; }

/* ===== Site header / nav ===== */
.site-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
}
.site-nav {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.site-nav a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
}
.site-nav a:hover { background: var(--bg); text-decoration: none; }
.site-nav a.active { color: var(--primary); background: var(--bg); }
.theme-toggle {
  background: none;
  border: 1px solid var(--input-border);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  color: var(--text);
}
.theme-toggle:hover { background: var(--bg); }

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px; }
}

/* ===== Main / page layout ===== */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}
.page-title {
  font-size: 28px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.page-lead {
  color: var(--text-soft);
  margin: 0 0 32px;
  font-size: 16px;
}
article h2 {
  font-size: 22px;
  margin: 32px 0 12px;
  letter-spacing: -0.01em;
}
article h3 {
  font-size: 18px;
  margin: 24px 0 8px;
}
article p { margin: 0 0 14px; }
article ul, article ol { padding-left: 22px; margin: 0 0 14px; }
article li { margin-bottom: 6px; }
article table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
article th, article td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
}
article th { background: var(--bg); font-weight: 600; }
article blockquote {
  border-left: 3px solid var(--primary);
  margin: 16px 0;
  padding: 8px 16px;
  color: var(--text-soft);
  background: var(--card-bg);
}
.notice {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
  padding: 12px 16px;
  border-radius: 8px;
  margin: 16px 0;
  font-size: 14px;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 6px var(--shadow);
}
.card + .card { margin-top: 16px; }

/* ===== Lotto generator ===== */
.generator {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 6px var(--shadow);
  margin-bottom: 24px;
}
.controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.controls label { font-size: 14px; color: var(--label); }
input[type="number"], input[type="text"], input[type="email"], textarea {
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  border-radius: 8px;
  width: 100%;
}
input[type="number"] { width: 90px; text-align: center; }
input:focus, textarea:focus { outline: none; border-color: var(--primary); }
button.primary {
  padding: 10px 18px;
  font-size: 15px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}
button.primary:hover:not(:disabled) { background: var(--primary-hover); }
button.primary:disabled { opacity: 0.6; cursor: not-allowed; }

.game {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.game:first-child { border-top: none; }
.game .label {
  font-weight: 700;
  color: var(--label);
  min-width: 56px;
  font-size: 14px;
}
.ball {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: white;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.b1 { background: #fbc400; }
.b2 { background: #69c8f2; }
.b3 { background: #ff7272; }
.b4 { background: #888; }
.b5 { background: #b0d840; }

/* ===== Forms ===== */
form .field { margin-bottom: 14px; }
form label.block {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--label);
  margin-bottom: 6px;
}
form label .required { color: var(--error); margin-left: 4px; }
textarea { min-height: 120px; resize: vertical; }
.status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
  display: none;
}
.status.show { display: block; }
.status.success { background: var(--success); color: white; }
.status.error { background: var(--error); color: white; }

/* ===== Footer ===== */
.site-footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 32px 20px;
  margin-top: 32px;
  color: var(--text-soft);
  font-size: 14px;
}
.site-footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; }
.footer-links a { color: var(--text-soft); }
.footer-meta { font-size: 13px; color: var(--label); }

/* ===== Cookie consent ===== */
.consent {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  max-width: 560px;
  margin: 0 auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 24px var(--shadow);
  font-size: 14px;
  z-index: 100;
  display: none;
}
.consent.show { display: block; }
.consent p { margin: 0 0 12px; color: var(--text-soft); }
.consent .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.consent button {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.consent button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ===== Comments ===== */
.comments {
  margin-top: 32px;
  padding: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.comments h2 { margin: 0 0 16px; font-size: 18px; }
