:root {
  color-scheme: light;
  --ink: #12344d;
  --deep: #06335a;
  --sky: #13a8f2;
  --sea: #1fc6dc;
  --sun: #ffd447;
  --coral: #ff6f61;
  --berry: #e91e63;
  --lime: #7bd34f;
  --sand: #ffe4a3;
  --card: rgba(255, 255, 255, 0.82);
  --card-strong: rgba(255, 255, 255, 0.94);
  --shadow: 0 26px 80px rgba(7, 54, 82, 0.26);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  overflow: hidden;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #9ae3ff;
}

.stage {
  position: relative;
  display: grid;
  min-height: 100vh;
  padding: clamp(18px, 4vw, 48px);
  place-items: center;
  isolation: isolate;
}

.stage__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -3;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 239, 178, 0.18)),
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.2), transparent 35%);
}

.stage::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 36vh;
  z-index: -1;
  background: linear-gradient(0deg, rgba(255, 232, 166, 0.42), transparent);
  pointer-events: none;
}

.sunburst {
  position: absolute;
  top: -12vmin;
  left: -10vmin;
  width: 34vmin;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9), rgba(255, 212, 71, 0.38) 36%, transparent 70%);
  filter: blur(1px);
  animation: glow 5s ease-in-out infinite alternate;
  pointer-events: none;
}

.settings-toggle,
.audio-toggle,
.skip-toggle {
  position: fixed;
  top: 18px;
  z-index: 6;
  display: grid;
  width: 48px;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  color: var(--deep);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 12px 34px rgba(7, 54, 82, 0.18);
  cursor: pointer;
  font-size: 1.45rem;
  line-height: 1;
  backdrop-filter: blur(10px);
}

.settings-toggle {
  right: 18px;
}

.audio-toggle {
  right: 78px;
}

.skip-toggle {
  right: 138px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.18s ease, transform 0.18s ease, background-color 0.18s ease;
}

body.is-audio-playing .skip-toggle {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.settings-toggle:hover,
.settings-toggle:focus-visible,
.audio-toggle:hover,
.audio-toggle:focus-visible,
.skip-toggle:hover,
.skip-toggle:focus-visible {
  background: #fff;
  outline: 3px solid rgba(255, 212, 71, 0.65);
  outline-offset: 2px;
}

.icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.icon-stop,
.audio-toggle.is-playing .icon-play {
  display: none;
}

.audio-toggle.is-playing .icon-stop {
  display: block;
}

.audio-toggle.is-unavailable {
  opacity: 0.62;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.countdown-panel {
  width: min(980px, 100%);
  padding: clamp(22px, 4.5vw, 58px);
  border: 3px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  background:
    linear-gradient(135deg, var(--card-strong), var(--card)),
    linear-gradient(135deg, rgba(255, 212, 71, 0.32), rgba(31, 198, 220, 0.32));
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(12px) saturate(1.18);
  overflow: hidden;
}

.school-name {
  margin: 0 0 8px;
  color: #008c7a;
  font-size: clamp(1.05rem, 2.7vw, 1.75rem);
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 12px;
  color: #006a9d;
  font-size: clamp(1rem, 2.5vw, 1.45rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  max-width: 880px;
  margin: 0 auto;
  color: var(--deep);
  font-size: clamp(2.45rem, 7vw, 6.2rem);
  line-height: 0.95;
  letter-spacing: 0;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.timer {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 18px);
  margin: clamp(22px, 4vw, 42px) auto 0;
}

.timer div {
  display: grid;
  min-width: 0;
  min-height: clamp(92px, 15vw, 156px);
  place-items: center;
  padding: clamp(10px, 2vw, 18px);
  border: 2px solid rgba(6, 51, 90, 0.08);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 255, 255, 0.95), rgba(255, 228, 163, 0.62)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0.2));
  box-shadow: 0 14px 30px rgba(7, 54, 82, 0.12);
}

.timer strong {
  font-size: clamp(2.2rem, 8vw, 6.8rem);
  line-height: 0.82;
  font-variant-numeric: tabular-nums;
  color: var(--berry);
}

