* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background: linear-gradient(180deg, #8B5CF6 0%, #6366F1 30%, #06B6D4 70%, #14B8A6 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  color: #1f2937;
  overflow: hidden;
  position: relative;
}

/* Geometric floating shapes */
body::before,
body::after {
  content: '';
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 200px;
  height: 200px;
  border: 30px solid rgba(236, 72, 153, 0.3);
  border-radius: 50%;
  bottom: 10%;
  left: 5%;
  animation: float 8s ease-in-out infinite;
}

body::after {
  width: 0;
  height: 0;
  border-left: 100px solid transparent;
  border-right: 100px solid transparent;
  border-bottom: 150px solid rgba(96, 165, 250, 0.3);
  top: 10%;
  left: 10%;
  animation: float 10s ease-in-out infinite reverse;
}

.geometric-shape {
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.shape-triangle-1 {
  width: 0;
  height: 0;
  border-left: 80px solid transparent;
  border-right: 80px solid transparent;
  border-bottom: 120px solid rgba(20, 184, 166, 0.4);
  top: 15%;
  right: 8%;
  animation: float 12s ease-in-out infinite;
  transform: rotate(45deg);
}

.shape-triangle-2 {
  width: 0;
  height: 0;
  border-left: 60px solid transparent;
  border-right: 60px solid transparent;
  border-bottom: 90px solid rgba(244, 114, 182, 0.4);
  bottom: 20%;
  right: 15%;
  animation: float 9s ease-in-out infinite reverse;
  transform: rotate(-20deg);
}

.shape-circle {
  width: 80px;
  height: 80px;
  border: 20px solid rgba(147, 197, 253, 0.4);
  border-radius: 50%;
  top: 60%;
  left: 8%;
  animation: float 11s ease-in-out infinite;
}

.shape-sparkle {
  width: 40px;
  height: 40px;
  background: linear-gradient(45deg, rgba(255,255,255,0.6), transparent);
  transform: rotate(45deg);
  top: 80%;
  right: 20%;
  animation: sparkle 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-30px) rotate(10deg); }
}

@keyframes sparkle {
  0%, 100% { opacity: 0.3; transform: rotate(45deg) scale(1); }
  50% { opacity: 0.8; transform: rotate(45deg) scale(1.2); }
}

.lang-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-radius: 30px;
  padding: 6px;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.lang-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 25px;
  background: transparent;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lang-btn.active {
  background: white;
  color: #8B5CF6;
}

.screen {
  display: none;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border-radius: 32px;
  padding: 40px 32px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.2);
  animation: slideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin: auto;
  position: relative;
  z-index: 1;
}

.screen.active {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

#game-screen.active {
  display: flex !important;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
}

#game-screen {
  max-width: 600px;
  max-height: 90vh;
  padding: 24px;
  overflow: hidden;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.title {
  font-size: 64px;
  font-weight: 900;
  color: white;
  margin-bottom: 12px;
  text-align: center;
  letter-spacing: -2px;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 
    -4px -4px 0 #06B6D4,
    4px 4px 0 #EC4899,
    0 0 40px rgba(6, 182, 212, 0.5),
    0 0 80px rgba(236, 72, 153, 0.3);
}

