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

body {
  font-family: 'Courier New', monospace;
  background-color: #0A0A0A;
  color: #FFFFFF;
  overflow: hidden;
  position: relative;
}

/* Screens */
.screen {
  position: absolute;
  width: 100%;
  height: 100%;
  display: none;
}

.screen.active {
  display: block;
}

/* Team Selection */
.team-selection-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: radial-gradient(circle at center, #1A1A1A 0%, #0A0A0A 100%);
}

.game-title {
  font-size: 72px;
  font-weight: bold;
  letter-spacing: 8px;
  margin-bottom: 10px;
  text-shadow: 0 0 20px #FF4444, 0 0 40px #4444FF;
  animation: pulse 2s infinite;
}

.game-subtitle {
  font-size: 24px;
  margin-bottom: 50px;
  opacity: 0.8;
}

.team-options {
  display: flex;
  gap: 50px;
  margin-bottom: 40px;
}

.team-card {
  width: 300px;
  height: 400px;
  padding: 40px;
  border: 3px solid;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: rgba(26, 26, 26, 0.8);
}

.team-card.attacker {
  border-color: #FF4444;
  box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
}

.team-card.attacker:hover {
  border-color: #FF6B6B;
  box-shadow: 0 0 40px rgba(255, 107, 107, 0.8);
  transform: scale(1.05);
}

.team-card.defender {
  border-color: #4444FF;
  box-shadow: 0 0 20px rgba(68, 68, 255, 0.5);
}

.team-card.defender:hover {
  border-color: #6B6BFF;
  box-shadow: 0 0 40px rgba(107, 107, 255, 0.8);
  transform: scale(1.05);
}

.team-card h2 {
  font-size: 32px;
  margin-bottom: 20px;
  letter-spacing: 4px;
}

.team-card p {
  font-size: 16px;
  margin: 10px 0;
  opacity: 0.8;
}

.team-count {
  margin-top: 20px;
  font-size: 18px;
  font-weight: bold;
}

.name-input {
  width: 400px;
}

.name-input input {
  width: 100%;
  padding: 15px;
  font-size: 18px;
  font-family: 'Courier New', monospace;
  background: #1A1A1A;
  border: 2px solid #333;
  color: #FFFFFF;
  border-radius: 5px;
  text-align: center;
  transition: border-color 0.3s;
}

.name-input input:focus {
  outline: none;
  border-color: #6B6BFF;
}

/* Game Screen */
#gameCanvas {
  position: absolute;
  width: 100%;
  height: 50%;
  top: 0;
  cursor: crosshair;
  z-index: 1;
}

#gameUI {
  position: absolute;
  width: 100%;
  height: 100vh;
  top: 0;
  pointer-events: none;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

#gameUI > * {
  pointer-events: auto;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background: rgba(0, 0, 0, 0.9);
  border-bottom: 2px solid #444;
  position: relative;
  z-index: 20;
  flex-shrink: 0; /* Don't shrink */
}

.team-score {
  font-size: 20px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 15px;
}

.permanent-score {
  font-size: 36px;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.1);
  padding: 5px 15px;
  border-radius: 10px;
  border: 2px solid currentColor;
  min-width: 50px;
  text-align: center;
}

.team-score.attackers {
  color: #FF6B6B;
}

.team-score.defenders {
  color: #6B6BFF;
}

.game-info {
  text-align: center;
}

.timer {
  font-size: 64px;
  font-weight: bold;
  color: #FFFF00;
  text-shadow: 0 0 20px #FFFF00, 0 0 40px #FFFF00;
  letter-spacing: 3px;
}

.phase {
  font-size: 18px;
  opacity: 1;
  margin-top: 5px;
  color: #CCCCCC;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: bold;
}

/* Password Display */
.password-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 120px;
  background: rgba(26, 26, 26, 0.9);
  position: relative;
  z-index: 20;
  flex-shrink: 0; /* Don't shrink */
}

.password {
  font-size: 64px;
  font-weight: bold;
  letter-spacing: 20px;
  text-shadow: 0 0 20px #FFFFFF;
}

.password .revealed {
  color: #44FF44;
  animation: reveal 0.5s ease;
}

