/* =================================
   RESET & BASE STYLES
   ================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Add smooth scrolling and better mobile handling */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

/* =================================
   CSS VARIABLES
   ================================= */
:root {
  /* Light Theme - Improved Color Scheme */
  --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  --container-bg: rgba(255, 255, 255, 0.15);
  --tile-border: rgba(255, 255, 255, 0.4);
  --tile-bg: rgba(255, 255, 255, 0.2);
  --key-bg: rgba(255, 255, 255, 0.25);
  
  /* Dark Theme */
  --dark-bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  --dark-container-bg: rgba(0, 0, 0, 0.2);
  --dark-tile-border: rgba(255, 255, 255, 0.2);
  --dark-key-bg: rgba(255, 255, 255, 0.1);
  
  /* State Colors - Enhanced for Light Mode */
  --correct-bg: linear-gradient(135deg, #28a745, #20c997);
  --present-bg: linear-gradient(135deg, #ffc107, #fd7e14);
  --absent-bg: linear-gradient(135deg, #6c757d, #495057);
  --dark-correct-bg: linear-gradient(135deg, #2e7d32, #388e3c);
  --dark-present-bg: linear-gradient(135deg, #f57c00, #ff9800);
  --dark-absent-bg: linear-gradient(135deg, #424242, #616161);
  
  /* Common */
  --white: #fff;
  --text-shadow: rgba(0, 0, 0, 0.2);
  --shadow: rgba(0, 0, 0, 0.15);
  
  /* Mobile optimizations */
  --mobile-touch-target: 44px;
  --mobile-padding: 10px;
  
  /* GAME SIZE CONTROL - Change this to scale the entire game */
  --game-scale: 0.8; /* Change this: 0.7 = 70%, 0.8 = 80%, 0.9 = 90%, 1.0 = 100%, 1.2 = 120% */
}

/* =================================
   LAYOUT & TYPOGRAPHY
   ================================= */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-gradient);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 15px;
  transition: background 0.3s ease;
  /* Mobile optimizations */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.game-container {
  background: var(--container-bg);
  backdrop-filter: blur(25px);
  border-radius: 25px;
  padding: 30px;
  box-shadow: 0 25px 50px var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.3);
  max-width: 1200px;
  width: 90%;
  transition: all 0.3s ease;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: 
    "header header"
    "board right-panel";
  gap: 30px;
  /* Apply the scale transformation to resize everything */
  transform: scale(var(--game-scale));
  transform-origin: center center;
  margin: 0 auto;
}

/* =================================
   HEADER
   ================================= */
.header {
  grid-area: header;
  text-align: center;
}

.title {
  font-size: 2.8rem;
  font-weight: bold;
  color: var(--white);
  text-shadow: 0 3px 15px var(--text-shadow);
  margin-bottom: 8px;
  background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4, #feca57);
  background-size: 400% 400%;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientShift 4s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.1rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* =================================
   GAME BOARD & TILES
   ================================= */
.game-board {
  grid-area: board;
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 15px;
  padding: 30px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  backdrop-filter: blur(15px);
  justify-self: center;
  align-self: start;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 10px 20px rgba(0, 0, 0, 0.1);
}

.word-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 15px;
}

.letter-tile {
  width: 65px;
  height: 65px;
  border: 2px solid var(--tile-border);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--white);
  background: var(--tile-bg);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.letter-tile.filled {
  border-color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.letter-tile.correct { 
  background: var(--correct-bg); 
  border-color: #28a745; 
  animation: tileFlip 0.6s ease-in-out; 
  box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.letter-tile.present { 
  background: var(--present-bg); 
  border-color: #ffc107; 
  animation: tileFlip 0.6s ease-in-out; 
  box-shadow: 0 4px 15px rgba(255, 193, 7, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.letter-tile.absent { 
  background: var(--absent-bg); 
  border-color: #6c757d; 
  animation: tileFlip 0.6s ease-in-out; 
  box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* =================================
   RIGHT PANEL
   ================================= */
.right-panel {
  grid-area: right-panel;
  display: flex;
  flex-direction: column;
  gap: 25px;
}

/* =================================
   STATS
   ================================= */
.stats {
  display: flex;
  justify-content: space-around;
  padding: 25px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  backdrop-filter: blur(15px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat {
  text-align: center;
  color: var(--white);
}

.stat-number {
  font-size: 2rem;
  font-weight: bold;
  display: block;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.9;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* =================================
   KEYBOARD
   ================================= */
.keyboard {
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: 10px;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.key {
  min-width: 45px;
  height: 55px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 10px;
  background: var(--key-bg);
  color: var(--white);
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(15px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  /* Mobile optimizations */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.key:hover, .key:focus {
  background: rgba(255, 255, 255, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  outline: none;
  border-color: rgba(255, 255, 255, 0.5);
}

.key:active {
  transform: translateY(0);
  transition: transform 0.1s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.key.wide { min-width: 70px; font-size: 0.85rem; }
.key.correct { 
  background: var(--correct-bg); 
  border-color: #28a745;
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.key.present { 
  background: var(--present-bg); 
  border-color: #ffc107;
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.key.absent { 
  background: var(--absent-bg); 
  opacity: 0.7;
  color: rgba(255, 255, 255, 0.8);
  border-color: #6c757d;
  box-shadow: 0 2px 6px rgba(108, 117, 125, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* =================================
   CONTROLS
   ================================= */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.message {
  padding: 15px;
  border-radius: 12px;
  text-align: center;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  font-size: 1rem;
  min-height: 60px;
  margin-top: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255,255,255,0) 30%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0) 70%);
  transform: translateX(-100%);
}

.message.show { 
  opacity: 1; 
  transform: translateY(0); 
}

.message.show::before { 
  animation: shimmer 2s infinite; 
}

.message.info { 
  background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%); 
  color: #2c2c54; 
  border: 1px solid rgba(142, 197, 252, 0.5); 
}

.message.win { 
  background: linear-gradient(135deg, #b8e994 0%, #78e08f 100%); 
  color: #1e4620; 
  border: 1px solid rgba(120, 224, 143, 0.5); 
}

.message.lose { 
  background: linear-gradient(135deg, #ff9a9e 0%, #f78ca0 100%); 
  color: #6a1b21; 
  border: 1px solid rgba(247, 140, 160, 0.5); 
}

.message.info::after {
  content: '💡';
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 1.2rem;
  opacity: 0.7;
}

/* =================================
   BUTTONS
   ================================= */
.btn {
  padding: 15px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
  color: var(--white);
  background: linear-gradient(135deg, #8a5cf7, #6c5ce7);
  border-color: #5a49d1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  /* Mobile optimizations */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: var(--mobile-touch-target);
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.15);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn:hover, .btn:focus { 
  transform: translateY(-2px); 
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  outline: none;
}
.btn:hover::before { opacity: 1; }
.btn:hover { background: linear-gradient(135deg, #9d74ff, #7d6df8); }
.btn:active { 
  transform: translateY(1px); 
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.2); 
}

/* Button Variants - Enhanced for Light Mode */
.new-game-btn { 
  background: linear-gradient(135deg, #ff6b6b, #f53b57); 
  border-color: #e84545; 
  box-shadow: 0 4px 12px rgba(245, 59, 87, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.new-game-btn:hover { 
  background: linear-gradient(135deg, #ff8383, #ff6b8b); 
  box-shadow: 0 6px 16px rgba(245, 59, 87, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.hint-btn { 
  background: linear-gradient(135deg, #ffc107, #fd7e14); 
  border-color: #fd7e14; 
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.hint-btn:hover { 
  background: linear-gradient(135deg, #ffcd39, #ff922b); 
  box-shadow: 0 6px 16px rgba(255, 193, 7, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.sound-btn { 
  background: linear-gradient(135deg, #17a2b8, #007bff); 
  color: #fff; 
  border-color: #007bff; 
  box-shadow: 0 4px 12px rgba(23, 162, 184, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.sound-btn:hover {
  background: linear-gradient(135deg, #20c0d7, #0056b3);
  box-shadow: 0 6px 16px rgba(23, 162, 184, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.theme-btn { 
  background: linear-gradient(135deg, #a55eea, #6c5ce7); 
  border-color: #8854d0; 
  box-shadow: 0 4px 12px rgba(165, 94, 234, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.theme-btn:hover {
  background: linear-gradient(135deg, #b370f0, #7d6df8);
  box-shadow: 0 6px 16px rgba(165, 94, 234, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* =================================
   CONFETTI
   ================================= */
.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  top: -20px;
  border-radius: 3px;
  animation: confettiFall ease-out forwards;
  z-index: 1000;
  pointer-events: none;
  opacity: 1;
}

@keyframes confettiFall {
  0% { 
    transform: translateY(-20px) rotate(0deg) scale(1); 
    opacity: 1; 
  }
  15% {
    opacity: 1;
    transform: translateY(10vh) rotate(180deg) scale(1.2);
  }
  85% {
    opacity: 0.9;
    transform: translateY(85vh) rotate(540deg) scale(0.8);
  }
  100% { 
    transform: translateY(100vh) rotate(720deg) scale(0.5); 
    opacity: 0; 
  }
}

.confetti:nth-child(odd) {
  border-radius: 50%;
}

.confetti:nth-child(3n) {
  width: 8px;
  height: 12px;
  border-radius: 2px;
}

.confetti:nth-child(4n) {
  width: 12px;
  height: 8px;
  border-radius: 6px;
}

/* =================================
   DARK THEME
   ================================= */
body.dark-theme {
  background: var(--dark-bg-gradient);
}

body.dark-theme .game-container {
  background: var(--dark-container-bg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-theme .letter-tile {
  border-color: var(--dark-tile-border);
  background: rgba(255, 255, 255, 0.05);
}

body.dark-theme .letter-tile.correct {
  background: var(--dark-correct-bg);
  border-color: #43a047;
  color: #e8f5e9;
  box-shadow: 0 0 10px rgba(67, 160, 71, 0.5);
}

body.dark-theme .letter-tile.present {
  background: var(--dark-present-bg);
  border-color: #ffb74d;
  color: #fff3e0;
  box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
}

body.dark-theme .letter-tile.absent {
  background: var(--dark-absent-bg);
  border-color: #757575;
  color: #eeeeee;
  box-shadow: 0 0 5px rgba(117, 117, 117, 0.3);
}

body.dark-theme .key {
  background: var(--dark-key-bg);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

body.dark-theme .key:hover,
body.dark-theme .key:focus {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

/* Fixed dark mode keyboard colors */
body.dark-theme .key.correct { 
  background: var(--dark-correct-bg); 
  border-color: #43a047;
  color: #e8f5e9;
}

body.dark-theme .key.present { 
  background: var(--dark-present-bg); 
  border-color: #ffb74d;
  color: #fff3e0;
}

body.dark-theme .key.absent { 
  background: var(--dark-absent-bg); 
  border-color: #424242;
  color: rgba(255, 255, 255, 0.4);
  opacity: 0.5;
}

body.dark-theme .btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

body.dark-theme .btn:hover,
body.dark-theme .btn:focus {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: none;
  transform: translateY(-1px);
}

/* Dark Button Variants */
body.dark-theme .new-game-btn { background: rgba(244, 67, 54, 0.2); border-color: rgba(244, 67, 54, 0.4); color: #ff5252; }
body.dark-theme .new-game-btn:hover { background: rgba(244, 67, 54, 0.3); }
body.dark-theme .hint-btn { background: rgba(255, 193, 7, 0.2); border-color: rgba(255, 193, 7, 0.4); color: #ffc107; }
body.dark-theme .hint-btn:hover { background: rgba(255, 193, 7, 0.3); }
body.dark-theme .sound-btn { background: rgba(3, 169, 244, 0.2); border-color: rgba(3, 169, 244, 0.4); color: #03a9f4; }
body.dark-theme .theme-btn { background: rgba(156, 39, 176, 0.2); border-color: rgba(156, 39, 176, 0.4); color: #ba68c8; }

/* Dark Message Variants */
body.dark-theme .message.info {
  background: linear-gradient(135deg, #2c2c54 0%, #474787 100%);
  color: #a5b1c2;
  border: 1px solid rgba(75, 75, 126, 0.5);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

body.dark-theme .message.info::after { opacity: 0.8; }
body.dark-theme .message.win { background: linear-gradient(135deg, #1e4620 0%, #2f7336 100%); color: #b8e994; border: 1px solid rgba(40, 114, 51, 0.5); }
body.dark-theme .message.lose { background: linear-gradient(135deg, #6a1b21 0%, #8c2f39 100%); color: #ff9a9e; border: 1px solid rgba(138, 43, 57, 0.5); }

/* =================================
   ANIMATIONS
   ================================= */
@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  25% { background-position: 100% 50%; }
  50% { background-position: 50% 100%; }
  75% { background-position: 100% 0%; }
}

@keyframes tileFlip {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1) rotateY(180deg); }
}

@keyframes shimmer {
  100% { transform: translateX(100%); }
}

/* =================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ================================= */

/* Tablet Landscape */
@media (max-width: 1024px) {
  :root {
    --game-scale: 0.9;
  }
  
  .game-container {
    grid-template-columns: 1fr;
    grid-template-areas: 
      "header"
      "board"
      "right-panel";
    max-width: 600px;
    gap: 20px;
    width: 95%;
  }
  
  .letter-tile { width: 55px; height: 55px; font-size: 1.5rem; }
  .key { min-width: 40px; height: 50px; font-size: 0.95rem; }
}

/* Tablet Portrait & Large Phones */
@media (max-width: 768px) {
  :root {
    --game-scale: 1.0;
  }
  
  body {
    padding: 8px;
    align-items: flex-start;
  }
  
  .game-container {
    transform: none;
    width: 100%;
    max-width: none;
    padding: 12px;
    border-radius: 15px;
    gap: 12px;
    margin-top: 5px;
  }
  
  .title { 
    font-size: 2rem;
    margin-bottom: 5px;
  }
  
  .subtitle { 
    font-size: 0.9rem;
  }
  
  .game-board {
    padding: 15px;
    gap: 8px;
  }
  
  .word-row {
    gap: 8px;
  }
  
  .letter-tile { 
    width: 50px; 
    height: 50px; 
    font-size: 1.3rem;
    border-radius: 8px;
  }
  
  .keyboard {
    gap: 6px;
  }
  
  .keyboard-row {
    gap: 4px;
  }
  
  .key { 
    min-width: 35px; 
    height: 44px; 
    font-size: 0.85rem;
    border-radius: 6px;
  }
  
  .key.wide { 
    min-width: 55px; 
    font-size: 0.75rem; 
  }
  
  .controls { 
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  
  .btn {
    padding: 10px 12px;
    font-size: 0.8rem;
    min-height: 40px;
  }
  
  .stats {
    padding: 12px;
    flex-direction: row;
  }
  
  .stat-number {
    font-size: 1.4rem;
  }
  
  .stat-label {
    font-size: 0.75rem;
  }
  
  .message {
    font-size: 0.85rem;
    padding: 10px;
    min-height: 45px;
    margin-top: 8px;
  }
}

/* Mobile Phones */
@media (max-width: 480px) {
  :root {
    --game-scale: 1.0;
  }
  
  body {
    padding: 5px;
  }
  
  .game-container {
    transform: none;
    padding: 8px;
    gap: 8px;
    border-radius: 12px;
  }
  
  .title { 
    font-size: 1.6rem;
    margin-bottom: 3px;
  }
  
  .subtitle { 
    font-size: 0.8rem;
  }
  
  .game-board {
    padding: 8px;
    gap: 5px;
  }
  
  .word-row {
    gap: 5px;
  }
  
  .letter-tile { 
    width: 42px; 
    height: 42px; 
    font-size: 1.1rem;
    border-radius: 6px;
  }
  
  .keyboard {
    gap: 4px;
  }
  
  .keyboard-row {
    gap: 3px;
  }
  
  .key { 
    min-width: 28px; 
    height: 38px; 
    font-size: 0.75rem;
    border-radius: 5px;
  }
  
  .key.wide { 
    min-width: 42px; 
    font-size: 0.65rem; 
  }
  
  .controls { 
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  
  .btn {
    padding: 8px 10px;
    font-size: 0.7rem;
    border-radius: 8px;
    min-height: 36px;
  }
  
  .stats {
    padding: 8px;
    flex-direction: row;
    gap: 5px;
  }
  
  .stat {
    flex: 1;
  }
  
  .stat-number {
    font-size: 1.2rem;
  }
  
  .stat-label {
    font-size: 0.65rem;
  }
  
  .message {
    font-size: 0.75rem;
    padding: 8px;
    min-height: 40px;
    margin-top: 6px;
  }
  
  .scoreboard {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    margin: 10px auto;
    max-width: 300px;
    width: 90%;
  }

  .score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 14px;
  }

  .score-value {
    font-weight: bold;
    min-width: 30px;
    text-align: right;
  }
}

/* Very Small Phones */
@media (max-width: 360px) {
  body {
    padding: 3px;
  }
  
  .game-container {
    padding: 6px;
    gap: 6px;
  }
  
  .title { 
    font-size: 1.4rem;
    margin-bottom: 2px;
  }
  
  .subtitle { 
    font-size: 0.7rem;
  }
  
  .game-board {
    padding: 6px;
    gap: 4px;
  }
  
  .word-row {
    gap: 4px;
  }
  
  .letter-tile { 
    width: 36px; 
    height: 36px; 
    font-size: 0.95rem;
    border-radius: 5px;
  }
  
  .keyboard {
    gap: 3px;
  }
  
  .keyboard-row {
    gap: 2px;
  }
  
  .key { 
    min-width: 24px; 
    height: 34px; 
    font-size: 0.65rem;
    border-radius: 4px;
  }
  
  .key.wide { 
    min-width: 36px; 
    font-size: 0.55rem; 
  }
  
  .controls { 
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }
  
  .btn {
    padding: 6px 8px;
    font-size: 0.65rem;
    border-radius: 8px;
    min-height: 32px;
  }
  
  .stats {
    padding: 6px;
    flex-direction: column;
    gap: 3px;
  }
  
  .stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .stat-number {
    font-size: 1rem;
  }
  
  .stat-label {
    font-size: 0.6rem;
  }
  
  .message {
    font-size: 0.7rem;
    padding: 6px;
    min-height: 35px;
  }
  
  .scoreboard {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    margin: 10px auto;
    max-width: 300px;
    width: 90%;
  }

  .score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 14px;
  }

  .score-value {
    font-weight: bold;
    min-width: 30px;
    text-align: right;
  }
}

/* Landscape orientation for phones */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    align-items: flex-start;
    padding: 3px;
  }
  
  .game-container {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: 
      "header header"
      "board right-panel";
    max-width: none;
    width: 100%;
    min-height: auto;
    padding: 6px;
    gap: 8px;
  }
  
  .header {
    margin-bottom: 0;
  }
  
  .title {
    font-size: 1.2rem;
    margin-bottom: 1px;
  }
  
  .subtitle {
    font-size: 0.65rem;
  }
  
  .game-board {
    padding: 6px;
    gap: 3px;
  }
  
  .word-row {
    gap: 3px;
  }
  
  .letter-tile {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
    border-radius: 4px;
  }
  
  .keyboard {
    gap: 2px;
  }
  
  .keyboard-row {
    gap: 1px;
  }
  
  .key {
    height: 26px;
    min-width: 20px;
    font-size: 0.55rem;
    border-radius: 3px;
  }
  
  .key.wide {
    min-width: 30px;
    font-size: 0.5rem;
  }
  
  .right-panel {
    gap: 6px;
  }
  
  .stats {
    padding: 4px;
    flex-direction: row;
    gap: 2px;
  }
  
  .stat-number {
    font-size: 0.9rem;
  }
  
  .stat-label {
    font-size: 0.5rem;
  }
  
  .controls {
    gap: 3px;
  }
  
  .btn {
    padding: 4px 6px;
    font-size: 0.6rem;
    min-height: 26px;
  }
  
  .message {
    font-size: 0.65rem;
    padding: 4px;
    min-height: 30px;
  }
}

/* Fix for iOS Safari viewport issues */
@supports (-webkit-touch-callout: none) {
  body {
    min-height: -webkit-fill-available;
  }
  
  .game-container {
    min-height: auto;
  }
}

/* Prevent zoom on input focus (iOS Safari) */
@media screen and (max-width: 768px) {
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="tel"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .letter-tile,
  .key,
  .btn {
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
}

/* =================================
   SCOREBOARD STYLES - HORIZONTAL & COMPACT
   ================================= */
.scoreboard {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 10px;
  margin: 8px auto;
  max-width: 400px;
  width: 95%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex: 1;
  min-height: 50px;
}

.score-label {
  font-weight: 700;
  font-size: 11px;
  opacity: 0.9;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.score-value {
  font-weight: 900;
  font-size: 18px;
  text-align: center;
  line-height: 1;
}

/* Dark theme - better visibility */
body.dark-theme .scoreboard {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

body.dark-theme .score-item {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Mobile optimizations */
@media (max-width: 480px) {
  .scoreboard {
    max-width: 95%;
    padding: 8px;
    gap: 6px;
    margin: 6px auto;
  }
  
  .score-item {
    padding: 6px 4px;
    min-height: 42px;
  }
  
  .score-label {
    font-size: 10px;
    font-weight: 800;
  }
  
  .score-value {
    font-size: 16px;
    font-weight: 900;
  }
}

/* Very small phones */
@media (max-width: 360px) {
  .scoreboard {
    padding: 6px;
    gap: 4px;
  }
  
  .score-item {
    padding: 5px 3px;
    min-height: 38px;
  }
  
  .score-label {
    font-size: 9px;
  }
  
  .score-value {
    font-size: 15px;
  }
}