body {
    font-family: 'Poppins', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #000000;
    background-image: radial-gradient(circle at center, rgba(255, 59, 48, 0.5) 0%, transparent 60%);
    color: #ffffff;
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

.container {
    text-align: center;
    background: rgba(20, 20, 20, 0.7);
    padding: 40px 60px;
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#timer-display,
#stopwatch-display {
  font-size: 7rem !important;
  font-weight: 300;
  color: white;
  text-shadow: 0 0 25px rgba(0,0,0,0.3);
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin-bottom: 10px;
}

.timer-title-display {
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 20px;
    color: #ccc;
}

.title-setter, .stopwatch-title-setter {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#title-input, #stopwatch-title-input {
    font-family: 'Poppins', sans-serif;
    width: 180px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0,0,0,0.2);
    color: white;
    font-size: 1rem;
    text-align: center;
    margin-right: 10px;
}

#title-input::placeholder, #stopwatch-title-input::placeholder {
    color: #888;
}

#set-title, #set-stopwatch-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

#set-title:hover, #set-stopwatch-title:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.8);
}

.custom-time-setter {
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

#custom-hours-input, #custom-minutes-input {
    font-family: 'Poppins', sans-serif;
    width: 60px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0,0,0,0.2);
    color: white;
    font-size: 1rem;
    text-align: center;
}

#custom-hours-input {
    margin-right: 5px; /* Adjusted spacing */
}

#custom-minutes-input {
    margin-right: 10px; /* Spacing before Set button */
}

.time-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 100%;
    font-size: 1.5rem;
    color: #ccc;
    margin: 0;
    padding: 0;
}

#custom-hours-input::placeholder, #custom-minutes-input::placeholder {
    color: #888;
}

/* Hide spin buttons for number input */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield; /* Firefox */
}

#set-time {
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.5);
    margin-left: 10px; /* Added spacing */
}

#set-time:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.8);
}

.buttons button {
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    padding: 12px 30px;
    margin: 0 10px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    background-color: rgba(45, 45, 45, 0.8);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.buttons button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    background-color: rgba(65, 65, 65, 0.9);
}

.buttons button:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

#start, #pause, #reset, #stopwatch-start, #stopwatch-pause, #stopwatch-reset, #timer-mode-back-btn, #stopwatch-mode-back-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.9);
}

#start:hover, #pause:hover, #reset:hover, #stopwatch-start:hover, #stopwatch-pause:hover, #stopwatch-reset:hover, #timer-mode-back-btn:hover, #stopwatch-mode-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.8);
}

#timer-mode-back-btn, #stopwatch-mode-back-btn {
    color: #007aff; /* A distinct color for the mode button */
}

.settings-icon {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 1000;
  padding: 8px;
  transition: opacity 0.2s;
  opacity: 0.6;
  cursor: pointer;
}
.settings-icon:hover {
  opacity: 1;
}
.settings-icon svg {
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.fullscreen-btn {
  position: fixed;
  top: 24px;
  right: 24px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: color 0.3s ease, opacity 0.3s;
  z-index: 1001;
}
.fullscreen-btn:hover {
  color: rgba(255, 255, 255, 0.8);
}

/* Mode Selection Screen Styles */
#mode-selection-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.question {
    font-size: 2rem;
    margin-bottom: 30px;
    color: white;
}

.mode-buttons button {
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    padding: 15px 40px;
    margin: 0 15px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    background-color: rgba(45, 45, 45, 0.8);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.mode-buttons button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    background-color: rgba(65, 65, 65, 0.9);
}

.mode-buttons button:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

/* Settings Modal Styles */
.settings-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px) saturate(1.2);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}

.settings-modal.active {
  display: flex;
}

.settings-content {
  background: rgba(26, 32, 44, 0.85); /* Dark, semi-transparent background */
  backdrop-filter: blur(15px);
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #E2E8F0; /* Light text for dark background */
}

.settings-header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 24px;
  position: relative;
}

.settings-header h2 {
  margin: 0;
  color: #E2E8F0; /* Lighter text color */
  font-size: 24px;
  font-weight: 600;
}

.close-settings {
  position: absolute;
  top: 50%;
  right: -8px;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #A0AEC0; /* Lighter gray for close button */
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.close-settings:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #FFF;
}

.settings-group {
  margin-bottom: 24px;
  text-align: center;
}

.settings-group.toggle-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px; /* Add some padding to align with inputs */
  text-align: left;
}

.settings-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #CBD5E0; /* Lighter label color */
}

.settings-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid #4A5568; /* Darker border */
  border-radius: 8px;
  font-size: 16px;
  background: rgba(45, 55, 71, 0.7); /* Dark input background */
  transition: border-color 0.2s;
  color: #E2E8F0; /* Light text color for input */
}

