/* Owner: Screens. Paper Playroom: cream paper, torn tags, cut-paper squares. No external fonts or images (CSP). */
@font-face{font-family:"Caveat Brush";src:url("fonts/caveat-brush.woff2") format("woff2");font-weight:400;font-style:normal;font-display:swap}
@font-face{font-family:"Patrick Hand";src:url("fonts/patrick-hand.woff2") format("woff2");font-weight:400;font-style:normal;font-display:swap}

:root{
  color-scheme:light;   /* light by design: the paper look has no dark version */
  --cream:#f6ecd6; --paper:#fffaf0; --tomato:#e5563b; --marigold:#f3ac1f; --leaf:#4e9c5a; --sky:#6fb9e0; --plum:#6d3f7d; --ink:#392a3b;
  --ink-soft:#6b5a66;
  --shadow:0 1px 0 rgba(90,60,40,.08),0 3px 4px rgba(90,60,40,.22),0 8px 12px -6px rgba(90,60,40,.32);
  --hand:"Caveat Brush","Comic Sans MS","Chalkboard SE",cursive;
  --label:"Patrick Hand","Comic Sans MS","Chalkboard SE",cursive;
  --pad-t:max(8px,env(safe-area-inset-top)); --pad-r:max(12px,env(safe-area-inset-right));
  --pad-b:max(10px,env(safe-area-inset-bottom)); --pad-l:max(12px,env(safe-area-inset-left));
}
*{box-sizing:border-box;margin:0}
[hidden]{display:none!important}
html,body{height:100%;overflow:hidden;overscroll-behavior:none}
body{
  position:fixed;inset:0;width:100%;
  background-color:var(--cream);
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='420' height='420'><filter id='f' x='0' y='0' width='100%25' height='100%25'><feTurbulence type='fractalNoise' baseFrequency='.32 .11' numOctaves='2' seed='11' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .52  0 0 0 0 .38  0 0 0 0 .22  0 0 0 3.4 -2.5'/></filter><rect width='100%25' height='100%25' filter='url(%23f)'/></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='380' height='380'><filter id='h' x='0' y='0' width='100%25' height='100%25'><feTurbulence type='fractalNoise' baseFrequency='.12 .3' numOctaves='2' seed='23' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .95  0 0 0 0 .9  0 0 0 0 .8  0 0 0 3.4 -2.55'/></filter><rect width='100%25' height='100%25' filter='url(%23h)'/></svg>");
  color:var(--ink);font-family:var(--label);font-size:17px;line-height:1.25;
  -webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;
  touch-action:manipulation;
}
button{font:inherit;color:inherit}
.grain{position:fixed;inset:0;pointer-events:none;z-index:40;opacity:.28;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='g' x='0' y='0' width='100%25' height='100%25'><feTurbulence type='fractalNoise' baseFrequency='1.15' numOctaves='1' seed='9' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .3  0 0 0 0 .2  0 0 0 0 .12  0 0 0 .8 -.3'/></filter><rect width='100%25' height='100%25' filter='url(%23g)'/></svg>");}
.defs{position:absolute;width:0;height:0}
.sr{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0;padding:0}
:focus-visible{outline:3px dashed var(--plum);outline-offset:3px}

/* ---------- layout: one screen, three rows ---------- */
.stage{
  position:relative;z-index:2;height:100vh;height:100dvh;display:grid;
  grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto;
  grid-template-areas:"hud" "board" "dock";
  padding:var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);gap:6px;
}

