/* 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;
}

/* --- 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 {
  display: flex;
}

/* 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 floatCloud {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.rainbow-sun {
  transition: transform 0.6s ease;
}

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

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

/* Landscape compact adjustments for Fire HD 8/10 */
@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;
  }
}
