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

@font-face {
  font-family: "Fredoka";
  src: url("assets/fredoka-600.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

:root {
  --cream: #fff8e6;
  --cream-deep: #f4e5c4;
  --wood: #a96b3d;
  --wood-dark: #633b22;
  --navy: #174a7e;
  --ink: #3d3226;
  --gold: #f2c141;
  --gold-deep: #bf8420;
  --coral: #e98978;
  --coral-deep: #ad5449;
  --green: #4f8d55;
  --green-dark: #285b38;
  --ice: #bde7e8;
  --mist: #e8f7f4;
  --paper-shadow: 0 8px 0 rgb(99 59 34 / 24%), 0 20px 40px rgb(23 74 126 / 18%);
  --small-shadow: 0 5px 0 rgb(99 59 34 / 24%), 0 10px 22px rgb(23 74 126 / 14%);
  --focus: 0 0 0 4px #fff8e6, 0 0 0 8px #174a7e;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #194f60;
}

body {
  min-width: 280px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background: transparent;
  font-family: "Fredoka", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.35;
}

button,
summary {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
summary:focus-visible {
  outline: 0;
  box-shadow: var(--focus);
}

button:disabled {
  cursor: not-allowed;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  color: var(--navy);
  font-weight: 600;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2.2rem, 5.2vw, 5.1rem);
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
}

.sr-only {
  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;
}

.app {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
}

.world {
  position: fixed;
  z-index: -2;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.world img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
}

.world-wash {
  position: fixed;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(180deg, rgb(18 74 104 / 10%), rgb(250 242 218 / 8%) 55%, rgb(20 62 80 / 18%)),
    radial-gradient(circle at 50% 44%, rgb(255 248 230 / 0%), rgb(255 248 230 / 22%) 60%, rgb(9 48 68 / 24%));
}

.screen {
  width: 100%;
}

.opening {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100svh;
  padding: 0;
  isolation: isolate;
}

.opening-art {
  position: absolute;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  background: #194f60;
}

.opening-art::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    linear-gradient(180deg, rgb(255 248 230 / 10%) 40%, rgb(19 74 100 / 38%) 100%),
    linear-gradient(90deg, rgb(19 74 100 / 20%), transparent 45%);
}

.opening-story {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.opening-story img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.title-frame {
  align-self: start;
  justify-self: end;
  width: min(430px, 46vw);
  margin: clamp(10px, 2vw, 22px);
  padding: 10px 18px;
  text-align: center;
  background:
    linear-gradient(180deg, rgb(255 253 244 / 94%), rgb(246 231 201 / 94%));
  border: 2px solid rgb(99 59 34 / 28%);
  border-radius: 18px;
  box-shadow: 0 6px 18px rgb(14 47 67 / 22%);
  backdrop-filter: blur(5px);
}

.modal-kicker,
.target-kicker {
  margin-bottom: 5px;
  color: #7a4d2b;
  font-size: 0.75em;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.title-frame h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3.2vw, 2.6rem);
}

.opening-actions {
  align-self: end;
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: 7px;
  margin-bottom: clamp(12px, 4vh, 32px);
  padding: 0;
  text-align: center;
}

.image-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.opening-play {
  display: grid;
  grid-template-columns: 72px auto;
  min-width: 220px;
  min-height: 68px;
  padding: 2px 26px 4px 4px;
  color: var(--ink);
  background: linear-gradient(180deg, #ffe18b, #d89a32);
  border: 4px solid var(--cream);
  border-radius: 999px;
  box-shadow: 0 8px 0 #7f4b22, 0 14px 28px rgb(11 49 68 / 32%);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.opening-play img {
  width: 62px;
  height: 62px;
}

.opening-play span {
  padding-left: 8px;
  font-size: 1.4rem;
  font-weight: 600;
}

.opening-caption {
  max-width: min(440px, 88vw);
  padding: 5px 14px;
  margin: 0;
  color: #fff;
  background: rgb(23 74 126 / 78%);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgb(14 47 67 / 20%);
  font-size: 0.86rem;
  font-weight: 600;
  text-shadow: 0 1px 2px rgb(14 47 67 / 50%);
}

.opening-play:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #7f4b22, 0 8px 18px rgb(11 49 68 / 28%);
}

.game {
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr);
  gap: 4px;
  height: 100vh;
  height: 100svh;
  padding: 4px clamp(8px, 1.4vw, 20px) 6px;
  overflow: hidden;
}

