@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&family=Noto+Naskh+Arabic:wght@400;600&display=swap");

:root {
  color-scheme: dark;
  --ink: #101525;
  --panel: #161e30;
  --cream: #f5e9d5;
  --text: #d5c9b5;
  --muted: #b7ac9b;
  --gold: #e2bc7a;
  --line: #b7965d55;
  --jade: #92d7c4;
  --rose: #efaaa3;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
  background: var(--ink);
  color: var(--cream);
  font: 16px/1.55 var(--sans);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; }
img { display: block; max-width: 100%; }
button, summary { cursor: pointer; }
button { font: inherit; }
button:disabled { cursor: default; opacity: .64; }
a { color: inherit; text-decoration: none; }
a, button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: .96; }
h1 em, h2 em { color: var(--gold); }
.wrap { width: min(1200px, calc(100% - 5rem)); margin-inline: auto; }
.skip { position: fixed; z-index: 3; top: .75rem; left: .75rem; background: var(--ink); padding: .65rem 1rem; transform: translateY(-200%); }
.skip:focus { transform: translateY(0); }

.header, .footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.header { min-height: 78px; border-bottom: 1px solid var(--line); }
.wordmark { display: inline-flex; gap: .8rem; align-items: center; font-family: var(--serif); font-size: 1.53rem; line-height: 1; }
.seal { width: 34px; aspect-ratio: 1; display: grid; place-items: center; border: 1px solid var(--line); color: var(--gold); transform: rotate(45deg) scale(.83); }
.seal span { transform: rotate(-45deg); font-size: 1.25rem; }
nav { display: flex; align-items: center; gap: clamp(1rem, 3vw, 2.75rem); font-size: .82rem; font-weight: 600; }
nav a:hover, .text-link:hover { color: var(--cream); }
nav a:first-child { color: var(--text); }
.nav-play { color: var(--gold); border: 1px solid var(--line); padding: .52rem .95rem; white-space: nowrap; }
.nav-play span { padding-left: .35rem; }

