:root {
  color-scheme: light;
  --ink: #102234;
  --muted: #496579;
  --panel: rgba(248, 252, 255, 0.93);
  --blue: #176ee8;
  --blue-deep: #0b479e;
  --gold: #ffca3a;
  --mint: #51d6ac;
  --leaf: #0a816d;
  --rose: #ff7d96;
  --shadow: 0 18px 48px rgba(12, 31, 56, 0.22);
  --header-space: 104px;
  --task-space: 174px;
  --scene-center-y: calc(var(--header-space) + (100vh - var(--header-space) - var(--task-space)) * 0.5);
  --scene-action-y: calc(var(--scene-center-y) + 112px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body.terms-open {
  overflow: hidden;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #d7f2ff;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  min-height: 48px;
  padding: 0 22px;
  font-weight: 850;
  color: var(--ink);
  background: #eef8ff;
  box-shadow: inset 0 0 0 2px rgba(16, 34, 52, 0.09);
  cursor: pointer;
}

button:focus-visible,
[contenteditable="true"]:focus-visible,
input:focus-visible {
  outline: 4px solid rgba(255, 202, 58, 0.82);
  outline-offset: 3px;
}

.timer-shell {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

.hero {
  position: fixed;
  inset: var(--header-space) 0 var(--task-space) 0;
  z-index: 0;
  background: #172441;
}

.hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  opacity: 0;
  transition: opacity 0.55s ease;
}

.hero-image[data-scene="toys"],
.hero-image[data-scene="potty"] {
  object-position: center center;
}

.hero-image.active {
  opacity: 1;
}

.sky-tint {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0 12%, rgba(255, 255, 255, 0.02) 28%, rgba(255, 255, 255, 0.01) 74%, rgba(255, 255, 255, 0.72) 100%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.01) 38%);
}

.goodnight {
  position: fixed;
  left: clamp(18px, 7vw, 118px);
  top: clamp(210px, 31vh, 310px);
  z-index: 3;
  display: none;
  color: #fff;
  font-size: clamp(2.6rem, 8vw, 7rem);
  font-weight: 1000;
  line-height: 0.9;
  letter-spacing: 0;
  white-space: nowrap;
  text-shadow:
    0 5px 0 var(--blue),
    0 10px 0 var(--blue-deep),
    0 16px 30px rgba(4, 15, 34, 0.42);
}

.goodnight span {
  display: block;
}

.goodnight.show {
  display: block;
  animation: goodnightPop 0.75s ease both;
}

.sticker-chart {
  position: fixed;
  left: 5vw;
  top: 57vh;
  z-index: 3;
  width: 44vw;
  max-width: 760px;
  text-align: center;
  pointer-events: none;
}

.star-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.gold-sticker-star {
  display: inline-grid;
  place-items: center;
  width: clamp(34px, 4vw, 56px);
  height: clamp(34px, 4vw, 56px);
  border-radius: 50%;
  color: var(--gold);
  background: rgba(255, 255, 255, 0.94);
  border: 3px solid rgba(255, 255, 255, 0.98);
  box-shadow:
    0 4px 0 var(--blue),
    0 8px 18px rgba(4, 15, 34, 0.28);
  font-size: clamp(1.8rem, 3.4vw, 3.1rem);
  line-height: 1;
  text-shadow: 0 2px 0 rgba(130, 92, 0, 0.2);
}

.star-total {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(248, 252, 255, 0.92);
  box-shadow: 0 8px 20px rgba(12, 31, 56, 0.16);
  font-size: clamp(0.95rem, 1.8vw, 1.25rem);
  font-weight: 950;
  text-shadow: none;
}

.scene-message {
  position: fixed;
  left: 5vw;
  top: var(--scene-center-y);
  transform: translateY(-50%);
  z-index: 3;
  width: 44vw;
  max-width: 760px;
  color: #fff;
  font-size: clamp(1.55rem, 3.8vw, 3.85rem);
  font-weight: 1000;
  line-height: 1.04;
  letter-spacing: 0;
  white-space: pre-line;
  text-align: center;
  text-shadow:
    0 4px 0 var(--blue),
    0 8px 0 var(--blue-deep),
    0 14px 28px rgba(4, 15, 34, 0.45);
}

