:root{
  --bg0:#070b12;
  --bg1:#0a1424;

  --panel: rgba(11,18,30,.70);
  --line: rgba(135,170,210,.18);

  --text:#e9f2fb;
  --muted:#9db2c6;

  --arc: rgba(74,222,196,.90);
  --needle: rgba(74,222,196,.98);

  --arc_single: rgba(251,146,60,.92);
  --needle_single: rgba(251,146,60,.98);

  --shadow: 0 18px 55px rgba(0,0,0,.48);
  --r: 18px;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "PingFang SC","Hiragino Sans GB","Microsoft YaHei", Arial, sans-serif;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family:var(--sans);
  color:var(--text);
  background:
    radial-gradient(900px 560px at 18% -10%, rgba(56,189,248,.16) 0%, transparent 58%),
    radial-gradient(860px 520px at 105% 0%, rgba(74,222,196,.10) 0%, transparent 58%),
    radial-gradient(900px 640px at 50% 110%, rgba(56,189,248,.06) 0%, transparent 62%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  background-attachment: fixed;
}

body.mode-single{
  --arc: var(--arc_single);
  --needle: var(--needle_single);
}

.app{
  max-width: 980px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 18px 16px 22px;
  display:flex;
  flex-direction:column;
  gap: 14px;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}

.brand{ display:flex; align-items:center; gap:12px; }

.logo{
  width:44px;height:44px;
  display:grid;place-items:center;
  border-radius:14px;
  border:1px solid var(--line);
  background: rgba(12,18,30,.58);
  box-shadow: var(--shadow);
  font-family: var(--mono);
  font-weight: 900;
  letter-spacing: .5px;
  color: rgba(56,189,248,.92);
}

body.mode-single .logo{
  color: rgba(251,146,60,.95);
  box-shadow: var(--shadow), 0 0 0 1px rgba(251,146,60,.12) inset;
}

.brandTitle{ font-size:18px; font-weight:950; line-height:1; }
.brandSub{ margin-top:4px; font-size:12px; color:var(--muted); }

.topActions{ display:flex; align-items:center; gap:10px; }

.topActions{
  padding: 6px;
  border-radius: 999px;
  border: 1px solid rgba(135,170,210,.18);
  background: rgba(7,12,20,.45);
  box-shadow: 0 10px 34px rgba(0,0,0,.35);
}

.modeBtnSolo{
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(157,178,198,.92);
  font-weight: 950;
  cursor:pointer;
  transition: transform .12s ease, filter .12s ease, border-color .12s ease, background .12s ease, color .12s ease;
}

.modeBtnSolo:hover{ color: var(--text); }
.modeBtnSolo:active{ transform: scale(.98); }

body.mode-multi #modeMulti{
  color: var(--text);
  background: rgba(12,28,30,.72);
  border-color: rgba(74,222,196,.55);
  box-shadow: 0 0 0 1px rgba(74,222,196,.14) inset, 0 8px 22px rgba(0,0,0,.35);
}

body.mode-single #modeSingle{
  color: var(--text);
  background: rgba(34,22,14,.72);
  border-color: rgba(251,146,60,.64);
  box-shadow: 0 0 0 1px rgba(251,146,60,.14) inset, 0 8px 22px rgba(0,0,0,.35);
}

body.mode-multi #modeSingle{ color: rgba(157,178,198,.82); }
body.mode-single #modeMulti{ color: rgba(157,178,198,.82); }

.main{
  flex:1;
  display:flex;
  flex-direction:column;
  gap: 12px;
}

.meterCard{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 16px 16px 14px;
  position: relative;
}

.meter{
  position: relative;
  width: min(760px, 100%);
  margin: 0 auto;
  aspect-ratio: 1/1;
}

@media (max-width: 520px){
  .app{
    padding: 12px max(10px, env(safe-area-inset-right)) 18px max(10px, env(safe-area-inset-left));
    gap: 10px;
  }
  .meterCard{
    padding: 12px 10px 12px;
    overflow: hidden;
  }
  .brandSub{ display:none; }
  .meter{
    width: 100%;
    margin: 0 auto;
  }
  .speedVal{ font-size: clamp(62px, 15.5vw, 94px); }
  .topActions{ padding: 5px; }
  .modeBtnSolo{ padding: 10px 12px; }
}

@media (max-width: 380px){
  .meter{ width: 100%; }
  .modeBtnSolo{ padding: 9px 11px; }
}

.gauge{ width:100%; height:100%; display:block; }

