:root {
    --cream: #fff6e6;
    --cream-2: #ffe8c8;
    --paper: #fffdf8;
    --brown: #5b3a29;
    --brown-2: #7d5232;
    --muted: #8a6a50;
    --line: #ecd9bb;
    --orange: #ff7a3d;
    --orange-d: #e5601f;
    --green: #2fa37a;
    --red: #d9433f;
    --amber: #e0a526;
    --shadow: 0 10px 30px -14px rgba(91, 58, 41, 0.45);
    --display: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
    --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--body);
    font-size: 17px;
    line-height: 1.55;
    color: var(--brown);
    background:
        radial-gradient(circle at 12% 8%, #ffe2b8 0, transparent 38%),
        radial-gradient(circle at 92% 0%, #ffd9c2 0, transparent 34%),
        var(--cream);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--orange-d); }
a:hover { color: var(--brown); }

button { font-family: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #4a90d9; outline-offset: 3px; }

.page { max-width: 1120px; margin: 0 auto; padding: 28px 18px 64px; }

/* ---------- hero ---------- */
.hero { padding: 18px 0 8px; }
.eyebrow { margin: 0 0 6px; font-weight: 800; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--orange-d); }
h1 { margin: 0 0 10px; font-family: var(--display); font-weight: 700; font-size: clamp(2.4rem, 7vw, 4.2rem); line-height: 1; letter-spacing: -0.01em; }
.lede { margin: 0; max-width: 62ch; font-size: 1.15rem; color: #6b4a37; }
h2 { margin: 0 0 12px; font-family: var(--display); font-weight: 600; font-size: 1.6rem; }

/* ---------- guided tour ---------- */
.tour { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 18px 0 6px; padding: 14px 18px; background: var(--paper); border: 2px solid var(--line); border-left: 8px solid var(--orange); border-radius: 16px; box-shadow: var(--shadow); animation: slide-in .4s ease-out; }
.tour p { margin: 0; flex: 1 1 320px; }
.tour-dots { display: flex; gap: 6px; }
.tour-dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--line); transition: background .3s; }
.tour-dots span.on { background: var(--orange); }
.tour-actions { display: flex; gap: 12px; align-items: center; }
.tour-replay { margin: 14px 0 0; }

/* ---------- layout ---------- */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; margin-top: 16px; align-items: start; }
.scene-card { background: var(--paper); border: 2px solid var(--line); border-radius: 22px; padding: 10px; box-shadow: var(--shadow); }
.panel { display: flex; flex-direction: column; gap: 16px; background: var(--paper); border: 2px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); }
@media (max-width: 900px) { .stage { grid-template-columns: 1fr; } }

/* ---------- controls ---------- */
.control { display: flex; align-items: center; gap: 12px; }
.control.column { flex-direction: column; align-items: stretch; gap: 6px; }
.control strong { display: block; }
.hint { display: block; font-size: .88rem; color: var(--muted); line-height: 1.35; }
.label-text, .control label { font-weight: 700; font-size: .95rem; }
input[type="range"] { width: 100%; accent-color: var(--orange); }

.buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { appearance: none; border: 2px solid var(--brown); background: var(--paper); color: var(--brown); border-radius: 999px; padding: .65rem 1.1rem; font-weight: 800; font-size: .95rem; cursor: pointer; transition: transform .15s, background .15s, color .15s, box-shadow .15s; }
.btn:hover:not([disabled]) { transform: translateY(-2px); box-shadow: 0 6px 0 -2px rgba(91, 58, 41, .25); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--orange); border-color: var(--orange-d); color: #fff; }
.btn.danger { background: var(--red); border-color: #a92f2b; color: #fff; flex: 1 1 100%; }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.link { appearance: none; border: 0; background: none; color: var(--orange-d); font-weight: 800; text-decoration: underline; cursor: pointer; padding: 0; font-size: .95rem; }

.switch { position: relative; flex: none; width: 62px; height: 34px; border: 0; border-radius: 999px; background: #cdb89a; cursor: pointer; transition: background .25s; }
.switch .knob { position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); transition: transform .25s cubic-bezier(.3, 1.4, .5, 1); }
.switch.on { background: var(--green); }
.switch.on .knob { transform: translateX(28px); }

.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; align-self: flex-start; }
.seg button { appearance: none; border: 0; background: transparent; padding: .35rem .9rem; font-weight: 800; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--brown); color: #fff; }