.scene-message[contenteditable="true"] {
  cursor: text;
}

body:not(.parent-mode) .scene-message,
body:not(.parent-mode) .child-name,
body:not(.parent-mode) h1[contenteditable="true"] {
  caret-color: transparent;
}

.scene-message.prayer-message {
  width: 44vw;
  max-width: 760px;
}

.reward-mode .scene-message {
  animation: rewardPop 0.55s ease both;
}

.reward-mode .hero-image.active {
  animation: rewardImagePulse 1.1s ease both;
}

.app-header {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(230px, 0.85fr) minmax(200px, 0.7fr) minmax(300px, 0.85fr);
  gap: 12px;
  align-items: center;
  min-height: 84px;
  padding: 4px clamp(8px, 1.8vw, 18px);
  background: rgba(248, 252, 255, 0.86);
  box-shadow: 0 8px 26px rgba(12, 31, 56, 0.12);
  backdrop-filter: blur(14px);
}

.title-block {
  min-width: 0;
}

.child-name,
.eyebrow,
.status {
  margin: 0;
}

.child-name {
  width: fit-content;
  max-width: 100%;
  border-radius: 8px;
  padding: 2px 4px;
  color: var(--leaf);
  font-size: clamp(0.9rem, 1.55vw, 1.25rem);
  font-weight: 950;
  line-height: 1;
}

