/* Star board runtime. Layout is authored on a 390×660 canvas scaled by --sb-scale;
   colours and art come from the theme (--sb-* variables set by theme.js). Seat corners are
   physical (they sit next to the board corner of that colour) so they do not mirror in RTL. */
html,body{margin:0;height:100%;background:transparent;overflow:hidden;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
.sb-app{--sb-scale:1;position:fixed;inset:0;font-family:var(--sb-font-body,system-ui,sans-serif);color:var(--sb-paper,#fff);user-select:none;-webkit-user-select:none}
.sb-app *{box-sizing:border-box}
.sb-app img{pointer-events:none}
.sb-panel{position:absolute;inset:auto 0 0;height:75%;overflow:hidden;background:var(--sb-bg) center/cover no-repeat,var(--sb-base,#234);border-radius:22px 22px 0 0;box-shadow:0 -6px 24px rgba(0,0,0,.35)}
.sb-app[data-mode=full] .sb-panel{height:100%;border-radius:0}
.sb-panel::before{content:"";position:absolute;inset:0;background:linear-gradient(180deg,rgba(0,0,0,.3),rgba(0,0,0,0) 20%,rgba(0,0,0,0) 72%,rgba(0,0,0,.35))}
.sb-canvas{position:absolute;left:50%;top:50%;width:390px;height:660px;transform:translate(-50%,-50%) scale(var(--sb-scale));transform-origin:50% 50%}
[hidden]{display:none!important}

/* buttons */
:where(.sb-app) button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:pointer}
.sb-app button:disabled{cursor:default}
.sb-app button:focus-visible,.sb-app a:focus-visible{outline:3px solid var(--sb-glow,#fff2a8);outline-offset:2px}
.sb-btn{display:grid;place-items:center;width:36px;height:36px;border-radius:50%;background:var(--sb-art-button) center/contain no-repeat;color:var(--sb-paper,#fff);text-decoration:none;filter:drop-shadow(0 2px 2px rgba(0,0,0,.4));transition:transform .12s}
.sb-btn:active{transform:scale(.9)}
.sb-glyph{font:800 20px/1 var(--sb-font-display);text-shadow:0 1px 0 rgba(0,0,0,.5)}
.sb-back .sb-glyph{font-size:28px;margin-top:-3px}
.sb-action{display:grid;place-items:center;min-width:132px;height:44px;padding:0 18px;background:var(--sb-art-plate) center/100% 100% no-repeat;color:var(--sb-paper,#fff);font:900 15px/1 var(--sb-font-display);text-decoration:none;text-shadow:0 1px 2px rgba(0,0,0,.6);filter:drop-shadow(0 3px 2px rgba(0,0,0,.35));transition:transform .12s,filter .12s}
.sb-action:active:not(:disabled){transform:scale(.95)}
.sb-action:disabled{filter:grayscale(.8) brightness(.8);opacity:.7}
.sb-secondary{min-width:110px;height:38px;font-size:13px}

/* top bar */
.sb-top{position:absolute;inset:6px 8px auto;height:54px;display:grid;grid-template-columns:36px 1fr auto;align-items:center;gap:6px;direction:ltr}
.sb-title{height:44px;max-width:150px;object-fit:contain;justify-self:start;filter:drop-shadow(0 2px 3px rgba(0,0,0,.45))}
.sb-actions{display:flex;gap:5px}
.sb-actions .sb-btn{width:34px;height:34px}
.sb-actions .sb-glyph{font-size:17px}

/* status */
.sb-status{position:absolute;left:104px;width:182px;top:64px;height:72px;padding:4px 8px;border-radius:14px;background:rgba(0,0,0,.42);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,.75)}
.sb-mode-pill{padding:2px 10px;border-radius:10px;background:rgba(0,0,0,.35);border:1px solid rgba(255,255,255,.35);font-size:10px;font-weight:800;letter-spacing:.02em}
.sb-status-text{margin:0;font:900 14px/1.2 var(--sb-font-display)}
.sb-status-note{margin:0;font-size:10.5px;font-weight:700;opacity:.9;line-height:1.2}
.sb-status-note:empty{display:none}
.sb-status.my-turn .sb-status-text{color:var(--sb-glow,#fff2a8);animation:sb-beat 1s ease-in-out infinite}
@keyframes sb-beat{50%{transform:scale(1.06)}}

/* seats */
.sb-seat{position:absolute;width:92px;height:76px;display:flex;flex-direction:column;align-items:center;gap:1px;text-shadow:0 1px 2px rgba(0,0,0,.8);--sb-seat-color:rgba(255,255,255,.35)}
.sb-seat-tl{left:6px;top:62px}.sb-seat-tr{right:6px;top:62px}
.sb-seat-bl{left:6px;top:504px}.sb-seat-br{right:6px;top:504px}
.sb-avatar{position:relative;width:46px;height:46px;flex:none}
.sb-badge{position:absolute;inset:7px;display:grid;place-items:center;border-radius:50%;background:radial-gradient(circle at 35% 30%,rgba(255,255,255,.55),transparent 55%),var(--sb-seat-color);font:900 16px/1 var(--sb-font-display);color:#fff}
.sb-seat-frame{position:absolute;inset:0;width:100%;height:100%}
.sb-ring{position:absolute;inset:-4px;border-radius:50%;background:conic-gradient(var(--sb-glow,#fff2a8) calc(var(--sb-p,1)*360deg),rgba(0,0,0,.25) 0);-webkit-mask:radial-gradient(circle,transparent 25px,#000 26px);mask:radial-gradient(circle,transparent 25px,#000 26px)}
.sb-ring.urgent{background:conic-gradient(#ff5a4e calc(var(--sb-p,1)*360deg),rgba(0,0,0,.25) 0)}
.sb-name{margin-top:3px;padding:0 5px;border-radius:6px;background:rgba(0,0,0,.42);max-width:92px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11.5px;font-weight:800}
.sb-tag{position:absolute;top:37px;left:50%;transform:translateX(-50%);padding:1px 6px;border-radius:7px;background:var(--sb-accent,#ffd447);color:var(--sb-ink,#3b1a06);font-style:normal;font-size:9px;font-weight:900;line-height:1.1;text-shadow:none;white-space:nowrap;z-index:1}
.sb-tag:empty{display:none}
.sb-detail{max-width:92px;padding:1px 5px;border-radius:6px;background:rgba(0,0,0,.42);font-size:9.5px;font-weight:700;line-height:1.15;text-align:center}
.sb-detail:empty{display:none}
.sb-seat.empty{opacity:.6}
.sb-seat.empty .sb-badge{background:rgba(0,0,0,.3);border:1px dashed rgba(255,255,255,.6)}
.sb-seat.active .sb-avatar::after{content:"";position:absolute;inset:-14px;background:var(--sb-art-glow) center/contain no-repeat;z-index:-1;animation:sb-pulse 1.2s ease-in-out infinite}
.sb-seat.active .sb-name{color:var(--sb-glow,#fff2a8)}
@keyframes sb-pulse{50%{opacity:.55;transform:scale(1.08)}}

/* board + dock (owned by the stage) */
.sb-board-host{position:absolute;left:15px;top:140px;width:360px;height:360px}
.sb-dock{position:absolute;left:100px;width:190px;top:504px;height:150px;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:6px}
.sb-app:not([data-stage=active]):not([data-stage=finished]) .sb-dock{visibility:hidden}

/* lobby overlay */
.sb-lobby{position:absolute;left:24px;top:150px;width:342px;height:340px;padding:44px 34px 30px;background:var(--sb-art-panel) center/100% 100% no-repeat;color:var(--sb-ink,#3b1a06);display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center;z-index:5;animation:sb-rise .25s ease-out}
.sb-lobby-title{margin:0;font:900 19px/1.1 var(--sb-font-display)}
.sb-lobby-text{margin:0;font-size:12.5px;font-weight:700;line-height:1.3;opacity:.85}
.sb-lobby-modes{display:flex;flex-direction:column;gap:5px;width:100%}
.sb-mode-choice{display:flex;flex-direction:column;align-items:flex-start;gap:1px;width:100%;padding:5px 10px;border-radius:10px;border:2px solid rgba(0,0,0,.15);background:rgba(255,255,255,.45);text-align:start}
.sb-mode-choice strong{font-size:13px}
.sb-mode-choice small{font-size:10.5px;line-height:1.2;opacity:.8}
.sb-mode-choice[aria-checked=true]{border-color:var(--sb-accent,#ffd447);background:rgba(255,255,255,.85);box-shadow:0 0 0 2px var(--sb-accent2,#ff8a1f) inset}
.sb-lobby-actions{display:flex;flex-wrap:wrap;justify-content:center;gap:6px}
.sb-lobby-list{display:flex;flex-direction:column;align-items:center;gap:6px;width:100%;overflow-y:auto;flex:1;min-height:0}
.sb-join{width:100%;max-width:240px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sb-invite{width:100%;font-size:11px;padding:4px 6px;border-radius:6px;border:1px solid rgba(0,0,0,.3);user-select:text;-webkit-user-select:text}

/* pending confirmation, toast */
.sb-retry{position:absolute;left:70px;right:70px;top:452px;height:40px;border-radius:20px;background:var(--sb-ink,#3b1a06);color:var(--sb-paper,#fff);font-weight:900;font-size:13px;z-index:6;box-shadow:0 3px 0 rgba(0,0,0,.4)}
.sb-retry.pulse{animation:sb-beat .5s ease-in-out 3}
.sb-toast{position:absolute;left:40px;right:40px;top:290px;padding:16px;border-radius:16px;background:var(--sb-paper,#fff6dc);border:3px solid var(--sb-ink,#3b1a06);color:var(--sb-ink,#3b1a06);text-align:center;font-weight:800;font-size:14px;line-height:1.35;z-index:8;animation:sb-rise .25s ease-out}

/* result */
.sb-result{position:absolute;left:35px;top:120px;width:320px;height:400px;padding:86px 46px 26px;background:var(--sb-art-result) center/100% 100% no-repeat;color:var(--sb-ink,#3b1a06);display:flex;flex-direction:column;align-items:center;gap:10px;z-index:7;animation:sb-rise .3s ease-out}
.sb-result-title{position:absolute;top:16px;left:40px;right:40px;height:38px;margin:0;display:grid;place-items:center;font:900 18px/1.1 var(--sb-font-display);color:var(--sb-paper,#fff);text-shadow:0 2px 2px rgba(0,0,0,.55);text-align:center}
.sb-firework{position:absolute;inset:-60px -40px auto;height:240px;width:calc(100% + 80px);object-fit:contain;opacity:0;z-index:-1}
.sb-result.won .sb-firework{animation:sb-burst 1.6s ease-out 2}
@keyframes sb-burst{0%{opacity:0;transform:scale(.4)}30%{opacity:1}100%{opacity:0;transform:scale(1.15)}}
.sb-result-list{list-style:none;margin:0;padding:0;width:100%;display:flex;flex-direction:column;gap:6px;flex:1;min-height:0;overflow-y:auto}
.sb-result-row{display:grid;grid-template-columns:22px 26px 1fr auto;align-items:center;gap:7px;padding:6px 8px;border-radius:10px;background:rgba(255,255,255,.5);font-size:13px;font-weight:800;--sb-seat-color:#888}
.sb-result-row .sb-badge{position:static;width:26px;height:26px;font-size:12px}
.sb-result-row.winner{background:linear-gradient(90deg,rgba(255,212,71,.75),rgba(255,138,31,.35));outline:2px solid var(--sb-accent,#ffd447)}
.sb-result-row.me .sb-result-name{text-decoration:underline;text-underline-offset:3px}
.sb-result-no{display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:var(--sb-ink,#3b1a06);color:var(--sb-paper,#fff);font-size:12px}
.sb-result-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sb-result-detail{font-size:11.5px}
.sb-result-actions{display:flex;gap:8px;justify-content:center}
.sb-result-actions .sb-action{min-width:118px}

/* sheets: rules / sound */
.sb-sheet{position:absolute;inset:60px 12px 10px;padding:84px 58px 58px;background:var(--sb-art-panel) center/100% 100% no-repeat;color:var(--sb-ink,#3b1a06);z-index:9;display:flex;flex-direction:column;animation:sb-rise .25s ease-out}
.sb-sheet-title{position:absolute;inset:38px 70px auto;margin:0;text-align:center;font:900 19px/1 var(--sb-font-display)}
.sb-sheet-close{position:absolute;top:22px;inset-inline-end:22px}
.sb-sheet-body{flex:1;overflow-y:auto;font-size:13px;line-height:1.45;-webkit-overflow-scrolling:touch}
.sb-rule{margin:0 0 10px}
.sb-slider{display:grid;grid-template-columns:auto 1fr 32px;gap:10px;align-items:center;margin:14px 0;font-weight:800}
.sb-slider input{width:100%;accent-color:var(--sb-accent2,#ff8a1f)}
.sb-mute{width:100%;margin-top:10px;height:40px;border-radius:20px;border:2px solid var(--sb-ink,#3b1a06);font-weight:900}
.sb-mute[aria-pressed=true]{background:var(--sb-ink,#3b1a06);color:var(--sb-paper,#fff6dc)}

@keyframes sb-rise{from{opacity:0;transform:translateY(16px) scale(.96)}}
@media (prefers-reduced-motion:reduce){.sb-app *{animation:none!important;transition:none!important}}
