/* ============================================================
   Mahjong Tiles - site styles
   Static, dependency-free. Design tokens first.
   ============================================================ */

:root {
  --ink: #16201a;
  --ink-soft: #4a5a50;
  --paper: #fbfaf6;
  --paper-2: #f1efe7;
  --felt: #0d5c3f;
  --felt-dark: #083f2c;
  --felt-soft: #e7f0ea;
  --gold: #b8892b;
  --line: #dedbd0;
  --shadow: 0 10px 30px rgba(13, 40, 28, 0.08);
  --radius: 14px;
  --maxw: 1180px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--felt); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--felt-dark); }
img { max-width: 100%; display: block; }

.container { width: min(100% - 40px, var(--maxw)); margin-inline: auto; }

/* ---------- Header / navigation (CSS-only hamburger) ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(251, 250, 246, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: inline-block;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  object-fit: contain;
  flex: none;
}

.nav-toggle { display: none; }
.nav-toggle-label {
  display: none;
  cursor: pointer;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.nav-toggle-label span,
.nav-toggle-label span::before,
.nav-toggle-label span::after {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  content: "";
  position: relative;
  transition: transform .2s ease;
}
.nav-toggle-label span::before { position: absolute; top: -6px; }
.nav-toggle-label span::after { position: absolute; top: 6px; }

.site-nav {
  margin-left: auto;
}
.site-nav ul {
  display: flex;
  align-items: center;
  gap: 26px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.site-nav a {
  color: var(--ink-soft);
  font-size: 0.94rem;
  font-weight: 550;
  text-decoration: none;
}
.site-nav a:hover { color: var(--felt); }
.site-nav .nav-cta {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--felt);
  color: #fff;
}
.site-nav .nav-cta:hover { background: var(--felt-dark); color: #fff; }

/* ---------- Share button / popover ---------- */
.share-wrap { position: relative; display: flex; flex: none; margin-left: 0; }
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.share-btn:hover { color: var(--felt); border-color: var(--felt); background: var(--felt-soft); }
.share-btn svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.share-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 80;
  width: 214px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.share-wrap.open .share-menu { display: block; }
