:root {
  color-scheme: dark;
  --ink: #112c24;
  --forest: #102c25;
  --forest-dark: #0b211c;
  --paper: #fff1d5;
  --gold: #f4c65a;
  --gold-soft: #e8cd8b;
  --muted: #ced8ca;
  --line: #536447;
  --display: Georgia, 'Times New Roman', serif;
  --body: system-ui, -apple-system, 'Segoe UI', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 1rem; }
body {
  margin: 0;
  font-family: var(--body);
  color: var(--paper);
  background: radial-gradient(ellipse at 50% 28%, #1a392e 0%, var(--forest-dark) 70%);
  line-height: 1.5;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid #ffe49b; outline-offset: 4px; }
.rules:focus-visible { outline-color: #1c6948; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { font-family: var(--display); line-height: 1.06; }
.shell { width: min(1120px, calc(100% - 48px)); margin-inline: auto; }
.skip {
  position: absolute; z-index: 3; top: 8px; left: 8px; padding: .6rem 1rem;
  background: var(--paper); color: var(--ink); transform: translateY(-150%);
}
.skip:focus { transform: none; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.masthead { border-bottom: 1px solid #e7c16a30; }
.masthead-inner {
  min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { flex: none; }
.brand b { display: block; font: bold 1.4rem/.96 var(--display); color: var(--gold-soft); }
.brand span { font-size: .63rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.header-link {
  display: flex; align-items: center; gap: .45em; min-height: 44px; padding: 0 .2em;
  font-size: .83rem; color: var(--paper); text-underline-offset: .27em;
}
.header-link span { color: var(--gold); }
.hero {
  isolation: isolate; position: relative; display: grid; align-items: center; grid-template-columns: 1.32fr 1fr;
  min-height: 362px; margin-block: 24px 22px; padding: clamp(23px, 2.8vw, 36px) clamp(23px, 4vw, 52px);
  border: 1px solid #8e8053; border-radius: 24px; overflow: hidden;
  background: #183a2a url('assets/hero.webp') 50% 52% / cover no-repeat;
  box-shadow: 0 20px 45px #070f0d4d, inset 0 0 36px #142c24b3;
}
.hero::before {
  content: ''; position: absolute; z-index: -1; inset: 0;
  background: linear-gradient(90deg, #0b211bf7 0%, #102a22ed 32%, #173528a1 58%, #122b2355);
}
.hero::after {
  content: ''; pointer-events: none; position: absolute; inset: 8px;
  border: 1px solid #ead9a44d; border-radius: 17px;
}
.eyebrow {
  color: var(--gold-soft); font-size: .68rem; font-weight: 750; letter-spacing: .18em;
  text-transform: uppercase;
}
.eyebrow span { margin-right: .35em; color: var(--gold); }
h1 { margin-top: 12px; font-size: clamp(3rem, 6.1vw, 5.1rem); letter-spacing: -.052em; }
h1 em { color: var(--gold); font-weight: inherit; }
.intro { max-width: 34ch; margin-top: 16px; color: #f4ebd7; font-size: clamp(.98rem, 1.65vw, 1.13rem); }
.hero-tags {
  display: flex; flex-wrap: wrap; gap: 7px 14px; padding: 0; margin: 22px 0 0;
  list-style: none; color: #f6edda; font-size: .8rem;
}
.hero-tags span { color: var(--gold); margin-right: .15em; }
.hero-play { margin-top: 18px; text-decoration: none; }
.hero-art { position: relative; justify-self: end; width: min(100%, 347px); height: 260px; }
.sample {
  position: absolute; display: flex; flex-direction: column; width: 48%; padding: 6px;
  background: #f8e4b6; border: 1px solid #fff2c6; border-radius: 13px;
  box-shadow: 0 12px 24px #0009, 0 0 0 2px #664a28; color: #244537; text-align: center;
}
.sample img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5.1; object-fit: cover; border-radius: 8px; }
.sample span { font: bold clamp(.65rem, 1.4vw, 1rem) var(--display); padding: 7px 0 3px; }
.sample-place { top: 3%; right: 11%; transform: rotate(11deg); }
.sample-friend { top: 12%; right: 43%; transform: rotate(-11deg); }
.sparkle { position: absolute; color: #ffe5a0; font-size: 2rem; line-height: 1; text-shadow: 0 0 14px #f4c65a; }
.sparkle-top { top: -2%; left: 8%; }
.sparkle-bottom { right: 1%; bottom: 11%; font-size: 1.3rem; }
.game {
  padding: clamp(16px, 3.4vw, 34px); border: 1px solid #5e6d50; border-radius: 22px;
  background: linear-gradient(158deg, #244333, #132f27 68%);
  box-shadow: 0 14px 30px #081a1459;
}
.game-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.game h2, .rules h2 { margin-top: 5px; font-size: clamp(1.85rem, 3.4vw, 2.65rem); letter-spacing: -.026em; }
.mode-help { margin-top: 6px; color: var(--muted); font-size: .84rem; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 44px;
  padding: 8px 14px; border-radius: 9px; border: 1px solid transparent; font-size: .86rem; font-weight: 750;
}
.button-outline { color: var(--paper); background: #173429; border-color: #879476; }
.button-outline:hover { background: #2e4e3e; }
.button-outline span { color: var(--gold); }
.button-gold { color: #243427; background: var(--gold); border-color: #ffe5a0; }
.button-gold:hover { background: #ffdb84; }
.decks { display: flex; gap: 9px; min-width: 0; border: 0; padding: 0; margin: 18px 0 12px; }
.deck-choice {
  flex: 0 1 178px; display: flex; gap: 4px 12px; flex-wrap: wrap; align-items: baseline;
  min-height: 48px; padding: 9px 13px; color: var(--paper); text-align: left; background: #102820;
  border: 1px solid #7d8b6d; border-radius: 9px;
}
.deck-choice span { color: var(--muted); font-size: .76rem; }
.deck-choice[aria-pressed="true"] {
  color: #ffe29e; background: #3c4630; border-color: var(--gold); box-shadow: inset 0 -2px 0 #c59b44;
}
.deck-choice:hover { border-color: var(--gold); }
.scoreboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.scoreboard div {
  display: flex; align-items: center; justify-content: center; gap: 5px 11px;
  min-height: 48px; padding: 6px; border: 1px solid #657658; border-radius: 9px; background: #0e2720;
}
.scoreboard dt { color: var(--muted); font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; }
.scoreboard dd { color: #ffe09a; font-size: 1.04rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.turn-line {
  position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between;
  min-height: 59px; gap: 6px 12px; padding: 6px 8px; margin-inline: -8px;
  border-radius: 8px; background: #1c3b30;
}
.turn-line p { color: #f7efd8; font-size: .89rem; }
.next-button { flex: none; }
.board { --columns: 6; display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); gap: clamp(7px, 1.15vw, 14px); }
.board[data-mode="quest"] { --columns: 5; }
.card {
  position: relative; display: block; width: 100%; aspect-ratio: 1 / 1.19; min-width: 0;
  padding: 0; overflow: hidden; isolation: isolate; scroll-margin-top: 92px; border-radius: 11px; border: 1px solid #b39659;
  color: #ffe5a9; background: radial-gradient(ellipse at 46% 39%, #346144, #143a2e 59%, #102c24);
  box-shadow: 0 4px 6px #061a1499; transition: border-color .15s, box-shadow .15s, transform .15s;
}
.board[data-mode="quest"] .card { aspect-ratio: 1 / 1.08; }
.card::before {
  content: ''; position: absolute; inset: 5px; z-index: -1; border-radius: 7px; pointer-events: none;
  border: 1px solid #ddbb6b69;
  background: repeating-linear-gradient(45deg, transparent 0 9px, #d2c5800d 9px 10px),
              repeating-linear-gradient(-45deg, transparent 0 9px, #d2c5800d 9px 10px);
}
.card:hover:not([aria-disabled="true"]) {
  border-color: #ffe8a8; box-shadow: 0 0 0 1px #f4c65a, 0 6px 10px #061a1499; transform: translateY(-2px);
}
.card:focus-visible { z-index: 1; }
.card[aria-disabled="true"] { cursor: default; }
.card-back {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: url('assets/card-back.svg') center 46% / min(67%, 92px) no-repeat;
}
.card-number {
  position: absolute; top: 7px; left: 8px; font-family: var(--display); font-size: .72rem; color: #ffe6a4;
}
.card-face { position: absolute; inset: 0; background: #193a2e; }
.card-face img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 43%; }
.card-friend .card-face { background: #f8eedb; }
.card-friend .card-face img { height: 80%; object-fit: contain; }
.card[data-state="open"] { border-color: #fff1c1; }
.card[data-state="matched"] { border: 2px solid #e5cc83; }
.card-name {
  position: absolute; bottom: 0; left: 0; right: 0; display: grid; place-items: center;
  min-height: 25%; padding: 4px; background: #10251ef2; color: #fff3d6;
  font: bold clamp(.68rem, 1.15vw, .9rem)/1.05 var(--display); overflow-wrap: anywhere;
}
.match-mark {
  position: absolute; top: 5px; right: 5px; min-width: 22px; padding: 0 4px;
  border-radius: 99px; background: #ffe09a; color: #1e422c; font: bold .78rem/1.65 var(--body);
}
.rules {
  margin-top: 22px; padding: clamp(19px, 3vw, 32px); border: 1px solid #e0bb69; border-radius: 20px;
  color: #243a2e; background: radial-gradient(ellipse at top left, #fff7e5, #f5e5c5);
}
.rules .eyebrow, .rules .eyebrow span { color: #65501f; }
.rule-steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
  padding: 0; margin: 20px 0 0; list-style: none;
}
.rule-steps li { display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.rule-steps h3 { font-size: 1.16rem; margin: 3px 0 5px; }
.rule-steps p, .keyboard { font-size: .88rem; }
.step {
  display: grid; place-items: center; width: 29px; height: 29px; border: 1px solid #9a7a3a;
  border-radius: 50%; background: #ffebaf; font: bold 1rem var(--display);
}
.keyboard { border-top: 1px solid #b09963; margin-top: 18px; padding-top: 12px; }
.finish {
  overflow: hidden; position: relative; isolation: isolate; text-align: center; margin-top: 14px;
  border: 1px solid #ba9b54; border-radius: 13px; padding: clamp(24px, 5vw, 50px) 15px;
  background: #182f23 url('assets/hero.webp') center 62% / cover;
}
.finish::before { content: ''; position: absolute; z-index: -1; inset: 0; background: #0c251be6; }
.finish-crystal { display: block; margin: 0 auto 10px; filter: drop-shadow(0 0 12px #dfc4748c); }
.finish h2 { color: #ffe0a0; }
.finish p:not(.eyebrow) { margin-top: 12px; }
.finish button { margin-top: 19px; }
.footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  padding-block: 23px 28px; font-size: .79rem; color: var(--muted);
}
.footer span { color: var(--gold-soft); }

@media (max-width: 760px) {
  .shell { width: calc(100% - 30px); }
  .hero { min-height: 290px; }
  h1 { font-size: clamp(2.5rem, 7.1vw, 3.8rem); }
  .hero-art { height: clamp(125px, 30vw, 230px); }
  .hero-tags { margin-top: 15px; }
  .board { --columns: 4; }
  .board[data-mode="quest"] { --columns: 4; }
}
@media (max-width: 530px) {
  .shell { width: calc(100% - 24px); }
  .masthead-inner { min-height: 60px; }
  .hero {
    min-height: 0; margin-block: 13px; padding: 19px 15px 18px;
    grid-template-columns: minmax(0, 1fr) minmax(0, .38fr); border-radius: 16px;
  }
  .hero::after { inset: 5px; border-radius: 11px; }
  .hero::before { background: linear-gradient(90deg, #0b211bf5, #112c24eb 55%, #112d2470); }
  h1 { font-size: clamp(2.15rem, 8.25vw, 2.9rem); margin-top: 8px; }
  .hero .eyebrow { font-size: .6rem; }
  .intro { margin-top: 11px; font-size: .88rem; }
  .hero-tags { margin-top: 11px; font-size: .72rem; gap: 4px 8px; }
  .hero-play { margin-top: 12px; }
  .hero-art { align-self: center; }
  .sample { width: 82%; padding: 4px; border-radius: 7px; }
  .sample img { border-radius: 4px; }
  .sample span { padding: 3px 0 1px; }
  .sample-place { right: 2%; top: 9%; transform: rotate(12deg); }
  .sample-friend { right: 9%; top: 26%; transform: rotate(-10deg); }
  .sparkle-top { left: 5%; top: -6%; font-size: 1.4rem; }
  .sparkle-bottom { display: none; }
  .game { padding: 13px; border-radius: 16px; }
  .game h2 { font-size: 1.73rem; }
  .game-heading { gap: 6px; }
  .decks { margin-top: 13px; gap: 6px; }
  .deck-choice { flex: 1; min-height: 44px; padding: 7px 9px; gap: 2px 7px; font-size: .84rem; }
  .scoreboard { gap: 5px; }
  .scoreboard div { min-height: 44px; gap: 3px 6px; }
  .scoreboard dt { font-size: .62rem; letter-spacing: .035em; }
  .scoreboard dd { font-size: .91rem; }
  .board { --columns: 3; }
  .board[data-mode="quest"] { --columns: 4; }
  .board[data-mode="quest"] .card { aspect-ratio: 1 / 1.26; }
  .card { border-radius: 8px; }
  .card::before { inset: 3px; border-radius: 5px; }
  .card-number { top: 5px; left: 6px; font-size: .65rem; }
  .turn-line { min-height: 47px; gap: 5px; }
  .turn-line p { font-size: .81rem; }
  .next-button { padding-inline: 8px; font-size: .75rem; }
  .rule-steps { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-width: 355px) {
  .brand { gap: 7px; }
  .brand span { font-size: .53rem; }
  .header-link { font-size: .76rem; white-space: nowrap; }
  .hero { grid-template-columns: minmax(0, 1fr) 51px; column-gap: 5px; }
  .sample { width: 86%; }
  .sample-place { top: 15%; right: 0; }
  .sample-friend { right: 4%; }
  .card-name { font-family: var(--body); font-size: .625rem; padding-inline: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