.subtitle {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  margin-bottom: 32px;
  font-weight: 400;
  line-height: 1.6;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.btn-primary,
.btn-secondary {
  padding: 18px 48px;
  border: none;
  border-radius: 50px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  margin: 10px;
  font-family: 'Poppins', sans-serif;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(90deg, #FF9A56 0%, #FF6B9D 50%, #EC4899 100%);
  color: white;
  box-shadow: 0 8px 24px rgba(236, 72, 153, 0.4), 0 0 40px rgba(255, 107, 157, 0.3);
}

.btn-primary:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(236, 72, 153, 0.5), 0 0 60px rgba(255, 107, 157, 0.4);
}

.btn-primary:active {
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.instructions {
  margin-top: 30px;
  text-align: left;
  width: 100%;
}

.instructions h3 {
  color: white;
  margin-bottom: 15px;
  font-size: 22px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.instructions ul {
  list-style: none;
  padding: 0;
}

.instructions li {
  padding: 14px 18px;
  margin: 10px 0;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  font-size: 16px;
  border-left: 4px solid #06B6D4;
  transition: all 0.3s;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.instructions li:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateX(8px);
  border-left-color: #EC4899;
}

.instructions li:before {
  content: '✓ ';
  color: #06B6D4;
  font-weight: bold;
  margin-right: 8px;
  font-size: 18px;
}

.screen-title {
  font-size: 40px;
  font-weight: 800;
  color: white;
  margin-bottom: 30px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: -1px;
  text-shadow: 
    -2px -2px 0 #06B6D4,
    2px 2px 0 #EC4899,
    0 0 30px rgba(6, 182, 212, 0.4);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  width: 100%;
  margin-bottom: 24px;
  max-width: 100%;
}

.category-card {
  padding: 32px 24px;
  border-radius: 24px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: 'Poppins', sans-serif;
  color: white;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  letter-spacing: 0.3px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.category-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
  opacity: 0;
  transition: opacity 0.3s;
}

.category-card:hover::before {
  opacity: 1;
}

.category-card:hover {
  transform: translateY(-12px) scale(1.05);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 15px;
  font-size: 20px;
  font-weight: bold;
  flex-shrink: 0;
  position: relative;
}

.timer {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  min-width: 80px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
  font-weight: 700;
  border: 3px solid rgba(255, 255, 255, 0.3);
}

.timer.warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
  animation: pulse 1s infinite;
}

.timer.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
  animation: pulse 0.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.score {
  background: linear-gradient(135deg, #8B5CF6, #6366F1);
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
  font-weight: 700;
  border: 3px solid rgba(255, 255, 255, 0.3);
}

.menu-btn {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  font-size: 24px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateX(-50%) scale(1.1);
}

.game-menu {
  position: absolute;
  top: 55px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  padding: 10px;
  z-index: 100;
  min-width: 220px;
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.game-menu.hidden {
  display: none;
}

.menu-option {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 16px;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
  transition: all 0.3s;
  text-align: left;
  margin: 4px 0;
  color: #1f2937;
}

.menu-option:hover {
  background: linear-gradient(90deg, #FF9A56, #FF6B9D);
  color: white;
  transform: translateX(5px);
}

.card-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 10px 0;
  min-height: 0;
}

.card {
  background: linear-gradient(135deg, #8B5CF6 0%, #6366F1 50%, #06B6D4 100%);
  color: white;
  padding: 48px 40px;
  border-radius: 32px;
  width: 100%;
  height: 100%;
  max-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 50px rgba(99, 102, 241, 0.5), 0 0 0 4px rgba(255, 255, 255, 0.3);
  animation: cardFlip 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.3);
}

.card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 70%);
  animation: shimmer 4s infinite;
}

@keyframes shimmer {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(15%, 15%); }
}

@keyframes cardFlip {
  0% { transform: rotateY(90deg); opacity: 0; }
  100% { transform: rotateY(0); opacity: 1; }
}

.card-word {
  font-size: 52px;
  font-weight: 900;
  text-align: center;
  word-wrap: break-word;
  text-shadow: 
    -3px -3px 0 #06B6D4,
    3px 3px 0 #EC4899,
    0 0 30px rgba(255, 255, 255, 0.5);
  letter-spacing: 1px;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.tilt-instructions {
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin-top: 10px;
  flex-shrink: 0;
}

.tilt-hint {
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.tilt-up {
  color: #10b981;
}

.tilt-down {
  color: #ef4444;
}

.congrats {
  font-size: 42px;
  font-weight: 800;
  color: white;
  margin-bottom: 20px;
  text-transform: uppercase;
  text-shadow: 
    -2px -2px 0 #06B6D4,
    2px 2px 0 #EC4899,
    0 0 30px rgba(6, 182, 212, 0.5);
}

.final-score {
  text-align: center;
  margin-bottom: 30px;
}

.score-number {
  font-size: 80px;
  font-weight: 900;
  background: linear-gradient(135deg, #FF9A56, #FF6B9D, #EC4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  text-shadow: 0 4px 20px rgba(236, 72, 153, 0.4);
}

.final-score p {
  font-size: 22px;
  color: white;
  margin-top: 10px;
  font-weight: 600;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.results-list {
  width: 100%;
  margin-bottom: 20px;
  max-height: 200px;
  overflow-y: auto;
}

.results-list h3 {
  color: white;
  margin-bottom: 10px;
  font-size: 20px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.result-item {
  padding: 10px 14px;
  margin: 6px 0;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.result-item.correct {
  background: rgba(16, 185, 129, 0.3);
  color: white;
  border: 2px solid rgba(16, 185, 129, 0.5);
}

.result-item.passed {
  background: rgba(239, 68, 68, 0.3);
  color: white;
  border: 2px solid rgba(239, 68, 68, 0.5);
}

.back-btn {
  margin-top: 20px;
}

.settings-group {
  width: 100%;
  margin: 25px 0;
  text-align: left;
}

.settings-group label {
  display: block;
  font-size: 19px;
  font-weight: 700;
  color: white;
  margin-bottom: 12px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 15px;
}

.slider-container input[type="range"] {
  flex: 1;
  height: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.3);
  outline: none;
  -webkit-appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF9A56, #EC4899);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.5);
  border: 3px solid white;
}

.slider-container input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF9A56, #EC4899);
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.5);
}

.slider-container span {
  font-size: 26px;
  font-weight: 800;
  color: white;
  min-width: 70px;
  text-align: right;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Landscape optimization */
@media (orientation: landscape) {
  .screen {
    max-width: 95vw;
    padding: 20px 32px;
    max-height: 92vh;
  }
  
  .category-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
  }
  
  .title {
    font-size: 48px;
    margin-bottom: 16px;
  }
  
  .subtitle {
    font-size: 16px;
    margin-bottom: 20px;
  }
}

/* Short landscape screens (phones) */
@media (orientation: landscape) and (max-height: 600px) {
  .screen {
    padding: 16px 24px;
    max-height: 95vh;
    overflow-y: auto;
  }
  
  #game-screen {
    padding: 12px;
    max-height: 95vh;
  }
  
  .title {
    font-size: 36px;
    margin-bottom: 8px;
  }
  
  .subtitle {
    font-size: 14px;
    margin-bottom: 16px;
  }
  
  .instructions {
    margin-top: 12px;
  }
  
  .instructions li {
    padding: 8px 12px;
    margin: 5px 0;
    font-size: 13px;
  }
  
  .game-header {
    font-size: 16px;
    margin-bottom: 8px;
  }
  
  .timer, .score {
    padding: 8px 16px;
    font-size: 15px;
  }
  
  .card {
    padding: 24px 28px;
    max-height: 250px;
  }
  
  .card-word {
    font-size: 36px;
  }
  
  .tilt-instructions {
    margin-top: 8px;
  }
  
  .tilt-hint {
    font-size: 14px;
  }
  
  .category-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
  }
  
  .category-card {
    padding: 20px 16px;
    font-size: 15px;
  }
  
  .btn-primary,
  .btn-secondary {
    padding: 12px 28px;
    font-size: 16px;
  }
}

/* Tablet and larger (portrait) */
@media (min-width: 768px) and (orientation: portrait) {
  .category-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
  }
  
  .category-card {
    padding: 36px 24px;
    font-size: 18px;
  }
  
  .title {
    font-size: 72px;
  }
  
  .card-word {
    font-size: 56px;
  }
}

/* Wide landscape screens (tablets, laptops) */
@media (min-width: 1024px) and (orientation: landscape) {
  .screen {
    max-width: 96vw;
    padding: 24px 40px;
  }
  
  .category-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
  }
  
  .category-card {
    padding: 32px 20px;
    font-size: 16px;
  }
}

/* Mobile portrait */
@media (max-width: 480px) and (orientation: portrait) {
  .title {
    font-size: 42px;
  }
  
  .card-word {
    font-size: 38px;
  }
  
  .category-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .category-card {
    padding: 25px 15px;
    font-size: 16px;
  }
  
  .screen {
    padding: 30px 20px;
  }
}

/* Very short screens (landscape phones) */
@media (orientation: landscape) and (max-height: 450px) {
  #game-screen {
    padding: 10px;
    max-height: 98vh;
  }
  
  .game-header {
    font-size: 14px;
    margin-bottom: 5px;
  }
  
  .timer, .score {
    padding: 6px 14px;
    font-size: 14px;
  }
  
  .card {
    padding: 18px 22px;
    max-height: 180px;
  }
  
  .card-word {
    font-size: 28px;
  }
  
  .tilt-instructions {
    margin-top: 5px;
  }
  
  .tilt-hint {
    font-size: 12px;
  }
}