.share-menu a,
.share-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: .88rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.share-menu a:hover,
.share-menu button:hover { background: var(--paper-2); }
.share-ico {
  display: inline-grid;
  place-items: center;
  width: 25px; height: 25px;
  flex: none;
  border-radius: 6px;
  background: var(--felt);
  color: #fff;
  font-size: .65rem;
  font-weight: 800;
  line-height: 1;
}
.share-ico.x { background: #111827; }
.share-ico.fb { background: #1877f2; font-size: .9rem; }
.share-ico.li { background: #0a66c2; }
.share-ico.wa { background: #25d366; font-size: .58rem; }
.share-ico.mail { background: #64748b; font-size: .85rem; }
.share-ico.link { background: var(--gold); color: #2b2009; font-size: .9rem; }

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 80px;
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  padding: 48px 0 28px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 40px;
}
.footer-grid h2 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin-bottom: 8px; }
.footer-grid a { color: var(--ink-soft); text-decoration: none; font-size: 0.94rem; }
.footer-grid a:hover { color: var(--felt); text-decoration: underline; }
.footer-note {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* ---------- Typography blocks ---------- */

.hero { padding: 72px 0 44px; }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
}
.hero p.lede { font-size: 1.15rem; color: var(--ink-soft); max-width: 720px; margin: 0 0 24px; }

.answer-box {
  border-left: 4px solid var(--felt);
  background: var(--felt-soft);
  padding: 16px 20px;
  border-radius: 0 10px 10px 0;
  max-width: 780px;
  margin: 0 0 28px;
}
.answer-box p { margin: 0; }

.section { padding: 36px 0; }
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.section-head h2 {
  font-family: var(--serif);
  font-size: 1.9rem;
  line-height: 1.2;
  margin: 0;
}
.section-head p { margin: 6px 0 0; color: var(--ink-soft); }

.prose { max-width: 780px; }
.prose h2 { font-family: var(--serif); font-size: 1.7rem; margin-top: 36px; }
.prose h3 { font-size: 1.15rem; margin-top: 26px; }
.prose p, .prose li { color: var(--ink-soft); }
.prose ul { padding-left: 22px; }

.breadcrumb { font-size: 0.85rem; color: var(--ink-soft); margin: 28px 0 0; }
.breadcrumb a { color: var(--ink-soft); }

/* ---------- Game cards ---------- */

.game-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}
.game-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.game-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgba(13, 40, 28, 0.13); }
.game-card img { aspect-ratio: 16 / 10; object-fit: cover; background: var(--felt-soft); }
.game-card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.game-card h3 { margin: 0; font-family: var(--serif); font-size: 1.25rem; }
.game-card p { margin: 0; color: var(--ink-soft); font-size: 0.94rem; flex: 1; }
.game-card .card-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.game-card .btn { margin-top: 6px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--felt-soft);
  color: var(--felt-dark);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: .02em;
}
.badge.gold { background: #f6ecd7; color: #7a5a15; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 9px;
  background: var(--felt);
  color: #fff;
  font-weight: 650;
  text-decoration: none;
  border: 0;
  cursor: pointer;
}
.btn:hover { background: var(--felt-dark); color: #fff; }
.btn.secondary { background: #fff; color: var(--felt); border: 1px solid var(--felt); }
.btn.secondary:hover { background: var(--felt-soft); }

/* ---------- Game detail ---------- */

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 32px; align-items: start; }
.game-stage {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0b1f16;
  box-shadow: var(--shadow);
}
.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #122a1e;
  color: #e8f2ec;
  font-size: 0.85rem;
}
.stage-bar button {
  background: transparent;
  border: 1px solid #3c5b4b;
  color: #e8f2ec;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.8rem;
}
.stage-bar button:hover { background: #1c3b2b; }
.game-stage iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 0;
  background: #0b1f16;
}
.game-stage:fullscreen iframe { aspect-ratio: auto; height: 100vh; }

.fact-list { list-style: none; margin: 0; padding: 0; }
.fact-list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.fact-list li:last-child { border-bottom: 0; }
.fact-list strong { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.fact-list span { font-size: 0.96rem; }

.faq { margin-top: 20px; }
.faq details {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  margin-bottom: 10px;
  padding: 0 16px;
}
.faq summary { cursor: pointer; font-weight: 650; padding: 16px 0; }
.faq details p { margin: 0 0 16px; color: var(--ink-soft); }

.related { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.related a {
  display: block;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-decoration: none;
  font-weight: 600;
  color: var(--ink);
}
.related a:hover { border-color: var(--felt); color: var(--felt); }

.guide-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.guide-card {
  display: block;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
}
.guide-card h3 { font-family: var(--serif); margin: 0 0 8px; }
.guide-card p { margin: 0; color: var(--ink-soft); font-size: 0.94rem; }
.guide-card:hover { border-color: var(--felt); }

/* ---------- Minimal home ---------- */

.home-hero { padding: 54px 0 8px; text-align: center; }
.home-hero h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}
.home-hero p { margin: 0; color: var(--ink-soft); font-size: 1.05rem; }

.home-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  padding: 34px 0 40px;
}
.home-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.home-card:hover { transform: translateY(-4px); border-color: var(--felt); box-shadow: 0 18px 40px rgba(13, 40, 28, 0.15); }
.home-card img { aspect-ratio: 16 / 10; object-fit: cover; object-position: center; background: var(--felt-soft); flex: 0 0 auto; width: 100%; }
.home-card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.home-card h2 { margin: 0; font-family: var(--serif); font-size: 1.15rem; line-height: 1.3; }
.home-card p { margin: 0; color: var(--ink-soft); font-size: 0.9rem; flex: 1; }
.home-play {
  margin-top: 8px;
  display: inline-block;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--felt);
  color: #fff;
  font-weight: 650;
  font-size: 0.9rem;
  text-align: center;
}
.home-card:hover .home-play { background: var(--felt-dark); }

.home-footer { margin-top: 20px; padding: 26px 0; }
.home-footer .footer-note { margin: 0; padding: 0; border: 0; text-align: center; }

/* ---------- Direct-play stage (no iframe) ---------- */

.play-hero { text-align: center; }
.play-hero .answer-box { margin-inline: auto; text-align: left; }
.play-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 300px;
  padding: 40px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  text-align: center;
}
.play-panel img { width: 140px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; }
.play-panel h2 { margin: 0; font-family: var(--serif); font-size: 1.5rem; }
.play-panel p { margin: 0; color: var(--ink-soft); }
.play-panel .btn { padding: 14px 28px; font-size: 1.05rem; }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .game-grid, .guide-grid, .related { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-layout { grid-template-columns: 1fr; }
  .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .nav-toggle-label { display: inline-flex; margin-left: auto; }
  .site-nav {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 12px 20px 18px;
  }
  .nav-toggle:checked ~ .site-nav { display: block; }
  .nav-toggle:checked ~ .nav-toggle-label span { background: transparent; }
  .nav-toggle:checked ~ .nav-toggle-label span::before { top: 0; transform: rotate(45deg); }
  .nav-toggle:checked ~ .nav-toggle-label span::after { top: 0; transform: rotate(-45deg); }
  .site-nav ul { flex-direction: column; align-items: stretch; gap: 4px; }
  .site-nav a { display: block; padding: 10px 0; }
  .site-nav .nav-cta { text-align: center; margin-top: 8px; }
  .game-grid, .guide-grid, .related { grid-template-columns: 1fr; }
  .home-grid { grid-template-columns: 1fr; gap: 14px; }
  .home-hero { padding-top: 40px; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .hero { padding-top: 48px; }
  .section-head { flex-direction: column; align-items: start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