.password .hidden {
  color: #666;
}

/* Progress Bars */
.progress-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background: rgba(0, 0, 0, 0.9);
  border-top: 1px solid #333;
  position: relative;
  z-index: 20;
  border-bottom: 1px solid #333;
  flex-shrink: 0; /* Don't shrink */
}

.progress-bar {
  flex: 1;
  margin: 0 20px;
}

.progress-label {
  font-size: 14px;
  margin-bottom: 5px;
  text-align: center;
  opacity: 0.8;
}

.progress-track {
  width: 100%;
  height: 30px;
  background: #1A1A1A;
  border: 2px solid #333;
  border-radius: 15px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

.attacker-progress .progress-fill {
  background: linear-gradient(90deg, #FF4444, #FF6B6B);
  box-shadow: 0 0 10px #FF4444;
}

.defender-progress .progress-fill {
  background: linear-gradient(90deg, #4444FF, #6B6BFF);
  box-shadow: 0 0 10px #4444FF;
}

.progress-percent {
  text-align: center;
  margin-top: 5px;
  font-weight: bold;
}

.shield-display {
  text-align: center;
  min-width: 150px;
}

.shield-points {
  font-size: 48px;
  font-weight: bold;
  color: #6B6BFF;
  text-shadow: 0 0 20px #4444FF;
}

.shield-label {
  font-size: 14px;
  opacity: 0.8;
}

/* Team UI */
.team-ui {
  flex: 1;
  width: 100%;
  text-align: center;
  z-index: 100;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), rgba(10, 10, 10, 0.95));
  padding: 20px;
  border-top: 3px solid #4444FF;
  box-shadow: 0 -10px 40px rgba(68, 68, 255, 0.3);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
  min-height: 0; /* Allow flexbox to shrink */
}

/* Attacker UI specific */
#attackerUI {
  gap: 20px;
}

.input-hint {
  font-size: 32px;
  margin-bottom: 20px;
  opacity: 0.9;
  color: #FF6B6B;
  text-shadow: 0 0 10px #FF6B6B;
}

/* Mobile input container */
.letter-input-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin: 20px 0;
}

#letterInput {
  font-size: 48px;
  font-weight: bold;
  width: 80px;
  height: 80px;
  text-align: center;
  background: #1A1A1A;
  border: 3px solid #FF6B6B;
  border-radius: 10px;
  color: #FFFFFF;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
  transition: all 0.2s ease;
}

#letterInput:focus {
  outline: none;
  border-color: #FF4444;
  box-shadow: 0 0 30px rgba(255, 68, 68, 0.5);
  background: #2A2A2A;
}

#guessButton {
  font-size: 24px;
  font-weight: bold;
  padding: 20px 30px;
  background: linear-gradient(145deg, #FF6B6B, #FF4444);
  border: none;
  border-radius: 10px;
  color: #FFFFFF;
  font-family: 'Courier New', monospace;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(255, 107, 107, 0.4);
  transition: all 0.2s ease;
  min-width: 120px;
}

#guessButton:hover {
  background: linear-gradient(145deg, #FF4444, #FF2222);
  transform: translateY(-2px);
  box-shadow: 0 5px 25px rgba(255, 68, 68, 0.6);
}

#guessButton:active {
  transform: translateY(0);
}

.last-guess-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 24px;
  margin-top: 20px;
}

.last-guess {
  font-size: 36px;
  font-weight: bold;
  text-shadow: 0 0 20px currentColor;
  min-width: 40px;
  display: inline-block;
}

/* Cooldown display */
.cooldown-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  padding: 15px;
  background: rgba(255, 68, 68, 0.1);
  border: 2px solid #FF4444;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(255, 68, 68, 0.3);
}

.cooldown-text {
  font-size: 18px;
  font-weight: bold;
  color: #FF6B6B;
  text-align: center;
}