h1 {
  margin: 2px 0 0;
  font-size: clamp(1.85rem, 3.6vw, 3.25rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.primary {
  width: 100%;
  min-height: 58px;
  color: #fff;
  background: linear-gradient(135deg, #1f7cff, #0f4aae);
  box-shadow: 0 12px 28px rgba(23, 110, 232, 0.3);
  font-size: clamp(1.05rem, 2vw, 1.55rem);
  font-weight: 950;
}

.timer-block {
  display: grid;
  gap: 2px;
}

.eyebrow {
  display: none;
  color: var(--blue-deep);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.countdown {
  display: flex;
  justify-content: center;
  align-items: baseline;
  border-radius: 8px;
  padding: 4px 10px;
  color: #fff;
  background: linear-gradient(135deg, #101d38, #12457e 52%, #0a816d);
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.4rem, 4.8vw, 3.75rem);
  font-weight: 1000;
  line-height: 0.95;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.14);
}

.progress-track {
  position: relative;
  height: 28px;
  padding: 6px 9px;
  border-radius: 999px;
  background: #d7ecf8;
  box-shadow: inset 0 0 0 2px rgba(16, 34, 52, 0.08);
}

.progress-fill {
  width: 0%;
  height: 16px;
  border-radius: inherit;
  background: #63d471;
  transition: width 0.3s linear;
}

.runner {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 36px;
  height: 36px;
  transform: translate(-14px, -50%);
  border: 6px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 5px 14px rgba(16, 34, 52, 0.24), 0 0 0 1px rgba(16, 34, 52, 0.06);
  transition: left 0.3s linear;
}

.runner::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 7px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
}

.progress-wrap {
  grid-column: 2 / 4;
  margin-top: -6px;
  z-index: 5;
}

.scene-thumb {
  display: none;
  border: 3px solid #052c43;
  border-radius: 8px;
  background-color: #172441;
  background-image: url("assets/bedtime-dash.jpg");
  background-position: center;
  background-size: cover;
  box-shadow: 0 10px 22px rgba(12, 31, 56, 0.2);
}

.task-strip {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  gap: clamp(8px, 1.8vw, 20px);
  align-items: end;
  justify-content: space-around;
  min-height: var(--task-space);
  padding: 12px 64px 14px 14px;
  background: rgba(248, 252, 255, 0.78);
  box-shadow: 0 -10px 30px rgba(12, 31, 56, 0.12);
  overflow-x: auto;
  backdrop-filter: blur(12px);
}

.task-item {
  position: relative;
  flex: 0 0 116px;
  display: grid;
  grid-template-rows: 66px 96px;
  justify-items: center;
  align-items: center;
  padding: 6px 5px 8px;
  border: 3px solid #052c43;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(21, 92, 165, 0.96) 0 56px, rgba(255, 255, 255, 0.98) 56px);
  box-shadow: 0 10px 20px rgba(4, 15, 34, 0.14);
}

.task-item[draggable="true"] {
  cursor: grab;
  touch-action: none;
}

.parent-mode .task-item {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.parent-mode .task-strip {
  scroll-snap-type: none;
}

.task-item.dragging {
  opacity: 0.45;
}

.task-item.drag-over {
  outline: 4px dashed rgba(23, 110, 232, 0.65);
  outline-offset: 6px;
  transform: translateY(-5px);
}

.task-item.is-next-task .step-orb {
  box-shadow:
    0 12px 26px rgba(5, 18, 36, 0.22),
    0 0 0 7px rgba(255, 202, 58, 0.48);
}

.step-card {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-rows: 42px 56px;
  justify-items: center;
  align-items: center;
  gap: 5px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #fff;
  background: transparent;
  box-shadow: none;
  text-shadow: 0 2px 8px rgba(4, 15, 34, 0.55);
}

.step-card[aria-pressed="true"] {
  box-shadow: none;
}

.step-orb {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 6px solid rgba(255, 255, 255, 0.96);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 12px 26px rgba(5, 18, 36, 0.22);
  transition: transform 0.2s ease;
}

.step-card:hover .step-orb,
.step-card:focus-visible .step-orb {
  transform: translateY(-4px) scale(1.04);
}

.step-card[aria-pressed="true"] .step-orb {
  background: var(--blue);
}

.step-card[aria-pressed="true"] .step-orb::after {
  content: "★";
  color: var(--gold);
  font-size: 2.9rem;
  line-height: 1;
  text-shadow:
    0 0 0 #fff,
    0 3px 10px rgba(4, 15, 34, 0.3);
}

.step-label {
  order: -1;
  width: 102px;
  min-height: 40px;
  height: 40px;
  margin-bottom: 1px;
  padding: 4px 6px;
  border: 3px solid #052c43;
  border-radius: 6px;
  overflow-wrap: normal;
  word-break: normal;
  color: #071d2d;
  font-size: 0.7rem;
  font-weight: 950;
  line-height: 1.05;
  text-align: center;
  background: var(--gold);
  text-shadow: none;
  transform: none;
  display: grid;
  place-items: center;
  overflow: hidden;
  white-space: normal;
}

.step-label[contenteditable="true"] {
  cursor: text;
}

.task-guide {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  min-height: 64px;
  height: 64px;
  padding: 5px;
  border: 4px solid #052c43;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  box-shadow:
    inset 0 0 0 6px var(--blue),
    inset 0 0 0 10px #dce8ee,
    0 8px 16px rgba(4, 15, 34, 0.2);
  transform: none;
  z-index: 6;
}

.task-item.is-next-task .task-guide {
  box-shadow:
    inset 0 0 0 7px var(--blue),
    inset 0 0 0 10px #dce8ee,
    0 8px 16px rgba(4, 15, 34, 0.2),
    0 0 0 6px rgba(255, 202, 58, 0.46);
}

.parent-mode .task-guide {
  opacity: 0.55;
}

.task-guide img {
  display: block;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  background: #fff;
}

.drag-handle {
  position: absolute;
  top: -12px;
  left: -10px;
  z-index: 8;
  display: none;
  place-items: center;
  width: 48px;
  min-height: 34px;
  height: 34px;
  padding: 0;
  border: 3px solid #052c43;
  border-radius: 999px;
  color: #071d2d;
  background: var(--gold);
  box-shadow: 0 5px 0 var(--blue);
  font-size: 1.25rem;
  line-height: 1;
  touch-action: none;
  cursor: grab;
}

.parent-mode .drag-handle {
  display: grid;
}

.drag-handle:active {
  cursor: grabbing;
}

.delete-task {
  position: absolute;
  top: -10px;
  right: -10px;
  display: none;
  width: 28px;
  min-height: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--rose);
  box-shadow: 0 6px 14px rgba(16, 34, 52, 0.24);
}

.custom-reward-editor {
  position: absolute;
  left: 50%;
  bottom: 196px;
  display: none;
  width: 188px;
  min-height: 68px;
  transform: translateX(-50%);
  resize: vertical;
  border: 3px solid #052c43;
  border-radius: 8px;
  padding: 8px;
  color: var(--ink);
  background: rgba(248, 252, 255, 0.98);
  box-shadow: 0 10px 24px rgba(12, 31, 56, 0.18);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.15;
}

.custom-reward-editor:focus {
  z-index: 7;
}

.parent-mode .delete-task {
  display: grid;
  place-items: center;
}

.parent-mode .custom-reward-editor {
  display: block;
}

.status {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 108px;
  z-index: 4;
  transform: translateX(-50%);
  min-width: min(520px, calc(100vw - 32px));
  padding: 8px 18px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(248, 252, 255, 0.86);
  box-shadow: 0 10px 24px rgba(12, 31, 56, 0.14);
  font-size: 1.04rem;
  font-weight: 850;
  text-align: center;
  backdrop-filter: blur(8px);
}

.parent-controls {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 6;
}

.parent-toggle {
  display: grid;
  place-items: center;
  width: 42px;
  min-height: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(13, 32, 63, 0.5);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 8px 22px rgba(5, 18, 36, 0.22);
  backdrop-filter: blur(8px);
}

.parent-menu {
  position: absolute;
  right: 0;
  bottom: 52px;
  display: grid;
  gap: 9px;
  width: 220px;
  padding: 34px 12px 12px;
  border-radius: 8px;
  background: rgba(248, 252, 255, 0.96);
  box-shadow: var(--shadow);
}

.parent-close {
  position: absolute;
  right: 8px;
  top: 8px;
  display: grid;
  place-items: center;
  width: 24px;
  min-height: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--blue-deep);
  font-size: 1rem;
  line-height: 1;
}

.parent-menu .parent-close {
  width: 24px;
  min-height: 24px;
  height: 24px;
}

.parent-menu label {
  color: var(--blue-deep);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.parent-menu input {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #eef8ff;
  box-shadow: inset 0 0 0 2px rgba(16, 34, 52, 0.09);
  font-weight: 900;
}

.parent-menu button {
  width: 100%;
  min-height: 42px;
}

.settings-brand {
  display: grid;
  place-items: center;
  margin-top: 3px;
  padding-top: 10px;
  border-top: 1px solid rgba(16, 34, 52, 0.12);
}

.settings-brand img {
  display: block;
  width: min(148px, 88%);
  height: auto;
}

.terms-gate,
.demo-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 18, 36, 0.68);
  backdrop-filter: blur(8px);
}

