.app-shell {
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 255, 255, 0.9) 0 5%, transparent 5.2%),
    linear-gradient(155deg, #fff9ec, #ffecdb 58%, #f9e1db);
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(8px, env(safe-area-inset-top)) var(--page-gutter) 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.88);
  backdrop-filter: blur(14px);
}

.game-layout {
  width: min(1120px, 100%);
  min-height: 0;
  margin: 0 auto;
  padding: 14px var(--page-gutter) max(14px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto minmax(300px, 1fr) auto;
  gap: 12px;
}

.mission-card,
.order-tray {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.playfield-frame {
  min-height: 0;
  padding: 7px;
  border: 1px solid rgba(92, 55, 39, 0.12);
  border-radius: calc(var(--radius-large) + 7px);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
}

.playfield {
  position: relative;
  height: 100%;
  min-height: 300px;
  overflow: hidden;
  border-radius: var(--radius-large);
  background:
    linear-gradient(rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.12)),
    linear-gradient(160deg, var(--mint), var(--sky));
  isolation: isolate;
}

.choice-controls {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.playfield > canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100% !important;
  height: 100% !important;
  border-radius: inherit;
  touch-action: none;
}

.playfield::before {
  content: "";
  position: absolute;
  inset: auto -8% -22% -8%;
  height: 55%;
  z-index: -1;
  border-radius: 50% 50% 0 0;
  background: rgba(255, 255, 255, 0.42);
}

.playfield::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: url("../../assets/v2/candy/cakeCenter_rounded.png") repeat;
  background-size: 70px 70px;
  opacity: 0.075;
  pointer-events: none;
}

.game-choice { position: absolute; z-index: 1; }
.choice-one { left: 14%; top: 44%; }
.choice-two { right: 16%; top: 24%; }
.choice-three { right: 23%; bottom: 12%; }
.helper-preview { left: 43%; bottom: 5%; z-index: 1; }

.celebration {
  position: fixed;
  top: max(78px, calc(env(safe-area-inset-top) + 70px));
  left: 50%;
  z-index: 20;
  translate: -50% 0;
  max-width: calc(100vw - 24px);
  pointer-events: none;
}

@media (min-width: 800px) {
  .topbar { min-height: 72px; }
  .game-layout {
    padding-top: 18px;
    grid-template-columns: minmax(0, 1fr) clamp(220px, 24vw, 260px);
    grid-template-rows: auto minmax(380px, 1fr);
    gap: 16px;
  }
  .mission-card { grid-column: 1 / -1; }
  .playfield-frame { grid-column: 1; grid-row: 2; }
  .order-tray {
    grid-column: 2;
    grid-row: 2;
    align-self: stretch;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
  }
}

@media (max-width: 390px) {
  .game-layout {
    min-height: calc(100svh - 60px - max(0px, calc(env(safe-area-inset-top) - 5px)));
    grid-template-rows: auto minmax(270px, 1fr) auto;
    padding-top: 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    gap: 8px;
  }
  .topbar {
    min-height: calc(60px + max(0px, calc(env(safe-area-inset-top) - 5px)));
    padding-top: max(5px, env(safe-area-inset-top));
    padding-bottom: 5px;
  }
  .brand img { display: none; }
  .brand > span:first-of-type { max-width: 102px; font-size: 0.86rem; line-height: 1.05; }
  .playfield { min-height: 280px; }
  .playfield-copy small { display: none; }
  .choice-one { left: 7%; }
  .choice-two { right: 8%; top: 27%; }
  .choice-three { right: 10%; bottom: 8%; }
  .helper-preview { left: 38%; }
}

@media (min-width: 391px) and (max-width: 520px) {
  .playfield { min-height: 296px; }
}

@media (max-height: 650px) and (orientation: landscape) {
  .app-shell { min-height: 100svh; }
  .topbar { min-height: 48px; padding-top: 3px; padding-bottom: 3px; }
  .brand img { width: 34px; height: 34px; }
  .game-layout {
    height: calc(100svh - 55px);
    min-height: 0;
    padding-top: 6px;
    padding-bottom: 6px;
    grid-template-columns: minmax(0, 1fr) 210px;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
  }
  .mission-card { grid-column: 2; grid-row: 1; padding: 8px 10px; }
  .mission-card .eyebrow { display: none; }
  .mission-card {
    align-items: stretch;
    flex-direction: column;
    gap: 4px;
  }
  .mission-copy h1 {
    font-size: clamp(1rem, 2.7vw, 1.2rem);
    overflow-wrap: normal;
  }
  .shift-progress { margin-top: 3px; }
  .shift-progress-dots { display: none; }
  .mission-instruction { font-size: 0.76rem; }
  .playfield-frame { grid-column: 1; grid-row: 1 / 3; }
  .playfield { min-height: 0; height: 100%; }
  .order-tray {
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
    padding: 8px 10px;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
  }
  .order-tray h2 { display: none; }
  .tray-slots, .stars { justify-content: center; }
}