.ticks line{
  stroke: rgba(170,200,230,.20);
  stroke-width: 2;
  stroke-linecap: round;
}
.ticks line.major{
  stroke: rgba(210,235,255,.28);
  stroke-width: 3;
}
.ticks text{
  fill: rgba(210,235,255,.56);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 12px;
}

.arcBg{
  fill:none;
  stroke: rgba(170,200,230,.12);
  stroke-width: 18;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(0,0,0,.25));
}
.arcFg{
  fill:none;
  stroke: var(--arc);
  stroke-width: 18;
  stroke-linecap: round;
  filter: drop-shadow(0 0 16px rgba(0,0,0,.25));
}

.needle line{
  stroke: var(--needle);
  stroke-width: 4;
  stroke-linecap: round;
  filter: drop-shadow(0 0 10px rgba(0,0,0,.25));
}
.needle circle{
  fill: rgba(7,10,16,.92);
  stroke: rgba(255,255,255,.12);
  stroke-width: 2;
}

.center{
  position:absolute;
  inset: 0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  pointer-events:none;
  padding-bottom: 62px;
}

.speedRow{ display:flex; align-items:baseline; gap: 10px; }
.speedVal{
  font-size: clamp(66px, 8.5vw, 94px);
  font-weight: 980;
  letter-spacing: .3px;
}
.speedUnit{
  font-family: var(--mono);
  font-weight: 950;
  color: rgba(210,235,255,.78);
  font-size: 12px;
  letter-spacing: .3px;
}

.actionStack{
  position:absolute;
  left:50%;
  bottom: 17%;
  transform: translateX(-50%);
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 10px;
  pointer-events:none;
  text-align:center;
}

.stageAbove{
  font-family: var(--mono);
  font-weight: 950;
  letter-spacing: .7px;
  color: rgba(157,178,198,.92);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(135,170,210,.14);
  background: rgba(7,12,20,.38);
  backdrop-filter: blur(8px);
}

/* =========================================================
   Start Button (fixed for iOS/Safari compositing "square block")
   - Remove pseudo-element blur filter (triggers square layer)
   - Ensure strict clipping + stable compositing
   ========================================================= */
.startBtn{
  pointer-events:auto;
  -webkit-appearance: none;
  appearance: none;

  border: 1px solid rgba(255,255,255,.18);
  background: rgba(14,22,34,.74);
  color: var(--text);
  cursor:pointer;

  border-radius: 999px;
  padding: 15px 26px 13px;
  position: relative;
  overflow: hidden;

  isolation: isolate;
  transform: translateZ(0);
  backface-visibility: hidden;

  box-shadow:
    0 16px 52px rgba(0,0,0,.52),
    0 0 0 1px rgba(255,255,255,.06) inset,
    0 0 18px rgba(74,222,196,.14);
}
body.mode-single .startBtn{
  box-shadow:
    0 16px 52px rgba(0,0,0,.52),
    0 0 0 1px rgba(255,255,255,.06) inset,
    0 0 18px rgba(251,146,60,.14);
}

.startBtn::before{
  content:"";
  position:absolute;

  /* was inset:-45% (too large; may trigger odd compositing) */
  inset:-12%;
  opacity: .95;
  pointer-events:none;

  background:
    radial-gradient(circle at 28% 35%, rgba(74,222,196,.26), transparent 55%),
    radial-gradient(circle at 78% 70%, rgba(56,189,248,.12), transparent 60%);

  /* critical fix: remove blur filter to prevent "square background block" */
  filter: none !important;

  border-radius: 999px;
}
body.mode-single .startBtn::before{
  background:
    radial-gradient(circle at 28% 35%, rgba(251,146,60,.26), transparent 55%),
    radial-gradient(circle at 78% 70%, rgba(56,189,248,.12), transparent 60%);
}

.startBtn::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  opacity: .52;
  background:
    radial-gradient(120% 85% at 50% 0%,
      rgba(255,255,255,.24),
      rgba(255,255,255,.10) 35%,
      transparent 62%);
  border-radius: 999px;
}

/* ultimate fallback clip for stubborn WebKit builds */
@supports (-webkit-mask-image: -webkit-radial-gradient(white, black)){
  .startBtn{
    -webkit-mask-image: -webkit-radial-gradient(white, black);
  }
}

.startBtn:hover{
  filter: brightness(1.08);
  border-color: rgba(255,255,255,.26);
}
.startBtn:active{ transform: translateZ(0) scale(.985); }
.startBtn:disabled{ opacity:.55; cursor:not-allowed; }