.terms-card,
.demo-card {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 22px;
  border: 4px solid #052c43;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(248, 252, 255, 0.98);
  box-shadow: var(--shadow);
}

.terms-card h2,
.demo-card h2 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 6vw, 3rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.terms-card p,
.terms-card h3,
.demo-card p {
  margin: 0 0 10px;
}

.terms-preview {
  margin: 14px 0;
}

.terms-preview summary {
  min-height: 44px;
  padding: 10px 12px;
  border: 3px solid #052c43;
  border-radius: 8px;
  color: #071d2d;
  background: var(--gold);
  font-weight: 950;
  cursor: pointer;
}

.terms-scroll {
  max-height: 260px;
  overflow: auto;
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #eef8ff;
}

.terms-scroll h3 {
  color: var(--blue-deep);
  font-size: 1rem;
  line-height: 1.1;
}

.terms-scroll p {
  color: #263f55;
  font-size: 0.95rem;
  line-height: 1.42;
}

.accept-terms {
  width: 100%;
  min-height: 52px;
  color: #fff;
  background: linear-gradient(135deg, #2485ff, #0e54bd);
  box-shadow: 0 10px 24px rgba(14, 84, 189, 0.28);
}

.demo-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.demo-primary,
.demo-secondary,
.demo-ok {
  display: grid;
  place-items: center;
  min-height: 46px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 950;
  text-align: center;
  text-decoration: none;
}

.demo-primary {
  color: #fff;
  background: linear-gradient(135deg, #1f7cff, #0f4aae);
}

.demo-secondary {
  color: var(--ink);
  background: #eef8ff;
  box-shadow: inset 0 0 0 2px rgba(16, 34, 52, 0.09);
}

.demo-ok {
  width: 100%;
  margin-top: 12px;
}

.terms-link,
.menu-link {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  color: #071d2d;
  background: #eef8ff;
  box-shadow: inset 0 0 0 2px rgba(16, 34, 52, 0.09);
  font-weight: 850;
  text-align: center;
  text-decoration: none;
}

.menu-link[aria-disabled="true"] {
  opacity: 0.72;
}

.terms-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 202, 58, 0.28), transparent 22%),
    linear-gradient(180deg, #eef8ff, #d7f2ff);
}

