.hero-art__trigger[data-game-trigger] {
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  inset: 0;
  padding: 0;
  pointer-events: auto;
  position: absolute;
  touch-action: manipulation;
  user-select: none;
  z-index: 1;
}

.hero-art img {
  pointer-events: none;
  transition: filter 180ms cubic-bezier(0.22, 1, 0.36, 1), transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
  user-select: none;
}

.hero-art:has(.hero-art__trigger.is-game-primed) img {
  filter: saturate(1.08);
  transform: translateY(-1px);
}

.hero-art__trigger[data-game-trigger]:focus-visible {
  outline: 3px solid var(--lemon);
  outline-offset: 3px;
}

html.game-is-open,
body.game-is-open {
  overscroll-behavior: none;
  overflow: hidden;
}

.game-dialog {
  background: transparent;
  border: 0;
  color: var(--ink);
  height: 100dvh;
  margin: 0;
  max-height: none;
  max-width: none;
  overflow: hidden;
  padding: 0;
  width: 100vw;
}

.game-dialog[open] {
  display: block;
}

.game-dialog::backdrop {
  backdrop-filter: none;
  background: transparent;
}

.game-card {
  --game-origin-top: 0px;
  --game-origin-right: 100vw;
  --game-origin-bottom: 100dvh;
  --game-origin-left: 0px;
  animation: game-expand 360ms cubic-bezier(0.32, 0.72, 0, 1) both;
  background: #cfe4e9;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  width: 100vw;
}

.game-dialog.is-closing .game-card {
  animation: game-collapse 190ms cubic-bezier(0.4, 0, 1, 1) both;
}

@keyframes game-expand {
  from {
    clip-path: inset(var(--game-origin-top) var(--game-origin-right) var(--game-origin-bottom) var(--game-origin-left) round 18px);
    opacity: 0.92;
  }
  to {
    clip-path: inset(0 0 0 0 round 0);
    opacity: 1;
  }
}

@keyframes game-collapse {
  from {
    clip-path: inset(0 0 0 0 round 0);
    opacity: 1;
  }
  to {
    clip-path: inset(var(--game-origin-top) var(--game-origin-right) var(--game-origin-bottom) var(--game-origin-left) round 18px);
    opacity: 0.92;
  }
}

