:root {
  color-scheme: dark;
  --page: #edf1f4;
  --clock-face: #25262d;
  --clock-face-deep: #18191f;
  --rim: #f8f9fb;
  --rim-shadow: #c7ccd4;
  --tick: rgba(255, 255, 255, 0.78);
  --tick-strong: rgba(255, 255, 255, 0.96);
  --text: #f8f9fb;
  --muted: #69707d;
  --accent: #25e667;
  --success: #22e86a;
  --warning: #e43737;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  display: grid;
  place-items: center;
  min-height: 100vh;
  background:
    radial-gradient(circle at 52% 42%, rgba(255, 255, 255, 0.7), transparent 0.5px) 0 0 / 5px 5px,
    linear-gradient(135deg, #f9fafb 0%, var(--page) 58%, #dfe5eb 100%);
  font-family: "Segoe UI", Arial, sans-serif;
  color: #15171d;
}

.shell {
  width: min(100%, 760px);
  padding: 20px;
}

.auth-screen {
  width: min(100%, 420px);
  padding: 20px;
}

.auth-form {
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid #cfd6df;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 45px rgba(30, 34, 40, 0.18);
}

.auth-form h1 {
  margin: 0 0 4px;
  color: #15171d;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: #394150;
  font-size: 14px;
  font-weight: 600;
}

.auth-form input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #b8c1cc;
  border-radius: 8px;
  background: #ffffff;
  color: #15171d;
  font: 16px/1.2 "Segoe UI", Arial, sans-serif;
}

.auth-form input:focus {
  border-color: #17763a;
  outline: 3px solid rgba(37, 230, 103, 0.18);
}

.auth-form button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: #15171d;
  color: #ffffff;
  font: 700 15px/1 "Segoe UI", Arial, sans-serif;
  cursor: pointer;
}

.auth-form button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.auth-message[data-mode="warning"] {
  color: var(--warning);
}

.clock-panel {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.server-label {
  text-align: center;
}

.server-label p {
  margin: 0;
  line-height: 1.35;
}

.status {
  color: var(--muted);
  font-size: 14px;
}

.status[data-mode="ok"] {
  color: #17763a;
}

.status[data-mode="warning"] {
  color: var(--warning);
}

.clock {
  position: relative;
  width: min(88vw, 560px);
  aspect-ratio: 1;
  border: 8px solid var(--rim);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.04) 0 7%, transparent 7.5%),
    radial-gradient(circle at 50% 50%, var(--clock-face) 0 72%, var(--clock-face-deep) 100%);
  box-shadow:
    0 0 0 2px var(--rim-shadow),
    0 18px 45px rgba(30, 34, 40, 0.25),
    inset 0 0 36px rgba(0, 0, 0, 0.35);
}

.tick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 18px;
  background: var(--tick);
  border-radius: 2px;
  transform-origin: 50% 50%;
}

.tick.major {
  width: 4px;
  height: 34px;
  background: var(--tick-strong);
}

.tick.half {
  width: 4px;
  height: 32px;
  background: rgba(255, 255, 255, 0.88);
}

.number {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 56px;
  height: 36px;
  color: var(--text);
  font-size: clamp(15px, 3.3vw, 26px);
  font-weight: 700;
  line-height: 1;
  text-align: center;
  transform: translate(-50%, -50%);
}

.hand {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 999px;
  transform: translate(-50%, -100%) rotate(0deg);
  transform-origin: 50% 100%;
  transition: background-color 140ms ease, box-shadow 140ms ease;
}

.millisecond-hand {
  width: 3px;
  height: 45%;
  background: #d7dbe1;
  box-shadow: 0 0 7px rgba(255, 255, 255, 0.22);
}

.millisecond-hand::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -12%;
  width: 3px;
  height: 15%;
  border-radius: 999px;
  background: inherit;
  transform: translateX(-50%);
}

.pin {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: var(--clock-face);
  transform: translate(-50%, -50%);
  z-index: 4;
}

.center-readout {
  position: absolute;
  left: 50%;
  top: 58%;
  display: grid;
  justify-items: center;
  min-width: 180px;
  transform: translate(-50%, -50%);
  z-index: 5;
}

.digital-time {
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
  font-size: clamp(24px, 5.5vw, 38px);
  font-weight: 700;
  letter-spacing: 0;
  text-align: center;
  transition: color 140ms ease, text-shadow 140ms ease;
}

.milliseconds {
  color: var(--accent);
  font-family: Consolas, "Courier New", monospace;
  font-size: clamp(15px, 3vw, 22px);
  font-weight: 700;
  line-height: 1.2;
  transition: color 140ms ease, text-shadow 140ms ease;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, auto));
  justify-content: center;
  justify-items: center;
  align-items: center;
  gap: 8px;
}

.delay-toggle,
.capture-button,
.logout-button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid #b8c1cc;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2430;
  font: 600 14px/1 "Segoe UI", Arial, sans-serif;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(30, 34, 40, 0.12);
}

.delay-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: #e9fff0;
  color: #0f6d32;
}

.logout-button {
  color: #5b2430;
}

.capture-result {
  grid-column: 1 / -1;
  margin: 0;
  min-height: 24px;
  color: #1f2430;
  font-family: Consolas, "Courier New", monospace;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.jqclock[hidden] {
  display: none;
}

.clock.is-final-second .millisecond-hand {
  background: var(--warning);
  box-shadow: 0 0 16px rgba(228, 55, 55, 0.76);
}

.clock.is-final-second .digital-time,
.clock.is-final-second .milliseconds {
  color: var(--warning);
  text-shadow: 0 0 15px rgba(228, 55, 55, 0.8);
}

.clock.is-second-59 {
  border-color: var(--success);
  box-shadow:
    0 0 0 2px rgba(34, 232, 106, 0.55),
    0 0 34px rgba(34, 232, 106, 0.42),
    0 18px 45px rgba(30, 34, 40, 0.25),
    inset 0 0 36px rgba(34, 232, 106, 0.14);
}

.clock.is-second-59 .millisecond-hand {
  background: var(--success);
  box-shadow: 0 0 18px rgba(34, 232, 106, 0.82);
}

.clock.is-second-59 .pin {
  border-color: var(--success);
  box-shadow: 0 0 14px rgba(34, 232, 106, 0.7);
}

.clock.is-second-59 .digital-time,
.clock.is-second-59 .milliseconds {
  color: var(--success);
  text-shadow: 0 0 16px rgba(34, 232, 106, 0.82);
}

.sync-details {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

@media (max-width: 520px) {
  .shell {
    padding: 14px;
  }

  .clock {
    border-width: 6px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .tick {
    height: 12px;
  }

  .tick.major {
    height: 24px;
  }

  .tick.half {
    height: 24px;
  }

  .number {
    width: 44px;
    height: 28px;
  }
}
