/* Reset & Global */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--color-ground);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  width: 100%;
}

::selection {
  background-color: color-mix(in oklch, var(--color-banana) 35%, transparent);
  color: var(--color-ink);
}

:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

/* Main Layout: Centered vertically and horizontally in viewport */
.app-container {
  max-width: 860px;
  width: 100%;
  margin: auto;
  padding: var(--space-4) var(--space-4) var(--space-6);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-3);
  overflow-x: hidden;
  position: relative;
  z-index: 1;
}

/* On shorter viewports or landscape mobile, allow natural scrolling from top */
@media (max-height: 660px) {
  body {
    justify-content: flex-start;
  }
  .app-container {
    margin-top: 0;
    margin-bottom: auto;
    padding-top: var(--space-2);
  }
}

/* Persistent utility buttons bar (Help question mark + Sound toggle) */
/* On mobile: placed at top right in normal flow. */
/* On desktop: aligned horizontally with the "jan's waffle maker" header image. */
.global-utility-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  flex-shrink: 0;
  z-index: 50;
}

@media (min-width: 641px) {
  .global-utility-bar {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    height: clamp(74px, 8.5vw, 100px);
    width: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    z-index: 50;
  }
}

.utility-circle-btn {
  position: relative;
  background-color: var(--color-surface);
  border: none;
  color: var(--color-ink);
  padding: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease-out, color 0.15s ease-out, transform 0.15s ease-out;
  touch-action: manipulation;
  flex-shrink: 0;
}

.utility-circle-btn:hover {
  background-color: color-mix(in oklch, var(--color-surface) 80%, var(--color-ink) 8%);
  transform: translateY(-1px);
}

.utility-circle-btn:active {
  transform: translateY(0);
}

/* Tooltip for persistent top utility buttons (question & volume) */
.utility-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background-color: var(--color-ink);
  color: var(--color-cream);
  font-family: var(--font-body);
  font-size: var(--text-small);
  font-weight: 500;
  line-height: 1;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease-out, transform 0.18s ease-out, visibility 0.18s;
  z-index: 60;
}

.utility-tooltip::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent var(--color-ink) transparent;
}

.utility-circle-btn:hover .utility-tooltip,
.utility-circle-btn:focus-visible .utility-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* For sound toggle button on the right edge, prevent overflow */
.sound-toggle-btn .utility-tooltip {
  left: auto;
  right: 0;
  transform: translateY(-4px);
}

.sound-toggle-btn .utility-tooltip::after {
  left: auto;
  right: 17px;
  transform: none;
}

.sound-toggle-btn:hover .utility-tooltip,
.sound-toggle-btn:focus-visible .utility-tooltip {
  transform: translateY(0);
}

.sound-toggle-btn .sound-icon-off {
  display: none;
}

.sound-toggle-btn.is-muted {
  color: var(--color-subtle);
}

.sound-toggle-btn.is-muted .sound-icon-on {
  display: none;
}

.sound-toggle-btn.is-muted .sound-icon-off {
  display: block;
}

.view-active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-4);
  width: 100%;
}

.view-hidden {
  display: none !important;
}

