:root {
  color-scheme: dark;
  --bg: #06101d;
  --bg-deep: #020711;
  --surface: rgba(12, 28, 47, 0.92);
  --surface-solid: #0d1d31;
  --surface-soft: rgba(27, 48, 75, 0.68);
  --text: #f4f7fb;
  --muted: #93a5bd;
  --line: rgba(151, 190, 223, 0.23);
  --accent: #54d8ff;
  --accent-2: #9e68ff;
  --accent-ink: #021018;
  --danger: #ff657a;
  --success: #65efb7;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html[data-theme="woodgrain"] {
  --bg: #1b0f0a;
  --bg-deep: #0d0704;
  --surface: rgba(57, 31, 20, 0.94);
  --surface-solid: #3a2117;
  --surface-soft: rgba(105, 63, 35, 0.55);
  --text: #fff6e8;
  --muted: #d1b89a;
  --line: rgba(236, 181, 105, 0.25);
  --accent: #f1ad54;
  --accent-2: #d76d36;
  --accent-ink: #211006;
}

html[data-theme="paper"] {
  --bg: #171512;
  --bg-deep: #0d0c0a;
  --surface: rgba(49, 45, 37, 0.94);
  --surface-solid: #302c25;
  --surface-soft: rgba(102, 92, 74, 0.48);
  --text: #fff9e9;
  --muted: #c9bfa8;
  --line: rgba(244, 224, 179, 0.22);
  --accent: #f0cd75;
  --accent-2: #da8f62;
  --accent-ink: #211a0c;
}

html[data-theme="light"] {
  --bg: #121925;
  --bg-deep: #080c13;
  --surface: rgba(30, 40, 55, 0.94);
  --surface-solid: #202c3b;
  --surface-soft: rgba(79, 95, 116, 0.45);
  --text: #ffffff;
  --muted: #bdc8d6;
  --line: rgba(255, 255, 255, 0.22);
  --accent: #ffffff;
  --accent-2: #a7d9ff;
  --accent-ink: #14202d;
}

html[data-mode="light"] {
  color-scheme: light;
  --bg: #e8edf4;
  --bg-deep: #d9e0ea;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-solid: #ffffff;
  --surface-soft: rgba(220, 229, 241, 0.82);
  --text: #152134;
  --muted: #5b6c80;
  --line: rgba(27, 53, 85, 0.18);
  --shadow: 0 24px 60px rgba(33, 48, 70, 0.16);
}

html[data-theme="woodgrain"][data-mode="light"] {
  --bg: #eadfce;
  --bg-deep: #d9c8ae;
  --surface: rgba(255, 249, 239, 0.95);
  --surface-solid: #fff8ed;
  --surface-soft: rgba(221, 194, 156, 0.58);
  --text: #3a2519;
  --muted: #755b49;
  --line: rgba(82, 48, 25, 0.2);
}

html[data-theme="paper"][data-mode="light"] {
  --bg: #f1ead9;
  --bg-deep: #e1d6bf;
  --surface: rgba(255, 252, 242, 0.95);
  --surface-solid: #fffdf6;
  --surface-soft: rgba(229, 215, 184, 0.6);
  --text: #332e24;
  --muted: #716958;
  --line: rgba(58, 48, 31, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 20% 10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 38%),
    radial-gradient(circle at 90% 90%, color-mix(in srgb, var(--accent-2) 16%, transparent), transparent 38%),
    linear-gradient(145deg, var(--bg-deep), var(--bg));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
select,
input {
  font: inherit;
}

button,
select,
input[type="range"],
input[type="checkbox"] {
  accent-color: var(--accent);
}

button {
  color: inherit;
}

button:not(:disabled),
select,
input {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

#app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100svh;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.985);
  transition: opacity 220ms ease, transform 220ms ease, visibility 220ms;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.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;
}

.brand {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 14vw, 6.8rem);
  font-weight: 700;
  letter-spacing: -0.065em;
  line-height: 0.82;
  text-align: center;
  text-shadow: 0 0 36px color-mix(in srgb, var(--accent) 20%, transparent);
}