.world-wash {
  background:
    linear-gradient(180deg, rgb(19 74 100 / 2%) 0 30%, transparent 58%),
    radial-gradient(ellipse at 50% 62%, rgb(255 249 226 / 8%), transparent 56%);
}

.hud {
  position: relative;
  z-index: 8;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 1440px);
  min-height: 56px;
  min-width: 0;
  margin: 0 auto;
}

.control-row {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 4px;
  order: 2;
}

.control {
  flex: 0 0 56px;
  width: 56px;
  min-width: 56px;
  height: 56px;
  min-height: 56px;
  filter: drop-shadow(0 4px 4px rgb(51 38 25 / 28%));
  transition: transform 150ms ease, filter 150ms ease;
}

.control img {
  width: 56px;
  height: 56px;
}

.control:hover {
  transform: translateY(-2px);
  filter: drop-shadow(0 6px 6px rgb(51 38 25 / 34%));
}

.control:active {
  transform: translateY(2px) scale(0.96);
}

.control[aria-pressed="true"] {
  opacity: 0.82;
}

.control:disabled {
  opacity: 0.46;
  transform: none;
}

.progress-panel {
  display: flex;
  flex: 1 1 auto;
  gap: 7px;
  align-items: center;
  width: auto;
  min-width: 0;
  max-width: 100%;
  height: 56px;
  padding: 2px 4px;
  order: 1;
  background: none;
  border: 0;
  box-shadow: none;
}

.level-track {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
  align-items: center;
}

.level-prop {
  display: grid;
  width: 28px;
  height: 28px;
  color: #69828a;
  background: #e7eee9;
  border: 1px solid #bdcbc7;
  border-radius: 50%;
  box-shadow: inset 0 -2px 2px rgb(41 63 58 / 9%);
  place-items: center;
  transition: transform 180ms ease, background 180ms ease;
}

.level-prop svg {
  width: 21px;
  height: 21px;
  overflow: visible;
}

.level-prop.done {
  color: var(--navy);
  background: #ffe497;
  border-color: var(--gold-deep);
}

.level-prop.active {
  background: #fff8e7;
  border-color: #8f5a2f;
  transform: translateY(-2px) scale(1.1);
}

.round-copy {
  display: grid;
  grid-template-columns: minmax(54px, 1fr) auto;
  gap: 5px;
  align-items: center;
  min-width: 0;
}

.round-copy > p {
  overflow: hidden;
  margin: 0;
  color: var(--navy);
  font-size: 0.82rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.round-track {
  display: flex;
  gap: 0;
}

.star {
  width: 18px;
  height: 18px;
  background: url("assets/ui/ui-reward-star-empty.webp") center / contain no-repeat;
  filter: drop-shadow(0 1px 0 rgb(255 255 255 / 75%));
}

.star.gold {
  background-image: url("assets/ui/ui-reward-star.webp");
  animation: star-in 360ms cubic-bezier(.16, 1, .3, 1);
}

@keyframes star-in {
  from { transform: scale(0.45) rotate(-24deg); }
  to { transform: scale(1) rotate(0); }
}

.stage {
  position: relative;
  display: grid;
  grid-template-rows: 246px minmax(0, 1fr);
  gap: 0;
  width: min(100%, 1180px);
  min-height: 0;
  margin: 0 auto;
}

.scene-head {
  position: relative;
  width: min(100%, 760px);
  min-height: 0;
  margin: 0 auto;
  isolation: isolate;
}

.scene-head::after {
  position: absolute;
  z-index: -1;
  inset: 16px 0 0;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(ellipse at 30% 88%, rgb(255 244 203 / 22%), transparent 34%),
    linear-gradient(180deg, transparent 60%, rgb(20 70 89 / 14%));
  border-radius: 28px 34px 18px 24px;
}

.guide-card {
  position: absolute;
  bottom: 0;
  left: clamp(6px, 1.4vw, 24px);
  z-index: 3;
  width: clamp(160px, 42vw, 288px);
  height: 230px;
  pointer-events: none;
}

.guide-art-wrap {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: end center;
}

.guide-art {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 12px 12px rgb(22 59 73 / 24%));
}

.guide-speech {
  position: absolute;
  right: auto;
  bottom: 10px;
  left: calc(100% + 6px);
  width: 230px;
  padding: 6px 10px;
  margin: 0;
  color: var(--navy);
  background: rgb(255 249 229 / 91%);
  border: 1px solid rgb(114 73 42 / 35%);
  border-radius: 5px 10px 5px 9px;
  box-shadow: 0 3px 0 rgb(99 59 34 / 17%), 0 6px 12px rgb(21 65 83 / 14%);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.16;
  text-wrap: balance;
  transform: rotate(-1deg);
}