/* Entrance animations when transitioning into the Waffle Maker page */
.view-build-entering .intro-block {
  animation: buildLoadFadeRise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.view-build-entering .stage-card {
  animation: buildTableFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.08s both;
}

.view-build-entering .bottom-controls {
  animation: buildLoadFadeRise 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

@keyframes buildLoadFadeRise {
  0% {
    opacity: 0;
    transform: translateY(18px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes buildTableFadeIn {
  0% {
    opacity: 0;
    transform: scale(0.97) translateY(14px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Empty table waiting states before plate slides in */
.sage-plate.plate-waiting {
  opacity: 0;
  transform: translateX(-140%);
  pointer-events: none !important;
}

.cutlery.cutlery-waiting {
  opacity: 0;
  transform: translateY(14px);
}

.cutlery.cutlery-enter {
  animation: cutlerySlideIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cutlerySlideIn {
  0% {
    opacity: 0;
    transform: translateY(14px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.stage-action-bar.bar-waiting {
  opacity: 0;
  pointer-events: none;
}

.stage-action-bar.bar-enter {
  animation: barFadeIn 0.35s ease-out forwards;
}

@keyframes barFadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.intro-block {
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--space-1) 0;
  gap: var(--space-2);
  width: 100%;
}

.brand-title {
  margin: 0;
  padding: 0;
  line-height: 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.title-brand-image {
  max-width: min(520px, calc(100% - 150px));
  height: auto;
  display: block;
  object-fit: contain;
}

@media (max-width: 640px) {
  .title-brand-image {
    max-width: min(520px, 92vw);
  }
}

/* --- View 0: Game Start Screen --- */
.start-header-block {
  padding-top: 0;
  gap: var(--space-3);
}

.start-brand-image {
  max-width: min(580px, calc(100% - 150px));
}

@media (max-width: 640px) {
  .start-brand-image {
    max-width: min(580px, 94vw);
  }
}

.start-subtitle {
  margin: var(--space-1) auto 0;
  padding: 0;
  line-height: 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.start-subtitle-image {
  max-width: min(280px, 68vw);
  height: auto;
  display: block;
  object-fit: contain;
}

.start-steps-section {
  width: 100%;
  margin: var(--space-2) auto;
}

.start-steps-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  width: 100%;
}

@media (max-width: 640px) {
  .start-steps-list {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
}

.start-step-item {
  background-color: var(--color-surface);
  border-radius: var(--radius-surface);
  padding: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.start-step-visual {
  width: 104px;
  height: 104px;
  border-radius: var(--radius-surface);
  background-color: var(--color-ink);
  background-image: url("/_versions/1119e5f9-6630-4720-bc19-88ffcee008f3/assets/table-wood-dark.svg");
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.step-visual-cluster {
  position: relative;
  width: 82px;
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-icon-berry {
  position: absolute;
  top: 6px;
  left: 8px;
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.step-icon-banana {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.step-icon-cream {
  position: absolute;
  bottom: 4px;
  left: 6px;
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.step-icon-choc {
  position: absolute;
  bottom: 10px;
  right: 12px;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.step-visual-waffle-wrap {
  position: relative;
  width: 74px;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-icon-waffle {
  width: 70px;
  height: 70px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.step-mini-placed-berry {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.step-visual-syrup-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.step-icon-maple {
  width: 46px;
  height: 58px;
  object-fit: contain;
}

.step-syrup-swirl {
  width: 48px;
  height: 24px;
  margin-top: -6px;
}

.step-visual-serve-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.step-icon-utensil {
  width: 12px;
  height: 58px;
  object-fit: contain;
}

.step-mini-sage-plate {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-full);
  background-color: var(--color-plate-bg);
  border: 4px solid var(--color-plate-rim);
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-mini-plate-waffle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.start-step-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  text-align: left;
}

.start-step-title {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 2.6vw, 1.375rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--color-ink);
  text-wrap: balance;
}

.start-step-desc {
  font-family: var(--font-body);
  font-size: clamp(0.9375rem, 2.4vw, 1.05rem);
  line-height: 1.48;
  color: var(--color-subtle);
  text-wrap: pretty;
}

.start-action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: var(--space-2);
  padding-bottom: var(--space-4);
}

.start-game-btn {
  font-size: clamp(1.1rem, 3.8vw, 1.3rem);
  padding: var(--space-4) var(--space-10);
  min-height: 54px;
  min-width: 240px;
}

/* Instruction text below top header in build view */
.instructions-text {
  font-family: var(--font-body);
  font-size: clamp(0.8125rem, 3.2vw, 1.05rem);
  color: var(--color-ink);
  margin: 0 auto;
  padding: var(--space-1) var(--space-2);
  text-align: center;
  line-height: 1.45;
  letter-spacing: -0.01em;
  max-width: 100%;
  box-sizing: border-box;
  text-wrap: balance;
}

@media (min-width: 769px) {
  .instructions-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-wrap: nowrap;
    display: block;
    width: 100%;
  }
}

/* Served instruction text: "Click the waffle to eat" */
.served-instructions-text {
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 3.5vw, 1.25rem);
  font-weight: 600;
  color: var(--color-ink);
  margin: 0 auto;
  padding: var(--space-1) var(--space-3);
  text-align: center;
  line-height: 1.4;
  letter-spacing: -0.01em;
  max-width: 720px;
  text-wrap: balance;
}

/* Waffle Stage Card with authentic dark brown wood grain surface - made smaller and sleeker */
.stage-card {
  background-color: var(--color-ink);
  border-radius: var(--radius-surface);
  box-shadow: none;
  padding: var(--space-3) var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  width: 100%;
  max-width: min(680px, 100%);
  margin: 0 auto;
  min-height: 360px;
  box-sizing: border-box;
}

/* Wood grain table background layer with dark brown timber surface */
.stage-card::before,
.served-stage::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("/_versions/1119e5f9-6630-4720-bc19-88ffcee008f3/assets/table-wood-dark.svg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: -1;
  pointer-events: none;
}

/* Stage Action Bar (Start Fresh button in upper-right corner) */
.stage-action-bar {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  z-index: 10;
}

.reset-button {
  background-color: var(--color-cream);
  border: none;
  color: var(--color-ink);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-small);
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-full);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  transition: background-color 0.15s ease-out, transform 0.15s ease-out;
  touch-action: manipulation;
}

.reset-button:hover {
  background-color: var(--color-ground);
  transform: translateY(-1px);
}

.reset-button:active {
  transform: translateY(0);
}

.reset-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Table Setting with Utensils & Plate */
.table-setting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2.5vw, 28px);
  width: 100%;
  max-width: 540px;
  margin: var(--space-2) auto;
  position: relative;
}

/* Cutlery: Fork & Knife - proportioned to smaller table and plate */
.cutlery {
  width: clamp(18px, 4.2vw, 44px);
  height: clamp(110px, 22vw, 190px);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  pointer-events: none;
  flex-shrink: 0;
}

.cutlery-fork {
  justify-content: flex-end;
}

.cutlery-knife {
  justify-content: flex-start;
}

.utensil-img {
  max-width: 100%;
  max-height: 100%;
  height: 100%;
  width: auto;
  object-fit: contain;
  display: block;
  filter: contrast(1.15) brightness(1.08);
  pointer-events: none;
}

/* Sage Green Plate container - scaled smaller per request */
.sage-plate {
  position: relative;
  width: min(230px, 48vw);
  height: min(230px, 48vw);
  border-radius: var(--radius-full);
  background-color: var(--color-plate-inner);
  border: clamp(7px, 1.8vw, 12px) solid var(--color-plate-rim);
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform, opacity;
  user-select: none;
  flex-shrink: 0;
}

/* Inner groove detail of ceramic plate */
.sage-plate::before {
  content: "";
  position: absolute;
  inset: clamp(3px, 1.2vw, 7px);
  border-radius: var(--radius-full);
  border: clamp(2px, 0.5vw, 3px) solid var(--color-plate-bg);
  pointer-events: none;
}

/* When Start Fresh is clicked or initial plate arrives: THE ENTIRE PLATE SLIDES OUT AND IN */
.sage-plate.plate-slide-out-right {
  animation: plateSlideOutRight 0.45s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none !important;
}

.sage-plate.plate-slide-in-left {
  animation: plateSlideInLeft 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: none !important;
}

@keyframes plateSlideOutRight {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(140%);
    opacity: 0;
  }
}

@keyframes plateSlideInLeft {
  0% {
    transform: translateX(-140%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Waffle Platter area inside the sage green plate center */
.waffle-platter {
  position: relative;
  width: 74%;
  height: 74%;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  cursor: crosshair;
  touch-action: none;
  z-index: 2;
}

/* Maple drizzle active cursor */
.waffle-platter.mode-drizzle {
  cursor: crosshair;
}

/* Base Waffle image wrapper */
.waffle-base-wrapper {
  width: 98%;
  height: 98%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  overflow: hidden;
  pointer-events: none;
}

.waffle-center-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-full);
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Interactive Maple Drizzle HTML5 Canvas Layer */
.maple-drizzle-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  pointer-events: none;
  z-index: 2;
}

.waffle-platter.mode-drizzle .maple-drizzle-layer {
  pointer-events: auto;
}

/* Layer containing toppings */
.toppings-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
}

/* Placed item - fully draggable and touchable */
.placed-topping {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: grab;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  filter: none;
  touch-action: none;
  user-select: none;
}

.placed-topping:hover {
  transform: translate(-50%, -50%) scale(1.1);
}

.placed-topping.is-dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.22);
  z-index: 10;
}

.placed-topping:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Topping graphics scaled for the smaller waffle */
.topping-graphic-berry,
.topping-graphic-chocolate,
.topping-graphic-banana,
.topping-graphic-cream {
  object-fit: contain;
  display: block;
  filter: none !important;
  box-shadow: none !important;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.topping-graphic-berry {
  width: clamp(22px, 3.6vw, 36px);
  height: clamp(22px, 3.6vw, 36px);
}

.topping-graphic-chocolate {
  width: clamp(13px, 2vw, 21px);
  height: clamp(13px, 2vw, 21px);
}

.topping-graphic-banana {
  width: clamp(27px, 4.4vw, 44px);
  height: clamp(27px, 4.4vw, 44px);
}

.topping-graphic-cream {
  width: clamp(32px, 5.2vw, 52px);
  height: clamp(32px, 5.2vw, 52px);
}

/* Drizzle Helper Row positioned at bottom of stage card (no container, white text per request 31) */
.drizzle-helper-row {
  position: absolute;
  bottom: var(--space-2);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background: transparent;
  border: none;
  padding: 6px 14px;
  width: calc(100% - 24px);
  max-width: 520px;
  min-height: 42px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease-out, visibility 0.2s ease-out;
  z-index: 10;
  box-sizing: border-box;
}

.drizzle-helper-row.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.drizzle-status-text {
  font-family: var(--font-body);
  font-size: clamp(0.75rem, 2.8vw, 0.95rem);
  color: var(--color-cream);
  letter-spacing: -0.01em;
  text-align: center;
  line-height: 1.25;
}

.mini-tool-btn {
  background-color: var(--color-cream);
  border: none;
  color: var(--color-ink);
  font-family: var(--font-body);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: clamp(0.75rem, 2.6vw, 0.875rem);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, transform 0.15s ease;
  min-height: 36px;
  touch-action: manipulation;
}

.mini-tool-btn:hover {
  background-color: var(--color-ground);
  transform: translateY(-1px);
}

.mini-tool-btn:active {
  transform: translateY(0);
}

/* Bottom Controls / Toppings Bar */
.bottom-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
}

.toppings-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 2.5vw, 24px);
  padding: var(--space-2) 0;
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  flex-wrap: nowrap;
}

/* Button has NO border and NO static label below */
.topping-btn {
  background: transparent;
  border: none !important;
  outline: none;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
  color: var(--color-ink);
  box-shadow: none !important;
  position: relative;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  flex-shrink: 0;
  touch-action: manipulation;
}

/* When user hovers or taps */
@media (hover: hover) {
  .topping-btn:hover,
  .topping-btn:focus-visible {
    transform: scale(1.22);
    z-index: 10;
  }
}

.topping-btn:active {
  transform: scale(1.08);
}

/* Selected state: gentle scale and focus dot */
.topping-btn.is-selected {
  transform: scale(1.15);
}

@media (hover: hover) {
  .topping-btn.is-selected:hover {
    transform: scale(1.26);
  }
}

.topping-btn.is-selected::after {
  content: "";
  position: absolute;
  bottom: -4px;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background-color: var(--color-accent);
}

.topping-icon-wrapper {
  width: clamp(42px, 11vw, 54px);
  height: clamp(42px, 11vw, 54px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  pointer-events: none;
}

.topping-preview-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  filter: none !important;
  box-shadow: none !important;
  transition: transform 0.2s ease;
}

#btn-add-chocolate .topping-preview-img {
  max-width: 65%;
  max-height: 65%;
}

#btn-add-banana .topping-preview-img {
  max-width: 95%;
  max-height: 95%;
}

#btn-add-cream .topping-preview-img {
  max-width: 98%;
  max-height: 98%;
}

#btn-tool-drizzle .topping-preview-img {
  max-width: 82%;
  max-height: 88%;
}

/* Tooltip showing what each topping is when hovered or focused */
.topping-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background-color: var(--color-ink);
  color: var(--color-cream);
  font-family: var(--font-body);
  font-size: var(--text-small);
  line-height: 1;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease-out, transform 0.18s ease-out, visibility 0.18s;
  z-index: 20;
}

.topping-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: var(--color-ink) transparent transparent transparent;
}

.topping-btn:hover .topping-tooltip,
.topping-btn:focus-visible .topping-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Done action row */
.action-bar {
  display: flex;
  justify-content: center;
  padding-top: var(--space-1);
}

.primary-done-btn {
  background-color: var(--color-accent);
  color: var(--color-cream);
  border: none;
  font-family: var(--font-display);
  font-size: clamp(1rem, 3.5vw, 1.125rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: var(--space-3) var(--space-8);
  border-radius: var(--radius-full);
  cursor: pointer;
  min-height: 48px;
  min-width: 170px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
  touch-action: manipulation;
}

.primary-done-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.primary-done-btn:active {
  transform: translateY(0);
}

/* ========================================================================= */
/* Theatrical White Curtain Overlay & Reveal Sequence                        */
/* ========================================================================= */
.theatre-curtain-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  overflow: hidden;
  pointer-events: auto;
}

.theatre-curtain-overlay[hidden] {
  display: none !important;
}

/* Top valance header track */
.curtain-valance {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 12px;
  background-color: var(--color-surface);
  border-bottom: 2px solid var(--color-border);
  z-index: 30;
  pointer-events: none;
}

/* Theatrical White Silk/Velvet Curtain Panels */
.curtain-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  width: calc(50% + 2px);
  height: 100%;
  height: 100dvh;
  background-color: var(--color-curtain-white);
  background-image:
    repeating-linear-gradient(
      90deg,
      var(--color-curtain-white) 0px,
      var(--color-curtain-white) 16px,
      var(--color-curtain-fold) 32px,
      var(--color-curtain-shade) 46px,
      var(--color-curtain-white) 64px
    );
  z-index: 20;
  will-change: transform;
  pointer-events: none;
  overflow: hidden;
}

.curtain-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    color-mix(in oklch, var(--color-curtain-shade) 50%, transparent) 0%,
    transparent 22%,
    color-mix(in oklch, var(--color-ink) 5%, transparent) 88%,
    color-mix(in oklch, var(--color-ink) 14%, transparent) 100%
  );
  pointer-events: none;
}

