html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #000000;
  overflow: hidden;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#clock-stage {
  position: relative;
  width: 100%;
  height: 100%;
}
#hud-header,
#brand-block {
  display: contents;
}
#top-left {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
}
#clock-switcher {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(16px, 4.5vw, 24px);
  line-height: 1;
  white-space: nowrap;
  pointer-events: auto;
  user-select: none;
}
#clock-switcher a,
#clock-switcher span {
  padding: 10px 20px;
  border-radius: 999px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.65);
  transition: color 0.15s ease, background 0.15s ease;
}
#clock-switcher a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}
#clock-switcher .active {
  color: #000000;
  background: #ffffff;
  font-weight: 600;
}
#clock-switcher .clock-dropdown {
  position: relative;
}
#clock-switcher .clock-dropdown summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
#clock-switcher .clock-dropdown summary::-webkit-details-marker {
  display: none;
}
#clock-switcher .clock-dropdown summary::after {
  content: "▾";
  font-size: 0.75em;
  transition: transform 0.15s ease;
}
#clock-switcher .clock-dropdown[open] summary::after {
  transform: rotate(180deg);
}
#clock-switcher .clock-dropdown summary:hover,
#clock-switcher .clock-dropdown[open] summary {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}
#clock-switcher .clock-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 16px;
  background: rgba(18, 18, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  z-index: 30;
}
#clock-switcher .clock-dropdown-menu a {
  display: block;
  padding: 10px 16px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.8);
}
#clock-switcher .clock-dropdown-menu a:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}
#header {
  color: #ffffff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(32px, 4.2vw, 72px);
  font-weight: 600;
  letter-spacing: -0.5px;
  line-height: 1.05;
  margin: 0;
  user-select: none;
}
#header .version {
  font-size: 0.5em;
}
#shoutout {
  color: #ffffff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(14px, 1.8vw, 30px);
  font-weight: 400;
  opacity: 0.55;
  margin: 0;
  user-select: none;
}
#seo-blurb {
  max-width: clamp(260px, 26vw, 480px);
  color: rgba(255, 255, 255, 0.45);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(10px, 0.9vw, 14px);
  font-weight: 400;
  line-height: 1.5;
  margin: 2px 0 0;
  user-select: none;
}
#lively-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 2px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(10px, 0.9vw, 14px);
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.45);
  pointer-events: auto;
}
#lively-links a,
#lively-links button,
#about-faq summary {
  color: rgba(255, 255, 255, 0.72);
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
#lively-links a:hover,
#lively-links button:hover,
#about-faq summary:hover {
  color: #ffffff;
}
#about-faq {
  max-width: clamp(260px, 26vw, 480px);
}
#about-faq .faq-body {
  margin-top: 6px;
  padding: 10px 12px;
  max-height: 42vh;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(8px);
}
#about-faq h3 {
  margin: 8px 0 2px;
  font-size: 1em;
  font-weight: 600;
  color: #ffffff;
}
#about-faq h3:first-child {
  margin-top: 0;
}
#about-faq p {
  margin: 0 0 6px;
}
#about-faq p:last-child {
  margin-bottom: 0;
}
#controls {
  position: absolute;
  top: 64px;
  right: 12px;
  z-index: 20;
  display: none;
  flex-direction: column;
  gap: 15px;
  padding: 18px 21px;
  min-width: 315px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  box-sizing: border-box;
  color: #ffffff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 20px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 11px;
  pointer-events: auto;
  backdrop-filter: blur(4px);
}
#controls.expanded {
  display: flex;
}
.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.control-group-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.55;
}
#controls label {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.3;
}
#controls input[type="checkbox"] {
  width: 21px;
  height: 21px;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}
#controls input[type="datetime-local"] {
  font: inherit;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  padding: 9px 12px;
  width: 100%;
  box-sizing: border-box;
  outline: none;
}
#controls input[type="datetime-local"]:focus {
  border-color: rgba(56, 185, 240, 0.75);
}
#controls input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}
#controls label.select-label {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
#controls select {
  font: inherit;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  padding: 8px 12px;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  cursor: pointer;
}
#controls select:focus {
  border-color: rgba(56, 185, 240, 0.75);
}
#controls select option {
  background: #1a1a1a;
  color: #ffffff;
}
.digital-time-row {
  display: flex;
  align-items: center;
  gap: 15px;
}
.digital-time-options {
  display: flex;
  align-items: center;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.digital-time-options.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}