.terms-shell {
  width: min(920px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 34px 0 56px;
  color: var(--ink);
}

.terms-shell h1 {
  margin: 16px 0 8px;
  font-size: clamp(2.35rem, 8vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.terms-shell h2 {
  margin: 26px 0 8px;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  line-height: 1.05;
}

.terms-shell p {
  margin: 0 0 14px;
  color: #263f55;
  font-size: 1.02rem;
  line-height: 1.55;
}

.terms-updated {
  font-weight: 850;
}

.back-link {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  padding: 0 16px;
  border: 3px solid #052c43;
  border-radius: 8px;
  color: #071d2d;
  background: var(--gold);
  font-weight: 950;
  text-decoration: none;
  box-shadow: 0 5px 0 var(--blue);
}

.demo-video,
.demo-placeholder {
  display: block;
  width: 100%;
  max-height: 72vh;
  border: 4px solid #052c43;
  border-radius: 8px;
  background: #102234;
  box-shadow: var(--shadow);
}

.demo-placeholder {
  padding: 22px;
  color: #fff;
  line-height: 1.45;
}

@keyframes bedtimeGlow {
  50% {
    box-shadow: 0 0 0 8px rgba(255, 202, 58, 0.32), var(--shadow);
  }
}

@keyframes goodnightPop {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.88);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes rewardPop {
  0% {
    opacity: 0;
    transform: translateY(-42%) scale(0.9);
  }

  60% {
    opacity: 1;
    transform: translateY(-50%) scale(1.04);
  }

  100% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
}

@keyframes rewardImagePulse {
  0% {
    filter: saturate(1);
    transform: scale(1);
  }

  45% {
    filter: saturate(1.2) brightness(1.06);
    transform: scale(1.012);
  }

  100% {
    filter: saturate(1);
    transform: scale(1);
  }
}

@keyframes voiceWave {
  50% {
    transform: scaleY(0.52);
    opacity: 0.66;
  }
}

@media (min-width: 901px) and (max-width: 1180px) {
  :root {
    --header-space: 96px;
    --task-space: 166px;
  }

  .app-header {
    grid-template-columns: minmax(210px, 0.75fr) minmax(180px, 0.72fr) minmax(260px, 0.82fr);
    gap: 10px;
    min-height: 78px;
  }

  h1 {
    font-size: clamp(2rem, 4.2vw, 2.85rem);
  }

  .child-name {
    font-size: clamp(0.9rem, 1.8vw, 1.1rem);
  }

  .primary {
    min-height: 52px;
  }

  .countdown {
    font-size: clamp(2.4rem, 5.8vw, 3.35rem);
  }

  .task-strip {
    gap: 12px;
    justify-content: flex-start;
    padding: 10px 64px 10px 12px;
  }

  .task-item {
    flex-basis: 112px;
  }

  .scene-message {
    width: 45vw;
    font-size: clamp(2rem, 4.2vw, 3.3rem);
  }
}

@media (max-width: 900px) {
  :root {
    --header-space: 188px;
    --task-space: 164px;
    --scene-center-y: calc(var(--header-space) + (100dvh - var(--header-space) - var(--task-space)) * 0.48);
    --scene-action-y: calc(var(--scene-center-y) + 104px);
  }

  .app-header {
    grid-template-columns: minmax(0, 1fr) minmax(116px, 0.8fr);
    gap: 7px;
    min-height: 0;
  }

  .title-block {
    grid-row: 1 / 3;
  }

  .primary {
    min-height: 46px;
  }

  .progress-wrap {
    grid-column: 1 / 3;
    margin-top: 0;
  }

  .countdown {
    font-size: clamp(2rem, 10vw, 3.1rem);
  }

  .task-strip {
    justify-content: start;
    min-height: var(--task-space);
    padding-left: 14px;
  }

  .step-card {
    grid-template-rows: 42px 50px;
    min-height: 0;
    gap: 4px;
  }

  .task-item {
    flex-basis: 106px;
    grid-template-rows: 56px 94px;
    padding: 5px 4px 7px;
    border-radius: 18px;
    background:
      linear-gradient(180deg, rgba(21, 92, 165, 0.96) 0 46px, rgba(255, 255, 255, 0.98) 46px);
  }

  .task-guide {
    width: 54px;
    min-height: 54px;
    height: 54px;
    padding: 3px;
    box-shadow:
      inset 0 0 0 6px var(--blue),
      inset 0 0 0 10px #dce8ee,
      0 8px 16px rgba(4, 15, 34, 0.2);
  }

  .task-guide img {
    width: 36px;
    height: 36px;
  }

  .task-item:not(:last-child)::after {
    display: none;
  }

  .step-orb {
    width: 50px;
    height: 50px;
    border-width: 6px;
  }

  .step-card[aria-pressed="true"] .step-orb::after {
    font-size: 2.45rem;
  }

  .step-label {
    width: 94px;
    min-height: 40px;
    height: 40px;
    font-size: 0.62rem;
    line-height: 1;
  }

  .status {
    bottom: 150px;
  }

  .goodnight {
    top: 44%;
    left: 16px;
    font-size: clamp(2.2rem, 13vw, 4rem);
  }

  .scene-message {
    top: var(--scene-center-y);
    left: 16px;
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
    transform: translateY(-50%);
    font-size: clamp(1.55rem, 9vw, 3.4rem);
  }

  .scene-message.prayer-message {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
  }

  .sticker-chart {
    top: 54%;
    left: 16px;
    bottom: auto;
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
  }
}

@media (min-width: 641px) and (max-width: 1180px) {
  .sticker-chart {
    top: auto;
    bottom: calc(var(--task-space) + 18px + env(safe-area-inset-bottom, 0px));
    left: clamp(22px, 6vw, 78px);
    width: min(46vw, 560px);
    max-width: min(46vw, 560px);
  }

  .goodnight {
    top: calc(var(--header-space) + 7vh);
    left: clamp(22px, 6vw, 78px);
    font-size: clamp(3.2rem, 8.5vw, 5.8rem);
  }

  .star-row {
    justify-content: flex-start;
    gap: 7px;
  }

  .gold-sticker-star {
    width: clamp(34px, 4.5vw, 48px);
    height: clamp(34px, 4.5vw, 48px);
    font-size: clamp(1.9rem, 3.6vw, 2.7rem);
  }
}

@media (min-width: 641px) and (max-width: 1180px) and (orientation: portrait) {
  .sticker-chart {
    left: 22px;
    width: min(58vw, 520px);
    max-width: min(58vw, 520px);
    bottom: calc(var(--task-space) + 12px + env(safe-area-inset-bottom, 0px));
  }

  .gold-sticker-star {
    width: clamp(30px, 5.4vw, 42px);
    height: clamp(30px, 5.4vw, 42px);
    font-size: clamp(1.7rem, 4.4vw, 2.3rem);
  }
}

@media (max-width: 640px) {
  :root {
    --header-space: 176px;
    --task-space: 146px;
    --scene-center-y: calc(var(--header-space) + (100dvh - var(--header-space) - var(--task-space)) * 0.46);
  }

  .timer-shell {
    min-height: 100dvh;
  }

  .hero {
    inset: var(--header-space) 0 calc(var(--task-space) + env(safe-area-inset-bottom, 0px)) 0;
  }

  .hero-image {
    object-position: 58% center;
  }

  .hero-image[data-scene="toys"] {
    object-position: 58% center;
  }

  .hero-image[data-scene="potty"] {
    object-position: 58% center;
  }

  .app-header {
    grid-template-columns: minmax(0, 1fr) minmax(88px, 108px);
    grid-template-rows: auto auto auto 24px;
    align-items: start;
    gap: 6px 8px;
    min-height: var(--header-space);
    padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 7px;
  }

  .title-block {
    grid-column: 1;
    grid-row: 1;
  }

  .child-name {
    font-size: clamp(0.82rem, 4vw, 1rem);
  }

  h1 {
    font-size: clamp(2.05rem, 12vw, 2.8rem);
    line-height: 0.9;
  }

  .scene-thumb {
    display: block;
    grid-column: 2;
    grid-row: 1 / 3;
    width: 100%;
    aspect-ratio: 1.1;
    align-self: start;
  }

  .timer-block {
    grid-column: 1;
    grid-row: 2;
    width: min(152px, 100%);
  }

  .countdown {
    min-height: 34px;
    padding: 2px 8px;
    font-size: clamp(1.45rem, 8vw, 2rem);
    line-height: 1;
  }

  .primary {
    grid-column: 1 / 3;
    grid-row: 3;
    min-height: 40px;
    font-size: clamp(1rem, 5vw, 1.35rem);
  }

  .progress-wrap {
    grid-column: 1 / 3;
    grid-row: 4;
    margin-top: 0;
    align-self: center;
  }

  .progress-track {
    height: 22px;
    padding: 5px 7px;
  }

  .progress-fill {
    height: 12px;
  }

  .runner {
    width: 30px;
    height: 30px;
    border-width: 5px;
  }

  .runner::before {
    left: 6px;
    top: 6px;
    width: 8px;
    height: 8px;
  }

  .task-strip {
    min-height: var(--task-space);
    gap: 9px;
    align-items: stretch;
    padding: 8px 54px calc(8px + env(safe-area-inset-bottom, 0px)) 10px;
  }

  .task-item {
    flex: 0 0 92px;
    grid-template-rows: 42px 86px;
    padding: 4px 4px 6px;
    border-width: 3px;
    border-radius: 16px;
    background:
      linear-gradient(180deg, rgba(21, 92, 165, 0.96) 0 39px, rgba(255, 255, 255, 0.98) 39px);
  }

  .task-guide {
    width: 42px;
    min-height: 42px;
    height: 42px;
    padding: 2px;
    border-width: 3px;
    box-shadow:
      inset 0 0 0 4px var(--blue),
      inset 0 0 0 7px #dce8ee,
      0 6px 12px rgba(4, 15, 34, 0.18);
  }

  .task-guide img {
    width: 28px;
    height: 28px;
  }

  .step-card {
    grid-template-rows: 40px 42px;
    gap: 4px;
  }

  .step-label {
    width: 82px;
    min-height: 38px;
    height: 38px;
    padding: 3px 4px;
    font-size: 0.54rem;
    line-height: 1;
    border-width: 3px;
  }

  .step-orb {
    width: 42px;
    height: 42px;
    border-width: 5px;
  }

  .step-card[aria-pressed="true"] .step-orb::after {
    font-size: 2rem;
  }

  .scene-message {
    left: 12px;
    top: var(--scene-center-y);
    width: min(64vw, 300px);
    max-width: min(64vw, 300px);
    font-size: clamp(1.45rem, 8.5vw, 2.6rem);
    text-align: center;
  }

  .scene-message.prayer-message {
    width: min(64vw, 300px);
    max-width: min(64vw, 300px);
  }

  .goodnight {
    top: calc(var(--header-space) + 9vh);
    left: 14px;
    font-size: clamp(2.1rem, 11vw, 3.35rem);
    white-space: normal;
  }

  .sticker-chart {
    top: auto;
    left: 14px;
    bottom: calc(var(--task-space) + 16px + env(safe-area-inset-bottom, 0px));
    width: min(62vw, 270px);
    max-width: min(62vw, 270px);
    text-align: left;
  }

  .star-row {
    justify-content: flex-start;
    gap: 5px;
    margin-bottom: 5px;
  }

  .gold-sticker-star {
    width: 30px;
    height: 30px;
    border-width: 2px;
    box-shadow:
      0 3px 0 var(--blue),
      0 7px 14px rgba(4, 15, 34, 0.22);
    font-size: 1.65rem;
  }

  .star-total {
    padding: 4px 10px;
    font-size: 0.86rem;
  }
}

@media (display-mode: standalone) {
  body {
    user-select: none;
    -webkit-user-select: none;
  }
}

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