.nudge { animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 122, 61, .55); } 50% { box-shadow: 0 0 0 10px rgba(255, 122, 61, 0); } }

/* ---------- scoreboard ---------- */
.scoreboard { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
@media (max-width: 820px) { .scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--paper); border: 2px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.tile-label { font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tile b { font-family: var(--display); font-weight: 600; font-size: 2.4rem; line-height: 1.1; }
.tile.good b { color: var(--green); }
.tile.bad b { color: var(--red); }
.tile.warn b { color: var(--amber); }
.pop { display: inline-block; animation: pop .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { 0% { transform: scale(.6); } 100% { transform: scale(1); } }

/* ---------- feed ---------- */
.feed { margin-top: 22px; padding: 18px 20px; background: var(--paper); border: 2px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.feed ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.feed li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: 12px; background: #fff7ea; animation: slide-in .35s ease-out; }
.feed .dot { flex: none; width: 12px; height: 12px; margin-top: 7px; border-radius: 50%; background: var(--muted); }
.feed li.good .dot { background: var(--green); }
.feed li.bad .dot { background: var(--red); }
.feed li.save .dot { background: #4a90d9; }
.feed li.bad { background: #ffeceb; }
.feed li.save { background: #eaf3fd; }
.feed li.good { background: #eaf8f1; }
.empty { margin: 0; color: var(--muted); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- explainer ---------- */
.explain { margin-top: 26px; padding: 22px 24px; background: var(--brown); color: #fff1dc; border-radius: 26px; box-shadow: var(--shadow); }
.explain h2 { color: #fff; }
.explain p { max-width: 78ch; }
.explain a { color: #ffc98a; }
.map { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; margin: 16px 0; }
.map div { padding: 12px 14px; background: #ffffff14; border: 1px solid #ffffff26; border-radius: 14px; }
.map b { display: block; color: #ffd9a8; }
.map span { font-size: .93rem; color: #ffeedd; }
.source { font-size: .93rem; color: #f3dcc0; }

.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 26px; font-size: .92rem; color: var(--muted); }

/* ---------- the cafe scene ---------- */
.scene { display: block; width: 100%; height: auto; border-radius: 16px; }
.scene .label { font: 800 11px var(--body); letter-spacing: .14em; fill: var(--muted); }
.scene .label.on-wood { fill: #ffe6c4; }
.scene .sign-text { font: 600 22px var(--display); letter-spacing: .1em; fill: #fff1dc; }
.scene .sun { animation: glow 4s ease-in-out infinite; }
.scene .rail-bar { fill: var(--brown-2); }
.scene .rail-leg { stroke: var(--brown-2); stroke-width: 4; }
.scene .rail-hint { font: 700 11px var(--body); fill: var(--muted); }
.scene .more { font: 800 12px var(--body); fill: var(--red); }
.scene.net-off .rail { opacity: .4; }
.scene.net-on .rail-bar { filter: drop-shadow(0 0 7px rgba(255, 179, 71, .8)); }
.scene.net-on .rail-label { fill: var(--green); }

.scene .tok { transition: transform .14s linear; }
.scene .tok .num { font: 800 10px var(--body); fill: var(--brown); text-anchor: middle; }
.scene .person { --s: 1.4; transform: scale(var(--s)); animation: arrive .45s cubic-bezier(.3, 1.5, .5, 1); }
.scene .person .mouth, .scene .barista .mouth { stroke: #3a2a22; stroke-width: 1.8; fill: none; stroke-linecap: round; }
.scene .brow { stroke: #3a2a22; stroke-width: 2.2; stroke-linecap: round; }
.scene .cheek { fill: #ff8a7a; opacity: .75; }
.scene .t-person.angry .person { animation: arrive .45s cubic-bezier(.3, 1.5, .5, 1), shake .4s .45s infinite; }

.scene .paper { fill: #fffdf6; stroke: #d9c7a6; stroke-width: 1.5; }
.scene .lines { stroke: #cdbd9c; stroke-width: 1.6; stroke-linecap: round; }
.scene .clip { fill: #b9bcc4; }
.scene .ticket { --s: 1.45; transform: scale(var(--s)); animation: arrive .4s cubic-bezier(.3, 1.5, .5, 1); }
.scene .ticket.mini { --s: 1; }
.scene .ticket .num { font: 800 9px var(--body); }

.scene .bubble { transform: scale(1.25); }
.scene .bubble rect, .scene .bubble path { fill: #fff; stroke: var(--orange); stroke-width: 2.5; stroke-linejoin: round; }
.scene .bubble-text { font: 800 12px var(--body); fill: var(--orange-d); text-anchor: middle; }

.scene .cup-body { fill: #fff6e6; stroke: var(--brown-2); stroke-width: 3; stroke-linejoin: round; }
.scene .cup-handle { fill: none; stroke: var(--brown-2); stroke-width: 3; }
.scene .cup-num { font: 800 9px var(--body); fill: var(--brown-2); text-anchor: middle; }
.scene .cup { --s: 1.3; transform: scale(var(--s)); }
.scene .t-cup:not(.t-ready) .cup { animation: bob 1s ease-in-out infinite; }
.scene .cup.ready { animation: arrive .5s cubic-bezier(.3, 1.6, .5, 1); }
.scene .tick circle { fill: var(--green); }
.scene .tick path { stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.scene .poof { --s: 1.7; transform: scale(var(--s)); animation: poof 1.1s ease-out forwards; }
.scene .lost-text { font: 800 11px var(--body); fill: var(--red); text-anchor: middle; letter-spacing: .08em; }
.scene .poof circle { fill: #9aa0a6; opacity: .88; }
.scene .x-mark { stroke: var(--red); stroke-width: 4.5; stroke-linecap: round; }

.scene .merged { animation: arrive .4s cubic-bezier(.3, 1.5, .5, 1); }
.scene .stamp rect { fill: #2fa37a22; stroke: var(--green); stroke-width: 2; }
.scene .stamp text { font: 800 9px var(--body); fill: var(--green); text-anchor: middle; }

.scene .barista-body { transform-box: fill-box; transform-origin: center bottom; animation: work 1.3s ease-in-out infinite; }
.scene .dead-eyes { stroke: #3a2a22; stroke-width: 2; stroke-linecap: round; fill: none; }
.scene.is-crashed .barista-body { animation: crash-shake .3s infinite; }
.scene .machine-light { fill: var(--green); }
.scene.is-crashed .machine-light { fill: var(--red); animation: blink .6s infinite; }
.scene .steam-puff { fill: none; stroke: #fff; stroke-width: 3.5; stroke-linecap: round; opacity: 0; animation: steam 2.4s ease-in-out infinite; }
.scene .steam-puff.p2 { animation-delay: .8s; }
.scene .steam-puff.p3 { animation-delay: 1.6s; }
.scene.is-crashed .steam-puff { stroke: #4a3b34; animation-duration: 1.1s; }
.scene .dizzy { animation: spin 1.3s linear infinite; }
.scene .star { fill: var(--amber); }
.scene .star.st2 { transform: rotate(120deg); }
.scene .star.st3 { transform: rotate(240deg); }
.scene .reboot rect { fill: rgba(58, 42, 34, .88); }
.scene .reboot text { font: 800 12px var(--body); fill: #fff; }

.scene .cloud ellipse, .scene .cloud circle { fill: #fff; stroke: #d9c7a6; stroke-width: 2.5; }
.scene .cloud { opacity: .75; }
.scene .cloud.has-orders { opacity: 1; }
.scene .cloud-label { font: 800 9px var(--body); letter-spacing: .1em; fill: var(--muted); text-anchor: middle; }

@keyframes arrive { from { opacity: 0; transform: scale(calc(var(--s, 1) * .4)); } to { opacity: 1; transform: scale(var(--s, 1)); } }
@keyframes bob { 0%, 100% { transform: translateY(0) scale(var(--s, 1)); } 50% { transform: translateY(-4px) scale(var(--s, 1)); } }
@keyframes work { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.04); } }
@keyframes shake { 0%, 100% { transform: translateX(0) scale(var(--s, 1)); } 25% { transform: translateX(-2.5px) scale(var(--s, 1)); } 75% { transform: translateX(2.5px) scale(var(--s, 1)); } }
@keyframes crash-shake { 0%, 100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
@keyframes blink { 50% { opacity: .2; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes steam { 0% { opacity: 0; transform: translateY(8px); } 40% { opacity: .85; } 100% { opacity: 0; transform: translateY(-14px); } }
@keyframes poof { 0% { opacity: 1; transform: scale(calc(var(--s, 1) * .5)); } 60% { opacity: 1; transform: scale(calc(var(--s, 1) * 1.1)); } 100% { opacity: 0; transform: scale(calc(var(--s, 1) * 1.4)); } }
@keyframes glow { 50% { opacity: .7; } }

/* ---------- loading screen ---------- */
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; text-align: center; font-family: var(--display); color: var(--brown); background: var(--cream); }
.boot-cup { position: relative; width: 90px; height: 90px; margin-bottom: 12px; }
.boot .cup { position: absolute; left: 14px; bottom: 6px; width: 56px; height: 46px; background: var(--brown); border-radius: 6px 6px 22px 22px; animation: bob 1.1s ease-in-out infinite; }
.boot .handle { position: absolute; right: -16px; top: 8px; width: 20px; height: 22px; border: 6px solid var(--brown); border-left: 0; border-radius: 0 16px 16px 0; }
.boot .steam { position: absolute; bottom: 52px; width: 8px; height: 28px; border-radius: 8px; background: #d9b48a; opacity: 0; animation: steam 1.8s ease-in-out infinite; }
.boot .s1 { left: 24px; }
.boot .s2 { left: 40px; animation-delay: .5s; }
.boot .s3 { left: 56px; animation-delay: 1s; }
.boot-title { margin: 0; font-size: 2rem; font-weight: 600; }
.boot-sub { margin: 4px 0 0; font-family: var(--body); color: var(--muted); }

#blazor-error-ui { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; padding: .8rem 1.2rem; background: #fff3c4; color: #5b3a29; box-shadow: 0 -1px 6px rgba(0, 0, 0, .25); }
#blazor-error-ui .dismiss { position: absolute; right: .75rem; top: .5rem; cursor: pointer; }

/* customers waiting at the pickup counter */
.scene .waiter-pos { transition: transform .35s ease; }
.scene .waiter { animation: arrive .45s cubic-bezier(.3, 1.5, .5, 1); }
.scene .waiter .mouth { stroke: #3a2a22; stroke-width: 1.7; fill: none; stroke-linecap: round; }
.scene .waiter .num { font: 800 9px var(--body); fill: var(--brown); text-anchor: middle; }
.scene .waiter.angry { animation: arrive .45s cubic-bezier(.3, 1.5, .5, 1), shake .4s .45s infinite; }
.scene .waiter.forgotten { filter: saturate(.55); }
.scene .qmark { animation: bob 1.1s ease-in-out infinite; }
.scene .qmark circle { fill: #fff; stroke: var(--red); stroke-width: 2.5; }
.scene .qmark text { font: 800 15px var(--body); fill: var(--red); text-anchor: middle; }
/* ---------- sticky controls for small screens ---------- */
.dock { display: none; }
@media (max-width: 900px) {
    .page { padding-bottom: 110px; }
    .dock { position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 50; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: rgba(255, 253, 248, .96); border: 2px solid var(--line); border-radius: 20px; box-shadow: 0 10px 30px -8px rgba(91, 58, 41, .55); backdrop-filter: blur(6px); }
    .dock .switch { width: 54px; height: 30px; }
    .dock .switch .knob { width: 22px; height: 22px; top: 4px; left: 4px; }
    .dock .switch.on .knob { transform: translateX(24px); }
    .dock-label { flex: 1; font-weight: 800; font-size: .85rem; line-height: 1.15; }
    .dock .btn.danger { flex: none; padding: .55rem .9rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
    .scene .steam-puff { opacity: .5; }
}
