:root{
  --bg:#211F3A; --card:#2B2950; --card2:#34325E; --blue:#384998; --cyan:#39BEEC; --teal:#7CCBDD;
  --text:#FFFFFF; --muted:#A9AECF; --good:#3DDC97; --bad:#FF6B6B; --warn:#FFC857;
  --snow:#EEF4FA; --asphalt:#3B3F52;
}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent; min-width:0}
html,body{margin:0; background:var(--bg); color:var(--text); font-family:"Noto Sans",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
body{min-height:100vh; display:flex; justify-content:center; touch-action:manipulation; user-select:none; -webkit-user-select:none}
#app{width:100%; max-width:440px; padding:14px 14px 28px}
h1{font-size:22px; margin:6px 0 6px; font-weight:700; line-height:1.2}
h2{font-size:18px; margin:0 0 8px}
p{margin:6px 0; line-height:1.45; color:var(--muted); font-size:15px}
.small{font-size:13px; text-align:center}
.tag{display:inline-block; font-size:12px; color:var(--cyan); margin-top:4px}
.btn{display:block; width:100%; border:0; border-radius:12px; padding:15px 16px; font-size:17px; font-weight:600; color:#fff; background:var(--blue); margin-top:10px; cursor:pointer; font-family:inherit}
.btn.cyan{background:var(--cyan); color:#10122B}
.btn.ghost{background:transparent; border:1px solid #4A4880; color:var(--muted); font-weight:500}
.btn:disabled{opacity:.45}
.card{background:var(--card); border-radius:16px; padding:14px; margin-top:12px}
label{display:block; font-size:14px; color:var(--muted); margin:10px 0 4px}
input,select{width:100%; padding:12px; border-radius:10px; border:1px solid #4A4880; background:var(--card2); color:#fff; font-size:16px; font-family:inherit; user-select:text; -webkit-user-select:text}
input[type=range]{padding:0; border:0; background:transparent; accent-color:var(--cyan); height:40px}
.chk{display:flex; align-items:center; gap:10px; font-size:16px; color:#fff; margin:6px 0; padding:8px 4px}
.chk input{width:22px; height:22px; accent-color:var(--cyan)}
.bignum{font-size:44px; font-weight:700; text-align:center}
.hud{display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:10px}
.hud .night{font-size:14px; color:var(--teal); font-weight:600}
.hud .timer{font-size:30px; font-weight:700; font-variant-numeric:tabular-nums}
.hud .timer.low{color:var(--warn)}
.tbar{height:6px; border-radius:3px; background:#3A3868; overflow:hidden; margin-bottom:12px}
.tbar>i{display:block; height:100%; background:var(--cyan); width:100%}
.hint{font-size:13px; color:var(--muted); min-height:18px; margin:2px 0 10px; text-align:center}
.grid{display:grid; grid-template-columns:repeat(3,1fr); gap:8px}
.cell{position:relative; aspect-ratio:1/1; border-radius:12px; overflow:hidden; display:flex; align-items:center; justify-content:center; font-weight:700}
.cell .lbl{position:absolute; left:7px; top:5px; font-size:12px; font-weight:700; opacity:.75}
.cell.dirty{background:var(--snow); color:#2A3550; background-image:radial-gradient(#fff 18%, transparent 19%), radial-gradient(#DCE7F2 14%, transparent 15%); background-size:16px 16px, 22px 22px; background-position:0 0, 8px 10px}
.cell.dirty.target{outline:3px solid var(--cyan); outline-offset:-3px}
.cell.work{background:#D5E2EF; color:#2A3550}
.cell.wait{background:#C7D6E6; color:#2A3550}
.cell.accepted,.cell.clean{background:var(--asphalt); color:#fff}
.cell.check{background:#4A4F66; color:#fff}
.cell.failflash{animation:fail 1.2s}
@keyframes fail{0%,60%{box-shadow:inset 0 0 0 4px var(--bad)} 100%{box-shadow:inset 0 0 0 0 var(--bad)}}
.cell .center{display:flex; flex-direction:column; align-items:center; gap:4px; font-size:12px; text-align:center; padding:0 4px}
.cell .big{font-size:24px; line-height:1}
.prog{position:absolute; left:0; bottom:0; height:6px; background:var(--cyan)}
.badge{display:inline-flex; align-items:center; justify-content:center; min-width:34px; height:26px; padding:0 8px; border-radius:13px; background:var(--blue); color:#fff; font-size:13px; font-weight:700}
.ok{color:var(--good)} .rep{color:var(--teal)} .bad{color:var(--bad)}
.base{margin-top:12px; background:var(--card); border-radius:16px; padding:12px; display:flex; align-items:center; gap:10px}
.base .bt{font-size:13px; color:var(--muted); width:52px; line-height:1.2}
.brigs{display:flex; gap:8px; flex:1}
.brig{flex:1; height:64px; border-radius:12px; background:var(--card2); border:2px solid transparent; display:flex; flex-direction:column; align-items:center; justify-content:center; font-size:12px; color:var(--muted); touch-action:none; text-align:center}
.brig b{font-size:16px; color:#fff}
.brig.idle{background:var(--blue); color:#DDE3FF; cursor:grab}
.brig.sel{border-color:var(--cyan); box-shadow:0 0 0 3px rgba(57,190,236,.25)}
.brig.back{background:var(--warn); color:#3A2A00; animation:pulse 1s infinite}
.brig.back b{color:#2A1E00}
.brig.check{background:#4A4F66}
@keyframes pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.05)}}
.dragghost{position:fixed; z-index:50; pointer-events:none; width:56px; height:56px; border-radius:12px; background:var(--cyan); color:#10122B; display:flex; align-items:center; justify-content:center; font-weight:700; transform:translate(-50%,-50%); opacity:.92}
.modal{position:fixed; inset:0; background:rgba(10,10,25,.6); display:flex; align-items:flex-end; justify-content:center; z-index:40}
.sheet{width:100%; max-width:440px; background:var(--card); border-radius:18px 18px 0 0; padding:18px 16px 24px}
.sheet h3{margin:0 0 4px; font-size:18px}
.toast{position:fixed; left:50%; top:14px; transform:translateX(-50%); background:var(--card2); border-radius:12px; padding:10px 14px; font-size:14px; z-index:60; box-shadow:0 6px 20px rgba(0,0,0,.35); max-width:92vw}
.net{position:fixed; left:0; right:0; bottom:0; background:var(--warn); color:#2A1E00; text-align:center; padding:8px; font-size:14px; z-index:70}
.duo{display:flex; gap:10px; margin-top:10px}
.duo>div{flex:1; background:var(--card2); border-radius:14px; padding:12px; text-align:center}
.duo .n{font-size:34px; font-weight:700}
.duo .c{font-size:13px; color:var(--muted)}
.mini{display:grid; grid-template-columns:repeat(3,1fr); gap:5px}
.mini div{aspect-ratio:1/1; border-radius:8px; display:flex; flex-direction:column; gap:3px; align-items:center; justify-content:center; font-size:11px; text-align:center; padding:2px; line-height:1.2}
.mini b{font-size:12px}
table{width:100%; border-collapse:collapse; margin-top:8px; font-size:14px}
td,th{padding:8px 4px; border-bottom:1px solid #3E3C70; text-align:right}
th{color:var(--muted); font-weight:500; font-size:12px}
td:first-child,th:first-child{text-align:left}
.foot{font-size:12px; color:#7E83AE; margin-top:16px; text-align:center}