.brand span {
  display: block;
  margin-top: 1.25rem;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 0.16em;
  font-weight: 700;
  letter-spacing: 0.42em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--accent);
}

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(2rem + var(--safe-top)) calc(1.5rem + var(--safe-right)) calc(2rem + var(--safe-bottom)) calc(1.5rem + var(--safe-left));
  cursor: pointer;
  isolation: isolate;
}

.start-halo {
  position: absolute;
  z-index: -1;
  width: min(70vw, 26rem);
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 50%;
  box-shadow:
    0 0 0 2.5rem color-mix(in srgb, var(--accent-2) 4%, transparent),
    0 0 0 5rem color-mix(in srgb, var(--accent) 3%, transparent),
    0 0 90px color-mix(in srgb, var(--accent) 12%, transparent);
  animation: breathe 4s ease-in-out infinite;
}

.start-logo {
  width: clamp(3.5rem, 14vw, 5.5rem);
  height: auto;
  margin-bottom: 2rem;
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--accent) 28%, transparent));
}

.brand-start {
  font-size: clamp(3.6rem, 17vw, 7.8rem);
}

.start-prompt {
  margin: 4rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
}

.intro-screen {
  display: grid;
  place-items: center;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: #000;
}

.intro-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.skip-button {
  position: absolute;
  right: calc(1rem + var(--safe-right));
  bottom: calc(1rem + var(--safe-bottom));
  min-width: 5.2rem;
  min-height: 2.9rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: white;
  font-weight: 750;
}

.menu-screen {
  display: grid;
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: calc(2rem + var(--safe-top)) calc(1.25rem + var(--safe-right)) calc(1.2rem + var(--safe-bottom)) calc(1.25rem + var(--safe-left));
}

.menu-pattern {
  position: absolute;
  inset: -8%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  opacity: 0.055;
  transform: rotate(-9deg) scale(1.08);
  pointer-events: none;
}

.menu-pattern span {
  justify-self: center;
  width: min(27vw, 11rem);
  aspect-ratio: 0.774;
  background-image: url('./card-flip-sprite-sheet.png');
  background-repeat: no-repeat;
  background-size: 500% 400%;
  background-position: 50% 100%;
}

.menu-content {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(100%, 31rem);
  min-height: min(91dvh, 52rem);
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.menu-content .brand {
  margin: 0.25rem 0 clamp(2rem, 6vh, 4rem);
  font-size: clamp(3.4rem, 15vw, 6.4rem);
}

.menu-nav {
  display: grid;
  width: min(100%, 22rem);
  gap: 0.68rem;
}

.menu-button {
  display: grid;
  min-height: 3.35rem;
  grid-template-columns: 2.2rem 1fr 2.2rem;
  align-items: center;
  padding: 0.65rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.14);
  font-weight: 750;
  letter-spacing: 0.015em;
  transition: transform 130ms ease, border-color 130ms ease, background 130ms ease;
}

.menu-button span {
  color: var(--accent);
  font-size: 1.05rem;
}

.menu-button::after {
  content: '›';
  color: var(--muted);
  font-size: 1.45rem;
}

.menu-button:not(:disabled):hover,
.menu-button:not(:disabled):active {
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
  transform: translateY(-2px);
}

.menu-button-primary {
  border-color: transparent;
  background: linear-gradient(120deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--accent-2)));
  color: var(--accent-ink);
}

.menu-button-primary span,
.menu-button-primary::after {
  color: var(--accent-ink);
}

