@font-face {
  font-family: "FableDust";
  src: url("assets/FableDust.otf") format("opentype");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

:root {
  color-scheme: light;
  --paper: #e4e4e4;
  --paper-bright: #f8f8f8;
  --mist: #e4e4e4;
  --board-grey: #a4a4a4;
  --graphite: #4a4b49;
  --graphite-soft: #939598;
  --signal: #e2e8a7;
  --signal-deep: #e2e8a7;
  --danger: #939598;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --focus: 3px solid var(--graphite);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--graphite);
}

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

body {
  font-family: "FableDust", Georgia, serif;
  font-synthesis: none;
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font-family: "FableDust", Georgia, serif;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: var(--focus);
  outline-offset: 4px;
}

button {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  background: var(--paper-bright);
  color: var(--graphite);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

#app,
.home,
.desktop-home,
.mobile-home {
  min-height: 100dvh;
}

.mobile-home {
  display: none;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--graphite-soft);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.text-button,
.utility-link {
  appearance: none;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--graphite);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 0;
  text-decoration: none;
  text-transform: uppercase;
}

.hint {
  position: fixed;
  z-index: 999;
  left: 50%;
  bottom: max(26px, env(safe-area-inset-bottom));
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border: 1px solid color-mix(in oklch, var(--graphite) 30%, transparent);
  border-radius: 999px;
  background: color-mix(in oklch, var(--paper-bright) 88%, transparent);
  box-shadow: 0 10px 35px color-mix(in oklch, var(--graphite) 12%, transparent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 12px);
  transition: opacity 280ms var(--ease-out), transform 280ms var(--ease-out);
}

.hint.is-visible {
  opacity: 0.78;
  transform: translate(-50%, 0);
}

/* Framed board, matched to the supplied 8 by 4 desktop mockup */
.board-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  background: var(--paper);
  overflow: hidden;
  transition: opacity 350ms var(--ease-out);
}

.board-page.is-complete {
  opacity: 0;
}

.ornate-board {
  position: relative;
  width: 100vw;
  height: 100dvh;
  background: var(--board-grey);
  overflow: hidden;
}

.intro-board,
.menu-board {
  position: absolute;
  z-index: 1;
  top: 0.8%;
  left: 9.5%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(4, 1fr);
  width: 80.8%;
  height: 77.1%;
  background: var(--board-grey);
}

.intro-3d-stage {
  position: absolute;
  z-index: 1;
  top: 0.8%;
  left: 9.5%;
  width: 80.8%;
  height: 77.1%;
  overflow: hidden;
  background: var(--board-grey);
}

.intro-3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--board-grey);
  cursor: grab;
  touch-action: none;
}

.intro-3d-canvas.is-orbiting {
  cursor: grabbing;
}

.intro-flat-fallback {
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.intro-3d-stage.is-fallback .intro-flat-fallback {
  opacity: 1;
  pointer-events: auto;
}

.intro-3d-stage.is-fallback .intro-3d-canvas,
.intro-3d-stage.is-fallback .intro-3d-caption {
  display: none;
}

.intro-3d-caption {
  position: absolute;
  right: 0;
  bottom: 16px;
  left: 0;
  display: grid;
  justify-items: center;
  gap: 2px;
  margin: 0;
  color: var(--paper-bright);
  font-size: clamp(0.72rem, 1.05vw, 1rem);
  line-height: 1.25;
  opacity: 0.82;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 1px 3px color-mix(in srgb, var(--graphite) 75%, transparent);
  transition: opacity 240ms ease;
}

.intro-3d-caption span {
  display: block;
  overflow: hidden;
  width: calc(var(--ch) * 1ch);
  white-space: nowrap;
  animation: intro-type 900ms steps(var(--ch)) both;
}

.intro-3d-caption span:nth-child(2) { animation-delay: 900ms; }
.intro-3d-caption span:nth-child(3) { animation-delay: 1800ms; }

@keyframes intro-type {
  from { width: 0; }
  to { width: calc(var(--ch) * 1ch); }
}

@media (prefers-reduced-motion: reduce) {
  .intro-3d-caption span { animation: none; width: calc(var(--ch) * 1ch); }
}

.intro-3d-stage.is-solving .intro-3d-caption {
  opacity: 0;
}

.menu-board-page {
  opacity: 1;
}

.intro-transition-snapshot {
  position: fixed;
  z-index: 20;
  display: block;
  object-fit: fill;
  pointer-events: none;
  opacity: 1;
  transition: opacity 720ms var(--ease-out);
}

.intro-transition-snapshot.is-fading {
  opacity: 0;
}

@keyframes menu-board-arrive {
  from { opacity: 0; }
  to { opacity: 1; }
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
}

.square--light {
  background: var(--mist);
}

.square--dark {
  background: var(--board-grey);
}

.piece {
  position: relative;
  z-index: 3;
  display: grid;
  width: 72%;
  height: 94%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
  transition: opacity 180ms ease, transform 180ms var(--ease-out), filter 180ms ease;
}

.piece:active {
  cursor: grabbing;
}

.piece-icon {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 1.5px 0 color-mix(in srgb, var(--graphite-soft) 68%, transparent));
  shape-rendering: geometricPrecision;
}

