:root {
  --primary: #0f62fe;
  --hover: #0056b3;
  --bg-light: #f4f4f4;
  --bg-dark: #121212;
  --white: #ffffff;
  --text-dark: #333;
  --text-light: #666;
  --green: #4caf50;
  --red: #f44336;
}

/* Dark mode overrides */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-light: #1e1e1e; /* lighter dark bg for sections */
    --white: #ffffff;     /* keep white consistent */
    --text-dark: #e0e0e0;
    --text-light: #aaa;
  }

  /* Dark mode backgrounds */
  nav {
    background: var(--bg-dark);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
  }

  .hero,
  #whiteboard,
  .feature {
    background: var(--bg-light);
  }

  header,
  footer {
    background: #0a47c1;
  }

  /* Text and link colors */
  nav a,
  .hero,
  .feature h3,
  .feature p {
    color: var(--text-dark);
  }

  /* Text box tweaks */
  .text-box {
    background: rgba(30, 30, 30, 0.8);
    border-color: var(--text-light);
    color: var(--text-light);
  }

  /* Meme border */
  .meme {
    border-color: var(--text-light);
  }

  /* Ticker dark mode */
  .ticker-wrapper {
    background: var(--bg-dark);
    color: var(--text-light);
  }

  /* Text options */
  #textOptions {
    background: var(--bg-light);
    border-color: var(--text-light);
    color: var(--text-light);
  }

  .text-option-label,
  .checkbox-group label {
    color: var(--text-light);
  }

  .text-option-input {
    background: var(--bg-dark);
    border-color: var(--text-light);
    color: var(--text-light);
  }

  .text-option-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 4px var(--primary);
  }
}

/* Base styles */
html {
  font-size: 16px;
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg-light);
  color: var(--text-dark);
}

.wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Screen Reader Only Label - improved */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Hidden class for toggling */
.hidden {
  display: none !important;
}

/* Ticker */
.ticker-wrapper {
  background: #222;
  color: white;
  overflow: hidden;
  white-space: nowrap;
  width: 100%;
  padding: 10px 0;
}

.ticker {
  display: inline-block;
  animation: scroll 15s linear infinite;
  will-change: transform;
}

.ticker span {
  margin: 0 30px;
  font-weight: bold;
}

.price-up {
  color: var(--green);
}

.price-down {
  color: var(--red);
}

@keyframes scroll {
  0% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* Header */
header {
  background: var(--primary);
  color: var(--white);
  padding: 20px 0;
  text-align: center;
}

/* Navigation */
nav {
  background: var(--white);
  display: flex;
  justify-content: center;
  gap: 30px;
  padding: 15px 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

nav a {
  color: var(--primary);
  text-decoration: none;
  font-weight: bold;
  transition: color 0.3s ease, text-decoration 0.2s ease;
}

nav a:hover,
nav a:focus-visible {
  text-decoration: underline;
  outline: none;
}

/* Add focus style for keyboard users on upload-label */
.upload-label:focus-visible {
  outline: 2px dashed var(--primary);
  outline-offset: 2px;
}

/* Hero Section */
.hero {
  text-align: center;
  padding: 80px 20px;
  background: var(--white);
}

.hero h1,
.hero h2 {
  font-size: clamp(2rem, 6vw, 3rem);
  margin-bottom: 20px;
}

.hero p {
  font-size: clamp(1rem, 2vw, 1.25rem);
  margin-bottom: 40px;
}

/* Buttons */
.tool-btn {
  display: inline-block;
  margin: 10px 8px;
  padding: 10px 16px;
  font-weight: bold;
  border: none;
  border-radius: 5px;
  background-color: var(--primary);
  color: var(--white);
  cursor: pointer;
  transition: background 0.3s ease;
}

.tool-btn:hover,
.tool-btn:focus-visible {
  background-color: var(--hover);
  outline: 2px dashed var(--primary);
  outline-offset: 2px;
}

.tool-btn:disabled {
  background-color: #999;
  cursor: not-allowed;
  opacity: 0.6;
  pointer-events: none;
}

/* Canvas Area */
#whiteboard {
  width: 90vw;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  margin: 20px auto;
  background: var(--white);
  border: 2px solid var(--text-dark);
  position: relative;
  overflow: hidden;
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Text box style */
#textOptions {
  border: 1px solid var(--text-light);
  border-radius: 6px;
  padding: 12px 16px;
  background: var(--bg-light);
  max-width: 400px;
  margin: 1rem auto 0 auto;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

#textOptions legend {
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.text-options-row {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.text-option-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-dark);
}

.text-option-input {
  padding: 4px 6px;
  font-size: 1rem;
  border: 1px solid var(--text-light);
  border-radius: 4px;
  width: 70px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.text-option-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 4px var(--primary);
}

.color-input {
  width: 40px;
  height: 30px;
  padding: 0;
  border-radius: 4px;
  cursor: pointer;
}

.checkbox-group label {
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  color: var(--text-dark);
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* Meme image styling */
.meme {
  position: absolute;
  cursor: move;
  max-width: 150px;
  max-height: 150px;
  border: 1px solid #ccc;
  border-radius: 6px;
  transition: transform 0.2s ease;
  background-color: transparent;
}

.meme:hover {
  transform: scale(1.03);
  cursor: grab;
}

.meme:active {
  cursor: grabbing;
}

/* Footer */
footer {
  background: var(--primary);
  color: var(--white);
  text-align: center;
  padding: 20px 0;
}

/* Mobile */
@media (max-width: 768px) {
  .features {
    padding: 30px 20px;
    gap: 20px;
  }

  #whiteboard {
    aspect-ratio: 4 / 3;
  }

  .tool-btn {
    width: 90%;
    margin: 10px auto;
    display: block;
  }
}