:root {
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #3f302a;
  background: #fff7ed;
  --heat-0: #f2ece7;
  --heat-1: #bbf7d0;
  --heat-2: #4ade80;
  --heat-3: #60a5fa;
  --heat-4: #facc15;
  --heat-1-text: #244c35;
  --heat-2-text: #173d28;
  --heat-3-text: #173b67;
  --heat-4-text: #4d3b00;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 15%, rgba(251, 191, 36, 0.23), transparent 25%),
    radial-gradient(circle at 85% 82%, rgba(251, 146, 60, 0.18), transparent 28%),
    #fff7ed;
}

.settings-shell {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10;
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  color: #5f5048;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(120, 79, 54, 0.14);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(92, 65, 50, 0.12);
  backdrop-filter: blur(10px);
}

.settings-toggle:hover {
  color: #28754a;
  border-color: #86cfa6;
}

.settings-panel {
  width: min(390px, calc(100vw - 28px));
  max-height: calc(100vh - 80px);
  margin-top: 10px;
  padding: 20px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(120, 79, 54, 0.14);
  border-radius: 20px;
  box-shadow: 0 20px 55px rgba(74, 53, 42, 0.2);
}

.settings-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.settings-title strong,
.settings-title span {
  display: block;
}

.settings-title strong {
  font-size: 18px;
}

.settings-title span {
  margin-top: 3px;
  color: #907b70;
  font-size: 11px;
}

#settings-close {
  padding: 0;
  color: #8a7469;
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  border: 0;
}

.settings-labels,
.heat-setting-row {
  display: grid;
  grid-template-columns: minmax(68px, 1fr) 44px 82px 32px;
  align-items: center;
  gap: 10px;
}

.settings-labels {
  margin-bottom: 6px;
  color: #a08c82;
  font-size: 10px;
}

.settings-labels span:nth-child(n + 2) {
  text-align: center;
}

.heat-setting-row {
  padding: 7px 0;
  color: #66534a;
  font-size: 12px;
  font-weight: 700;
}

.heat-setting-row input[type="color"] {
  width: 40px;
  height: 34px;
  padding: 3px;
  cursor: pointer;
  background: #fff;
  border: 1px solid #ded2ca;
  border-radius: 9px;
}

.heat-setting-row input[type="number"] {
  width: 82px;
  padding: 8px 7px;
  color: #51423b;
  font: inherit;
  font-size: 12px;
  text-align: center;
  border: 1px solid #ded2ca;
  border-radius: 9px;
}

.heat-setting-row input[type="number"]:disabled {
  color: #7a6a62;
  background: #eee9e5;
  cursor: not-allowed;
}

.delete-tier {
  width: 30px;
  height: 30px;
  padding: 0;
  color: #6d28d9;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  background: #f3e8ff;
  border: 0;
  border-radius: 50%;
}

.tier-lock {
  color: #9b8c85;
  font-size: 13px;
  text-align: center;
}

.add-tier {
  width: 100%;
  margin-top: 9px;
  padding: 9px;
  color: #256b49;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  background: #ecfdf3;
  border: 1px dashed #75c99b;
  border-radius: 10px;
}

.settings-error {
  min-height: 16px;
  margin: 7px 0 3px;
  color: #6d28d9;
  font-size: 11px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.settings-actions button {
  padding: 8px 13px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 999px;
}

.restore-settings {
  color: #76645b;
  background: transparent;
  border: 1px solid #ded2ca;
}

.save-settings {
  color: #fff;
  background: #268653;
  border: 1px solid #268653;
}

.counter-card {
  width: min(100%, 620px);
  padding: 40px 32px 32px;
  text-align: center;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(120, 79, 54, 0.1);
  border-radius: 32px;
  box-shadow: 0 24px 70px rgba(120, 79, 54, 0.14);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 8px;
  color: #c76a30;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
}

h1 {
  margin: 0 0 26px;
  font-size: clamp(30px, 8vw, 42px);
  line-height: 1.2;
  letter-spacing: -0.04em;
}

.image-wrap {
  position: relative;
  width: min(100%, 270px);
  margin: 0 auto 26px;
}

.dog-button {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  border: 0;
  border-radius: 28px;
  box-shadow: 0 14px 32px rgba(92, 65, 50, 0.18);
  transition: transform 160ms ease, box-shadow 160ms ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.dog-button:hover {
  transform: translateY(-3px) rotate(-1deg);
  box-shadow: 0 18px 38px rgba(92, 65, 50, 0.22);
}

.dog-button:active,
.dog-button.is-clicked {
  transform: scale(0.95) rotate(1deg);
}

.dog-button:focus-visible,
.reset-button:focus-visible {
  outline: 4px solid rgba(234, 88, 12, 0.28);
  outline-offset: 4px;
}

.dog-button img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
}

.bark-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
}