.curtain-hem-line {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20px;
  border-top: 2px solid var(--color-curtain-shade);
  background-color: color-mix(in oklch, var(--color-curtain-white) 90%, var(--color-surface));
}

.curtain-panel-left {
  left: 0;
  transform: translateX(-105%);
  box-shadow: 14px 0 36px color-mix(in oklch, var(--color-ink) 25%, transparent);
}

.curtain-panel-right {
  right: 0;
  transform: translateX(105%);
}

/* Curtain Closing Phase: Both panels slide inward to meet at center */
.theatre-curtain-overlay.curtain-is-closing .curtain-panel-left {
  animation: curtainCloseLeft 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.theatre-curtain-overlay.curtain-is-closing .curtain-panel-right {
  animation: curtainCloseRight 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Curtain Opening Phase: "very open and dramatically introduce the waffle" */
.theatre-curtain-overlay.curtain-is-opening .curtain-panel-left {
  animation: curtainOpenWideLeft 0.85s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

.theatre-curtain-overlay.curtain-is-opening .curtain-panel-right {
  animation: curtainOpenWideRight 0.85s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

@keyframes curtainCloseLeft {
  0% { transform: translateX(-105%); }
  100% { transform: translateX(0%); }
}

@keyframes curtainCloseRight {
  0% { transform: translateX(105%); }
  100% { transform: translateX(0%); }
}

@keyframes curtainOpenWideLeft {
  0% { transform: translateX(0%); }
  100% { transform: translateX(-105%); }
}

@keyframes curtainOpenWideRight {
  0% { transform: translateX(0%); }
  100% { transform: translateX(105%); }
}

/* Dramatic waffle intro when curtains open */
.served-dramatic-intro .served-stage {
  animation: dramaticWaffleIntro 0.85s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.served-dramatic-intro .served-condiments-column {
  animation: dramaticCondimentsIntro 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.12s both;
}

@keyframes dramaticWaffleIntro {
  0% {
    opacity: 0;
    transform: scale(0.82) translateY(28px);
  }
  60% {
    transform: scale(1.035) translateY(-3px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes dramaticCondimentsIntro {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .curtain-panel {
    transition: opacity 0.25s ease;
  }
  .theatre-curtain-overlay.curtain-is-closing .curtain-panel,
  .theatre-curtain-overlay.curtain-is-opening .curtain-panel {
    animation: none !important;
    transform: none !important;
  }
  .theatre-curtain-overlay.curtain-is-closing .curtain-panel {
    opacity: 1;
  }
  .theatre-curtain-overlay.curtain-is-opening .curtain-panel {
    opacity: 0;
  }
  .served-dramatic-intro .served-stage,
  .served-dramatic-intro .served-condiments-column {
    animation: fadeInFast 0.2s ease forwards !important;
  }
}

/* View 2: Served View Styling - container shadow removed */
.served-brand-block {
  padding-bottom: 0;
}

.served-stage {
  background-color: var(--color-ink);
  border-radius: var(--radius-surface);
  box-shadow: none;
  padding: var(--space-3) var(--space-3);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  width: 100%;
  max-width: min(680px, 100%);
  margin: 0 auto;
  min-height: 360px;
  box-sizing: border-box;
}

/* Condiments Column to the LEFT of the waffle container */
.served-condiments-column {
  position: absolute;
  left: clamp(12px, 2.8vw, 32px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  z-index: 5;
  pointer-events: none;
}

.served-condiment-row {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.served-condiment-count {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3.5vw, 2.125rem);
  font-weight: 800;
  line-height: 1;
  color: var(--color-cream);
  font-variant-numeric: tabular-nums;
  min-width: 20px;
  text-align: right;
}

.served-condiment-icon-wrap {
  width: clamp(28px, 5vw, 48px);
  height: clamp(28px, 5vw, 48px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.served-condiment-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.served-condiment-icon-wrap.is-chocolate .served-condiment-img {
  max-width: 24px;
  max-height: 24px;
}

.served-condiment-icon-wrap.is-drizzle .served-condiment-img {
  max-width: 32px;
  max-height: 38px;
}

/* Responsive Served View for Tablets and Mobile (<768px) */
@media (max-width: 768px) {
  .served-stage {
    flex-direction: column;
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
    min-height: auto;
  }
  .served-condiments-column {
    position: static;
    transform: none;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
    width: 100%;
  }
}

.served-waffle-platter {
  position: relative;
  width: 74%;
  height: 74%;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  overflow: visible;
  z-index: 2;
  touch-action: manipulation;
}

.served-waffle-platter.is-eatable {
  cursor: pointer;
  transition: transform 0.12s ease-out;
}

.served-waffle-platter.is-eatable:hover {
  transform: scale(1.02);
}

.served-waffle-platter.is-eatable:active {
  transform: scale(0.98);
}

/* Tooltip for served waffle: "click to eat" */
.waffle-hover-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background-color: var(--color-ink);
  color: var(--color-cream);
  font-family: var(--font-body);
  font-size: var(--text-small);
  line-height: 1;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease-out, transform 0.18s ease-out, visibility 0.18s;
  z-index: 30;
}

.waffle-hover-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: var(--color-ink) transparent transparent transparent;
}

.served-waffle-platter.is-eatable:hover .waffle-hover-tooltip,
.served-waffle-platter.is-eatable:focus-visible .waffle-hover-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.served-toppings-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

/* Bite Mask Canvas Layer over the served waffle */
.bite-overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  pointer-events: none;
  z-index: 4;
}

/* Floating bite crumb visual effect */
.bite-crumb-particle {
  position: absolute;
  border-radius: var(--radius-full);
  pointer-events: none;
  z-index: 10;
  animation: crumbScatter 0.5s ease-out forwards;
}

@keyframes crumbScatter {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0.4);
    opacity: 0;
  }
}

/* Plate cleared banner */
.plate-cleared-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-3);
  z-index: 6;
  pointer-events: none;
  animation: fadeInCleared 0.4s ease-out forwards;
}

.plate-cleared-message span {
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 3.2vw, 1.125rem);
  font-weight: 700;
  color: var(--color-plate-inner);
  background-color: var(--color-ink);
  padding: 8px 16px;
  border-radius: var(--radius-full);
}

@keyframes fadeInCleared {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Make another waffle button outside the container */
.served-actions-outside {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) 0 var(--space-6);
  width: 100%;
}

/* Common modal dialog styles */
dialog.help-dialog {
  border: none;
  border-radius: var(--radius-surface);
  background-color: var(--color-ground);
  color: var(--color-ink);
  padding: var(--space-4) var(--space-5) var(--space-5);
  margin: auto;
  max-width: min(820px, calc(100vw - 24px));
  width: 100%;
  max-height: calc(100dvh - 32px);
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

dialog.help-dialog::backdrop {
  background-color: color-mix(in oklch, var(--color-ink) 72%, transparent);
}

.help-dialog-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: relative;
  width: 100%;
}

.help-dialog-close-btn {
  position: absolute;
  top: 0;
  right: 0;
  background-color: var(--color-surface);
  border: none;
  color: var(--color-ink);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease-out, transform 0.15s ease-out;
  touch-action: manipulation;
  z-index: 10;
}

.help-dialog-close-btn:hover {
  background-color: color-mix(in oklch, var(--color-surface) 80%, var(--color-ink) 8%);
  transform: translateY(-1px);
}

.help-dialog-close-btn:active {
  transform: translateY(0);
}

.help-dialog-header {
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: var(--space-10);
  padding-top: var(--space-1);
}

.help-dialog-title {
  margin: 0;
  padding: 0;
  line-height: 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.help-dialog-title-img {
  max-width: min(280px, 68vw);
  height: auto;
  display: block;
  object-fit: contain;
}

.help-dialog-body {
  width: 100%;
}

.help-dialog-steps-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  width: 100%;
}

@media (max-width: 640px) {
  .help-dialog-steps-list {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
}

.help-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: var(--space-2);
}

.help-action-btn {
  min-width: 220px;
  font-size: clamp(1rem, 3.2vw, 1.15rem);
  padding: var(--space-3) var(--space-8);
}

/* ========================================================================= */
/* Responsive Scaling for Super Big Screens (1200px, 1440px, 1920px, 2560px+) */
/* ========================================================================= */
@media (min-width: 1200px) {
  .app-container {
    max-width: min(1080px, 88vw);
    padding: var(--space-5) var(--space-5) var(--space-8);
    gap: var(--space-4);
  }

  .global-utility-bar {
    top: var(--space-5);
    right: var(--space-5);
    height: clamp(84px, 7vw, 110px);
  }

  .utility-circle-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
  }

  .title-brand-image {
    max-width: min(580px, calc(100% - 180px));
  }

  .start-brand-image {
    max-width: min(640px, calc(100% - 180px));
  }

  .start-subtitle-image,
  .help-dialog-title-img {
    max-width: 320px;
  }

  .stage-card,
  .served-stage {
    max-width: 780px;
    min-height: 400px;
    padding: var(--space-4);
  }

  .table-setting {
    max-width: 620px;
    gap: clamp(14px, 2.8vw, 38px);
    margin: var(--space-3) auto;
  }

  .sage-plate {
    width: clamp(245px, 18vw, 275px);
    height: clamp(245px, 18vw, 275px);
  }

  .cutlery {
    width: clamp(26px, 3.2vw, 48px);
    height: clamp(140px, 15vw, 205px);
  }

  .toppings-grid {
    gap: clamp(12px, 2.5vw, 28px);
  }

  .topping-btn {
    min-height: 52px;
    min-width: 52px;
  }

  .topping-icon-wrapper {
    width: 58px;
    height: 58px;
  }

  .start-step-item {
    padding: var(--space-6);
  }

  .start-step-visual {
    width: 114px;
    height: 114px;
  }
}

@media (min-width: 1600px) {
  .app-container {
    max-width: min(1240px, 82vw);
    padding: var(--space-6) var(--space-6) var(--space-10);
  }

  .global-utility-bar {
    top: var(--space-6);
    right: var(--space-6);
    height: clamp(92px, 6vw, 120px);
  }

  .title-brand-image {
    max-width: min(660px, calc(100% - 200px));
  }

  .start-brand-image {
    max-width: min(700px, calc(100% - 200px));
  }

  .stage-card,
  .served-stage {
    max-width: 860px;
    min-height: 440px;
  }

  .table-setting {
    max-width: 680px;
    gap: clamp(18px, 2.5vw, 44px);
  }

  .sage-plate {
    width: clamp(265px, 16vw, 300px);
    height: clamp(265px, 16vw, 300px);
  }

  .cutlery {
    width: clamp(30px, 2.8vw, 52px);
    height: clamp(160px, 13vw, 225px);
  }

  .topping-icon-wrapper {
    width: 64px;
    height: 64px;
  }

  .primary-done-btn {
    font-size: 1.25rem;
    min-height: 54px;
    padding: var(--space-4) var(--space-10);
  }
}

/* ========================================================================= */
/* Fine-tuned adjustments for Mobile Devices (361px - 480px)                 */
/* ========================================================================= */
@media (max-width: 480px) {
  .app-container {
    padding: var(--space-2) var(--space-2) var(--space-5);
    gap: var(--space-2);
  }

  .intro-block {
    padding: var(--space-1) 0;
    gap: 4px;
  }

  .start-subtitle-image,
  .help-dialog-title-img {
    max-width: min(220px, 65vw);
  }

  .start-step-item {
    padding: var(--space-3);
    gap: var(--space-3);
  }

  .start-step-visual {
    width: 82px;
    height: 82px;
  }

  dialog.help-dialog {
    padding: var(--space-3) var(--space-3) var(--space-4);
    max-height: calc(100dvh - 20px);
  }

  .stage-card,
  .served-stage {
    min-height: 310px;
    max-width: 100%;
    padding: var(--space-2);
    border-radius: 16px;
  }

  .stage-action-bar {
    top: 8px;
    right: 8px;
  }

  .reset-button {
    padding: 6px 12px;
    min-height: 40px;
    font-size: 0.8125rem;
  }

  .sage-plate {
    width: min(190px, 50vw);
    height: min(190px, 50vw);
  }

  .table-setting {
    gap: 8px;
    margin: 4px auto;
  }

  .cutlery {
    width: 18px;
    height: clamp(100px, 26vw, 135px);
  }

  .drizzle-helper-row {
    bottom: 8px;
    padding: 4px 10px;
    gap: 6px;
  }

  .drizzle-status-text {
    font-size: 0.75rem;
  }

  .mini-tool-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
  }

  .toppings-grid {
    gap: 4px;
    padding: var(--space-1) 0;
  }

  .topping-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 2px;
  }

  .topping-icon-wrapper {
    width: 44px;
    height: 44px;
  }

  .primary-done-btn {
    min-height: 46px;
    padding: 10px 24px;
    font-size: 1rem;
    width: 100%;
    max-width: 240px;
  }
}