.timer span {
  display: block;
  margin-top: 8px;
  color: #25536d;
  font-size: clamp(0.86rem, 2.2vw, 1.25rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.loader {
  margin: clamp(22px, 4vw, 42px) auto 0;
}

.loader__track {
  position: relative;
  height: clamp(30px, 5vw, 44px);
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  background:
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.7) 0 14px,
      rgba(255, 255, 255, 0.42) 14px 28px
    ),
    rgba(255, 255, 255, 0.52);
  box-shadow: inset 0 3px 10px rgba(6, 51, 90, 0.16), 0 10px 26px rgba(7, 54, 82, 0.14);
}

.loader__bar {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--coral), var(--sun), var(--lime), var(--sea), #8b67ff),
    linear-gradient(90deg, rgba(255, 255, 255, 0.34), transparent);
  transition: width 0.7s ease;
}

.loader__sparkle {
  position: absolute;
  top: 50%;
  left: 0%;
  translate: -50% -50%;
  font-size: clamp(1.3rem, 3vw, 2rem);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.18));
  transition: left 0.7s ease;
}

.loader__meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 10px;
  color: #164664;
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  font-weight: 900;
}

.reminder-card {
  width: min(760px, 100%);
  margin: clamp(18px, 3vw, 30px) auto 0;
  padding: clamp(14px, 2.8vw, 22px);
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.76), rgba(255, 248, 221, 0.74)),
    linear-gradient(90deg, rgba(255, 111, 97, 0.12), rgba(31, 198, 220, 0.12));
  box-shadow: 0 14px 34px rgba(7, 54, 82, 0.1);
}

.reminder-card span {
  display: block;
  margin-bottom: 8px;
  color: #0078a8;
  font-size: clamp(0.82rem, 1.9vw, 1rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.status {
  margin: 0;
  color: #214d64;
  font-size: clamp(1.05rem, 2.6vw, 1.65rem);
  font-weight: 800;
  line-height: 1.25;
}

.summer-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(8px, 2vw, 18px);
  margin-top: clamp(20px, 3vw, 34px);
  font-size: clamp(1.8rem, 4.5vw, 3.8rem);
}

.summer-strip span {
  display: inline-block;
  transform-origin: 50% 100%;
  animation: emoji-wave 1.6s ease-in-out infinite;
}

.summer-strip span:nth-child(1) {
  animation-delay: 0s;
}

.summer-strip span:nth-child(2) {
  animation-delay: 0.12s;
}

.summer-strip span:nth-child(3) {
  animation-delay: 0.24s;
}

.summer-strip span:nth-child(4) {
  animation-delay: 0.36s;
}

.summer-strip span:nth-child(5) {
  animation-delay: 0.48s;
}

.summer-strip span:nth-child(6) {
  animation-delay: 0.6s;
}

.summer-strip span:nth-child(7) {
  animation-delay: 0.72s;
}

.summer-strip span:nth-child(8) {
  animation-delay: 0.84s;
}

.confetti {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.confetti span {
  position: absolute;
  top: -12vh;
  left: var(--x);
  display: inline-block;
  font-size: clamp(1.4rem, 4vw, 3.2rem);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.18));
  animation: rain 4.9s linear infinite;
  animation-delay: var(--delay);
}

.is-warming-up .confetti {
  opacity: 0.38;
}

.is-celebrating .countdown-panel {
  animation: party-pop 1.2s ease-in-out infinite alternate;
}

.is-celebrating .confetti {
  opacity: 1;
}

.is-celebrating .confetti span {
  animation-duration: 3.2s;
}

.is-complete h1 {
  color: #005f8b;
}

.is-complete .timer strong {
  color: #008c7a;
}

.settings-panel {
  position: fixed;
  top: 84px;
  right: 18px;
  z-index: 7;
  width: min(420px, calc(100vw - 28px));
  max-height: calc(100vh - 108px);
  overflow: auto;
  padding: 18px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  color: var(--deep);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  backdrop-filter: blur(14px);
}

