:root {
  --ink: #2d1d16;
  --cream: #fff8e8;
  --orange: #ff7a2f;
  --orange-dark: #d94a1c;
  --green: #325c47;
  --yellow: #f9a825;
  --mid-green: #4caf50;
  --red: #e53935;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: #efcf84;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

.page {
  position: relative;
  display: grid;
  min-height: 100svh;
  place-items: center;
  overflow: hidden;
  padding: 40px 20px;
  isolation: isolate;
  background: linear-gradient(145deg, #f7d98b, #eeb267);
}

.page::before {
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 32px 32px;
  content: "";
}

.sun {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  background: rgba(255, 251, 224, 0.4);
  filter: blur(1px);
}

.sun-one {
  top: -90px;
  right: -70px;
  width: 270px;
  height: 270px;
}

.sun-two {
  bottom: -110px;
  left: -80px;
  width: 310px;
  height: 310px;
}

/* ---- layout ---- */
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  width: 100%;
  max-width: 680px;
}

.title-block {
  text-align: center;
}

h1 {
  margin: 0;
  font-family: Impact, "Microsoft YaHei", sans-serif;
  font-size: clamp(2.2rem, 8vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.03em;
  line-height: 1.2;
  text-shadow: 3px 3px 0 rgba(255, 248, 232, 0.72);
}

.subtitle {
  margin: 20px 0 0;
  color: rgba(45, 29, 22, 0.68);
  font-size: clamp(1rem, 3vw, 1.4rem);
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* ---- gauge ---- */
.gauge-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.gauge-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.gauge-container {
  position: relative;
  width: 100%;
  height: 36px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.gauge-bar {
  position: absolute;
  inset: 0;
  display: flex;
  border: 2px solid #1a1a1a;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.2),
    0 6px 20px rgba(73, 39, 20, 0.28),
    0 3px 0 rgba(73, 38, 21, 0.18);
}

.gauge-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.gauge-yellow {
  flex: 6 0 0%;
  background: linear-gradient(180deg, #fdd835, #f9a825);
}

.gauge-green {
  flex: 1 0 0%;
  background: linear-gradient(180deg, #66bb6a, #388e3c);
}

.gauge-red {
  flex: 3 0 0%;
  background: linear-gradient(180deg, #ef5350, #c62828);
}

/* ---- ticks ---- */
.gauge-ticks {
  position: absolute;
  inset: 0 0 auto 0;
  top: 50%;
  height: 8px;
  transform: translateY(-50%);
  pointer-events: none;
}

.tick {
  position: absolute;
  top: 0;
  width: 1.5px;
  height: 100%;
  background: rgba(255, 255, 255, 0.55);
  transform: translateX(-50%);
  border-radius: 2px;
}

.tick:nth-child(5n + 1) {
  height: 160%;
  top: -30%;
  width: 2px;
  background: rgba(255, 255, 255, 0.8);
}

/* ---- pointer ---- */
.gauge-pointer {
  position: absolute;
  top: -10px;
  bottom: -6px;
  width: 18px;
  margin-left: -9px;
  z-index: 2;
  filter: drop-shadow(2px 2px 3px rgba(45, 29, 22, 0.45));
  transition: filter 180ms ease;
}

.pointer-svg {
  width: 100%;
  height: 100%;
}

.pointer-svg polygon {
  fill: var(--cream);
  stroke: var(--ink);
  stroke-width: 1.2;
  stroke-linejoin: round;
}

/* lock / bounce states */
.gauge-pointer.is-locked .pointer-svg polygon {
  fill: #fff;
  animation: pointer-flash 120ms ease 3;
}

.gauge-pointer.is-done {
  filter: drop-shadow(0 0 10px rgba(255, 248, 232, 0.9));
}

/* ---- particles ---- */
.particle {
  position: absolute;
  top: var(--py);
  left: var(--px);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
}

/* ---- reset button ---- */
.reset-button {
  flex-shrink: 0;
  min-height: 36px;
  border: 2px solid rgba(45, 29, 22, 0.35);
  border-radius: 18px;
  padding: 0 18px;
  color: var(--ink);
  background: rgba(255, 248, 232, 0.65);
  backdrop-filter: blur(4px);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(73, 39, 20, 0.15);
  transition: background 180ms ease, transform 120ms ease;
}

.reset-button:hover {
  background: rgba(255, 248, 232, 0.9);
  transform: scale(1.04);
}

.reset-button:active {
  transform: scale(0.96);
}

/* ---- dog photo ---- */
.photo-frame {
  position: relative;
  overflow: hidden;
  width: min(100%, 450px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border: 10px solid var(--cream);
  border-radius: 28px;
  background: #c69963;
  box-shadow:
    0 22px 44px rgba(73, 39, 20, 0.26),
    0 5px 0 rgba(72, 43, 27, 0.12);
  transform: rotate(-1deg);
}

.dog-photo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* ---- hint ---- */
.gauge-hint {
  margin: 0;
  min-height: 24px;
  color: rgba(45, 29, 22, 0.64);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: color 200ms ease, transform 200ms ease;
}

.gauge-hint.is-active {
  color: var(--ink);
  transform: scale(1.06);
}

.gauge-hint.is-done {
  color: var(--green);
}

/* ---- anims ---- */
@keyframes pointer-flash {
  0%, 100% { fill: #fff; }
  50% { fill: #ffcc80; }
}

/* ---- responsive ---- */
@media (max-width: 520px) {
  .page {
    padding: 20px 12px;
  }

  .content {
    gap: 24px;
  }

  /* suns smaller on mobile */
  .sun-one {
    top: -50px;
    right: -40px;
    width: 150px;
    height: 150px;
  }

  .sun-two {
    bottom: -60px;
    left: -40px;
    width: 170px;
    height: 170px;
  }

  h1 {
    font-size: clamp(1.8rem, 9vw, 3rem);
  }

  .subtitle {
    margin-top: 14px;
    font-size: clamp(0.85rem, 3.5vw, 1.1rem);
  }

  .gauge-section {
    gap: 12px;
  }

  .gauge-row {
    gap: 8px;
  }

  .gauge-container {
    height: 28px;
  }

  .gauge-bar {
    border-width: 1.5px;
    border-radius: 14px;
  }

  .gauge-pointer {
    top: -7px;
    bottom: -4px;
    width: 13px;
    margin-left: -6.5px;
  }

  .reset-button {
    min-height: 28px;
    padding: 0 12px;
    font-size: 0.75rem;
    border-radius: 14px;
  }

  .gauge-hint {
    font-size: 0.8rem;
  }

  .photo-frame {
    border-width: 6px;
    border-radius: 20px;
    box-shadow:
      0 12px 28px rgba(73, 39, 20, 0.22),
      0 3px 0 rgba(72, 43, 27, 0.1);
  }
}

/* small phones */
@media (max-width: 360px) {
  .page {
    padding: 16px 10px;
  }

  .content {
    gap: 18px;
  }

  .gauge-container {
    height: 24px;
  }

  .gauge-bar {
    border-radius: 12px;
  }

  .gauge-pointer {
    top: -6px;
    bottom: -3px;
    width: 11px;
    margin-left: -5.5px;
  }

  .reset-button {
    min-height: 24px;
    padding: 0 10px;
    font-size: 0.7rem;
    border-radius: 12px;
  }

  .photo-frame {
    border-width: 5px;
    border-radius: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