/* ---------- HUD: torn tags + sun ---------- */
.hud{grid-area:hud;position:relative;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:10px;padding-top:6px}
.brand{position:absolute;left:58px;top:12px;font-family:var(--hand);font-size:22px;color:var(--tomato);transform:rotate(-3deg);display:none;letter-spacing:.01em}
.tag{position:relative;filter:drop-shadow(0 2px 2px rgba(90,60,40,.3));flex:none}
.tag.l{justify-self:end;transform:rotate(-2.2deg)}
.tag.r{justify-self:start;transform:rotate(2deg)}
.tag .in{
  display:flex;align-items:center;gap:6px;height:52px;padding:2px 12px 0 20px;
  background:linear-gradient(160deg,rgba(255,255,255,.55),rgba(255,255,255,0) 50%),#fffaf0;
  clip-path:polygon(9% 0,100% 0,100% 100%,7% 100%,1% 88%,5% 76%,0 62%,5% 48%,1% 34%,6% 20%,2% 9%);
}
.tag.r .in{padding:2px 20px 0 12px;clip-path:polygon(0 0,91% 0,98% 10%,94% 22%,100% 36%,95% 50%,100% 64%,95% 78%,99% 90%,93% 100%,0 100%)}
.tag .in::after{content:"";position:absolute;inset:0;pointer-events:none;background:repeating-linear-gradient(0deg,rgba(150,110,60,.05) 0 1px,transparent 1px 5px)}
.tag i.tape,.sticky i.tape{position:absolute;top:-6px;left:50%;width:34px;height:12px;margin-left:-14px;transform:rotate(-6deg);z-index:2;
  background:repeating-linear-gradient(135deg,rgba(255,255,255,.4) 0 3px,transparent 3px 7px),rgba(229,86,59,.78);
  clip-path:polygon(0 0,100% 0,95% 25%,100% 50%,95% 75%,100% 100%,0 100%,5% 75%,0 50%,5% 25%)}
.tag.r i.tape{background:radial-gradient(circle,rgba(255,255,255,.6) 1.2px,transparent 1.7px) 0 0/6px 6px,rgba(109,63,125,.78);transform:rotate(5deg)}
.tag svg{width:24px;height:24px;flex:none;overflow:visible}
.tag b{font-family:var(--hand);font-weight:400;font-size:34px;line-height:1;letter-spacing:.03em;color:var(--ink);min-width:2.1em;text-align:center;font-variant-numeric:tabular-nums}
.tag.l b{color:var(--tomato)}

/* Flag mode tag: a taped paper label by the HUD, shown for as long as flag mode is on (it survives new games) */
.modetag{position:absolute;left:2px;top:-4px;z-index:4;padding:5px 12px 3px 13px;transform:rotate(-4deg);pointer-events:none;
  font-family:var(--hand);font-size:17px;line-height:1;letter-spacing:.02em;color:var(--tomato);background:var(--paper);
  border-radius:3px 6px 4px 7px/6px 3px 7px 4px;box-shadow:var(--shadow),inset 0 0 0 2px rgba(229,86,59,.75)}
.modetag i.tape{position:absolute;top:-7px;left:50%;width:30px;height:11px;margin-left:-13px;transform:rotate(5deg);
  background:repeating-linear-gradient(135deg,rgba(255,255,255,.4) 0 3px,transparent 3px 7px),rgba(243,172,31,.9);
  clip-path:polygon(0 0,100% 0,95% 25%,100% 50%,95% 75%,100% 100%,0 100%,5% 75%,0 50%,5% 25%)}

.face{
  position:relative;width:66px;height:66px;border:0;background:none;padding:0;cursor:pointer;
  filter:drop-shadow(0 3px 3px rgba(90,60,40,.32));transition:transform .25s cubic-bezier(.3,1.6,.5,1);touch-action:manipulation;
}
.face svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
.face:hover{transform:scale(1.06) rotate(-4deg)}
.face:active{transform:scale(.92)}
.face.spin svg{animation:facespin .6s cubic-bezier(.3,1.4,.5,1)}
.face:focus-visible{outline:3px dashed var(--plum);outline-offset:4px;border-radius:50%}
@keyframes facespin{from{transform:rotate(-90deg) scale(.7)}to{transform:none}}

/* ---------- board ---------- */
.boardwrap{grid-area:board;position:relative;min-height:0;min-width:0;touch-action:none;cursor:pointer;overflow:hidden;-webkit-user-drag:none}
.boardwrap:focus{outline:none}
.boardwrap:focus-visible{outline:3px dashed var(--plum);outline-offset:-3px;border-radius:10px}
.bbox{position:absolute;inset:0}
.bbox canvas{position:absolute;left:0;top:0;display:block}
#fx,#conf{pointer-events:none}
#fx.stain{mix-blend-mode:multiply}   /* the ink soaks into the paper: the numbers under the stain stay readable */
.bbox.shake{animation:shake .38s ease}
@keyframes shake{0%,100%{transform:none}15%{transform:translate(-5px,2px) rotate(-.5deg)}35%{transform:translate(5px,-2px) rotate(.5deg)}55%{transform:translate(-3px,1px)}75%{transform:translate(2px,-1px)}}