.settings-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.settings-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.settings-panel h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1;
}

.settings-panel__header button {
  display: grid;
  width: 34px;
  aspect-ratio: 1;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--deep);
  background: rgba(6, 51, 90, 0.08);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
}

.settings-panel label {
  display: grid;
  gap: 7px;
  margin-top: 13px;
  font-size: 0.88rem;
  font-weight: 900;
  text-transform: uppercase;
}

.settings-panel input,
.settings-panel textarea {
  width: 100%;
  border: 2px solid rgba(6, 51, 90, 0.14);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--deep);
  background: #fff;
  font: 700 1rem/1.35 "Segoe UI", Arial, sans-serif;
  text-transform: none;
}

.settings-panel textarea {
  resize: vertical;
  min-height: 116px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.track-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 12px;
  margin: 16px 0 0;
  padding: 12px;
  border: 2px solid rgba(6, 51, 90, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
}

.track-selector legend {
  padding: 0 6px;
  color: var(--deep);
  font-size: 0.88rem;
  font-weight: 900;
  text-transform: uppercase;
}

.track-selector label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #164664;
  font-size: 0.95rem;
  text-transform: none;
}

.track-selector input {
  width: 18px;
  height: 18px;
  accent-color: #008c7a;
}

.settings-hint {
  margin: 12px 0 0;
  color: #456a7f;
  font-size: 0.9rem;
  font-weight: 700;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.settings-actions button {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--deep);
  background: rgba(6, 51, 90, 0.1);
  cursor: pointer;
  font-weight: 900;
}

.settings-actions button[type="submit"] {
  color: #fff;
  background: #008c7a;
}

@keyframes emoji-wave {
  0%,
  70%,
  100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
  18% {
    transform: translateY(-18px) rotate(-6deg) scale(1.08);
  }
  34% {
    transform: translateY(2px) rotate(4deg) scale(1);
  }
}

@keyframes rain {
  0% {
    transform: translate3d(-16px, -8vh, 0) rotate(0deg);
  }
  100% {
    transform: translate3d(20px, 118vh, 0) rotate(360deg);
  }
}

@keyframes glow {
  from {
    opacity: 0.78;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1.05);
  }
}

@keyframes party-pop {
  from {
    transform: rotate(-0.25deg) scale(1);
  }
  to {
    transform: rotate(0.25deg) scale(1.012);
  }
}

@media (max-width: 620px) {
  body {
    overflow: auto;
  }

  .stage {
    min-height: 100svh;
    align-items: end;
    padding: 14px;
  }

  .stage__bg {
    object-position: center;
  }

  .countdown-panel {
    width: calc(100vw - 28px);
    max-width: 100%;
    padding: 20px 14px;
  }

  .settings-toggle {
    top: 12px;
    right: 12px;
    width: 42px;
    font-size: 1.25rem;
  }

  .audio-toggle {
    top: 12px;
    right: 62px;
    width: 42px;
  }

  .skip-toggle {
    top: 12px;
    right: 112px;
    width: 42px;
  }

  .school-name {
    font-size: 1rem;
  }

  h1 {
    font-size: clamp(1.85rem, 8vw, 2.25rem);
    line-height: 1;
  }

  .timer {
    gap: 7px;
  }

  .timer div {
    min-height: 86px;
    padding: 8px 5px;
  }

  .timer strong {
    font-size: clamp(1.8rem, 8vw, 2.35rem);
  }

  .timer span {
    font-size: 0.66rem;
  }

  .status {
    font-size: 1rem;
  }

  .reminder-card {
    padding: 12px;
  }

  .summer-strip {
    gap: 8px;
    font-size: 1.55rem;
  }

  .loader__meta {
    align-items: center;
    font-size: 0.95rem;
  }

  .settings-panel {
    top: 62px;
    right: 14px;
    left: 14px;
    width: auto;
    max-height: calc(100svh - 76px);
  }

  .settings-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .track-selector {
    grid-template-columns: 1fr;
  }
}

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

  .confetti {
    display: none;
  }
}
