* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
}

:root {
  --seg-on: #ffffff;
  --seg-off: rgba(255, 255, 255, 0.07);
  --date-color: rgba(255, 255, 255, 0.55);
}

body {
  font-family: 'Courier New', monospace;
}

#screen {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  cursor: pointer;
}

/* ---------- main time row: SVG fills the row, scaled to the max size
   that fits without distorting or clipping the digits ---------- */

#time-row {
  flex: 1 1 auto;
  min-height: 0;
  padding: 1vh 1vw 0;
}

#clock-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.seg {
  fill: var(--seg-off);
}

.seg.on {
  fill: var(--seg-on);
}

.meridiem-text {
  fill: var(--seg-on);
  font-family: 'Courier New', monospace;
  font-weight: bold;
}

/* ---------- date row ---------- */

#date-row {
  flex: 0 0 auto;
  height: 8vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  color: var(--date-color);
  font-size: min(3.2vw, 4vh);
  letter-spacing: 0.08em;
}

#fullscreen-btn {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #2a4a63;
  background: rgba(20, 30, 40, 0.6);
  color: #7fa8cc;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity 0.2s;
}

#fullscreen-btn:hover,
#fullscreen-btn:active {
  opacity: 1;
}

#fullscreen-btn.hidden {
  display: none;
}

#color-btn {
  position: fixed;
  bottom: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #444;
  background: rgba(30, 30, 30, 0.6);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  transition: opacity 0.2s;
}

#color-btn:hover,
#color-btn:active,
#color-btn.active {
  opacity: 1;
}

#color-panel {
  position: fixed;
  bottom: 68px;
  left: 16px;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 24px;
  border: 1px solid #444;
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(4px);
}

#color-panel.open {
  display: flex;
}

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: var(--sw);
  padding: 0;
  cursor: pointer;
}

.swatch:hover {
  border-color: rgba(255, 255, 255, 0.8);
}

#custom-swatch {
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
}

#custom-color-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
