/* Fallback colors for the page; the stage gets its colors from the saved look */
:root{--bg:#fff6d9;--glow:#ffffff;--page:#c9ccd9;--ink:#1b2a4a;--muted:#5b6378;--accent:#1f5fbf;--accent2:#d92b2b;--mark:#ffc526;--line:#e8c96a;--card:#ffffff;--opbg:#fffaf0;--ballBg:#ffffff;--cell:#fff1c2;--cellInk:#7a5c00;--called:#1f5fbf;--calledInk:#ffffff;--latest:#ffc526;--latestInk:#1b2a4a;--pw:min(300px,40vw);color-scheme:light}
*{box-sizing:border-box}
html,body{margin:0;height:100%;background:var(--page);color:var(--ink);font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;overflow:hidden}
[hidden]{display:none!important}
button,input,select{font:inherit}
button:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}

/* ===== DISPLAY: stage (ratio set by the operator, letterboxed) ===== */
#app{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;container-type:size;background:var(--page)}
body.open #app{right:var(--pw);padding:12px}
:root{--arw:16;--arh:9}
#stage{position:relative;width:min(100cqw,calc(100cqh * var(--arw) / var(--arh)));aspect-ratio:var(--arw)/var(--arh);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1.8cqh;padding:3cqh 3cqw;container-type:size;overflow:hidden;background:radial-gradient(circle at 50% 45%,var(--glow),var(--bg) 75%);color:var(--ink);--k:1}
body.open #stage{width:min(100%,calc((100cqh - 32px) * var(--arw) / var(--arh)));outline:1px dashed var(--line);outline-offset:4px}
#eventTitle{font-weight:700;font-size:calc(3cqh * var(--k));opacity:.75;letter-spacing:.04em;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:94cqw}
.top{display:flex;flex-direction:column;align-items:center;gap:1.4cqh;width:94cqw}
#ball{flex-shrink:0;width:min(16cqh,30cqw);aspect-ratio:1;border-radius:50%;border:min(.7cqh,1cqw) solid var(--mark);display:flex;flex-direction:column;align-items:center;justify-content:center;background:var(--ballBg);line-height:1}
#ballLetter{font-size:calc(3cqh * var(--k));font-weight:800;color:var(--accent)}
#ballNum{font-size:calc(8cqh * var(--k));font-weight:800;color:var(--ink)}
#history{display:flex;flex-wrap:nowrap;gap:.5cqh;justify-content:flex-end;width:min(60cqw,75cqh);overflow:hidden}
.chip{flex-shrink:0;background:var(--cell);color:var(--cellInk);border-radius:999px;padding:.3cqh 1.3cqh;font-weight:700;font-size:calc(2.6cqh * var(--k))}
.chip.latest{background:var(--latest);color:var(--latestInk)}
#board{display:grid;grid-template-columns:repeat(5,1fr);grid-template-rows:auto repeat(15,minmax(0,1fr));gap:.4cqh;width:min(60cqw,75cqh);height:62cqh}
.head{text-align:center;font-weight:800;font-size:calc(3.2cqh * var(--k));color:var(--accent);line-height:1.1}
.cell{display:flex;align-items:center;justify-content:center;min-height:0;border-radius:.6cqh;background:var(--cell);color:var(--cellInk);font-weight:700;font-size:calc(2.4cqh * var(--k));line-height:1}
.cell.op{cursor:pointer;user-select:none}
.cell.op:hover{filter:brightness(.92)}
.cell.called{background:var(--called);color:var(--calledInk)}
.cell.latest{background:var(--latest);color:var(--latestInk);box-shadow:inset 0 0 0 .3cqh var(--called)}
body.display #op{display:none!important}
body.display #app{padding:0;cursor:none}
body.display.ui #app{cursor:default}
#toast{position:fixed;left:50%;top:20px;transform:translateX(-50%);background:var(--card);border:1px solid var(--line);border-radius:12px;padding:10px 16px;font-size:15px;z-index:20;max-width:90vw;text-align:center}

