* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #0f1923;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(72, 40, 120, 0.4) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(20, 80, 100, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(120, 60, 20, 0.2) 0%, transparent 40%);
  color: #e8e4df;
  padding: 70px 10px 20px 10px;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
}

.game-container {
  text-align: center;
  width: 100%;
  max-width: 400px;
  padding: 0 10px;
  box-sizing: border-box;
}

h1 {
  margin-bottom: 20px;
  font-size: 2rem;
  letter-spacing: 2px;
  color: #f0c040;
  text-shadow: 0 2px 10px rgba(240, 192, 64, 0.3);
}

.card {
  background: rgba(20, 30, 48, 0.85);
  border-radius: 16px;
  padding: 25px 20px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: 100%;
  box-sizing: border-box;
}

#scrambled-word {
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 600;
  margin: 15px 0;
  letter-spacing: 2px;
  word-wrap: break-word;
}

.scrambled-text {
  display: block;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  letter-spacing: 2px;
}

.hint-text {
  display: block;
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  letter-spacing: 4px;
  color: #ffeb3b;
  margin-top: 5px;
  font-family: monospace;
  text-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
}

input {
  width: 100%;
  max-width: 100%;
  padding: 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  font-size: clamp(0.9rem, 3vw, 1rem);
  margin-bottom: 20px;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  color: #e8e4df;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

input:focus {
  outline: none;
  border-color: #f0c040;
  box-shadow: 0 0 15px rgba(240, 192, 64, 0.2);
  background: rgba(0, 0, 0, 0.4);
}

input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.game-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 10px;
}

.difficulty-selector,
.category-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 150px;
  justify-content: center;
}

.difficulty-selector label,
.category-selector label {
  font-size: clamp(0.8rem, 2.5vw, 0.9rem);
  white-space: nowrap;
}

.difficulty-selector select,
.category-selector select {
  padding: 6px 10px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.4);
  color: white;
  cursor: pointer;
  font-weight: 500;
  font-size: clamp(0.8rem, 2.5vw, 0.9rem);
  min-width: 100px;
}

.buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

button {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  background: #d4841a;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  transition: 0.3s;
  box-shadow: 0 2px 8px rgba(212, 132, 26, 0.3);
  min-width: 100px;
  flex: 1;
  max-width: 150px;
  box-sizing: border-box;
}

button:hover {
  background: #e8972a;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(232, 151, 42, 0.4);
}

button:disabled {
  background: #4a3a20;
  color: #8a7a60;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  opacity: 0.6;
}

#pause-btn {
  padding: 6px 16px;
  font-size: clamp(0.8rem, 2.5vw, 0.9rem);
  flex: 1;
  min-width: 100px;
  max-width: 150px;
}

#pause-btn.paused {
  background: #2979ff;
  color: white;
}

#hint-btn {
  background: #2a7a5a;
  min-width: 120px;
}

#hint-btn:hover {
  background: #35946e;
}

#hint-btn:disabled {
  background: #1a3a2a;
  color: #5a7a6a;
}

.timer,
.score {
  font-size: 1rem;
  margin: 10px 0;
  color: #fff;
}

#time {
  color: #e85a5a;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(232, 90, 90, 0.4);
}

#score {
  color: #f0c040;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(240, 192, 64, 0.4);
}

/* Streak display */
.streak-display {
  min-height: 28px;
  font-size: 1rem;
  font-weight: 700;
  color: #ffeb3b;
  text-shadow: 0 0 15px rgba(255, 235, 59, 0.6);
  transition: all 0.3s ease;
  margin-bottom: 5px;
}

.streak-display.active {
  animation: streakPulse 1.5s ease-in-out infinite;
}

.streak-display.milestone {
  animation: streakMilestone 0.6s ease-out;
  font-size: 1.3rem;
}

@keyframes streakPulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.85;
    transform: scale(1.03);
  }
}

@keyframes streakMilestone {
  0% {
    transform: scale(1);
  }

  30% {
    transform: scale(1.4);
    color: #ff5722;
  }

  60% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
  }
}

/* Word reveal animation */
.reveal-letter {
  display: inline-block;
  opacity: 0;
  transform: translateY(-20px);
  animation: revealLetter 0.4s forwards;
  color: #ffeb3b;
  font-weight: 700;
  text-shadow: 0 0 15px rgba(255, 235, 59, 0.5);
}

