html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #000000;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#app-logo {
  position: fixed;
  top: 95px;
  right: 75px;
  z-index: 40;
  /* Allow children to control their own opacity via classes */
  opacity: 1;
  pointer-events: none;
  text-align: right;
}

/* Start logo text hidden; fade in when .text-visible is applied */
#app-logo .logo-main,
#app-logo .logo-sub {
  opacity: 0;
  transition: opacity 1s ease;
}

#app-logo.text-visible .logo-main,
#app-logo.text-visible .logo-sub {
  opacity: 1;
}

#app-logo .logo-main {
  font-family: 'Playfair Display', 'Georgia', serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d4af37;
  text-shadow:
    -2px -2px 0 #000,
    2px -2px 0 #000,
    -2px 2px 0 #000,
    2px 2px 0 #000,
    0 0 14px rgba(0, 0, 0, 0.85),
    0 0 26px rgba(212, 175, 55, 0.5);
}

#app-logo .logo-sub {
  margin-top: 4px;
  font-family: "Brush Script MT", "Lucida Handwriting", cursive;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #f5e2b8;
  text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000,
    0 0 10px rgba(0, 0, 0, 0.7),
    0 0 14px rgba(212, 175, 55, 0.4);
}

#app-logo::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  /* Start zoomed out (scale 0) */
  transform: translate(0, -50%) scale(0);
  width: 150px;
  height: 150px;
  background-image: url("logo-backw.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
  /* Zoom + fade over 2s on first reveal */
  transition: opacity 1s ease, transform 2s ease-out;
}

/* Background clock fades in first */
#app-logo.bg-visible::before {
  opacity: 0.35;
  /* End state: fully sized logo */
  transform: translate(0, -50%) scale(1);
}

/* Entire logo fades out at the end of intro */
#app-logo.fade-out {
  transition: opacity 1s ease;
  opacity: 0;
}

/* Old keyframe-based .visible animation is no longer used, but kept for compatibility */
#app-logo.visible {
  animation: logoIntro 10s ease-out forwards;
}

@keyframes logoIntro {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  15% {
    opacity: 1;
    transform: translateY(0);
  }
  80% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-6px);
  }
}

#clock-container {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 1080px;
  height: 1920px;
  transform: translate(-50%, -50%) scale(var(--zoom, 0.5));
  transform-origin: center center;
  opacity: 0;
  transition: opacity 1s ease, transform 0.3s ease;
}

#clock-container.show-clock {
  opacity: 1;
}

#clock {
  display: block;
  width: 1080px;
  height: 1920px;
  border: none;
  box-shadow: none;
}

#zoom-controls {
  position: fixed;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 20;
}

.zoom-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(18, 18, 18, 0.8);
  color: #f5f5f5;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-btn:active {
  transform: scale(0.96);
}

#zoom-level {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(18, 18, 18, 0.8);
  color: #f5f5f5;
  font-size: 12px;
  z-index: 20;
}

#face-thumb-toggle {
  position: fixed;
  bottom: 12px;
  left: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  padding: 0;
  display: block;
  cursor: pointer;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease, transform 0.1s ease;
}

#face-thumb-toggle:active {
  transform: scale(0.96);
}

.face-toggle-visible {
  opacity: 1;
  pointer-events: auto;
}

#settings-toggle {
  position: fixed;
  bottom: 12px;
  left: 64px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(18, 18, 18, 0.8);
  color: #f5f5f5;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

/* Quick control buttons (CA, AC, BC, S) */
.quick-btn {
  position: fixed;
  bottom: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(18, 18, 18, 0.8); /* same as settings button */
  color: #f5f5f5;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: transform 0.1s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.quick-btn:active {
  transform: scale(0.96);
}

#btn-ca { left: 116px; }
#btn-ac { left: 168px; }
#btn-bc { left: 220px; }
#btn-s  { left: 272px; }

#settings-toggle:active {
  transform: scale(0.96);
}

#settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
}

#settings-overlay.hidden {
  display: none;
}

#settings-panel {
  width: 100%;
  max-width: 300px;
  background: linear-gradient(135deg, rgba(20, 20, 20, 0.98) 0%, rgba(30, 30, 30, 0.96) 100%);
  color: #f5f5f5;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(212, 175, 55, 0.2);
  border: 1px solid rgba(212, 175, 55, 0.2);
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.settings-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  cursor: grab;
  color: #d4af37;
  background: rgba(255, 255, 255, 0.02);
}

.settings-header:active {
  cursor: grabbing;
}

#settings-close {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 18px;
  padding: 4px;
  cursor: pointer;
}

.settings-content {
  padding: 16px 20px;
  overflow-y: auto;
}

.setting-group {
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 16px;
}

.setting-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.setting-group.condensed-group {
  margin-bottom: 16px;
  padding-bottom: 10px;
}