.piece-icon path {
  fill: currentColor;
}

.piece--light .piece-icon path,
.mobile-knight .piece-icon path {
  stroke: var(--graphite-soft);
  stroke-linejoin: round;
  stroke-width: 0.8;
  paint-order: stroke fill;
}

.menu-board .piece-icon--rook,
.intro-board .piece-icon--rook {
  transform: translateY(-13%) scale(0.64);
}

.menu-board .piece-icon--pawn,
.intro-board .piece-icon--pawn {
  transform: translateY(-15%) scale(0.72);
}

.menu-board .piece-icon--bishop,
.intro-board .piece-icon--bishop {
  transform: translateY(-8%) scale(0.82);
}

.menu-board .piece-icon--knight,
.intro-board .piece-icon--knight {
  transform: translateY(-6%) scale(0.84);
}

.intro-board .piece-icon--king {
  transform: scale(0.76);
}

.piece--light {
  color: var(--paper-bright);
}

.piece--dark {
  color: var(--graphite);
}

.piece.is-selected {
  filter: drop-shadow(0 0 9px var(--signal));
  transform: translateY(-7%) scale(1.04);
}

.piece.is-dragging,
.piece.is-captured {
  opacity: 0.08;
}

.drag-ghost {
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 84px;
  height: 104px;
  margin: 0;
  opacity: 0.92;
  pointer-events: none;
  transform-origin: center;
}

.move-marker {
  width: 22%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: color-mix(in oklch, var(--signal) 55%, transparent);
  opacity: 0;
  transition: opacity 200ms ease;
}

.intro-board:has(.intro-piece.is-selected) .move-marker {
  opacity: 0.55;
}

.square.is-correct {
  box-shadow: inset 0 0 0 clamp(4px, 0.6vw, 8px) var(--signal);
}

.wrong-move {
  animation: wrong-move 220ms ease-out;
}

@keyframes wrong-move {
  35% { transform: translateX(-5px); }
  70% { transform: translateX(4px); }
}

.board-border {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.ornate-board > .board-logo {
  position: absolute;
  z-index: 3;
  bottom: 3.3%;
  left: 50%;
  width: 5.5%;
  height: 11%;
  filter: brightness(0) invert(1);
  object-fit: contain;
  transform: translateX(-50%);
}

.board-logo-button {
  position: absolute;
  z-index: 4;
  bottom: 3.3%;
  left: 50%;
  width: 5.5%;
  height: 11%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: translateX(-50%);
}

.board-logo-button .board-logo {
  width: 100%;
  height: 100%;
  filter: brightness(0) invert(1);
  object-fit: contain;
}

.board-logo-button:focus-visible {
  outline-color: var(--paper-bright);
}

.route-target {
  position: relative;
  z-index: 4;
  max-width: 100%;
  padding: 2px;
  border: 0;
  background: transparent;
  color: var(--signal);
  cursor: pointer;
  font-family: "FableDust", Georgia, serif;
  font-size: clamp(1.55rem, 3.1vw, 3.1rem);
  line-height: 0.86;
  text-shadow:
    -1px -1px 0 var(--graphite-soft),
    1px -1px 0 var(--graphite-soft),
    -1px 1px 0 var(--graphite-soft),
    1px 1px 0 var(--graphite-soft);
  transform: rotate(-45deg);
  transform-origin: center;
}

.intro-meta {
  position: absolute;
  z-index: 5;
  top: 2.5%;
  bottom: auto;
  left: 50%;
  display: grid;
  gap: 3px;
  width: max-content;
  max-width: 48vw;
  margin: 0;
  color: var(--signal);
  font-family: "FableDust", Georgia, serif;
  text-align: center;
  text-shadow:
    -1px -1px 0 color-mix(in srgb, var(--graphite-soft) 65%, transparent),
    1px 1px 0 color-mix(in srgb, var(--graphite-soft) 65%, transparent);
  transform: translateX(-50%);
  animation: intro-cue 2.8s var(--ease-out) infinite alternate;
}

.intro-meta strong {
  font-size: clamp(1.9rem, 3.2vw, 3.3rem);
  font-weight: 400;
  line-height: 0.86;
}

.intro-meta span {
  font-size: clamp(0.78rem, 1.2vw, 1.18rem);
  letter-spacing: 0.03em;
  opacity: 0.88;
}

.intro-skip {
  position: absolute;
  z-index: 5;
  right: 11%;
  top: 3%;
  bottom: auto;
  left: auto;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--graphite);
  cursor: pointer;
  font-family: "FableDust", Georgia, serif;
  font-size: clamp(1.35rem, 2.6vw, 2.7rem);
  font-weight: 400;
  line-height: 0.9;
  text-shadow: 0 1px 2px color-mix(in srgb, var(--paper-bright) 55%, transparent);
  transform: none;
  transition: opacity 180ms ease, transform 220ms var(--ease-out);
}

