:root{
  --bg: #f5f7fb;
  --grid: #2a2a2a;
  --gridW: 4px;

  --fly: #000000;
  --ready: #ff0000;
  --hit: #00b050;

  --overlay: rgba(0,163,255,0.18);
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: #111;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;

  /* no page scroll */
  overflow: hidden;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 10;
}

.brand{ display:flex; align-items:center; gap: 10px; min-width: 180px; }
.dot{ width: 10px; height: 10px; border-radius: 50%; background: #111; }
.brand-text{ display:flex; flex-direction: column; gap: 2px; }
.title{ font-weight: 900; font-size: 14px; }
.subtitle{ font-size: 11px; opacity: 0.7; }

.controls{
  display:flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}
.btn{
  border: 1px solid rgba(0,0,0,0.18);
  background: #fff;
  padding: 8px 10px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
}
.btn:active{ transform: translateY(1px); }
.btn.primary{
  background: #111;
  color: #fff;
  border-color: #111;
}
.btn:disabled{
  opacity: 0.5;
  cursor: not-allowed;
}

.main{
  height: calc(100vh - 50px);
  display:flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px 10px 10px;
}

.hud{
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 8px;
  flex: 0 0 auto;
}

.hud-row{
  display:flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.pill{
  background: rgba(0,0,0,0.06);
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 12px;
  white-space: nowrap;
}
.pill b{ margin-right: 6px; }
.pill.status{
  margin-left: auto;
  font-weight: 900;
  background: rgba(0,0,0,0.10);
}

.progress{
  margin-top: 6px;
  display:flex;
  gap: 8px;
  align-items: center;
}
.progressbar{
  flex: 1 1 auto;
  height: 10px;
  background: rgba(0,0,0,0.10);
  border-radius: 999px;
  overflow: hidden;
}
.progressfill{
  height: 100%;
  width: 0%;
  background: rgba(0,0,0,0.75);
  transition: width 180ms linear;
}
.progress-mini{
  display:flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  opacity: 0.75;
  flex: 0 0 auto;
  min-width: 130px;
}

.stage-wrap{
  flex: 1 1 auto;
  display:flex;
  justify-content:center;
  align-items: center;
  min-height: 0;
}

.stage{
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 12px 34px rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.10);

  background-image:
    linear-gradient(to right, var(--grid) var(--gridW), transparent var(--gridW)),
    linear-gradient(to bottom, var(--grid) var(--gridW), transparent var(--gridW));
  background-size: 25% 25%;
  background-position: 0 0;
}

/* SPRITE: mask-based, so you can swap icons and still recolor */
.sprite{
  position: absolute;
  width: 64px;
  height: 64px;
  transform: translate(-50%, -50%);
  color: var(--fly);
  background: currentColor;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.25));
  will-change: left, top, transform, color;

  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;

  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

.target-overlay{
  position: absolute;
  border-radius: 999px;
  border: 3px dashed rgba(0,0,0,0.35);
  background: var(--overlay);
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
}