/* ========================================================================= */
/* Ultra-compact phone screens (320px - 360px)                               */
/* ========================================================================= */
@media (max-width: 360px) {
  .app-container {
    padding: var(--space-1) var(--space-1) var(--space-4);
  }

  .stage-card,
  .served-stage {
    min-height: 280px;
    padding: var(--space-1);
  }

  .sage-plate {
    width: min(168px, 48vw);
    height: min(168px, 48vw);
  }

  .table-setting {
    gap: 5px;
  }

  .cutlery {
    width: 15px;
    height: 95px;
  }

  .toppings-grid {
    gap: 2px;
  }

  .topping-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0;
  }

  .topping-icon-wrapper {
    width: 40px;
    height: 40px;
  }

  .start-step-visual {
    width: 72px;
    height: 72px;
  }
}

/* ========================================================================= */
/* Height-constrained landscape displays (e.g. phones in landscape)          */
/* ========================================================================= */
@media (max-height: 540px) and (orientation: landscape) {
  .app-container {
    padding-top: var(--space-1);
    padding-bottom: var(--space-3);
    gap: var(--space-1);
  }

  .intro-block {
    padding: 0;
    gap: 2px;
  }

  .stage-card,
  .served-stage {
    min-height: 240px;
    max-width: 580px;
    padding: var(--space-1);
  }

  .sage-plate {
    width: min(170px, 42vh);
    height: min(170px, 42vh);
  }

  .cutlery {
    height: min(125px, 32vh);
    width: 18px;
  }

  .start-steps-list,
  .help-dialog-steps-list {
    grid-template-columns: repeat(2, 1fr);
  }

  dialog.help-dialog {
    max-height: calc(100dvh - 16px);
    padding: var(--space-2) var(--space-3);
  }
}
