:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#app { width: 100%; height: 100%; position: relative; }
.screen { width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.focusable { transition: all 0.15s ease; border: 2px solid transparent; cursor: pointer; outline: none; }
.focusable:focus { border-color: var(--focus-ring); box-shadow: 0 0 20px var(--focus-glow); }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--bg-tertiary);
  flex-shrink: 0;
}
.title { font-size: 26px; font-weight: 700; letter-spacing: 2px; }
.live { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--text-secondary); letter-spacing: 1px; }
.live .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--text-muted); transition: all 0.2s ease; }
.live.on { color: var(--accent-secondary); }
.live.on .dot { background: var(--accent-secondary); box-shadow: 0 0 12px var(--accent-secondary); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- Status + meter ---------- */
.status {
  text-align: center; color: var(--text-secondary);
  font-size: 16px; padding: 12px 24px 6px;
  flex-shrink: 0; min-height: 28px;
}
.meter {
  height: 6px; margin: 0 24px 4px; border-radius: 4px;
  background: var(--bg-tertiary); overflow: hidden; flex-shrink: 0;
}
#meterFill {
  height: 100%; width: 100%; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent));
  transform: scaleX(0); transform-origin: left center;
}

/* ---------- Counter ---------- */
.counter-wrap { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.counter-card {
  position: relative;
  width: 300px; height: 300px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 40%, var(--bg-tertiary), var(--bg-secondary));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 2px solid var(--bg-tertiary);
}
.counter-card:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 28px var(--focus-glow), inset 0 0 24px rgba(0, 212, 255, 0.08);
}
.pulse-ring {
  position: absolute; width: 300px; height: 300px;
  border-radius: 50%; border: 3px solid var(--accent);
  opacity: 0; pointer-events: none;
}
.pulse-ring.on { animation: ring 0.5s ease-out; }
@keyframes ring {
  0% { transform: scale(0.55); opacity: 0.85; }
  100% { transform: scale(1.35); opacity: 0; }
}
.count {
  font-size: 130px; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.counter-card.bump .count { animation: bump 0.16s ease; }
@keyframes bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.14); color: var(--accent); }
  100% { transform: scale(1); }
}
.count-label {
  margin-top: 6px; font-size: 18px; font-weight: 600;
  letter-spacing: 6px; color: var(--text-secondary);
}

/* ---------- Stats ---------- */
.stats {
  display: flex; justify-content: space-around;
  padding: 10px 16px; flex-shrink: 0;
}
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-val { font-size: 28px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-key { font-size: 12px; letter-spacing: 1.5px; color: var(--text-muted); }

/* ---------- Controls ---------- */
.controls { padding: 12px 24px 22px; flex-shrink: 0; }
.btn {
  width: 100%; min-height: 64px;
  background: var(--bg-secondary); color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 19px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary {
  min-height: 72px;
  background: linear-gradient(135deg, #0d3a44, #0a2530);
  color: var(--accent); font-size: 21px;
}
.btn-row { display: flex; gap: 12px; margin-top: 12px; }
.btn-row .btn { font-size: 17px; min-height: 60px; }

/* ---------- Settings ---------- */
.settings-body { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 24px; overflow-y: auto; }
.setting-block { background: var(--bg-secondary); border-radius: var(--radius-md); padding: 18px 20px; }
.setting-label { font-size: 20px; font-weight: 700; }
.setting-hint { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.stepper { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.step-btn {
  width: 72px; height: 72px; flex-shrink: 0;
  background: var(--bg-tertiary); color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 38px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.step-val { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.step-val span { font-size: 42px; font-weight: 800; color: var(--accent); }
.sens-bar { width: 100%; height: 10px; background: var(--bg-tertiary); border-radius: 5px; overflow: hidden; }
#sensFill { height: 100%; width: 60%; background: linear-gradient(90deg, var(--accent-secondary), var(--accent)); border-radius: 5px; transition: width 0.15s ease; }
.toggle-setting { justify-content: space-between; padding: 0 22px; }

/* ---------- Help ---------- */
.help-body { flex: 1; padding: 24px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.help-body p { font-size: 18px; line-height: 1.5; color: var(--text-secondary); }
.help-body ul { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.help-body li { font-size: 16px; line-height: 1.45; color: var(--text-secondary); padding-left: 18px; position: relative; }
.help-body li::before { content: ""; position: absolute; left: 0; top: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.help-body b { color: var(--text-primary); }
.dpad-hint { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; color: var(--text-muted); padding: 4px 0; }
.dpad-hint span { background: var(--bg-secondary); padding: 6px 12px; border-radius: 8px; }
.help-body .btn { margin-top: auto; }