.intro-skip:hover {
  opacity: 0.72;
  transform: scale(1.04);
}

@keyframes intro-cue {
  from { opacity: 0.64; transform: translate3d(-50%, 5px, 0); }
  to { opacity: 1; transform: translate3d(-50%, -2px, 0); }
}

/* Mobile home */
.mobile-home-inner {
  position: relative;
  display: grid;
  grid-template-rows: 122px 1fr 92px;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 0 max(10px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.mobile-logo {
  width: 104px;
  height: 132px;
  margin: 0 auto;
  object-fit: contain;
  transform: translateY(-16px);
}

.knight-menu {
  position: relative;
  place-self: start center;
  width: 100%;
  height: min(62dvh, 480px);
}

.mobile-knight {
  position: absolute;
  z-index: 4;
  top: 47%;
  left: 50%;
  width: 100px;
  height: 136px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--paper-bright);
  cursor: pointer;
  filter: drop-shadow(0 2px 0 color-mix(in oklch, var(--graphite) 58%, transparent));
  transform: translate(-50%, -50%);
  transition: transform 260ms var(--ease-out), filter 260ms ease;
}

.mobile-knight:active {
  transform: translate(-50%, -47%) scale(0.97);
}

.menu-open .mobile-knight {
  filter: drop-shadow(0 2px 0 color-mix(in oklch, var(--graphite) 58%, transparent));
  transform: translate(-50%, -50%);
}

.mobile-knight .piece-icon {
  width: 100%;
  height: 100%;
}

.mobile-knight:focus-visible {
  outline: 0;
  filter: drop-shadow(0 2px 0 color-mix(in srgb, var(--graphite-soft) 68%, transparent));
}

.mobile-route {
  position: absolute;
  z-index: 3;
  color: var(--signal);
  font-family: "FableDust", Georgia, serif;
  font-size: clamp(2rem, 9vw, 2.55rem);
  line-height: 0.8;
  opacity: 0;
  pointer-events: none;
  text-decoration: none;
  text-shadow:
    -1px -1px 0 var(--graphite-soft),
    1px -1px 0 var(--graphite-soft),
    -1px 1px 0 var(--graphite-soft),
    1px 1px 0 var(--graphite-soft);
  transform: translate(-50%, -50%) scale(0.82);
  transition: opacity 190ms ease, transform 350ms var(--ease-out);
}

.menu-open .mobile-route {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.mobile-route--timer { top: 15.5%; left: 50%; }
.mobile-route--about { top: 37.5%; left: 83%; }
.mobile-route--privacy { top: 65%; left: 18%; }
.mobile-route--leaderboard { top: 88%; left: 53%; }

.event-stamp {
  display: grid;
  place-items: center;
  color: color-mix(in oklch, var(--graphite-soft) 25%, transparent);
  text-align: center;
}

.event-stamp strong {
  font-family: "FableDust", Georgia, serif;
  font-size: clamp(2.7rem, 12vw, 3.55rem);
  font-weight: 400;
  letter-spacing: 0;
}

/* Content pages */
.content-page {
  position: relative;
  min-height: 100dvh;
  padding: 28px clamp(24px, 7vw, 104px) 64px;
  overflow: hidden;
}

.page-topbar {
  position: relative;
  z-index: 12;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.utility-link {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.page-logo {
  width: 54px;
  height: 66px;
  object-fit: contain;
}

.content-measure {
  position: relative;
  z-index: 3;
  width: min(100%, 990px);
  margin: clamp(58px, 11vh, 130px) auto 0;
}

.content-page h1 {
  margin: 0;
  color: var(--graphite);
  font-family: "FableDust", Georgia, serif;
  font-size: clamp(4rem, 8vw, 8.4rem);
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 0.82;
}

.lead {
  max-width: 58ch;
  margin: clamp(28px, 5vw, 62px) 0 0;
  font-size: clamp(1.05rem, 1.8vw, 1.42rem);
  line-height: 1.65;
}

/* About — video plane with pointer-driven depth */
.about-page {
  --about-rx: 0deg;
  --about-ry: 0deg;
  --about-x: 0px;
  --about-y: 0px;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: minmax(0, 63dvh) minmax(0, 37dvh);
  width: 100%;
  height: 100dvh;
  min-height: 0;
  background: var(--paper);
  color: var(--graphite);
  overflow: hidden;
}

.about-video-stage {
  position: relative;
  z-index: 2;
  min-height: 0;
  padding: 0;
  background: var(--paper);
  perspective: 900px;
  overflow: hidden;
}

.about-video {
  position: absolute;
  z-index: 1;
  inset: -4%;
  display: block;
  width: 108%;
  height: 108%;
  object-fit: cover;
  border: 0;
  box-shadow: none;
  transform: translate3d(var(--about-x), var(--about-y), 18px) rotateX(var(--about-rx)) rotateY(var(--about-ry)) scale(1.035);
  transform-origin: 50% 50%;
  transition: transform 420ms var(--ease-out);
  will-change: transform;
}

.about-topbar {
  position: absolute;
  z-index: 4;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(22px, env(safe-area-inset-top)) clamp(24px, 4vw, 68px) 0;
}

.about-topbar .utility-link {
  color: var(--paper-bright);
  text-shadow: 0 1px 5px color-mix(in srgb, var(--graphite) 68%, transparent);
}

.about-logo {
  width: 54px;
  height: 66px;
  filter: brightness(0) invert(1);
  object-fit: contain;
}

.about-video-toggle {
  position: absolute;
  z-index: 4;
  right: clamp(24px, 4vw, 68px);
  bottom: 24px;
  padding: 6px 9px;
  border: 1px solid color-mix(in srgb, var(--paper-bright) 72%, transparent);
  border-radius: 2px;
  background: color-mix(in srgb, var(--graphite) 46%, transparent);
  color: var(--paper-bright);
  cursor: pointer;
  font-family: "FableDust", Georgia, serif;
  font-size: 0.78rem;
}

.about-story {
  position: relative;
  z-index: 12;
  display: grid;
  grid-template-columns: minmax(260px, 0.82fr) minmax(340px, 1.18fr);
  gap: clamp(36px, 8vw, 140px);
  margin: 0;
  min-height: 0;
  overflow: hidden;
  padding: clamp(20px, 3.3vh, 34px) clamp(24px, 6vw, 100px) max(20px, env(safe-area-inset-bottom));
  border-top: 1px solid color-mix(in srgb, var(--graphite) 42%, transparent);
  background: var(--paper);
}

.about-story-heading h2 {
  max-width: 12ch;
  margin: 0;
  font-family: "FableDust", Georgia, serif;
  font-size: clamp(3rem, 5.9vw, 6.2rem);
  font-weight: 400;
  line-height: 0.78;
}

.about-story-heading h2 span {
  display: block;
  color: var(--graphite);
  text-shadow: none;
}

.about-story-copy {
  display: grid;
  grid-template-columns: minmax(240px, 1.25fr) minmax(170px, 0.75fr);
  gap: 24px clamp(28px, 4vw, 64px);
  align-content: start;
}

.about-story-copy p {
  margin: 0;
  font-size: clamp(1rem, 1.35vw, 1.28rem);
  line-height: 1.45;
}

.about-story-copy p:nth-child(2) {
  font-size: clamp(0.92rem, 1.18vw, 1.12rem);
}

.about-story-copy a {
  grid-column: 2;
  justify-self: start;
  color: var(--graphite);
  font-size: clamp(1.35rem, 2.1vw, 2.1rem);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.privacy-copy {
  width: min(100%, 760px);
  margin-left: clamp(0px, 8vw, 130px);
}

.privacy-list {
  margin: clamp(52px, 8vw, 100px) 0 0;
}

.privacy-list > div {
  display: grid;
  grid-template-columns: minmax(120px, 0.5fr) 1.5fr;
  gap: 28px;
  padding: 22px 0;
  border-top: 1px solid color-mix(in oklch, var(--graphite) 20%, transparent);
}

.privacy-list dt {
  font-weight: 750;
}

.privacy-list dd {
  margin: 0;
  color: var(--graphite-soft);
  line-height: 1.55;
}

.privacy-pawn {
  position: absolute;
  right: 8vw;
  bottom: 8vh;
  width: min(20vw, 240px);
  color: color-mix(in oklch, var(--paper-bright) 86%, transparent);
  opacity: 0.7;
}

/* Leaderboard */
.leaderboard-page {
  position: relative;
  display: grid;
  place-items: start center;
  min-height: 100dvh;
  padding: 20px 0 0;
  overflow: hidden;
}

.leaderboard-soldier {
  position: absolute;
  z-index: 1;
  bottom: -2.5dvh;
  width: auto;
  height: 105dvh;
  max-width: none;
  opacity: 0.9;
  pointer-events: none;
}

.leaderboard-soldier--left { left: 0; }
.leaderboard-soldier--right { right: 0; }

.leaderboard-center {
  position: relative;
  z-index: 3;
  display: grid;
  justify-items: center;
  width: min(63.2vw, 920px);
}

.leaderboard-brand {
  display: flex;
  align-items: flex-start;
  justify-self: start;
  margin: 0 0 56px -3.5%;
  color: var(--signal);
  font-family: "FableDust", Georgia, serif;
  font-size: clamp(4.5rem, 11vw, 9rem);
  line-height: 0.8;
  text-decoration: none;
  text-shadow:
    -2px -2px 0 var(--graphite-soft),
    2px -2px 0 var(--graphite-soft),
    -2px 2px 0 var(--graphite-soft),
    2px 2px 0 var(--graphite-soft);
}

.leaderboard-brand > span {
  display: inline-block;
  transform-origin: 50% 70%;
}

.leaderboard-brand > span:nth-child(1) { transform: translate(-2px, 8px) rotate(-5deg); }
.leaderboard-brand > span:nth-child(2) { transform: translate(0, -2px) rotate(3deg); }
.leaderboard-brand > span:nth-child(3) { transform: translate(1px, 5px); }
.leaderboard-brand > span:nth-child(4) { transform: translate(-3px, 0) rotate(-4deg); }
.leaderboard-brand > span:nth-child(5) { transform: translate(-5px, 8px) rotate(3deg); }
.leaderboard-brand > span:nth-child(6) { transform: translate(-6px, -3px) rotate(-2deg); }
.leaderboard-brand > span:nth-child(7) { transform: translate(-7px, 6px) rotate(4deg); }
.leaderboard-brand > span:nth-child(8) { transform: translate(-8px, -1px) rotate(-3deg); }
.leaderboard-brand > span:nth-child(9) { transform: translate(-9px, 5px) rotate(2deg); }
.leaderboard-brand > span:nth-child(10) { transform: translate(-10px, 0) rotate(-2deg); }
.leaderboard-brand .brand-gap { width: 0.25em; }

.leaderboard-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 2.08;
}

.leaderboard-frame > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.player-rsvp {
  position: relative;
  z-index: 2;
  display: grid;
  gap: clamp(8px, 1.25vw, 15px);
  width: 60%;
  max-height: 70%;
  color: var(--graphite);
  text-align: center;
}

.player-event {
  margin: 0;
  font-family: "FableDust", Georgia, serif;
  font-size: clamp(1.35rem, 2.6vw, 2.7rem);
  font-weight: 400;
  line-height: 0.9;
}

.player-form {
  display: grid;
  gap: 7px;
}

.player-form label {
  color: var(--graphite-soft);
  font-size: clamp(0.72rem, 1vw, 0.94rem);
}

.player-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.player-entry input,
.player-entry button {
  min-height: 39px;
  border: 1px solid color-mix(in srgb, var(--graphite) 42%, transparent);
  border-radius: 2px;
  font-family: "FableDust", Georgia, serif;
}

.player-entry input {
  min-width: 0;
  padding: 0 12px;
  background: color-mix(in srgb, var(--paper-bright) 68%, transparent);
  color: var(--graphite);
  font-size: clamp(1rem, 1.5vw, 1.35rem);
}

.player-entry input::placeholder {
  color: color-mix(in srgb, var(--graphite-soft) 78%, transparent);
}

.player-entry button {
  padding: 0 14px;
  background: var(--signal);
  color: var(--graphite);
  cursor: pointer;
  font-size: clamp(0.86rem, 1.2vw, 1.05rem);
  transition: background 180ms ease, transform 180ms var(--ease-out);
}

.player-entry button:hover {
  background: var(--paper-bright);
  transform: translateY(-1px);
}

.player-status {
  min-height: 1em;
  margin: 0;
  color: var(--graphite-soft);
  font-size: clamp(0.66rem, 0.9vw, 0.82rem);
}

.player-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px 16px;
  max-height: clamp(42px, 8vh, 82px);
  margin: 0;
  padding: 0;
  overflow: auto;
  counter-reset: player;
  list-style: none;
  text-align: left;
}

.player-list li {
  min-width: 0;
  overflow: hidden;
  color: var(--graphite);
  font-size: clamp(0.72rem, 1vw, 0.92rem);
  text-overflow: ellipsis;
  white-space: nowrap;
  counter-increment: player;
}

.player-list li::before {
  margin-right: 5px;
  color: var(--graphite-soft);
  content: counter(player, decimal-leading-zero) ".";
}

/* Chess clock */
.timer-screen {
  --orn-w: clamp(52px, 24vw, 104px);
  --orn-edge: 16px;
  --stack-count: calc(var(--orn-w) + var(--orn-edge) + 10px);
  --stack-time: calc(var(--orn-w) + var(--orn-edge) + 40px);
  display: grid;
  grid-template-rows: 1fr 176px 1fr;
  width: 100%;
  height: 100dvh;
  min-height: 320px;
  background: var(--paper);
  overflow: hidden;
}

.timer-clock {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  padding: 18px 52px;
  border: 0;
  background: var(--paper);
  color: var(--graphite);
  cursor: pointer;
  overflow: visible;
  transition: box-shadow 180ms ease, background 180ms ease;
}

.timer-clock--top {
  color: var(--paper-bright);
}

.timer-clock.is-active {
  box-shadow: inset 0 0 0 7px var(--signal);
}

.timer-clock.is-ended {
  box-shadow: inset 0 0 0 7px var(--danger);
}

.clock-inner {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
}

.timer-clock--top .clock-inner {
  position: absolute;
  top: var(--stack-time);
  bottom: auto;
  left: 50%;
  transform: translateX(-50%) rotate(180deg);
}

.timer-clock--bottom .clock-inner {
  position: absolute;
  top: auto;
  bottom: var(--stack-time);
  left: 50%;
  transform: translateX(-50%);
}

.time-display {
  font-family: "FableDust", Georgia, serif;
  font-size: clamp(5.6rem, 26vw, 10rem);
  font-variant-numeric: tabular-nums;
  font-weight: 300;
  letter-spacing: -0.075em;
  line-height: 0.9;
}

.move-count,
.turn-label {
  color: var(--graphite-soft);
  font-size: 0.64rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.timer-clock .move-count {
  position: absolute;
  z-index: 3;
  top: auto;
  bottom: var(--stack-count);
  left: 50%;
  transform: translateX(-50%);
}

.timer-clock--top .move-count {
  top: var(--stack-count);
  bottom: auto;
  transform: translateX(-50%) rotate(180deg);
}

.move-count b {
  color: currentColor;
  font-size: 1.1rem;
}

.turn-label {
  margin-top: 8px;
}

.timer-ornament {
  position: absolute;
  z-index: 1;
  right: 0;
  left: 0;
  width: var(--orn-w);
  height: clamp(200px, 86vw, 360px);
  margin-inline: auto;
  object-fit: contain;
  opacity: 0.8;
}

.timer-ornament--top {
  top: calc(var(--orn-w) / 2 + var(--orn-edge));
  transform: translateY(-50%) rotate(90deg);
}

.timer-ornament--bottom {
  bottom: calc(var(--orn-w) / 2 + var(--orn-edge));
  transform: translateY(50%) rotate(90deg);
}

.timer-center {
  position: relative;
  z-index: 10;
  display: grid;
  place-items: center;
  overflow: visible;
  background: var(--paper);
  box-shadow: 0 -1px 0 color-mix(in oklch, var(--graphite) 15%, transparent), 0 1px 0 color-mix(in oklch, var(--graphite) 15%, transparent);
  overflow: visible;
}

.queen-control {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  width: 168px;
  height: min(96vw, 540px);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: translate(-50%, -50%) rotate(-90deg);
}

.queen-control img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.queen-control span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.timer-status {
  position: absolute;
  right: 14px;
  width: 86px;
  color: var(--graphite-soft);
  font-size: 0.58rem;
  font-weight: 650;
  line-height: 1.25;
  text-align: right;
  text-transform: uppercase;
}

.timer-settings {
  position: fixed;
  z-index: 32;
  top: 50%;
  left: 50%;
  bottom: auto;
  display: grid;
  place-items: center;
  width: min(92vw, 84dvh, 540px);
  aspect-ratio: 922 / 923;
  max-height: none;
  padding: 0;
  border: 0;
  background: transparent url("popupwindowframe.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 18px 28px color-mix(in srgb, var(--graphite) 18%, transparent));
  opacity: 0;
  overflow: visible;
  pointer-events: none;
  transform: translate(-50%, calc(-50% + 10px)) scale(0.98);
  transition: opacity 180ms ease, transform 220ms var(--ease-out);
}

.timer-settings.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.timer-settings-backdrop {
  position: fixed;
  z-index: 31;
  inset: 0;
  padding: 0;
  border: 0;
  background: color-mix(in srgb, var(--graphite) 28%, transparent);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.timer-settings-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.timer-settings-inner {
  display: grid;
  gap: clamp(6px, 1.2dvh, 10px);
  width: 61%;
}

.timer-settings-title {
  margin: 0 0 2px;
  color: var(--graphite);
  font-family: "FableDust", Georgia, serif;
  font-size: clamp(1.6rem, 5dvh, 2.5rem);
  line-height: 0.84;
  text-align: center;
}

.timer-settings-home {
  display: grid;
  place-items: center;
  min-height: 30px;
  border-top: 1px solid color-mix(in oklch, var(--graphite) 18%, transparent);
  color: var(--graphite);
  font-size: 0.78rem;
  font-weight: 400;
  text-decoration: none;
  text-transform: uppercase;
}

.preset-row,
.timer-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.preset-row button,
.timer-actions button,
.custom-time button {
  min-height: clamp(30px, 6dvh, 38px);
  border: 1px solid color-mix(in oklch, var(--graphite) 34%, transparent);
  border-radius: 2px;
  background: color-mix(in srgb, var(--paper-bright) 65%, transparent);
  cursor: pointer;
  font-family: "FableDust", Georgia, serif;
  font-size: clamp(0.66rem, 1.8dvh, 0.82rem);
  font-weight: 400;
}

.preset-row button:hover,
.timer-actions button:hover,
.custom-time button:hover {
  background: color-mix(in oklch, var(--signal) 45%, var(--paper));
}

.timer-actions {
  grid-template-columns: 1fr 1fr;
}

.custom-time {
  display: grid;
  grid-template-columns: 1fr 1fr 62px;
  gap: 7px;
  align-items: end;
}

.custom-time label {
  display: grid;
  gap: 4px;
  color: var(--graphite-soft);
  font-family: "FableDust", Georgia, serif;
  font-size: clamp(0.58rem, 1.5dvh, 0.7rem);
  font-weight: 400;
}

.custom-time input {
  width: 100%;
  height: clamp(30px, 6dvh, 38px);
  border: 1px solid color-mix(in oklch, var(--graphite) 34%, transparent);
  border-radius: 2px;
  background: color-mix(in srgb, var(--paper-bright) 65%, transparent);
  color: var(--graphite);
  font-family: "FableDust", Georgia, serif;
  padding: 0 9px;
}

@media (min-width: 600px) and (orientation: landscape) {
  /* The supplied mockup, read left to right: ornament, time, queen, time, ornament.
     Everything stays upright; the assets are never rotated. */
  .timer-screen {
    grid-template-columns: minmax(0, 1fr) clamp(200px, 24vw, 300px) minmax(0, 1fr);
    grid-template-rows: 1fr;
  }

  .timer-clock {
    padding: 32px clamp(24px, 6vw, 96px);
  }

  .timer-clock--top .clock-inner,
  .timer-clock--bottom .clock-inner {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    transform: none;
  }

  .timer-clock--top .move-count,
  .timer-clock--bottom .move-count {
    top: 26px;
    right: auto;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
  }

  .move-count b {
    font-size: 1.5rem;
  }

  .time-display {
    font-size: clamp(3.6rem, 10.5vw, 9.5rem);
    line-height: 0.86;
  }

  .timer-ornament {
    top: 50%;
    right: auto;
    left: auto;
    width: clamp(52px, 7vw, 104px);
    height: 64%;
    margin-inline: 0;
  }

  .timer-ornament--top {
    top: 50%;
    right: auto;
    left: clamp(16px, 3vw, 54px);
    transform: translateY(-50%);
  }

  .timer-ornament--bottom {
    top: 50%;
    right: clamp(16px, 3vw, 54px);
    bottom: auto;
    left: auto;
    transform: translateY(-50%);
  }

  .timer-center {
    box-shadow:
      -1px 0 0 color-mix(in oklch, var(--graphite) 15%, transparent),
      1px 0 0 color-mix(in oklch, var(--graphite) 15%, transparent);
  }

  .queen-control {
    position: relative;
    top: auto;
    left: auto;
    width: min(100%, 300px);
    height: min(86%, 620px);
    transform: none;
  }

  .queen-control img {
    transform: none;
  }

  .timer-settings {
    top: 50%;
    left: 50%;
    bottom: auto;
    transform: translate(-50%, calc(-50% + 10px)) scale(0.98);
  }

  .timer-settings.is-open {
    transform: translate(-50%, -50%) scale(1);
  }

  .timer-status { display: none; }
}

@media (max-width: 900px) and (min-width: 721px) {
  .route-target { font-size: clamp(1.4rem, 3vw, 2rem); }
}

@media (max-width: 720px) {
  /* Phone uses its own portrait frame and a full eight-by-eight board. */
  .home--phone {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    background: var(--paper);
  }

  .phone-frame {
    position: relative;
    width: min(100vw, calc(100dvh * 1147 / 2054));
    aspect-ratio: 1147 / 2054;
    background: url("assets/phone-frame-v2.png") center / 100% 100% no-repeat;
  }

  .phone-board {
    position: absolute;
    top: 50%;
    left: 9%;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 82%;
    /* the desktop board rules set an explicit height, which would beat aspect-ratio */
    height: auto;
    aspect-ratio: 1;
    background: none;
    transform: translateY(-50%);
  }

  .phone-meta {
    position: absolute;
    top: 13%;
    right: 0;
    left: 0;
    display: grid;
    gap: 2px;
    margin: 0;
    color: var(--graphite);
    font-family: "FableDust", Georgia, serif;
    text-align: center;
  }

  .phone-meta strong {
    font-size: clamp(1.3rem, 6vw, 2rem);
    font-weight: 400;
    line-height: 0.9;
  }

  .phone-meta span {
    font-size: clamp(0.7rem, 3vw, 1rem);
    opacity: 0.8;
  }

  .phone-skip {
    position: absolute;
    right: 9%;
    bottom: 15%;
    padding: 8px 10px;
    border: 0;
    background: transparent;
    color: var(--graphite);
    cursor: pointer;
    font-family: "FableDust", Georgia, serif;
    font-size: clamp(1.1rem, 5vw, 1.6rem);
    line-height: 0.9;
  }

  .phone-logo {
    width: 34px;
    height: 42px;
    object-fit: contain;
  }

  .phone-frame > .phone-logo,
  .phone-logo-button {
    position: absolute;
    bottom: 13%;
    left: 50%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    transform: translateX(-50%);
  }

  .phone-board .route-target {
    font-size: clamp(0.75rem, 3.4vw, 1.15rem);
  }

  .phone-board .square {
    position: relative;
  }

  .phone-board .piece {
    width: 100%;
    height: 100%;
  }

  /* Size the inline SVG against the square, which has a definite width and height.
     Percentages on the piece itself resolve to nothing, so the SVG falls back to its
     own 100:140 ratio and spills the cell. The desktop board's per-piece nudges go
     too: they optically centre pieces on 8x4 cells and push them out of square ones. */
  .phone-board .piece .piece-icon {
    position: absolute;
    top: 5%;
    left: 5%;
    width: 90%;
    height: 90%;
    transform: none;
  }

  .hint {
    font-size: 0.7rem;
  }

  .content-page {
    padding: max(20px, env(safe-area-inset-top)) 20px 54px;
  }

  .page-logo {
    width: 44px;
    height: 54px;
  }

  .utility-link span:last-child {
    display: none;
  }

  .content-measure {
    margin-top: 64px;
  }

  .content-page h1 {
    font-size: clamp(3.5rem, 18vw, 5.6rem);
  }

  .lead {
    margin-top: 28px;
    font-size: 1rem;
  }

  .about-page {
    grid-template-rows: minmax(0, 43dvh) minmax(0, 57dvh);
    height: 100dvh;
    min-height: 0;
    padding: 0;
    overflow: hidden;
  }

  .about-video-stage {
    min-height: 0;
    padding: 0;
  }

  .about-video {
    inset: -5%;
    width: 110%;
    height: 110%;
    transform: translate3d(var(--about-x), var(--about-y), 12px) rotateX(var(--about-rx)) rotateY(var(--about-ry)) scale(1.025);
  }

  .about-topbar {
    padding: max(18px, env(safe-area-inset-top)) 16px 0;
  }

  .about-logo {
    width: 44px;
    height: 54px;
  }

  .about-video-toggle {
    right: 16px;
    bottom: 16px;
  }

  .about-story {
    grid-template-columns: 1fr;
    gap: 14px;
    margin: 0;
    padding: 18px 18px max(18px, env(safe-area-inset-bottom));
  }

  .about-story-heading h2 {
    max-width: 100%;
    font-size: clamp(2.65rem, 12vw, 4rem);
  }

  .about-story-copy {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .about-story-copy p {
    font-size: 0.9rem;
    line-height: 1.3;
  }

  .about-story-copy a {
    grid-column: 1;
    font-size: 1.4rem;
  }

  .privacy-list > div {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .privacy-pawn {
    right: -28px;
    bottom: 10px;
    width: 150px;
    opacity: 0.24;
  }

  .leaderboard-page {
    padding: 20px 10px;
  }

  .leaderboard-center {
    width: 100%;
    min-width: 0;
  }

  .leaderboard-brand {
    justify-self: center;
    margin: 0 0 36px;
    font-size: clamp(3.35rem, 15.5vw, 4.8rem);
  }

  .leaderboard-frame {
    width: 100%;
    min-height: 0;
    aspect-ratio: 1.6;
  }

  .leaderboard-frame > img {
    object-fit: fill;
  }

  .player-rsvp {
    width: 62%;
    max-height: 74%;
  }

  .player-event {
    font-size: clamp(1.55rem, 7vw, 2.15rem);
  }

  .player-entry {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .player-entry input,
  .player-entry button {
    min-height: 34px;
  }

  .player-list {
    grid-template-columns: 1fr;
    max-height: 46px;
  }

  .leaderboard-soldier {
    bottom: -5dvh;
    width: auto;
    height: 65dvh;
    opacity: 0.36;
  }

  .leaderboard-soldier--left { left: -12vw; }
  .leaderboard-soldier--right { right: -12vw; }
}

@media (max-height: 680px) and (max-width: 720px) {
  .mobile-logo {
    width: 58px;
    height: 66px;
  }

  .knight-menu {
    width: min(72vh, 340px);
  }

  .event-stamp strong {
    font-size: 2rem;
  }

  .time-display {
    font-size: clamp(4rem, 18vw, 6rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