.cooldown-bar {
  width: 200px;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.cooldown-progress {
  height: 100%;
  background: linear-gradient(90deg, #FF4444, #FF6B6B);
  border-radius: 4px;
  transition: width 0.1s ease;
  box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
}

/* Defense UI */
.defense-header {
  text-align: center;
  background: linear-gradient(145deg, #4444FF, #6666FF);
  padding: 20px 40px;
  border-radius: 15px;
  margin-bottom: 30px;
  border: 3px solid #6666FF;
  box-shadow: 0 0 30px rgba(68, 68, 255, 0.5);
  max-width: 600px;
}

.defense-header h3 {
  font-size: 36px;
  margin: 0 0 15px 0;
  color: #FFFFFF;
  text-shadow: 0 0 20px #FFFFFF;
  letter-spacing: 3px;
}

.defense-header p {
  font-size: 20px;
  margin: 0;
  color: #E0E0FF;
  font-weight: 500;
}

.math-problem {
  background: linear-gradient(145deg, #1A1A1A, #2A2A2A);
  padding: 25px;
  border-radius: 15px;
  border: 3px solid #4444FF;
  box-shadow: 0 0 30px rgba(68, 68, 255, 0.2);
  margin-bottom: 20px;
}

.problem-label {
  font-size: 18px;
  font-weight: bold;
  color: #4444FF;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 15px;
  text-align: center;
}

.defense-status {
  background: rgba(68, 68, 255, 0.1);
  padding: 15px;
  border-radius: 10px;
  border: 1px solid #4444FF;
  text-align: center;
}

.shield-progress {
  font-size: 20px;
  font-weight: bold;
  color: #4444FF;
  margin-bottom: 10px;
}

.defense-instruction {
  font-size: 14px;
  color: #CCCCCC;
  font-style: italic;
}

.problem-text {
  font-size: 48px;
  font-weight: bold;
  margin-bottom: 30px;
  color: #FFFFFF;
  text-shadow: 0 0 10px rgba(68, 68, 255, 0.5);
}

.problem-choices {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.choice-button {
  padding: 25px 50px;
  font-size: 36px;
  font-family: 'Courier New', monospace;
  background: linear-gradient(145deg, #2A2A2A, #1A1A1A);
  border: 3px solid #6B6BFF;
  color: #FFFFFF;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 150px;
  font-weight: bold;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
}

.choice-button:hover {
  background: linear-gradient(145deg, #4444FF, #6666FF);
  transform: scale(1.1);
  box-shadow: 0 5px 30px rgba(68, 68, 255, 0.5);
}

.choice-button.correct {
  background: #44FF44;
  border-color: #44FF44;
  color: #000;
}

.choice-button.wrong {
  background: #FF4444;
  border-color: #FF4444;
  color: #FFF;
}

/* Game Over Overlay */
.overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-over-content {
  text-align: center;
  padding: 40px;
  background: #1A1A1A;
  border-radius: 10px;
  border: 3px solid #333;
}

#winnerText {
  font-size: 48px;
  margin-bottom: 20px;
  letter-spacing: 4px;
}

.final-password {
  font-size: 36px;
  margin-bottom: 20px;
  font-weight: bold;
  color: #44FF44;
}

.game-stats {
  font-size: 18px;
  margin-bottom: 20px;
  opacity: 0.8;
}

.countdown {
  font-size: 20px;
  font-weight: bold;
}

/* Animations */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

@keyframes reveal {
  0% {
    transform: scale(2) rotate(360deg);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

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

/* Lobby Countdown Overlay */
.lobby-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.lobby-content {
  text-align: center;
  padding: 60px;
  background: linear-gradient(145deg, #1A1A1A, #0F0F0F);
  border-radius: 20px;
  border: 3px solid #444;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.lobby-content h2 {
  font-size: 42px;
  margin-bottom: 30px;
  letter-spacing: 6px;
  color: #FF4444;
  text-shadow: 0 0 20px #FF4444;
}

.countdown-circle {
  width: 150px;
  height: 150px;
  border: 8px solid #333;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 30px auto;
  background: radial-gradient(circle, #2A2A2A, #1A1A1A);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.countdown-circle span {
  font-size: 72px;
  font-weight: bold;
  color: #FFFF00;
  text-shadow: 0 0 30px #FFFF00;
  animation: countdownPulse 1s infinite;
}

.lobby-content p {
  font-size: 24px;
  margin-top: 20px;
  opacity: 0.8;
  letter-spacing: 2px;
}

/* Responsive */
@media (max-width: 768px) {
  .team-options {
    flex-direction: column;
    gap: 20px;
  }
  
  .team-card {
    width: 250px;
    height: 300px;
  }
  
  .team-card h2 {
    font-size: 24px;
    letter-spacing: 2px;
  }
  
  .game-title {
    font-size: 48px;
  }
  
  .password {
    font-size: 36px;
    letter-spacing: 10px;
  }
  
  /* Enhanced mobile responsive design */
  .header {
    padding: 10px 15px;
    font-size: 14px;
  }
  
  /* Reduce countdown timer size on mobile */
  .timer {
    font-size: 36px;
  }
  
  /* Show team scores on mobile but simplified */
  .team-score {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  /* Hide labels on mobile, keep only score boxes */
  .team-score .label,
  .team-score .count {
    display: none;
  }
  
  /* Make score boxes more prominent on mobile */
  .permanent-score {
    font-size: 24px;
    padding: 8px 12px;
    min-width: 40px;
  }
  
  .password-container {
    height: 100px;
  }
  
  .progress-container {
    padding: 10px 15px;
    flex-direction: column;
    gap: 15px;
  }
  
  .progress-bar {
    margin: 0;
    width: 100%;
  }
  
  /* Hide shield points display completely on mobile to save space */
  .shield-display {
    display: none;
  }
  
  .team-ui {
    padding: 15px;
  }
  
  .input-hint {
    font-size: 20px;
  }
  
  #letterInput {
    font-size: 36px;
    width: 60px;
    height: 60px;
  }
  
  #guessButton {
    font-size: 18px;
    padding: 15px 20px;
    min-width: 100px;
  }
  
  .choice-button {
    padding: 15px 25px;
    font-size: 20px;
    min-width: 80px;
    flex: 1;
  }
  
  /* Disable hover effects on mobile but allow feedback states */
  .choice-button:hover {
    background: linear-gradient(145deg, #2A2A2A, #1A1A1A) !important;
    transform: none !important;
  }
  
  /* Allow correct/wrong feedback to show properly */
  .choice-button.correct {
    background: #44FF44 !important;
    border-color: #44FF44 !important;
    color: #000 !important;
    transition: all 0.3s ease !important;
    transform: none !important;
  }
  
  .choice-button.wrong {
    background: #FF4444 !important;
    border-color: #FF4444 !important;
    color: #FFF !important;
    transition: all 0.3s ease !important;
    transform: none !important;
  }
  
  .problem-choices {
    flex-direction: row;
    gap: 10px;
    justify-content: space-between;
  }
  
  /* Reduce defender UI font sizes */
  .problem-text {
    font-size: 32px;
  }
  
  .problem-label {
    font-size: 14px;
  }
  
  .math-problem {
    padding: 15px;
  }
  
  .lobby-content {
    padding: 40px 20px;
  }
  
  .lobby-content h2 {
    font-size: 28px;
    letter-spacing: 3px;
  }
  
  .countdown-circle {
    width: 120px;
    height: 120px;
  }
  
  .countdown-circle span {
    font-size: 48px;
  }
}

@media (max-height: 600px) {
  .password-container {
    height: 80px;
  }
  
  .password {
    font-size: 32px;
  }
  
  .header {
    padding: 8px 15px;
  }
  
  .progress-container {
    padding: 8px 15px;
  }
  
  .team-ui {
    padding: 10px;
  }
  
  .input-hint {
    font-size: 18px;
    margin-bottom: 10px;
  }
  
  #letterInput {
    font-size: 32px;
    width: 50px;
    height: 50px;
  }
  
  #guessButton {
    font-size: 16px;
    padding: 12px 18px;
  }
  
  .choice-button {
    padding: 12px 20px;
    font-size: 20px;
  }
  
  .cooldown-display {
    margin: 15px 0;
    padding: 12px;
  }
  
  .cooldown-text {
    font-size: 16px;
  }
  
  .cooldown-bar {
    width: 150px;
    height: 6px;
  }
}