:root {
  color-scheme: light;
  --ink: #171816;
  --paper: #fffaf0;
  --paper-deep: #f3e6c8;
  --stage: #bcebe7;
  --stage-deep: #73d2ca;
  --accent: #eb523f;
  --accent-dark: #9f2c23;
  --status: #147c75;
  --shadow: rgba(22, 31, 29, 0.2);
  --border: 3px solid var(--ink);
  --radius: 24px;
  --display: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  --body: "Avenir Next", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-width: 280px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vw, 28px);
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--body);
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.9), transparent 25%),
    linear-gradient(145deg, var(--stage) 0%, var(--paper-deep) 85%);
  transition: background 900ms ease, color 500ms ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.24'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

body[data-tier="1"] {
  --stage: #f7d975;
  --stage-deep: #e8b84c;
  --paper-deep: #efdba9;
  --status: #9a5b00;
}

body[data-tier="2"] {
  --stage: #ee9b63;
  --stage-deep: #d76440;
  --paper-deep: #dca780;
  --status: #8a291d;
}

body[data-tier="3"] {
  color-scheme: dark;
  --ink: #f8e9cf;
  --paper: #382120;
  --paper-deep: #190f10;
  --stage: #863d46;
  --stage-deep: #4b2029;
  --accent: #f2b84b;
  --accent-dark: #be7624;
  --status: #ffc75f;
  --shadow: rgba(0, 0, 0, 0.48);
}

button,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
select:focus-visible {
  outline: 4px solid #37a8e4;
  outline-offset: 3px;
}

.widget {
  position: relative;
  width: min(100%, 430px);
  min-height: min(760px, calc(100dvh - 20px));
  display: flex;
  flex-direction: column;
  padding: 22px 22px 16px;
  border: var(--border);
  border-radius: 30px 30px 20px 20px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 10px 12px 0 rgba(23, 24, 22, 0.88), 0 28px 70px var(--shadow);
  transition: background 600ms ease, border-color 500ms ease, box-shadow 500ms ease;
}

.widget::after {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: 10;
  pointer-events: none;
  border: 1px dashed color-mix(in srgb, var(--ink) 24%, transparent);
  border-radius: 22px 22px 13px 13px;
}

.topbar,
.status-row,
.daily-copy,
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  position: relative;
  z-index: 11;
  align-items: flex-start;
}

.brand-block {
  transform: rotate(-1deg);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.share-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 4px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  color: var(--ink);
  background: var(--stage);
  box-shadow: 2px 2px 0 var(--ink);
  font-family: var(--display);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  line-height: 1;
  cursor: pointer;
  transform: rotate(1.5deg);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.share-button i {
  font-family: var(--body);
  font-size: 14px;
  font-style: normal;
}

.share-button:hover {
  transform: rotate(-1deg) translateY(-1px);
  box-shadow: 3px 4px 0 var(--ink);
}

.share-button:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

h1,
h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  letter-spacing: 0.025em;
  line-height: 0.9;
}

h1 {
  font-size: clamp(30px, 9vw, 45px);
}

h2 {
  font-size: 34px;
}