.countdown-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-left: 31px;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.countdown-options.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}
#copy-countdown-url {
  font: inherit;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  padding: 8px 12px;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  cursor: pointer;
  text-align: center;
}
#copy-countdown-url:hover {
  background: rgba(255, 255, 255, 0.16);
}
#copy-countdown-url:focus-visible {
  border-color: rgba(56, 185, 240, 0.75);
}
#controls-toggle {
  display: block;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  padding: 10px 15px;
  color: #ffffff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 27px;
  line-height: 1;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 9px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  user-select: none;
}
#kofi-container {
  position: relative;
  min-height: 34px;
}
#kofi-container .floatingchat-container-wrap {
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  width: 100% !important;
  max-width: none !important;
  height: auto !important;
  z-index: auto !important;
  transform: scale(0.75);
  transform-origin: left top;
}
#kofi-container .floatingchat-container {
  position: relative !important;
  width: 100% !important;
  height: 45px !important;
}
#kofi-container .floatingchat-container-wrap-mobi {
  display: none !important;
}
.floating-chat-kofi-popup-iframe {
  position: fixed !important;
  top: 12px !important;
  right: 12px !important;
  bottom: auto !important;
  left: auto !important;
  max-width: calc(100vw - 24px) !important;
  max-height: calc(100vh - 24px) !important;
  transform: none !important;
  z-index: 10001 !important;
  overflow: hidden !important;
  /* Ko-Fi's embed has no dark mode (their dark mode is viewer-side only).
     Fake it from our side: invert the white panel, hue-rotate so brand
     colors stay roughly right. Cross-origin CSS can't reach inside, so a
     filter on the whole popup is the only lever. */
  filter: invert(0.93) hue-rotate(180deg);
}
@media (min-width: 1600px) {
  #header {
    font-size: clamp(40px, 4.2vw, 110px);
  }
  #shoutout {
    font-size: clamp(16px, 1.8vw, 48px);
  }
  #seo-blurb {
    max-width: clamp(300px, 28vw, 540px);
    font-size: clamp(12px, 0.9vw, 24px);
  }
  #lively-links {
    font-size: clamp(12px, 0.9vw, 24px);
  }
}
@media (max-width: 639px), (max-height: 500px) and (orientation: landscape) {
  html, body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }
  html:has(body.fullscreen),
  html:has(body.polar-screensaver),
  html:has(body.bbs-mode),
  body.fullscreen,
  body.polar-screensaver,
  body.bbs-mode {
    height: 100dvh;
    overflow: hidden !important;
  }
  #clock-stage {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 100dvh;
  }
  #hud-header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 12px 6px;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    z-index: 10;
  }
  #top-left {
    display: contents;
  }
  #brand-block {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
  }
  #header {
    font-size: clamp(22px, 6vw, 32px);
  }
  #shoutout {
    font-size: clamp(11px, 3.2vw, 14px);
  }
  #controls-toggle {
    grid-column: 2;
    grid-row: 1;
    position: static;
    padding: 8px 12px;
    font-size: 22px;
  }
  #clock-switcher {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    position: static;
    transform: none;
    width: fit-content;
    margin-inline: auto;
    font-size: 14px;
    padding: 4px;
    gap: 4px;
  }
  #clock-switcher a,
  #clock-switcher span,
  #clock-switcher .clock-dropdown summary {
    padding: 7px 14px;
  }
  #clock-switcher .clock-dropdown-menu a {
    padding: 8px 12px;
  }
  canvas {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    height: auto;
  }
  #seo-blurb {
    position: absolute;
    top: 100dvh;
    left: 0;
    width: 100%;
    max-width: 100%;
    padding: 16px 12px 24px;
    box-sizing: border-box;
    margin: 0;
    font-size: 13px;
    pointer-events: auto;
  }
  body.bbs-mode #seo-blurb {
    display: none;
  }
  #lively-links,
  #shortcuts-cheatsheet,
  .controls-shortcuts-note {
    display: none;
  }
  #controls {
    min-width: 200px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
  #kofi-container .floatingchat-container-wrap {
    display: block !important;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  #hud-header {
    grid-template-columns: 1fr auto auto;
    padding: 6px 12px 4px;
  }
  #clock-switcher {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    margin-inline: 0;
  }
  #controls-toggle {
    grid-column: 3;
    grid-row: 1;
  }
}
#fullscreen-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: #ffffff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  pointer-events: none;
  user-select: none;
  display: none;
}
.fullscreen #fullscreen-hint {
  display: block;
}
.polar-screensaver #hud-header,
.polar-screensaver #top-left,
.polar-screensaver #header,
.polar-screensaver #controls,
.polar-screensaver #shoutout,
.polar-screensaver #seo-blurb,
.polar-screensaver #lively-links,
.polar-screensaver #controls-toggle,
.fullscreen #hud-header,
.fullscreen #top-left,
.fullscreen #header,
.fullscreen #controls,
.fullscreen #shoutout,
.fullscreen #seo-blurb,
.fullscreen #lively-links,
.fullscreen #controls-toggle {
  display: none;
}

