@font-face {
  font-family: 'Bricolage';
  src: url('fonts/bricolage-latin-wdth.woff2') format('woff2');
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
}

:root {
  --bg: #e9ebe6;
  --ink: #18241e;
  --muted: #56635b;
  --surface: #f4f5f1;
  --line: rgba(24, 36, 30, 0.16);
  --line-strong: rgba(24, 36, 30, 0.36);
  --gut: clamp(20px, 5vw, 72px);
  --brass: #e4b952;
}
.js {
  --bg: #1b2b22;
  --ink: #e9ebe6;
  --muted: #9aa8a0;
  --surface: #22362b;
  --line: rgba(233, 235, 230, 0.16);
  --line-strong: rgba(233, 235, 230, 0.36);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Bricolage, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 17px;
  line-height: 1.5;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 6px; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; }
.skip:focus { top: 12px; }
.wrap { width: calc(100% - 2 * var(--gut)); max-width: 1500px; margin-inline: auto; }

#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100lvh; z-index: 0; transition: opacity 0.9s ease; }
.glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(60vmax 42vmax at 64% 56%, rgba(255, 205, 120, 0.17), transparent 62%);
}
main, .foot { position: relative; z-index: 1; }

/* ------------------------------------------------------------ nav */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px var(--gut);
  transition: background 0.3s, border-color 0.3s;
  border-bottom: 1px solid transparent;
}
.nav.is-solid {
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 750; letter-spacing: -0.01em; }
.logo {
  width: 36px; height: 36px; padding: 7px; border-radius: 11px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
  background: #fffdf8; transform: rotate(-3deg);
}
.logo span { border-radius: 3px; background: #47624b; }
.logo span:nth-child(2) { background: #e4b952; }
.logo span:nth-child(3) { background: #b87d69; }
.logo span:nth-child(4) { background: #7188a2; }
.nav nav { display: flex; align-items: center; gap: 28px; font-weight: 600; font-size: 0.95rem; }
.nav nav a:not(.nav-cta):hover { text-decoration: underline; text-underline-offset: 5px; }
.nav-cta { border: 1px solid var(--line-strong); padding: 9px 16px; border-radius: 12px; transition: background 0.2s, color 0.2s; }
.nav-cta:hover { background: var(--ink); color: var(--bg); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 22px; border-radius: 14px;
  border: 1px solid transparent; font-weight: 650; font-size: 1rem; line-height: 1;
  cursor: pointer; background: none; transition: transform 0.2s, background 0.2s, color 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.ghost { border-color: var(--line-strong); }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.btn.small { white-space: nowrap; flex: none; min-height: 40px; padding: 0 16px; border-color: var(--line-strong); font-size: 0.95rem; }
.btn.small:hover { background: var(--ink); color: var(--surface); }
.btn.big { min-height: 60px; padding: 0 30px; font-size: 1.1rem; }

/* ------------------------------------------------------------ 1. hero */
.hero { height: 360vh; position: relative; }
.hero-pin { position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden; }
.heroA { position: absolute; left: var(--gut); right: var(--gut); bottom: max(6svh, 24px); will-change: opacity, transform; }
.heroA h1 {
  margin: 0 0 0.32em;
  font-size: clamp(3rem, 8.2vw, 8.2rem);
  font-weight: 780; line-height: 0.9; letter-spacing: -0.02em; font-stretch: 74%;
}
.heroA h1 span { display: block; white-space: nowrap; }
.lede { margin: 0 0 22px; max-width: 28em; font-size: clamp(1.05rem, 1.5vw, 1.3rem); color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hint { margin: 16px 0 0; font-size: 0.9rem; color: var(--muted); }
@media (hover: none) { .hint { display: none; } }

.heroB {
  position: absolute; left: var(--gut); right: var(--gut); bottom: max(5svh, 22px);
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  padding-top: 20px; border-top: 1px solid var(--line);
  opacity: 0; visibility: hidden;
}
.heroB-title { margin: 0; font-size: clamp(1.7rem, 3.6vw, 3rem); font-weight: 720; font-stretch: 84%; line-height: 1.02; letter-spacing: -0.015em; }

/* ------------------------------------------------------------ 2. games */
.games { height: 170vh; height: 170svh; position: relative; }
.games-pin { position: sticky; top: 0; height: 100vh; height: 100svh; display: flex; align-items: center; }
.games-ui { width: min(48vw, 660px); padding: 8svh 0 4svh var(--gut); }
.small-h { margin: 0 0 1.6rem; font-size: 1rem; font-weight: 650; }
.small-h span { margin-left: 0.6em; font-weight: 500; color: var(--muted); }
.detail { min-height: 15.5rem; }
.g-name { margin: 0; font-size: clamp(2.6rem, 5.2vw, 5rem); font-weight: 760; font-stretch: 80%; line-height: 0.95; letter-spacing: -0.02em; }
.g-meta { margin: 0.8rem 0 0.7rem; }
.chip { display: inline-block; padding: 0.2em 0.75em; border-radius: 999px; background: var(--t, #d3e3cf); color: #1d2b24; font-weight: 650; font-size: 0.9rem; }
.g-line { margin: 0; max-width: 27em; font-size: 1.15rem; line-height: 1.45; }
.g-try { display: inline-block; margin-top: 0.7rem; font-weight: 650; border-bottom: 2px solid currentColor; }
.g-try[hidden] { display: none; }

.idx { margin-top: 1.4rem; }
.idx-row { display: grid; grid-template-columns: 6.4rem 1fr; gap: 12px; align-items: baseline; padding: 0.62rem 0; border-top: 1px solid var(--line); }
.idx-cat { margin: 0; display: flex; align-items: center; gap: 0.5em; font-size: 0.95rem; font-weight: 650; color: var(--muted); }
.idx-cat::before { content: ''; width: 0.7em; height: 0.7em; border-radius: 50%; background: var(--m); }
.idx-list { display: flex; flex-wrap: wrap; gap: 2px 4px; margin: 0; padding: 0; list-style: none; }
.gbtn {
  border: 1px solid transparent; background: none; cursor: pointer;
  padding: 0.26em 0.75em; border-radius: 999px; font-size: 1.05rem; font-weight: 620;
}
.gbtn:hover { border-color: var(--line-strong); }
.gbtn.is-active { background: var(--t); color: #1d2b24; }

.fallback { display: none; }
.nogl .fallback { display: block; position: absolute; right: var(--gut); top: 50%; transform: translateY(-50%); width: min(44vw, 560px); }
#fallback-tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.ftile { width: 100%; height: auto; cursor: pointer; }

/* ------------------------------------------------------------ 3. play */
.play { padding: clamp(80px, 16vh, 180px) 0; }
.play-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(32px, 6vw, 96px); align-items: start; }
.display-s { margin: 0 0 0.4em; font-size: clamp(2.4rem, 5vw, 4.4rem); font-weight: 740; font-stretch: 80%; line-height: 0.98; letter-spacing: -0.02em; }
.body { margin: 0; max-width: 34em; font-size: 1.1rem; line-height: 1.6; color: var(--muted); }
.tabs { margin-top: 2rem; }
.tab {
  display: grid; grid-template-columns: 14px 1fr; column-gap: 14px; align-items: baseline;
  width: 100%; text-align: left; padding: 16px 0; border: 0; border-top: 1px solid var(--line); background: none; cursor: pointer;
}
.tab:last-child { border-bottom: 1px solid var(--line); }
.tab::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: var(--line-strong); transition: background 0.2s, transform 0.2s; }
.tab b { font-size: 1.35rem; font-weight: 700; font-stretch: 84%; letter-spacing: -0.01em; }
.tab span { grid-column: 2; color: var(--muted); font-size: 0.98rem; }
.tab[aria-selected='true']::before { background: var(--ink); transform: rotate(45deg) scale(1.15); }
.tab:hover b { text-decoration: underline; text-underline-offset: 4px; }

.tray { background: var(--surface); border: 1px solid var(--line); border-radius: 36px; padding: clamp(18px, 3vw, 34px); overflow: hidden; }
.tray-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: clamp(16px, 2.4vw, 26px); }
.rule { margin: 0; max-width: 30em; font-size: 1rem; }
.status { margin: 18px 0 0; min-height: 1.5em; font-weight: 600; }
.board-slot { display: block; }

.aboard { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: clamp(4px, 1.2vw, 8px); width: min(100%, 540px); margin: auto; }
.acell { aspect-ratio: 1; border: 0; padding: 0; border-radius: clamp(10px, 2vw, 16px); background: var(--c); color: #1d2b24; display: grid; place-items: center; cursor: pointer; transition: transform 0.15s, opacity 0.45s ease; }
.acell.empty { background: color-mix(in srgb, var(--ink) 6%, transparent); cursor: default; }
.acell svg { width: 62%; height: 62%; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.acell:not(.empty):hover { transform: scale(1.05); }
.acell.hint { outline: 3px solid var(--ink); outline-offset: 2px; }
.acell.out { pointer-events: none; opacity: 0; transition: transform 0.5s cubic-bezier(0.5, 0, 0.9, 0.6), opacity 0.45s ease; }
.out-U { transform: translateY(-260%); } .out-D { transform: translateY(260%); }
.out-L { transform: translateX(-260%); } .out-R { transform: translateX(260%); }
.acell.shake { animation: shake 0.3s; }
@keyframes shake { 20% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 80% { transform: translateX(-3px); } }

.rboard { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(6px, 1.6vw, 12px); width: min(100%, 540px); margin: auto; }
.rcard { aspect-ratio: 3 / 4; perspective: 700px; border: 0; background: none; padding: 0; cursor: pointer; }
.rin { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.45s; }
.rcard.up .rin { transform: rotateY(180deg); }
.rface { position: absolute; inset: 0; display: grid; place-items: center; border-radius: clamp(10px, 2vw, 16px); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.rback { background: #bf6f58 repeating-linear-gradient(45deg, transparent 0 9px, rgba(255, 255, 255, 0.14) 9px 11px); }
.rfront { background: #f9faf6; transform: rotateY(180deg); box-shadow: inset 0 0 0 1px rgba(29, 43, 36, 0.14); }
.rfront svg { width: 52%; }
.rcard.done .rfront { box-shadow: inset 0 0 0 3px #4e7a58; }
.rcard:not(.up):hover .rin { transform: rotateY(-8deg); }

.lboard { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); width: min(100%, 520px); aspect-ratio: 1; margin: auto; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; outline-offset: 6px; }
.lcell { background: color-mix(in srgb, var(--ink) 7%, transparent); box-shadow: inset 0 0 0 3px var(--surface); border-radius: 14px; }
.lboard svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.lboard:not(.kb) .lcur { display: none; }

/* ------------------------------------------------------------ 4. ritual */
.ritual { padding: clamp(40px, 8vh, 100px) 0 clamp(80px, 16vh, 180px); }
.ritual-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(32px, 6vw, 96px); align-items: start; }
.ritual-head { position: sticky; top: 96px; }
.rows { margin: 0; }
.row { display: grid; grid-template-columns: 10.5rem 1fr; gap: 8px 28px; padding: 1.4rem 0; border-top: 1px solid var(--line); }
.row:last-child { border-bottom: 1px solid var(--line); }
.row dt { font-size: 1.3rem; font-weight: 700; font-stretch: 84%; letter-spacing: -0.01em; }
.row dd { margin: 0; max-width: 34em; font-size: 1.06rem; line-height: 1.55; color: color-mix(in srgb, var(--ink) 86%, transparent); }

/* ------------------------------------------------------------ 5. get */
.get { padding: clamp(40px, 10vh, 120px) 0 clamp(56px, 10vh, 120px); }
.get-title { margin: 0 0 0.35em; font-size: clamp(4.2rem, 15.5vw, 14.5rem); font-weight: 790; font-stretch: 72%; line-height: 0.84; letter-spacing: -0.03em; }
.get-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 40px; flex-wrap: wrap; }
.get-copy .body { margin-bottom: 20px; }
.qr-wrap { margin: 0; max-width: 190px; }
.qr { width: 150px; padding: 12px; background: #fff; border-radius: 18px; }
.qr svg { display: block; width: 100%; height: auto; }
.qr-wrap figcaption { margin-top: 10px; font-size: 0.88rem; color: var(--muted); }

.foot { padding: 24px 0 36px; border-top: 1px solid var(--line); font-size: 0.92rem; color: var(--muted); }
.foot-row { display: flex; justify-content: space-between; align-items: center; gap: 16px 28px; flex-wrap: wrap; }
.foot p { margin: 0; }
.foot nav { display: flex; gap: 22px; flex-wrap: wrap; }
.foot a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }

/* ------------------------------------------------------------ variants */
.rm .hero, .nogl .hero { height: 100vh; height: 100svh; }
.rm .games, .nogl .games { height: auto; min-height: 100svh; }
.rm .games-pin, .nogl .games-pin { position: relative; min-height: 100svh; height: auto; }
.nogl .heroB { display: none; }
.rm *, .rm *::before, .rm *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ small screens */
@media (max-width: 900px) {
  .nav nav a:not(.nav-cta) { display: none; }
  .brand-text { font-size: 0.98rem; }
  .heroB { flex-direction: column; align-items: flex-start; gap: 16px; }
  .games-ui { position: absolute; left: 0; right: 0; bottom: 0; width: auto; padding: 0 var(--gut) 3svh; max-height: 64svh; overflow-y: auto; }
  .small-h { margin-bottom: 0.7rem; font-size: 0.92rem; }
  .small-h span { display: block; margin: 0.1em 0 0; }
  .detail { min-height: 9.6rem; }
  .g-name { font-size: clamp(2.1rem, 9vw, 3rem); }
  .g-line { font-size: 1.02rem; }
  .g-meta { margin: 0.5rem 0 0.4rem; }
  .idx { margin-top: 0.8rem; }
  .idx-row { grid-template-columns: 1fr; gap: 2px; padding: 0.4rem 0; }
  .gbtn { font-size: 0.98rem; padding: 0.2em 0.62em; }
  .nogl .fallback { position: relative; top: auto; right: auto; transform: none; width: auto; padding: 0 var(--gut); }
  .play-grid, .ritual-grid { grid-template-columns: 1fr; }
  .ritual-head { position: static; }
  .row { grid-template-columns: 1fr; gap: 4px; padding: 1.1rem 0; }
  .tray { border-radius: 28px; }
  .tray-head { flex-direction: column; align-items: flex-start; }
  .qr-wrap { display: none; }
}
@media (max-width: 560px) {
  .actions .btn { flex: 1 1 100%; }
  .heroA h1 { font-size: clamp(2.7rem, 13.4vw, 4rem); }
}
@media (hover: none) { .qr-wrap { display: none; } }