.target-seal {
  position: absolute;
  top: 40px;
  right: clamp(10px, 2vw, 24px);
  left: auto;
  display: grid;
  width: clamp(200px, 31vw, 220px);
  aspect-ratio: 523 / 320;
  padding: clamp(6px, 1vh, 12px) 18px;
  color: var(--navy);
  background: url("assets/number-plaque.webp") center / contain no-repeat;
  filter: drop-shadow(0 9px 8px rgb(48 32 20 / 24%));
  place-items: center;
}

.target-copy {
  display: grid;
  align-self: center;
  justify-items: center;
  line-height: 1;
}

.target-copy p {
  margin: 0;
}

.target-kicker {
  color: #6c4826;
  font-size: clamp(0.72rem, 0.9vw, 0.82rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.goal-number {
  min-width: 1.15em;
  font-size: clamp(3.75rem, 6vw, 4.75rem);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 0.84;
  letter-spacing: -0.075em;
  text-align: center;
  text-shadow: 0 1px 0 rgb(255 250 223 / 80%);
}

.target-note,
.goal-dots {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.listen-button {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  filter: drop-shadow(0 3px 3px rgb(53 35 20 / 26%));
}

.listen-button img {
  width: 36px;
  height: 36px;
  margin: auto;
}

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

.play-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 0;
  width: min(100%, 920px);
  padding-top: 30px;
  margin: 0 auto;
}

.serving-panel,
.combined-panel,
.choice-panel {
  min-width: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.serving-panel {
  display: grid;
  justify-items: center;
  width: 100%;
}

.serving-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: min(100%, 638px);
}

.tray-slot {
  position: relative;
  display: block;
  aspect-ratio: 900 / 400;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: default;
  transition: transform 160ms ease, filter 160ms ease;
}

.tray-slot.filled {
  cursor: pointer;
}

.tray-slot:disabled {
  cursor: default;
}

.tray-slot.filled:hover {
  transform: translateY(-2px);
  filter: drop-shadow(0 0 7px rgb(255 221 122 / 82%));
}

.tray-slot.filled:active {
  transform: translateY(1px) scale(0.99);
}

.tray-slot.drop-ready {
  transform: translateY(-4px) scale(1.025);
  filter:
    drop-shadow(0 0 4px #fff8df)
    drop-shadow(0 0 12px rgb(255 213 92 / 96%));
}

.slot-frame,
.tray-ten-frame,
.combined-frame {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 900 / 400;
  background: url("assets/tray-deluxe.webp") center / contain no-repeat;
}

.slot-frame i,
.tray-ten-frame i,
.combined-frame i {
  position: absolute;
  top: 16%;
  width: 16.8%;
  height: 34%;
  background: transparent no-repeat center;
  background-size: 86% 86%;
}

.slot-frame i:nth-child(5n+1),
.tray-ten-frame i:nth-child(5n+1),
.combined-frame i:nth-child(5n+1) {
  left: 8%;
}

.slot-frame i:nth-child(5n+2),
.tray-ten-frame i:nth-child(5n+2),
.combined-frame i:nth-child(5n+2) {
  left: 24.8%;
}

.slot-frame i:nth-child(5n+3),
.tray-ten-frame i:nth-child(5n+3),
.combined-frame i:nth-child(5n+3) {
  left: 41.6%;
}

.slot-frame i:nth-child(5n+4),
.tray-ten-frame i:nth-child(5n+4),
.combined-frame i:nth-child(5n+4) {
  left: 58.4%;
}

.slot-frame i:nth-child(5n+5),
.tray-ten-frame i:nth-child(5n+5),
.combined-frame i:nth-child(5n+5) {
  left: 75.2%;
}

.slot-frame i:nth-child(n+6),
.tray-ten-frame i:nth-child(n+6),
.combined-frame i:nth-child(n+6) {
  top: 51%;
}

.slot-frame i.gold,
.slot-frame i.coral,
.tray-ten-frame i.biscuit,
.combined-frame i.gold,
.combined-frame i.coral {
  background-image: url("assets/biscuit-deluxe.webp");
  filter: drop-shadow(0 1px 1px rgb(74 43 18 / 23%));
}

.quick-actions {
  display: flex;
  flex: 0 0 auto;
  gap: clamp(12px, 1.6vw, 18px);
  align-items: center;
  justify-content: center;
  width: min(100%, 700px);
  margin-top: 20px;
}

.combined-panel {
  display: flex;
  gap: clamp(5px, 0.8vw, 9px);
  align-items: center;
  justify-content: center;
}

.combined-frames {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.combined-frame {
  min-width: 0;
}

.combined-count {
  min-width: 154px;
  padding: 6px 12px;
  margin: 0;
  color: var(--navy);
  background: rgb(255 248 227 / 88%);
  border: 1px solid rgb(98 60 35 / 35%);
  border-radius: 3px 8px 4px 7px;
  box-shadow: 0 2px 0 rgb(99 59 34 / 18%);
  font-size: clamp(1.5rem, 2.2vw, 1.75rem);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.ok-wrap {
  flex: 0 0 auto;
}

.ok-button {
  display: grid;
  width: clamp(72px, 7vw, 80px);
  min-width: clamp(72px, 7vw, 80px);
  min-height: 0;
  aspect-ratio: 1;
  background: transparent;
  border: 0;
  border-radius: 50%;
  filter: drop-shadow(0 5px 5px rgb(38 59 37 / 28%));
  transition: transform 140ms ease, filter 140ms ease;
}

.ok-button img {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  margin: auto;
}

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

.ok-button:not(:disabled):hover {
  filter: brightness(1.04) drop-shadow(0 7px 7px rgb(38 59 37 / 32%));
  transform: translateY(-2px);
}

.ok-button:not(:disabled):active {
  transform: translateY(3px) scale(0.97);
  filter: brightness(0.98) drop-shadow(0 3px 4px rgb(38 59 37 / 28%));
}

.ok-button:disabled {
  filter: saturate(0.42) opacity(0.78) drop-shadow(0 3px 3px rgb(60 65 52 / 22%));
}

.feedback {
  position: absolute;
  z-index: 7;
  bottom: 8px;
  left: 50%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  justify-content: center;
  width: min(100%, 700px);
  min-height: 0;
  padding: 5px 11px;
  margin: 0;
  color: #5e402a;
  background: rgb(255 247 222 / 95%);
  border: 1px solid rgb(116 76 44 / 42%);
  border-radius: 5px 11px 5px 9px;
  box-shadow: 0 3px 0 rgb(99 59 34 / 18%), 0 7px 12px rgb(33 60 68 / 12%);
  transform: translateX(-50%);
}

.feedback:empty {
  display: none;
}

.feedback.compare {
  background: rgb(255 241 194 / 96%);
}

.feedback.success {
  background: rgb(255 250 216 / 97%);
}

.feedback p {
  flex: 1 1 250px;
  min-width: 0;
  margin: 0;
  font-size: clamp(0.94rem, 1.2vw, 0.98rem);
  font-weight: 600;
  text-align: center;
}

.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 9px 18px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.primary-button {
  color: var(--ink);
  background: linear-gradient(180deg, #ffe18b, #d89a32);
  border: 3px solid #fff8e6;
  box-shadow: 0 5px 0 #7f4b22, 0 8px 16px rgb(99 59 34 / 20%);
}

.secondary-button {
  color: var(--navy);
  background: var(--cream);
  border: 2px solid #b58b55;
  box-shadow: 0 3px 0 #c4a170;
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(3px);
  box-shadow: none;
}

.secondary-button.small {
  min-height: 42px;
  padding: 6px 13px;
  font-size: 0.9rem;
}

.feedback .primary-button,
.feedback .secondary-button {
  min-height: 34px;
  padding: 4px 11px;
  border-radius: 5px 9px 5px 8px;
  font-size: 0.78rem;
}

.choice-panel {
  flex: 0 0 auto;
  width: 100%;
  margin-top: 40px;
}

.tray-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  justify-self: center;
  width: min(100%, 620px);
}

.tray-grid:has(.tray-card:nth-child(4)) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tray-card {
  position: relative;
  display: block;
  aspect-ratio: 900 / 400;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: grab;
  touch-action: none;
  transition: transform 140ms ease, filter 140ms ease, opacity 140ms ease;
  -webkit-tap-highlight-color: transparent;
}

.tray-card:hover {
  z-index: 2;
  filter: drop-shadow(0 0 5px rgb(255 237 171 / 72%));
  transform: translateY(-2px);
}

.tray-card.selected {
  z-index: 3;
  filter:
    drop-shadow(0 0 4px #fff8dc)
    drop-shadow(0 0 10px rgb(255 202 67 / 92%));
  transform: translateY(-4px) scale(1.025);
}

.tray-card.dragging {
  opacity: 0.3;
  cursor: grabbing;
}

.tray-card:disabled {
  cursor: default;
}

.tray-letter,
.tray-count,
.tray-count small {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.drag-ghost {
  position: fixed;
  z-index: 60;
  width: clamp(150px, 18vw, 210px);
  pointer-events: none;
  opacity: 0.9;
  filter: drop-shadow(0 10px 12px rgb(36 50 42 / 28%));
  transform: translate(-50%, -50%) rotate(2deg) scale(0.96);
}

.drag-ghost .tray-card {
  width: 100%;
}

.drag-ghost.demo-tray-moving {
  z-index: 19;
  width: clamp(170px, 19vw, 230px);
  opacity: 0.97;
  transition: left 600ms cubic-bezier(.36, .08, .2, 1), top 600ms cubic-bezier(.36, .08, .2, 1);
}

.demo-layer {
  position: fixed;
  z-index: 20;
  inset: 0;
  pointer-events: none;
}

.tutorial-hand {
  position: fixed;
  z-index: 2;
  top: 0;
  left: 0;
  width: 92px;
  height: 92px;
  transform: translate(var(--hand-x, -200px), var(--hand-y, -200px)) scale(var(--hand-scale, 1));
  transform-origin: 12% 12%;
  transition: transform 520ms cubic-bezier(.36, .08, .2, 1);
  filter: drop-shadow(0 8px 10px rgb(23 74 126 / 22%));
}

.tutorial-hand img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: rotate(-10deg);
}

.tutorial-hand.tap {
  animation: hand-tap 520ms ease-in-out infinite alternate;
}

@keyframes hand-tap {
  to { transform: translate(var(--hand-x), var(--hand-y)) scale(calc(var(--hand-scale, 1) * 0.92)); }
}

.demo-text {
  position: fixed;
  top: clamp(146px, 22vh, 208px);
  left: clamp(24px, 22vw, 300px);
  max-width: min(330px, 54vw);
  padding: 7px 12px;
  margin: 0;
  color: var(--navy);
  background: rgb(255 249 228 / 96%);
  border: 1px solid rgb(104 65 37 / 40%);
  border-radius: 5px 11px 5px 9px;
  box-shadow: 0 3px 0 rgb(99 59 34 / 18%), 0 7px 14px rgb(22 59 73 / 18%);
  font-size: clamp(0.82rem, 1.2vw, 1rem);
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
}

.demo-skip {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  min-width: 122px;
  min-height: 44px;
  padding: 6px 13px;
  color: var(--navy);
  background: rgb(255 248 230 / 94%);
  border: 2px solid rgb(255 255 255 / 88%);
  border-radius: 5px 11px 5px 9px;
  box-shadow: 0 4px 0 rgb(99 59 34 / 25%);
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
}

.fx-layer {
  position: fixed;
  z-index: 45;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  position: absolute;
  width: 12px;
  height: 18px;
  background: var(--gold);
  border-radius: 50% 20% 50% 20%;
  animation: confetti 900ms ease-out forwards;
}

@keyframes confetti {
  from { transform: translateY(-20px) rotate(0); opacity: 1; }
  to { transform: translateY(170px) rotate(320deg); opacity: 0; }
}

.modal-layer {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  overflow-y: auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  background: rgb(12 54 74 / 60%);
  backdrop-filter: blur(7px);
  place-items: center;
}

.modal-card {
  position: relative;
  width: min(610px, 100%);
  padding: clamp(22px, 4vw, 38px);
  color: var(--ink);
  background:
    linear-gradient(rgb(255 249 232 / 95%), rgb(245 229 194 / 95%)),
    url("assets/picnic-landscape-v3.webp") center / cover;
  border: 2px solid #754726;
  border-radius: 8px 22px 10px 18px;
  box-shadow:
    inset 0 0 0 7px rgb(226 186 112 / 72%),
    0 8px 0 rgb(99 59 34 / 30%),
    0 24px 58px rgb(9 43 61 / 38%);
}

.modal-card > p {
  color: #624d3b;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 48px;
  height: 48px;
  padding: 0 0 4px;
  color: var(--navy);
  background: #f7e4b8;
  border: 2px solid #915b31;
  border-radius: 5px 12px 6px 10px;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.modal-card > .primary-button,
.modal-card > .secondary-button {
  width: 100%;
  margin-top: 10px;
}

.pause-card {
  width: min(560px, 100%);
}

.level-picker {
  min-width: 0;
  padding: 13px;
  margin: 18px 0 0;
  border: 2px solid #c8a474;
  border-radius: 18px;
}

.level-picker legend {
  padding: 0 7px;
  color: var(--navy);
  font-weight: 600;
}

.level-picker-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
}

.level-choice {
  min-height: 54px;
  padding: 5px 3px;
  color: var(--navy);
  background: #fffaf0;
  border: 2px solid #b58b55;
  border-radius: 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.level-choice b {
  display: block;
  font-size: 1.25rem;
}

.level-choice.current {
  color: #fff;
  background: var(--navy);
}

.help-card {
  width: min(760px, 100%);
  align-self: start;
}

.help-transcript {
  margin: 14px 0 0;
  color: #624d3b;
}

.picture-steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0;
  margin: 18px 0;
  list-style: none;
}

.picture-steps li {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 92px;
  padding: 9px;
  background: rgb(255 253 246 / 84%);
  border: 1px solid #b98550;
  border-radius: 5px 12px 6px 10px;
}

.step-picture {
  display: flex;
  gap: 3px;
  align-items: center;
  justify-content: center;
  width: 66px;
  height: 66px;
  background: #dff4f1;
  border-radius: 15px;
}

.choose-picture i {
  width: 23px;
  height: 35px;
  background: var(--cream);
  border: 2px solid #b9874f;
  border-radius: 6px;
  box-shadow: inset 0 7px 0 #f7d57b;
}

.target-picture i {
  display: grid;
  width: 48px;
  height: 48px;
  color: var(--navy);
  background: var(--gold);
  border: 3px solid #fff;
  border-radius: 50%;
  font-size: 1.5rem;
  font-style: normal;
  font-weight: 600;
  box-shadow: 0 4px 0 var(--gold-deep);
  place-items: center;
}

.compare-picture i {
  width: 16px;
  height: 16px;
  background: var(--gold);
  border-radius: 50%;
}

.compare-picture i:nth-child(2) {
  background: var(--coral);
}

.ok-picture i {
  display: grid;
  width: 51px;
  height: 51px;
  color: #fff;
  background: var(--green);
  border: 3px solid #fff;
  border-radius: 14px;
  font-size: 1rem;
  font-style: normal;
  font-weight: 600;
  box-shadow: 0 4px 0 var(--green-dark);
  place-items: center;
}

.parent-note {
  margin: 12px 0;
  padding: 11px 13px;
  background: #edf8f5;
  border: 2px solid #b6d9d4;
  border-radius: 15px;
}

.parent-note summary {
  color: var(--navy);
  font-weight: 600;
  cursor: pointer;
}

.parent-note p {
  margin: 8px 0 0;
}

.narration-box {
  padding: 12px;
  margin: 12px 0 2px;
  background: #fff9e9;
  border: 2px solid #dbc28f;
  border-radius: 15px;
}

.narration-title {
  margin-bottom: 6px;
  color: var(--navy);
  font-weight: 600;
}

.narration-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.audio-status {
  margin: 7px 0 0;
  color: #705a45;
  font-size: 0.85rem;
}

.finale-layer {
  background:
    radial-gradient(circle at 50% 42%, rgb(255 238 167 / 42%), transparent 38%),
    rgb(12 54 74 / 68%);
}

.finale-card {
  max-width: 510px;
  text-align: center;
}

.finale-card h2 {
  font-size: clamp(2.6rem, 8vw, 4.4rem);
}

.finale-sopo {
  width: min(300px, 78vw);
  max-height: 250px;
  margin: 4px auto 8px;
  object-fit: contain;
}

.finale-stars {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  justify-content: center;
  margin-bottom: 8px;
}

.finale-stars .star {
  width: 24px;
  height: 24px;
}

.finale-audio-actions {
  justify-content: center;
  margin: 4px 0 10px;
}

.corner-rune {
  position: fixed;
  z-index: 80;
  bottom: max(4px, env(safe-area-inset-bottom));
  left: max(3px, env(safe-area-inset-left));
  width: 43px;
  height: 64px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 3px 4px rgb(14 47 67 / 25%));
}

@media (max-width: 900px) {
  .game {
    padding: 3px 8px 6px;
  }

  .hud {
    gap: 4px;
    width: 100%;
  }

  .control-row {
    gap: 4px;
  }

  .control,
  .control img {
    width: 56px;
    height: 56px;
  }

  .progress-panel {
    width: auto;
    height: 56px;
    padding: 2px 4px;
  }

  .level-track {
    gap: 1px;
  }

  .level-prop {
    width: 24px;
    height: 24px;
  }

  .level-prop svg {
    width: 18px;
    height: 18px;
  }

  .round-copy {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
  }

  .round-copy > p {
    font-size: 0.8rem;
  }

  .star {
    width: 16px;
    height: 16px;
  }

  .stage {
    grid-template-rows: 246px minmax(0, 1fr);
  }

  .target-seal {
    top: 40px;
  }

  .goal-number {
    font-size: 3.75rem;
  }

  .listen-button img {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
  }

  .play-area {
    width: min(100%, 620px);
  }

  .serving-grid {
    width: min(100%, 638px);
  }

  .tray-grid {
    width: min(100%, 590px);
  }

  .tray-grid:has(.tray-card:nth-child(3):last-child) .tray-card:last-child {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc((100% - 12px) / 2);
  }

  .quick-actions,
  .feedback {
    width: 100%;
  }

  .picture-steps {
    grid-template-columns: 1fr;
  }

  .corner-rune {
    width: 20px;
    height: 30px;
    left: env(safe-area-inset-left, 0px);
  }
}

@media (orientation: portrait) {
  .title-frame {
    justify-self: center;
    width: min(430px, 90vw);
  }

  .opening-actions {
    width: min(92vw, 420px);
  }
}

@media (max-width: 559px) {
  .choice-panel,
  .choice-panel .tray-grid {
    width: 100%;
  }

  .choice-panel .tray-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .choice-panel .tray-grid:has(.tray-card:nth-child(4)) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  .tray-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc((100% - 5px) / 2);
  }
}

@media (max-width: 430px) {
  body {
    font-size: 16px;
  }

  .title-frame {
    width: min(350px, 92vw);
    margin: 10px auto 0;
    padding: 10px 12px;
  }

  .title-frame h1 {
    font-size: clamp(1.65rem, 8.5vw, 2.35rem);
  }

  .opening-actions {
    width: auto;
    padding: 0;
  }

  .game {
    padding: 2px 4px 4px;
  }

  .hud {
    gap: 4px;
  }

  .control-row {
    gap: 0;
  }

  .control {
    flex-basis: 56px;
  }

  .progress-panel {
    flex: 1 1 auto;
    gap: 3px;
    min-width: 0;
    padding-inline: 2px;
    overflow: hidden;
  }

  .level-track {
    flex: 0 0 auto;
  }

  .level-prop:not(.active) {
    display: none;
  }

  .level-prop {
    width: 24px;
    height: 24px;
  }

  .level-prop svg {
    width: 16px;
    height: 16px;
  }

  .round-copy {
    min-width: 0;
  }

  .round-copy > p {
    display: none;
  }

  .star {
    width: 12px;
    height: 12px;
  }

  .stage {
    grid-template-rows: 198px minmax(0, 1fr);
  }

  .guide-card {
    display: block;
    left: 4px;
    bottom: 44px;
    width: 164px;
    height: 150px;
  }

  .guide-art-wrap {
    position: relative;
    width: 100%;
    height: 100%;
  }

  .guide-speech {
    position: absolute;
    top: 100%;
    right: auto;
    bottom: auto;
    left: 0;
    width: 195px;
    max-width: none;
    padding: 4px 8px;
    margin: 0;
    font-size: 1.125rem;
    line-height: 1.12;
    transform: rotate(-1deg);
  }

  .target-seal {
    top: 30px;
    right: 8px;
    left: auto;
    width: 140px;
  }

  .target-kicker {
    font-size: 0.7rem;
  }

  .goal-number {
    font-size: 3rem;
  }

  .play-area {
    width: 100%;
    padding-top: 12px;
  }

  .serving-grid {
    gap: 5px;
    width: 100%;
  }

  .quick-actions {
    width: 100%;
    gap: 5px;
    margin-top: 10px;
  }

  .combined-count {
    min-width: 130px;
    padding: 5px 7px;
    font-size: 1.5rem;
  }

  .ok-button,
  .ok-button img {
    width: 72px;
    min-width: 72px;
  }

  .choice-panel {
    margin-top: auto;
    margin-bottom: 50px;
  }

  .choice-panel .tray-grid {
    gap: 4px;
  }

  .tray-card:last-child:nth-child(odd) {
    width: calc((100% - 4px) / 2);
  }

  .feedback {
    bottom: 4px;
    gap: 3px 5px;
    padding: 4px 6px;
  }

  .feedback p {
    flex-basis: 110px;
    font-size: 0.94rem;
  }

  .feedback .primary-button,
  .feedback .secondary-button {
    min-height: 30px;
    padding: 3px 7px;
    font-size: 0.875rem;
  }

  .demo-text {
    top: 214px;
    right: 10px;
    left: 86px;
    max-width: none;
    padding: 5px 9px;
    font-size: 0.72rem;
    transform: none;
  }

  .demo-skip {
    min-width: 104px;
    min-height: 40px;
    padding: 4px 9px;
    font-size: 0.77rem;
  }

  .level-picker-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .modal-card {
    padding: 22px 16px;
    border-radius: 23px;
  }

  .picture-steps li {
    grid-template-columns: 58px 1fr;
    gap: 7px;
  }

  .step-picture {
    width: 55px;
    height: 55px;
  }
}

@media (max-width: 370px) {
  .round-copy {
    display: none;
  }
}

@media (min-width: 901px) {
  .stage {
    grid-template-rows: 196px minmax(0, 1fr);
  }

  .guide-card {
    width: 220px;
    height: 190px;
  }

  .guide-speech {
    width: 230px;
    font-size: 1.25rem;
  }

  .target-seal {
    width: 200px;
  }

  .goal-number {
    font-size: 4.5rem;
  }

  .play-area {
    padding-top: 8px;
  }

  .serving-grid {
    gap: 16px;
    width: min(100%, 656px);
  }

  .quick-actions {
    margin-top: 12px;
  }

  .choice-panel {
    margin-top: 20px;
  }

  .tray-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: min(100%, 900px);
  }

  .tray-grid:has(.tray-card:nth-child(4)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (orientation: landscape) and (max-height: 800px) and (min-width: 901px) {
  .stage {
    grid-template-rows: 180px minmax(0, 1fr);
  }

  .guide-card {
    width: 220px;
    height: 174px;
  }

  .target-seal {
    right: 14px;
    left: auto;
    width: 190px;
  }

  .goal-number {
    font-size: 4rem;
  }

  .serving-grid {
    gap: 10px;
    width: min(100%, 600px);
  }

  .play-area {
    width: min(100%, 620px);
    padding-top: 6px;
  }

  .tray-grid {
    width: min(100%, 840px);
  }

  .quick-actions {
    margin-top: 8px;
  }

  .choice-panel {
    margin-top: 12px;
  }

  .ok-button,
  .ok-button img {
    width: 72px;
    min-width: 72px;
  }

  .demo-text {
    top: 128px;
  }
}

@media (orientation: landscape) and (max-height: 720px) {
  .game {
    grid-template-rows: 56px minmax(0, 1fr);
    height: auto;
    min-height: 100svh;
    padding: 3px 6px 6px;
    overflow: visible;
  }

  .hud {
    display: flex;
    gap: 8px;
    width: 100%;
    min-height: 56px;
  }

  .control-row {
    gap: 4px;
  }

  .progress-panel {
    flex: 1 1 auto;
    width: auto;
    max-width: 100%;
    height: 56px;
  }

  .round-copy > p {
    display: block;
  }

  .stage {
    grid-template-rows: 174px minmax(0, auto);
  }

  .guide-card {
    left: 10px;
    width: 190px;
    height: 160px;
  }

  .guide-speech {
    right: auto;
    bottom: 16px;
    left: calc(100% + 6px);
    top: auto;
    width: 230px;
    font-size: 1.25rem;
  }

  .target-seal {
    top: 8px;
    right: 12px;
    left: auto;
    width: 160px;
  }

  .goal-number {
    font-size: 3rem;
  }

  .play-area {
    width: min(100%, 760px);
    padding-top: 8px;
  }

  .serving-grid {
    width: min(100%, 620px);
  }

  .tray-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 620px);
  }

  .tray-grid:has(.tray-card:nth-child(4)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(100%, 620px);
  }

  .choice-panel {
    margin-top: 12px;
  }

  .demo-text {
    top: 66px;
    left: clamp(180px, 28vw, 280px);
  }
}

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

  .tutorial-hand {
    transition: none;
  }
}
