:root {
  --ink: #2d302b;
  --muted: #74766f;
  --paper: #f7f3e9;
  --card: #fffdf7;
  --line: #e2ddcf;
  --accent: #d95656;
  --soft: #fff0e8;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html {
  background: var(--paper);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12px 12px, rgba(45, 48, 43, 0.035) 1px, transparent 1.5px)
    0 0 / 24px 24px,
    var(--paper);
  color: var(--ink);
  font-family:
    ui-rounded, "SF Pro Rounded", "Nunito", "Avenir Next", system-ui, sans-serif;
  overscroll-behavior: none;
}

button {
  color: inherit;
  font: inherit;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid var(--accent);
  outline: 3px solid color-mix(in srgb, var(--accent), white 35%);
  outline-offset: 3px;
}

a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper);
}

.section-study,
.section-ready,
.section-eat {
  --accent: #d95656;
  --soft: #fff0e8;
}

.section-tidy,
.section-play {
  --accent: #ef7d32;
  --soft: #fff3df;
}

.section-read,
.section-move,
.section-wait {
  --accent: #398766;
  --soft: #e6f5e9;
}

.section-music,
.section-create,
.section-other {
  --accent: #7b63c7;
  --soft: #f0edff;
}

.screen {
  width: min(100%, 480px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    max(24px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
}

.activity-screen {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.subactivity-screen {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.subactivity-header {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  gap: 12px;
  align-items: center;
}

.subactivity-header h1 {
  margin: 0;
  overflow: hidden;
  font-size: 2rem;
  font-size: clamp(1.7rem, 8vw, 2.4rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subactivity-header > span {
  font-size: 1.9rem;
  text-align: center;
}

.subactivity-picker {
  align-content: start;
}

.subactivity-picker button {
  min-height: 104px;
}

.activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.activity-header h1 {
  margin: 0;
  font-size: 2.35rem;
  font-size: clamp(2rem, 9vw, 2.75rem);
  font-weight: 900;
  letter-spacing: -0.055em;
  line-height: 0.96;
}

.activity-clock {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 5px 0 #ddd6c6;
  font-size: 1.9rem;
  transform: rotate(4deg);
}

.activity-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding-top: 2px;
}

.activity-footer a,
.activity-footer .text-link {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-underline-offset: 0.18em;
}

.text-link {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

.language-picker select {
  max-width: 9rem;
  min-height: 2rem;
  border: 1px solid color-mix(in srgb, currentColor 24%, transparent);
  border-radius: 0.55rem;
  padding: 0.25rem 1.7rem 0.25rem 0.55rem;
  background-color: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
}

.legal-screen {
  color: var(--ink);
  font-family: system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.62;
}

.legal-header {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 16px;
  align-items: start;
  margin-bottom: 28px;
}

.legal-header .icon-button {
  color: inherit;
  text-decoration: none;
}

.legal-header h1 {
  margin: 3px 0 0;
  font-size: 1.75rem;
  line-height: 1.12;
}

.legal-eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.legal-screen section {
  margin: 30px 0;
}

.legal-screen h2 {
  margin: 0 0 8px;
  font-size: 1.18rem;
}

.legal-screen p {
  margin: 0 0 14px;
}

.legal-screen a:not(.icon-button) {
  color: #6a47b8;
  text-underline-offset: 0.16em;
}

.legal-return {
  display: inline-block;
  margin: 8px 0 24px;
  font-weight: 750;
}

.info-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  margin-top: 1.7rem;
  padding-top: 1rem;
  border-top: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
}

.info-links a {
  color: var(--ink);
  font-weight: 700;
  text-underline-offset: 0.18em;
}

.activity-picker {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(2, 1fr);
  gap: 11px;
}

.activity-picker button {
  display: flex;
  min-width: 0;
  min-height: 82px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 19px;
  background: var(--card);
  box-shadow: 0 4px 0 #ded8ca;
  text-align: left;
}

.activity-picker button:active {
  box-shadow: 0 1px 0 #ded8ca;
  transform: translateY(3px);
}

.activity-picker span {
  flex: 0 0 auto;
  font-size: 2rem;
}

.activity-picker strong {
  min-width: 0;
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 1.08;
}

.setup-screen {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1,
h2,
p {
  margin-top: 0;
}

.finish-screen h1 {
  margin: 0;
  font-size: 2.5rem;
  font-size: clamp(2.05rem, 9vw, 3rem);
  font-weight: 900;
  letter-spacing: -0.055em;
  line-height: 1;
}

.activity-choice {
  display: flex;
  min-width: 0;
  min-height: 58px;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 10px;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 3px 0 #ded8ca;
  text-align: left;
}

.activity-choice span {
  font-size: 1.75rem;
}

.activity-choice strong {
  overflow: hidden;
  font-size: 0.94rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 5px 0 #ddd6c6;
  font-size: 2rem;
  transform: rotate(4deg);
}

.picker-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.animal-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}

.animal-option {
  min-width: 0;
  min-height: 86px;
  padding: 8px 4px;
  border: 1.5px solid var(--line);
  border-radius: 17px;
  background: var(--card);
  box-shadow: 0 3px 0 #ded8ca;
}

.animal-option > span {
  display: block;
  font-size: 2.5rem;
  transition: transform 180ms ease;
}

.animal-option.selected {
  border-color: var(--accent);
  background: var(--soft);
  box-shadow: 0 3px 0 #9c7665;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--accent), #8e7962 55%);
}

.animal-option.selected > span {
  transform: translateY(-2px) rotate(-4deg) scale(1.08);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.preset-grid button {
  min-height: 52px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 850;
}

.preset-grid button.selected {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--ink);
}

.fine-tune {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding-top: 2px;
}

.fine-tune button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  font-size: 1.4rem;
  font-weight: 700;
}

.fine-tune div {
  display: flex;
  min-width: 76px;
  flex-direction: column;
  align-items: center;
}

.fine-tune strong {
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
}

.fine-tune span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.primary-button {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border: 0;
  border-radius: 19px;
  background: var(--accent);
  box-shadow: 0 5px 0 #9e4848;
  box-shadow: 0 5px 0 color-mix(in srgb, var(--accent), black 25%);
  color: white;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.primary-button:active {
  box-shadow: 0 2px 0 #9e4848;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--accent), black 25%);
  transform: translateY(3px);
}

.primary-button span {
  font-size: 1.35rem;
}

.timer-screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.timer-header {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  gap: 12px;
  align-items: center;
}

.timer-header::after {
  width: 46px;
  height: 46px;
  content: "";
}

.timer-header > strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.86rem;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timer-header > strong span {
  font-size: 1.08rem;
  vertical-align: -0.08em;
}

@media (max-width: 350px) {
  .activity-picker {
    gap: 8px;
  }

  .activity-picker button {
    min-height: 74px;
    gap: 8px;
    padding: 9px;
  }

  .activity-picker span {
    font-size: 1.7rem;
  }
}

.icon-button {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: 15px;
  background: var(--card);
  font-size: 1.25rem;
  font-weight: 800;
}

.time-display {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.time-display strong {
  font-size: 4.5rem;
  font-size: clamp(3.45rem, 18vw, 5.6rem);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  letter-spacing: -0.075em;
  line-height: 0.92;
}

.time-display span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.progress-board {
  display: flex;
  min-height: 430px;
  flex: 1;
  flex-direction: column;
  padding: 16px;
  border: 1.5px solid var(--line);
  border-radius: 30px;
  background: var(--card);
  box-shadow: 0 8px 0 #ded8ca;
}

.progress-grid {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 4px 0 12px;
}

.minute-row {
  display: grid;
  min-height: 0;
  flex: 1 1 0;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: var(--soft);
  background: color-mix(in srgb, var(--soft), white 54%);
  transition:
    background 350ms ease,
    border-color 350ms ease,
    opacity 350ms ease;
}

.minute-row.current {
  border-color: var(--accent);
  background: var(--soft);
  border-color: color-mix(in srgb, var(--accent), transparent 58%);
  background: color-mix(in srgb, var(--soft), white 28%);
}

.is-running .minute-row.current {
  animation: row-breathe 2.2s ease-in-out infinite;
}

.minute-row.complete {
  background: transparent;
  opacity: 0.46;
}

.marker-cell {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  border-radius: 11px;
}

.marker-piece {
  font-size: 1.8rem;
  font-size: clamp(1.45rem, 7.8vw, 2.2rem);
  filter: saturate(0.96);
  transform-origin: center bottom;
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

.marker-cell.complete {
  background: transparent;
}

.marker-cell.complete .marker-piece {
  color: var(--accent);
  color: color-mix(in srgb, var(--accent), #a49d8e 70%);
  font-size: 1.15rem;
  opacity: 0.34;
  transform: scale(0.62);
}

.marker-cell.active {
  outline: 2px dashed var(--accent);
  outline: 2px dashed color-mix(in srgb, var(--accent), transparent 48%);
  outline-offset: -2px;
}

.scene-traveler {
  position: absolute;
  z-index: 2;
  right: -9px;
  bottom: -9px;
  width: 2.8rem;
  width: clamp(2.35rem, 11vw, 3.15rem);
  height: 2.8rem;
  height: clamp(2.35rem, 11vw, 3.15rem);
  pointer-events: none;
  will-change: transform;
}

.moving-symbol {
  position: relative;
  z-index: 2;
  display: block;
  font-size: 2.5rem;
  font-size: clamp(2rem, 10vw, 2.8rem);
  filter: drop-shadow(0 3px 0 rgba(58, 47, 30, 0.16));
  transform: rotate(-8deg);
  transform-origin: 46% 78%;
}

.symbol-shadow {
  position: absolute;
  right: 4px;
  bottom: 1px;
  width: 76%;
  height: 22%;
  border-radius: 50%;
  background: rgba(58, 47, 30, 0.14);
  filter: blur(2px);
}

.progress-spark {
  position: absolute;
  z-index: 3;
  top: 1px;
  left: -2px;
  color: var(--accent);
  font-size: 0.72rem;
  opacity: 0;
}

.is-running .moving-symbol {
  animation: progress-bob 1.25s cubic-bezier(.42, 0, .24, 1) infinite;
}

.is-running .marker-cell.active .marker-piece {
  animation: snack-wiggle 1.25s ease-in-out infinite;
}

.is-running .progress-spark {
  animation: progress-spark 1.25s ease-out infinite;
}

@keyframes progress-bob {
  0%,
  18%,
  100% {
    transform: translate(0, 0) rotate(-7deg);
  }
  32% {
    transform: translate(-5px, 1px) rotate(2deg) scale(1.08);
  }
  46% {
    transform: translate(-8px, 3px) rotate(6deg) scale(0.96);
  }
  62% {
    transform: translate(-3px, -2px) rotate(-5deg) scale(1.06);
  }
}

@keyframes snack-wiggle {
  0%,
  24%,
  100% {
    transform: rotate(0) scale(1);
  }
  40% {
    transform: rotate(-5deg) scale(0.97);
  }
  54% {
    transform: rotate(4deg) scale(0.95);
  }
}

@keyframes progress-spark {
  0%,
  30%,
  100% {
    opacity: 0;
    transform: translate(1px, 4px) scale(0.5) rotate(0);
  }
  42% {
    opacity: 0.9;
  }
  62% {
    opacity: 0;
    transform: translate(-7px, -7px) scale(1) rotate(35deg);
  }
}

@keyframes row-breathe {
  0%,
  100% {
    box-shadow: inset 0 0 0 0 transparent;
  }
  50% {
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent), transparent 72%);
  }
}

.rows-tiny .minute-row {
  max-height: 86px;
}

.rows-short .minute-row {
  max-height: 63px;
}

.rows-medium .progress-grid {
  gap: 4px;
}

.rows-medium .minute-row {
  max-height: 35px;
  padding: 2px 4px;
}

.rows-medium .marker-piece {
  font-size: 1.3rem;
  font-size: clamp(1.1rem, 5.6vw, 1.6rem);
}

.rows-long .progress-grid {
  gap: 2px;
  padding-top: 9px;
  padding-bottom: 9px;
  padding-block: 9px;
}

.rows-long .minute-row {
  max-height: 21px;
  padding: 1px 4px;
  border-radius: 8px;
}

.rows-long .marker-piece {
  font-size: 0.85rem;
  font-size: clamp(0.68rem, 3.5vw, 1rem);
}

.rows-dense .progress-grid {
  gap: 1px;
  padding-top: 7px;
  padding-bottom: 7px;
  padding-block: 7px;
}

.rows-dense .minute-row {
  max-height: 12px;
  padding: 0 4px;
  border-radius: 5px;
}

.rows-dense .marker-piece {
  font-size: 0.58rem;
  font-size: clamp(0.42rem, 2.2vw, 0.7rem);
}

.rows-long .scene-traveler,
.rows-dense .scene-traveler {
  right: -4px;
  bottom: -4px;
  width: 1.5rem;
  height: 1.5rem;
}

.rows-long .moving-symbol,
.rows-dense .moving-symbol {
  font-size: 1.35rem;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
  appearance: none;
  border: 0;
}

.progress-track::-webkit-progress-bar {
  border-radius: inherit;
  background: var(--soft);
}

.progress-track::-webkit-progress-value {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.progress-track::-moz-progress-bar {
  border-radius: inherit;
  background: var(--accent);
}

.timer-actions {
  display: grid;
  grid-template-columns: 58px 86px 58px;
  gap: 12px;
  align-items: center;
  justify-content: space-around;
  padding-top: 2px;
}

.small-action {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  justify-self: center;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  font-weight: 800;
}

.small-action span {
  color: var(--ink);
  font-size: 1.5rem;
}

.play-button {
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  justify-self: center;
  border: 0;
  border-radius: 27px;
  background: var(--accent);
  box-shadow: 0 6px 0 #9e4848;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--accent), black 24%);
  color: white;
  font-size: 1.7rem;
  font-weight: 900;
}

.play-button:active {
  box-shadow: 0 2px 0 #9e4848;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--accent), black 24%);
  transform: translateY(4px);
}

.finish-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-align: center;
}

.finish-symbol {
  display: grid;
  width: 142px;
  height: 142px;
  margin: 0 0 32px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 46px;
  background: var(--soft);
  box-shadow: 0 9px 0 #ded8ca;
  font-size: 5.8rem;
  animation: celebrate 900ms ease-in-out infinite alternate;
}

@keyframes celebrate {
  from {
    transform: rotate(-5deg) translateY(2px);
  }
  to {
    transform: rotate(6deg) translateY(-7px);
  }
}

.finish-actions {
  display: flex;
  gap: 20px;
  margin-top: 40px;
}

.finish-action,
.finish-action.primary-button,
.finish-action.icon-button {
  display: grid;
  width: 70px;
  height: 70px;
  min-height: 70px;
  padding: 0;
  place-items: center;
  border-radius: 24px;
  font-size: 1.55rem;
}

.finish-action.primary-button {
  align-content: center;
  justify-content: center;
}

.finish-action > span {
  display: block;
  margin: 0;
  line-height: 1;
}

.confetti span {
  position: absolute;
  color: var(--accent);
  opacity: 0.65;
  animation: float 2.2s ease-in-out infinite alternate;
}

.confetti span:nth-child(1) {
  top: 12%;
  left: 12%;
}

.confetti span:nth-child(2) {
  top: 19%;
  right: 11%;
  animation-delay: -0.8s;
}

.confetti span:nth-child(3) {
  top: 42%;
  left: 7%;
  animation-delay: -1.1s;
}

.confetti span:nth-child(4) {
  top: 52%;
  right: 8%;
  animation-delay: -0.35s;
}

.confetti span:nth-child(5) {
  bottom: 15%;
  left: 13%;
  animation-delay: -1.5s;
}

.confetti span:nth-child(6) {
  right: 15%;
  bottom: 8%;
  animation-delay: -0.55s;
}

@keyframes float {
  from {
    transform: translateY(-5px) rotate(0);
  }
  to {
    transform: translateY(8px) rotate(40deg);
  }
}

@media (min-width: 620px) {
  .app-shell {
    padding: 24px;
  }

  .screen {
    min-height: calc(100vh - 48px);
    min-height: calc(100dvh - 48px);
    border: 1px solid var(--line);
    border-radius: 36px;
    background: var(--paper);
    box-shadow: 0 18px 60px rgba(67, 58, 42, 0.12);
  }
}

@media (max-height: 740px) {
  .setup-screen {
    gap: 14px;
  }

  .progress-board {
    min-height: 340px;
  }

  .timer-screen {
    gap: 11px;
  }
}
