:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --text: #0d1117;
  --text-secondary: #4b5563;
  --text-tertiary: #6b7280;
  --muted: #9ca3af;
  --accent: #2563eb;
  --accent-light: #60a5fa;
  --accent-hover: #1d4ed8;
  --accent-dim: rgba(37, 99, 235, 0.12);
  --border: #e5e7eb;
  --separator: rgba(0, 0, 0, 0.08);
  --hero-bg: #0f172a;
  --hero-text: #f8fafc;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  --max-content: 760px;
  --max-wide: 1100px;
  --topbar-height: 64px;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --surface: #111827;
    --surface-elevated: #1f2937;
    --text: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --muted: #6b7280;
    --accent: #60a5fa;
    --accent-light: #93c5fd;
    --accent-hover: #3b82f6;
    --accent-dim: rgba(96, 165, 250, 0.15);
    --border: #1f2937;
    --separator: rgba(255, 255, 255, 0.08);
    --hero-bg: #020617;
    --hero-text: #f8fafc;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-height) + 16px);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover { text-decoration: underline; }

img {
  max-width: 100%;
  height: auto;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  z-index: 100;
  border-radius: 0 0 var(--radius-md) 0;
  font-weight: 600;
}

.skip-link:focus { top: 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.98rem;
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
  border: none;
  cursor: pointer;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

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

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--surface-elevated); }

.btn-hero-ghost {
  background: rgba(255, 255, 255, 0.1);
  color: var(--hero-text);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-hero-ghost:hover { background: rgba(255, 255, 255, 0.18); }

.btn-sm {
  padding: 8px 16px;
  font-size: 0.9rem;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-height);
}

@media (prefers-color-scheme: dark) {
  .topbar { background: rgba(11, 15, 23, 0.88); }
}

.topbar-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.brand-mark:hover { text-decoration: none; }

.brand-mark img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topnav a {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.94rem;
  font-weight: 500;
  white-space: nowrap;
}

.topnav a:hover { background: var(--border); color: var(--text); text-decoration: none; }

.topnav a.is-active {
  color: var(--text);
  background: var(--accent-dim);
  font-weight: 600;
}

.lang-switcher select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px 28px 7px 12px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
}

.lang-switcher select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
}

/* Hero */
.hero {
  position: relative;
  background: var(--hero-bg);
  color: var(--hero-text);
  padding: 96px 0 80px;
  text-align: center;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(37, 99, 235, 0.18) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(96, 165, 250, 0.12) 0%, transparent 45%);
  pointer-events: none;
}

.hero-grid {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='64' viewBox='0 0 56 64'%3E%3Cpath d='M28 0l28 16v32l-28 16L0 48V16z' fill='none' stroke='%23ffffff' stroke-width='1'/%3E%3C/svg%3E");
  pointer-events: none;
}

.hero .page-shell { position: relative; z-index: 1; }

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 16px;
}

.hero h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  line-height: 1.1;
  margin: 0 auto 20px;
  max-width: 760px;
  font-weight: 800;
}

.hero p {
  font-size: clamp(1.05rem, 2.5vw, 1.25rem);
  opacity: 0.85;
  max-width: 620px;
  margin: 0 auto 32px;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.hero-trust {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  font-size: 0.85rem;
  opacity: 0.7;
}

.hero-trust span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.section-header {
  text-align: center;
  max-width: 620px;
  margin: 0 auto 48px;
  padding: 0 20px;
}

.section-kicker {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.section-title {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin: 0 0 12px;
  font-weight: 700;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin: 0;
}

.page-shell {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 0 20px;
}

.page-wide {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 20px;
}

/* Feature grid */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  transition: transform var(--transition), box-shadow var(--transition);
}

.feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.feature-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--accent-dim);
  color: var(--accent);
  margin-bottom: 16px;
}

.feature-card h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.feature-card p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.6;
}

/* How to play */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  counter-reset: step;
}

.step-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.step-card::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.step-card h4 {
  margin: 8px 0 8px;
  font-size: 1rem;
}

.step-card p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
}

/* Legal layout */
.legal-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 40px;
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 48px 20px 80px;
  align-items: start;
}

.toc {
  position: sticky;
  top: calc(var(--topbar-height) + 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
}

.toc-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin: 0 0 14px;
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc li { margin-bottom: 6px; }

.toc a {
  display: block;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.4;
}

.toc a:hover { background: var(--border); color: var(--text); text-decoration: none; }

.toc a.is-active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.toc-select {
  display: none;
  width: 100%;
  margin-bottom: 20px;
}

.legal-content {
  min-width: 0;
}

.page-hero {
  padding: 64px 0 40px;
  text-align: center;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 10px;
}

.page-title {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  margin: 0 0 12px;
  font-weight: 800;
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin: 0 auto 16px;
  max-width: 620px;
}

.meta-row {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: var(--text-tertiary);
}

.legal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  scroll-margin-top: calc(var(--topbar-height) + 16px);
}

