:root {
  color-scheme: light;
  --bg-top: #f5efe6;
  --bg-bottom: #dbe7f2;
  --bg-glow: rgba(255, 255, 255, 0.92);
  --card-bg: rgba(255, 255, 255, 0);
  --card-border: rgba(62, 81, 102, 0.12);
  --text-main: #1f2a36;
  --text-muted: #5e6b77;
  --shadow: 0 24px 60px rgba(31, 42, 54, 0.14);
  --accent: #496070;
  --accent-strong: #69879c;
  --accent-soft: rgba(73, 96, 112, 0.14);
  --toggle-bg: rgba(255, 255, 255, 0.72);
  --toggle-border: rgba(62, 81, 102, 0.16);
  --toggle-thumb: linear-gradient(135deg, #ffffff, #d6ecff);
  --toggle-text: #405060;
  --drop-color: rgba(126, 164, 201, 0.72);
  --splash-color: rgba(126, 164, 201, 0.55);
  --splash-shadow: rgba(126, 164, 201, 0.18);
  --time-glow:
    0 0 8px rgba(105, 135, 156, 0.035),
    0 0 18px rgba(105, 135, 156, 0.035);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg-top: #08101d;
  --bg-bottom: #132943;
  --bg-glow: rgba(67, 120, 214, 0.22);
  --card-bg: rgba(7, 16, 28, 0.56);
  --card-border: rgba(117, 168, 255, 0.2);
  --text-main: #e8f3ff;
  --text-muted: #9cb5d2;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.42);
  --accent: #bfd0e6;
  --accent-strong: #86a8d4;
  --accent-soft: rgba(134, 168, 212, 0.16);
  --toggle-bg: rgba(9, 20, 34, 0.8);
  --toggle-border: rgba(123, 231, 255, 0.22);
  --toggle-thumb: linear-gradient(135deg, #8cecff, #4c84ff);
  --toggle-text: #dcecff;
  --drop-color: rgba(129, 200, 255, 0.82);
  --splash-color: rgba(123, 231, 255, 0.7);
  --splash-shadow: rgba(85, 169, 255, 0.34);
  --time-glow:
    0 0 10px rgba(191, 208, 230, 0.14),
    0 0 26px rgba(134, 168, 212, 0.112),
    0 0 48px rgba(85, 169, 255, 0.084);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  font-family: "Avenir Next", "PingFang SC", "Helvetica Neue", sans-serif;
  color: var(--text-main);
  transition:
    background 240ms ease,
    color 240ms ease;
  background:
    radial-gradient(circle at top, var(--bg-glow), transparent 38%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.rain-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.rain-layer--back {
  z-index: 0;
}

.rain-layer--front {
  z-index: 2;
}

.raindrop {
  position: absolute;
  top: 0;
  left: 0;
  z-index: var(--drop-layer, 1);
  width: var(--drop-width, 22px);
  height: var(--drop-height, 56px);
  opacity: var(--drop-opacity, 0.6);
  filter: var(--drop-filter, none);
  will-change: transform, opacity, filter;
}

.raindrop-streak {
  position: absolute;
  top: 0;
  left: var(--drop-left, 9px);
  width: var(--drop-streak-width, 3px);
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0),
    var(--drop-color)
  );
  transform-origin: center top;
  transform: rotate(var(--drop-angle, 12deg));
}

.raindrop--foreground {
  --drop-layer: 2;
  --drop-width: 30px;
  --drop-left: 12px;
  --drop-streak-width: 5px;
  --drop-opacity: 0.7;
  --drop-filter: blur(1.5px);
}

.raindrop--middle {
  --drop-layer: 1;
  --drop-width: 22px;
  --drop-left: 9px;
  --drop-streak-width: 3px;
  --drop-opacity: 0.6;
}

.raindrop--background {
  --drop-layer: 0;
  --drop-width: 12px;
  --drop-left: 5px;
  --drop-streak-width: 1px;
  --drop-opacity: 0.15;
}

.splash {
  position: absolute;
  z-index: 1;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--splash-color);
  box-shadow: 0 0 10px var(--splash-shadow);
  will-change: transform, opacity;
}

.clock-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.clock-card {
  width: min(92vw, 520px);
  padding: 32px 28px;
  border: 1px solid var(--card-border);
  border-radius: 24px;
  text-align: center;
  background: var(--card-bg);
  backdrop-filter: blur(5px);
  box-shadow: var(--shadow);
  transition:
    background 240ms ease,
    border-color 240ms ease,
    box-shadow 240ms ease;
}

.clock-label {
  margin: 0 0 14px;
  font-size: 0.82rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.clock-time {
  margin: 0;
  font-size: clamp(3rem, 10vw, 5.4rem);
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: var(--time-glow);
  animation: pulse-glow 6.6s ease-in-out infinite;
}

.clock-date {
  margin: 18px 0 0;
  font-size: 1rem;
  color: var(--text-muted);
}

.control-dock {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 24px;
  background: color-mix(in srgb, var(--toggle-bg) 78%, transparent);
  box-shadow: 0 18px 44px rgba(8, 15, 28, 0.16);
  backdrop-filter: blur(22px) saturate(145%);
  transform: translateX(-50%);
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--toggle-text);
  cursor: pointer;
  transition:
    background 240ms ease,
    box-shadow 240ms ease,
    transform 180ms ease;
}

.menu-toggle:hover {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.menu-toggle:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 4px;
}

.menu-toggle-icon path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.9;
}