.menu-footer {
  display: flex;
  margin-top: auto;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.menu-footer img {
  width: 3.2rem;
  height: auto;
  opacity: 0.84;
}

.menu-footer a {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  padding-inline: 0.5rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.game-screen {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: calc(0.75rem + var(--safe-top)) calc(0.8rem + var(--safe-right)) calc(1.2rem + var(--safe-bottom)) calc(0.8rem + var(--safe-left));
}

.game-header {
  display: grid;
  width: min(100%, 40rem);
  margin: 0 auto 0.7rem;
  grid-template-columns: 3rem 1fr 3rem;
  align-items: center;
}

.game-title-wrap {
  text-align: center;
}

.game-title-wrap h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  letter-spacing: -0.04em;
}

.game-title-wrap p {
  margin: 0.1rem 0 0;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.icon-button,
.back-button {
  min-width: 2.8rem;
  min-height: 2.8rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  font-weight: 800;
}

.game-stats {
  display: grid;
  width: min(100%, 31rem);
  margin: 0 auto 0.55rem;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.game-stats div {
  display: flex;
  min-height: 3.4rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
}

.game-stats span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.game-stats strong {
  margin-top: 0.1rem;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: min(92%, 29rem);
  height: 0.28rem;
  margin: 0.75rem auto 0;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 260ms ease;
}

.game-message {
  min-height: 1.3rem;
  margin: 0.55rem auto 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
  text-align: center;
}

.game-message.is-success {
  color: var(--success);
}

.game-message.is-error {
  color: var(--danger);
}

.card-grid {
  --cols: 4;
  --gap: clamp(0.22rem, 1.2vw, 0.5rem);
  display: grid;
  width: min(94vw, calc(var(--cols) * 5.6rem + (var(--cols) - 1) * var(--gap)));
  margin: 0 auto;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: var(--gap);
}

.memory-card {
  position: relative;
  min-width: 0;
  aspect-ratio: 0.774;
  padding: 0;
  border: 0;
  border-radius: 11%;
  background: transparent;
  perspective: 900px;
  touch-action: manipulation;
}

.memory-card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 430ms cubic-bezier(0.2, 0.75, 0.25, 1.05);
}

.memory-card.is-flipped .memory-card-inner,
.memory-card.is-matched .memory-card-inner {
  transform: rotateY(180deg);
}

.card-side {
  position: absolute;
  inset: 0;
  display: block;
  background-image: url('./card-flip-sprite-sheet.png');
  background-repeat: no-repeat;
  background-size: 500% 400%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.34));
}

.card-side-back {
  background-position: 50% 100%;
}

.card-side-front {
  background-position: var(--sprite-x) var(--sprite-y);
  transform: rotateY(180deg);
}

.memory-card:hover:not(:disabled) .memory-card-inner,
.memory-card:focus-visible .memory-card-inner {
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 65%, transparent));
}

.memory-card.is-matched .card-side-front {
  filter:
    drop-shadow(0 0 5px color-mix(in srgb, var(--success) 80%, transparent))
    drop-shadow(0 6px 7px rgba(0, 0, 0, 0.32));
  animation: match-pop 360ms ease-out;
}

.memory-card.is-wrong {
  animation: wrong-shake 330ms ease;
}

.pairs-label {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-align: center;
}

.panel-screen {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: calc(0.8rem + var(--safe-top)) calc(1rem + var(--safe-right)) calc(2rem + var(--safe-bottom)) calc(1rem + var(--safe-left));
}

.panel-header {
  display: grid;
  width: min(100%, 39rem);
  margin: 0 auto 1.5rem;
  grid-template-columns: 6.2rem 1fr 6.2rem;
  align-items: center;
}

.panel-header h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.75rem;
  text-align: center;
}

.back-button {
  padding-inline: 0.75rem;
  color: var(--muted);
}