.bark {
  position: absolute;
  top: 2%;
  right: -3%;
  padding: 8px 12px;
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  background: #ef762f;
  border: 4px solid #fff;
  border-radius: 50% 50% 50% 14%;
  box-shadow: 0 8px 22px rgba(190, 79, 19, 0.28);
  transform-origin: left bottom;
  animation: bark-in-out 900ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes bark-in-out {
  0% {
    opacity: 0;
    transform: translate(10px, 12px) scale(0.35) rotate(8deg);
  }
  25%, 62% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(-4deg);
  }
  100% {
    opacity: 0;
    transform: translate(5px, -24px) scale(1.12) rotate(2deg);
  }
}

.count-number {
  display: inline-block;
  color: #de5f19;
  font: inherit;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.count-number.bump {
  animation: count-bump 260ms ease-out;
}

@keyframes count-bump {
  50% { transform: scale(1.18); }
}

.reset-button {
  margin-top: 18px;
  padding: 11px 20px;
  color: #7b655a;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  border: 1px solid #dbc9bd;
  border-radius: 999px;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.reset-button:hover {
  color: #b64d17;
  background: #fff7ed;
  border-color: #e9a57e;
}

.attendance {
  margin-top: 36px;
  padding-top: 28px;
  text-align: left;
  border-top: 1px solid #eadfd7;
}

.attendance-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.attendance-kicker {
  margin: 0 0 4px;
  color: #c76a30;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.attendance h2 {
  margin: 0;
  font-size: 24px;
}

.month-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.month-controls strong {
  min-width: 92px;
  text-align: center;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.month-controls button {
  width: 34px;
  height: 34px;
  padding: 0;
  color: #7b655a;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  background: #fffaf6;
  border: 1px solid #e7d8cf;
  border-radius: 50%;
  transition: color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.month-controls button:hover:not(:disabled) {
  color: #de5f19;
  border-color: #e9a57e;
  transform: scale(1.06);
}

.month-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.32;
}

.weekdays,
.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}

.weekdays {
  margin-bottom: 7px;
  color: #9b887f;
  font-size: 11px;
  text-align: center;
}

.day {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  overflow: hidden;
  color: #644f45;
  border: 1px solid rgba(120, 79, 54, 0.08);
  border-radius: 10px;
  transition: transform 150ms ease;
}

.day:hover {
  z-index: 1;
  transform: translateY(-2px);
}

.day.is-empty {
  visibility: hidden;
}

.day.is-today {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.day-number {
  font-size: 11px;
  line-height: 1;
}

.day-count {
  font-size: clamp(11px, 2.8vw, 16px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.day-count::after {
  content: "次";
  margin-left: 1px;
  font-size: 8px;
  font-weight: 600;
  opacity: 0.72;
}

.heat-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 14px;
  color: #9b887f;
  font-size: 10px;
}

.heat-legend-colors {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.heat-legend i {
  display: block;
  width: 13px;
  height: 13px;
  border-radius: 4px;
}

.attendance-note {
  margin: 12px 0 0;
  color: #9b887f;
  font-size: 11px;
  text-align: center;
}

@media (max-width: 480px) {
  body { padding: 14px; }
  .settings-shell { top: 10px; right: 10px; }
  .settings-toggle { padding: 8px 11px; font-size: 12px; }
  .settings-panel { padding: 17px; }
  .counter-card { padding: 32px 20px 26px; border-radius: 26px; }
  .image-wrap { width: min(78vw, 260px); }
  .attendance-heading { align-items: flex-end; }
  .month-controls { gap: 6px; }
  .month-controls strong { min-width: 76px; font-size: 13px; }
  .month-controls button { width: 30px; height: 30px; }
  .weekdays, .calendar { gap: 4px; }
  .day { border-radius: 7px; }
}

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