#stall[data-world='night'] { background-color: #0c194c; background-image: url('art/festival.webp'); }
#stall[data-world='night'] .pk-bar {
  --kit-bar-tint: #111e45df;
  --kit-bar-ink: #fff0cb;
}
#stall[data-world='orchard'] { background-color: #adb781; background-image: url('art/orchard-phone.webp'); }
#stall[data-world='pier'] { background-color: #77bdc0; background-image: url('art/pier-phone.webp'); }
#stall[data-world='pier'] .pk-bar { --kit-bar-tint: #163c4be6; }
#stall[data-world='orchard'] .pk-bar { --kit-bar-tint: #263d24de; }

#sheet:is([data-kind='festival-result'], [data-kind='pause']) .primary {
  background: linear-gradient(#ffe089, #f8ae44); color: #3b2221; border-color: #ffe9a0;
  box-shadow: 0 3px 0 #a65a2d, 0 5px 15px #1c0d1f69;
}

#game[data-mode='festival'] {
  inset: var(--safe-top) 0 0;
  grid-template: auto minmax(0, 1fr) auto / minmax(0, 1fr);
}
#game[data-mode='festival'] #field { grid-area: 2 / 1; margin: 0; }
#christmas-garland { display: none; }
#game[data-christmas] #christmas-garland {
  display: block;
  position: absolute;
  inset: 37px 0 auto;
  height: clamp(47px, 14vw, 95px);
  background: url('art/christmas-garland.webp') center top / 100% 100% no-repeat;
  pointer-events: none;
}
/* Canvas receives focus to start the keyboard lane. Other controls keep their focus rings. */
#canvas:focus { outline: none; }
#game[data-mode='festival'] #hint {
  color: #fff2c8; border: 1px solid #e4b3747d;
  background: #151f4be8; font-size: 15px; line-height: 1.2;
}
#festival-hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(7px, 2.8vw, 20px);
  position: relative;
  z-index: 11;
  padding: 5px max(12px, env(safe-area-inset-left), env(safe-area-inset-right)) 7px;
  background: linear-gradient(180deg, #080f31f5, #0c153ad9 64%, #0b153700);
  color: #fff1c5;
  text-shadow: 0 2px 4px #080d29;
  pointer-events: none;
}
#festival-pause {
  width: 52px; height: 52px; display: grid; place-items: center; padding: 0;
  pointer-events: auto;
  border-radius: 50%; border: 1px solid #edd29e6b; color: #fff1c5; background: #111d42dd;
}
#festival-pause svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-linecap: round; }
#festival-pause:focus-visible, #spotlight:focus-visible { outline-color: #fff4bd; }
.festival-score, .festival-time, .festival-pair { display: grid; align-content: center; gap: 1px; min-width: 0; }
.festival-score { text-align: right; }
.festival-time { text-align: center; }
.festival-pair {
  position: absolute; inset: calc(100% + 3px) auto auto 50%; translate: -50% 0;
  justify-items: center; gap: 1px; padding: 4px 12px;
  border: 1px solid #f1ce8c69; border-radius: 13px;
  background: #111c3fed; box-shadow: 0 3px 10px #060a2661;
}
#festival-hud span { color: #ffdb91; font-size: 11px; font-weight: 900; line-height: 1.15; white-space: nowrap; }
#festival-hud strong { font: 800 clamp(23px, 6vw, 31px)/1.05 var(--serif); font-variant-numeric: tabular-nums; }
#festival-hud #festival-clock { font-size: clamp(32px, 9vw, 44px); }
.festival-time[data-final] strong { color: #ffb099; }
#pair-fruit { display: flex; align-items: center; justify-content: center; gap: 6px; }
#pair-fruit img { width: 37px; height: 37px; object-fit: contain; filter: drop-shadow(0 1px 2px #030a23); }
.festival-pair[data-delivered] img { filter: drop-shadow(0 0 5px #ffe38d); }
#festival-effects { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.pair-delivery {
  position: fixed; width: 42px; height: 42px; object-fit: contain;
  filter: drop-shadow(0 0 5px #ffe4949d);
}
.charge-delivery {
  position: fixed;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: radial-gradient(circle, #fffdf0 0 17%, #ffe685 26%, #fdaa3c80 50%, transparent 73%);
  filter: drop-shadow(0 0 7px #ffd989);
}
#festival-score { display: block; transform-origin: left center; }
#game[data-spotlight] #festival-score { color: #ffe28e; }
#game[data-spotlight] #field { box-shadow: inset 0 10px 29px -25px #ffe0a4, inset 0 -12px 34px -26px #ffe0a4; }
#festival-control {
  grid-area: 3 / 1;
  position: relative; z-index: 11; justify-self: end;
  width: min(166px, calc(100% - 24px));
  margin: 0 max(12px, env(safe-area-inset-right)) max(8px, var(--safe-bottom)) 12px;
  color: #fff2cc;
}
#spotlight, #cake-status {
  width: 100%; min-height: 54px; display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 9px; border: 1px solid #d9bb796b; border-radius: 13px;
  background: #101a38ed; color: #fff0ce; text-align: left;
}
.spotlight-copy { min-width: 0; }
.spotlight-copy { display: grid; gap: 2px; }
.spotlight-copy strong, #cake-status strong { font-size: 14px; line-height: 1.1; }
.spotlight-copy small, #cake-status span { font-size: 11px; font-weight: 850; line-height: 1.1; }
.spotlight-mark {
  display: grid; place-items: center; width: 29px; height: 29px; flex: 0 0 29px;
  background: #f4c77724; border-radius: 50%; color: #ffdb91; font-size: 19px; line-height: 1;
}
#spotlight-charge {
  position: absolute; inset: auto 11px 5px; width: calc(100% - 22px); height: 3px;
  appearance: none; border: 0; border-radius: 20px; overflow: hidden; background: #efce7638;
  pointer-events: none;
}
#spotlight-charge::-webkit-progress-bar { background: #efce7638; }
#spotlight-charge::-webkit-progress-value { background: #ffd478; border-radius: 20px; }
#spotlight-charge::-moz-progress-bar { background: #ffd478; border-radius: 20px; }
#festival-control[data-ready] #spotlight {
  background: linear-gradient(160deg, #ffe19a, #f6b958); color: #352433;
  border-color: #fff0bd; box-shadow: 0 0 15px #ffc96c65;
}
#festival-control[data-ready] .spotlight-mark { color: #4b2b32; background: #8f53182b; }
#festival-control[data-ready] #spotlight-charge { visibility: hidden; }
#festival-control[data-lit] #spotlight { border-color: #ffe398; }
#cake-status { flex-direction: column; justify-content: center; align-items: start; gap: 3px; }
#cake-status span { color: #ffdb91; }

#sheet[data-kind='festival-result'] {
  width: min(calc(100% - 28px), 412px);
  padding: clamp(15px, 4.5vw, 24px);
  border: 1px solid #dfb76a;
  color: #fff1cf;
  background: radial-gradient(ellipse at 50% -15%, #6d4271, #182446 57%);
  box-shadow: 0 20px 74px #070a20a8, inset 0 0 0 4px #f2c97810;
  text-align: center;
}
#sheet[data-kind='festival-result']::backdrop { background: #070d2bb5; }
#sheet[data-kind='festival-result'] #sheet-title {
  margin: 2px 0 3px; color: #ffe0a4;
  font: 900 13px/1.15 var(--sans); letter-spacing: .08em; text-transform: uppercase;
}
.festival-result-score { display: grid; justify-items: center; gap: 4px; padding: 3px 0 9px; }
.festival-result-score strong {
  color: #ffdf90; font: 800 clamp(49px, 15vw, 72px)/1.05 var(--serif);
  text-shadow: 0 4px #372847, 0 0 22px #ffe1883b;
}
.festival-result-score p { color: #fff2d4; font-size: 13px; font-weight: 850; }
.festival-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin: 2px 0 0; padding: 9px 0; border-block: 1px solid #f1d4a032;
}
.festival-stats > div { display: grid; justify-items: center; gap: 2px; }
.festival-stats dt { grid-row: 2; color: #ecd39e; font-size: 12px; }
.festival-stats dd { grid-row: 1; margin: 0; font: 800 22px/1.15 var(--serif); }
.festival-reward { margin-bottom: 10px; }
.festival-reward p { font-size: 13px; color: #ffe1a1; }
.festival-reward ul {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 5px;
  margin: 4px 0 0; padding: 0; list-style: none;
}
.festival-reward img {
  display: block; width: 44px; height: 44px; padding: 3px; margin-inline: auto; object-fit: contain;
  background: #e9c18214; border: 1px solid #e9c18253; border-radius: 10px;
}
.festival-reward li { flex: 0 0 min(86px, 31%); }
.festival-reward li p { color: #fff1cf; margin-top: 3px; font-size: 11px; }
#sheet[data-kind='festival-result'] #sheet-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
#stall:has(#sheet[data-kind='festival-result'][open]) :is(#festival-hud, #festival-control, #hint) { visibility: hidden; }
#sheet[data-kind='festival-result'] #sheet-actions button:not(.primary) {
  background: transparent; color: #fff1cb; border: 1px solid transparent; box-shadow: none;
}
#sheet[data-kind='festival-result'] button:focus-visible { outline-color: #fff3c4; }
@media (prefers-reduced-motion: no-preference) {
  #stall:not([data-still]) #sheet[data-kind='festival-result'][open] {
    animation: result-arrive 180ms cubic-bezier(.22, 1, .36, 1) both;
  }
  @keyframes result-arrive {
    from { opacity: .5; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
.trail-grid { display: grid; gap: 13px; }
.trail-group h3 { margin: 0 0 6px; font: 800 21px/1.2 var(--serif); }
.trail-group p { margin: 0 0 8px; font-size: 14px; }
.trail-group .menu-list > button > span { display: block; }
.trail-group .menu-list > button > span + span { font-size: 13px; white-space: nowrap; }
.trail-group { border: 1px solid #b69564; border-radius: 10px; background: #f9e6b9; padding: 12px; }
.trail-group[aria-label='The Orchard'] { background: #e0e9d0; border-color: #9eae80; }
.trail-group[aria-label='Citrus Pier'] { background: #d5eae6; border-color: #87aba8; }
.trail-group[aria-label='Lantern Row'] { background: #e5dcf2; border-color: #b5a1c6; }
dialog[data-kind='book'] #sheet-content { max-height: clamp(116px, 45dvh, 515px); overflow: auto; padding-right: 3px; }
#ingredients [data-sequence]:not([data-filled])::after {
  content: attr(data-sequence); position: absolute; right: -4px; bottom: -2px; width: 18px; height: 18px;
  border-radius: 50%; border: 1px solid #fff3d5; color: #fff7e0; background: #58512e; font-size: 13px; line-height: 16px;
}
#tap-zone { align-content: center; grid-template-columns: minmax(0, 1fr); }
#tap-fruit { display: grid; grid-template-columns: repeat(var(--visible-choices, 3), minmax(0, 1fr)); width: min(100%, 510px); }
.tap-fruit { position: relative; width: auto; min-width: 0; padding-inline: 4px; font-size: clamp(13px, 3.75vw, 16px); overflow-wrap: anywhere; }
.tap-key {
  position: absolute; left: 4px; top: 4px; min-width: 17px; padding: 1px 3px; border-radius: 5px;
  background: #e1cca1; color: #432a17; font-size: 12px; font-weight: 900;
}
.tap-fruit [data-tap-shell] { outline: 2px solid #45898d; border-radius: 30%; box-shadow: 0 0 0 4px #abe1d766; }
.tap-fruit [data-tap-cracked] { outline-style: dashed; }
@media (orientation: landscape) {
  #stall[data-world='night'] { background-image: url('art/festival-wide.webp'); }
  #stall[data-world='orchard'] { background-image: url('art/orchard.webp'); }
  #stall[data-world='pier'] { background-image: url('art/pier.webp'); }
  #game[data-christmas] #christmas-garland { height: clamp(48px, 13dvh, 94px); }
  .trail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (orientation: landscape) and (max-height: 480px) {
  #festival-hud { padding-block: 2px 4px; }
  #game[data-mode='festival'] #field { margin-block-start: 34px; }
  #festival-hud strong { font-size: 27px; }
  #festival-hud #festival-clock { font-size: 34px; }
  #pair-fruit img { width: 31px; height: 31px; }
  .festival-result-score strong { font-size: 49px; }
  #sheet[data-kind='festival-result'] { width: min(calc(100% - 28px), 560px); padding-block: 12px; }
  .festival-reward li { flex-basis: 78px; }
  #sheet[data-kind='festival-result'] #sheet-actions { grid-template-columns: 1.35fr 1fr; }
}
