:root {
  --ink: #f1ebe6;
  --muted: #a39890;
  --faint: rgba(255, 255, 255, 0.08);
  --panel: rgba(16, 13, 12, 0.58);
  --accent: #ff8f6b;
  --ok: #8fd6a4;
  font-family: ui-sans-serif, -apple-system, 'SF Pro Text', 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-feature-settings: 'tnum' 1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0a0a;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

#c {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
  cursor: none;
}

#cursor {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 5;
}
#cursor.on { opacity: 1; }
/* two-tone so it reads on pale skin, dark skin and purple gloves alike */
#cursor .ring {
  position: absolute;
  width: 22px;
  height: 22px;
  left: -11px;
  top: -11px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.65), inset 0 0 0 1.5px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s, border-color 0.12s;
}
#cursor .dot {
  position: absolute;
  width: 4px;
  height: 4px;
  left: -2px;
  top: -2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7);
}
#cursor.down .ring { transform: scale(0.7); }
#cursor.target .ring { border-color: var(--accent); transform: scale(1.15); }
#cursor .label {
  position: absolute;
  left: 16px;
  top: 12px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(16, 13, 12, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s;
}
#cursor .label:not(:empty) { opacity: 1; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; }

.panel {
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--faint);
  border-radius: 14px;
}

#chart {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 14px 16px 12px;
  width: 260px;
  font-size: 12px;
  line-height: 1.45;
}
.brand {
  font-weight: 650;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.brand span { color: var(--muted); font-weight: 450; letter-spacing: 0.04em; text-transform: none; margin-left: 6px; }
.pt { color: var(--ink); font-weight: 550; }
.dx { color: var(--muted); margin-top: 2px; }
.progress { height: 3px; background: var(--faint); border-radius: 2px; margin: 10px 0 7px; overflow: hidden; }
#prog { height: 100%; width: 0; background: var(--ok); transition: width 0.4s ease; }
.row { display: flex; justify-content: space-between; color: var(--muted); }
.row span:first-child { color: var(--ink); }

#irr {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.meter { width: 120px; height: 5px; border-radius: 3px; background: var(--faint); overflow: hidden; }
#irrbar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #8fd6a4, #f2c46b 55%, #ff6b5a);
  background-size: 120px 100%;
  transition: width 0.3s;
}

#toast {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translate(-50%, 8px);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6), 0 1px 2px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast small { display: block; text-align: center; font-size: 13px; font-weight: 450; color: rgba(255, 255, 255, 0.75); margin-top: 2px; }

#hint {
  position: absolute;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
  text-align: center;
  max-width: 90vw;
  transition: opacity 0.6s 1.5s;
}
#hint.faded { opacity: 0; }

#dock {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  pointer-events: auto;
}
#dock button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 10px 6px;
  min-width: 70px;
  border-radius: 10px;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s, color 0.15s;
}
#dock button:hover { background: rgba(255, 255, 255, 0.06); color: var(--ink); }
#dock button.active { background: rgba(255, 143, 107, 0.14); color: var(--ink); }
#dock button.active svg { stroke: var(--accent); }
#dock svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#dock kbd {
  position: absolute;
  top: 4px;
  right: 6px;
  font: inherit;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.3);
}
#dock .sep { width: 1px; height: 34px; background: var(--faint); margin: 0 4px; }
#mute .off { display: none; }
#mute.muted .on { display: none; }
#mute.muted .off { display: inline; }

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #0b0a0a;
  z-index: 10;
  transition: opacity 0.5s;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
#loading.done { opacity: 0; pointer-events: none; }
#loading .bar { width: 180px; height: 2px; background: var(--faint); overflow: hidden; border-radius: 1px; }
#loadbar { height: 100%; width: 0; background: var(--ink); }

#fatal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--ink);
  background: #0b0a0a;
  z-index: 20;
}

@media (max-width: 720px) {
  #chart { width: auto; right: 16px; padding: 10px 12px; }
  .dx, .row span:last-child { display: none; }
  #irr { top: auto; bottom: 92px; right: 12px; padding: 7px 10px; }
  #irr .label { display: none; }
  .meter { width: 60px; }
  #dock button { min-width: 0; padding: 7px 8px 6px; }
  #dock button span, #dock kbd { display: none; }
  #hint { bottom: 140px; }
  #toast { font-size: 18px; }
}
#fatal[hidden] { display: none; }

.marker {
  position: absolute;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid rgba(255, 143, 107, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: auto;
  cursor: pointer;
  animation: marker-pulse 1.6s ease-in-out infinite;
}
.marker svg { width: 14px; height: 14px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes marker-pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 143, 107, 0.12); } }

#reticle {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
#reticle.on { opacity: 1; }
#reticle .ring {
  position: absolute;
  left: calc(var(--r) * -1);
  top: calc(var(--r) * -1);
  width: calc(var(--r) * 2);
  height: calc(var(--r) * 2);
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  animation: reticle-spin 6s linear infinite;
}
#reticle .tick {
  position: absolute;
  width: 6px;
  height: 14px;
  margin: -7px 0 0 -3px;
  border-radius: 3px;
  background: rgba(255, 143, 107, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
  transform: rotate(var(--a)) translateX(var(--g));
}
#reticle .tick.l { transform: rotate(var(--a)) translateX(calc(var(--g) * -1)); }
@keyframes reticle-spin { to { transform: rotate(360deg); } }