.icon-button {
  width: 42px;
  height: 36px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: transparent;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.icon-button:hover {
  transform: rotate(6deg) scale(1.06);
  background: var(--stage);
}

.status-row {
  position: relative;
  z-index: 11;
  margin-top: 16px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.status-badge {
  padding: 5px 8px 4px;
  border: 2px solid currentColor;
  color: var(--status);
  transform: rotate(-1.5deg);
}

.time-since {
  text-align: right;
  opacity: 0.67;
}

.cat-stage {
  position: relative;
  width: calc(100% + 22px);
  height: clamp(245px, 43dvh, 355px);
  min-height: 210px;
  margin: 2px -11px -2px;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cat-stage::after {
  content: "CLICK ME";
  position: absolute;
  right: 8px;
  bottom: 17px;
  z-index: 3;
  padding: 4px 7px 3px;
  border: 2px solid var(--ink);
  border-radius: 2px;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.08em;
  transform: rotate(5deg);
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
}

.cat-stage:hover::after {
  opacity: 1;
  transform: rotate(2deg) translateY(-2px);
}

.sunburst {
  position: absolute;
  inset: 10% 6% 3%;
  border-radius: 48%;
  opacity: 0.68;
  background: repeating-conic-gradient(from -7deg, transparent 0deg 12deg, color-mix(in srgb, var(--stage-deep) 48%, transparent) 12deg 17deg);
  mask-image: radial-gradient(ellipse at center, #000 0 48%, transparent 75%);
  animation: slow-spin 40s linear infinite;
}

.cat-image {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  user-select: none;
  filter: drop-shadow(0 11px 4px rgba(22, 24, 22, 0.14));
  transform-origin: 50% 85%;
  transition: opacity 180ms ease, transform 180ms ease, filter 500ms ease;
}

.cat-image.is-changing {
  opacity: 0;
  transform: scale(0.94) rotate(-2deg);
}

body[data-tier="1"] .cat-image {
  animation: impatient 3.4s ease-in-out infinite;
}

body[data-tier="2"] .cat-image {
  animation: twitch 2.8s steps(1, end) infinite;
}

body[data-tier="3"] .cat-image {
  filter: drop-shadow(0 14px 7px rgba(0, 0, 0, 0.38));
  animation: wobble 3s ease-in-out infinite;
}

.cat-revival {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.cat-revival i {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 4px;
  height: 27px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: #f2b84b;
  box-shadow: 1px 1px 0 var(--ink);
  opacity: 0;
  transform-origin: 50% 118px;
  transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-84px) scaleY(0.25);
}

.cat-revival.go i {
  animation: revival-ray 620ms cubic-bezier(0.12, 0.7, 0.24, 1) forwards;
}

.cat-revival.go i:nth-child(1) { --angle: 0deg; animation-delay: 0ms; }
.cat-revival.go i:nth-child(2) { --angle: 45deg; animation-delay: 55ms; }
.cat-revival.go i:nth-child(3) { --angle: 90deg; animation-delay: 20ms; }
.cat-revival.go i:nth-child(4) { --angle: 135deg; animation-delay: 75ms; }
.cat-revival.go i:nth-child(5) { --angle: 180deg; animation-delay: 10ms; }
.cat-revival.go i:nth-child(6) { --angle: 225deg; animation-delay: 65ms; }
.cat-revival.go i:nth-child(7) { --angle: 270deg; animation-delay: 30ms; }
.cat-revival.go i:nth-child(8) { --angle: 315deg; animation-delay: 85ms; }

.cat-image.revive {
  animation: cat-revive 650ms cubic-bezier(0.16, 0.82, 0.25, 1) both !important;
}

.speech-wrap {
  position: relative;
  z-index: 4;
  min-height: 54px;
  display: grid;
  place-items: center;
  margin: -4px 0 19px;
}

.speech {
  position: relative;
  max-width: 92%;
  margin: 0;
  padding: 10px 14px 9px;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  font-style: italic;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  transform: rotate(-0.6deg);
}

.speech::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 27%;
  width: 15px;
  height: 15px;
  border-top: 2px solid var(--ink);
  border-left: 2px solid var(--ink);
  background: var(--paper);
  transform: rotate(45deg);
}

.controls {
  position: relative;
  z-index: 11;
}

.drink-button {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 59px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 15px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  color: #fff8e9;
  background: var(--accent);
  box-shadow: 0 7px 0 var(--accent-dark), 0 10px 0 var(--ink);
  font-family: var(--display);
  font-size: 23px;
  letter-spacing: 0.035em;
  cursor: pointer;
  transform: rotate(0.35deg);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.drink-button:hover {
  filter: brightness(1.07);
  transform: rotate(-0.25deg) translateY(-2px);
  box-shadow: 0 9px 0 var(--accent-dark), 0 12px 0 var(--ink);
}

.drink-button:active,
.drink-button.is-pressed {
  transform: translateY(7px);
  box-shadow: 0 1px 0 var(--accent-dark), 0 3px 0 var(--ink);
}

.plus-one {
  position: absolute;
  right: 25px;
  top: 50%;
  padding: 2px 5px 1px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  color: var(--ink);
  background: var(--stage);
  box-shadow: 2px 2px 0 var(--ink);
  font-family: var(--body);
  font-size: 17px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-30%) rotate(5deg) scale(0.45);
}

.plus-one.go {
  animation: plus-one-pop 760ms cubic-bezier(0.16, 0.8, 0.26, 1) forwards;
}

.button-splash {
  position: absolute;
  left: 50%;
  top: 28px;
  z-index: 1;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.button-splash i {
  position: absolute;
  left: 0;
  top: 0;
  width: 12px;
  height: 16px;
  border: 2px solid #12658c;
  border-radius: 70% 42% 68% 52%;
  background: #55d9f2;
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, 0.45);
  opacity: 0;
  transform: translate(-50%, -50%) rotate(45deg) scale(0.35);
}

.button-splash.go i {
  animation: button-splash 720ms cubic-bezier(0.12, 0.72, 0.22, 1) forwards;
}

.button-splash.go i:nth-child(1) { --x: -142px; --y: -44px; animation-delay: 0ms; }
.button-splash.go i:nth-child(2) { --x: -95px; --y: -71px; animation-delay: 35ms; }
.button-splash.go i:nth-child(3) { --x: -38px; --y: -81px; animation-delay: 70ms; }
.button-splash.go i:nth-child(4) { --x: 26px; --y: -84px; animation-delay: 18ms; }
.button-splash.go i:nth-child(5) { --x: 82px; --y: -73px; animation-delay: 55ms; }
.button-splash.go i:nth-child(6) { --x: 139px; --y: -43px; animation-delay: 10ms; }
.button-splash.go i:nth-child(7) { --x: 153px; --y: 3px; animation-delay: 75ms; }

.countdown {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.48em;
  margin: 18px 0 2px;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  opacity: 0.72;
}

.countdown strong {
  font: inherit;
}

.daily-card {
  position: relative;
  z-index: 11;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 2px solid var(--ink);
}

.daily-copy {
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.08em;
}

.daily-copy strong {
  font-size: 18px;
}

.drop-track {
  display: grid;
  grid-template-columns: repeat(var(--goal-count, 8), minmax(0, 1fr));
  gap: clamp(3px, 1.7vw, 7px);
  margin-top: 7px;
}

.tally-drop {
  width: min(100%, 22px);
  justify-self: center;
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  border-radius: 70% 42% 68% 52%;
  background: transparent;
  transform: rotate(45deg) scale(0.76);
  transition: transform 280ms cubic-bezier(0.15, 0.8, 0.25, 1.4), background 250ms ease;
}

.tally-drop.is-filled {
  background: #3cc9e9;
  box-shadow: inset 4px 4px 0 rgba(255, 255, 255, 0.38);
  transform: rotate(45deg) scale(1);
}

.desk-tip {
  position: relative;
  z-index: 11;
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 12px 2px 0;
  padding: 7px 9px;
  border: 1.5px dashed color-mix(in srgb, var(--ink) 62%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--stage) 24%, var(--paper));
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.desk-tip.is-dismissing {
  opacity: 0;
  transform: translateY(4px) rotate(-0.5deg) scale(0.98);
}

.desk-tip:hover {
  background: color-mix(in srgb, var(--stage) 40%, var(--paper));
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--ink) 76%, transparent);
  transform: translateY(-2px) rotate(0.25deg);
}

.desk-tip p {
  flex: 1;
  margin: 0;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.025em;
  line-height: 1.2;
}

.tip-dismiss {
  width: 24px;
  height: 24px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 0 0 2px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--body);
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease;
}

