:root {
  --berry: #e94f73;
  --berry-dark: #ad2850;
  --custard: #ffd45e;
  --mint: #54c7b8;
  --mint-dark: #177d75;
  --cocoa: #633820;
  --cream: #fff9e9;
  --paper: #fffdf5;
  --ink: #4b2c21;
  --shadow: 0 12px 0 rgba(101, 51, 31, .12), 0 18px 35px rgba(92, 47, 32, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: #f7d875; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(255,255,255,.75) 0 3px, transparent 4px),
    linear-gradient(135deg, #fff3b3, #ffcf6c 55%, #ffb858);
  background-size: 38px 38px, auto;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
button:focus-visible { outline: 5px solid #2d75ff; outline-offset: 4px; }
button { touch-action: manipulation; }

#app { min-height: 100vh; }
.topbar {
  height: 84px;
  padding: 10px clamp(16px, 4vw, 52px);
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 253, 245, .93);
  border-bottom: 4px solid rgba(99,56,32,.13);
  position: relative;
  z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  border: 0; background: none; cursor: pointer;
  text-align: left; line-height: 1.02; font-size: .78rem;
}
.brand b { font-size: 1.12rem; color: var(--berry-dark); }
.brand-mark { font-size: 2.5rem; transform: rotate(-8deg); }
.status-pill {
  margin-left: auto; display: flex; gap: 8px; align-items: center;
  background: #fff3c4; border: 3px solid #e1a927; border-radius: 999px;
  padding: 7px 15px; font-size: 1.15rem;
}
.round-btn {
  width: 48px; height: 48px; border: 3px solid #d7c8ab; border-radius: 50%;
  background: white; cursor: pointer; font-size: 1.3rem; box-shadow: 0 4px 0 #d7c8ab;
}
.round-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d7c8ab; }

main { min-height: calc(100vh - 84px); }
.screen { display: none; min-height: calc(100vh - 84px); padding: 28px clamp(16px, 4vw, 52px) 42px; }
.screen.active { display: block; animation: screenIn .35s ease-out both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } }

.hero {
  max-width: 1200px; min-height: 575px; margin: 0 auto;
  position: relative; overflow: hidden; border-radius: 34px;
  border: 6px solid white; box-shadow: var(--shadow); background: #9ee5ff;
}
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(255,249,233,.98) 0%, rgba(255,249,233,.9) 31%, rgba(255,249,233,.1) 62%); }
.hero img { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.hero-copy { position: relative; z-index: 2; width: 50%; min-width: 440px; padding: 56px 20px 42px 54px; }
.eyebrow { margin: 0 0 8px; color: var(--berry-dark); font-weight: 900; font-size: 1.05rem; }
h1 { font-size: clamp(2.5rem, 5vw, 4.6rem); line-height: 1.1; margin: 0 0 32px; letter-spacing: -.04em; text-shadow: 0 3px 0 white; }
.home-actions { display: grid; gap: 16px; max-width: 450px; }
.big-choice {
  border: 4px solid rgba(99,56,32,.18); border-radius: 24px; padding: 17px 17px;
  min-height: 98px; display: grid; grid-template-columns: 68px 1fr 24px; align-items: center;
  gap: 12px; text-align: left; cursor: pointer; box-shadow: 0 8px 0 rgba(99,56,32,.18);
  transition: transform .18s ease, box-shadow .18s ease;
}
.big-choice:hover { transform: translateY(-3px) rotate(-.3deg); box-shadow: 0 11px 0 rgba(99,56,32,.18); }
.big-choice:active { transform: translateY(5px); box-shadow: 0 3px 0 rgba(99,56,32,.18); }
.shop-choice { background: var(--berry); color: white; }
.free-choice { background: var(--mint); color: #173f3b; }
.choice-icon { font-size: 3rem; filter: drop-shadow(0 3px 0 rgba(0,0,0,.12)); }
.big-choice b { display: block; font-size: 1.42rem; }
.big-choice small { display: block; margin-top: 4px; font-size: .9rem; font-weight: 700; }
.choice-arrow { font-size: 2.4rem; font-weight: bold; }
.book-button {
  display: flex; align-items: center; gap: 10px; margin: -25px auto 0; position: relative; z-index: 3;
  border: 3px solid #a45c2b; border-radius: 18px; background: white; padding: 12px 24px;
  box-shadow: 0 6px 0 #a45c2b; cursor: pointer;
}
.book-button span { font-size: 1.6rem; }
.book-button small { padding-left: 12px; color: #87624f; border-left: 2px dashed #d7c8ab; }

.back-link { border: 0; background: rgba(255,255,255,.85); border-radius: 999px; padding: 10px 18px; font-weight: 900; cursor: pointer; box-shadow: 0 4px 0 rgba(99,56,32,.14); }
.section-heading { display: flex; justify-content: center; align-items: center; gap: 18px; margin: 28px auto 34px; text-align: left; }
.section-heading p { margin: 0; font-weight: 800; color: var(--berry-dark); }
.section-heading h2 { font-size: clamp(2rem, 4vw, 3.4rem); margin: 0; }
.mascot-bubble { font-size: 4.5rem; background: white; border-radius: 50%; width: 108px; height: 108px; display: grid; place-items: center; box-shadow: var(--shadow); }
.difficulty-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px; max-width: 1050px; margin: auto; }
.difficulty-card {
  min-height: 330px; padding: 24px 18px; border: 5px solid white; border-radius: 32px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: var(--shadow); position: relative; transition: transform .2s ease;
}
.difficulty-card:hover { transform: translateY(-7px) rotate(1deg); }
.difficulty-card.easy { background: #bfe8a7; }
.difficulty-card.medium { background: #ff9eb1; }
.difficulty-card.hard { background: #a7dff1; }
.level-stamp { position: absolute; top: 18px; left: 20px; background: white; border-radius: 999px; padding: 5px 12px; color: #e1a927; letter-spacing: 3px; }
.difficulty-art { font-size: 6rem; filter: drop-shadow(0 7px 0 rgba(99,56,32,.12)); }
.difficulty-card b { font-size: 2rem; margin: 15px 0 7px; }
.difficulty-card small { font-size: 1rem; line-height: 1.55; font-weight: 700; }

.cook-topline { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; max-width: 1200px; margin: auto; }
.progress-dots { display: flex; gap: 10px; }
.progress-dots span { width: 34px; height: 11px; background: rgba(99,56,32,.18); border-radius: 10px; }
.progress-dots span.on { background: var(--berry); }
.mini-timer { justify-self: end; background: white; border: 3px solid #d7c8ab; padding: 8px 14px; border-radius: 999px; font-size: 1.1rem; }
.order-card { max-width: 800px; margin: 18px auto 22px; display: flex; align-items: center; gap: 20px; }
.customer { width: 105px; height: 105px; border: 5px solid white; border-radius: 50%; background: #bde8ff; display: grid; place-items: center; font-size: 4.3rem; box-shadow: var(--shadow); flex: 0 0 auto; }
.order-speech { flex: 1; background: white; border: 4px solid #eddab9; border-radius: 25px; padding: 15px 22px; box-shadow: 0 7px 0 #ddbd87; position: relative; }
.order-speech::before { content: ""; position: absolute; left: -16px; top: 38px; width: 25px; height: 25px; background: white; border-left: 4px solid #eddab9; border-bottom: 4px solid #eddab9; transform: rotate(45deg); }
.order-label { display: flex; align-items: center; justify-content: space-between; color: var(--berry-dark); font-weight: 900; font-size: .85rem; }
.order-label button { border: 0; background: #fff1b9; width: 37px; height: 37px; border-radius: 50%; cursor: pointer; }
.order-speech h2 { margin: 0 0 8px; font-size: 1.35rem; }
.order-items { display: flex; gap: 10px; flex-wrap: wrap; min-height: 38px; }
.order-chip { display: inline-flex; align-items: center; gap: 5px; background: #fff4db; border: 2px solid #eddab9; border-radius: 13px; padding: 5px 10px; font-weight: 900; }
.order-hidden { color: #87624f; font-weight: 800; }

.kitchen { display: grid; grid-template-columns: minmax(390px, 1fr) minmax(330px, 430px); gap: 24px; max-width: 1200px; margin: auto; align-items: stretch; }
.workbench, .ingredients-panel { background: rgba(255,253,245,.95); border: 5px solid white; border-radius: 30px; box-shadow: var(--shadow); padding: 20px; }
.workbench { min-height: 460px; display: flex; flex-direction: column; }
.instruction { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; font-size: 1.15rem; }
.instruction span { width: 33px; height: 33px; display: grid; place-items: center; background: var(--berry); color: white; border-radius: 50%; }
.crepe-stage {
  flex: 1; min-height: 315px; display: grid; place-items: center; position: relative; overflow: hidden;
  border-radius: 25px; background: radial-gradient(circle at center, #fff6d8 0 48%, #e8c98d 49% 50%, #9f714b 51% 52%, #875d3d 53% 100%);
  border: 5px solid #6f4933;
}
.mix-bowl { border: 0; background: none; cursor: pointer; display: grid; gap: 6px; justify-items: center; animation: bob 1.4s ease-in-out infinite; }
.mix-bowl span { font-size: 8rem; filter: drop-shadow(0 8px 0 rgba(74,44,33,.12)); }
.mix-bowl i { background: var(--berry); color: white; border-radius: 999px; padding: 6px 16px; font-style: normal; font-weight: 900; }
.mix-bowl.shake { animation: shake .28s linear; }
@keyframes bob { 50% { transform: translateY(-7px); } }
@keyframes shake { 25% { transform: rotate(-9deg) scale(1.08); } 75% { transform: rotate(9deg) scale(1.08); } }
.crepe { width: min(285px, 72vw); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 34% 27%, #ffe5a4 0 5%, transparent 6%), radial-gradient(circle at 65% 72%, #d69745 0 3%, transparent 4%), #efbf6f; border: 6px solid #cf8b3f; box-shadow: inset -14px -15px 0 rgba(165,95,35,.12), 0 10px 0 rgba(70,42,24,.18); position: relative; transition: transform .5s ease; }
.crepe.flip { animation: flip .75s ease; }
@keyframes flip { 50% { transform: rotateY(90deg) scale(1.25); } }
.topping { position: absolute; transform: translate(-50%, -50%); font-size: 2.35rem; cursor: grab; user-select: none; filter: drop-shadow(0 3px 1px rgba(65,38,20,.18)); z-index: 3; touch-action: none; }
.topping:active { cursor: grabbing; transform: translate(-50%, -50%) scale(1.15); }
.primary-action, .secondary-action, .finish-btn, .soft-btn { border: 0; border-radius: 17px; min-height: 54px; padding: 11px 22px; font-weight: 900; cursor: pointer; }
.primary-action { margin-top: 14px; background: var(--berry); color: white; font-size: 1.15rem; box-shadow: 0 6px 0 var(--berry-dark); }
.primary-action:disabled { filter: grayscale(.6); opacity: .5; cursor: not-allowed; }
.primary-action:not(:disabled):active, .finish-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--berry-dark); }
.ingredients-panel { display: flex; flex-direction: column; }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; }
.panel-title b { font-size: 1.3rem; }
.panel-title small { color: #87624f; font-weight: 700; }
.ingredient-tabs { display: flex; gap: 7px; margin: 14px 0; overflow-x: auto; padding-bottom: 4px; }
.tab-btn { border: 2px solid #dbc49e; border-radius: 999px; background: #fff9e9; padding: 7px 12px; white-space: nowrap; font-weight: 800; cursor: pointer; }
.tab-btn.active { background: var(--cocoa); color: white; border-color: var(--cocoa); }
.ingredient-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; align-content: start; flex: 1; }
.ingredient-btn { min-height: 74px; border: 3px solid #eddab9; border-radius: 17px; background: white; cursor: pointer; display: grid; place-items: center; position: relative; font-size: 2rem; box-shadow: 0 4px 0 #ddbd87; }
.ingredient-btn small { font-size: .68rem; font-weight: 900; }
.ingredient-btn.hint { animation: glow 1.15s ease-in-out infinite; }
@keyframes glow { 50% { border-color: var(--berry); box-shadow: 0 0 0 6px rgba(233,79,115,.2), 0 4px 0 var(--berry-dark); } }
.count-badge { position: absolute; right: 4px; top: 4px; min-width: 23px; height: 23px; border-radius: 50%; background: var(--mint-dark); color: white; font-size: .75rem; display: grid; place-items: center; font-weight: 900; }
.work-actions { display: grid; grid-template-columns: 1fr 1.2fr; gap: 10px; margin-top: 15px; }
.soft-btn { background: #eee3ce; color: #6d503f; }
.finish-btn { background: var(--mint); color: #173f3b; box-shadow: 0 6px 0 var(--mint-dark); font-size: 1.05rem; }

#resultScreen { display: none; place-items: center; }
#resultScreen.active { display: grid; }
.result-card { width: min(680px, 100%); background: white; border: 6px solid white; border-radius: 38px; padding: 26px; box-shadow: var(--shadow); text-align: center; position: relative; overflow: hidden; }
.result-rays { position: absolute; width: 560px; height: 560px; left: 50%; top: -240px; transform: translateX(-50%); background: repeating-conic-gradient(from 0deg, rgba(255,212,94,.3) 0 12deg, transparent 12deg 24deg); border-radius: 50%; animation: spin 18s linear infinite; }
@keyframes spin { to { transform: translateX(-50%) rotate(360deg); } }
.result-face, .result-kicker, .result-card h2, .stars, .result-crepe, .coin-reward, .result-actions { position: relative; }
.result-face { font-size: 4rem; }
.result-kicker { color: var(--berry-dark); font-weight: 900; margin: 3px 0; }
.result-card h2 { font-size: clamp(1.9rem, 5vw, 3rem); margin: 0; }
.stars { color: #ffbd19; font-size: 2.4rem; letter-spacing: 8px; text-shadow: 0 3px 0 #c57d15; }
.result-crepe { width: 230px; min-height: 205px; margin: 10px auto; background: #efbf6f; border: 5px solid #cf8b3f; border-radius: 50% 50% 45% 45%; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; padding: 35px; font-size: 2rem; box-shadow: inset -12px -12px 0 rgba(165,95,35,.12), 0 9px 0 rgba(70,42,24,.15); }
.coin-reward { display: inline-block; background: #fff1b9; border: 3px solid #e1a927; border-radius: 999px; padding: 7px 18px; font-size: 1.2rem; font-weight: 900; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.secondary-action { background: #e7f6f2; color: var(--mint-dark); box-shadow: 0 6px 0 #9ccfc7; }

.book-heading { margin-top: 18px; }
.book-grid { max-width: 1050px; margin: auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.book-entry { background: white; border: 5px solid white; border-radius: 24px; padding: 16px; box-shadow: var(--shadow); text-align: center; }
.book-entry-art { width: 100%; min-height: 150px; border: 0; border-radius: 18px; background: #fff0bf; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; padding: 20px; font: inherit; font-size: 2.1rem; cursor: pointer; }
.book-entry-art:focus-visible { outline: 5px solid var(--berry); outline-offset: 3px; }
.book-entry b { display: block; margin-top: 10px; }
.book-entry small { color: #87624f; }
.empty-book { grid-column: 1/-1; text-align: center; background: rgba(255,255,255,.75); border: 4px dashed #cf9b58; padding: 50px 20px; border-radius: 30px; }
.empty-book span { display: block; font-size: 5rem; margin-bottom: 10px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 120px); background: var(--cocoa); color: white; border: 3px solid white; border-radius: 999px; padding: 12px 22px; font-weight: 900; z-index: 100; transition: transform .25s ease; box-shadow: var(--shadow); }
.toast.show { transform: translate(-50%, 0); }
.celebrate { position: absolute; inset: 0; pointer-events: none; }
.spark { position: absolute; animation: pop 1s ease-out forwards; font-size: 1.5rem; }
@keyframes pop { from { transform: translateY(25px) scale(.3); opacity: 1; } to { transform: translateY(-150px) rotate(180deg) scale(1.4); opacity: 0; } }

@media (max-width: 850px) {
  .topbar { height: 72px; }
  main, .screen { min-height: calc(100vh - 72px); }
  .brand b { font-size: .9rem; }
  .brand-mark { font-size: 2rem; }
  .hero { min-height: 680px; }
  .hero::after { background: linear-gradient(180deg, rgba(255,249,233,.98) 0 46%, rgba(255,249,233,.2) 70%); }
  .hero img { object-position: 65% center; }
  .hero-copy { width: 100%; min-width: 0; padding: 32px 22px; }
  h1 { font-size: clamp(2.3rem, 10vw, 3.4rem); margin-bottom: 22px; }
  .home-actions { max-width: 100%; }
  .difficulty-grid { grid-template-columns: 1fr; max-width: 500px; }
  .difficulty-card { min-height: 190px; display: grid; grid-template-columns: 100px 1fr; grid-template-rows: auto auto; text-align: left; }
  .difficulty-art { grid-row: 1/3; font-size: 5rem; }
  .difficulty-card b { margin: 0; align-self: end; }
  .level-stamp { left: auto; right: 15px; }
  .kitchen { grid-template-columns: 1fr; }
  .workbench { min-height: 400px; }
  .ingredients-panel { min-height: 380px; }
  .book-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .screen { padding: 18px 12px 32px; }
  .status-pill { padding: 5px 10px; }
  .round-btn { width: 43px; height: 43px; }
  .hero { border-radius: 25px; min-height: 640px; }
  .hero-copy { padding: 25px 15px; }
  .big-choice { grid-template-columns: 52px 1fr 18px; min-height: 88px; padding: 12px; }
  .choice-icon { font-size: 2.35rem; }
  .big-choice b { font-size: 1.12rem; }
  .big-choice small { font-size: .76rem; }
  .book-button { margin-top: -20px; }
  .section-heading { justify-content: flex-start; margin: 24px 6px; }
  .mascot-bubble { width: 76px; height: 76px; font-size: 3rem; }
  .section-heading h2 { font-size: 1.75rem; }
  .order-card { gap: 8px; }
  .customer { width: 70px; height: 70px; font-size: 2.7rem; }
  .order-speech { padding: 12px; }
  .order-speech::before { left: -10px; width: 16px; height: 16px; }
  .order-speech h2 { font-size: 1rem; }
  .kitchen { display: block; }
  .workbench, .ingredients-panel { padding: 11px; border-radius: 24px; }
  .workbench { min-height: 380px; }
  .ingredients-panel { margin-top: 16px; min-height: 340px; }
  .crepe-stage { min-height: 280px; }
  .ingredient-grid { grid-template-columns: repeat(4, 1fr); }
  .ingredient-btn { min-height: 68px; font-size: 1.7rem; }
  .result-card { padding: 18px 12px; }
  .result-actions { grid-template-columns: 1fr; }
  .book-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .book-entry { padding: 9px; }
  .book-entry-art { min-height: 110px; font-size: 1.6rem; padding: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

/* Hands-on cooking game */
.cooking-game {
  max-width: 1040px;
  margin: 0 auto;
  padding: 18px;
  border: 5px solid white;
  border-radius: 32px;
  background: rgba(255, 253, 245, .96);
  box-shadow: var(--shadow);
  position: relative;
}
.gesture-meter {
  width: min(520px, 82%);
  height: 15px;
  margin: 0 auto 14px;
  padding: 3px;
  border-radius: 999px;
  background: #e7d8bc;
  overflow: hidden;
}
.gesture-meter i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), #ffcd4f, var(--berry));
  transition: width .12s ease-out;
}
.interactive-stage {
  width: min(720px, 100%);
  margin: auto;
  position: relative;
}
.canvas-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 5px solid #6d472f;
  border-radius: 28px;
  background: #d99b55;
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.18), 0 10px 0 rgba(94,51,28,.18);
}
.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(54vh, 520px);
  object-fit: contain;
  touch-action: none;
  cursor: crosshair;
}
.finger-guide {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 126px;
  height: 126px;
  display: grid;
  place-content: center;
  gap: 3px;
  text-align: center;
  color: white;
  background: rgba(78, 42, 25, .72);
  border: 4px solid white;
  border-radius: 50%;
  pointer-events: none;
  animation: guideCircle 2s ease-in-out infinite;
}
.finger-guide span { font-size: 2.4rem; }
.finger-guide b { font-size: .9rem; }
@keyframes guideCircle {
  0%, 100% { transform: translate(-50%, -50%) rotate(-8deg); }
  50% { transform: translate(-50%, -50%) rotate(15deg) scale(1.08); }
}
.pour-control {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  gap: 3px;
  min-width: 160px;
  padding: 14px 24px;
  border: 4px solid white;
  border-radius: 24px;
  background: var(--berry);
  color: white;
  box-shadow: 0 8px 0 var(--berry-dark);
  cursor: pointer;
  z-index: 4;
}
.pour-control span { font-size: 3.2rem; }
.pour-control b { font-size: 1.05rem; }
.bake-clock {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(300px, 75%);
  padding: 9px 13px;
  border: 3px solid white;
  border-radius: 17px;
  background: rgba(64, 37, 26, .82);
  color: white;
  text-align: center;
}
.bake-clock span { display: block; margin-bottom: 6px; font-weight: 900; }
.bake-clock i { display: block; height: 10px; background: rgba(255,255,255,.25); border-radius: 999px; overflow: hidden; }
.bake-clock b { display: block; width: 0; height: 100%; background: #ffcf56; transition: width .1s linear; }
.decorate-wrap {
  position: relative;
  width: 100%;
  min-height: 520px;
  display: grid;
  place-items: center;
  border: 5px solid #6d472f;
  border-radius: 28px;
  background: repeating-linear-gradient(0deg, rgba(102,61,31,.07) 0 3px, transparent 3px 66px), linear-gradient(135deg, #f2c783, #d79752);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.18), 0 10px 0 rgba(94,51,28,.18);
  overflow: hidden;
}
.flat-crepe {
  width: min(480px, 82vw);
  aspect-ratio: 1;
  position: relative;
  border: 7px solid #c47b33;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #f9dc96, #e9b45e 72%, #ce8437);
  box-shadow: inset -18px -18px 0 rgba(142,80,26,.12), 0 16px 22px rgba(79,43,24,.22);
}
#creamCanvas, #placedToppings { position: absolute; inset: 0; width: 100%; height: 100%; }
#creamCanvas { z-index: 2; touch-action: none; cursor: crosshair; }
#placedToppings { z-index: 3; pointer-events: none; }
.placed-piece {
  position: absolute;
  width: 96px;
  height: 96px;
  object-fit: contain;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  filter: drop-shadow(0 5px 3px rgba(74,38,19,.2));
}
.placed-piece:active { cursor: grabbing; }
.drop-hint {
  position: absolute;
  bottom: 9px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(255,255,255,.82);
  font-size: .85rem;
  font-weight: 900;
  pointer-events: none;
}
.cream-cursor {
  position: absolute;
  z-index: 6;
  width: 38px;
  height: 38px;
  transform: translate(-50%, -50%);
  border: 4px solid var(--berry);
  border-radius: 50%;
  pointer-events: none;
}
.tool-tray {
  width: min(850px, 100%);
  margin: 20px auto 0;
  padding: 14px;
  border: 4px solid #d9bc87;
  border-radius: 24px;
  background: #fff5df;
}
.tray-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.tray-heading b { font-size: 1.1rem; }
.tray-heading small { color: #81604b; font-weight: 800; }
.real-ingredients, .cream-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cream-tools { grid-template-columns: repeat(2, 1fr); margin-top: 10px; }
.real-ingredient, .cream-tool {
  min-height: 112px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  border: 3px solid #dfc89e;
  border-radius: 18px;
  background: white;
  box-shadow: 0 5px 0 #caa96f;
  cursor: grab;
  touch-action: none;
}
.real-ingredient img { width: 76px; height: 76px; object-fit: contain; pointer-events: none; }
.real-ingredient b, .cream-tool b { font-size: .9rem; }
.real-ingredient i {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--mint-dark);
  color: white;
  font-style: normal;
  font-weight: 900;
}
.real-ingredient.hint { animation: glow 1.15s ease-in-out infinite; }
.cream-tool { min-height: 72px; cursor: pointer; }
.cream-tool.selected { border-color: var(--berry); background: #fff0f3; box-shadow: 0 0 0 5px rgba(233,79,115,.18), 0 5px 0 var(--berry-dark); }
.cream-swirl {
  width: 64px;
  height: 28px;
  display: block;
  border-radius: 999px;
  box-shadow: inset 0 -5px 0 rgba(91,53,33,.14), 0 4px 5px rgba(91,53,33,.13);
}
.cream-swirl.vanilla { background: repeating-linear-gradient(175deg, #fffdf3 0 8px, #ead9bb 8px 12px); }
.cream-swirl.chocolate { background: repeating-linear-gradient(175deg, #75432e 0 8px, #9b6242 8px 12px); }
.game-actions { width: min(850px, 100%); margin: 16px auto 0; display: flex; justify-content: center; gap: 12px; }
.game-actions .primary-action, .game-actions .finish-btn { min-width: 230px; margin-top: 0; }
.drag-ghost {
  position: fixed;
  z-index: 999;
  width: 110px;
  height: 110px;
  object-fit: contain;
  transform: translate(-50%, -50%) scale(1.08);
  pointer-events: none;
  filter: drop-shadow(0 9px 5px rgba(70,35,15,.25));
}
.result-crepe-canvas { display: block; width: min(320px, 78vw); height: auto; margin: 4px auto 10px; position: relative; }
.book-entry-art img { width: 48px; height: 48px; object-fit: contain; }
.book-entry-art .book-crepe-photo { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.legacy-book-crepe { position: relative; width: 100%; height: 100%; min-height: 0; }
.book-entry-art .legacy-book-base { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; z-index: 1; }
.legacy-book-filling { position: absolute; left: 31%; top: 16%; width: 39%; height: 24%; border-radius: 50%; background: radial-gradient(circle at 42% 36%, #fffdf2, #f1d8a2 72%, #c99352); box-shadow: inset 0 -4px 7px rgba(111,65,29,.25); z-index: 2; }
.book-entry-art .legacy-book-topping { position: absolute; width: 22%; height: 22%; object-fit: contain; transform: translate(-50%, -50%); filter: drop-shadow(0 2px 2px rgba(60,30,15,.24)); z-index: 3; }
.book-detail { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 18px; background: rgba(54,28,19,.68); backdrop-filter: blur(5px); }
.book-detail[hidden] { display: none; }
.book-detail-card { position: relative; width: min(620px, 100%); max-height: 88dvh; overflow: hidden; padding: 24px; border: 6px solid white; border-radius: 30px; background: #fff8dc; box-shadow: 0 24px 65px rgba(48,24,15,.35); text-align: center; }
.book-detail-card > p { margin: 0; color: var(--berry-dark); font-weight: 900; }
.book-detail-card h2 { margin: 3px 38px 15px; color: var(--cocoa); }
.book-detail-close { position: absolute; top: 10px; right: 12px; width: 42px; height: 42px; border: 0; border-radius: 50%; background: white; color: var(--cocoa); font-size: 1.7rem; font-weight: 900; cursor: pointer; }
.book-material-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 17px; }
.book-material-chip { min-width: 0; min-height: 82px; padding: 7px; border: 3px solid #ead3a5; border-radius: 17px; background: white; display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; align-items: center; gap: 5px; text-align: left; }
.book-material-chip img, .material-cream { width: 48px; height: 48px; object-fit: contain; }
.book-material-chip b { font-size: .82rem; line-height: 1.15; }
.book-material-chip i { color: var(--berry-dark); font-style: normal; font-weight: 900; }
.material-cream { display: block; border-radius: 50%; background: repeating-conic-gradient(from 8deg, #fffef8 0 18deg, #e4cda8 18deg 34deg); box-shadow: inset -4px -5px 0 rgba(73,39,22,.15); }
.material-cream.custard { background: repeating-conic-gradient(from 8deg, #fff09b 0 18deg, #d69b22 18deg 34deg); }
.material-cream.chocolate { background: repeating-conic-gradient(from 8deg, #a86d4c 0 18deg, #5a301f 18deg 34deg); }

@media (max-width: 720px) {
  .cooking-game { padding: 10px; border-radius: 24px; }
  .order-card { margin-bottom: 14px; }
  .decorate-wrap { min-height: 390px; }
  .flat-crepe { width: min(350px, 86vw); }
  .placed-piece { width: 72px; height: 72px; }
  .real-ingredient, .cream-tool { flex-direction: column; min-height: 104px; gap: 2px; }
  .real-ingredient img { width: 58px; height: 58px; }
  .cream-tools { gap: 8px; }
  .cream-tool { min-height: 90px; }
  .tray-heading { display: block; text-align: center; }
  .tray-heading small { display: block; margin-top: 3px; }
}

@media (max-width: 430px) {
  .cooking-game { border-width: 3px; }
  .instruction { font-size: .98rem; }
  .interactive-stage { width: calc(100% + 8px); margin-left: -4px; }
  .canvas-wrap, .decorate-wrap { border-width: 3px; border-radius: 20px; }
  .finger-guide { width: 98px; height: 98px; }
  .finger-guide span { font-size: 1.8rem; }
  .decorate-wrap { min-height: 345px; }
  .flat-crepe { width: min(310px, 84vw); }
  .placed-piece { width: 60px; height: 60px; }
  .tool-tray { padding: 9px; }
  .real-ingredient, .cream-tool { min-height: 94px; }
  .real-ingredient img { width: 52px; height: 52px; }
  .real-ingredient b, .cream-tool b { font-size: .76rem; }
  .game-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .game-actions .primary-action, .game-actions .finish-btn { min-width: 0; grid-column: 1 / -1; }
}

/* Every game view stays inside the viewport */
html, body, #app { height: 100%; overflow: hidden; }
main { height: calc(100dvh - 84px); min-height: 0; }
.screen { height: 100%; min-height: 0; overflow: hidden; }
#crepeHomeScreen.active, #difficultyScreen.active, #bookScreen.active { display: flex; flex-direction: column; }
#crepeHomeScreen .hero { flex: 1; width: min(1200px, 100%); min-height: 0; }
#crepeHomeScreen .book-button { flex: 0 0 auto; }
.cuisine-back { align-self: flex-start; margin-bottom: 8px; }
#difficultyScreen .section-heading, #bookScreen .section-heading { flex: 0 0 auto; }
#difficultyScreen .difficulty-grid { flex: 1; min-height: 0; width: min(1050px, 100%); }
#cookScreen.active { display: flex; flex-direction: column; padding-top: 14px; padding-bottom: 14px; }
#cookScreen .cook-topline, #cookScreen .order-card { flex: 0 0 auto; }
#cookScreen .order-card { margin-top: 9px; margin-bottom: 12px; }
#cookScreen .cooking-game { flex: 1; min-height: 0; width: min(1040px, 100%); display: flex; flex-direction: column; }
#cookScreen .interactive-stage { flex: 1; min-height: 0; }
#cookScreen .canvas-wrap { height: 100%; }
#cookScreen .canvas-wrap canvas { width: 100%; height: 100%; max-height: none; }

.cooking-game.decorate-mode {
  max-width: 1120px !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "instruction instruction"
    "stage tray"
    "actions tray";
  gap: 11px 15px;
}
.decorate-mode .instruction { grid-area: instruction; min-height: 38px; }
.decorate-mode .gesture-meter { display: none; }
.decorate-mode .interactive-stage { grid-area: stage; width: 100%; }
.decorate-mode .decorate-wrap { height: 100%; min-height: 0; }
.decorate-mode .flat-crepe {
  width: min(500px, 88%, 62vh);
  max-width: calc(100% - 12px);
  max-height: calc(100% - 12px);
}
.decorate-mode .tool-tray {
  grid-area: tray;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.decorate-mode .tray-heading { display: block; text-align: center; margin-bottom: 7px; }
.decorate-mode .tray-heading small { display: block; margin-top: 2px; }
.decorate-mode .real-ingredients { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.decorate-mode .real-ingredient { min-height: 82px; padding: 4px; flex-direction: column; gap: 0; }
.decorate-mode .real-ingredient img { width: 50px; height: 50px; }
.decorate-mode .cream-tools { grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 7px; }
.decorate-mode .cream-tool { min-height: 57px; padding: 4px; }
.decorate-mode .game-actions { grid-area: actions; margin: 0 auto; }
#cookScreen.decorating .order-card { max-width: 1120px; width: 100%; margin-top: 5px; margin-bottom: 8px; }
#cookScreen.decorating .customer { width: 72px; height: 72px; font-size: 2.9rem; }
#cookScreen.decorating .order-speech { padding: 8px 16px; }
#cookScreen.decorating .order-speech::before { top: 24px; }
#cookScreen.decorating .order-speech h2 { font-size: 1.02rem; margin-bottom: 3px; }
#cookScreen.decorating .order-chip { padding: 3px 8px; font-size: .85rem; }
#cookScreen.decorating.free-mode .order-card { display: none; }

.cream-swirl {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  box-shadow: inset -4px -6px 0 rgba(73,39,22,.18), 0 4px 5px rgba(91,53,33,.18);
}
.cream-swirl.vanilla { background: repeating-conic-gradient(from 8deg, #fffef8 0 18deg, #e4cda8 18deg 34deg); }
.cream-swirl.custard { background: repeating-conic-gradient(from 8deg, #fff09b 0 18deg, #d69b22 18deg 34deg); }
.cream-swirl.chocolate { background: repeating-conic-gradient(from 8deg, #a86d4c 0 18deg, #5a301f 18deg 34deg); }
.cream-cursor { width: 32px; height: 32px; border: 0; background: repeating-conic-gradient(#fffef8 0 18deg, #dfc79e 18deg 34deg); box-shadow: 0 4px 7px rgba(70,35,18,.3); }
.cream-cursor[data-type="custard"] { background: repeating-conic-gradient(#fff09b 0 18deg, #d69b22 18deg 34deg); }
.cream-cursor[data-type="chocolate"] { background: repeating-conic-gradient(#a86d4c 0 18deg, #5a301f 18deg 34deg); }

#resultScreen.active { padding: 10px; }
.result-card { max-height: 100%; padding: 12px 20px; }
.result-face { font-size: 3rem; }
.result-card h2 { font-size: clamp(1.55rem, 4vh, 2.5rem); }
.stars { font-size: 1.9rem; line-height: 1.1; }
.result-crepe-canvas { width: min(270px, 66vw, 36vh); margin: 0 auto; }
.result-actions { margin-top: 9px; }

#bookScreen { padding-top: 12px; padding-bottom: 12px; }
#bookScreen .book-heading { margin: 6px auto 12px; }
#bookScreen .mascot-bubble { width: 70px; height: 70px; font-size: 2.8rem; }
#bookScreen .book-grid { flex: 1; min-height: 0; width: min(1050px, 100%); grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 12px; }
#bookScreen .book-entry { min-height: 0; padding: 8px; display: flex; flex-direction: column; }
#bookScreen .book-entry-art { flex: 1; min-height: 0; padding: 7px; }
.book-pager { flex: 0 0 auto; display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 9px; }
.book-pager button { border: 2px solid #c9a16d; border-radius: 999px; background: white; padding: 7px 16px; font-weight: 900; cursor: pointer; }
.book-pager button:disabled { opacity: .35; }

@media (max-height: 760px) and (min-width: 721px) {
  .topbar { height: 66px; padding-top: 6px; padding-bottom: 6px; }
  main { height: calc(100dvh - 66px); }
  .brand-mark { font-size: 2rem; }
  #cookScreen .customer { width: 66px; height: 66px; font-size: 2.7rem; }
  #cookScreen .order-speech { padding: 6px 14px; }
  #cookScreen .order-speech h2 { margin-bottom: 2px; font-size: 1rem; }
  .instruction { min-height: 36px; font-size: 1rem; }
  .gesture-meter { margin-bottom: 8px; }
}

/* iPad portrait: keep the work surface large and the ingredients compact. */
@media (min-width: 721px) and (max-width: 900px) {
  .topbar { height: 60px; padding-top: 4px; padding-bottom: 4px; }
  main { height: calc(100dvh - 60px); }
  #cookScreen.active { padding: 6px 10px 8px; }
  #cookScreen .cook-topline { min-height: 34px; }
  #cookScreen .order-card { margin: 4px auto 6px; }
  #cookScreen .customer { width: 58px; height: 58px; font-size: 2.35rem; }
  #cookScreen .order-speech { padding: 5px 12px; border-width: 3px; }
  #cookScreen .order-speech::before { top: 19px; }
  #cookScreen .order-speech h2 { margin-bottom: 2px; font-size: .94rem; }
  #cookScreen .order-chip { padding: 2px 7px; font-size: .76rem; }
  #cookScreen .cooking-game { width: 100%; padding: 7px; border-width: 3px; }
  #cookScreen .instruction { min-height: 34px; font-size: .92rem; }
  #cookScreen .gesture-meter { height: 11px; margin-bottom: 5px; }
  #cookScreen .interactive-stage { width: 100%; max-width: 860px; }

  .cooking-game.decorate-mode { display: flex !important; gap: 5px; }
  .decorate-mode .interactive-stage { flex: 1 1 auto; min-height: 0; }
  .decorate-mode .decorate-wrap { height: 100%; min-height: 0; }
  .decorate-mode .flat-crepe { width: min(520px, 88vw, 54vh); }
  .decorate-mode .tool-tray { flex: 0 0 auto; height: auto; padding: 5px 7px; }
  .decorate-mode .tray-heading { margin: 0 0 3px; }
  .decorate-mode .tray-heading small { display: none; }
  .decorate-mode .real-ingredients { grid-template-columns: repeat(8, 1fr); gap: 4px; }
  .decorate-mode .real-ingredient { min-height: 55px; padding: 2px; flex-direction: column; }
  .decorate-mode .real-ingredient img { width: 38px; height: 38px; }
  .decorate-mode .real-ingredient b { font-size: .6rem; line-height: 1; }
  .decorate-mode .cream-tools { gap: 4px; margin-top: 4px; }
  .decorate-mode .cream-tool { min-height: 45px; padding: 2px; }
  .decorate-mode .cream-swirl { width: 34px; height: 34px; }
  .decorate-mode .cream-tool b { font-size: .68rem; }
  .decorate-mode .game-actions { flex: 0 0 auto; }
  #cookScreen.decorating.free-mode .order-card { display: none; }
  #cookScreen.decorating .drop-hint { display: none; }
}

@media (max-width: 720px) {
  main { height: calc(100dvh - 72px); }
  .screen { padding-top: 10px; padding-bottom: 10px; }
  #crepeHomeScreen .hero { min-height: 0; }
  #crepeHomeScreen .hero-copy { padding-top: 18px; }
  #crepeHomeScreen h1 { font-size: clamp(1.9rem, 8vw, 2.7rem); margin-bottom: 13px; }
  #crepeHomeScreen .big-choice { min-height: 76px; }
  #difficultyScreen .section-heading { margin: 8px 6px 10px; }
  #difficultyScreen .mascot-bubble { width: 60px; height: 60px; font-size: 2.5rem; }
  #difficultyScreen .section-heading h2 { font-size: 1.5rem; }
  #difficultyScreen .difficulty-grid { grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 8px; }
  #difficultyScreen .difficulty-card { min-height: 0; padding: 7px 14px; grid-template-columns: 76px 1fr; }
  #difficultyScreen .difficulty-art { font-size: 3.5rem; }
  #difficultyScreen .difficulty-card b { font-size: 1.35rem; }
  #difficultyScreen .difficulty-card small { font-size: .82rem; line-height: 1.25; }
  #cookScreen.active { padding: 6px 8px; }
  #cookScreen .cook-topline { min-height: 34px; }
  #cookScreen .order-card { margin: 4px auto 7px; }
  #cookScreen .customer { width: 58px; height: 58px; font-size: 2.3rem; }
  #cookScreen .order-speech { padding: 5px 10px; border-width: 3px; }
  #cookScreen .order-speech::before { width: 13px; height: 13px; left: -9px; top: 19px; border-width: 3px; }
  #cookScreen .order-speech h2 { font-size: .9rem; margin: 0 0 2px; }
  #cookScreen .order-chip { padding: 2px 6px; font-size: .75rem; }
  #cookScreen .cooking-game { padding: 6px; border-width: 3px; }
  #cookScreen .instruction { min-height: 34px; font-size: .88rem; }
  #cookScreen .instruction span { width: 26px; height: 26px; }
  #cookScreen .gesture-meter { height: 11px; margin-bottom: 5px; }
  .cooking-game.decorate-mode { display: flex !important; gap: 5px; }
  .decorate-mode .interactive-stage { flex: 1 1 52%; min-height: 0; }
  .decorate-mode .decorate-wrap { min-height: 0; height: 100%; }
  .decorate-mode .flat-crepe { width: min(285px, 74vw, 34vh); }
  .decorate-mode .tool-tray { flex: 0 0 auto; height: auto; padding: 5px; }
  .decorate-mode .tray-heading { margin: 0 0 3px; }
  .decorate-mode .tray-heading small { display: none; }
  .decorate-mode .real-ingredients { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .decorate-mode .real-ingredient { min-height: 52px; padding: 2px; flex-direction: row; }
  .decorate-mode .real-ingredient img { width: 39px; height: 39px; }
  .decorate-mode .real-ingredient b { font-size: .68rem; }
  .decorate-mode .cream-tools { grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 4px; }
  .decorate-mode .cream-tool { min-height: 48px; flex-direction: row; padding: 2px; }
  .decorate-mode .cream-swirl { width: 36px; height: 36px; }
  .decorate-mode .game-actions { flex: 0 0 auto; }
  #cookScreen.decorating.free-mode .order-card { display: none; }
  #cookScreen.decorating .drop-hint { display: none; }
  #resultScreen .result-card { padding: 8px 12px; }
  #resultScreen .result-face { font-size: 2.4rem; }
  #resultScreen .result-kicker { margin: 0; font-size: .8rem; }
  #resultScreen .stars { font-size: 1.5rem; }
  #resultScreen .coin-reward { padding: 4px 13px; font-size: 1rem; }
  #resultScreen .result-actions { grid-template-columns: 1fr 1fr; gap: 7px; }
  #resultScreen .result-actions button { min-height: 45px; padding: 6px; font-size: .84rem; }
  #bookScreen .book-heading { margin: 3px 0 7px; }
  #bookScreen .book-heading p { display: none; }
  #bookScreen .book-grid { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 7px; }
  #bookScreen .book-entry-art { font-size: 1.3rem; }
  #bookScreen .book-entry-art img:not(.book-crepe-photo):not(.legacy-book-base):not(.legacy-book-topping) { width: 36px; height: 36px; }
  #bookScreen .book-entry b { margin-top: 4px; font-size: .82rem; }
  #bookScreen .book-entry small { font-size: .7rem; }
  .book-detail-card { padding: 18px 12px 14px; }
  .book-detail-card h2 { margin-bottom: 10px; font-size: 1.35rem; }
  .book-material-list { grid-template-columns: repeat(3, 1fr); gap: 5px; }
  .book-material-chip { min-height: 66px; padding: 4px; grid-template-columns: 37px minmax(0, 1fr); gap: 3px; }
  .book-material-chip img, .material-cream { width: 36px; height: 36px; }
  .book-material-chip b { font-size: .68rem; }
  .book-material-chip i { grid-column: 2; font-size: .7rem; }
}

@media (max-height: 620px) {
  .topbar { height: 54px; padding-top: 3px; padding-bottom: 3px; }
  main { height: calc(100dvh - 54px); }
  .brand-mark { font-size: 1.6rem; }
  .brand { line-height: .9; }
  .round-btn { width: 38px; height: 38px; }
  #crepeHomeScreen .eyebrow { display: none; }
  #crepeHomeScreen .hero-copy { padding-top: 12px; }
  #crepeHomeScreen .big-choice { min-height: 64px; }
}

/* Crepe cooking: spend the viewport on the hands-on surface, not chrome. */
body[data-screen="cookScreen"] .topbar {
  height: 50px;
  padding-top: 3px;
  padding-bottom: 3px;
}
body[data-screen="cookScreen"] .brand-mark { font-size: 1.75rem; }
body[data-screen="cookScreen"] .brand b { font-size: .9rem; }
body[data-screen="cookScreen"] .status-pill {
  padding: 3px 11px;
  border-width: 2px;
  font-size: .95rem;
}
body[data-screen="cookScreen"] .round-btn { width: 38px; height: 38px; border-width: 2px; }
body[data-screen="cookScreen"] main { height: calc(100dvh - 50px); }

#cookScreen.active { padding: 5px 10px 7px; }
#cookScreen .cook-topline { width: min(1280px, 100%); min-height: 34px; }
#cookScreen .back-link { padding: 6px 13px; }
#cookScreen .progress-dots { gap: 6px; }
#cookScreen .progress-dots span { width: 27px; height: 8px; }
#cookScreen .mini-timer { padding: 4px 10px; border-width: 2px; font-size: .92rem; }

/* Free play needs no order panel. Shop orders remain, as one slim row. */
#cookScreen.free-mode .order-card { display: none; }
#cookScreen:not(.free-mode) .order-card {
  width: min(1180px, 100%);
  max-width: none;
  min-height: 45px;
  margin: 2px auto 5px;
  gap: 7px;
}
#cookScreen:not(.free-mode) .customer {
  width: 43px;
  height: 43px;
  border-width: 3px;
  font-size: 1.9rem;
  box-shadow: 0 3px 0 rgba(101, 51, 31, .12);
}
#cookScreen:not(.free-mode) .order-speech {
  min-height: 43px;
  padding: 3px 8px;
  border-width: 2px;
  border-radius: 14px;
  box-shadow: 0 3px 0 #ddbd87;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}
#cookScreen:not(.free-mode) .order-speech::before { display: none; }
#cookScreen:not(.free-mode) .order-speech h2 { display: none; }
#cookScreen:not(.free-mode) .order-label { gap: 6px; white-space: nowrap; }
#cookScreen:not(.free-mode) .order-label button { width: 29px; height: 29px; }
#cookScreen:not(.free-mode) .order-items {
  min-height: 0;
  gap: 5px;
  flex-wrap: nowrap;
  overflow: hidden;
}
#cookScreen:not(.free-mode) .order-chip { padding: 2px 7px; font-size: .78rem; white-space: nowrap; }

#cookScreen .cooking-game {
  width: min(1280px, 100%);
  max-width: 1280px;
  padding: 6px;
  border-width: 3px;
  border-radius: 24px;
}
#cookScreen .instruction { min-height: 32px; font-size: .95rem; }
#cookScreen .instruction span { width: 26px; height: 26px; }
#cookScreen .gesture-meter { width: min(720px, 88%); height: 10px; margin-bottom: 4px; padding: 2px; }
#cookScreen .interactive-stage { width: min(940px, 100%); height: 100%; margin: 0 auto; }
#cookScreen .canvas-wrap { border-width: 3px; border-radius: 22px; }
#cookScreen .game-actions { min-height: 44px; margin-top: 4px; }
#cookScreen .game-actions button { min-height: 42px; padding-top: 6px; padding-bottom: 6px; }

/* Decoration keeps the large, easy-to-tap ingredient cards. */
#cookScreen .cooking-game.decorate-mode {
  max-width: 1280px !important;
  grid-template-columns: minmax(0, 1fr) 330px;
  grid-template-rows: 32px minmax(0, 1fr) 44px;
  gap: 6px 10px;
}
.decorate-mode .instruction { min-height: 32px; }
.decorate-mode .flat-crepe { width: min(690px, 94%, 72vh); }
.decorate-mode .tool-tray {
  align-self: center;
  height: auto;
  padding: 9px;
  justify-content: center;
  overflow: hidden;
}
.decorate-mode .real-ingredient { min-height: 82px; }
.decorate-mode .cream-tool { min-height: 60px; }
.decorate-mode .game-actions { min-height: 44px; }

@media (min-width: 721px) and (max-width: 900px) {
  #cookScreen .cooking-game.decorate-mode { gap: 6px; }
  .decorate-mode .flat-crepe { width: min(610px, 92vw, 66vh); }
  .decorate-mode .tool-tray { padding: 8px; }
  .decorate-mode .real-ingredient { min-height: 68px; padding: 4px; }
  .decorate-mode .real-ingredient img { width: 47px; height: 47px; }
  .decorate-mode .cream-tool { min-height: 58px; padding: 4px; }
  .decorate-mode .cream-swirl { width: 42px; height: 42px; }
}

/* Keep the complete crepe inside its board, including its thick edge. */
#cookScreen .decorate-mode .flat-crepe {
  max-width: calc(100% - 28px);
  max-height: calc(100% - 28px);
}
#cookScreen.free-mode .decorate-mode .flat-crepe {
  width: min(690px, calc(100% - 28px), calc(100dvh - 228px));
}
#cookScreen:not(.free-mode) .decorate-mode .flat-crepe {
  width: min(690px, calc(100% - 28px), calc(100dvh - 280px));
}

/* The finished crepe and every action stay visible, even in short iPad Safari viewports. */
body[data-screen="resultScreen"] .topbar {
  height: 50px;
  padding-top: 3px;
  padding-bottom: 3px;
}
body[data-screen="resultScreen"] .brand-mark { font-size: 1.75rem; }
body[data-screen="resultScreen"] .brand b { font-size: .9rem; }
body[data-screen="resultScreen"] .status-pill {
  padding: 3px 11px;
  border-width: 2px;
  font-size: .95rem;
}
body[data-screen="resultScreen"] .round-btn { width: 38px; height: 38px; border-width: 2px; }
body[data-screen="resultScreen"] main { height: calc(100dvh - 50px); }

#resultScreen.active { padding: 6px; }
#resultScreen .result-card {
  width: min(680px, 100%);
  height: 100%;
  max-height: 100%;
  padding: 6px 16px 8px;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto;
  justify-items: center;
  gap: 2px;
}
#resultScreen .result-face { font-size: 2.35rem; line-height: 1; }
#resultScreen .result-kicker { margin: 0; line-height: 1.1; }
#resultScreen .result-card h2 { margin: 0; font-size: clamp(1.45rem, 3.7vh, 2.25rem); line-height: 1.08; }
#resultScreen .stars { font-size: 1.7rem; line-height: 1; }
#resultScreen .result-crepe-canvas {
  width: auto;
  height: 100%;
  min-height: 0;
  max-width: min(280px, 70vw);
  max-height: 100%;
  margin: 0 auto;
  object-fit: contain;
}
#resultScreen .coin-reward { padding: 4px 14px; font-size: 1rem; }
#resultScreen .result-actions {
  width: min(620px, 100%);
  margin-top: 3px;
  gap: 8px;
}
#resultScreen .result-actions button { min-height: 44px; padding: 6px 10px; }

/*
 * Screen fitting layer
 * Safari changes its visible height as its toolbars open and close. Keep a
 * 720px-tall landscape layout and scale that complete layout into the space
 * actually visible to the child, instead of clipping individual panels.
 */
:root { --screen-fit-header: 84px; }
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
#app {
  width: var(--screen-fit-width, 100vw);
  height: var(--screen-fit-height, 100dvh);
  min-height: 0;
  transform: scale(var(--screen-fit-scale, 1));
  transform-origin: left top;
}
#app main {
  height: calc(var(--screen-fit-height, 100dvh) - var(--screen-fit-header));
  min-height: 0;
}
#app .screen { height: 100%; min-height: 0; }
#cookScreen.free-mode .decorate-mode .flat-crepe {
  width: min(690px, calc(100% - 28px), calc(var(--screen-fit-height, 100dvh) - 228px));
}
#cookScreen:not(.free-mode) .decorate-mode .flat-crepe {
  width: min(690px, calc(100% - 28px), calc(var(--screen-fit-height, 100dvh) - 280px));
}

@media (max-height: 760px) and (min-width: 721px) {
  :root { --screen-fit-header: 66px; }
}
@media (min-width: 721px) and (max-width: 900px) {
  :root { --screen-fit-header: 60px; }
}
@media (max-width: 720px) {
  :root { --screen-fit-header: 72px; }
}
@media (max-height: 620px) {
  :root { --screen-fit-header: 54px; }
}
body[data-screen="cookScreen"],
body[data-screen="resultScreen"] { --screen-fit-header: 50px; }