.legal-card h2 {
  font-size: 1.25rem;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 800;
}

.legal-card p {
  color: var(--text-secondary);
  margin: 0 0 14px;
}

.legal-card p:last-child { margin-bottom: 0; }

.legal-card ul, .legal-card ol {
  color: var(--text-secondary);
  padding-left: 22px;
  margin: 0 0 14px;
}

.legal-card li { margin-bottom: 8px; }

.legal-card li:last-child { margin-bottom: 0; }

.legal-table-wrap {
  overflow-x: auto;
  margin-bottom: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.legal-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.92rem;
  min-width: 560px;
}

.legal-table th, .legal-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.legal-table th {
  background: var(--surface-elevated);
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.legal-table tr:last-child td { border-bottom: none; }

.service-list {
  display: grid;
  gap: 12px;
}

.service-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.service-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--accent-dim);
  color: var(--accent);
  flex-shrink: 0;
}

.service-item h4 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.service-item p {
  margin: 0;
  font-size: 0.92rem;
}

/* Rules specific */
.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.rule-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
}

.rule-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.rule-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--accent-dim);
  color: var(--accent);
}

.rule-card h4 {
  margin: 0;
  font-size: 1.05rem;
}

.rule-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.rule-card li { margin-bottom: 6px; }

/* Bottom CTA */
.bottom-cta {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 64px 0;
  text-align: center;
}

.bottom-cta h2 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin: 0 0 12px;
}

.bottom-cta p {
  color: var(--text-secondary);
  margin: 0 auto 24px;
  max-width: 520px;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 56px 0 32px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 40px;
}

.footer-brand img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.footer-brand .brand-name {
  color: var(--text);
  font-weight: 800;
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.footer-brand p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin: 4px 0;
}

.footer-group h4 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin: 0 0 14px;
}

.footer-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-group a {
  color: var(--text-secondary);
  font-size: 0.94rem;
}

.footer-group a:hover { color: var(--accent); }

.footer-bottom {
  max-width: var(--max-wide);
  margin: 32px auto 0;
  padding: 20px 20px 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text-tertiary);
  font-size: 0.88rem;
}

/* Acknowledgements */
.license-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  background: var(--surface);
}

.license-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 560px;
}

.license-table th, .license-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.license-table th {
  background: var(--surface-elevated);
  color: var(--text);
  font-weight: 700;
  position: sticky;
  top: 0;
}

.license-table tr:last-child td { border-bottom: none; }

.license-note {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-top: 16px;
}

/* Animations */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 500ms ease, transform 500ms ease;
  }

  .reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* Responsive */
@media (max-width: 900px) {
  .legal-layout {
    grid-template-columns: 1fr;
    padding-top: 24px;
  }

  .toc { display: none; }

  .toc-select {
    display: block;
    appearance: none;
    -webkit-appearance: none;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 36px 12px 14px;
    font-size: 0.95rem;
    font-weight: 500;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
  }

  .steps-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  :root { --topbar-height: 56px; }

  .topbar-inner { padding: 0 16px; }

  .topnav, .lang-switcher { display: none; }

  .menu-toggle { display: block; }

  .topbar.is-open .topnav,
  .topbar.is-open .lang-switcher {
    display: flex;
    position: absolute;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    box-shadow: var(--shadow-lg);
  }

  .topbar.is-open .topnav a {
    padding: 10px 12px;
  }

  .topbar.is-open .lang-switcher select {
    width: 100%;
  }

  .hero { padding: 72px 0 56px; }

  .section { padding: 56px 0; }

  .feature-grid { grid-template-columns: 1fr; }

  .steps-grid { grid-template-columns: 1fr; }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Print */
@media print {
  .topbar, .footer, .bottom-cta, .hero-actions, .toc, .toc-select, .menu-toggle {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  a {
    color: #000 !important;
    text-decoration: underline !important;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-break: break-all;
  }

  .hero {
    background: #fff !important;
    color: #000 !important;
    padding: 24px 0 !important;
  }

  .legal-card, .feature-card, .rule-card, .step-card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    break-inside: avoid;
  }

  .legal-layout {
    display: block !important;
    padding-top: 0 !important;
  }
}