/* The empty paper above a small board on a tall phone: doodles and a note about this level (JS sizes it, only when it fits). */
.band{position:absolute;left:0;right:0;top:0;height:var(--band,0px);display:none;pointer-events:none;overflow:hidden}
.band.on{display:block}
.band .dd{position:absolute;overflow:visible}
.sticky{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%) rotate(-2.5deg);min-width:150px;padding:14px 22px 10px;text-align:center;
  background:var(--paper);box-shadow:var(--shadow);border-radius:3px 7px 4px 8px/7px 3px 8px 4px;display:flex;flex-direction:column;align-items:center;gap:0}
.sticky span{font-size:17px;color:var(--ink-soft)}
.sticky b{font-family:var(--hand);font-weight:400;font-size:38px;line-height:1.05;color:var(--tomato);font-variant-numeric:tabular-nums}
.sticky small{font-size:14px;color:var(--ink-soft)}

/* ---------- dock ---------- */
.dock{grid-area:dock;display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:2px}
.row{display:flex;align-items:center;justify-content:center;gap:10px;flex-wrap:nowrap}
.chips{display:flex;gap:8px}
.chip{
  position:relative;font-family:var(--label);font-size:17px;line-height:1;color:var(--ink);cursor:pointer;
  padding:0 14px;height:44px;min-width:64px;border:0;background:var(--paper);
  border-radius:3px 6px 4px 7px / 6px 3px 7px 4px;box-shadow:var(--shadow);
  transition:transform .25s cubic-bezier(.3,1.6,.5,1);touch-action:manipulation;
}
.chip:nth-child(1){transform:rotate(-1.4deg)}.chip:nth-child(2){transform:rotate(.9deg)}.chip:nth-child(3){transform:rotate(-.7deg)}
.chip:hover{transform:translateY(-2px) rotate(0)}
.chip:active{transform:scale(.95)}
.chip[aria-pressed="true"]{background:var(--marigold);font-family:var(--hand);font-size:19px}
.chip[aria-pressed="true"]::after{content:"";position:absolute;left:50%;top:-6px;width:26px;height:10px;margin-left:-13px;transform:rotate(-5deg);
  background:repeating-linear-gradient(135deg,rgba(255,255,255,.4) 0 3px,transparent 3px 7px),rgba(229,86,59,.8);
  clip-path:polygon(0 0,100% 0,95% 25%,100% 50%,95% 75%,100% 100%,0 100%,5% 75%,0 50%,5% 25%)}
.ibtn{
  position:relative;width:48px;height:48px;border:0;cursor:pointer;background:var(--paper);padding:0;display:grid;place-items:center;
  border-radius:50% 46% 52% 48% / 48% 52% 46% 50%;box-shadow:var(--shadow);transition:transform .25s cubic-bezier(.3,1.6,.5,1),background .2s;touch-action:manipulation;
}
.ibtn svg{width:28px;height:28px;overflow:visible}
.ibtn:hover{transform:translateY(-2px) rotate(-3deg)}
.ibtn:active{transform:scale(.92)}
.ibtn[aria-pressed="true"]{background:var(--marigold);box-shadow:inset 0 2px 4px rgba(120,70,0,.3),0 1px 0 rgba(255,255,255,.6)}
/* Flag mode is the loud one: a tomato button with a cream flag. Zoom just gets a marigold outline, so the two never look alike. */
#flagmode[aria-pressed="true"]{background:var(--tomato);box-shadow:inset 0 2px 4px rgba(90,20,10,.35),0 0 0 3px rgba(229,86,59,.35)}
#flagmode[aria-pressed="true"] svg path:nth-of-type(2){fill:#fffaf0}
#flagmode[aria-pressed="true"] svg path:nth-of-type(3){stroke:#e5563b;opacity:1}
#zoom[aria-pressed="true"]{background:var(--paper);box-shadow:var(--shadow),0 0 0 3px var(--marigold)}
#sound[aria-pressed]{background:var(--paper);box-shadow:var(--shadow)}
#sound[aria-pressed="false"]{background:#efe4cf}
.ibtn.big{width:56px;height:56px}
.ibtn.big svg{width:34px;height:34px}
.chip:focus-visible,.ibtn:focus-visible{outline:3px dashed var(--plum);outline-offset:3px}
@media (hover:hover) and (pointer:fine){.touch-only{display:none}}