.tip-dismiss:hover {
  background: var(--accent);
  transform: rotate(8deg) scale(1.06);
}

.desk-tip strong {
  display: block;
  margin-bottom: 1px;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.09em;
}

.mini-window {
  position: relative;
  width: 34px;
  height: 26px;
  flex: 0 0 auto;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--paper);
  box-shadow: 2px 2px 0 var(--ink);
  overflow: hidden;
}

.mini-window::before {
  content: "•••";
  position: absolute;
  top: -4px;
  left: 4px;
  font-size: 8px;
  letter-spacing: 1px;
}

.mini-window i {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 13px;
  height: 10px;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  background: var(--stage);
  transform-origin: 100% 100%;
}

.desk-tip:hover .mini-window i {
  animation: dock-window 720ms cubic-bezier(0.16, 0.84, 0.24, 1) both;
}

.settings {
  width: min(390px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 22px;
  border: 3px solid #171816;
  border-radius: 18px;
  color: #171816;
  background: #fffaf0;
  box-shadow: 8px 9px 0 #171816;
  overflow-y: auto;
}

.settings::backdrop {
  background: rgba(14, 14, 12, 0.68);
  backdrop-filter: blur(4px);
}

.settings[open] {
  animation: dialog-in 220ms cubic-bezier(0.15, 0.9, 0.3, 1.25);
}

.close-button {
  font-size: 25px;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 22px;
  font-size: 13px;
  font-weight: 900;
}

.field-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.field-heading output {
  min-width: 34px;
  padding: 3px 7px;
  border: 2px solid #171816;
  border-radius: 50%;
  color: #171816;
  background: #f2c34c;
  font-family: var(--display);
  font-size: 18px;
  line-height: 1.1;
  text-align: center;
  transform: rotate(3deg);
}

.field select {
  width: 100%;
  padding: 11px 12px;
  border: 2px solid #171816;
  border-radius: 4px;
  color: #171816;
  background: #fff;
  font-weight: 800;
}

.field small {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.6;
}

.field input[type="range"] {
  width: 100%;
  height: 23px;
  margin: 0;
  accent-color: #eb523f;
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: -7px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  opacity: 0.55;
  text-transform: uppercase;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.preview-grid button {
  border: 2px solid #171816;
  border-radius: 4px;
  color: #171816;
  background: #fff;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.preview-grid button {
  padding: 8px 2px;
}

.preview-grid button:hover,
.preview-grid button.is-active {
  background: #f2c34c;
}

.toggle-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 48px;
  align-items: center;
  gap: 15px;
  margin-top: 22px;
  cursor: pointer;
}

.toggle-row > span {
  display: grid;
  gap: 3px;
}

.toggle-row strong {
  font-size: 13px;
}

.toggle-row small {
  font-size: 10px;
  line-height: 1.3;
  opacity: 0.6;
}

.toggle-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-row i {
  position: relative;
  width: 48px;
  height: 28px;
  border: 2px solid #171816;
  border-radius: 30px;
  background: #d8d0c0;
  box-shadow: 2px 2px 0 #171816;
  transition: background 180ms ease;
}

.toggle-row i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  border: 2px solid #171816;
  border-radius: 50%;
  background: #fffaf0;
  transition: transform 180ms cubic-bezier(0.15, 0.8, 0.25, 1.3);
}

