/* Rang · the paint program — a Khelghar page (the lamplit table) with a teak easel on it: a sheet of
   cream paper held by brass clips, a wooden tray of tools, a painter's palette whose every dab of paint
   is an instrument, and a brass play-head that sweeps the picture and plays it. */
@font-face{font-family:"Tiny5";font-style:normal;font-weight:400;font-display:block;src:url("../kit/fonts/tiny5.woff2") format("woff2")}
@font-face{font-family:"Yeseva One";font-style:normal;font-weight:400;font-display:swap;src:url("../../assets/fonts/yeseva-one.woff2") format("woff2")}
@font-face{font-family:"Alegreya";font-style:normal;font-weight:400 900;font-display:swap;src:url("../../assets/fonts/alegreya.woff2") format("woff2")}
@font-face{font-family:"Alegreya";font-style:italic;font-weight:400 900;font-display:swap;src:url("../../assets/fonts/alegreya-italic.woff2") format("woff2")}
@font-face{font-family:"Yatra One";font-style:normal;font-weight:400;font-display:swap;src:url("../../assets/fonts/yatra-khelghar.woff2") format("woff2")}
:root{
  --felt-1:#17453f; --felt-2:#0c2b27; --felt-3:#071c19;
  --lacquer-1:#b23a20; --lacquer-2:#8a2413; --lacquer-3:#6d1b0d;
  --gold-1:#e9b95a; --gold-2:#caa04a; --gold-3:#a67c2e;
  --cream:#f4e7c9; --cream-dim:#e3d6b6; --ink:#221410; --ring:#f2cf7e; --gold-text:#f2cf7e;
  --edge:transparent; --top-h:60px;
}
*{margin:0;padding:0;box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{font-family:"Alegreya",Georgia,serif;color:var(--cream);background:var(--felt-3);min-height:100dvh;overflow-x:hidden;font-size:1.06rem;line-height:1.4;-webkit-tap-highlight-color:transparent}
body::before{content:"";position:fixed;inset:0;pointer-events:none;z-index:0;background:
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.95 0 0 0 0 0.9 0 0 0 0 0.75 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E"),
  radial-gradient(120% 90% at 50% 18%, rgba(255,214,140,.16), rgba(255,214,140,0) 55%),
  radial-gradient(140% 120% at 50% 40%, var(--felt-1) 0%, var(--felt-2) 55%, var(--felt-3) 100%)}
/* the player whose turn it is owns the edge of the screen */
body::after{content:"";position:fixed;inset:0;pointer-events:none;z-index:40;box-shadow:inset 0 0 0 7px var(--edge),inset 0 0 70px color-mix(in srgb,var(--edge) 45%,transparent);transition:box-shadow .45s}
a{color:inherit}
button{font:inherit;color:inherit;background:none;border:0;cursor:pointer;touch-action:manipulation}
/* a press shows the instant the finger lands */
.tool:active:not(:disabled),.pencil button:active:not(:disabled),.pill:not(.gold):active:not(:disabled),.icon-btn:active,.seg button:active,.levels button:active{filter:brightness(1.3);transform:translateY(1px)}
:focus-visible{outline:3px solid var(--ring);outline-offset:3px;border-radius:8px}
[hidden]{display:none!important}

/* ---------- top bar ---------- */
.top{position:relative;z-index:5;display:flex;align-items:center;gap:10px;max-width:1180px;margin:0 auto;padding:calc(8px + env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) 6px max(16px,env(safe-area-inset-left));min-height:var(--top-h)}
.back{display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:6px 14px 6px 8px;border-radius:999px;text-decoration:none;background:rgba(0,0,0,.28);border:1px solid rgba(233,185,90,.4);font-size:1rem;white-space:nowrap}
.back img{width:30px;height:30px}
.back:hover{background:rgba(0,0,0,.42)}
.top .title{font-family:"Yeseva One",serif;font-size:1.35rem;letter-spacing:.1em;margin-left:auto;margin-right:auto;text-shadow:0 2px 14px rgba(0,0,0,.45)}
#mute{margin-left:auto}
.top .title:not([hidden])~#mute{margin-left:0}
.icon-btn{display:grid;place-items:center;width:46px;height:46px;border-radius:50%;background:rgba(0,0,0,.28);border:1px solid rgba(233,185,90,.4);flex:none}
.icon-btn:hover{background:rgba(0,0,0,.45)}
.icon-btn svg{width:22px;height:22px}
.icon-btn .off{display:none}
.icon-btn[aria-pressed="true"] .on{display:none}
.icon-btn[aria-pressed="true"] .off{display:block}
@media (max-width:520px){.back .txt-long{display:none}.top .title{font-size:1.15rem}.top{gap:8px}body.in-game .back{padding:6px}body.in-game .back>span{display:none}}

.screen{position:relative;z-index:1;display:none}
.screen.active{display:block}

/* ---------- setup ---------- */
#setup{max-width:1080px;margin:0 auto;padding:4px 16px 120px}
.hero{display:grid;grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr);gap:clamp(18px,4vw,48px);align-items:center;margin:clamp(6px,2vw,24px) 0 clamp(18px,3vw,32px)}
.hero-art{width:min(100%,400px);justify-self:center;aspect-ratio:1;filter:drop-shadow(0 26px 40px rgba(0,0,0,.55))}
.hero-art svg{width:100%;height:100%;display:block}
.eyebrow{font-size:.9rem;letter-spacing:.2em;text-transform:uppercase;color:var(--gold-text)}
.wordmark{font-family:"Yeseva One",serif;font-weight:400;letter-spacing:.1em;font-size:clamp(3rem,9vw,5.2rem);line-height:1;text-shadow:0 3px 22px rgba(0,0,0,.5);margin:.12em 0 .08em}
.meaning{display:block;font-style:italic;letter-spacing:.14em;color:var(--gold-text);font-size:clamp(1rem,2.4vw,1.2rem)}
/* the house Yatra subset only carries खेलघर, so a whole word in one Devanagari face: no half-and-half letters */
.deva{font-family:"Kohinoor Devanagari","Noto Sans Devanagari","Nirmala UI","Mangal",serif;font-style:normal;font-weight:600;letter-spacing:.02em;font-size:1.15em}
.lede{margin-top:.9em;font-size:clamp(1.08rem,2.3vw,1.28rem);max-width:38ch}
.lede b{color:var(--gold-text);font-weight:700}
.demo{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:14px}
.demo>span{color:var(--cream-dim);font-style:italic;margin-right:2px}
.chip-btn{min-height:44px;padding:6px 14px;border-radius:999px;background:rgba(0,0,0,.3);border:1.5px solid rgba(233,185,90,.4);font-size:1rem;transition:background .15s,transform .15s}
.chip-btn:hover{background:rgba(138,36,19,.6)}
.chip-btn.on{background:var(--gold-1);color:#2a1706;border-color:var(--gold-1);transform:translateY(-1px)}
@media (max-width:760px){.hero{grid-template-columns:1fr;text-align:center}.hero-art{width:min(62vw,300px);order:-1}.lede{margin-left:auto;margin-right:auto}}

.pick{background:rgba(0,0,0,.24);border:1px solid rgba(233,185,90,.22);border-radius:20px;padding:16px clamp(14px,2.4vw,22px) 18px;margin-top:16px}
.pick h2,.howto h2{font-family:"Yeseva One",serif;font-weight:400;font-size:1.35rem;color:var(--gold-text);margin-bottom:12px}
.seg{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.seg button{min-height:56px;padding:10px 12px;border-radius:16px;background:rgba(0,0,0,.28);border:1.5px solid rgba(233,185,90,.3);font-size:1.12rem;line-height:1.15;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;transition:background .2s,border-color .2s}
.seg button small{font-size:.86rem;color:var(--cream-dim)}
.seg button[aria-checked="true"]{background:linear-gradient(160deg,var(--lacquer-1),var(--lacquer-2));border-color:var(--gold-1);box-shadow:0 8px 20px rgba(0,0,0,.35),inset 0 1px 0 rgba(255,225,170,.25)}
.seg button:hover{border-color:rgba(233,185,90,.7)}
@media (max-width:420px){.seg button{font-size:1.02rem;padding:8px 6px}.seg button small{font-size:.8rem}}

.sub{margin-top:14px}
.count-row{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.count-row .icon-btn{font-size:1.5rem;line-height:1}
.count-row output{font-family:"Yeseva One",serif;font-size:1.6rem;min-width:1.4ch;text-align:center}
.names{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:10px;margin-top:12px}
.names label{display:flex;align-items:center;gap:10px;background:rgba(0,0,0,.26);border-radius:14px;padding:6px 10px;border:1px solid rgba(233,185,90,.2)}
.names i{width:18px;height:18px;border-radius:50%;flex:none;box-shadow:0 0 0 2px rgba(0,0,0,.35)}
.names input,.online input{font:inherit;font-size:1.08rem;color:var(--cream);background:transparent;border:0;min-height:44px;width:100%;min-width:0}
.names input:focus,.online input:focus{outline:none}
.online{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.online .box{background:rgba(0,0,0,.26);border:1px solid rgba(233,185,90,.22);border-radius:16px;padding:12px 14px;display:flex;flex-direction:column;gap:10px}
.online .box p{color:var(--cream-dim);font-size:.98rem}
.online .field{display:flex;align-items:center;gap:8px;background:rgba(0,0,0,.3);border:1px solid rgba(233,185,90,.35);border-radius:12px;padding:2px 12px}
.online #join-code{text-transform:uppercase;letter-spacing:.3em;font-family:"Yeseva One",serif}
.online .note{color:#ffc4a0;min-height:1.3em;font-size:.95rem}
@media (max-width:640px){.online{grid-template-columns:1fr}}

.ways{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.way{position:relative;text-align:left;border-radius:18px;padding:14px 14px 16px;background:linear-gradient(160deg,rgba(178,58,32,.35),rgba(109,27,13,.35));border:1.5px solid rgba(233,185,90,.28);display:grid;grid-template-columns:56px 1fr;gap:4px 12px;align-items:center;transition:border-color .2s,background .2s}
.way svg{grid-row:span 2;width:56px;height:56px}
.way b{font-family:"Yeseva One",serif;font-weight:400;font-size:1.3rem}
.way span{color:var(--cream-dim);font-size:.98rem;line-height:1.3}
.way[aria-checked="true"]{background:linear-gradient(160deg,var(--lacquer-1),var(--lacquer-2) 60%,var(--lacquer-3));border-color:var(--gold-1);box-shadow:0 12px 26px rgba(0,0,0,.4),inset 0 1px 0 rgba(255,225,170,.25)}
.way[aria-checked="true"] span{color:#f3d9b8}
@media (max-width:860px){.ways{grid-template-columns:1fr}}
.way-line{display:none}

.levels{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-top:14px}
.levels button{min-height:92px;text-align:left;border-radius:14px;padding:10px 12px;background:rgba(0,0,0,.3);border:1.5px solid rgba(233,185,90,.25);display:flex;flex-direction:column;gap:2px}
.levels .k{font-size:.84rem;letter-spacing:.08em;text-transform:uppercase;color:var(--gold-text)}
.levels b{font-family:"Yeseva One",serif;font-weight:400;font-size:1.12rem}
.levels .sw{font-size:.95rem;color:var(--cream-dim);line-height:1.25}
.levels .pb{font-size:.86rem;color:var(--gold-text);margin-top:auto}
.levels button[aria-checked="true"]{background:linear-gradient(160deg,var(--lacquer-1),var(--lacquer-2));border-color:var(--gold-1)}
.levels button[aria-checked="true"] .sw{color:#f3d9b8}
@media (max-width:900px){.levels{grid-template-columns:repeat(2,minmax(0,1fr))}}

.opts{display:flex;flex-wrap:wrap;gap:10px;margin-top:14px}
.toggle{display:inline-flex;align-items:center;gap:10px;min-height:48px;padding:8px 16px 8px 10px;border-radius:999px;background:rgba(0,0,0,.28);border:1.5px solid rgba(233,185,90,.3);font-size:1rem;text-align:left}
.toggle i{width:40px;height:24px;border-radius:999px;background:rgba(255,255,255,.14);position:relative;flex:none;transition:background .2s}
.toggle i::after{content:"";position:absolute;top:3px;left:3px;width:18px;height:18px;border-radius:50%;background:var(--cream);transition:transform .2s}
.toggle[aria-checked="true"]{border-color:var(--gold-1)}
.toggle[aria-checked="true"] i{background:var(--gold-2)}
.toggle[aria-checked="true"] i::after{transform:translateX(16px)}
.toggle small{display:block;color:var(--cream-dim);font-size:.86rem}

.go{display:flex;align-items:center;justify-content:center;gap:14px;flex-wrap:wrap;margin-top:22px}
.pill{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:52px;padding:10px 26px;border-radius:999px;font-weight:700;font-size:1.1rem;text-decoration:none;background:rgba(0,0,0,.28);border:1.5px solid rgba(233,185,90,.45)}
.pill.gold{background:var(--gold-1);color:#2a1706;border-color:var(--gold-1);box-shadow:0 4px 0 var(--gold-3),0 12px 26px rgba(0,0,0,.35)}
.pill.gold:hover{background:#f4cb72}
.pill.gold:active{transform:translateY(2px);box-shadow:0 2px 0 var(--gold-3)}
.pill.big{min-height:60px;font-size:1.3rem;padding:12px 40px}
.pill:disabled{opacity:.5;cursor:not-allowed}
.best-line{color:var(--cream-dim);font-size:1rem;text-align:center;margin-top:10px}
.best-line b{color:var(--gold-text)}

.howto{margin-top:34px;padding:18px clamp(14px,2.4vw,22px);border-top:1px solid rgba(233,185,90,.22)}
.howto ul{list-style:none;display:grid;gap:10px;max-width:74ch}
.howto li{color:var(--cream-dim)}
.howto li b{color:var(--cream)}
.maker{display:flex;flex-direction:column;align-items:center;gap:8px;margin-top:30px;color:var(--cream-dim);font-size:.95rem;text-align:center}
.maker img{height:44px;width:auto;opacity:.9}
.more98{display:inline-flex;align-items:center;min-height:44px;padding:4px 14px;color:var(--gold-text);text-decoration:underline;text-underline-offset:3px}
.nojs{position:relative;z-index:2;text-align:center;padding:12px 16px 40px;color:var(--gold-text)}

@media (max-width:760px),(max-height:520px){
  /* Begin is always one thumb away: it rides the bottom of the screen */
  /* the Support/Share dock sits in its own row under Begin, never over it */
  .go{position:sticky;bottom:0;z-index:20;margin:14px -16px 0;padding:14px 16px calc(70px + env(safe-area-inset-bottom));
    background:linear-gradient(rgba(7,28,25,0),rgba(7,28,25,.94) 22%,rgba(7,28,25,.98))}
  .go .pill.big{width:min(100%,460px);padding-left:20px;padding-right:20px}
  body:not(.in-game) .nsm-dock{bottom:calc(12px + env(safe-area-inset-bottom))}
}
@media (max-width:760px){
  #setup{padding-bottom:96px}
  .hero{grid-template-columns:auto minmax(0,1fr);text-align:left;gap:4px 16px;margin:0 0 6px}
  .hero-art{width:clamp(96px,30vw,136px);order:0;grid-row:1 / span 3}
  .hero>div:last-child{display:contents}
  .hero .eyebrow{grid-column:2;align-self:end;font-size:.8rem;letter-spacing:.1em}
  .hero .wordmark{grid-column:2;font-size:clamp(2.4rem,12vw,3.2rem);margin:0}
  .hero .meaning{grid-column:2;align-self:start;font-size:1rem}
  .hero .lede{grid-column:1 / -1;margin:8px 0 0;max-width:none;font-size:1.06rem}
  .hero .demo{grid-column:1 / -1;margin-top:8px}
  .pick{margin-top:12px;padding:14px 14px 16px}
  .pick h2{font-size:1.2rem;margin-bottom:10px}
  .ways{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  .way{grid-template-columns:1fr;justify-items:center;text-align:center;padding:10px 6px;gap:4px;min-height:100px}
  .way svg{grid-row:auto;width:44px;height:44px}
  .way b{font-size:1.06rem;line-height:1.1}
  .way span{display:none}
  .way-line{display:block;margin-top:10px;color:var(--cream-dim);font-size:1rem;line-height:1.35;min-height:2.7em}
  .levels button{min-height:0}
  .levels .sw{display:none}
  .opts{flex-direction:column}
  .toggle{width:100%;border-radius:16px}
}
@media (max-height:520px) and (min-width:761px){
  /* a phone on its side: Begin and the Support/Share dock share one short bar */
  .go{justify-content:flex-start;padding:10px 410px calc(10px + env(safe-area-inset-bottom)) 16px}
  .go .pill.big{min-height:52px;font-size:1.15rem}
  body:not(.in-game) .nsm-dock{bottom:calc(14px + env(safe-area-inset-bottom))}
  .hero{margin:4px 0 12px}
  .hero-art{width:180px}
  .wordmark{font-size:3rem}
}

/* ================= play ================= */
body.in-game{height:100vh;height:100dvh;overflow:hidden;display:flex;flex-direction:column}
body.in-game .top{flex:none;width:100%}
#play{padding:0 max(8px,env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}
#play.active{flex:1 1 auto;min-height:0;width:100%;max-width:1400px;margin:0 auto;display:grid;
  grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto;grid-template-areas:"rail" "stage" "side";gap:6px}
.rail{grid-area:rail;display:flex;flex-wrap:wrap;gap:6px;justify-content:center}
.rail:empty{display:none}
.stage{grid-area:stage;min-height:0;min-width:0;display:grid;place-items:center}
.side{grid-area:side;display:flex;flex-direction:column;align-items:center;gap:8px;min-width:0}
.chip{display:inline-flex;align-items:center;gap:8px;min-height:40px;padding:4px 12px 4px 8px;border-radius:999px;background:rgba(0,0,0,.32);border:2px solid transparent;font-size:1rem;transition:transform .25s,border-color .25s,background .25s}
.chip i{width:14px;height:14px;border-radius:50%;flex:none}
.chip b{font-family:"Yeseva One",serif;font-weight:400;color:var(--gold-text)}
.chip.turn{border-color:var(--c);background:color-mix(in srgb,var(--c) 26%,rgba(0,0,0,.4));transform:translateY(-1px)}
.chip.out{opacity:.5;text-decoration:line-through}
.chip.me{border-color:rgba(233,185,90,.5)}
.chip .pill{min-height:34px;padding:2px 12px;font-size:.92rem}

.say{text-align:center;font-size:1.02rem;line-height:1.25;height:4.1em;overflow:hidden;max-width:44ch;display:flex;flex-direction:column;justify-content:center}
.say b{font-family:"Yeseva One",serif;font-weight:400;font-size:1.22rem;color:var(--cream);letter-spacing:.01em}
.say small{display:block;color:var(--cream-dim);font-size:1rem;margin-top:2px}
.tools{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}
.tool{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;min-width:64px;padding:6px 14px;border-radius:999px;background:rgba(0,0,0,.32);border:1.5px solid rgba(233,185,90,.4);font-size:1rem}
.tool svg{width:20px;height:20px;flex:none}
.tool[aria-pressed="true"]{background:var(--gold-1);color:#2a1706;border-color:var(--gold-1)}
.tool[aria-pressed="true"] path[fill="#f2cf7e"]{fill:#2a1706}
.tool[aria-pressed="true"] [stroke="#f2cf7e"]{stroke:#2a1706}
.tool:disabled{opacity:.45}
.pencil{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:6px}
.pencil>span{color:var(--cream-dim);font-style:italic;width:100%;text-align:center;font-size:.98rem}
.pencil button{min-width:44px;min-height:44px;border-radius:12px;background:rgba(0,0,0,.32);border:1.5px solid rgba(233,185,90,.35);font-family:"Yeseva One",serif;font-size:1.15rem}
.pencil button[aria-pressed="true"]{background:var(--gold-1);color:#2a1706;border-color:var(--gold-1)}
.pencil button:disabled{opacity:.4}

/* ---------- the setup: scales ---------- */
.scales{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.scales button{min-height:58px;text-align:left;border-radius:14px;padding:8px 12px;background:rgba(0,0,0,.3);border:1.5px solid rgba(233,185,90,.25);display:flex;flex-direction:column;gap:1px}
.scales b{font-family:"Yeseva One",serif;font-weight:400;font-size:1.06rem}
.scales span{font-size:.9rem;color:var(--cream-dim)}
.scales button[aria-checked="true"]{background:linear-gradient(160deg,var(--lacquer-1),var(--lacquer-2));border-color:var(--gold-1)}
.scales button[aria-checked="true"] span{color:#f3d9b8}
@media (max-width:760px){.scales{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.scales span{display:none}.scales button{min-height:48px;padding:6px 8px;align-items:center;text-align:center}.scales b{font-size:.98rem}}

/* ================= play: the easel ================= */
body.in-game{height:100vh;height:100dvh;overflow:hidden;display:flex;flex-direction:column}
body.in-game .top{flex:none;width:100%}
#play{padding:0 max(8px,env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}
#play.active{flex:1 1 auto;min-height:0;width:100%;max-width:1500px;margin:0 auto;display:flex;flex-direction:column;gap:6px}
.rail{flex:none}
.studio{flex:1 1 auto;min-height:0;display:grid;gap:10px;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto auto;grid-template-areas:"easel" "tray" "side"}
.easel{grid-area:easel;align-self:stretch;justify-self:stretch;min-height:0;min-width:0;position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px}
.tray{grid-area:tray}
.side{grid-area:side;display:flex;flex-direction:column;gap:8px;min-width:0}

/* the board behind the paper: teak, with brass clips holding the sheet */
.sheet-wrap{position:relative;display:flex;align-items:stretch;gap:0;padding:12px 12px 12px 6px;border-radius:12px;
  background:repeating-linear-gradient(92deg,rgba(42,20,6,0) 0 11px,rgba(42,20,6,.15) 11px 12px,rgba(42,20,6,0) 12px 27px),linear-gradient(135deg,#8a5228,#5a3014 55%,#3c1e0a);
  border:2px solid #2a1406;box-shadow:inset 0 0 0 2px rgba(233,185,90,.25),0 3px 0 #1c0d04,0 22px 44px rgba(0,0,0,.5)}
.clips{position:absolute;top:0;left:0;right:0;height:0;z-index:3;pointer-events:none}
.clips i{position:absolute;top:-4px;width:46px;height:20px;border-radius:5px;background:radial-gradient(circle at 38% 32%,#fff4cf,#f2cf7e 55%,#c8913a);border:1.5px solid #5a3210;box-shadow:0 3px 6px rgba(0,0,0,.4)}
.clips i:first-child{left:24%}.clips i:last-child{right:24%}
.ruler{display:block;flex:none;width:38px}
.paper-box{position:relative;flex:none;background:#fbf5e6;box-shadow:0 2px 0 rgba(0,0,0,.25),0 0 0 1px rgba(42,20,6,.5)}
#paper,#over{position:absolute;inset:0;width:100%;height:100%;display:block}
#paper{image-rendering:pixelated;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;cursor:crosshair}
#over{pointer-events:none}
body.no-ruler .ruler{display:none}
body.no-ruler .sheet-wrap{padding-left:12px}
.status{min-height:1.4em;font-size:.95rem;color:var(--cream-dim);font-style:italic;text-align:center;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.status b{color:var(--gold-text);font-style:normal}

/* the tray of tools: wooden tiles on a teak ledge */
.tray{display:flex;flex-wrap:wrap;justify-content:center;gap:6px;padding:8px;border-radius:14px;
  background:linear-gradient(180deg,#8a5a2c,#7a4520 14%,#5a3014 70%,#3c1e0a);box-shadow:inset 0 2px 0 rgba(255,210,150,.3),0 3px 0 #1c0d04,0 12px 24px rgba(0,0,0,.35)}
.tl{width:46px;height:46px;border-radius:11px;display:grid;place-items:center;background:linear-gradient(180deg,#f4e7c9,#e0cba0);border:1.5px solid #3a2410;box-shadow:0 3px 0 #3a2410,inset 0 1px 0 #fff8e4;transition:transform .1s,box-shadow .1s}
.tl svg{width:30px;height:30px}
.tl[aria-pressed="true"]{background:linear-gradient(180deg,#f2cf7e,#d9a845);transform:translateY(2px);box-shadow:0 1px 0 #3a2410,inset 0 2px 4px rgba(90,50,16,.4);outline:2px solid #fff3c4;outline-offset:1px}
.tl.act{background:linear-gradient(180deg,#5a3014,#3c1e0a);border-color:#caa04a;box-shadow:0 3px 0 #1c0d04,inset 0 1px 0 rgba(255,210,150,.25)}
.tl.act:disabled{opacity:.4}
.tl:active{transform:translateY(2px)}
.tl#more[aria-expanded="true"]{background:linear-gradient(180deg,#b23a20,#6d1b0d)}

/* the palette: a kidney of wood with a thumb hole and dabs of paint */
.palette{position:relative;display:grid;grid-template-columns:repeat(7,44px);gap:6px;justify-content:center;padding:12px 14px;border-radius:28px 40px 34px 22px / 26px 30px 40px 30px;
  background:radial-gradient(circle at 88% 70%,rgba(42,20,6,.75) 0 12px,rgba(42,20,6,0) 13px),radial-gradient(120% 120% at 30% 20%,#ddb37a,#c99a62 50%,#a87a44);
  border:2px solid #5a3014;box-shadow:inset 0 2px 0 rgba(255,240,210,.5),0 3px 0 #3a1e08,0 14px 26px rgba(0,0,0,.4)}
.dab{width:44px;height:44px;border-radius:46% 54% 50% 50% / 52% 46% 54% 48%;background:var(--c);border:1.5px solid rgba(42,20,6,.55);box-shadow:inset -3px -4px 0 rgba(0,0,0,.18),inset 3px 3px 0 rgba(255,255,255,.28)}
.dab[data-paper]{background:#fbf5e6;background-image:linear-gradient(135deg,transparent 46%,rgba(200,50,31,.55) 47% 53%,transparent 54%)}
.dab[aria-checked="true"]{outline:3px solid #fff3c4;outline-offset:2px;transform:scale(1.06)}
.dab.second{box-shadow:inset -3px -4px 0 rgba(0,0,0,.18),inset 3px 3px 0 rgba(255,255,255,.28),0 0 0 3px #2a1406,0 0 0 5px #a9bccf}
.cbox{position:relative;width:44px;height:44px}
.cbox i{position:absolute;width:30px;height:30px;border-radius:8px;border:2px solid #2a1406;box-shadow:0 2px 3px rgba(0,0,0,.35)}
.cbox #cb-1{left:0;top:0;z-index:1}.cbox #cb-2{right:0;bottom:0}

/* the drawer: sizes and the less-used buttons */
.drawer{display:flex;flex-direction:column;gap:8px}
.sizes{display:flex;flex-wrap:wrap;gap:6px;justify-content:center}
.sizes button{min-width:48px;min-height:44px;border-radius:12px;background:rgba(0,0,0,.3);border:1.5px solid rgba(233,185,90,.3);display:grid;place-items:center;padding:4px 8px;font-size:.92rem}
.sizes button[aria-checked="true"]{background:var(--gold-1);color:#2a1706;border-color:var(--gold-1)}
.sizes i{display:block;background:currentColor;border-radius:50%}
.drawer-row{display:flex;gap:8px;justify-content:center;flex-wrap:wrap}
.bar{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;align-items:center}
.bar:empty{display:none}
.bar .led{display:inline-flex;gap:2px;padding:4px 5px;background:#140604;line-height:0;border-radius:6px;border:1.5px solid var(--gold-2);box-shadow:inset 0 2px 7px rgba(0,0,0,.85)}
.bar .led svg{width:12px;height:21px;display:block;filter:drop-shadow(0 0 2.5px rgba(255,80,30,.6))}
.led .on{fill:#ff5a2a}.led .off{fill:#3a1208}
.tempo{display:inline-flex;align-items:center;gap:6px}
.tempo .icon-btn{width:44px;height:44px;font-size:1.3rem}
.tempo small{font-size:.8rem;letter-spacing:.12em;text-transform:uppercase;color:var(--cream-dim)}
.tool.play{min-width:110px;background:linear-gradient(180deg,#b23a20,#8a2413);border-color:var(--gold-1)}
.tool.play[aria-pressed="true"]{background:var(--gold-1);color:#2a1706}
.tool.gold{background:var(--gold-1);color:#2a1706;border-color:var(--gold-1);font-weight:700}
.bar select{font:inherit;font-size:1rem;color:var(--cream);background:rgba(0,0,0,.35);border:1.5px solid rgba(233,185,90,.4);border-radius:999px;min-height:44px;padding:4px 12px}
.stars{color:var(--gold-1);letter-spacing:.12em;font-size:1.1rem}
.say{text-align:center;font-size:1rem;line-height:1.25;min-height:2.6em}
.say b{font-family:"Yeseva One",serif;font-weight:400;font-size:1.15rem;color:var(--cream)}
.say small{display:block;color:var(--cream-dim);font-size:1rem;margin-top:2px}

/* portrait phones: the drawer waits behind "More options" */
@media (max-aspect-ratio:5/4){
  .drawer{display:none}
  .drawer.open{display:flex}
  .tray{padding:6px;gap:5px}
}
@media (max-aspect-ratio:5/4) and (max-width:520px){
  #play{padding-left:max(4px,env(safe-area-inset-left));padding-right:max(4px,env(safe-area-inset-right))}
  .studio{gap:6px}
  .tl{width:44px;height:44px}
  .tl svg{width:27px;height:27px}
  .palette{grid-template-columns:repeat(7,44px);gap:4px;padding:8px 10px;border-radius:20px}
  .sheet-wrap{padding:8px 8px 8px 4px}
  .ruler{width:30px}
  .status{font-size:1rem}
  .say{min-height:2.4em;font-size:1rem}
}

/* landscape: tools on the left, the easel in the middle, the palette and the controls on the right */
@media (min-aspect-ratio:5/4){
  #play{--side:clamp(250px,24vw,340px)}
  .studio{grid-template-columns:auto minmax(0,1fr) var(--side);grid-template-rows:minmax(0,1fr);grid-template-areas:"tray easel side";align-items:center}
  .tray{flex-direction:column;flex-wrap:wrap;max-height:100%;align-content:flex-start;display:grid;grid-template-columns:repeat(2,46px);padding:10px}
  .tray #more{display:none}
  .side{align-self:stretch;justify-content:center;overflow-y:auto}
  .palette{grid-template-columns:repeat(5,44px)}
  .say{text-align:left}
}
@media (min-aspect-ratio:5/4) and (max-height:620px){
  body.in-game .top{position:fixed;top:0;right:0;width:calc(var(--side) + max(8px,env(safe-area-inset-right)) + 8px);max-width:none;margin:0;
    padding:calc(6px + env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) 0 8px;min-height:0;gap:6px;z-index:6;justify-content:flex-end}
  body.in-game .back{padding:6px;min-height:44px}
  body.in-game .back>span{display:none}
  body.in-game .top .title{display:none}
  #play{padding-top:calc(6px + env(safe-area-inset-top))}
  .studio{gap:8px}
  .side{padding-top:52px;justify-content:flex-start;gap:6px}
  .tray{padding:6px;gap:4px;grid-template-columns:repeat(2,44px)}
  .tl{width:44px;height:44px}.tl svg{width:26px;height:26px}
  .palette{grid-template-columns:repeat(7,30px);gap:4px;padding:6px 8px;border-radius:16px}
  .dab{width:30px;height:30px}.cbox{width:30px;height:30px}.cbox i{width:20px;height:20px}
  .drawer{display:none}
  .drawer.open{display:flex}
  .tray #more{display:grid}
  .sheet-wrap{padding:8px 8px 8px 4px}
  .ruler{width:30px}
  .status{display:none}
  .say{min-height:0;font-size:1rem}
  .say b{font-size:1rem}
  .bar{gap:6px}
  .bar .tool{min-height:44px;padding:4px 10px;font-size:.95rem}
  .tempo small{display:none}
}
.chip .pill{min-height:34px;padding:2px 12px;font-size:.92rem}
.card canvas.reveal{width:100%;height:auto;border-radius:8px;background:#fbf5e6;margin:10px 0 4px;display:block}
.card .legend{display:flex;flex-wrap:wrap;gap:8px 14px;justify-content:center;font-size:.95rem;color:var(--cream-dim)}
.card .legend i{display:inline-block;width:14px;height:6px;border-radius:3px;margin-right:5px;vertical-align:middle}
.veil.peek{background:rgba(7,22,20,.4)}
/* ---------- sheets ---------- */
.veil{position:fixed;inset:0;z-index:50;display:none;align-items:center;justify-content:center;padding:16px;background:rgba(7,22,20,.74);backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);overflow-y:auto}
.veil.open{display:flex}
.card{position:relative;width:min(560px,100%);margin:auto;border-radius:22px;padding:24px clamp(16px,4vw,28px);text-align:center;
  background:linear-gradient(160deg,#2a1a12,#1a100b);border:1px solid rgba(233,185,90,.4);box-shadow:0 30px 70px rgba(0,0,0,.6),inset 0 1px 0 rgba(255,225,170,.2)}
.card h2{font-family:"Yeseva One",serif;font-weight:400;font-size:clamp(1.6rem,5vw,2.2rem);line-height:1.1;margin-bottom:8px}
.card p{color:var(--cream-dim);font-size:1.06rem;margin-top:6px}
.card .row{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;margin-top:18px}
.card .eyebrow{font-size:.84rem}
.card.wide{width:min(640px,100%);text-align:left}
.card.wide h2,.card.wide .row{text-align:center}
.big-num{font-family:"Yeseva One",serif;font-size:clamp(3.2rem,13vw,4.6rem);line-height:1;color:var(--gold-text);margin:.1em 0}
.pass-card{border:3px solid var(--c,var(--gold-1));background:radial-gradient(120% 90% at 50% 0%,color-mix(in srgb,var(--c,#e9b95a) 30%,#1a100b),#1a100b 70%)}
.pass-card .to{font-size:1rem;letter-spacing:.3em;text-transform:uppercase;color:var(--cream-dim)}
.pass-card .who{font-family:"Yeseva One",serif;font-size:clamp(2.8rem,12vw,4.6rem);line-height:1.05;color:var(--c,var(--gold-1));text-shadow:0 4px 30px rgba(0,0,0,.6);margin:.1em 0;word-break:break-word}
.podium{display:grid;grid-template-columns:repeat(3,1fr);align-items:end;gap:8px;margin:16px 0 8px}
.podium .step{display:flex;flex-direction:column;align-items:center;gap:6px;min-width:0}
.podium .block{width:100%;border-radius:12px 12px 4px 4px;display:grid;place-items:center;font-family:"Yeseva One",serif;font-size:1.8rem;color:#2a1706;background:linear-gradient(180deg,var(--gold-1),var(--gold-3));box-shadow:inset 0 2px 0 rgba(255,245,210,.6)}
.podium .p1 .block{height:110px}.podium .p2 .block{height:78px;filter:saturate(.3) brightness(1.05)}.podium .p3 .block{height:56px;filter:sepia(.6) hue-rotate(-20deg) brightness(.85)}
.podium .nm{font-family:"Yeseva One",serif;font-size:1.1rem;word-break:break-word}
.podium .nm i{display:inline-block;width:12px;height:12px;border-radius:50%;margin-right:6px;vertical-align:middle}
.podium small{color:var(--cream-dim);font-size:.9rem}
.rest{list-style:none;display:grid;gap:6px;margin-top:8px}
.rest li{display:flex;justify-content:space-between;gap:10px;padding:6px 12px;border-radius:10px;background:rgba(0,0,0,.25)}
.tbl{width:100%;border-collapse:collapse;margin:10px 0;font-size:1rem}
.tbl th,.tbl td{text-align:left;padding:7px 8px;border-bottom:1px solid rgba(233,185,90,.18);vertical-align:middle}
.tbl th{color:var(--gold-text);font-weight:700}
.tbl .n{text-align:right;font-variant-numeric:tabular-nums}
.tbl i{display:inline-block;width:12px;height:12px;border-radius:50%;margin-right:6px;vertical-align:-1px}
.tbl .chip-btn{min-height:40px;padding:2px 12px}
.lobby-wrap{width:min(560px,100%);margin:auto}
.lobby-set{margin-top:10px;color:var(--gold-text);font-size:1rem;text-align:center}
.nsmr-status{z-index:70}
.help-list{list-style:none;display:grid;gap:8px;margin-top:6px}
.help-list li{color:var(--cream-dim)}
.help-list b{color:var(--cream)}

@media (max-height:520px){
  .veil{padding:10px}
  .card{padding:14px 18px}
  .card h2{font-size:1.45rem}
  .card .row{margin-top:10px}
  .big-num{font-size:2.6rem}
  .pass-card .who{font-size:2.6rem}
  .podium{margin:8px 0 4px}
  .podium .p1 .block{height:64px}.podium .p2 .block{height:46px}.podium .p3 .block{height:34px}
  .card .row .pill{min-height:46px;padding:8px 18px;font-size:1rem}
}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.001ms!important;transition-duration:.001ms!important}
}

.side>*{max-width:100%;min-width:0}
.side .palette{align-self:center}
@media (max-aspect-ratio:5/4) and (max-width:520px){ .side .palette{align-self:stretch} }
@media (min-aspect-ratio:5/4) and (max-height:620px){
  .side .palette{align-self:stretch;display:flex;flex-wrap:nowrap;overflow-x:auto;overscroll-behavior-x:contain;justify-content:flex-start;gap:6px;padding:6px 8px;border-radius:16px;
    -webkit-mask-image:linear-gradient(90deg,#000 86%,transparent);mask-image:linear-gradient(90deg,#000 86%,transparent)}
  .side .palette>*{flex:none}
  .side .dab{width:44px;height:44px}.side .cbox{width:44px;height:44px}.side .cbox i{width:30px;height:30px}
}
/* the second row of tools lives in the drawer on upright phones only */
.tray2{display:none;flex-wrap:wrap;gap:6px;justify-content:center;padding:6px;border-radius:12px;background:linear-gradient(180deg,#7a4520,#5a3014)}
@media (max-aspect-ratio:5/4) and (max-width:520px){
  .tray2{display:flex}
  .tray [data-tool="rect"],.tray [data-tool="ellipse"],.tray [data-tool="eraser"],.tray [data-tool="pick"],.tray #redo{display:none}
  .tray{flex-wrap:nowrap;justify-content:space-between}
  /* the palette: one row of paint you slide along */
  .palette{display:flex;flex-wrap:nowrap;overflow-x:auto;overscroll-behavior-x:contain;scroll-snap-type:x proximity;justify-content:flex-start;gap:6px;padding:8px 10px;border-radius:18px;
    -webkit-mask-image:linear-gradient(90deg,#000 88%,transparent);mask-image:linear-gradient(90deg,#000 88%,transparent)}
  .palette>*{flex:none;scroll-snap-align:start}
  .bar{gap:6px}
  .bar .tool{min-height:44px;padding:4px 12px;font-size:.98rem}
  .bar .tool.play{min-width:0}
}
