html, body {
    height: 100%;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
  }

.container .correct {
    background-color: var(--correct-color);
    border: 2px solid transparent;
    color: white;
  }
  
  .container .found {
    background-color: var(--found-color);
    border: 2px solid transparent;
    color: white;
  }
  
  .container .wrong {
    background-color: var(--wrong-color);
    border: 2px solid transparent;
    color: white;
  }

  /* High Contrast Mode - Override colors for accessibility */
  /* Works in both light and dark mode */
  :root.high-contrast-mode .container .correct,
  :root.high-contrast-mode .key-guess.correct {
    background-color: #f5793a !important;
    color: white !important;
  }
  
  :root.high-contrast-mode .container .found,
  :root.high-contrast-mode .key-guess.found {
    background-color: #85c0f9 !important;
    color: white !important;
  }
  
  .key-guess {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
    border: 2px solid var(--border-color);
    height: clamp(50px, 8vw, 62px);
    width: clamp(50px, 8vw, 62px);
    min-height: 50px;
    min-width: 50px;
    max-height: 62px;
    max-width: 62px;
    vertical-align: top;
    color: #1a1a1b;
    margin: clamp(2px, 0.4vw, 3px);
    transition: border-color 0.1s ease, color 0.3s ease;
    font-size: clamp(28px, 4.5vw, 36px);
    font-weight: bold;
    box-sizing: border-box;
  }
  
  /* Chrome-specific fix to prevent oversized grid cells - force max size */
  @media screen and (-webkit-min-device-pixel-ratio: 0) {
    .key-guess {
      max-height: 62px !important;
      max-width: 62px !important;
    }
  }
  
  /* Safari-specific fixes - use more specific detection */
  @supports (-webkit-appearance: none) and (not (-webkit-min-device-pixel-ratio: 0)) {
    .key-guess {
      /* Ensure Safari respects max dimensions */
      max-height: 62px !important;
      max-width: 62px !important;
    }
  }
  

  /* Mobile base styles - override min dimensions */
  /* Use multiple breakpoints to catch all mobile devices - Updated for Wordle-style keyboard */
  @media (max-width: 1024px) and (orientation: portrait),
         (max-width: 768px),
         (max-device-width: 768px),
         (max-width: 480px),
         (max-device-width: 480px),
         screen and (max-width: 768px) {
    .key-guess {
      min-height: 35px !important;
      min-width: 35px !important;
    }
    
    /* Override ALL key styles for mobile - Wordle-style larger, readable keys - Target #keyboard */
    #keyboard .keyboard-row .key,
    #keyboard .keyboard-row button.key,
    #keyboard button.key,
    #keyboard .key {
      border: 1px solid #86888a !important;
      padding: 8px 6px !important;
      background-color: #d3d6da !important;
      color: #1a1a1b !important;
      font-size: 13px !important;
      font-weight: bold !important;
      height: 42px !important;
      width: 28px !important;
      min-width: 28px !important;
      max-width: 28px !important;
      margin: 0 !important;
      border-radius: 4px !important;
      box-sizing: border-box !important;
      flex: 0 0 28px !important;
    }
    
    #keyboard .keyboard-row .key#enter,
    #keyboard .keyboard-row .key[id="⌫"],
    #keyboard button#enter,
    #keyboard button[id="⌫"] {
      width: 45px !important; /* 1.5x wider */
      min-width: 45px !important;
      max-width: 45px !important;
      flex: 0 0 45px !important;
      font-size: 11px !important;
      padding: 8px 6px !important;
    }
    
    #keyboard {
      width: calc(100vw - 30px) !important; /* 15px margin on each side */
      max-width: calc(100vw - 30px) !important;
      min-width: 0 !important;
      gap: 6px !important;
      overflow: visible !important;
      margin-left: 15px !important;
      margin-right: 15px !important;
      position: relative !important;
    }
    
    #keyboard .keyboard-row {
      gap: 3px !important;
      padding: 0 !important;
      overflow: visible !important;
      width: 100% !important;
      justify-content: center !important;
    }
  }

  /* Dark mode: white letters */
  :root.dark-mode .key-guess {
    color: white;
  }
  
  /* Darker border when box has a letter (like Wordle) */
  .key-guess.filled {
    border-color: var(--border-dark);
  }
  
  .key-guess::before {
    content: '';
  }
  
  #keyboard {
    display: block;
    text-align: center;
    margin-top: clamp(15px, 2.5vh, 20px);
  }
  
  .key {
    font-weight: bold;
    font-size: clamp(14px, 2.2vw, 18px);
    text-transform: uppercase;
    border-radius: 4px;
    background-color: #d3d6da;
    border: 0;
    height: clamp(42px, 6.5vh, 58px);
    width: clamp(38px, 6vw, 43px);
    min-width: clamp(38px, 6vw, 43px);
    max-width: clamp(38px, 6vw, 43px);
    max-height: 58px; /* Ensure max height for Safari */
    margin: clamp(1.5px, 0.3vw, 2px);
    cursor: pointer;
    color: #1a1a1b;
    padding: clamp(6px, 1vh, 8px) clamp(4px, 0.8vw, 6px);
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Safari-specific: ensure proper rendering */
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Desktop-only: ensure .key styles only apply on desktop */
  @media (min-width: 769px) {
    .key {
      border: 0;
      padding: clamp(6px, 1vh, 8px) clamp(4px, 0.8vw, 6px);
      width: clamp(38px, 6vw, 43px);
      min-width: clamp(38px, 6vw, 43px);
      max-width: clamp(38px, 6vw, 43px);
      height: clamp(42px, 6.5vh, 58px);
    }
  }

  /* Dark mode: white keys with Carolina blue text.
     State classes (.key.correct/.found/.wrong) defined below will override these. */
  :root.dark-mode .key {
    background-color: white;
    color: #7BAFD4;
  }

  /* Keyboard key colors */
  .key.correct {
    background-color: var(--correct-color);
    color: white;
    width: clamp(38px, 6vw, 43px);
    min-width: clamp(38px, 6vw, 43px);
    max-width: clamp(38px, 6vw, 43px);
    height: clamp(42px, 6.5vh, 58px);
  }
  
  .key.found {
    background-color: var(--found-color);
    color: white;
    width: clamp(38px, 6vw, 43px);
    min-width: clamp(38px, 6vw, 43px);
    max-width: clamp(38px, 6vw, 43px);
    height: clamp(42px, 6.5vh, 58px);
  }
  
  .key.wrong {
    background-color: var(--wrong-color);
    color: white;
    width: clamp(38px, 6vw, 43px);
    min-width: clamp(38px, 6vw, 43px);
    max-width: clamp(38px, 6vw, 43px);
    height: clamp(42px, 6.5vh, 58px);
  }

  /* Ensure dark-mode keys also pick up the state colors (override base white keys) */
  :root.dark-mode .key.correct {
    background-color: var(--correct-color);
    color: white;
    width: clamp(38px, 6vw, 43px);
    min-width: clamp(38px, 6vw, 43px);
    max-width: clamp(38px, 6vw, 43px);
    height: clamp(42px, 6.5vh, 58px);
  }

  :root.dark-mode .key.found {
    background-color: var(--found-color);
    color: white;
    width: clamp(38px, 6vw, 43px);
    min-width: clamp(38px, 6vw, 43px);
    max-width: clamp(38px, 6vw, 43px);
    height: clamp(42px, 6.5vh, 58px);
  }

  :root.dark-mode .key.wrong {
    background-color: var(--wrong-color);
    color: white;
    width: clamp(38px, 6vw, 43px);
    min-width: clamp(38px, 6vw, 43px);
    max-width: clamp(38px, 6vw, 43px);
    height: clamp(42px, 6.5vh, 58px);
  }

  /* High Contrast Mode - Keyboard keys match grid colors */
  /* These must come after dark mode rules to override them */
  :root.high-contrast-mode .key.correct,
  :root.dark-mode.high-contrast-mode .key.correct {
    background-color: #f5793a !important;
    color: white !important;
    width: clamp(38px, 6vw, 43px) !important;
    min-width: clamp(38px, 6vw, 43px) !important;
    max-width: clamp(38px, 6vw, 43px) !important;
    height: clamp(42px, 6.5vh, 58px) !important;
  }

  :root.high-contrast-mode .key.found,
  :root.dark-mode.high-contrast-mode .key.found {
    background-color: #85c0f9 !important;
    color: white !important;
    width: clamp(38px, 6vw, 43px) !important;
    min-width: clamp(38px, 6vw, 43px) !important;
    max-width: clamp(38px, 6vw, 43px) !important;
    height: clamp(42px, 6.5vh, 58px) !important;
  }

  :root.high-contrast-mode .key.wrong,
  :root.dark-mode.high-contrast-mode .key.wrong {
    background-color: var(--wrong-color) !important;
    color: white !important;
    width: clamp(38px, 6vw, 43px) !important;
    min-width: clamp(38px, 6vw, 43px) !important;
    max-width: clamp(38px, 6vw, 43px) !important;
    height: clamp(42px, 6.5vh, 58px) !important;
  }
  
  #enter{
    width: clamp(76px, 12vw, 90px);
    min-width: clamp(76px, 12vw, 90px);
    max-width: clamp(76px, 12vw, 90px);
    height: clamp(42px, 6.5vh, 58px);
  }

  /* Shake animation for invalid words */
  .shake {
    animation: shake 0.5s ease-in-out;
    /* Safari-specific: ensure transforms work */
    -webkit-animation: shake 0.5s ease-in-out;
  }

  @keyframes shake {
    0%, 100% { 
      transform: translateX(0);
      -webkit-transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% { 
      transform: translateX(-5px);
      -webkit-transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% { 
      transform: translateX(5px);
      -webkit-transform: translateX(5px);
    }
  }
  
  @-webkit-keyframes shake {
    0%, 100% { -webkit-transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { -webkit-transform: translateX(-5px); }
    20%, 40%, 60%, 80% { -webkit-transform: translateX(5px); }
  }

  /* Flip animation for revealing colors */
  .flip {
    animation: flip 0.8s ease-in-out;
    /* Safari-specific: ensure 3D transforms work */
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }

  @keyframes flip {
    0% { 
      transform: rotateX(0);
      -webkit-transform: rotateX(0);
    }
    50% { 
      transform: rotateX(-90deg);
      -webkit-transform: rotateX(-90deg);
    }
    100% { 
      transform: rotateX(0);
      -webkit-transform: rotateX(0);
    }
  }

  /* Ensure the grid has perspective for 3D flip effect */
  .grid {
    perspective: 1000px;
    -webkit-perspective: 1000px;
  }

  