.mobile-controls {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.rain-control {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--toggle-text);
}

.rain-control-label {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.rain-control-value {
  min-width: 2ch;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

.rain-control-slider {
  width: 132px;
  accent-color: var(--accent-strong);
  cursor: pointer;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--toggle-text);
  cursor: pointer;
  transition:
    background 240ms ease,
    box-shadow 240ms ease,
    transform 180ms ease;
}

.theme-toggle:hover {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 4px;
}

.theme-toggle-track {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-soft), rgba(255, 255, 255, 0.1));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--toggle-thumb);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.22),
    0 0 18px rgba(255, 255, 255, 0.22);
  transition:
    transform 220ms ease,
    background 240ms ease;
}

:root[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(20px);
}

.theme-toggle-text {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.fullscreen-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--toggle-text);
  cursor: pointer;
  transition:
    background 240ms ease,
    box-shadow 240ms ease,
    transform 180ms ease;
}

.fullscreen-toggle:hover {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.fullscreen-toggle:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 4px;
}

.fullscreen-toggle-icon {
  overflow: visible;
}

.fullscreen-toggle-icon path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.fullscreen-toggle-text {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.info-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--toggle-text);
  cursor: pointer;
  transition:
    background 240ms ease,
    box-shadow 240ms ease,
    transform 180ms ease;
}

.info-toggle:hover {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.info-toggle:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 4px;
}

.info-toggle-icon {
  overflow: visible;
}

.info-toggle-icon circle:first-child,
.info-toggle-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}

.control-info {
  position: absolute;
  right: 8px;
  bottom: calc(100% + 12px);
  max-width: 240px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius:24px;
  background: color-mix(in srgb, var(--toggle-bg) 88%, transparent);
  color: var(--toggle-text);
  box-shadow: 0 14px 32px rgba(8, 15, 28, 0.18);
  backdrop-filter: blur(18px) saturate(140%);
}

.control-info-text {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
}

@keyframes pulse-glow {
  0%,
  100% {
    text-shadow: var(--time-glow);
    filter: brightness(1);
  }

  50% {
    text-shadow:
      0 0 8px color-mix(in srgb, var(--accent) 52%, transparent),
      0 0 18px color-mix(in srgb, var(--accent-strong) 48%, transparent);
    filter: brightness(1.021);
  }
}