.startMain{
  display:block;
  font-weight: 980;
  letter-spacing: .5px;
  font-size: 16px;
  position: relative;
}
.startSub{
  display:block;
  margin-top: 3px;
  font-family: var(--mono);
  font-weight: 950;
  font-size: 11px;
  color: rgba(157,178,198,.92);
  position: relative;
}

@media (max-width: 520px){
  .center{ padding-bottom: 70px; }
  .actionStack{ bottom: 16%; gap: 10px; }
  .startBtn{ padding: 16px 28px 14px; }
}

@media (max-width: 380px){
  .center{ padding-bottom: 76px; }
  .actionStack{ bottom: 15%; }
}

.pingBar{
  margin-top: 10px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(135,170,210,.14);
  background: rgba(7,12,20,.48);
}
.pingChip{ display:flex; flex-direction:column; gap:2px; min-width: 92px; text-align:left; }
.pingK{ font-size: 11px; color: var(--muted); font-weight: 900; }
.pingV{ font-family: var(--mono); font-size: 13px; font-weight: 950; }
.pingU{ color: var(--muted); font-weight: 900; margin-left: 4px; }
.pingDot{
  width: 6px; height: 6px;
  border-radius: 99px;
  background: rgba(74,222,196,.70);
  box-shadow: 0 0 14px rgba(74,222,196,.16);
}
body.mode-single .pingDot{
  background: rgba(251,146,60,.75);
  box-shadow: 0 0 14px rgba(251,146,60,.16);
}
@media (max-width: 520px){
  .pingBar{ border-radius: 16px; justify-content:space-between; gap: 10px; }
  .pingChip{ min-width: 0; }
}

.stats{
  margin-top: 10px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 860px){ .stats{ grid-template-columns: 1fr; } }

.stat{
  position: relative;
  overflow: hidden;
  background: rgba(7,12,20,.55);
  border: 1px solid rgba(135,170,210,.14);
  border-radius: 16px;
  padding: 14px;
}
.stat::before{
  content:"";
  position:absolute;
  left:0; right:0; top:0;
  height: 3px;
  background: rgba(74,222,196,.82);
}
body.mode-single .stat::before{ background: rgba(251,146,60,.88); }

.statTop{ display:flex; justify-content:space-between; align-items:center; gap:10px; }
.statName{ font-weight: 980; letter-spacing: .2px; }

.statTag{
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 950;
  color: rgba(215,240,255,.90);
  border: 1px solid rgba(74,222,196,.32);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(74,222,196,.10);
}
body.mode-single .statTag{
  border-color: rgba(251,146,60,.36);
  background: rgba(251,146,60,.10);
}

.statVal{
  margin-top: 10px;
  font-size: 48px;
  font-weight: 980;
  line-height: 1;
  letter-spacing: .2px;
}
.statVal span{
  display:inline-block;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(210,235,255,.82));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
body.mode-single .statVal span{
  background: linear-gradient(180deg, rgba(255,240,220,.98), rgba(255,200,150,.84));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.statSub{
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.statSub span{
  font-family: var(--mono);
  font-weight: 950;
  color: rgba(215,240,255,.86);
}
body.mode-single .statSub span{ color: rgba(255,228,198,.88); }

.details{
  background: rgba(7,12,20,.38);
  border: 1px solid rgba(135,170,210,.12);
  border-radius: var(--r);
  padding: 10px 12px;
}
details summary{
  cursor:pointer;
  user-select:none;
  color: var(--muted);
  font-weight: 950;
  letter-spacing: .2px;
}
.log{
  margin: 10px 0 0;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(135,170,210,.12);
  background: rgba(7,12,20,.55);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.35;
  color: #cfe3f5;
  white-space: pre-wrap;
}

.footer{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:10px;
  padding-top: 6px;
}
.who{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:10px 12px;
}
.chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:9px 10px;
  border-radius:999px;
  border: 1px solid rgba(135,170,210,.14);
  background: rgba(7,12,20,.40);
  color: var(--muted);
  font-size: 12px;
}
.chip b{
  color: var(--text);
  font-family: var(--mono);
  font-weight: 980;
}
.ad{
  display:inline-block;
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid rgba(56,189,248,.22);
  background: rgba(56,189,248,.08);
  color: var(--text);
  text-decoration:none;
  font-weight: 980;
  letter-spacing: .2px;
  box-shadow: 0 0 0 1px rgba(56,189,248,.10) inset;
}
.ad:hover{ filter: brightness(1.08); }