:root {
  --ink: #3f372f;
  --orange: #f47b20;
  --orange-dark: #bd4f12;
  --accent: #f47b20;
  --cream: #fff7df;
  --dock-h: 174px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; color: var(--ink); background: #fff0c9; touch-action: none; user-select: none; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.game-shell { position: relative; width: 100%; height: 100%; min-height: 560px; overflow: hidden; }

.topbar {
  position: absolute;
  z-index: 20;
  inset: 0 0 auto;
  height: 90px;
  display: grid;
  grid-template-columns: 75px 1fr 75px;
  align-items: center;
  padding: 7px 16px;
  background: linear-gradient(180deg, rgba(255,244,207,.99), rgba(255,244,207,.9));
  backdrop-filter: blur(8px);
}

.round-button {
  width: 54px;
  height: 54px;
  border: 3px solid rgba(255,255,255,.92);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #5c584f;
  background: rgba(255,255,255,.72);
  box-shadow: 0 5px 0 rgba(116,91,57,.19), 0 8px 18px rgba(96,72,45,.14);
  font-size: 41px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
.reset-button { justify-self: end; font-size: 34px; }
.round-button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(116,91,57,.19); }
.title-block { text-align: center; }
.title-block h1 { margin: 0; font-size: clamp(30px, 3.1vw, 45px); line-height: 1; letter-spacing: 1px; color: #29364e; text-shadow: 0 3px 0 white; }
.title-block p { margin: 5px 0 0; color: #80673f; font-size: clamp(15px, 1.45vw, 20px); font-weight: 900; }

.kitchen {
  position: absolute;
  inset: 88px 24px var(--dock-h);
  overflow: hidden;
  border: 5px solid rgba(255,255,255,.86);
  border-radius: 25px;
  background: url("../shared/generated_assets/little_chef_bg_optimized.webp") center 50% / cover no-repeat;
  box-shadow: 0 9px 27px rgba(140,85,31,.17), inset 0 0 0 2px rgba(209,136,48,.13);
}
.kitchen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 60%, rgba(255,255,255,.11) 0 24%, rgba(255,248,218,.02) 55%, rgba(104,65,25,.08) 100%);
}

.recipe-badge, .step-badge {
  position: absolute;
  z-index: 7;
  top: 12px;
  padding: 7px 15px;
  border: 2px solid white;
  border-radius: 999px;
  background: rgba(255,255,255,.86);
  box-shadow: 0 4px 11px rgba(86,58,29,.14);
  color: #705437;
  font-size: 15px;
  font-weight: 800;
}
.recipe-badge { left: 14px; }
.recipe-badge strong { color: var(--accent); }
.step-badge { right: 14px; color: #4f7190; }

.cook-stage {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 2px;
  width: min(47vw, 520px);
  height: calc(100% - 40px);
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: transform .18s, filter .18s;
}
.cook-stage.drop-ready { transform: translateX(-50%) scale(1.025); filter: drop-shadow(0 0 18px #fff06b); }
.cook-stage.wrong { animation: stage-shake .34s ease; }
.stage-halo { position: absolute; left: 50%; bottom: 15px; width: 90%; height: 66%; transform: translateX(-50%); border-radius: 46%; background: rgba(255,250,213,.44); filter: blur(13px); }
.stage-image {
  position: relative;
  z-index: 3;
  width: auto;
  height: min(100%, 490px);
  max-width: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 10px 7px rgba(83,52,24,.22));
  transition: opacity .14s ease, transform .26s cubic-bezier(.18,.9,.28,1.2);
}
.stage-image.changing { opacity: .2; transform: scale(.88); }
.stage-image.pop { animation: food-pop .48s cubic-bezier(.15,.9,.25,1.2); }
.stage-image.baking { animation: oven-bob 1s ease-in-out infinite; }

.baking-badge {
  position: absolute;
  z-index: 8;
  top: 18px;
  left: 50%;
  width: 200px;
  padding: 9px 14px 12px;
  transform: translateX(-50%);
  border: 3px solid white;
  border-radius: 19px;
  color: #a14412;
  background: rgba(255,239,182,.94);
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 6px 15px rgba(110,64,22,.16);
}
.baking-badge i { display: block; height: 8px; margin-top: 7px; overflow: hidden; border-radius: 999px; background: rgba(190,99,25,.18); }
.baking-badge b { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#ffbd35,#f66c22); animation: bake-progress 1.85s linear forwards; }

.praise {
  position: absolute;
  z-index: 12;
  top: 55px;
  left: 50%;
  min-width: 185px;
  transform: translate(-50%,-14px) scale(.78);
  opacity: 0;
  padding: 8px 19px;
  border: 3px solid white;
  border-radius: 999px;
  background: #fff1a6;
  color: #aa5418;
  text-align: center;
  font-size: clamp(18px,1.9vw,26px);
  font-weight: 900;
  box-shadow: 0 6px 16px rgba(100,58,22,.18);
  pointer-events: none;
}
.praise.show { animation: praise-in 1.1s ease both; }

.cook-effects { position: absolute; z-index: 6; inset: 6% 4% 3%; overflow: hidden; pointer-events: none; }
.ingredient-speck { position: absolute; border-radius: 50%; background: var(--color); animation: speck-fall var(--duration) ease-in forwards; }
.swirl { position: absolute; left: 50%; bottom: 22%; width: 250px; height: 115px; transform: translateX(-50%); border: 7px solid rgba(255,231,131,.72); border-left-color: transparent; border-radius: 50%; animation: swirl-spin .75s linear infinite; }
.spark { position: absolute; color: #ffe242; font-size: var(--size); text-shadow: 0 0 5px white; animation: sparkle-pop 1.15s ease-out forwards; }

.tool-dock {
  position: absolute;
  z-index: 24;
  left: 24px;
  right: 24px;
  bottom: 10px;
  height: calc(var(--dock-h) - 14px);
  border: 4px solid rgba(255,255,255,.91);
  border-radius: 26px;
  background: linear-gradient(180deg,rgba(255,255,255,.95),rgba(255,242,209,.95));
  box-shadow: 0 8px 24px rgba(120,76,31,.18);
}
.progress-dots { position: absolute; z-index: 4; top: 8px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: #e3d1ac; transition: width .2s, background .2s; }
.dot.active { width: 27px; border-radius: 999px; background: var(--accent); }
.dot.done { background: #6dc68b; }
.tools { height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: clamp(11px,2.8vw,40px); padding: 27px 12px 11px; }
.tool-card {
  width: clamp(104px,12.5vw,154px);
  height: 112px;
  border: 3px solid rgba(255,255,255,.96);
  border-radius: 21px;
  background: rgba(255,255,255,.66);
  color: #55483c;
  box-shadow: 0 6px 0 #e2c99c, 0 9px 16px rgba(101,69,35,.15);
  cursor: grab;
  touch-action: none;
  transition: transform .18s,opacity .2s,filter .2s;
}
.tool-card img { width: 78px; height: 78px; object-fit: contain; pointer-events: none; filter: drop-shadow(0 5px 5px rgba(68,45,26,.18)); }
.tool-card span { display: block; margin-top: -8px; font-size: 15px; font-weight: 900; pointer-events: none; }
.tool-card.expected { border-color: var(--accent); animation: expected-pulse 1.35s ease-in-out infinite; }
.tool-card.used { opacity: .3; filter: grayscale(.4); pointer-events: none; transform: scale(.91); box-shadow: 0 3px 0 #e2c99c; }
.tool-card:not(.used):active { cursor: grabbing; transform: translateY(4px) scale(.97); box-shadow: 0 2px 0 #e2c99c; }

.tools[data-count="3"] .tool-card { width: clamp(120px,15vw,174px); }
.tools[data-count="4"] .tool-card { width: clamp(112px,13.5vw,160px); }

.finish-panel { height: 100%; padding: 14px 28px; display: flex; align-items: center; justify-content: center; gap: clamp(35px,8vw,120px); }
.finish-copy { display: flex; flex-direction: column; color: #7b654a; font-size: 15px; font-weight: 800; }
.finish-copy strong { color: var(--accent); font-size: clamp(23px,2.2vw,31px); }
.again-button {
  min-width: 205px;
  height: 72px;
  padding: 0 27px;
  border: 4px solid white;
  border-radius: 23px;
  background: linear-gradient(180deg,color-mix(in srgb,var(--accent),white 22%),var(--accent));
  color: white;
  box-shadow: 0 7px 0 #ba4714, 0 11px 20px rgba(118,57,22,.23);
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
  animation: again-breathe 1.7s ease-in-out infinite;
}
.again-button span { margin-left: 8px; font-size: 28px; }
.again-button:active { transform: translateY(5px); box-shadow: 0 2px 0 #ba4714; }

.drag-ghost { position: fixed; z-index: 999; width: 116px; height: 116px; display: none; place-items: center; transform: translate(-50%,-50%); border: 4px solid white; border-radius: 50%; background: rgba(255,255,255,.88); box-shadow: 0 10px 28px rgba(75,48,23,.25); pointer-events: none; }
.drag-ghost.visible { display: grid; }
.drag-ghost img { width: 90px; height: 90px; object-fit: contain; }

@keyframes stage-shake { 25% { transform:translateX(calc(-50% - 13px)) rotate(-2deg); } 55% { transform:translateX(calc(-50% + 12px)) rotate(2deg); } 80% { transform:translateX(calc(-50% - 5px)); } }
@keyframes food-pop { 0% { transform:scale(.84); } 68% { transform:scale(1.06); } 100% { transform:scale(1); } }
@keyframes oven-bob { 50% { transform:translateY(-4px); filter:drop-shadow(0 13px 10px rgba(239,91,18,.28)); } }
@keyframes bake-progress { to { width:100%; } }
@keyframes praise-in { 0% { opacity:0; transform:translate(-50%,-14px) scale(.76); } 22%,72% { opacity:1; transform:translate(-50%,0) scale(1); } 100% { opacity:0; transform:translate(-50%,-12px) scale(.93); } }
@keyframes expected-pulse { 50% { transform:translateY(-4px); box-shadow:0 10px 0 #e6bc7d,0 13px 20px rgba(101,69,35,.17); } }
@keyframes again-breathe { 50% { transform:translateY(-3px) scale(1.025); } }
@keyframes speck-fall { 0% { transform:translateY(-35px) scale(.5); opacity:0; } 15% { opacity:1; } 100% { transform:translate(var(--drift),390px) scale(1); opacity:0; } }
@keyframes swirl-spin { to { transform:translateX(-50%) rotate(360deg); } }
@keyframes sparkle-pop { 0% { transform:scale(.1) rotate(0); opacity:0; } 35% { opacity:1; transform:scale(1.2) rotate(80deg); } 100% { transform:scale(.25) rotate(160deg); opacity:0; } }

@media (max-width: 780px), (max-height: 620px) {
  :root { --dock-h: 148px; }
  .topbar { height: 75px; padding: 5px 9px; grid-template-columns:56px 1fr 56px; }
  .round-button { width:46px; height:46px; font-size:35px; }
  .reset-button { font-size:29px; }
  .title-block h1 { font-size:28px; }
  .title-block p { margin-top:3px; font-size:13px; }
  .kitchen { inset:73px 7px var(--dock-h); border-width:3px; border-radius:18px; }
  .recipe-badge,.step-badge { top:7px; padding:5px 8px; font-size:11px; }
  .recipe-badge { left:7px; }
  .step-badge { right:7px; }
  .cook-stage { width:min(82vw,410px); height:calc(100% - 30px); }
  .praise { top:42px; font-size:17px; }
  .tool-dock { left:7px; right:7px; bottom:5px; height:calc(var(--dock-h) - 8px); border-width:3px; border-radius:18px; }
  .tools { gap:5px; padding:24px 5px 8px; }
  .tool-card { width:19%; min-width:0; height:99px; border-radius:15px; padding:2px; }
  .tools[data-count="3"] .tool-card { width:30%; max-width:132px; }
  .tools[data-count="4"] .tool-card { width:23%; max-width:119px; }
  .tool-card img { width:61px; height:67px; }
  .tool-card span { font-size:12px; }
  .finish-panel { padding:9px 13px; gap:18px; }
  .finish-copy { max-width:50%; font-size:11px; }
  .finish-copy strong { font-size:19px; }
  .again-button { min-width:155px; height:60px; padding:0 14px; font-size:19px; }
}

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