@media (max-width: 480px) {
  .control-dock {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
    gap: 10px;
    width: min(92vw, 320px);
  }

  .clock-card {
    padding: 28px 20px;
    border-radius: 20px;
  }

  .clock-date {
    font-size: 0.95rem;
  }

  .theme-toggle {
    gap: 10px;
    padding: 9px 14px;
    justify-content: center;
  }

  .theme-toggle-text {
    font-size: 0.84rem;
  }

  .fullscreen-toggle {
    gap: 10px;
    padding: 9px 14px;
    justify-content: center;
  }

  .fullscreen-toggle-text {
    font-size: 0.84rem;
  }

  .rain-control {
    gap: 10px;
    padding: 9px 12px;
  }

  .rain-control-label {
    font-size: 0.84rem;
  }

  .rain-control-slider {
    width: 120px;
  }

  .control-info {
    right: 50%;
    bottom: calc(100% + 10px);
    width: min(78vw, 240px);
    transform: translateX(50%);
  }
}

@media (max-width: 767px) and (orientation: portrait) {
  .clock-shell {
    padding:
      calc(env(safe-area-inset-top, 0px) + 28px)
      18px
      calc(env(safe-area-inset-bottom, 0px) + 88px);
  }

  .clock-card {
    width: min(92vw, 430px);
  }

  .clock-time {
    font-size: clamp(3.2rem, 15vw, 5rem);
  }

  .control-dock {
    left: auto;
    right: calc(env(safe-area-inset-right, 0px) + 18px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 0;
    width: auto;
    padding: 8px;
    border-radius: 999px;
    transform: none;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .mobile-controls {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    left: auto;
    display: none;
    width: min(calc(100vw - 36px), 280px);
    max-width: calc(100vw - 36px);
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 18px;
    background: color-mix(in srgb, var(--toggle-bg) 90%, transparent);
    box-shadow: 0 14px 28px rgba(8, 15, 28, 0.22);
    backdrop-filter: blur(20px) saturate(140%);
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .control-dock[data-mobile-open="true"] .mobile-controls {
    display: flex;
  }

  .rain-control {
    min-width: 0;
    padding: 8px 10px;
    border-radius: 18px;
  }

  .rain-control-label {
    gap: 4px;
    font-size: 0.8rem;
  }

  .rain-control-slider {
    flex: 1;
    width: auto;
    min-width: 84px;
  }

  .theme-toggle,
  .fullscreen-toggle {
    min-width: 0;
    min-height: 42px;
    gap: 8px;
    padding: 8px 10px;
    justify-content: center;
    border-radius: 18px;
  }

  .theme-toggle-text,
  .fullscreen-toggle-text {
    font-size: 0.8rem;
  }

  .theme-toggle-track {
    width: 42px;
    height: 24px;
  }

  .theme-toggle-thumb {
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
  }

  :root[data-theme="dark"] .theme-toggle-thumb {
    transform: translateX(18px);
  }

  .info-toggle {
    align-self: flex-end;
    width: 32px;
    height: 32px;
  }

  .control-info {
    right: 0;
    bottom: calc(100% + 8px);
    width: min(calc(100vw - 52px), 210px);
    max-width: calc(100vw - 52px);
    transform: none;
  }
}

@media (max-width: 960px) and (orientation: landscape) {
  .clock-shell {
    padding:
      calc(env(safe-area-inset-top, 0px) + 18px)
      calc(env(safe-area-inset-right, 0px) + 18px)
      calc(env(safe-area-inset-bottom, 0px) + 92px)
      calc(env(safe-area-inset-left, 0px) + 18px);
  }

  .clock-card {
    width: min(58vw, 520px);
    padding: 24px 24px;
  }

  .clock-time {
    font-size: clamp(2.7rem, 11vh, 4.5rem);
  }

  .clock-date {
    margin-top: 14px;
    font-size: 0.94rem;
  }

  .control-dock {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
    gap: 8px;
    padding: 8px 10px;
  }

  .rain-control,
  .theme-toggle,
  .fullscreen-toggle {
    min-height: 40px;
  }

  .rain-control-slider {
    width: 104px;
  }

  .theme-toggle,
  .fullscreen-toggle {
    gap: 8px;
    padding: 8px 10px;
  }

  .theme-toggle-text,
  .fullscreen-toggle-text,
  .rain-control-label {
    font-size: 0.82rem;
  }
}