.game-sr-only {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.game-stage {
  background: #cfe4e9;
  height: 100%;
  overflow: hidden;
  position: relative;
  touch-action: none;
  width: 100%;
}

.game-stage:focus {
  outline: none;
}

.game-canvas {
  height: 100%;
  inset: 0;
  position: absolute;
  width: 100%;
}

.game-card:not([data-game-state="running"]) .game-canvas {
  pointer-events: none;
}

.game-close,
.game-start,
.game-character {
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}

.game-close:focus-visible,
.game-start:focus-visible,
.game-character:focus-visible {
  outline: 3px solid var(--lemon);
  outline-offset: 3px;
}

.game-close {
  align-items: center;
  background: var(--lemon);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: none;
  display: inline-flex;
  font-family: var(--body);
  font-size: 1.8rem;
  height: 46px;
  justify-content: center;
  line-height: 1;
  padding: 0 0 3px;
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  transition: transform 150ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 150ms cubic-bezier(0.22, 1, 0.36, 1);
  width: 46px;
  z-index: 10;
}

.game-close:active {
  box-shadow: none;
  transform: scale(0.97);
}

.game-scoreboard {
  align-items: center;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: none;
  display: flex;
  font-family: var(--mono);
  font-size: clamp(0.72rem, 2vw, 0.88rem);
  gap: 16px;
  left: max(12px, env(safe-area-inset-left));
  opacity: 0;
  padding: 8px 12px;
  pointer-events: none;
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  transform: translateY(-6px);
  transition: opacity 180ms cubic-bezier(0.22, 1, 0.36, 1), transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 5;
}

.game-card[data-game-state="running"] .game-scoreboard,
.game-card[data-game-state="gameover"] .game-scoreboard {
  opacity: 1;
  transform: translateY(0);
}

.game-scoreboard strong {
  color: var(--brand-orange);
  font-size: 1.1em;
}

.game-onboarding,
.game-result {
  align-items: center;
  background: transparent;
  display: flex;
  inset: 0;
  justify-content: center;
  overflow-y: auto;
  padding:
    max(70px, calc(env(safe-area-inset-top) + 56px))
    max(18px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  position: absolute;
  pointer-events: auto;
  z-index: 4;
}

.game-onboarding {
  background: var(--blue);
}

.game-onboarding[hidden],
.game-result[hidden] {
  display: none;
}

.game-onboarding__content {
  animation: game-content-in 260ms 120ms cubic-bezier(0.22, 1, 0.36, 1) both;
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2.2vh, 20px);
  margin: auto;
  max-width: 760px;
  pointer-events: auto;
  position: relative;
  text-align: center;
  width: 100%;
  z-index: 1;
}

@keyframes game-content-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.game-eyebrow {
  color: var(--brand-orange);
  font-family: var(--mono);
  font-size: clamp(0.66rem, 1.6vw, 0.78rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  margin: 0;
  text-transform: uppercase;
}

.game-onboarding h2,
.game-result h2 {
  font-family: var(--display);
  font-size: clamp(2rem, 6vw, 4.2rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
  margin: 0;
  text-shadow: 2px 2px 0 var(--paper);
  text-wrap: balance;
}

.game-characters {
  display: grid;
  gap: clamp(10px, 2vw, 18px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 560px;
  width: 100%;
}

.game-character {
  align-items: center;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: none;
  display: grid;
  gap: 3px;
  justify-items: center;
  min-height: clamp(154px, 25vh, 230px);
  padding: 8px 12px 12px;
  transition:
    background-color 180ms cubic-bezier(0.22, 1, 0.36, 1),
    border-color 180ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 180ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 150ms cubic-bezier(0.22, 1, 0.36, 1);
}

.game-character:active {
  transform: scale(0.985);
}

.game-character.is-selected {
  background: var(--lemon);
  border-color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.game-character__art {
  align-items: flex-end;
  display: flex;
  height: clamp(112px, 19vh, 178px);
  justify-content: center;
  overflow: hidden;
  width: 100%;
}

.game-character__art img {
  display: block;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  object-position: center bottom;
}

.game-character strong {
  font-family: var(--body);
  font-size: clamp(1rem, 2.2vw, 1.3rem);
  font-weight: 800;
  text-transform: uppercase;
}

.game-instructions {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 680px;
}

.game-collectibles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.game-collectibles span {
  align-items: center;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: none;
  display: inline-flex;
  font-family: var(--mono);
  font-size: clamp(0.66rem, 1.7vw, 0.78rem);
  font-weight: 700;
  gap: 5px;
  padding: 4px 9px 4px 5px;
}

.game-collectibles img {
  height: 34px;
  object-fit: contain;
  width: 34px;
}

.game-collectibles b {
  color: var(--brand-orange);
}

.game-instructions p,
.game-result > p:not(.game-eyebrow) {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-family: var(--body);
  font-size: clamp(0.72rem, 1.8vw, 0.86rem);
  line-height: 1.45;
  margin: 0;
  max-width: 52ch;
  padding: 7px 12px;
  text-wrap: balance;
}

.game-control-copy--keyboard {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .game-control-copy--touch {
    display: none;
  }

  .game-control-copy--keyboard {
    display: inline;
  }
}

.game-start {
  background: var(--lemon);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--body);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  min-height: 44px;
  padding: 10px 24px;
  text-transform: uppercase;
  transition: transform 140ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 160ms cubic-bezier(0.22, 1, 0.36, 1), opacity 160ms linear;
}

.game-start:active:not(:disabled) {
  box-shadow: none;
  transform: scale(0.97);
}

.game-start:disabled {
  cursor: default;
  opacity: 0.48;
}

.game-result {
  align-content: center;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.game-toast {
  background: var(--ink);
  border-radius: 999px;
  color: var(--chalk);
  font-family: var(--display);
  font-size: clamp(0.84rem, 2.6vw, 1.04rem);
  font-weight: 800;
  left: 50%;
  opacity: 0;
  padding: 7px 13px;
  pointer-events: none;
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  transform: translate(-50%, -6px);
  transition: opacity 140ms linear, transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 6;
}

.game-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (hover: hover) and (pointer: fine) {
  .game-character:hover:not(.is-selected) {
    border-color: color-mix(in srgb, var(--ink) 54%, transparent);
    transform: translateY(-2px);
  }
}

@media (max-width: 640px) {
  .game-onboarding {
    padding-inline: 12px;
  }

  .game-character { min-height: 150px; }

  .game-scoreboard {
    gap: 10px;
  }
}

@media (max-width: 360px) {
  .game-onboarding {
    align-items: flex-start;
    touch-action: pan-y;
  }

  .game-characters {
    grid-template-columns: 1fr;
    max-width: 250px;
  }

  .game-character {
    min-height: 138px;
  }

  .game-character__art {
    height: 104px;
  }
}

@media (max-height: 650px) and (orientation: landscape) {
  .game-onboarding {
    align-items: flex-start;
    padding-block: 52px 12px;
  }

  .game-onboarding__content {
    display: grid;
    gap: 8px 16px;
    grid-template-columns: minmax(270px, 0.9fr) minmax(300px, 1.1fr);
  }

  .game-eyebrow,
  .game-onboarding h2 {
    grid-column: 1;
  }

  .game-characters {
    grid-column: 1;
    grid-row: 3 / span 3;
  }

  .game-character {
    min-height: 132px;
  }

  .game-character__art {
    height: 96px;
  }

  .game-instructions,
  .game-start {
    grid-column: 2;
    justify-self: center;
  }

  .game-close {
    height: 40px;
    width: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-card,
  .game-dialog.is-closing .game-card {
    animation: none;
  }

  .hero-art img,
  .game-close,
  .game-scoreboard,
  .game-character,
  .game-start,
  .game-toast {
    transition: none;
  }

  .game-onboarding__content { animation: none; }
}
