/* Kid Visual Timer Display — Hardened for Fire HD / Amazon Silk Browser */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.6s ease, color 0.4s ease;
}

.hidden {
  display: none !important;
}

/* Rendered visibly (not display:none) so Amazon Silk honors video screen wake lock */
.keepawake-video {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  opacity: 0.01;
  pointer-events: none;
  z-index: 1;
}

.awake-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #0f172a;
  white-space: nowrap;
}

body.theme-rocket .awake-pill,
body.theme-ring .awake-pill,
body.theme-ocean .awake-pill {
  background: rgba(15, 23, 42, 0.45);
  color: #fde047;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

/* --- Theme Palettes --- */
body.theme-pie {
  background: linear-gradient(180deg, #fffdf5 0%, #fef3c7 100%);
  color: #1e293b;
}

body.theme-rocket {
  background: linear-gradient(160deg, #070b1e 0%, #172554 55%, #1e1b4b 100%);
  color: #f8fafc;
}

body.theme-rainbow {
  background: linear-gradient(180deg, #7dd3fc 0%, #bae6fd 48%, #fef9c3 100%);
  color: #1e293b;
}

body.theme-ocean {
  background: linear-gradient(180deg, #0284c7 0%, #0369a1 45%, #0c4a6e 100%);
  color: #f0f9ff;
}

body.theme-ring {
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
  color: #f8fafc;
}

body.theme-dino {
  background: linear-gradient(180deg, #dcfce7 0%, #fef9c3 65%, #bbf7d0 100%);
  color: #14532d;
}

body.theme-train {
  background: linear-gradient(180deg, #7dd3fc 0%, #e0f2fe 52%, #dcfce7 100%);
  color: #0f172a;
}

body.theme-construction {
  background: linear-gradient(180deg, #fef3c7 0%, #fed7aa 70%, #fde68a 100%);
  color: #451a03;
}

body.theme-bedtime {
  background: linear-gradient(180deg, #040712 0%, #0b0e1f 100%);
  color: #f59e0b;
}

/* Star reward pill */
.star-pill {
  font-size: 0.82rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(254, 240, 138, 0.9);
  color: #854d0e;
  white-space: nowrap;
}

body.theme-bedtime .star-pill,
body.theme-bedtime .awake-pill,
body.theme-bedtime .activity-pill,
body.theme-bedtime .icon-btn {
  background: rgba(30, 27, 46, 0.72);
  color: #d97706;
  border: 1px solid rgba(217, 119, 6, 0.25);
}

/* Multi-step visual routine tracker (prominent under top banner so kids can prep for what's next!) */
.routine-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 18px 8px;
  z-index: 18;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.routine-name-badge {
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

.routine-steps-track {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.routine-arrow {
  font-size: 0.85rem;
  font-weight: 900;
  opacity: 0.45;
}

.routine-step-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.72);
  color: #334155;
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  opacity: 0.78;
}

body.theme-rocket .routine-step-pill,
body.theme-ring .routine-step-pill,
body.theme-ocean .routine-step-pill,
body.theme-bedtime .routine-step-pill {
  background: rgba(15, 23, 42, 0.65);
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.16);
}

.routine-step-pill.done {
  background: rgba(34, 197, 94, 0.22);
  border-color: rgba(34, 197, 94, 0.45);
  color: #15803d;
  opacity: 0.92;
}

body.theme-rocket .routine-step-pill.done,
body.theme-ring .routine-step-pill.done,
body.theme-ocean .routine-step-pill.done {
  color: #86efac;
}

.routine-step-pill.active {
  background: #2563eb;
  border-color: #60a5fa;
  color: #ffffff;
  opacity: 1;
  transform: scale(1.04);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.32);
}

.routine-step-pill.next-up {
  background: #fef9c3;
  border-color: #eab308;
  color: #854d0e;
  opacity: 1;
}

body.theme-rocket .routine-step-pill.next-up,
body.theme-ring .routine-step-pill.next-up,
body.theme-ocean .routine-step-pill.next-up {
  background: rgba(250, 204, 21, 0.2);
  border-color: rgba(250, 204, 21, 0.6);
  color: #fef08a;
}

body.theme-bedtime .routine-step-pill.active {
  background: #92400e;
  border-color: #d97706;
  color: #fef3c7;
  box-shadow: none;
}

body.theme-bedtime .routine-step-pill.next-up {
  background: rgba(146, 64, 14, 0.28);
  border-color: rgba(217, 119, 6, 0.45);
  color: #fbbf24;
}

.step-tag {
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.16);
}

.routine-step-pill.next-up .step-tag {
  background: rgba(202, 138, 4, 0.22);
}

.wake-pin-row {
  font-size: 0.92rem;
  color: #334155;
  margin-bottom: 4px;
}

.wake-pin-row strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.08rem;
  letter-spacing: 0.12em;
  color: #2563eb;
}

/* --- Layout --- */
body {
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 8px;
  z-index: 20;
  flex-shrink: 0;
}

.top-left, .top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.top-right {
  justify-content: flex-end;
}

.conn-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.conn-dot.connected {
  background: #22c55e;
}

.conn-dot.connecting {
  background: #f59e0b;
}

.conn-dot.offline {
  background: #ef4444;
}

.activity-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: #0f172a;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.14);
  max-width: 65vw;
}

body.theme-rocket .activity-pill,
body.theme-ring .activity-pill,
body.theme-ocean .activity-pill {
  background: rgba(15, 23, 42, 0.55);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.activity-emoji {
  font-size: 1.7rem;
  line-height: 1;
}

.activity-label {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-badge {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.2);
}

body.status-running .status-badge {
  background: #22c55e;
  color: #ffffff;
}

body.status-paused .status-badge {
  background: #f59e0b;
  color: #ffffff;
}

body.status-finished .status-badge {
  background: #ef4444;
  color: #ffffff;
}

.icon-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.72);
  color: #0f172a;
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

body.theme-rocket .icon-btn,
body.theme-ring .icon-btn,
body.theme-ocean .icon-btn {
  background: rgba(15, 23, 42, 0.45);
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.2);
}

.lock-btn {
  overflow: visible;
}

.hold-ring {
  position: absolute;
  top: -3px;
  left: -3px;
  width: 48px;
  height: 48px;
  transform: rotate(-90deg);
  pointer-events: none;
}

.hold-ring-bg {
  fill: none;
  stroke: transparent;
  stroke-width: 4;
}

.hold-ring-fill {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 119.38;
  stroke-dashoffset: 119.38;
}

.lock-icon {
  position: relative;
  z-index: 2;
}

/* --- Main Stage --- */
.stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 20px 18px;
  min-height: 0;
}

.scene {
  display: none;
  width: 100%;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

body.theme-pie .scene-pie,
body.theme-rocket .scene-rocket,
body.theme-rainbow .scene-rainbow,
body.theme-ocean .scene-ocean,
body.theme-ring .scene-ring,
body.theme-dino .scene-dino,
body.theme-train .scene-train,
body.theme-construction .scene-construction,
body.theme-bedtime .scene-bedtime {
  display: flex;
}

.dino-svg, .train-svg, .construction-svg {
  width: min(92vw, 860px);
  max-height: 56vh;
  height: auto;
}

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

.bedtime-time {
  color: #d97706;
  margin-top: 26px;
}

.bedtime-helper {
  color: #b45309;
}

body.theme-bedtime .time-readout {
  display: none;
}

@keyframes eggWobbleSlow {
  0%, 100% { transform: translate(340px, 200px) rotate(0deg); }
  25% { transform: translate(340px, 200px) rotate(-3.5deg); }
  75% { transform: translate(340px, 200px) rotate(3.5deg); }
}

@keyframes eggWobbleMed {
  0%, 100% { transform: translate(340px, 200px) rotate(0deg); }
  25% { transform: translate(340px, 200px) rotate(-6deg); }
  75% { transform: translate(340px, 200px) rotate(6deg); }
}

@keyframes eggWobbleFast {
  0%, 100% { transform: translate(340px, 200px) rotate(0deg); }
  25% { transform: translate(340px, 200px) rotate(-9deg); }
  75% { transform: translate(340px, 200px) rotate(9deg); }
}

@keyframes dinoHop {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.egg-wobble-slow { animation: eggWobbleSlow 1.35s ease-in-out infinite; }
.egg-wobble-med { animation: eggWobbleMed 0.72s ease-in-out infinite; }
.egg-wobble-fast { animation: eggWobbleFast 0.36s ease-in-out infinite; }

.dino-hop {
  animation: dinoHop 0.75s ease-in-out infinite;
}

@keyframes volcanoSmoke {
  0% {
    transform: translate(0px, 0px) scale(0.6);
    opacity: 0;
  }
  14% {
    opacity: 0.72;
  }
  65% {
    opacity: 0.42;
  }
  100% {
    transform: translate(14px, -68px) scale(1.7);
    opacity: 0;
  }
}

.v-puff {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

.v-puff.vp1 { animation: volcanoSmoke 5.4s ease-out infinite; }
.v-puff.vp2 { animation: volcanoSmoke 5.4s ease-out 1.8s infinite; }
.v-puff.vp3 { animation: volcanoSmoke 5.4s ease-out 3.6s infinite; }

@keyframes fernSway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(5deg); }
}

.dino-fern.f1 {
  transform-origin: 64px 298px;
  animation: fernSway 3.4s ease-in-out infinite;
}

.dino-fern.f2 {
  transform-origin: 90px 295px;
  animation: fernSway 4.0s ease-in-out 0.6s infinite;
}

.dino-fern.f3 {
  transform-origin: 118px 298px;
  animation: fernSway 3.7s ease-in-out 1.3s infinite;
}

@keyframes steamDrift {
  0% {
    transform: translate(0px, 0px) scale(0.65);
    opacity: 0;
  }
  15% {
    opacity: 0.88;
  }
  65% {
    opacity: 0.6;
  }
  100% {
    transform: translate(-38px, -34px) scale(1.65);
    opacity: 0;
  }
}

.train-steam {
  opacity: 0;
  transition: opacity 0.3s ease;
}

body.status-running .train-steam {
  opacity: 1;
}

.steam-puff {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}

body.status-running .steam-puff.p1 {
  animation: steamDrift 1.6s ease-out infinite;
}

body.status-running .steam-puff.p2 {
  animation: steamDrift 1.6s ease-out 0.53s infinite;
}

body.status-running .steam-puff.p3 {
  animation: steamDrift 1.6s ease-out 1.06s infinite;
}

.tower-block {
  opacity: 0.14;
  transition: opacity 0.35s ease;
}

.tower-block.placed {
  opacity: 1;
}

/* Pie Theme */
.pie-wrapper {
  width: min(56vh, 78vw, 420px);
  height: min(56vh, 78vw, 420px);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* Rocket, Rainbow, Ocean SVGs */
.rocket-svg, .rainbow-svg, .ocean-svg {
  width: min(92vw, 860px);
  max-height: 58vh;
  height: auto;
}

/* Subtle GPU-friendly animations */
@keyframes twinkle {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.star.s1 { animation: twinkle 2.4s ease-in-out infinite; }
.star.s2 { animation: twinkle 3.1s ease-in-out 0.6s infinite; }
.star.s3 { animation: twinkle 2.8s ease-in-out 1.2s infinite; }

@keyframes flicker {
  0%, 100% { transform: scaleX(1); opacity: 0.95; }
  50% { transform: scaleX(1.22); opacity: 1; }
}

.rocket-flame {
  opacity: 0;
  transition: opacity 0.3s ease;
  transform-origin: -34px 0;
}

body.status-running .rocket-flame {
  opacity: 1;
  animation: flicker 0.22s ease-in-out infinite;
}

@keyframes floatCloudLeft {
  0%, 100% { transform: translate(125px, 295px) translateY(0px); }
  50% { transform: translate(125px, 295px) translateY(-7px); }
}

@keyframes floatCloudRight {
  0%, 100% { transform: translate(555px, 295px) translateY(0px); }
  50% { transform: translate(555px, 295px) translateY(-7px); }
}

@keyframes sunBob {
  0%, 100% { transform: translate(565px, 86px) translateY(0px); }
  50% { transform: translate(565px, 86px) translateY(-9px); }
}

@keyframes sunRaysSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.rainbow-sun {
  animation: sunBob 3.2s ease-in-out infinite;
}

.sun-rays {
  transform-origin: 0px 0px;
  animation: sunRaysSpin 28s linear infinite;
}

.cloud-left {
  animation: floatCloudLeft 4.4s ease-in-out infinite;
}

.cloud-right {
  animation: floatCloudRight 4.8s ease-in-out 1.2s infinite;
}

@keyframes bubbleRise {
  0% { transform: translateY(16px); opacity: 0.15; }
  50% { opacity: 0.8; }
  100% { transform: translateY(-28px); opacity: 0; }
}

.bubble.b1 { animation: bubbleRise 4.2s ease-in-out infinite; }
.bubble.b2 { animation: bubbleRise 5.0s ease-in-out 1.1s infinite; }
.bubble.b3 { animation: bubbleRise 3.8s ease-in-out 2.0s infinite; }

/* Ring Theme */
.ring-wrapper {
  position: relative;
  width: min(70vh, 84vw, 480px);
  height: min(70vh, 84vw, 480px);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.ring-time {
  font-size: clamp(3.2rem, 11vw, 6.2rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

.ring-helper {
  margin-top: 10px;
  font-size: clamp(1rem, 2.6vw, 1.5rem);
  font-weight: 600;
  opacity: 0.8;
}

/* Shared Digital Readout */
.time-readout {
  text-align: center;
  flex-shrink: 0;
  padding: 4px 16px 8px;
}

body.theme-ring .time-readout {
  display: none;
}

body.hide-digital .digital-time,
body.hide-digital .ring-time {
  display: none;
}

.digital-time {
  font-size: clamp(3rem, 9.5vw, 5.4rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.helper-text {
  margin-top: 4px;
  font-size: clamp(1.1rem, 2.8vw, 1.6rem);
  font-weight: 700;
  opacity: 0.85;
}

/* Final 10 seconds gentle pulse */
@keyframes urgentPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

body.urgent .digital-time,
body.urgent .ring-time {
  color: #ef4444;
  animation: urgentPulse 1s ease-in-out infinite;
}

/* --- Wake / Enable Sound Overlay --- */
.wake-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(11, 16, 38, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.wake-card {
  background: #ffffff;
  color: #0f172a;
  border-radius: 28px;
  padding: 28px 28px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  max-height: 94vh;
  overflow-y: auto;
}

.wake-icon {
  font-size: 3.2rem;
  line-height: 1;
  margin-bottom: 8px;
}

.wake-title {
  margin: 0 0 6px;
  font-size: 1.75rem;
  font-weight: 900;
}

.wake-subtitle {
  margin: 0 0 16px;
  font-size: 0.98rem;
  line-height: 1.4;
  color: #475569;
}

.wake-pair-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 18px;
  padding: 12px 16px;
  margin-bottom: 18px;
  text-align: left;
}

.wake-qr {
  width: 104px;
  height: 104px;
  flex-shrink: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wake-qr svg {
  width: 100%;
  height: 100%;
}

.wake-pair-info {
  flex: 1;
  min-width: 0;
}

.wake-pair-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
}

.wake-room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #0f172a;
  margin: 2px 0 4px;
}

.wake-pair-status {
  font-size: 0.84rem;
  color: #475569;
}

.wake-pair-status.paired {
  color: #16a34a;
  font-weight: 700;
}

.pair-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wake-btn {
  width: 100%;
  padding: 18px 24px;
  border: none;
  border-radius: 18px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #ffffff;
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.35);
}

.wake-btn:active {
  transform: scale(0.98);
}

.wake-link {
  margin-top: 14px;
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px;
  text-decoration: underline;
}

/* --- Intercom Announcement Toast --- */
.announce-banner {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: #fef08a;
  color: #1e293b;
  border: 3px solid #eab308;
  border-radius: 20px;
  padding: 14px 26px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  max-width: 88vw;
}

.announce-icon {
  font-size: 1.8rem;
}

.announce-text {
  font-size: 1.45rem;
  font-weight: 800;
}

/* --- Time's Up Celebration --- */
.finish-banner {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

@keyframes popIn {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.finish-card {
  position: relative;
  z-index: 2;
  background: #ffffff;
  color: #0f172a;
  border-radius: 32px;
  padding: 36px 44px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  animation: popIn 0.45s ease-out;
  max-width: 90vw;
}

.finish-emoji {
  font-size: 4.5rem;
  line-height: 1.1;
}

.finish-title {
  margin: 8px 0 6px;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 900;
  color: #16a34a;
}

.finish-sub {
  margin: 0 0 18px;
  font-size: 1.35rem;
  font-weight: 700;
  color: #475569;
}

.finish-btn {
  padding: 14px 28px;
  border: none;
  border-radius: 16px;
  background: #3b82f6;
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
}

.finish-next-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 36px;
  border: none;
  border-radius: 22px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #ffffff;
  font-size: clamp(1.25rem, 3.6vw, 1.7rem);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 14px 32px rgba(34, 197, 94, 0.38);
  margin-bottom: 10px;
}

.finish-next-btn:active {
  transform: scale(0.96);
}

.confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

@keyframes confettiFall {
  0% { transform: translateY(-40px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: 0.7; }
}

.confetti {
  position: absolute;
  top: -20px;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  animation: confettiFall 3.2s linear infinite;
}

.confetti.c1 { left: 10%; background: #ef4444; animation-delay: 0s; }
.confetti.c2 { left: 22%; background: #facc15; animation-delay: 0.4s; }
.confetti.c3 { left: 35%; background: #22c55e; animation-delay: 0.9s; }
.confetti.c4 { left: 48%; background: #38bdf8; animation-delay: 0.2s; }
.confetti.c5 { left: 60%; background: #a855f7; animation-delay: 1.3s; }
.confetti.c6 { left: 73%; background: #f97316; animation-delay: 0.6s; }
.confetti.c7 { left: 84%; background: #ec4899; animation-delay: 1.1s; }
.confetti.c8 { left: 92%; background: #14b8a6; animation-delay: 0.3s; }

/* --- On-Tablet Parent Controls Drawer --- */
.parent-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.96);
  color: #f8fafc;
  border-top: 2px solid rgba(148, 163, 184, 0.3);
  border-radius: 22px 22px 0 0;
  padding: 16px 20px 20px;
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.4);
  max-height: 55vh;
  overflow-y: auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.drawer-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #cbd5e1;
}

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

.drawer-link {
  color: #7dd3fc;
  font-weight: 700;
  text-decoration: none;
  font-size: 0.92rem;
}

.drawer-close-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  background: #334155;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.drawer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.drawer-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: #94a3b8;
  margin-right: 4px;
}

.ctrl-btn, .theme-chip, .preset-chip {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: #1e293b;
  color: #f8fafc;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.ctrl-btn.primary {
  background: #22c55e;
  border-color: #16a34a;
  color: #ffffff;
  min-width: 105px;
}

.ctrl-btn.primary.is-running {
  background: #f59e0b;
  border-color: #d97706;
}

.theme-chip.active {
  background: #38bdf8;
  color: #0f172a;
  border-color: #7dd3fc;
}

.preset-chip {
  background: #0f172a;
  font-size: 0.88rem;
}

body.theme-bedtime .time-readout,
body.theme-firstthen .time-readout,
body.theme-whilewait .time-readout {
  display: none;
}

body.theme-whilewait {
  background: linear-gradient(155deg, #ecfdf5 0%, #f0f9ff 55%, #f5f3ff 100%);
  color: #0f172a;
}

body.theme-whilewait #scene-whilewait {
  display: flex;
}

.ww-board {
  width: min(94vw, 940px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2vh, 18px);
  padding: 6px;
}

.ww-top {
  width: 100%;
  background: #ffffff;
  border-radius: 28px;
  border: 4px solid #a7f3d0;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
  padding: clamp(12px, 2.2vh, 22px) clamp(16px, 3vw, 30px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3.5vw, 34px);
}

.ww-ring-wrap {
  position: relative;
  width: clamp(108px, 20vh, 154px);
  height: clamp(108px, 20vh, 154px);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ww-ring-svg { width: 100%; height: 100%; }

.ww-ring-emoji {
  position: absolute;
  font-size: clamp(2.6rem, 6vh, 3.8rem);
  line-height: 1;
}

.ww-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.ww-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  background: #059669;
  color: #ffffff;
  font-size: clamp(0.76rem, 1.8vw, 0.94rem);
  font-weight: 900;
  letter-spacing: 0.08em;
}

.ww-title {
  margin-top: 6px;
  font-size: clamp(1.25rem, 3.2vw, 1.95rem);
  font-weight: 900;
  color: #0f172a;
  line-height: 1.15;
}

.ww-time {
  margin-top: 4px;
  font-size: clamp(2.1rem, 5.4vw, 3.3rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #065f46;
}

body.hide-digital .ww-time { display: none; }
body.urgent .ww-time { color: #ef4444; animation: urgentPulse 1s ease-in-out infinite; }

.ww-helper {
  margin-top: 4px;
  font-size: clamp(0.86rem, 1.9vw, 1.08rem);
  font-weight: 700;
  color: #64748b;
}

.ww-prompt {
  font-size: clamp(0.95rem, 2.2vw, 1.2rem);
  font-weight: 800;
  color: #334155;
}

.ww-choices {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: clamp(10px, 2vw, 18px);
}

.ww-choice-card {
  appearance: none;
  background: #ffffff;
  border: 3.5px solid #cbd5e1;
  border-radius: 24px;
  padding: clamp(14px, 2.4vh, 22px) 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  color: #0f172a;
  font-family: inherit;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.07);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.ww-choice-card:active {
  transform: scale(0.97);
}

.ww-choice-card.picked {
  border-color: #10b981;
  background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
  box-shadow: 0 14px 32px rgba(16, 185, 129, 0.24);
  transform: translateY(-2px);
}

.ww-choice-emoji {
  font-size: clamp(2.4rem, 5.8vh, 3.6rem);
  line-height: 1;
}

.ww-choice-label {
  font-size: clamp(1rem, 2.4vw, 1.3rem);
  font-weight: 900;
  text-align: center;
  line-height: 1.2;
}

.ww-choice-tag {
  font-size: 0.78rem;
  font-weight: 800;
  color: #047857;
  background: #ffffff;
  padding: 3px 10px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.ww-choice-card.picked .ww-choice-tag {
  opacity: 1;
}

@media (max-width: 560px) {
  .ww-top {
    flex-direction: column;
    text-align: center;
  }
  .ww-meta {
    align-items: center;
  }
}

body.theme-firstthen {
  background: linear-gradient(155deg, #eff6ff 0%, #f8fafc 50%, #fefce8 100%);
  color: #0f172a;
}

body.theme-firstthen #scene-firstthen {
  display: flex;
}

.ft-board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vw, 32px);
  width: min(94vw, 960px);
  padding: 8px;
}

.ft-panel {
  flex: 1;
  background: #ffffff;
  border-radius: 32px;
  padding: clamp(18px, 3vh, 30px) clamp(16px, 2.5vw, 28px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.1);
  border: 4px solid #dbeafe;
  min-width: 0;
}

.ft-then-panel {
  border-color: #fde68a;
  background: linear-gradient(180deg, #ffffff 0%, #fefce8 100%);
}

.ft-then-panel.ft-ready {
  border-color: #22c55e;
  box-shadow: 0 20px 48px rgba(34, 197, 94, 0.25);
}

.ft-badge {
  display: inline-block;
  padding: 6px 18px;
  border-radius: 999px;
  font-size: clamp(0.9rem, 2.2vw, 1.15rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.ft-badge-first {
  background: #2563eb;
  color: #ffffff;
}

.ft-badge-then {
  background: #f59e0b;
  color: #ffffff;
}

.ft-dial-wrap {
  position: relative;
  width: clamp(128px, 24vh, 184px);
  height: clamp(128px, 24vh, 184px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ft-dial-svg {
  width: 100%;
  height: 100%;
}

.ft-dial-emoji {
  position: absolute;
  font-size: clamp(3rem, 7vh, 4.4rem);
  line-height: 1;
}

.ft-then-circle {
  width: clamp(128px, 24vh, 184px);
  height: clamp(128px, 24vh, 184px);
  border-radius: 50%;
  background: linear-gradient(135deg, #fef9c3, #fde68a);
  border: 5px solid #facc15;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ft-then-emoji {
  font-size: clamp(3.4rem, 8vh, 5rem);
  line-height: 1;
}

.ft-panel-title {
  margin-top: 12px;
  font-size: clamp(1.35rem, 3.4vw, 2.15rem);
  font-weight: 900;
  color: #0f172a;
  line-height: 1.15;
}

.ft-time {
  margin-top: 6px;
  font-size: clamp(2.2rem, 5.8vw, 3.6rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #1e293b;
}

body.hide-digital .ft-time {
  display: none;
}

body.urgent .ft-time {
  color: #ef4444;
  animation: urgentPulse 1s ease-in-out infinite;
}

.ft-helper {
  margin-top: 4px;
  font-size: clamp(0.9rem, 2vw, 1.15rem);
  font-weight: 700;
  color: #64748b;
}

.ft-then-sub {
  margin-top: 10px;
  padding: 6px 16px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: clamp(0.9rem, 2vw, 1.15rem);
  font-weight: 800;
}

.ft-then-panel.ft-ready .ft-then-sub {
  background: #22c55e;
  color: #ffffff;
}

.ft-arrow {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 900;
  color: #3b82f6;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .ft-board {
    flex-direction: column;
    gap: 10px;
  }
  .ft-panel {
    width: 100%;
    padding: 14px 16px;
  }
  .ft-arrow {
    transform: rotate(90deg);
    font-size: 1.8rem;
    line-height: 1;
  }
}

/* Landscape compact adjustments for Fire HD 8/10 */
/* --- Star Goals, Wrap-Up Buffer & Sensory-Quiet Visual Cues --- */
.quiet-pill,
.soundscape-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: inherit;
}

.soundscape-pill {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.45);
}

.star-pill.goal-reached {
  background: linear-gradient(135deg, #fde047, #f59e0b) !important;
  color: #451a03 !important;
  border-color: #fef08a !important;
  box-shadow: 0 0 18px rgba(250, 204, 21, 0.65);
}

.wrapup-banner {
  margin: 4px auto 2px;
  padding: 8px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #ffffff;
  font-size: clamp(0.9rem, 2.2vw, 1.15rem);
  font-weight: 900;
  text-align: center;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4);
  z-index: 15;
  animation: wrapUpPulse 2.4s ease-in-out infinite;
}

@keyframes wrapUpPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

body.wrap-up-mode {
  box-shadow: inset 0 0 0 8px rgba(245, 158, 11, 0.65);
}

@keyframes sensoryGlow {
  0%, 100% { box-shadow: inset 0 0 0 0px rgba(56, 189, 248, 0); }
  50% { box-shadow: inset 0 0 0 18px rgba(56, 189, 248, 0.65); }
}

body.sensory-pulse {
  animation: sensoryGlow 1.2s ease-in-out 2;
}

.finish-star-goal {
  margin: 0 auto 18px;
  padding: 12px 18px;
  border-radius: 18px;
  background: #fefce8;
  border: 2px solid #fde047;
  max-width: 440px;
}

.finish-stars-row {
  font-size: 1.85rem;
  letter-spacing: 0.08em;
  line-height: 1.25;
}

.finish-goal-text {
  margin-top: 6px;
  font-size: 1.05rem;
  font-weight: 800;
  color: #854d0e;
}

.finish-goal-text.reached {
  color: #15803d;
  font-size: 1.2rem;
}

@media (max-height: 540px) {
  .top-bar {
    padding: 8px 16px 4px;
  }
  .activity-pill {
    padding: 5px 14px;
  }
  .activity-label {
    font-size: 1.15rem;
  }
  .digital-time {
    font-size: clamp(2.4rem, 7.5vw, 3.8rem);
  }
  .helper-text {
    font-size: 1rem;
  }
}