/* ===== OPERATOR SIDE PANEL (fixed light style) ===== */
#op{position:fixed;top:0;right:0;bottom:0;width:var(--pw);background:var(--opbg);border-left:1px solid var(--line);overflow:auto;z-index:11;display:none}
body.open #op{display:block}
.opwrap{display:flex;flex-direction:column;gap:10px;padding:12px 12px 30px}
.opbar h2{margin:0;font-size:16px}
section{background:var(--card);border:1px solid var(--line);border-radius:10px;padding:10px;display:flex;flex-direction:column;gap:7px}
section h3{margin:0;font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted)}
section p{margin:0;color:var(--muted);font-size:12px;line-height:1.5}
select,input[type=number],input[type=text]{background:var(--opbg);color:var(--ink);border:1px solid var(--line);border-radius:8px;padding:7px 9px;font-size:14px;width:100%;min-width:0}
.btn{border-radius:8px;padding:6px 12px;font-size:13px;font-weight:600;cursor:pointer;background:var(--opbg);color:var(--ink);border:1px solid var(--line);display:inline-flex;align-items:center;justify-content:center;gap:6px}
.btn.primary{background:linear-gradient(90deg,var(--accent),var(--accent2));border:0;color:#fff}
.btn.big{padding:9px 16px;font-size:14px}
.btn.danger{color:var(--accent2)}
.btn:disabled{opacity:.4;cursor:default}
.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;justify-content:space-between}
.row.start{justify-content:flex-start}
.stack{display:flex;flex-direction:column;gap:6px}
.stack .btn{width:100%}
.field{display:flex;flex-direction:column;gap:5px;font-size:12px;color:var(--muted)}
.field.inline{flex-direction:row;align-items:center;justify-content:space-between;color:var(--ink);font-size:14px}
.field input[type=checkbox]{width:18px;height:18px;accent-color:var(--accent)}
input[type=range]{accent-color:var(--accent)}
input[type=color]{width:42px;height:30px;padding:2px;border:1px solid var(--line);border-radius:6px;background:var(--opbg);cursor:pointer}
input[type=file]{font-size:12px;color:var(--muted);width:100%}
.colors{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.sub{border-top:1px solid var(--line);padding-top:8px;margin-top:2px;display:flex;flex-direction:column;gap:7px}
.status{font-size:12px;color:var(--muted);min-height:1.2em}
.status.bad{color:var(--accent2)}
.status.good{color:#15803d}
.status:empty{display:none}
/* Random draw */
.callbox #drawBtn{width:100%;font-size:16px}
.autorow{display:flex;gap:8px;align-items:center}
.autorow .field.inline{flex:1;justify-content:flex-start;gap:8px;flex-direction:row-reverse}
.autorow select{width:auto}
#stage.rolling #ball{animation:roll .25s ease-in-out infinite alternate}
#stage.rolling #ballNum,#stage.rolling #ballLetter{opacity:.75}
@keyframes roll{from{transform:scale(1)}to{transform:scale(1.06)}}
/* Delete prompt in Past games */
.delbox{display:flex;flex-direction:column;gap:6px;border:1px solid var(--accent2);border-radius:8px;padding:8px;background:#fff5f5}
.delbox .btn{width:100%;justify-content:flex-start}
.delbox #delCancel{justify-content:center}
/* Collapsible Colors group */
.fold{display:flex;flex-direction:column;gap:7px}
.fold summary{cursor:pointer;list-style:none;user-select:none;display:flex;justify-content:center;align-items:center;gap:8px;padding:7px 12px;border:1px dashed var(--line);border-radius:8px;font-size:13px;font-weight:600;color:var(--ink);background:var(--opbg)}
.fold summary::-webkit-details-marker{display:none}
.fold summary::after{content:"▾";font-size:14px;transition:transform .15s}
.fold[open] summary::after{transform:rotate(180deg)}
.fold summary:hover{border-style:solid}
.fold .hide,.fold[open] .show{display:none}
.fold[open] .hide{display:inline}
/* Call section: the operator's main control */
.callbox{border:2px solid var(--accent);background:#eef4ff;box-shadow:0 2px 10px rgba(31,95,191,.18);padding:12px;gap:9px}
.callbox h3{color:var(--accent);font-size:13px;font-weight:800}
.callbox #callInput{font-size:24px;font-weight:700;padding:10px 12px;border:2px solid var(--accent);background:#fff;text-align:center}
.callbox #callInput::placeholder{font-size:15px;font-weight:400}
.callbox button[type=submit]{font-size:18px;padding:10px 20px}
.callbox .status{font-size:13px}
.callbox #callStatus{font-weight:600}
.sig{text-align:center;font-size:11px;color:var(--muted);padding:6px 0 0;letter-spacing:.03em;line-height:1.6}
.sig .mail{color:var(--muted);text-decoration:none}
.sig .mail:hover{color:var(--ink);text-decoration:underline}