/* ---------- Late-90s / Early-2000s BBS ASCII Art Mode ---------- */
body.bbs-mode {
  background: #000000;
  font-family: "Courier New", "Lucida Console", Consolas, monospace;
}
body.bbs-mode::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0px,
    rgba(255, 255, 255, 0) 2px,
    rgba(0, 0, 0, 0.28) 3px,
    rgba(0, 0, 0, 0.28) 4px
  );
}
body.bbs-mode #top-left {
  gap: 4px;
}
body.bbs-mode #header,
body.bbs-mode #shoutout,
body.bbs-mode #seo-blurb,
body.bbs-mode #lively-links,
body.bbs-mode #controls,
body.bbs-mode #controls-toggle,
body.bbs-mode #fullscreen-hint {
  font-family: "Courier New", "Lucida Console", Consolas, monospace;
}
body.bbs-mode #header {
  color: #55ffff;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(85, 255, 255, 0.45);
  border-top: 2px double #55ffff;
  border-bottom: 2px double #55ffff;
  padding: 2px 6px;
}
body.bbs-mode #header .version {
  color: #ffff55;
}
body.bbs-mode #shoutout {
  color: #55ff55;
  opacity: 0.9;
  font-size: clamp(12px, 1.4vw, 22px);
}
body.bbs-mode #shoutout::before {
  content: ">> ";
  color: #ffff55;
}
body.bbs-mode #seo-blurb {
  color: #aaaaaa;
  opacity: 0.85;
  line-height: 1.4;
}
body.bbs-mode #lively-links {
  color: #aaaaaa;
  gap: 2px;
}
body.bbs-mode #lively-links a,
body.bbs-mode #lively-links button,
body.bbs-mode #about-faq summary {
  color: #55ffff;
  text-decoration: none;
}
body.bbs-mode #lively-links a::before,
body.bbs-mode #lively-links button::before,
body.bbs-mode #about-faq summary::before {
  content: "[ ";
  color: #aaaaaa;
}
body.bbs-mode #lively-links a::after,
body.bbs-mode #lively-links button::after,
body.bbs-mode #about-faq summary::after {
  content: " ]";
  color: #aaaaaa;
}
body.bbs-mode #lively-links a:hover,
body.bbs-mode #lively-links button:hover,
body.bbs-mode #about-faq summary:hover {
  color: #ffff55;
  background: #0000aa;
}
body.bbs-mode #about-faq .faq-body {
  background: #000084;
  border: 2px solid #55ffff;
  border-radius: 0;
  color: #ffffff;
}
body.bbs-mode #about-faq h3 {
  color: #ffff55;
}
body.bbs-mode #controls {
  background: #000084;
  color: #ffffff;
  border: 2px solid #55ffff;
  outline: 2px solid #000084;
  border-radius: 0;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.85);
  backdrop-filter: none;
}
body.bbs-mode .control-group-title {
  color: #ffff55;
  opacity: 1;
  letter-spacing: 1px;
}
body.bbs-mode .control-group-title::before {
  content: "== ";
  color: #55ffff;
}
body.bbs-mode .control-group-title::after {
  content: " ==";
  color: #55ffff;
}
body.bbs-mode #controls input[type="checkbox"] {
  accent-color: #55ff55;
}
body.bbs-mode #controls select,
body.bbs-mode #controls input[type="datetime-local"],
body.bbs-mode #copy-countdown-url {
  background: #000000;
  color: #55ff55;
  border: 1px solid #55ffff;
  border-radius: 0;
}
body.bbs-mode #controls select option {
  background: #000000;
  color: #55ff55;
}
body.bbs-mode #controls-toggle {
  background: #000084;
  color: #55ffff;
  border: 2px solid #55ffff;
  border-radius: 0;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.85);
  backdrop-filter: none;
}
body.bbs-mode #controls-toggle:hover {
  color: #ffff55;
  border-color: #ffff55;
}
body.bbs-mode #fullscreen-hint {
  color: #55ff55;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---------- Keyboard Shortcuts UI ---------- */
#controls kbd,
#shortcuts-cheatsheet kbd {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
#controls kbd {
  padding: 2px 6px;
  font-size: 14px;
  border-radius: 4px;
}
#controls label kbd {
  margin-left: auto;
  opacity: 0.65;
}
#controls .controls-shortcuts-note {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.55);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 9px;
}
#shortcuts-cheatsheet {
  margin-top: 9px;
  padding: 16px 21px;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 11px;
  color: rgba(255, 255, 255, 0.85);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 22px;
  line-height: 1.45;
  pointer-events: auto;
  user-select: none;
}
#shortcuts-cheatsheet.hidden {
  display: none;
}
#shortcuts-cheatsheet .shortcuts-title {
  font-size: 18px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 10px;
}
#shortcuts-cheatsheet .shortcuts-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 18px;
  align-items: center;
}
#shortcuts-cheatsheet kbd {
  padding: 2px 8px;
  font-size: 20px;
  border-radius: 5px;
}
body.bbs-mode #shortcuts-cheatsheet {
  background: #000084;
  border: 2px solid #55ffff;
  border-radius: 0;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.85);
  backdrop-filter: none;
  color: #55ff55;
  font-family: "Courier New", Courier, monospace;
}
body.bbs-mode #shortcuts-cheatsheet .shortcuts-title {
  color: #ffff55;
}
body.bbs-mode #controls kbd,
body.bbs-mode #shortcuts-cheatsheet kbd {
  background: #000000;
  color: #55ffff;
  border-color: #55ffff;
  border-radius: 0;
}
