:root {
  --bg-color: #0f172a;
  --surface-color: #1e293b;
  --primary-color: #8b5cf6;
  --primary-glow: rgba(139, 92, 246, 0.5);
  --secondary-color: #64748b;
  --danger-color: #ef4444;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --font-main: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition-speed: 0.3s;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
}

#app {
  width: 100%;
  max-width: 480px;
  background-color: var(--surface-color);
  border-radius: 24px;
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: 80vh;
  min-height: 680px;
  /* Ensure enough space for all clock elements */
  position: relative;
}

main {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Header & Title */
header {
  margin-bottom: 2rem;
  text-align: center;
}

.app-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #fff 0%, var(--primary-color) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  cursor: default;
  transition: all 0.3s ease;
  letter-spacing: -0.02em;
}

.app-title:hover {
  filter: drop-shadow(0 0 10px var(--primary-glow));
  transform: scale(1.02);
}

.subtitle {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-secondary);
  display: block;
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  background: none;
  -webkit-text-fill-color: var(--text-secondary);
}

.github-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.3);
  transition: all 0.3s;
  cursor: pointer;
  -webkit-text-fill-color: var(--text-secondary);
}

.github-link:hover {
  color: var(--primary-color);
  -webkit-text-fill-color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

/* Tabs */
.tabs {
  display: flex;
  position: relative;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 4px;
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 12px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 1;
  transition: color var(--transition-speed);
}

.tab-btn.active {
  color: var(--text-primary);
}

.tab-indicator {
  position: absolute;
  top: 4px;
  left: 0;
  width: 33.33%;
  /* Fallback */
  height: calc(100% - 8px);
  background-color: var(--primary-color);
  border-radius: 8px;
  transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 15px var(--primary-glow);
}

/* Sections */
.tab-content {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  flex: 1;
  width: 100%;
  animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Time Display */
.time-display-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  width: 100%;
}

.time-display {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
  font-variant-numeric: tabular-nums;
}

.milliseconds {
  font-size: 1.5rem;
  color: var(--text-secondary);
}

/* Controls */
.controls {
  display: flex;
  gap: 1rem;
  width: 100%;
  justify-content: center;
}

.btn {
  padding: 12px 32px;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 0 20px var(--primary-glow);
}

.btn.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 30px var(--primary-glow);
}

.btn.secondary {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn.secondary:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.2);
}

.btn.danger {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
}

.btn.danger:hover:not(:disabled) {
  background-color: rgba(239, 68, 68, 0.2);
}

/* Laps */
.laps-container {
  width: 100%;
  height: 150px;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1rem;
}

.laps-container::-webkit-scrollbar {
  width: 4px;
}

.laps-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.lap-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Timer Specific */
.timer-input-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
}

.time-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.time-input-group input {
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 2.5rem;
  text-align: center;
  outline: none;
  transition: all 0.2s;
}

.time-input-group input:focus {
  border-color: var(--primary-color);
  background: rgba(255, 255, 255, 0.1);
}

.separator {
  font-size: 2rem;
  color: var(--text-secondary);
}

.hidden {
  display: none !important;
}

/* Progress Ring */
.progress-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
}

.progress-ring__circle {
  transition: stroke-dashoffset 0.1s linear;
  transform-origin: 50% 50%;
  stroke-linecap: round;
}

.time-display.centered {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
}

/* Clock Specific */
.date-display {
  /* Removed absolute positioning for stable layout */
  position: static;
  margin-top: 0.5rem;
  font-size: 1.25rem;
  color: var(--primary-color);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

/* Time Zone Selector */
.time-zone-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.timezone-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
}

.timezone-select:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary-color);
}

.timezone-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.timezone-select option,
.timezone-select optgroup {
  background-color: #1e293b;
  /* Hardcoded surface color for better browser support */
  color: var(--text-primary);
}

.timezone-select optgroup {
  font-weight: 800;
  font-style: normal;
  color: var(--primary-color);
  /* Highlight continent names */
}

.ampm {
  font-size: 1.5rem;
  color: var(--text-secondary);
  margin-left: 0.5rem;
}

/* Analog Clock - Premium Depth Design */
.analog-clock-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.analog-clock {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
  position: relative;
  box-shadow:
    inset 0 0 20px rgba(0, 0, 0, 0.8),
    /* Inner depth */
    0 10px 20px rgba(0, 0, 0, 0.5),
    /* Drop shadow */
    0 0 0 1px rgba(255, 255, 255, 0.05);
  /* Subtle rim */
}

.hand {
  position: absolute;
  bottom: 50%;
  left: 50%;
  transform-origin: bottom;
  border-radius: 4px;
  transform: translateX(-50%) rotate(0deg);
  transition: transform 0.05s cubic-bezier(0.4, 2.08, 0.55, 0.44);
  z-index: 5;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.hour-hand {
  width: 6px;
  height: 55px;
  background: linear-gradient(to top, #94a3b8, #e2e8f0);
  margin-left: -3px;
  clip-path: polygon(20% 100%, 50% 0, 80% 100%);
  /* Tapered */
}

.minute-hand {
  width: 4px;
  height: 80px;
  background: linear-gradient(to top, #94a3b8, #e2e8f0);
  margin-left: -2px;
  clip-path: polygon(20% 100%, 50% 0, 80% 100%);
  /* Tapered */
}

.second-hand {
  width: 2px;
  height: 90px;
  background: var(--primary-color);
  margin-left: -1px;
  z-index: 6;
  box-shadow: none;
  /* clip-path cuts shadow */
}

/* Center Dot - Metallic Cap */
.center-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  background: radial-gradient(circle at 30% 30%, #e2e8f0, #475569);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.3);
}

/* Decor: Inner Ring */
.analog-clock::after {
  content: '';
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.03);
  pointer-events: none;
}

/* Hide Tick Markers for cleaner look, or style elegantly */
.marker {
  display: none;
  /* Cleaner look requested */
}

/* Clock Numbers - Modern & Glowing */
.clock-number {
  position: absolute;
  width: 20px;
  height: 20px;
  text-align: center;
  line-height: 20px;
  color: var(--text-secondary);
  font-family: var(--font-main);
  /* Cleaner sans-serif */
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.8;
  left: calc(50% - 10px);
  top: calc(50% - 10px);
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.num-1 {
  transform: rotate(30deg) translate(0, -75px) rotate(-30deg);
}

.num-2 {
  transform: rotate(60deg) translate(0, -75px) rotate(-60deg);
}

.num-3 {
  transform: rotate(90deg) translate(0, -75px) rotate(-90deg);
}

.num-4 {
  transform: rotate(120deg) translate(0, -75px) rotate(-120deg);
}

.num-5 {
  transform: rotate(150deg) translate(0, -75px) rotate(-150deg);
}

.num-6 {
  transform: rotate(180deg) translate(0, -75px) rotate(-180deg);
}

.num-7 {
  transform: rotate(210deg) translate(0, -75px) rotate(-210deg);
}

.num-8 {
  transform: rotate(240deg) translate(0, -75px) rotate(-240deg);
}

.num-9 {
  transform: rotate(270deg) translate(0, -75px) rotate(-270deg);
}

.num-10 {
  transform: rotate(300deg) translate(0, -75px) rotate(-300deg);
}

.num-11 {
  transform: rotate(330deg) translate(0, -75px) rotate(-330deg);
}

.num-12 {
  transform: translate(0, -75px);
}