.hero { min-height: min(665px, 78vw); display: grid; grid-template-columns: .96fr 1.04fr; align-items: center; position: relative; padding-block: 3.5rem; }
.hero-copy { z-index: 1; padding: 1.5rem 0 1rem; }
.arabic { font-family: "Noto Naskh Arabic", "Geeza Pro", serif; font-weight: 400; color: var(--gold); line-height: 1.38; text-align: start; }
.hero-arabic { display: inline-block; font-size: clamp(2rem, 4vw, 3.1rem); margin-bottom: .65rem; }
.hero h1 { font-size: clamp(4.8rem, 8.1vw, 7.3rem); letter-spacing: -.048em; line-height: .87; }
.hero h1 span { white-space: nowrap; }
.hero-subtitle { font-size: clamp(1rem, 1.6vw, 1.25rem); color: var(--text); max-width: 33ch; margin-top: 1.7rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 1rem 1.4rem; align-items: center; margin-top: 1.65rem; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 1.4rem; min-height: 49px; padding: .65rem 1.1rem; border: 1px solid transparent; font-size: .85rem; font-weight: 700; }
.primary { background: var(--gold); color: #241a13; }
.primary:hover:not(:disabled) { background: #f6d69d; }
.text-link { display: inline-flex; align-items: baseline; gap: .4em; padding: 0; color: var(--gold); border: 0; border-bottom: 1px solid var(--line); background: none; font-size: .85rem; line-height: 1.7; }
.hero-credit { color: var(--muted); font-size: .75rem; margin-top: 1.5rem; }
.hero-credit span { color: var(--gold); font-size: .53rem; margin: 0 .4rem; vertical-align: .11em; }
.hero-visual { position: relative; display: grid; place-items: center; padding: 1rem; }
.hero-visual::before { position: absolute; content: ""; inset: -10% -6% -8%; background: radial-gradient(ellipse, #283750af, transparent 69%); pointer-events: none; }
.arch { isolation: isolate; position: relative; width: 100%; aspect-ratio: 1 / .95; padding: 8px; border: 1px solid #bb986c79; border-radius: 50% 50% 6px 6px / 49% 49% 6px 6px; overflow: hidden; }
.arch::after { content: ""; position: absolute; inset: 8px; border-radius: inherit; background: linear-gradient(0deg, #0c102185, transparent 44%), linear-gradient(90deg, #0d132741, transparent 39%); pointer-events: none; }
.arch img { width: 100%; height: 100%; object-fit: cover; object-position: 58% center; border-radius: inherit; }
.ornament { position: absolute; color: var(--gold); font-size: .9rem; background: #111626; line-height: 1; padding: .2rem; left: 50%; transform: translateX(-50%); }
.ornament.top { top: .44rem; }
.ornament.bottom { bottom: .44rem; }

.tradition { background: #1b2333; border-block: 1px solid var(--line); padding: clamp(3rem, 7vw, 6.5rem) 0; }
.tradition-inner { display: grid; grid-template-columns: minmax(150px, 27%) minmax(0, 620px); justify-content: center; align-items: center; gap: clamp(2.5rem, 8vw, 7rem); }
.tradition-image { padding: 6px; border: 1px solid var(--line); }
.tradition-image img { width: 100%; height: auto; }
.kicker { color: var(--gold); text-transform: uppercase; letter-spacing: .16em; font-size: .68rem; font-weight: 700; }
h2 { font-size: clamp(3rem, 6vw, 5rem); letter-spacing: -.025em; }
.tradition h2 { margin: .65rem 0 1.15rem; }
.tradition p:not(.kicker) { max-width: 58ch; color: var(--text); }
.tradition p + p { margin-top: .8rem; }
.source-links { display: flex; flex-wrap: wrap; gap: .65rem 1.2rem; margin-top: 1.25rem; }

.game { padding-block: clamp(3rem, 6vw, 5.5rem); scroll-margin-top: 1.5rem; }
.section-head { display: flex; align-items: end; gap: 1rem 2rem; justify-content: space-between; margin-bottom: 1.35rem; }
.section-head p:last-child { color: var(--text); padding-bottom: .35rem; max-width: 32ch; }
.game-arabic { display: inline-block; font-size: 1.5rem; margin-bottom: .25rem; }
.game-layout { display: grid; grid-template-columns: 1.25fr .85fr; gap: clamp(1.25rem, 3vw, 2.5rem); align-items: start; }
.board-frame { border: 1px solid var(--line); padding: clamp(.28rem, 1vw, .65rem); background: #0a0e19; }
.board { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 2px; background: linear-gradient(#1015256b, #1015256b), url("/assets/rosette.webp") center / cover; }
.cell { aspect-ratio: 1; position: relative; display: grid; place-items: center; min-width: 0; border: 1px solid #ae956b36; background: var(--tile, #1d273df0); color: var(--cream); font-size: clamp(.67rem, 1.35vw, 1rem); font-weight: 600; font-variant-numeric: tabular-nums; padding: 0; }
.cell:nth-child(4n + 1), .cell:nth-child(4n + 4) { --tile: #26324ae7; }
.cell:hover { border-color: var(--gold); background: #364866; }
.cell.is-selected { border: 2px solid var(--gold); }
.cell.is-player { color: #1f180e; background: var(--gold); font-weight: 700; border-color: #fff2c9; }
.cell.is-player.is-selected { box-shadow: inset 0 0 0 2px #1f180e; }
.cell:focus-visible { z-index: 1; outline-offset: 0; }
.cell-mark { position: absolute; right: 11%; top: 3%; font-size: .67em; line-height: 1; }
.cell.is-player .cell-mark { color: #332518; }
.ascent, .legend-rise { color: var(--jade); }
.descent, .legend-fall { color: var(--rose); }
.goal, .legend-goal { color: var(--gold); }
.legend { display: flex; flex-wrap: wrap; gap: 1.2rem; padding: .75rem .1rem 0; color: var(--muted); font-size: .73rem; }
.legend b { margin-right: .24rem; }
.game-side { display: grid; gap: .85rem; }
.roll-panel, .station-panel, .rules { background: var(--panel); border: 1px solid var(--line); }
.roll-panel, .station-panel { padding: clamp(1rem, 2vw, 1.55rem); }
.roll-head, .station-top { display: flex; justify-content: space-between; align-items: center; gap: .85rem; }
.position { font-family: var(--serif); font-size: 1.85rem; line-height: 1.06; margin: .35rem 0; }
.die { color: var(--gold); font-family: system-ui, sans-serif; font-size: 2.55rem; line-height: 1; }
.roll { margin-top: .85rem; width: 100%; justify-content: space-between; }
.roll-status { color: var(--text); font-size: .83rem; margin-top: .65rem; }
.journey-actions { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.journey-actions:has(button:not([hidden])) { margin-top: .5rem; }
.station-art { border: 1px solid var(--line); width: 58px; height: 58px; object-fit: cover; }
.station-arabic { display: inline-block; font-size: 1.55rem; margin-top: .25rem; }
.station-panel h3 { font-size: 2.28rem; margin: .45rem 0 .7rem; }
.station-panel p:not(.kicker), .rules p { color: var(--text); font-size: .9rem; }
.station-passage { margin-top: .65rem; font-weight: 600; }
.station-reading { border-top: 1px solid var(--line); margin-top: .8rem; padding-top: .65rem; }
summary { color: var(--gold); font-size: .85rem; font-weight: 600; }
.station-description p, .rules p { margin-top: .65rem; }
.back-to-board { display: none; }
.rules { padding: .8rem 1.15rem; }
.full-game { margin-top: 1.25rem; }
.play-page .game { padding-top: clamp(1.8rem, 4vw, 3.5rem); }
.play-page h1 { font-size: clamp(3rem, 6vw, 5rem); letter-spacing: -.025em; }

.footer { border-top: 1px solid var(--line); background: #0d1120; }
.footer-inner { padding-block: 1.55rem; }
.footer p { color: var(--muted); font-size: .82rem; }
.footer p a { color: var(--gold); }
.reset-dialog { max-width: min(460px, calc(100% - 2rem)); padding: 1.5rem; border: 1px solid var(--line); color: var(--cream); background: var(--panel); }
.reset-dialog::backdrop { background: #080b14bb; }
.reset-dialog h2 { font-size: 2.8rem; }
.reset-dialog p { color: var(--text); margin: .6rem 0 1.15rem; }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1.15rem; }

@media (max-width: 960px) {
  .hero { min-height: auto; grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: clamp(3.25rem, 8vw, 5.4rem); }
  .wrap { width: min(1200px, calc(100% - 3rem)); }
}

@media (max-width: 680px) {
  .wrap { width: calc(100% - 2rem); }
  .header { min-height: 62px; gap: .5rem; }
  .wordmark { font-size: 1.3rem; gap: .48rem; }
  .seal { width: 26px; }
  nav a:first-child { display: none; }
  .nav-play { padding: .37rem .6rem; }
  .hero { grid-template-columns: 1fr; padding-block: 1.6rem 2.25rem; }
  .hero-copy { padding: .5rem 0 1.15rem; }
  .hero h1 { font-size: clamp(3.1rem, 13vw, 5.7rem); }
  .hero-subtitle { margin-top: 1.2rem; }
  .hero-actions { margin-top: 1.15rem; }
  .hero-credit { margin-top: 1rem; }
  .hero-visual { width: min(100%, 470px); margin-inline: auto; padding-inline: 0; }
  .hero-visual::before { inset-inline: 0; }
  .arch { aspect-ratio: 1.18; }
  .tradition-inner { grid-template-columns: minmax(0, 1fr); gap: 1.2rem; }
  .tradition-image { width: 108px; }
  .section-head { align-items: start; flex-direction: column; gap: .65rem; }
  .game-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .game-layout > div:first-child { display: contents; }
  .roll-panel { grid-area: roll; }
  .station-panel { grid-area: station; }
  .rules { grid-area: rules; }
  .board-frame { grid-area: board; }
  .legend { grid-area: legend; padding-top: 0; }
  .game-side { display: contents; }
  .game-layout { grid-template-areas: "roll" "board" "legend" "station" "rules"; }
  .back-to-board { display: inline-flex; margin-top: 1rem; }
  .footer-inner { align-items: start; flex-direction: column; gap: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