/* ---------- toast ---------- */
.toast{position:fixed;left:50%;top:calc(var(--pad-t) + 8px);z-index:35;transform:translate(-50%,-14px) rotate(-1deg);width:max-content;max-width:calc(100vw - 32px);text-wrap:balance;
  padding:11px 20px 10px;background:var(--paper);box-shadow:var(--shadow),0 14px 30px rgba(90,60,40,.25);border-radius:3px 7px 4px 8px/7px 3px 8px 4px;
  font-size:18px;text-align:center;opacity:0;pointer-events:none;transition:opacity .25s,transform .35s cubic-bezier(.3,1.5,.5,1)}
.toast.show{opacity:1;transform:translate(-50%,0) rotate(-1deg)}
.toast::before{content:"";position:absolute;top:-7px;left:50%;width:34px;height:12px;margin-left:-17px;transform:rotate(-4deg);
  background:repeating-linear-gradient(135deg,rgba(255,255,255,.4) 0 3px,transparent 3px 7px),rgba(243,172,31,.85);
  clip-path:polygon(0 0,100% 0,95% 25%,100% 50%,95% 75%,100% 100%,0 100%,5% 75%,0 50%,5% 25%)}

/* ---------- sheets (win card, best times) ---------- */
dialog.sheet{
  position:fixed;inset:0;margin:auto;width:min(92vw,440px);max-height:min(90vh,760px);max-height:min(90dvh,760px);overflow:auto;overscroll-behavior:contain;
  padding:20px 20px 18px;border:0;color:var(--ink);background:var(--paper);font-family:var(--label);font-size:17px;
  border-radius:4px 9px 5px 10px/9px 4px 10px 5px;box-shadow:var(--shadow),0 22px 50px rgba(57,42,59,.35);
  -webkit-user-select:none;user-select:none;touch-action:pan-y;
}
dialog.sheet[open]{animation:sheetin .34s cubic-bezier(.3,1.4,.5,1)}
dialog.sheet::backdrop{background:rgba(57,42,59,.38)}
dialog.card::backdrop{background:rgba(57,42,59,.22)}   /* the win card leaves the finished board visible behind it */
dialog.sheet::before{content:"";position:absolute;top:-8px;left:50%;width:56px;height:16px;margin-left:-28px;transform:rotate(-3deg);z-index:2;
  background:repeating-linear-gradient(135deg,rgba(255,255,255,.4) 0 3px,transparent 3px 7px),rgba(229,86,59,.8);
  clip-path:polygon(0 0,100% 0,96% 25%,100% 50%,96% 75%,100% 100%,0 100%,4% 75%,0 50%,4% 25%)}
@keyframes sheetin{from{opacity:0;transform:translateY(16px) rotate(-1.5deg) scale(.96)}to{opacity:1;transform:none}}
dialog h2{font-family:var(--hand);font-weight:400;font-size:30px;line-height:1.05;color:var(--tomato);letter-spacing:.01em}
.x{position:absolute;top:8px;right:8px;width:44px;height:44px;border:0;background:none;cursor:pointer;display:grid;place-items:center;border-radius:50%;z-index:3}
.x svg{width:22px;height:22px}
.x:active{transform:scale(.9)}

.btn{
  position:relative;min-height:46px;padding:0 20px;border:0;cursor:pointer;background:var(--paper);color:var(--ink);font-family:var(--label);font-size:18px;
  border-radius:3px 7px 4px 8px/7px 3px 8px 4px;box-shadow:var(--shadow);transition:transform .25s cubic-bezier(.3,1.6,.5,1);touch-action:manipulation;
}
.btn:hover{transform:translateY(-2px) rotate(-.6deg)}
.btn:active{transform:scale(.96)}
.btn.primary{background:var(--marigold);font-family:var(--hand);font-size:22px;letter-spacing:.02em}
.btn.quiet{background:none;box-shadow:none;text-decoration:underline;text-underline-offset:3px;padding:0 10px;color:var(--ink-soft)}
.btn:focus-visible{outline:3px dashed var(--plum);outline-offset:3px}