.panel-body {
  width: min(100%, 35rem);
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-body h2 {
  margin: 2rem 0 0.8rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.summary-grid article {
  display: flex;
  min-height: 6rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  text-align: center;
}

.summary-grid strong {
  color: var(--accent);
  font-size: 1.65rem;
}

.summary-grid span {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.best-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.best-row {
  display: grid;
  min-height: 3.4rem;
  grid-template-columns: 1.15fr 1fr 1fr;
  align-items: center;
  padding: 0.7rem 0.9rem;
  gap: 0.45rem;
  background: var(--surface-soft);
  font-size: 0.82rem;
}

.best-row + .best-row {
  border-top: 1px solid var(--line);
}

.best-row span:nth-child(n+2) {
  color: var(--muted);
  text-align: right;
}

.text-button {
  min-height: 2.8rem;
  margin-top: 1.5rem;
  padding: 0.55rem 0.8rem;
  border: 0;
  background: transparent;
  font-weight: 700;
}

.danger-button {
  color: var(--danger);
}

.help-copy {
  line-height: 1.6;
}

.help-copy ol {
  display: grid;
  margin: 1.5rem 0;
  padding-left: 1.4rem;
  gap: 0.65rem;
}

.help-copy p {
  color: var(--muted);
}

.sprite-demo {
  display: flex;
  height: 8.4rem;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.sprite-card {
  display: block;
  width: 6.25rem;
  aspect-ratio: 0.774;
  background-image: url('./card-flip-sprite-sheet.png');
  background-repeat: no-repeat;
  background-size: 500% 400%;
  filter: drop-shadow(0 7px 7px rgba(0, 0, 0, 0.28));
}

.sprite-back {
  background-position: 50% 100%;
  transform: rotate(-6deg);
}

.sprite-symbol {
  margin-left: -1rem;
  background-position: 75% 33.333%;
  transform: rotate(7deg);
}

.settings-list {
  display: grid;
  gap: 0;
}

.settings-list label {
  display: grid;
  min-height: 4.2rem;
  grid-template-columns: 1fr minmax(8rem, 42%);
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

.settings-list label:last-child {
  border-bottom: 0;
}

.settings-list select {
  min-height: 2.8rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-solid);
  color: var(--text);
}

.settings-list input[type="checkbox"] {
  justify-self: end;
  width: 1.45rem;
  height: 1.45rem;
}

.settings-list input[type="range"] {
  width: 100%;
  min-height: 2.75rem;
}

.game-dialog {
  width: min(30rem, calc(100vw - var(--safe-left) - var(--safe-right) - 1rem));
  max-width: calc(100vw - var(--safe-left) - var(--safe-right) - 1rem);
  max-height: min(44rem, calc(100dvh - var(--safe-top) - var(--safe-bottom) - 1rem));
  margin: auto;
  padding: clamp(1.2rem, 5vw, 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow);
}

.game-dialog::backdrop {
  background: rgba(1, 5, 11, 0.78);
  backdrop-filter: blur(6px);
}

.game-dialog h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 8vw, 2.5rem);
  line-height: 1.05;
}

.dialog-heading {
  margin-bottom: 1.25rem;
}

.difficulty-list {
  display: grid;
  gap: 0.65rem;
}

.difficulty-list button {
  display: flex;
  min-height: 4.2rem;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 0.65rem 1rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
  text-align: left;
}

.difficulty-list button:hover {
  border-color: var(--accent);
}

.difficulty-list strong {
  font-size: 1rem;
}

.difficulty-list span {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.77rem;
}

.dialog-primary,
.dialog-cancel {
  width: 100%;
  min-height: 3.15rem;
  margin-top: 0.7rem;
  border-radius: 12px;
  font-weight: 800;
}

.dialog-primary {
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
}

.dialog-cancel {
  border: 1px solid var(--line);
  background: transparent;
}

.compact-dialog,
.complete-dialog {
  text-align: center;
}

.compact-dialog h2 {
  margin-bottom: 1.4rem;
}

.completion-mark {
  display: grid;
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1.3rem;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--success) 16%, transparent);
  color: var(--success);
  font-size: 1.8rem;
  box-shadow: 0 0 36px color-mix(in srgb, var(--success) 20%, transparent);
}

.complete-dialog > p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.completion-score {
  display: flex;
  margin: 1.25rem 0;
  flex-direction: column;
  align-items: center;
}

.completion-score span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.completion-score strong {
  color: var(--accent);
  font-size: 2.6rem;
  font-variant-numeric: tabular-nums;
}

@keyframes breathe {
  0%, 100% { transform: scale(0.94); opacity: 0.65; }
  50% { transform: scale(1.04); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 0.48; }
  50% { opacity: 1; }
}

@keyframes match-pop {
  0% { transform: rotateY(180deg) scale(0.9); }
  55% { transform: rotateY(180deg) scale(1.08); }
  100% { transform: rotateY(180deg) scale(1); }
}

@keyframes wrong-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

html.reduced-motion *,
html.reduced-motion *::before,
html.reduced-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

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

