* {box-sizing: border-box;}
html, body {margin: 0; min-height: 100%;}
body {display: grid; place-items: center; background: #3d2a21; color: #54200d; font-family: 'Microsoft YaHei', system-ui, sans-serif;}
button, a {-webkit-tap-highlight-color: transparent; touch-action: manipulation;}
button {font: inherit; cursor: pointer; color: inherit;}
button:disabled {cursor: default; opacity: .48;}
button:focus-visible, a:focus-visible, canvas:focus-visible {outline: 3px solid #71834d; outline-offset: 3px;}
[hidden] {display: none !important;}
.sg-game {position: relative; isolation: isolate; container-type: inline-size; width: min(100vw, calc(100svh * .61)); min-width: 300px; height: 100svh; min-height: 640px; overflow: hidden; background: var(--sg-scene) center / cover, #e8b579; box-shadow: 0 0 70px #150f0c88;}
.sg-layout {height: 100%; padding: max(8px, env(safe-area-inset-top)) 2.5cqw max(6px, env(safe-area-inset-bottom)); display: grid; grid-template-rows: 16cqw 8cqw 23cqw 11cqw minmax(220px, 1fr) 22cqw 6cqw; gap: 1cqw;}
.sg-heading {display: grid; grid-template-columns: 12cqw 1fr 12cqw; gap: 2cqw; align-items: center;}
.sg-heading h1 {margin: 0; text-align: center; white-space: nowrap; color: #54200d; font: 900 10.2cqw/1.2 'Noto Serif SC', 'STKaiti', serif; letter-spacing: -.3cqw; text-shadow: 0 1px #ffdfb1;}
.sg-icon-button {display: grid; place-items: center; width: 11cqw; height: 11cqw; min-width: 44px; min-height: 44px; border: 2px solid #6c3318; border-radius: 3cqw; background: #fff2d7; box-shadow: 0 2px #b9753d; color: #632b13;}
.sg-icon-button svg {width: 6.3cqw; height: 6.3cqw; fill: none; stroke: currentColor; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round;}
.sg-status {display: flex; align-items: center; justify-content: space-evenly; gap: 3cqw; margin: 0 15cqw; white-space: nowrap; font: 800 3.9cqw/1.2 'Noto Serif SC', 'Microsoft YaHei', serif; background: #ffefd3; border: 1.5px solid #b57136; border-radius: 6cqw; box-shadow: inset 0 0 0 3px #fff6dc;}
.sg-status span + span {padding-left: 3cqw; border-left: 1px solid #c58b4e;}
.sg-orders {display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: center; gap: .5cqw; min-height: 0;}
.sg-order {position: relative; height: 100%; min-width: 0; border: 0; background: transparent; padding: 0;}
.sg-order > .sg-dish-art {width: 100%; height: 100%; object-fit: contain;}
.sg-order .sg-order-food {position: absolute; width: 52%; height: 65%; left: 24%; top: 6%; object-fit: contain; filter: drop-shadow(0 2px 1px #5c341932);}
.sg-order .sg-count {position: absolute; left: 27%; right: 27%; bottom: -1%; border-radius: 4cqw; border: 1px solid #b67e42; color: #5d2a14; background: #fff0d0; font: 800 3.7cqw/1.35 'Noto Serif SC', serif; text-align: center;}
.sg-order-add svg {position: absolute; left: 37%; top: 24%; width: 26%; height: 40%; stroke: #9b693c; stroke-width: 5; stroke-linecap: round;}
.sg-order.is-idle {opacity: .5;}
.sg-buffer {display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .5cqw; margin: 0 3cqw;}
.sg-small-dish {position: relative; min-width: 0; height: 100%;}
.sg-small-dish .sg-dish-art {width: 100%; height: 100%; object-fit: fill;}
.sg-small-dish .sg-buffer-food {position: absolute; width: 63%; height: 90%; object-fit: contain; left: 19%; top: -8%;}
.sg-buffer.is-full {filter: drop-shadow(0 0 5px #b33319);}
.sg-stage {position: relative; min-width: 0; min-height: 0; margin: 0 -2.5cqw;}
#sgCanvas {display: block; width: 100%; height: 100%; touch-action: manipulation; user-select: none; -webkit-user-select: none;}
.sg-tools {display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2cqw; padding: 0 2cqw;}
.sg-tools button {position: relative; display: grid; grid-template-rows: minmax(0, 1fr) auto; align-items: center; justify-items: center; gap: .5cqw; min-width: 0; border: 2px solid #ba7b38; border-radius: 3.5cqw; padding: 1.5cqw 1cqw; background: #ffedc7; box-shadow: inset 0 0 0 3px #fff7dc, 0 3px #b87a3a;}
.sg-tool-art {display: block; width: 100%; height: 100%; min-height: 0;}
.sg-tool-art canvas {width: 100%; height: 100%; object-fit: contain;}
.sg-tools b {font: 900 4.5cqw/1.2 'Noto Serif SC', 'Microsoft YaHei', serif;}
.sg-tools small {position: absolute; right: 1.4cqw; top: 1.4cqw; max-width: calc(100% - 2.8cqw); padding: .6cqw 1cqw; border-radius: 3cqw; background: #fff4dbee; font: 800 2.7cqw/1.1 system-ui; white-space: nowrap;}
.sg-hint {margin: 0; align-self: center; text-align: center; font: 700 3.1cqw/1.3 'Noto Serif SC', 'Microsoft YaHei', serif; color: #733b19; white-space: nowrap;}
.sg-loading {position: absolute; inset: 0; z-index: 10; display: grid; align-content: center; justify-items: center; gap: 16px; padding: 28px; text-align: center; background: #f5d7a1;}
.sg-loading h2 {margin: 0; font: 900 36px 'Noto Serif SC', serif;}
.sg-loading p {font-size: 14px;}
.sg-loading progress {width: min(100%, 260px); height: 12px; accent-color: #bf582d;}
.sg-loading button {padding: 10px 24px; background: #fff0ce; border: 1px solid #925025; border-radius: 9px; min-height: 44px;}
.sg-menu {width: min(88%, 370px); max-height: calc(100dvh - 40px); overflow: auto; padding: 25px; color: #5a2d16; background: #fff0d0; border: 2px solid #a16b35; border-radius: 22px; box-shadow: 0 10px 50px #3a1e1a55; text-align: center;}
.sg-menu::backdrop {background: #3e221d83;}
.sg-menu h2 {margin: 0 0 12px; font: 900 27px/1.4 'Noto Serif SC', 'Microsoft YaHei', serif;}
.sg-menu p {margin: 0 0 20px; font-size: 14px; line-height: 1.8; white-space: pre-line;}
#sgMenuActions {display: grid; gap: 10px;}
#sgMenuActions button {min-height: 46px; padding: 10px 15px; color: #fff6df; background: #b3502b; border: 1px solid #853d21; border-radius: 11px; font-weight: 700;}
#sgMenuActions button.sg-secondary {background: #f7dfb5; color: #6e3c23; border-color: #c19660;}
.sg-flying {position: absolute; z-index: 8; pointer-events: none; width: 15cqw; height: 15cqw;}
.sg-flying canvas {width: 100%; height: 100%; object-fit: contain;}
.sg-keyboard {position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);}
.sg-keyboard:focus-within {width: calc(100% - 24px); height: auto; max-height: 140px; overflow: auto; clip-path: none; left: 12px; bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; background: #fff4dbeF; border: 1px solid #a36d36; border-radius: 8px;}
.sg-keyboard button {min-height: 44px; padding: 6px 10px; border: 1px solid #b88b53; border-radius: 6px; background: #fff5df;}
@media (max-width: 350px) {.sg-layout {grid-template-rows: 17cqw 9cqw 24cqw 12cqw minmax(220px, 1fr) 23cqw 7cqw;}.sg-status {margin: 0 12cqw;}.sg-heading h1 {font-size: 9.5cqw;}.sg-hint {font-size: 3cqw;}}
@media (prefers-reduced-motion: reduce) {* {scroll-behavior: auto !important;}}

.sg-add-button {position: absolute; inset: 0; width: 100%;}
.sg-flying {left: 0; top: 0;}

.sg-tools {grid-template-rows: minmax(0, 1fr); min-height: 0;}
.sg-tools button {height: 100%; min-height: 0; overflow: hidden;}
.sg-tool-art {position: relative;}
.sg-tool-art canvas {position: absolute; inset: 0;}
.sg-dish-art {transform: rotate(13deg);}
#sgCanvas:focus {outline: none;}
.sg-order-add .sg-add-button {transform: none;}
.sg-orders {grid-template-columns:repeat(4,minmax(0,1fr));gap:0;}
.sg-order .sg-count {left:23%;right:23%;font-size:3.4cqw;bottom:3%;}
.sg-order .sg-order-food {width:58%;left:21%;height:62%;}
.sg-lock {position:absolute;inset:10% 4%;display:flex;flex-direction:column;justify-content:center;align-items:center;border:0;border-radius:50%;background:#fff1d4db;font-weight:800;font-size:3cqw;}
.sg-lock strong {font-size:6cqw;line-height:1.1;}
.sg-home {position:absolute;inset:0;z-index:3;background:var(--sg-home) center/cover,#e4c69a;display:flex;flex-direction:column;align-items:center;}
.sg-home header {width:100%;display:flex;align-items:center;justify-content:space-between;padding:max(12px,env(safe-area-inset-top)) 4cqw 0;}
.sg-home header a,.sg-home header button {color:#603719;font-weight:800;font-size:3.5cqw;background:#fff1d7e8;border:1.5px solid #ad794a;border-radius:3cqw;padding:2cqw 3cqw;text-decoration:none;min-height:40px;}
.sg-home h1 {margin:1cqw 0 0;font:900 12cqw/1.2 'Noto Serif SC',serif;color:#672e1b;text-shadow:0 2px #fff3d8,0 -1px #fff3d8;letter-spacing:1cqw;}
.sg-home-subtitle {margin:1.5cqw 0;font-size:3cqw;font-weight:700;color:#643c25;}
.sg-home-footer {position:absolute;bottom:max(7cqw,env(safe-area-inset-bottom));width:88%;display:grid;gap:3cqw;}
.sg-home-record {display:flex;justify-content:space-between;align-items:center;background:#fff1d7ea;border:1px solid #bd8a55;border-radius:8cqw;padding:2cqw 4cqw;font-size:3.3cqw;font-weight:700;}
.sg-home-record button {border:0;background:transparent;padding:0;font-size:3.2cqw;min-height:28px;}
.sg-start {min-height:16cqw;background:#b65a2f;color:#fff7dc;border:2px solid #743c21;border-radius:4cqw;box-shadow:inset 0 0 0 2px #de9c62,0 5px #814021;font:900 7cqw 'Noto Serif SC',serif;}
.sg-home-footer nav {display:grid;grid-template-columns:repeat(3,1fr);gap:3cqw;}
.sg-home-footer nav button {border:1.5px solid #ae7749;border-radius:3cqw;display:grid;justify-items:center;gap:1cqw;background:#fff0d8ed;padding:2cqw 1cqw;font-size:3.2cqw;font-weight:800;}
.sg-home-footer nav span {font:900 6cqw 'Noto Serif SC',serif;line-height:1.2;color:#9f512d;}
.sg-home-footer small {font-size:2.7cqw;}
.sg-home-notice {position:absolute;bottom:1cqw;text-align:center;font-size:2.6cqw;max-width:94%;margin:0;background:#fff1d9d9;border-radius:2cqw;padding:.6cqw 2cqw;}
.sg-menu.is-wide {width:min(94%,480px);padding:18px;}
.sg-theme-grid {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;}
.sg-theme-grid button {display:grid;justify-items:center;gap:2px;background:#fff8e6!important;color:#70472a!important;padding:6px!important;font-size:12px;min-width:0;}
.sg-theme-grid canvas {height:58px;width:100%;object-fit:contain;}
.sg-theme-grid .is-selected {outline:3px solid #869b54;outline-offset:-3px;}
.sg-theme-grid .is-locked canvas {filter:grayscale(1);opacity:.3;}
.sg-theme-grid small {font-size:10px;}
.sg-pages {display:flex;gap:12px;align-items:center;justify-content:center;}
.sg-pages button {min-width:54px;}
.sg-rank-row {display:grid;grid-template-columns:26px minmax(0,1fr) 68px;gap:8px;padding:10px 4px;border-bottom:1px solid #dfbe8f;font-size:13px;text-align:left;}
.sg-rank-row span {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.sg-rank-row.is-mine {background:#e3e5bb;font-weight:800;}
.sg-shop-note {font-size:12px;color:#80512f;}
.sg-tools button:active,.sg-start:active {transform:translateY(2px);}
@media (max-height:700px) {.sg-game {min-height:520px;width:min(100vw,calc(100svh * .65));}.sg-layout {grid-template-rows:14cqw 7cqw 21cqw 10cqw minmax(150px,1fr) 20cqw 6cqw;}.sg-home-footer {bottom:5cqw;gap:2cqw;}.sg-home h1 {font-size:10cqw;}.sg-home-footer nav span {font-size:5cqw;}}

/* Keep the complete chef above a compact menu anchored to the bottom ground. */
.sg-home {background:#ecd5b3;}
.sg-home::before {content:"";position:absolute;inset:0 0 16%;background:var(--sg-home) center bottom/cover no-repeat;pointer-events:none;}
.sg-home::after {content:"";position:absolute;inset:67% 0 0;background:linear-gradient(180deg,transparent 0%,#eed8b900 10%,#eed8b9ed 48%,#efdbbd 100%);pointer-events:none;}
.sg-home > * {z-index:1;}
.sg-home header {position:relative;min-height:12cqw;padding:max(8px,env(safe-area-inset-top)) 4cqw 0;}
.sg-home header a,.sg-home header button {font-size:2.9cqw;padding:1.5cqw 2.5cqw;border-radius:5cqw;min-height:36px;background:#fff5dfeF;box-shadow:inset 0 0 0 2px #fff9e9,0 2px 3px #70442122;}
.sg-home header button {min-width:36px;font-size:5cqw;line-height:1;}
.sg-home h1 {position:relative;margin:.5cqw 0 0;width:78%;height:22cqw;display:grid;place-items:center;font-size:9cqw;letter-spacing:.5cqw;}
.sg-home-art-ready .sg-home h1 {display:block;background:var(--sg-title-art) center/contain no-repeat;color:transparent;text-shadow:none;font-size:0;overflow:hidden;}
.sg-home-subtitle {position:relative;margin:1cqw 0 0;padding:.6cqw 2.5cqw;border-radius:4cqw;background:#fff4dcd9;font-size:2.7cqw;letter-spacing:.12cqw;color:#71472a;}
.sg-home-footer {position:absolute;bottom:max(19px,calc(env(safe-area-inset-bottom) + 12px));width:88%;gap:1.2cqw;}
.sg-home-record {min-height:7cqw;padding:1.1cqw 3.6cqw;background:#fff5e4ed;border:1px solid #bc965f;border-radius:5cqw;font-size:2.8cqw;box-shadow:inset 0 0 0 2px #fff9e5;}
.sg-home-record button {min-height:22px;font-size:2.7cqw;}
.sg-start {min-height:13.5cqw;font-size:5.2cqw;letter-spacing:.4cqw;}
.sg-home-art-ready .sg-start {background:var(--sg-start-art) center/100% 100% no-repeat;border:0;box-shadow:none;filter:drop-shadow(0 2px 1px #81532c36);color:#fff6dc;text-shadow:0 1px 1px #67371e;font-weight:900;}
.sg-home-footer nav {grid-template-columns:repeat(3,minmax(0,1fr));gap:4cqw;align-items:start;}
.sg-home-footer nav button {position:relative;min-height:19cqw;min-width:0;display:grid;grid-template-rows:11.5cqw auto;align-content:start;align-items:center;gap:1cqw;padding:.5cqw 0 0;border:0;border-radius:0;background:transparent;font-size:2.9cqw;line-height:1.2;color:#6b4025;text-shadow:0 1px #fff5df;}
.sg-home-footer nav span {display:block;width:11.5cqw;height:11.5cqw;font-size:6cqw;line-height:11.5cqw;}
.sg-home-footer nav span canvas {display:block;width:100%;height:100%;object-fit:contain;filter:drop-shadow(0 2px 2px #7d542b30);}
.sg-home-footer nav small {position:absolute;top:1cqw;right:1cqw;border:1px solid #c39b64;border-radius:3cqw;padding:.4cqw 1cqw;background:#fff5dfee;font-size:2.3cqw;line-height:1.1;}
.sg-home-notice {bottom:max(1px,env(safe-area-inset-bottom));font-size:2.2cqw;padding:.3cqw 1.5cqw;background:#fff1d6b8;line-height:1.25;}
.sg-theme-grid button {grid-template-rows:64px auto auto;align-content:center;overflow:hidden;}
.sg-theme-grid canvas {width:100%;height:64px;max-width:100%;object-fit:contain;}
@media (max-height:700px) {.sg-home-footer {bottom:max(17px,calc(env(safe-area-inset-bottom) + 10px));gap:1cqw;}.sg-home header {min-height:10cqw;}.sg-home h1 {height:14cqw;width:70%;}.sg-home-subtitle {display:none;}}
/* Larger cooking area with compact HUD, including short mobile screens. */
.sg-game{width:min(100vw,calc(100svh * .65));min-height:560px}
.sg-layout{padding-top:max(6px,env(safe-area-inset-top));grid-template-rows:10cqw 5.5cqw 16cqw 9cqw minmax(250px,1fr) 16cqw 5cqw;gap:.5cqw}
.sg-heading{grid-template-columns:11cqw 1fr 11cqw}
.sg-icon-button{width:9cqw;height:9cqw;min-height:36px;min-width:36px;border-width:1px}
.sg-timer{justify-self:center;min-width:24cqw;text-align:center;font:800 5.8cqw/1.4 system-ui;font-variant-numeric:tabular-nums;color:#4e391d;background:#fff1d5e6;border:1px solid #a77545;border-radius:8cqw}
.sg-timer.is-urgent{color:#ac2216;background:#ffe2d4}
.sg-status{margin:0 14cqw;font-size:3.1cqw}
.sg-tools{padding:0 5cqw;gap:3cqw}
.sg-tools b{font-size:3.5cqw}.sg-tools small{font-size:2.5cqw}
.sg-stage{overflow:hidden}#sgCanvas{touch-action:none}#sgCanvas[aria-busy=true]{cursor:wait}
.sg-order .sg-count{font-size:3cqw;bottom:0}
.sg-order .sg-count{bottom:1cqw;z-index:2;line-height:1.4}
.sg-order .sg-order-food{height:54%;top:2%}
/* Keep the rotated five small plates below the order-count badges. */
.sg-orders,.sg-buffer{grid-template-rows:minmax(0,1fr)}
.sg-buffer{padding-top:2.5cqw;min-height:0}
.sg-small-dish{min-height:0}
.sg-flying{z-index:12;filter:drop-shadow(0 4px 5px #82592b66)}
@media(max-height:660px){.sg-game{min-height:480px}.sg-layout{grid-template-rows:9cqw 5cqw 14cqw 8cqw minmax(215px,1fr) 14cqw 4.5cqw}.sg-hint{font-size:2.7cqw}}
