:root {
  --bg-a: #ecf3f2;
  --bg-b: #e4ebf0;
  --card: rgba(248, 251, 251, 0.9);
  --card-border: rgba(51, 80, 95, 0.12);
  --ink: #213846;
  --muted: #627984;
  --button: #2f637b;
  --button-hover: #29586d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Manrope", "Avenir Next", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1000px 500px at -10% -20%, rgba(150, 196, 180, 0.32), transparent 58%),
    radial-gradient(900px 520px at 110% 0%, rgba(163, 186, 220, 0.25), transparent 62%),
    linear-gradient(165deg, var(--bg-a), var(--bg-b));
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 36px);
}

.layout {
  width: min(980px, 100%);
  display: grid;
  justify-items: center;
  gap: 18px;
}

h1 {
  margin: 0;
  text-align: center;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-wrap: balance;
  color: #203746;
  font-size: clamp(2rem, 5vw, 3.6rem);
}

.gauge-card {
  width: min(980px, 100%);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 34px;
  padding: clamp(14px, 3.5vw, 30px);
  box-shadow: 0 22px 48px rgba(30, 52, 62, 0.13);
  backdrop-filter: blur(7px);
}

.gauge-card.locked-wiggle {
  animation: locked-wiggle 360ms ease;
}

@keyframes locked-wiggle {
  0% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

#gauge {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;
  user-select: none;
}

#track {
  fill: none;
  stroke: rgba(113, 137, 147, 0.2);
  stroke-width: 58;
  stroke-linecap: round;
}

#colorArc {
  fill: none;
  stroke: url(#arcPaint);
  stroke-width: 44;
  stroke-linecap: round;
  filter: url(#softShadow);
}

#ticks line {
  stroke: rgba(87, 108, 118, 0.5);
  stroke-linecap: round;
}

#needleShadow {
  stroke: rgba(16, 32, 40, 0.25);
  stroke-width: 12;
  stroke-linecap: round;
}

#needle {
  stroke: url(#needlePaint);
  stroke-width: 8.5;
  stroke-linecap: round;
  transition: x1 90ms linear, y1 90ms linear, x2 90ms linear, y2 90ms linear;
}

#pivotOuter {
  fill: #f9fdfd;
  stroke: rgba(39, 59, 70, 0.2);
  stroke-width: 6;
}

#pivotInner {
  fill: #c94754;
}

.score {
  margin-top: -6px;
  text-align: center;
  font-size: clamp(3rem, 10vw, 5.6rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #223a4a;
}

.julia-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 24px;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  color: #f4fcff;
  background: var(--button);
  cursor: pointer;
  box-shadow: 0 9px 18px rgba(34, 64, 79, 0.24);
  transition: transform 130ms ease, background-color 130ms ease;
}

.julia-button:hover {
  transform: translateY(-1px);
  background: var(--button-hover);
}

.julia-button.needs-auth {
  animation: button-pulse 900ms ease;
}

@keyframes button-pulse {
  0% { box-shadow: 0 0 0 0 rgba(215, 103, 116, 0.46); }
  70% { box-shadow: 0 0 0 16px rgba(215, 103, 116, 0); }
  100% { box-shadow: 0 0 0 0 rgba(215, 103, 116, 0); }
}

.pin-dialog {
  width: min(360px, calc(100vw - 24px));
  border: 1px solid rgba(43, 69, 81, 0.24);
  border-radius: 18px;
  padding: 18px;
  background: rgba(250, 253, 253, 0.96);
  box-shadow: 0 24px 54px rgba(20, 38, 47, 0.24);
}

.pin-dialog::backdrop {
  background: rgba(16, 27, 34, 0.31);
  backdrop-filter: blur(3px);
}

#pinForm {
  display: grid;
  gap: 10px;
}

#pinForm h2 {
  margin: 0;
  font-size: 1.05rem;
  color: #2a4757;
}

#pinInput {
  border: 1px solid rgba(48, 78, 94, 0.26);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  color: #233a47;
  background: rgba(255, 255, 255, 0.95);
  outline: none;
}

#pinInput:focus {
  border-color: rgba(47, 99, 123, 0.52);
  box-shadow: 0 0 0 3px rgba(47, 99, 123, 0.17);
}

.pin-error {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: #ba4c56;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-ghost,
.btn-solid {
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(47, 76, 89, 0.28);
  color: #365a6b;
}

.btn-solid {
  border: 0;
  background: var(--button);
  color: #eff8fb;
}

@media (max-width: 700px) {
  .gauge-card {
    border-radius: 26px;
    padding: 14px;
  }

  .julia-button {
    width: min(240px, 100%);
  }
}
