html, body { height: 100%; }
body{
  margin: 0;
  background: #fff;
  overflow: hidden;
}
.miq-page{
  height: 100%;
  display: grid;
  place-items: center;
  padding: 10px;
}

#miqTuner{
  --IMG_W: 840;
  --IMG_H: 988;
  --IMG_RATIO: calc(var(--IMG_W) / var(--IMG_H));

  --screen-bg: rgba(6,6,6,0.78);

  --danger:#ff3b30;
  --warn:#ffcc00;
  --good:#34c759;

  --gold-soft: rgba(216,184,90,0.72);

  --needle-coarse: rgba(255,255,255,0.92);
  --needle-fine: rgba(255,59,48,0.95);

  --max-angle: 72deg;

  --LED_LEFT: 80.41%;
  --LED_TOP:  10.88%;

  --SCREEN_LEFT:  9.65%;
  --SCREEN_TOP:   23.57%;
  --SCREEN_W:     80.60%;
  --SCREEN_H:     37.10%;

  --SW_LEFT: 50.19%;
  --SW_TOP:  72.2%;

  --BADGE_LEFT: 48.8%;
  --BADGE_TOP:  12.1%;

  position: relative;
  display: block;

  width: min(calc(100vw - 20px), calc((100vh - 20px) * var(--IMG_RATIO)));
  aspect-ratio: var(--IMG_W) / var(--IMG_H);

  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
#miqTuner, #miqTuner *{ box-sizing: border-box; }

#miqTuner .pedal-img{
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  position: relative;
  z-index: 1;
}

#miqTuner .badge-tuner,
#miqTuner .led,
#miqTuner .screen,
#miqTuner .footswitch{
  position: absolute;
}

#miqTuner .badge-tuner{
  z-index: 8;
  left: var(--BADGE_LEFT);
  top: var(--BADGE_TOP);
  transform: translate(0, -50%);
  font-weight: 850;
  letter-spacing: 0.20em;
  font-size: clamp(12px, 1.6vw, 19px);
  color: var(--gold-soft);
  text-shadow:
    0 0 8px rgba(216,184,90,0.16),
    0 8px 24px rgba(0,0,0,0.35);
  pointer-events: none;
  white-space: nowrap;
}

#miqTuner .led{
  z-index: 10;
  width: 3.9%;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  left: var(--LED_LEFT);
  top:  var(--LED_TOP);
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.18);
  pointer-events: none;
  opacity: 0.98;
}
#miqTuner .led.on{
  background: var(--good);
  box-shadow:
    0 0 14px rgba(52,199,89,0.95),
    0 0 30px rgba(52,199,89,0.75),
    0 0 52px rgba(52,199,89,0.45);
}

#miqTuner .screen{
  z-index: 9;
  left: var(--SCREEN_LEFT);
  top:  var(--SCREEN_TOP);
  width: var(--SCREEN_W);
  height: var(--SCREEN_H);

  border-radius: 16px;
  background: var(--screen-bg);
  padding: clamp(10px, 1.0vw, 12px);

  border: 2px solid rgba(255,255,255,0.08);
  overflow: hidden;

  box-shadow:
    inset 0 0 110px rgba(0,0,0,0.66),
    inset 0 0 38px rgba(0,0,0,0.42);
}
#miqTuner .screen.screen-off{
  background: rgba(0,0,0,0);
  border-color: rgba(255,255,255,0);
  box-shadow: none;
}
#miqTuner .screen.screen-off *{ visibility: hidden; }

/* boot: 3s fade in (whole UI together) */
#miqTuner .ui{
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  opacity: 0;
  transform: translateY(10px);
}
#miqTuner .screen.booting .ui{
  opacity: 1;
  transform: translateY(0);
  transition: opacity 3000ms ease, transform 3000ms ease;
}

/* shutdown: 1s fade out (whole UI together) */
#miqTuner .screen.shutting .ui{
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1000ms ease, transform 1000ms ease;
}

#miqTuner .topline{
  display:flex;
  justify-content:space-between;
  align-items: baseline;
  gap: 12px;
}

/* Note/Freq typography */
#miqTuner .note,
#miqTuner .freq{
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  font-size: clamp(18px, 3.4vw, 34px);
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.95);
  line-height: 1;
  text-shadow: 0 10px 28px rgba(0,0,0,0.45);
}
#miqTuner .freq{ text-align:right; white-space:nowrap; }