.toggle-row input:checked + i {
  background: #eb523f;
}

.toggle-row input:checked + i::after {
  transform: translateX(20px);
}

.toggle-row input:focus-visible + i {
  outline: 4px solid #37a8e4;
  outline-offset: 3px;
}

.text-button {
  width: 100%;
  margin-top: 13px;
  border: 0;
  color: #a62e26;
  background: transparent;
  font-size: 11px;
  font-weight: 900;
  text-decoration: underline;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  max-width: calc(100vw - 30px);
  padding: 9px 13px;
  border: 2px solid #171816;
  color: #171816;
  background: #fffaf0;
  box-shadow: 3px 3px 0 #171816;
  font-size: 12px;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes slow-spin {
  to { transform: rotate(360deg); }
}

@keyframes impatient {
  0%, 88%, 100% { transform: translateX(0); }
  91% { transform: translateX(-4px) rotate(-1deg); }
  95% { transform: translateX(4px) rotate(1deg); }
}

@keyframes twitch {
  0%, 80%, 84%, 100% { transform: translate(0, 0); }
  81% { transform: translate(-3px, 1px); }
  82% { transform: translate(3px, -2px); }
  83% { transform: translate(-2px, 0); }
}

@keyframes wobble {
  0%, 100% { transform: rotate(-0.7deg) translateY(0); }
  50% { transform: rotate(0.8deg) translateY(2px); }
}

@keyframes cat-revive {
  0% { transform: scale(0.88) rotate(-3deg); filter: saturate(0.65) brightness(0.9); }
  30% { transform: scale(0.82, 1.07) rotate(2deg); }
  58% { transform: scale(1.09, 0.94) rotate(-1deg); filter: saturate(1.2) brightness(1.06); }
  78% { transform: scale(0.98, 1.03) rotate(0.5deg); }
  100% { transform: scale(1) rotate(0); filter: none; }
}

@keyframes revival-ray {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-70px) scaleY(0.2); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-132px) scaleY(1.25); }
}

@keyframes button-splash {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(45deg) scale(0.3); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(45deg) scale(1); }
}

@keyframes plus-one-pop {
  0% { opacity: 0; transform: translateY(-20%) rotate(6deg) scale(0.45); }
  24% { opacity: 1; transform: translateY(-75%) rotate(-3deg) scale(1.25); }
  70% { opacity: 1; transform: translateY(-150%) rotate(2deg) scale(1); }
  100% { opacity: 0; transform: translateY(-215%) rotate(-2deg) scale(0.82); }
}