/* win card */
.card{text-align:center}
.card .sun{width:92px;height:92px;margin:2px auto 0;filter:drop-shadow(0 3px 3px rgba(90,60,40,.3))}
.card .sun svg{width:100%;height:100%;overflow:visible}
.card h2{margin-top:2px}
.card .big{font-family:var(--hand);font-size:56px;line-height:1;color:var(--ink);margin:4px 0 0;font-variant-numeric:tabular-nums}
.card .big small{font-size:26px;margin-left:4px;color:var(--ink-soft)}
.card .sub{color:var(--ink-soft);margin-top:2px}
.badge{display:inline-block;margin:10px 0 0;padding:5px 16px 4px;background:var(--marigold);font-family:var(--hand);font-size:22px;transform:rotate(-2.5deg);
  border-radius:3px 7px 4px 8px/7px 3px 8px 4px;box-shadow:var(--shadow)}
.rankline{margin-top:10px;display:flex;flex-direction:column;gap:2px;font-size:18px}
.rankline b{font-family:var(--hand);font-weight:400;color:#c8402a;font-size:24px}
.quiet-note{margin-top:8px;font-size:15px;color:var(--ink-soft)}
.namebox{margin:14px 0 0;padding:12px 12px 12px;background:#fff3d6;border-radius:4px 8px 5px 9px/8px 4px 9px 5px;box-shadow:inset 0 0 0 2px rgba(243,172,31,.35)}
.namebox p{font-size:18px;margin-bottom:8px}
.namerow{display:flex;gap:8px;align-items:stretch}
.namerow input,.namebar input{flex:1;min-width:0;height:46px;padding:0 12px;border:0;background:var(--paper);font:inherit;font-size:19px;color:var(--ink);
  border-radius:3px 6px 4px 7px/6px 3px 7px 4px;box-shadow:inset 0 2px 3px rgba(90,60,40,.22),0 1px 0 rgba(255,255,255,.7);-webkit-user-select:text;user-select:text}
.namerow input::placeholder,.namebar input::placeholder{color:#7c6b73}
#win-dyn{min-height:76px}   /* the rank line arrives late; the card must not jump when it does */
.namebox .skip{margin-top:6px}
.actions{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;margin-top:16px}

/* best times sheet */
#scores{padding-top:22px}
/* a steady height so the sheet does not jump between tabs; the list scrolls inside it */
#scores[open]{display:flex;flex-direction:column;height:min(84vh,700px);height:min(84dvh,700px);overflow:hidden}
#sc-panel{flex:1;min-height:0;display:flex;flex-direction:column}
#sc-panel .list{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding-bottom:22px;
  -webkit-mask-image:linear-gradient(to bottom,#000 calc(100% - 22px),transparent);mask-image:linear-gradient(to bottom,#000 calc(100% - 22px),transparent)}   /* a fade says there is more below */
#sc-panel>.stats,#sc-panel>.seg,#sc-panel>.note{flex:none}
.sh-head{display:flex;align-items:baseline;justify-content:space-between;gap:10px;padding-right:44px}
.tabs{display:flex;gap:8px;margin:12px 0 0}
.tab{flex:1;min-height:44px;padding:0 6px;border:0;background:#f3e8cd;cursor:pointer;font-family:var(--label);font-size:17px;border-radius:3px 6px 4px 7px/6px 3px 7px 4px;transition:transform .2s}
.tab[aria-selected="true"]{background:var(--marigold);font-family:var(--hand);font-size:19px;box-shadow:var(--shadow)}
.tab:focus-visible{outline:3px dashed var(--plum);outline-offset:2px}
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:14px 0 0}
.stat{padding:8px 4px 6px;background:#fff3d6;border-radius:3px 7px 4px 8px/7px 3px 8px 4px;text-align:center}
.stat b{display:block;font-family:var(--hand);font-weight:400;font-size:26px;line-height:1.05;color:var(--ink);font-variant-numeric:tabular-nums}
.stat span{font-size:14px;color:var(--ink-soft)}
.seg{display:flex;margin:14px 0 8px;border-radius:999px;background:#f3e8cd;padding:3px}
.seg button{flex:1;min-height:44px;border:0;background:none;cursor:pointer;font-family:var(--label);font-size:16px;border-radius:999px}
.seg button[aria-pressed="true"]{background:var(--paper);box-shadow:var(--shadow);font-family:var(--hand);font-size:18px}
.seg button:focus-visible{outline:3px dashed var(--plum);outline-offset:1px}
.list{list-style:none;padding:0;margin:0;min-height:120px}
.list li{display:grid;grid-template-columns:2.2em 1fr auto;align-items:baseline;gap:6px;padding:6px 4px;border-bottom:1.5px dashed rgba(57,42,59,.16);font-size:18px}
.list li:last-child{border-bottom:0}
.list li i{font-style:normal;font-family:var(--hand);color:var(--ink-soft)}
.list li em{font-style:normal;font-family:var(--hand);font-size:21px;font-variant-numeric:tabular-nums}
.list li.me{background:rgba(243,172,31,.28);border-radius:5px;border-bottom-color:transparent}
.list li .d{grid-column:2/-1;font-size:13px;color:var(--ink-soft);margin-top:-4px}
.list .name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.empty{padding:26px 10px;text-align:center;color:var(--ink-soft)}
.note{margin:8px 0 0;font-size:15px;color:var(--ink-soft);text-align:center}
.note button{border:0;background:none;text-decoration:underline;cursor:pointer;color:var(--ink);font-size:15px;padding:6px 8px;min-height:44px}
.namebar{display:flex;gap:8px;margin:14px 0 0;align-items:center}
.namebar label{font-size:15px;color:var(--ink-soft);flex:none}
.namebar input{height:44px}
.namebar .btn{min-height:44px;padding:0 14px;font-size:17px}

/* ---------- the update screen (platform fills these ids in) ---------- */
#updater{position:fixed;inset:0;z-index:2147483000;display:grid;place-items:center;padding:20px;background:var(--cream);color:var(--ink);text-align:center;font-family:var(--label);opacity:0;transition:opacity .25s}
#updater.show{opacity:1}
#updater .upd-card{position:relative;width:min(340px,86vw);padding:26px 24px 22px;background:var(--paper);box-shadow:var(--shadow),0 18px 40px rgba(90,60,40,.28);border-radius:4px 9px 5px 10px/9px 4px 10px 5px;transform:rotate(-1deg)}
#updater .upd-card::before{content:"";position:absolute;top:-8px;left:50%;width:56px;height:16px;margin-left:-28px;transform:rotate(-3deg);
  background:repeating-linear-gradient(135deg,rgba(255,255,255,.4) 0 3px,transparent 3px 7px),rgba(229,86,59,.8);clip-path:polygon(0 0,100% 0,96% 25%,100% 50%,96% 75%,100% 100%,0 100%,4% 75%,0 50%,4% 25%)}
#updater .upd-title{font-family:var(--hand);font-size:28px;color:var(--tomato);margin-bottom:8px}
#updater #upd-notes{margin-bottom:16px;color:var(--ink);font-size:17px}
#updater .upd-bar{height:10px;border-radius:6px;background:#efe2c4;overflow:hidden;box-shadow:inset 0 1px 2px rgba(90,60,40,.3)}
#updater .upd-fill{height:100%;width:100%;background:repeating-linear-gradient(135deg,rgba(255,255,255,.35) 0 6px,transparent 6px 12px),var(--marigold);border-radius:6px}
#updater .upd-hint{margin-top:12px;font-size:15px;color:var(--ink-soft)}

/* ---------- doodles on wide screens ---------- */
.doodle{display:none;position:fixed;pointer-events:none;z-index:1;overflow:visible}

/* ---------- small phones ---------- */
@media (max-width:700px){
  .boardwrap{margin:0 -2px}                 /* the board gets nearly the full width: every pixel counts for 22 px cells */
  .boardwrap.wide{margin:0 -8px}            /* Medium and Expert take a little more of the margin back */
}
@media (max-width:380px){
  .hud{gap:4px}.face{width:56px;height:56px}
  .tag .in{padding-left:14px;padding-right:8px;gap:4px}.tag.r .in{padding-left:8px;padding-right:14px}.tag b{font-size:30px}.tag svg{width:20px;height:20px}
  .chip{min-width:58px;padding:0 10px}
}
@media (max-height:600px) and (orientation:portrait){
  .face{width:58px;height:58px}.tag .in{height:46px}.tag b{font-size:30px}.ibtn.big,.ibtn{width:44px;height:44px}.chip{height:44px}
}

/* ---------- desktop and tablet ---------- */
@media (min-width:700px) and (min-height:521px){
  .doodle.dd-desk{display:block}
  .stage{padding-left:max(20px,env(safe-area-inset-left));padding-right:max(20px,env(safe-area-inset-right));gap:8px}
  .dock{flex-direction:row;justify-content:center;gap:22px;padding-bottom:2px}
  .face{width:76px;height:76px}
  .tag .in{height:58px}
  .tag b{font-size:42px}
  .sticky{display:none}
}

@media (min-width:900px) and (min-height:521px){
  .brand{display:block}   /* only where it clears the counters */
}

/* ---------- landscape phone: the HUD and the buttons move to a side column ---------- */
@media (orientation:landscape) and (max-height:520px){
  .stage{
    grid-template-columns:minmax(0,1fr) clamp(190px,24vw,240px);grid-template-rows:auto minmax(0,1fr);
    grid-template-areas:"board hud" "board dock";
    padding-top:max(6px,env(safe-area-inset-top));padding-bottom:max(6px,env(safe-area-inset-bottom));gap:6px 6px;
  }
  .boardwrap{margin:0}
  .hud{grid-template-columns:1fr 1fr;gap:6px 8px;padding-top:2px}
  .modetag{position:relative;left:auto;top:auto;grid-column:1/-1;grid-row:3;justify-self:center;font-size:15px;padding:4px 10px 2px}
  .face{grid-column:1/-1;grid-row:1;justify-self:center;width:56px;height:56px}
  .tag.l{grid-column:1;grid-row:2;justify-self:stretch}
  .tag.r{grid-column:2;grid-row:2;justify-self:stretch}
  .tag .in{height:38px;padding:2px 6px 0 14px;gap:3px;justify-content:center}
  .tag.r .in{padding:2px 14px 0 6px}
  .tag b{font-size:25px;min-width:0}
  .tag svg{width:17px;height:17px}
  .dock{flex-direction:column;align-items:stretch;gap:9px;padding-top:4px;align-self:start}
  .chips{flex-direction:column;gap:7px}
  .chip{height:44px;min-width:0;width:100%;font-size:16px}
  .chip[aria-pressed="true"]{font-size:18px}
  .row{gap:4px}
  .ibtn,.ibtn.big{width:44px;height:44px}
  .ibtn svg,.ibtn.big svg{width:25px;height:25px}
  .sticky,.brand{display:none}
  dialog.sheet{max-height:94vh;max-height:94dvh;padding-top:16px;padding-bottom:14px}
  /* the win card in two columns so "Play again" is on screen at 844x390: the sun and the time side by side, rank or name to the right */
  dialog.card[open]{display:grid;grid-template-columns:auto auto auto;justify-content:center;column-gap:20px;align-items:center;width:min(94vw,700px)}
  dialog.card[open]>*{grid-column:2}
  dialog.card[open]>.x{grid-column:auto}
  dialog.card[open]>.sun{grid-column:1;grid-row:1 / span 5;margin:0}
  dialog.card[open]>#win-dyn{grid-column:3;grid-row:1 / span 5;min-height:0;align-self:center}
  dialog.card[open]>#win-dyn:empty{display:none}
  dialog.card[open]>.actions{grid-column:1 / -1;grid-row:auto;margin-top:10px}
  .card .sun{width:68px;height:68px}
  .card .big{font-size:44px;margin-top:0}
  .card h2{font-size:26px}
  .badge{margin-top:6px;font-size:19px;padding:3px 14px 2px}
  .namebox{margin-top:0;padding:8px 10px}
  .namebox p{margin-bottom:6px;font-size:16px}
  #scores[open]{display:block;height:auto;overflow:auto}
  #sc-panel{display:block}
  #sc-panel .list{overflow:visible}
}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation:none!important;transition:none!important}
}