.condensed-group .control-row {
  margin-bottom: 4px;
  min-height: 24px;
}

.condensed-group .slider-container {
  padding: 0 4px;
}

.group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #d4af37;
  margin-bottom: 12px;
  font-weight: 700;
  opacity: 0.9;
}

.face-section-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.preview-thumb-large {
  width: 90px;
  height: 120px;
  border-radius: 6px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  background-color: #050505;
  flex-shrink: 0;
  box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}

.face-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding-top: 10px;
}

.style-number {
  font-size: 16px;
  font-family: 'Playfair Display', serif;
  color: #f5f5f5;
  font-weight: 600;
}

.control-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  min-height: 32px;
}

.control-row.toggle-row {
  justify-content: space-between;
  margin-bottom: 8px;
}

.control-row.indent {
  padding-left: 24px;
}

.label {
  font-size: 13px;
  color: #ccc;
  width: 60px;
  flex-shrink: 0;
}

.slider-container {
  flex: 1;
  padding: 0 10px;
  display: flex;
  align-items: center;
}

.color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
  margin-left: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.value-text {
  flex: 1;
  text-align: right;
  font-size: 13px;
  color: #d4af37;
  font-weight: 600;
  padding-right: 12px;
}

.cycle-btn, .text-btn {
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  background: rgba(255, 255, 255, 0.05);
  color: #f5f5f5;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.cycle-btn {
  width: 100%;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  background: rgba(255, 255, 255, 0.05);
  color: #d4af37;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

.cycle-btn:hover, .text-btn:hover, .icon-btn:hover {
  background: rgba(212, 175, 55, 0.15);
  border-color: #d4af37;
}

.preview-row {
  display: flex;
  justify-content: center;
  margin: 4px 0 8px 0;
  background: rgba(0,0,0,0.3);
  padding: 6px;
  border-radius: 8px;
}

.hand-preview-canvas {
  width: 40px;
  height: 40px;
}

/* Checkbox styling */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  background: #333;
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  border: 1px solid #555;
  transition: background 0.3s;
}

input[type="checkbox"]:checked {
  background: #d4af37;
  border-color: #d4af37;
}

input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}

@media (min-width: 600px) {
  #settings-panel {
    border-radius: 12px;
    margin-bottom: 24px;
    max-width: 320px;
  }
}

/* Desktop positioning */
@media (min-width: 601px) {
  /* Center the face thumb at the bottom as a large miniature */
  #face-thumb-toggle {
    left: 50%;
    transform: translateX(-50%);
    bottom: 30px;
    width: 90px;
    height: 125px;
    border-radius: 12px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: #000;
    border: 2px solid rgba(212, 175, 55, 0.5);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(0,0,0,0.5);
    transition: opacity 0.5s ease, transform 0.2s ease, border-color 0.2s ease;
  }

  #face-thumb-toggle:hover {
    border-color: rgba(212, 175, 55, 1);
    transform: translateX(-50%) scale(1.05);
    background-color: #111;
  }

  #face-thumb-toggle:active {
    transform: translateX(-50%) scale(0.95);
    border-color: rgba(212, 175, 55, 0.8);
  }

  /* Settings button to the bottom left area */
  #settings-toggle {
    left: 40px;
    bottom: 25px;
  }

  /* Desktop positions for quick buttons, aligned next to settings */
  .quick-btn {
    bottom: 25px;
  }

  #btn-ca { left: 92px; }
  #btn-ac { left: 144px; }
  #btn-bc { left: 196px; }
  #btn-s  { left: 248px; }

  /* Zoom controls to the bottom right area */
  #zoom-controls {
    left: auto;
    right: 40px;
    bottom: 25px;
  }
  
  /* Move zoom level readout so it doesn't overlap the centered clock thumb */
  #zoom-level {
    left: auto;
    right: 140px;
    bottom: 37px;
    transform: none;
  }
}

#clock-title {
  position: fixed;
  top: 95px;
  right: 75px;
  transform: none;
  text-align: right;
  z-index: 25;
  max-width: 40%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 3s cubic-bezier(0.4, 0, 0.2, 1), transform 3s cubic-bezier(0.4, 0, 0.2, 1);
}

#clock-title.visible {
  opacity: 1;
}

#clock-title.hidden {
  display: none;
}