@keyframes revealLetter {
  0% {
    opacity: 0;
    transform: translateY(-20px) scale(0.5);
  }

  60% {
    opacity: 1;
    transform: translateY(3px) scale(1.1);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Stats panel */
.stats-panel {
  display: flex;
  justify-content: space-around;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  gap: 8px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f0c040;
  text-shadow: 0 0 8px rgba(240, 192, 64, 0.3);
}

.container {
  text-align: center;
  width: 90%;
  max-width: 400px;
}

#signup-form {
  display: none;
}

form {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 30px 20px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  margin-top: 20px;
}

form h2 {
  margin-bottom: 20px;
  color: #fff;
}

form input {
  margin-bottom: 15px;
}

form p {
  margin-top: 15px;
  font-size: 0.9rem;
}

form a {
  color: #4caf50;
  text-decoration: none;
  font-weight: bold;
}

form a:hover {
  text-decoration: underline;
}

/* Player info styles */
#player-info {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(15, 25, 35, 0.9);
  padding: 10px;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  flex-wrap: wrap;
  box-sizing: border-box;
}

#player-info span {
  color: #fff;
  font-size: clamp(0.75rem, 2.5vw, 0.9rem);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

#player-info button {
  padding: 6px 14px;
  font-size: clamp(0.7rem, 2.5vw, 0.8rem);
  background: #d4841a;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  min-width: 70px;
  white-space: nowrap;
}

#player-info button:hover {
  background: #e8972a;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Start form styles */
.start-form {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 30px 20px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.start-form h2 {
  margin-bottom: 20px;
  color: #fff;
}

.start-form input {
  margin-bottom: 20px;
  width: 100%;
  max-width: 300px;
}

/* Popup styles */
.popup {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 12px 20px;
  border-radius: 50px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 999;
  max-width: 90%;
  box-sizing: border-box;
}

.popup.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(10px);
}

.popup-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.popup-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
}

.popup.success {
  background: #2a7a5a;
  color: #e8e4df;
}

.popup.error {
  background: #8a3030;
  color: #e8e4df;
}

.popup-message {
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  font-weight: 500;
  text-align: center;
  word-wrap: break-word;
}

/* Responsive breakpoints for all devices */

/* Extra small devices (phones, less than 360px) */
@media (max-width: 359px) {
  body {
    padding: 65px 5px 15px 5px;
  }

  .game-container {
    width: 100%;
    padding: 0 5px;
  }

  .card {
    padding: 15px 10px;
    border-radius: 15px;
  }

  h1 {
    font-size: 1.2rem;
    margin-bottom: 10px;
  }

  .game-options {
    flex-direction: column;
    gap: 8px;
  }

  .difficulty-selector,
  .category-selector,
  #pause-btn {
    width: 100%;
    max-width: 100%;
  }

  .buttons {
    gap: 8px;
  }

  .buttons button {
    min-width: 70px;
    padding: 10px 12px;
    font-size: 0.75rem;
  }

  #player-info {
    padding: 8px 5px;
    gap: 6px;
  }

  #player-info span {
    font-size: 0.7rem;
  }

  #player-info button {
    min-width: 60px;
    padding: 5px 10px;
  }

  .stats-panel {
    gap: 4px;
  }

  .stat-label {
    font-size: 0.6rem;
  }

  .stat-value {
    font-size: 0.9rem;
  }
}

/* Small devices (phones, 360px to 480px) */
@media (min-width: 360px) and (max-width: 480px) {
  .card {
    padding: 20px 15px;
  }

  h1 {
    font-size: 1.4rem;
  }
}

/* Medium devices (landscape phones, tablets, 481px to 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  .game-container {
    max-width: 500px;
  }

  .card {
    padding: 30px 25px;
  }

  h1 {
    font-size: 1.8rem;
  }

  .buttons button {
    max-width: 180px;
  }
}

/* Large devices (tablets, small laptops, 769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .game-container {
    max-width: 550px;
  }

  .card {
    padding: 35px 30px;
  }

  h1 {
    font-size: 2rem;
  }
}

/* Extra large devices (desktops, 1025px and up) */
@media (min-width: 1025px) {
  .game-container {
    max-width: 600px;
  }

  .card {
    padding: 40px 35px;
  }

  button:hover {
    transform: scale(1.08);
  }
}

/* Landscape orientation adjustments */
@media (max-height: 600px) and (orientation: landscape) {
  body {
    padding: 60px 10px 10px 10px;
  }

  .card {
    padding: 15px;
  }

  h1 {
    margin-bottom: 10px;
  }

  #scrambled-word {
    margin: 10px 0;
  }

  .timer,
  .score {
    margin: 5px 0;
  }
}

/* For very small screens */
@media (max-width: 350px) {
  .game-container {
    width: 98%;
  }

  h1 {
    font-size: 1.3rem;
  }

  #scrambled-word {
    font-size: 1.2rem;
  }

  button {
    padding: 10px 20px;
    font-size: 0.9rem;
  }
}