@media (max-height: 690px) {
  .menu-screen {
    place-items: start center;
  }

  .menu-content {
    min-height: calc(100dvh - 3.2rem - var(--safe-top) - var(--safe-bottom));
    justify-content: flex-start;
  }

  .menu-content .brand {
    margin-bottom: 1.3rem;
    font-size: clamp(3rem, 13vw, 5rem);
  }

  .menu-nav {
    gap: 0.45rem;
  }

  .menu-button {
    min-height: 2.9rem;
  }

  .menu-footer img {
    width: 2.4rem;
  }

  .menu-footer {
    margin-top: 1rem;
  }

  .game-header,
  .game-stats {
    margin-bottom: 0.4rem;
  }

  .game-message {
    margin-top: 0.35rem;
  }
}

/* Short desktop windows: the menu footer (logo and site link) sat below the
   fold at 150% browser zoom on 720p/768p displays. Tighten the same spacing
   the short-height mobile query tightens, without touching touch layouts. */
@media (min-width: 760px) and (hover: hover) and (pointer: fine) and (max-height: 640px) {
  .menu-screen {
    padding-top: calc(1.25rem + var(--safe-top));
  }

  .menu-content .brand {
    margin-bottom: 1rem;
    font-size: clamp(2.6rem, 9vh, 4.25rem);
  }

  .menu-button {
    min-height: 2.7rem;
  }

  .menu-footer {
    margin-top: 0.8rem;
  }

  .menu-footer img {
    width: 2rem;
  }
}

/* Short desktop windows. Modal content (the completion summary above all)
   was taller than the window between 520px and 700px of viewport height, so
   the closing buttons sat below the dialog fold. Reclaim the vertical padding
   there. Placed before the 520px query so the more compact landscape rules
   still win, and gated on a precise pointer so phone and tablet layouts are
   untouched. */
@media (min-width: 760px) and (hover: hover) and (pointer: fine) and (max-height: 700px) {
  .game-dialog {
    padding: 1.25rem;
  }

  .dialog-heading {
    margin-bottom: 0.85rem;
  }

  .dialog-primary,
  .dialog-cancel {
    min-height: 2.9rem;
    margin-top: 0.5rem;
  }

  .difficulty-list {
    gap: 0.5rem;
  }

  .difficulty-list button {
    min-height: 3.7rem;
  }

  .completion-mark {
    width: 3rem;
    height: 3rem;
    margin-bottom: 0.7rem;
    font-size: 1.45rem;
  }

  .compact-dialog h2 {
    margin-bottom: 1rem;
  }
}

@media (max-height: 520px) {
  .game-dialog {
    padding: 1rem;
  }

  .dialog-heading {
    margin-bottom: 0.75rem;
  }

  .difficulty-list {
    gap: 0.45rem;
  }

  .difficulty-list button {
    min-height: 3.25rem;
  }

  .completion-mark {
    width: 3rem;
    height: 3rem;
    margin-bottom: 0.7rem;
  }
}

/* Very short desktop windows (720p and 768p at 150% browser zoom). The
   completion summary is still taller than the window after the tiers above,
   so drop the purely decorative completion mark and the last of the padding
   rather than leave the closing buttons below the dialog fold. Ordered after
   the 520px query so these desktop-only values win there. */
@media (min-width: 760px) and (hover: hover) and (pointer: fine) and (max-height: 540px) {
  .game-dialog {
    padding: 0.75rem 1rem;
  }

  .completion-mark {
    display: none;
  }

  .complete-dialog .eyebrow {
    margin-bottom: 0.4rem;
  }

  .dialog-primary,
  .dialog-cancel {
    min-height: 2.85rem;
    margin-top: 0.45rem;
  }
}

@media (min-width: 760px) {
  .menu-screen::before,
  .game-screen::before,
  .panel-screen::before {
    content: '';
    position: fixed;
    inset: 1.2rem;
    z-index: -1;
    border: 1px solid var(--line);
    border-radius: 28px;
    pointer-events: none;
  }

  .game-screen {
    padding-top: calc(1.6rem + var(--safe-top));
  }
}
