:root,
html[data-theme="dark"] {
  /* Dark theme */
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --text-primary: #ffffff;
  --text-secondary: #999999;
  --border-color: #2a2a2a;
  --button-bg: #0066ff;
  --button-hover: #0052cc;
  --button-text: #ffffff;
  --success-color: #34d399;
  --error-color: #f87171;
  --warning-color: #fbbf24;
  --accent-color: #0099ff;
}

* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  font-weight: 500;
}

/* Modern header with gradient and better typography */
.header {
  background: linear-gradient(135deg, var(--accent-color) 0%, #004fbf 100%);
  color: white;
  padding: 3rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
}

.header h1 {
  margin: 0;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header p {
  margin: 0.75rem 0 0;
  font-size: 1.1rem;
  opacity: 0.95;
  font-weight: 400;
}

/* Enhanced button styling with modern look */
.button {
  background: var(--button-bg);
  color: var(--button-text);
  border: none;
  border-radius: 10px;
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 102, 255, 0.15);
}

.button:hover:not(:disabled) {
  background: var(--button-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 102, 255, 0.25);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  color: #ffffff !important; /* Ensure text stays bright white when disabled */
}

.button.start-button {
  background: var(--success-color);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}

.button.start-button:hover:not(:disabled) {
  background: #059669;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.button.timing-button {
  background: var(--warning-color);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
  color: #ffffff !important; /* Force bright white text on timing button */
  font-weight: 600;
  white-space: pre-wrap;
}

.button.timing-button:hover:not(:disabled) {
  background: #d97706;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.button.timing-button:active:not(:disabled) {
  transform: translateY(0);
}

.button.timing-button:disabled {
  color: #ffffff !important;
}

.button.error-button {
  background: var(--error-color);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15);
}

.button.error-button:hover:not(:disabled) {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

/* Modern menu buttons layout */
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 3rem 1rem;
  max-width: 500px;
  margin: 0 auto;
}

.menu-buttons .button {
  padding: 1.25rem;
  font-size: 1.05rem;
  width: 100%;
  border-radius: 12px;
}

/* Modern container styling */
.container-header {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 2rem;
  margin-bottom: 2rem;
  border-radius: 12px;
}

.container-header h2 {
  margin: 0 0 1rem 0;
  font-size: 1.75rem;
  color: var(--text-primary);
  font-weight: 700;
}

.container-header p {
  margin: 0.75rem 0;
  color: var(--text-secondary);
  font-weight: 500;
}

#segments-container {
  display: flex;
  flex-direction: column;
  padding: 2rem 1rem;
  max-width: 900px;
  margin: 0 auto;
}

/* Modern segment card styling */
.segment {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 1.75rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.3s ease;
}

.segment:hover {
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(0, 102, 255, 0.1);
}

.segment.timing {
  border-left: 4px solid var(--warning-color);
  background: rgba(245, 158, 11, 0.05);
  border-color: var(--warning-color);
}

.segment-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.segment-info {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  font-weight: 500;
}

/* Modern timer display */
.timer {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent-color);
  text-align: center;
  padding: 1.5rem 0;
  font-family: "Courier New", monospace;
  letter-spacing: 2px;
}

.menu-button {
  margin-top: 2rem;
  width: 100%;
  border-radius: 12px;
}

#highway-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 3rem 1rem;
  max-width: 500px;
  margin: 0 auto;
}

#highway-buttons .button {
  padding: 1.25rem;
  font-size: 1rem;
  border-radius: 12px;
}

#total-time,
#total-distance,
#break-warning {
  margin: 0.75rem 0;
  font-weight: 600;
}

#break-warning {
  color: var(--error-color) !important;
}

#total-trip-time {
  color: var(--accent-color) !important;
  font-size: 1.5rem !important;
  font-weight: 700;
  margin-top: 1rem;
}

/* New styles for control buttons layout */
.control-buttons {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  width: 100%;
}

.control-buttons .button {
  flex: 1;
  border-radius: 12px;
}

.stop-button {
  background: var(--error-color);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15);
}

.stop-button:hover:not(:disabled) {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.reset-button {
  background: var(--warning-color);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
}

.reset-button:hover:not(:disabled) {
  background: #d97706;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.reset-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .header {
    padding: 2rem 1rem;
  }

  .header h1 {
    font-size: 1.75rem;
  }

  .header p {
    font-size: 0.95rem;
  }

  .segment {
    padding: 1.25rem;
  }

  .timer {
    font-size: 1.75rem;
  }

  .menu-buttons,
  #highway-buttons {
    padding: 2rem 1rem;
  }
}
