/* ---------- Tokens ---------- */
:root{
  --paper:#fbf8ee;--ink:#1c1b1f;--accent:#f2a20f;--dot:rgba(28,27,31,.16);--soft:#f1ebd6;
  --mute:#5a574f;--on:#1c1b1f;
  --radius-blob:30px 24px 32px 22px/24px 32px 22px 30px;
  --shadow:4px 4px 0 var(--ink);
  color-scheme:light;
}
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){--paper:#23211d;--ink:#f3eedd;--accent:#f5b13a;--dot:rgba(243,238,221,.16);--soft:#2f2c25;--mute:#cfc9b6;--on:#1c1b1f;color-scheme:dark}
}
:root[data-theme="dark"]{--paper:#23211d;--ink:#f3eedd;--accent:#f5b13a;--dot:rgba(243,238,221,.16);--soft:#2f2c25;--mute:#cfc9b6;--on:#1c1b1f;color-scheme:dark}

/* ---------- Base ---------- */
*,*::before,*::after{box-sizing:border-box}
html,body{height:100%;margin:0}
body{
  background-color:var(--paper);
  background-image:radial-gradient(var(--dot) 1.5px,transparent 1.7px);
  background-size:24px 24px;
  color:var(--ink);
  font:20px/1.3 'Patrick Hand','Segoe Print','Comic Sans MS',cursive;
  overflow:hidden;
}
[hidden]{display:none!important}
button{font:inherit;color:inherit;cursor:pointer}
button:disabled{cursor:default}
:focus-visible{outline:3px solid var(--ink);outline-offset:3px}
h1,h2,p{margin:0}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
body:not(.is-boss) .boss-only,body.is-boss .guest-only{display:none!important}

/* ---------- Screens ---------- */
.app{position:relative;height:100dvh;max-width:560px;margin:0 auto;overflow:hidden}
.view{
  position:absolute;inset:0;display:flex;flex-direction:column;gap:12px;
  padding:max(12px,env(safe-area-inset-top)) 16px max(16px,env(safe-area-inset-bottom));
  text-align:center;
  visibility:hidden;opacity:0;transform:translateX(28px);
  transition:opacity .25s,transform .25s,visibility 0s .25s;
}
.view.active{visibility:visible;opacity:1;transform:none;transition:opacity .25s,transform .25s}
.view-body{flex:1;min-height:0;display:flex;flex-direction:column;justify-content:center;gap:16px;overflow-y:auto;padding:4px}
.view-body.scroll{justify-content:flex-start;text-align:left}
.view-foot{display:flex;flex-direction:column;gap:10px;align-items:stretch}

.bar{display:grid;grid-template-columns:44px 1fr 44px;align-items:center;min-height:44px}
.bar h1,.bar h2{font-weight:400;font-size:28px;line-height:1}
.bar .right{justify-self:end}

/* ---------- Controls ---------- */
.btn{
  font-size:28px;padding:10px 24px;border:3px solid var(--ink);border-radius:14px;
  background:var(--accent);color:var(--on);box-shadow:var(--shadow);
}
.btn.alt{background:var(--paper);color:var(--ink)}
.btn:active:not(:disabled){transform:translate(3px,3px);box-shadow:1px 1px 0 var(--ink)}
.btn:disabled{opacity:.55}
a.btn{display:block;text-decoration:none}

.chip{white-space:nowrap;font-size:17px;padding:1px 14px;border:2px solid var(--ink);border-radius:999px;background:transparent}
.chip[aria-pressed="true"]{background:var(--accent);color:var(--on)}
.chip:disabled{opacity:.5}

.link{font-size:19px;padding:6px 8px;border:0;background:none;opacity:.8;text-decoration:underline dotted;text-underline-offset:5px}
.link:hover{opacity:1}
.links{display:flex;gap:6px 14px;justify-content:center;flex-wrap:wrap}

.icon{width:44px;height:44px;display:grid;place-items:center;padding:0;border:2px solid var(--ink);border-radius:50%;background:transparent}
.icon svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.icon .off{display:none}
.icon[aria-pressed="true"]{opacity:.7}
.icon[aria-pressed="true"] .on{display:none}
.icon[aria-pressed="true"] .off{display:inline}

.status{min-height:1.3em;font-size:18px}
.card{padding:14px;background:var(--paper);border:3px solid var(--ink);border-radius:20px 15px 23px 16px;box-shadow:5px 5px 0 var(--ink)}
.note{
  padding:12px 18px;background:var(--accent);color:var(--on);
  border:3px solid var(--ink);border-radius:6px 12px 6px 14px;box-shadow:var(--shadow);
  transform:rotate(-1.2deg);font-size:26px;line-height:1.2;
}
.status-line{font-size:24px;line-height:1.2;min-height:2.4em;display:grid;place-items:center}
.note.big{font-size:34px;padding:18px 20px}

/* ---------- Home: title + machine ---------- */
.title{font-size:clamp(34px,10vw,48px)!important;transform:rotate(-1.5deg)}
.title span{background:linear-gradient(transparent 60%,var(--accent) 60% 92%,transparent 92%);padding:0 8px}
.sub{opacity:.8}

.machine{
  display:grid;grid-template-columns:repeat(3,minmax(0,1fr)) 40px;gap:10px;
  padding:14px 10px 12px 12px;border:3px solid var(--ink);border-radius:var(--radius-blob);
  background:var(--paper);box-shadow:6px 7px 0 var(--ink);
}
.reel{display:flex;flex-direction:column;align-items:center;gap:8px;min-width:0}
.win{
  width:100%;aspect-ratio:1;border:3px solid var(--ink);border-radius:16px 12px 18px 12px;
  background:var(--soft);padding:2px;display:grid;place-items:center;overflow:hidden;
}
.win svg,.pic svg{width:100%;height:100%;filter:url(#wob)}
.win.spin svg{filter:blur(2.5px);animation:jit .16s linear infinite}
.win.land{animation:land .4s cubic-bezier(.3,1.6,.5,1)}
.lever{grid-column:4;align-self:center;display:flex;flex-direction:column;align-items:center;padding:0;border:0;background:none;transform-origin:center}
.lever.pull{animation:pull .55s ease-in-out}
.ball{width:30px;height:30px;border-radius:50%;background:var(--accent);border:3px solid var(--ink)}
.stem{width:8px;height:86px;margin-top:-2px;background:var(--ink);border-radius:4px}

/* SVG fills used by the art */
.a{fill:var(--accent)}.p{fill:var(--paper)}.k{fill:currentColor}

/* ---------- Draw screen ---------- */
.tiles{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.tile{display:flex;flex-direction:column;gap:4px;font-size:16px;line-height:1.1;min-width:0}
.pic{aspect-ratio:1;border:2px solid var(--ink);border-radius:14px 10px 16px 10px;background:var(--soft);padding:2px;display:grid;place-items:center}

/* ---------- Example / camera ---------- */
.result{display:grid;gap:10px}
.result img,.stage img,.stage video{display:block;width:100%;height:auto;border-radius:9px;background:#fff}
.stage{display:grid;place-items:center;aspect-ratio:1;width:min(100%,360px);margin:0 auto;border:3px dashed var(--ink);border-radius:20px;background:var(--soft);padding:12px;overflow:hidden}
.stage video,.stage img{height:100%;object-fit:cover;border-radius:14px}
.stage[data-has-media]{border-style:solid}
.banana{width:140px;height:140px;align-self:center;animation:scribble 1.1s ease-in-out infinite}

/* ---------- Catalog ---------- */
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(92px,1fr));gap:10px}
.tabs{display:flex;gap:8px;justify-content:center}
.view-body h2{font-weight:400;font-size:24px;margin:0}

/* ---------- Login ---------- */
.login{display:grid;gap:12px;justify-items:center}
.login input{font:inherit;font-size:22px;padding:10px 12px;width:min(100%,280px);text-align:center;background:var(--paper);color:var(--ink);border:3px solid var(--ink);border-radius:12px}

/* ---------- Motion ---------- */
@keyframes jit{50%{transform:translateY(9px)}}
@keyframes scribble{0%,100%{transform:rotate(-8deg) translateX(-6px)}50%{transform:rotate(8deg) translateX(6px)}}
@keyframes land{0%{transform:translateY(-14px) scale(.95)}100%{transform:none}}
@keyframes pull{0%{transform:scaleY(1)}35%{transform:scaleY(-1)}100%{transform:scaleY(1)}}
@media (prefers-reduced-motion:reduce){*{animation:none!important}.view{transition:none}}

/* ---------- Bigger screens / short screens ---------- */
@media (min-width:600px){
  .machine{gap:16px;padding:24px 20px 20px 24px;grid-template-columns:repeat(3,minmax(0,1fr)) 54px}
  .ball{width:44px;height:44px}.stem{width:11px;height:130px}
  .chip{font-size:20px}
}
@media (max-height:640px){
  .stem{height:56px}
  .status-line{font-size:24px;line-height:1.2;min-height:2.4em;display:grid;place-items:center}
.note.big{font-size:28px}
}