.tap-fx{
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 999px;
  border: 3px solid rgba(0,0,0,0.35);
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
}
.tap-fx.on{
  opacity: 1;
  animation: tap 260ms ease-out forwards;
}
@keyframes tap{
  from { transform: translate(-50%, -50%) scale(0.85); opacity: 0.9; }
  to   { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

.web-svg{
  position:absolute;
  inset:0;
  pointer-events:none;
  display:none;
}
.web-svg line{
  stroke: rgba(0,0,0,0.35);
  stroke-width: 2;
  stroke-dasharray: 4 6;
}

/* HOME overlay */
.home-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 12px;
}
.home-overlay.show{ display: flex; }

.home-card{
  width: min(980px, 96vw);
  max-height: min(92vh, 900px);
  background: #fff;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: 0 16px 44px rgba(0,0,0,0.22);
  display:flex;
  flex-direction: column;
  overflow: hidden;
}

.home-header{
  padding: 10px 12px;
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.home-title{ font-weight: 900; font-size: 16px; }
.home-subtitle{ font-size: 12px; opacity: 0.75; }

.home-section{
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.section-title{
  font-weight: 900;
  font-size: 13px;
  margin-bottom: 8px;
}

.profile-row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.profile-card{
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 16px;
  padding: 10px;
  cursor: pointer;
  background: rgba(0,0,0,0.02);
}
.profile-card.selected{
  outline: 3px solid rgba(0,0,0,0.65);
  background: rgba(0,0,0,0.06);
}
.profile-name{ font-weight: 900; }
.profile-desc{ font-size: 12px; opacity: 0.75; margin-top: 4px; }

.grid-picker{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  overflow: auto;
  padding-bottom: 4px;
}

.grid-card{
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 16px;
  padding: 10px;
  background: rgba(0,0,0,0.02);
  cursor: pointer;
  display:flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}
.grid-card.selected{
  outline: 3px solid rgba(0,0,0,0.65);
  background: rgba(0,0,0,0.06);
}
.grid-top{
  display:flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.grid-name{ font-weight: 900; font-size: 13px; }
.grid-meta{ font-size: 11px; opacity: 0.75; }

.grid-icon{
  width: 46px; height: 46px;
  border-radius: 14px;
  background: rgba(0,0,0,0.08);
  display:flex;
  align-items:center;
  justify-content:center;
  color: #111;
  background: #111;

  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;

  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

.home-footer{
  padding: 10px 12px;
  border-top: 1px solid rgba(0,0,0,0.08);
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.home-hint{ font-size: 12px; opacity: 0.8; }

/* REPORT overlay */
.report-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 55;
  padding: 12px;
}
.report-overlay.show{ display:flex; }

.report-card{
  width: min(980px, 96vw);
  max-height: min(92vh, 900px);
  background: #fff;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: 0 16px 44px rgba(0,0,0,0.22);
  display:flex;
  flex-direction: column;
  overflow: hidden;
}
.report-header{
  padding: 10px 12px;
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.report-title{ font-weight: 900; font-size: 16px; }
.report-subtitle{ font-size: 12px; opacity: 0.75; }
.report-body{ padding: 10px 12px; overflow:auto; }
.report-footer{
  padding: 10px 12px;
  border-top: 1px solid rgba(0,0,0,0.08);
  display:flex;
  justify-content: flex-end;
}

.report-kpis{
  display:grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.kpi{
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 16px;
  padding: 10px;
  background: rgba(0,0,0,0.02);
}
.kpi-label{ font-size: 11px; opacity: 0.7; }
.kpi-val{ font-weight: 900; font-size: 18px; margin-top: 2px; }

.chart-wrap{
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 16px;
  padding: 10px;
  background: rgba(0,0,0,0.02);
}
canvas{
  width: 100%;
  height: auto;
  display:block;
}
.report-note{ font-size: 12px; opacity: 0.75; margin-top: 10px; }

/* settings drawer */
.settings{
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(460px, 92vw);
  background: #fff;
  border-left: 1px solid rgba(0,0,0,0.12);
  box-shadow: -12px 0 28px rgba(0,0,0,0.14);
  padding: 10px;
  z-index: 60;
  display:flex;
  flex-direction: column;
  gap: 10px;
}
.settings.hidden{ display:none; }

.settings-header{
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.settings-title{ font-weight: 900; font-size: 16px; }
.settings-subtitle{ font-size: 11px; opacity: 0.7; }

.settings-grid{
  display:grid;
  gap: 10px;
  overflow:auto;
  padding-right: 4px;
}
.setting{
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 10px;
  background: rgba(0,0,0,0.02);
}
.setting label{
  display:block;
  font-size: 11px;
  opacity: 0.8;
  margin-bottom: 8px;
}
.setting .row{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
}
.hint{
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.7;
}

.icons-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.icon-item{
  border: 1px dashed rgba(0,0,0,0.18);
  border-radius: 12px;
  padding: 8px;
  background: rgba(255,255,255,0.65);
}
.icon-label{
  font-size: 11px;
  font-weight: 900;
  margin-bottom: 6px;
}
.icon-item input{ width: 100%; }

.settings-footer{
  border-top: 1px solid rgba(0,0,0,0.08);
  padding-top: 10px;
  display:flex;
  justify-content: flex-end;
}
