/* The lantern layer shares the museum illustration's native 270 × 96 grid. */
#game:has(#round-start:not([hidden])) .intro::after {
  content: "";
  position: absolute;
  inset: 1px 0 0 49%;
  z-index: -1;
  background: url('/designs/pixel/garden-lights.png') right bottom / contain no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
}
@media (max-width: 700px) {
  #game:has(#round-start:not([hidden])) .intro::after {
    inset: auto -1px 2px auto;
    width: 41%;
    height: 67px;
  }
}
@media (max-width: 370px) {
  #game:has(#round-start:not([hidden])) .intro::after { width: 35% }
}

.card.correct .letter { background: var(--pixel-green) }
.card.wrong .letter { background: var(--pixel-red) }
.feedback[data-outcome="miss"] { border-left-color: var(--pixel-red) }
.feedback[data-outcome="timeout"] { border-left-color: var(--pixel-gold) }

/* Small ticket punches echo the square letters on the frames. */
.feedback[data-outcome] strong {
  display: block;
  text-wrap: balance;
}
.feedback[data-outcome] strong::before {
  content: "";
  width: .68em;
  height: .68em;
  margin-right: .44em;
  display: inline-block;
  background: url('/designs/pixel/ticket-marks.png') left center / 300% 100% no-repeat;
  image-rendering: pixelated;
}
.feedback[data-outcome="miss"] strong::before { background-position: center }
.feedback[data-outcome="timeout"] strong::before { background-position: right center }

@media (prefers-reduced-motion: no-preference) {
  #game:has(#round-start:not([hidden])) .intro::after {
    animation: museum-lamps 780ms steps(3, end) both;
  }
  @keyframes museum-lamps {
    0% { opacity: 0 }
    36% { opacity: .72 }
    53% { opacity: .48 }
    100% { opacity: 1 }
  }

  /* The mounting corners move while the paintings and hit targets stay put. */
  #gallery:not([hidden]) .card:not(.revealed) .wall { position: relative }
  #gallery:not([hidden]) .card:not(.revealed) .wall::after {
    --edge: linear-gradient(var(--pixel-gold), var(--pixel-gold));
    content: "";
    position: absolute;
    inset: 3px;
    pointer-events: none;
    opacity: 0;
    background:
      var(--edge) left top / 12px 2px,
      var(--edge) left top / 2px 9px,
      var(--edge) right top / 12px 2px,
      var(--edge) right top / 2px 9px,
      var(--edge) left bottom / 12px 2px,
      var(--edge) left bottom / 2px 9px,
      var(--edge) right bottom / 12px 2px,
      var(--edge) right bottom / 2px 9px;
    background-repeat: no-repeat;
    animation: museum-mount 290ms steps(4, end) var(--mount-delay, 0ms) backwards;
  }
  #gallery .card:nth-child(2) { --mount-delay: 45ms }
  #gallery .card:nth-child(3) { --mount-delay: 90ms }
  @keyframes museum-mount {
    0% { transform: scale(.96,.93); opacity: 0 }
    28% { opacity: .9 }
    64% { transform: none; opacity: .7 }
    100% { transform: none; opacity: 0 }
  }

  .card.correct .letter, .feedback[data-outcome="hit"] strong::before {
    animation: museum-stamp 210ms steps(4, end);
  }
  @keyframes museum-stamp {
    0% { transform: translateY(-3px) scale(1.12) }
    56% { transform: translateY(1px) scale(1,.94) }
    100% { transform: none }
  }
  .card.wrong .letter, .feedback[data-outcome="miss"] strong::before {
    animation: museum-nudge 200ms steps(2, end);
  }
  @keyframes museum-nudge {
    0%, 100% { transform: none }
    25% { transform: translateX(-2px) }
    65% { transform: translateX(2px) }
  }
  .feedback[data-outcome="timeout"] strong::before {
    animation: museum-hourglass 200ms steps(3, end);
  }
  @keyframes museum-hourglass {
    from { transform: rotate(-90deg) }
    to { transform: none }
  }

  .results:not([hidden]) li {
    animation: museum-caption 190ms ease-out var(--caption-delay, 0ms) backwards;
  }
  .results li:nth-child(2) { --caption-delay: 30ms }
  .results li:nth-child(3) { --caption-delay: 60ms }
  .results li:nth-child(4) { --caption-delay: 90ms }
  .results li:nth-child(5) { --caption-delay: 120ms }
  @keyframes museum-caption {
    from { opacity: .78; transform: translateY(-4px) }
    to { opacity: 1; transform: none }
  }
  #modal[open] .large-art { animation: museum-magnify 145ms ease-out }
  @keyframes museum-magnify {
    from { transform: scale(.98) }
    to { transform: none }
  }
  #modal[open]:has(.large-art)::backdrop { animation: museum-shade 145ms ease-out }
  @keyframes museum-shade {
    from { background-color: #151221b3 }
    to { background-color: #151221dd }
  }
}