.settings-group input:focus {
  outline: none;
  border-color: #E53E3E; /* Red border on focus */
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.2); /* Red shadow */
}

/* Toggle Switch Styles */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #4A5568;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: #c81e1e;
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.slider.round {
  border-radius: 28px;
}

.slider.round:before {
  border-radius: 50%;
}

.save-settings {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #c81e1e, #1a1a1a); /* Red to Black gradient */
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.save-settings:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(229, 62, 62, 0.35); /* Reddish glow */
}

.timer-container {
  margin-bottom: 20px;
}

#timer-progress-container {
  position: relative;
  width: 90%;
  max-width: 450px;
  height: 4px;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
  margin: 20px auto 0;
  border: 1.5px solid rgba(255, 255, 255, 0.25); /* Subtle white outline */
}

#timer-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #E53E3E, #c81e1e);
  border-radius: 2px;
  transition: width 0.2s linear;
}

#timer-progress-dot {
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  background-color: #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.9), 0 0 16px rgba(229, 62, 62, 0.6);
  transition: left 0.2s linear;
}

.controls {
  display: flex;
}

.hide-on-fullscreen {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 0.4s;
}

#timer-app,
#stopwatch-app {
  /* Remove transitions for size and box-shadow */
}

#timer-app.compact-mode, #stopwatch-app.compact-mode {
  /* Remove all min/max width/height, box-shadow, and padding changes */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#timer-app.compact-mode .buttons,
#stopwatch-app.compact-mode .buttons {
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px) scale(0.98);
  transition: opacity 0.5s cubic-bezier(0.4,0,0.2,1), transform 0.5s cubic-bezier(0.4,0,0.2,1);
}

#timer-app.compact-mode .timer-title-display,
#stopwatch-app.compact-mode .timer-title-display {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

#timer-app.compact-mode .timer-container,
#stopwatch-app.compact-mode .timer-display {
  margin-left: auto;
  margin-right: auto;
}

#timer-app.compact-mode .title-setter,
#timer-app.compact-mode .custom-time-setter,
#stopwatch-app.compact-mode .stopwatch-title-setter {
  display: none !important;
}

#timer-app.compact-mode:hover .buttons,
#stopwatch-app.compact-mode:hover .buttons {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  transition: opacity 0.4s cubic-bezier(0.4,0,0.2,1), transform 0.4s cubic-bezier(0.4,0,0.2,1);
}

#timer-app.compact-mode:hover,
#stopwatch-app.compact-mode:hover {
  /* Remove all min/max width/height, box-shadow, and padding changes */
}

/* ===== Mobile Optimization (≤ 600px) ===== */
@media (max-width: 600px) {
  /* Let the content start from the top, not centered vertically */
  body {
    display: block;
    padding: 0;
    height: auto;
    min-height: 100vh;
  }

  /* Make the container a full-screen, seamless part of the app */
  .container {
    width: 100%;
    min-height: 100vh; /* Ensure it fills the screen height */
    padding: 24px 16px;
    border-radius: 0;
    box-shadow: none;
    background: none; /* Make background seamless with body */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center the content within the viewport */
  }

  /* Refine font sizes for readability */
  #timer-display,
  #stopwatch-display {
    font-size: clamp(3rem, 15vw, 5rem) !important; /* Adjust clamp for better scaling */
    margin: 10px 0;
  }

  .timer-title-display {
    font-size: 1.2rem;
    margin-bottom: 16px;
  }

  /* Ensure progress bar doesn't overflow */
  #timer-progress-container {
    width: 100%;
    margin-top: 16px;
  }

  /* Improve spacing and layout for input sections */
  .title-setter,
  .stopwatch-title-setter,
  .custom-time-setter {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin: 16px 0;
  }

  #title-input,
  #stopwatch-title-input,
  #custom-hours-input,
  #custom-minutes-input {
    width: 100%;
    font-size: 1.1rem;
    padding: 14px;
    margin: 0;
  }

  #set-title,
  #set-stopwatch-title,
  #set-time {
    width: 100%;
    font-size: 1.1rem;
    padding: 14px 0;
    margin: 0;
  }

  /* Stack buttons cleanly */
  .buttons {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    margin-top: 16px;
  }

  .buttons button {
    width: 100%;
    font-size: 1.1rem;
    padding: 18px 0;
    border-radius: 12px;
  }

  /* Position fixed icons safely */
  .settings-icon {
    top: 16px;
    left: 16px;
  }

  .fullscreen-btn {
    top: 16px;
    right: 16px;
  }

  /* Ensure settings modal is usable */
  .settings-modal .settings-content {
    width: 95vw;
    padding: 24px 16px;
  }
}