@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.92) rotate(-1deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes dock-window {
  0% { transform: translate(0, 0) scale(1); }
  42% { transform: translate(-5px, -3px) scale(1.08) rotate(-3deg); }
  100% { transform: translate(1px, 1px) scale(0.68); }
}

@media (max-height: 680px) {
  .widget {
    min-height: calc(100dvh - 12px);
    padding-top: 16px;
  }

  .cat-stage {
    height: clamp(180px, 36dvh, 255px);
  }

  .status-row {
    margin-top: 9px;
  }

  .speech-wrap {
    min-height: 45px;
    margin-bottom: 13px;
  }

  .daily-card {
    margin-top: 13px;
  }
}

@media (max-width: 460px) {
  body {
    padding: 0;
    place-items: stretch;
  }

  .widget {
    width: 100%;
    min-height: 100dvh;
    border-width: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .widget::after {
    border-radius: 14px;
  }
}

/* Compact desk-widget mode for a small window tucked into a screen corner. */
@media (max-height: 560px) {
  html,
  body {
    min-width: 240px;
    height: 100%;
  }

  body {
    min-height: 100dvh;
    padding: 0;
  }

  .share-button {
    display: none;
  }

  .widget {
    width: min(100%, 430px);
    height: 100dvh;
    min-height: 0;
    display: grid;
    grid-template-rows: 27px minmax(72px, 1fr) auto auto;
    padding: 8px 11px;
    border-radius: 18px;
    box-shadow: 5px 6px 0 rgba(23, 24, 22, 0.88);
  }

  .widget::after {
    inset: 4px;
    border-radius: 13px;
  }

  .widget > .topbar .eyebrow {
    display: none;
  }

  .topbar {
    grid-row: 1;
    grid-column: 1;
    align-items: center;
    gap: 6px;
  }

  h1 {
    font-size: clamp(18px, 7vw, 24px);
  }

  .icon-button {
    width: 31px;
    height: 27px;
    border-width: 1.5px;
    font-size: 12px;
  }

  .status-row {
    grid-row: 2;
    grid-column: 1;
    align-self: start;
    justify-self: start;
    min-height: 0;
    margin-top: 3px;
    gap: 6px;
    font-size: 8px;
    letter-spacing: 0.055em;
  }

  .status-badge {
    padding: 3px 5px 2px;
    border-width: 1.5px;
    background: var(--paper);
    box-shadow: 2px 2px 0 var(--ink);
    white-space: nowrap;
  }

  .time-since {
    display: none;
  }

  .cat-stage {
    grid-row: 2;
    grid-column: 1;
    width: calc(100% + 12px);
    height: 100%;
    min-height: 0;
    margin: -2px -6px 0;
  }

  .cat-stage::after {
    display: none;
  }

  .sunburst {
    inset: 3% 11% 0;
  }

  .speech-wrap {
    grid-row: 2;
    grid-column: 1;
    align-self: end;
    min-height: 28px;
    margin: 0 0 4px;
    pointer-events: none;
  }

  .speech {
    max-width: 98%;
    padding: 5px 8px 4px;
    border-width: 1.5px;
    box-shadow: 2px 2px 0 var(--ink);
    font-size: 10.5px;
    line-height: 1.08;
  }

  .speech::before {
    top: -6px;
    width: 9px;
    height: 9px;
    border-width: 1.5px 0 0 1.5px;
  }

  .controls {
    grid-row: 3;
    grid-column: 1;
  }

  .drink-button {
    min-height: 39px;
    padding: 5px 10px;
    border-width: 2px;
    font-size: 17px;
    box-shadow: 0 4px 0 var(--accent-dark), 0 6px 0 var(--ink);
  }

  .drink-button:hover {
    box-shadow: 0 5px 0 var(--accent-dark), 0 7px 0 var(--ink);
  }

  .drink-button:active,
  .drink-button.is-pressed {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--accent-dark), 0 2px 0 var(--ink);
  }

  .plus-one {
    right: 14px;
    font-size: 12px;
  }

  .countdown {
    z-index: 3;
    width: max-content;
    max-width: 100%;
    margin: 10px auto 0;
    padding: 3px 7px 2px;
    overflow: hidden;
    border-radius: 2px;
    color: var(--paper);
    background: var(--ink);
    font-size: 8.5px;
    letter-spacing: 0.075em;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .countdown strong {
    font: inherit;
  }

  .daily-card {
    grid-row: 4;
    grid-column: 1;
    margin-top: 6px;
    padding-top: 5px;
    border-top-width: 1.5px;
  }

  .daily-copy {
    font-size: 9.5px;
  }

  .daily-copy strong {
    font-size: 12px;
  }

  .drop-track {
    gap: 2px;
    margin-top: 2px;
  }

  .tally-drop {
    width: min(100%, 13px);
    border-width: 1.5px;
  }

  .desk-tip {
    display: none;
  }

  .settings {
    width: min(390px, calc(100vw - 12px));
    max-height: calc(100dvh - 12px);
    padding: 14px;
  }

  .settings h2 {
    font-size: 27px;
  }

  .field,
  .toggle-row {
    margin-top: 14px;
  }

  .toast {
    bottom: 8px;
    padding: 6px 9px;
    font-size: 10px;
  }
}

@media (max-height: 360px) {
  .status-row {
    margin-top: 1px;
  }

  .cat-stage {
    min-height: 0;
  }

  .speech-wrap {
    margin-bottom: 3px;
  }

  .speech {
    max-width: 100%;
    font-size: 9.5px;
  }

  .drink-button {
    min-height: 35px;
    font-size: 15px;
  }

  .countdown {
    margin-top: 8px;
  }

  .daily-card {
    margin-top: 4px;
    padding-top: 4px;
  }
}

/* Short, wide browser windows get a purpose-built landscape control panel. */
@media (min-width: 420px) and (max-height: 420px) {
  .widget {
    width: 100%;
    max-width: none;
    grid-template-columns: minmax(0, 1.35fr) minmax(180px, 0.85fr);
    grid-template-rows: 32px minmax(0, 1fr);
    column-gap: 12px;
    padding: 8px 14px 9px;
    border-width: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .widget::after {
    inset: 4px;
    border-radius: 10px;
  }

  .topbar {
    grid-row: 1;
    grid-column: 1 / -1;
  }

  .share-button {
    display: none;
  }

  h1 {
    font-size: 27px;
  }

  .status-row {
    grid-row: 2;
    grid-column: 1;
    margin: 3px 0 0 2px;
  }

  .status-badge {
    padding: 4px 7px 3px;
    background: var(--paper);
    box-shadow: 2px 2px 0 var(--ink);
  }

  .cat-stage {
    grid-row: 2;
    grid-column: 1;
    width: 100%;
    height: 100%;
    margin: 0;
  }

  .sunburst {
    inset: 1% 5% 0;
  }

  .speech-wrap {
    grid-row: 2;
    grid-column: 1;
    margin: 0 7px 5px;
  }

  .speech {
    max-width: 96%;
    font-size: 11px;
  }

  .controls {
    grid-row: 2;
    grid-column: 2;
    align-self: center;
    padding: 0 2px;
  }

  .drink-button {
    min-height: 50px;
    font-size: 20px;
  }

  .countdown {
    width: 100%;
    max-width: none;
    display: grid;
    gap: 3px;
    margin: 14px 0 0;
    padding: 8px 10px 7px;
    overflow: visible;
    border: 2px solid var(--ink);
    border-radius: 5px;
    color: var(--ink);
    background: color-mix(in srgb, var(--stage) 38%, var(--paper));
    box-shadow: 3px 3px 0 var(--ink);
    font-size: 9px;
    line-height: 1;
    opacity: 1;
    white-space: normal;
  }

  .countdown span {
    font-size: 9px;
    letter-spacing: 0.1em;
  }

  .countdown strong {
    font-size: 12px;
    letter-spacing: 0.055em;
  }

  .countdown[data-mode="timer"] strong {
    font-size: 23px;
    letter-spacing: 0.04em;
  }

  .daily-card {
    grid-row: 2;
    grid-column: 2;
    align-self: end;
    margin: 0 2px;
    padding-top: 8px;
  }

  .daily-copy {
    font-size: 10px;
  }

  .daily-copy strong {
    font-size: 13px;
  }

  .drop-track {
    gap: 3px;
    margin-top: 5px;
  }

  .tally-drop {
    width: min(100%, 15px);
  }
}

@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;
  }
}