/* Make Hz smaller (JS outputs spans) */
#miqTuner .freq .num{ font-size: 1em; }
#miqTuner .freq .unit{
  font-size: 0.70em;
  opacity: 0.92;
  letter-spacing: 0.04em;
  margin-left: 0.14em;
}

#miqTuner .gauge-semi{
  position: relative;
  width: 100%;
  height: 100%;

  /* safe area so scale never touches edges */
  padding: 4% 4% 5% 4%;

  background: rgba(0,0,0,0.10);
  border-radius: 14px;
  overflow: hidden;

  box-shadow:
    inset 0 0 40px rgba(0,0,0,0.38),
    inset 0 0 140px rgba(0,0,0,0.35);
}

#miqTuner .gauge-svg{
  position:absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Scale lines thinner and sharper */
#miqTuner .gauge-svg line{
  stroke: rgba(255,255,255,0.20);
  stroke-width: 0.80;
  stroke-linecap: butt;   /* sharp ends */
}
#miqTuner .gauge-svg line.major{
  stroke: rgba(255,255,255,0.48);
  stroke-width: 1.70;
  stroke-linecap: butt;
}
#miqTuner .gauge-svg line.super{
  stroke: rgba(255,255,255,0.70);
  stroke-width: 2.40;
  stroke-linecap: butt;
}

#miqTuner .gauge-svg text{
  fill: rgba(255,255,255,0.86);
  font-size: 4.8px;
  font-weight: 850;
  letter-spacing: 0.02em;
}

/* Needles: more "metal" */
#miqTuner .needle{
  position:absolute;
  left: 50%;
  bottom: 0;
  transform-origin: 50% 100%;
  transform: translateX(-50%) rotate(0deg);
  border-radius: 2px;
  filter: drop-shadow(0 0 12px rgba(0,0,0,0.55));
}
#miqTuner .needle::after{
  content:"";
  position:absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 1px;
  height: 100%;
  opacity: 0.35;
  background: rgba(0,0,0,0.55);
}

#miqTuner .needle-coarse{
  width: 5px;
  height: 82%;
  background: linear-gradient(to right,
    rgba(255,255,255,0.75),
    var(--needle-coarse),
    rgba(255,255,255,0.65)
  );
  opacity: 0.98;
  box-shadow:
    0 0 18px rgba(0,0,0,0.42),
    0 0 16px rgba(255,255,255,0.06);
}

#miqTuner .needle-fine{
  width: 2px;
  height: 76%;
  background: linear-gradient(to right,
    rgba(255,255,255,0.25),
    var(--needle-fine),
    rgba(0,0,0,0.25)
  );
  opacity: 0.98;
  display: none;
  box-shadow:
    0 0 18px rgba(0,0,0,0.42),
    0 0 18px rgba(255,255,255,0.05);
}
#miqTuner.fine-visible .needle-fine{ display:block; }

#miqTuner .pivot{
  position:absolute;
  left: 50%;
  bottom: 0;
  width: 14px;
  height: 14px;
  transform: translate(-50%, 50%);
  border-radius: 999px;
  background: radial-gradient(circle at 35% 35%,
    rgba(255,255,255,0.78),
    rgba(255,255,255,0.35) 45%,
    rgba(0,0,0,0.42) 78%,
    rgba(0,0,0,0.62)
  );
  box-shadow:
    0 0 0 3px rgba(0,0,0,0.32),
    0 0 22px rgba(255,255,255,0.10);
}

/* Warmup hides values + needles */
#miqTuner.warmup .note,
#miqTuner.warmup .freq{ visibility: hidden; }
#miqTuner.warmup .needle{ visibility: hidden; }

#miqTuner .footswitch{
  z-index: 11;
  left: var(--SW_LEFT);
  top:  var(--SW_TOP);
  width: 11%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
  margin: 0;
  outline: none;
  box-shadow: none;
}
#miqTuner .footswitch:focus,
#miqTuner .footswitch:focus-visible{
  outline: none !important;
  box-shadow: none !important;
}
#miqTuner .footswitch:active{
  transform: translate(-50%, -50%) scale(0.985);
}

#miqTuner .sr-only{
  position:absolute;
  width:1px; height:1px;
  padding:0; margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0);
  white-space:nowrap;
  border:0;
}
