/* Base variables for consistent theming */
:root {
  --primary-color: #ffa500;
  --primary-glow: rgba(255, 165, 0, 0.7);
  --secondary-glow: rgba(255, 165, 0, 0.5);
  --tertiary-glow: rgba(255, 165, 0, 0.3);
  --start-btn-color: #4caf50;
  --start-btn-hover: #45a049;
  --reset-btn-color: #666;
  --reset-btn-hover: #555;
  --bg-overlay: rgba(0, 0, 0, 0.5);
  --container-bg: rgba(0, 0, 0, 0.7);
  --lap-bg: rgba(0, 0, 0, 0.4);
}

/* Stopwatch display styling */
.stopwatch-display {
  font-family: "Roboto Mono", monospace;
  font-size: 120px;
  color: var(--primary-color);
  text-align: center;
  margin: 20px 0;
  text-shadow: 0 0 10px var(--primary-glow), 0 0 20px var(--secondary-glow),
    0 0 30px var(--tertiary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 2px;
  animation: fadeInScale 0.5s ease-out;
}

.hours,
.minutes,
.seconds,
.milliseconds {
  display: inline-block;
  width: 120px;
  font-size: 120px;
  line-height: 1;
  text-align: center;
}

.separator {
  animation: blink 1s infinite;
  opacity: 0.8;
  line-height: 1;
  margin: 0 -5px;
}

/* Control buttons */
.stopwatch-controls {
  text-align: center;
  margin: 20px 0;
}

.btn {
  font-size: 18px;
  padding: 15px 40px;
  margin: 0 10px;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  text-transform: uppercase;
  font-weight: bold;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.start-btn {
  background: var(--start-btn-color);
  color: white;
  position: relative;
  overflow: hidden;
}

.start-btn:hover {
  background: var(--start-btn-hover);
  transform: scale(1.05);
}

/* Added button press animation */
.start-btn:active {
  animation: buttonPress 0.2s ease;
}

.reset-btn {
  background: var(--reset-btn-color);
  color: white;
  position: relative;
  overflow: hidden;
}

.reset-btn:hover {
  background: var(--reset-btn-hover);
  transform: scale(1.05);
}

/* Added button press animation */
.reset-btn:active {
  animation: buttonPress 0.2s ease;
}

/* Added button ripple effect */
.btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.5);
  opacity: 0;
  border-radius: 100%;
  transform: scale(1, 1) translate(-50%, -50%);
  transform-origin: 50% 50%;
}

.btn:focus:not(:active)::after {
  animation: ripple 1s ease-out;
}

/* Lap times section */
.lap-times {
  position: absolute;
  top: calc(100% - 0px);
  left: 0;
  right: 0;
  max-height: 300px;
  overflow-y: auto;
  padding: 25px 30px;
  background: var(--lap-bg);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 165, 0, 0.1);
  width: 100%;
  z-index: 10;
  transition: all 0.3s ease;
}

.lap-times:empty {
  padding: 0;
  border: none;
}

.lap-times table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
  table-layout: fixed;
}

.lap-times tr {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
}

.lap-times thead {
  position: sticky;
  top: 0;
  background: var(--lap-bg);
  z-index: 1;
}

.lap-times thead tr {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
}

.lap-times thead th {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--primary-color);
  text-align: center;
}

.lap-times td {
  padding: 15px 20px;
  text-align: center;
}

.lap-times td:first-child span {
  background: rgba(255, 165, 0, 0.15);
  border: 2px solid rgba(255, 165, 0, 0.3);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
}

.lap-times td:last-child {
  font-size: 28px;
  letter-spacing: 2px;
  text-shadow: 0 0 15px rgba(255, 165, 0, 0.4);
  font-weight: 500;
}

/* Reverse order of lap display */
.lap-times tbody {
  display: flex;
  flex-direction: column-reverse;
}

.lap-times tbody tr {
  width: 100%;
}

/* Main content layout */
.main-content {
  position: fixed;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1 !important;
}

.mode-container {
  min-width: 200px;
  max-width: 800px;
  padding: 20px;
  background: var(--container-bg);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  position: relative;
  animation: containerFadeIn 0.8s ease-out;
}

/* Background video */
.background-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
}

#bg-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-overlay);
}

/* Improved scrollbar */
.lap-times::-webkit-scrollbar {
  width: 8px;
}

.lap-times::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.lap-times::-webkit-scrollbar-thumb {
  background: rgba(255, 165, 0, 0.3);
  border-radius: 4px;
}

.lap-times::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 165, 0, 0.5);
}

/* Keyframe Animations */
@keyframes blink {
  0%,
  100% {
    opacity: 0.8;
  }
  50% {
    opacity: 0.3;
  }
}

@keyframes newLap {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* New animations */
@keyframes buttonPress {
  0% {
    transform: scale(1.05);
  }
  50% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes ripple {
  0% {
    transform: scale(0, 0);
    opacity: 1;
  }
  20% {
    transform: scale(25, 25);
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(40, 40);
  }
}

@keyframes containerFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseGlow {
  0% {
    text-shadow: 0 0 10px var(--primary-glow), 0 0 20px var(--secondary-glow),
      0 0 30px var(--tertiary-glow);
  }
  50% {
    text-shadow: 0 0 15px var(--primary-glow), 0 0 30px var(--secondary-glow),
      0 0 45px var(--tertiary-glow);
  }
  100% {
    text-shadow: 0 0 10px var(--primary-glow), 0 0 20px var(--secondary-glow),
      0 0 30px var(--tertiary-glow);
  }
}

@keyframes highlight {
  0% {
    background: rgba(255, 165, 0, 0.15);
  }
  50% {
    background: rgba(255, 165, 0, 0.4);
  }
  100% {
    background: rgba(255, 165, 0, 0.15);
  }
}

/* Apply new animations */
.lap-times tbody tr:first-child td:first-child span {
  animation: highlight 2s ease-out;
}

.stopwatch-display.running {
  animation: pulseGlow 2s infinite;
}

/* Responsive design */
@media (max-width: 768px) {
  .mode-container {
    min-width: auto;
    padding: 20px;
    margin: 10px;
  }

  .stopwatch-display {
    font-size: 80px;
  }

  .hours,
  .minutes,
  .seconds,
  .milliseconds {
    width: auto;
    font-size: 80px;
  }

  .lap-times thead,
  .lap-times tbody tr {
    grid-template-columns: 100px 1fr;
  }

  .lap-times td:first-child {
    width: 100px;
  }

  .lap-times td:last-child {
    font-size: 24px;
  }

  .btn {
    padding: 12px 30px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .stopwatch-display {
    font-size: 60px;
  }

  .hours,
  .minutes,
  .seconds,
  .milliseconds {
    font-size: 60px;
    width: auto;
  }

  .btn {
    padding: 10px 25px;
    margin: 0 5px;
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes numberChange {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  50% {
    transform: translateY(-2px);
    opacity: 0.8;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.stopwatch-display.running .milliseconds {
  animation: numberChange 0.2s linear infinite;
}