.title-main {
  font-family: 'Playfair Display', 'Georgia', serif;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.4;
  color: #d4af37;
  /* Thick, dark stroke effect */
  text-shadow: 
    -4px -4px 0 #000, 4px -4px 0 #000, -4px 4px 0 #000, 4px 4px 0 #000,
    -4px 0 0 #000, 4px 0 0 #000, 0 -4px 0 #000, 0 4px 0 #000,
    -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000,
    0 0 20px rgba(0, 0, 0, 0.8),
    0 0 40px rgba(212, 175, 55, 0.3);
  letter-spacing: 0.02em;
  max-width: 450px;
  margin: 0 0 0 auto;
  animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
  from {
    text-shadow: 
      -4px -4px 0 #000, 4px -4px 0 #000, -4px 4px 0 #000, 4px 4px 0 #000,
      -4px 0 0 #000, 4px 0 0 #000, 0 -4px 0 #000, 0 4px 0 #000,
      -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000,
      0 0 20px rgba(0, 0, 0, 0.8),
      0 0 40px rgba(212, 175, 55, 0.3);
  }
  to {
    text-shadow: 
      -4px -4px 0 #000, 4px -4px 0 #000, -4px 4px 0 #000, 4px 4px 0 #000,
      -4px 0 0 #000, 4px 0 0 #000, 0 -4px 0 #000, 0 4px 0 #000,
      -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000,
      0 0 20px rgba(0, 0, 0, 0.8),
      0 0 60px rgba(212, 175, 55, 0.6);
  }
}

.title-year {
  font-family: 'Playfair Display', 'Georgia', serif;
  font-size: 22px;
  font-weight: 400;
  font-style: italic;
  margin-top: 8px;
  color: #b8964f;
  text-shadow: 
    -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 3px 3px 0 #000,
    -2px 0 0 #000, 2px 0 0 #000, 0 -2px 0 #000, 0 2px 0 #000,
    0 0 15px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 3s cubic-bezier(0.4, 0, 0.2, 1), transform 3s cubic-bezier(0.4, 0, 0.2, 1);
}

#clock-title.date-visible .title-year {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 600px) {
  #clock-container {
    position: fixed;
    top: 50%;
    left: 50%;
    /* Transform is set dynamically by JS */
    transform-origin: center center;
  }

  #clock {
    width: 1080px;
    height: 1920px;
    border: none;
    box-shadow: none;
  }

  /* Mobile-specific logo adjustments */
  #app-logo {
    top: 45px; /* 95px - 50px = 45px, 50 pixels higher */
  }

  #app-logo .logo-main {
    font-size: 16px; /* ~40% smaller than 26px */
  }

  #app-logo .logo-sub {
    font-size: 13px; /* ~40% smaller than 22px */
  }

  #app-logo::before {
    width: 75px;  /* ~40% smaller than 125px */
    height: 75px;
  }

  #settings-panel {
    width: calc(100% - 32px);
    max-width: 280px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 12px;
    margin: 0;
  }

  #settings-overlay {
    align-items: center;
    justify-content: center;
  }

  #clock-title {
    top: 45px;
    right: 75px;
    max-width: 60%;
  }

  .title-main {
    font-size: 26px;
    text-shadow:
      -2px -2px 0 #000,
      2px -2px 0 #000,
      -2px 2px 0 #000,
      2px 2px 0 #000,
      0 0 12px rgba(212, 175, 55, 0.4);
  }

  .title-year {
    font-size: 18px;
    text-shadow:
      -1px -1px 0 #000,
      1px -1px 0 #000,
      -1px 1px 0 #000,
      1px 1px 0 #000,
      0 0 8px rgba(184, 150, 79, 0.35);
  }

  /* Mobile bottom controls: smaller and aligned from bottom-left */
  #face-thumb-toggle,
  #settings-toggle,
  .quick-btn {
    width: 31px; /* ~30% smaller than 44px */
    height: 31px;
  }

  #face-thumb-toggle {
    left: 12px;
  }

  #settings-toggle {
    left: 54px;
  }

  /* Mobile positions for quick buttons, aligned in a row from left */
  #btn-ca { left: 96px; }
  #btn-ac { left: 138px; }
  #btn-bc { left: 180px; }
  #btn-s  { left: 222px; }

  #zoom-controls {
    right: 62px; /* 12px + 50px */
  }
}

/* Initial state: hide bottom controls until intro is done */
#zoom-controls,
#face-thumb-toggle,
#settings-toggle,
.quick-btn,
#zoom-level {
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease;
}

/* Reveal bottom controls after first clock face appears */
body.controls-ready #zoom-controls,
body.controls-ready #face-thumb-toggle,
body.controls-ready #settings-toggle,
body.controls-ready .quick-btn,
body.controls-ready #zoom-level {
  opacity: 1;
  pointer-events: auto;
}

/* Fade out controls when inactive on all viewports (overrides ready state) */
body.user-inactive #zoom-controls,
body.user-inactive #face-thumb-toggle,
body.user-inactive #settings-toggle,
body.user-inactive .quick-btn,
body.user-inactive #zoom-level {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Hide cursor on desktop when user is inactive */
@media (min-width: 601px) {
  body.user-inactive {
    cursor: none;
  }
}

