*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--table);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.4;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Hide the app until modules have hydrated sprites, avoiding a flash of empty boxes. */
html:not(.is-ready) #app { visibility: hidden; }

/* Tabletop: warm dark board with coloured glows like the sprite sheet backdrops. */
.tabletop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60vmax 45vmax at 0% 0%, rgba(200, 50, 43, 0.28), transparent 70%),
    radial-gradient(55vmax 45vmax at 100% 10%, rgba(31, 79, 156, 0.32), transparent 70%),
    radial-gradient(60vmax 50vmax at 90% 100%, rgba(242, 182, 50, 0.22), transparent 70%),
    radial-gradient(50vmax 40vmax at 5% 95%, rgba(58, 138, 58, 0.22), transparent 70%),
    radial-gradient(120% 90% at 50% 45%, var(--table-2), var(--table) 70%, #17120d);
}
.tabletop::after {
  /* Paper-fibre grain */
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.18;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.1;
  margin: 0;
}

p { margin: 0; }

button, input, select { font: inherit; color: inherit; }

img { max-width: 100%; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Sprites: element size comes from width + the aspect-ratio set in JS. */
.sprite {
  display: inline-block;
  flex: none;
  background-repeat: no-repeat;
  pointer-events: none;
  user-select: none;
}

.noscript {
  max-width: 420px;
  margin: 20vh auto;
  padding: 24px;
  text-align: center;
}

/*
 * Cross-browser hardening:
 * - Giving the board frame both axes avoids small WebKit aspect-ratio rounding
 *   drift in short landscape layouts.
 * - Rotated paper cards are flattened on narrow phones so their transformed
 *   corners cannot grow the document's horizontal scroll area.
 */
.board-frame {
  height: var(--board-size, min(100cqw, 100cqh)); /* the same as its width: always square */
}
@media (max-width: 540px) {
  .screen--page { overflow-x: clip; }
  .howto-card { transform: none !important; max-width: 100%; min-width: 0; }
}

/*
 * Reduced motion must remove delayed animations altogether. Merely shortening
 * durations leaves elements sitting in backwards-filled opacity:0 keyframes
 * during their original delays, which can blank menus in WebKit and makes
 * reduced-motion feedback race the browser tests.
 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
html[data-motion='reduced'] *,
html[data-motion='reduced'] *::before,
html[data-motion='reduced'] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
