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

html, body, #app {
  height: 100svh;
}

body {
  font-family: "Arial", sans-serif;
  background: #ffb200;
  color: #000;
  overflow: hidden;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

#app {
  position: relative;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

.container {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 30px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-align: center;
  max-width: 90%;
  width: 480px;
}

h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
}

h2 {
  font-size: 2em;
  margin-bottom: 20px;
}

p {
  margin-bottom: 20px;
  opacity: 0.9;
}

.form-group {
  margin-bottom: 15px;
}

input {
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  font-size: 16px;
  outline: none;
}

input::placeholder {
  color: #666;
}

.btn {
  padding: 15px 30px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 5px;
  min-width: 120px;
}

.btn-primary {
  background: linear-gradient(45deg, #ff6b6b, #ff8e8e);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(45deg, #ff5252, #ff7979);
  transform: translateY(-2px);
}

.btn-secondary {
  background: linear-gradient(45deg, #4ecdc4, #81ecec);
  color: white;
}

.btn-secondary:hover {
  background: linear-gradient(45deg, #00b894, #00cec9);
  transform: translateY(-2px);
}

.info {
  font-size: 14px;
  opacity: 0.8;
  margin-top: 15px;
}

/* Lobby specific styles */
#playersContainer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin: 15px 0;
}

.player-card {
  background: rgba(255, 255, 255, 0.2);
  padding: 10px 15px;
  border-radius: 15px;
  font-weight: bold;
}

/* Game screen styles */
#gameScreen {
  align-items: stretch;
  justify-content: stretch;
}

#gameContainer {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

#gameView {
  width: 100%;
  height: 75%;
  position: relative;
  background: #faf9f7;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #faf9f7;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  object-fit: contain;
}

#gameUI {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

#countdown {
  font-size: 20vw;
  font-weight: bold;
  color: white;
  text-shadow: 0 0 15px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 0, 0, 0.5);
  font-family: "Arial Black", Gadget, sans-serif;
  -webkit-text-stroke: 2px black;
  display: none;
  z-index: 999;
}

.player-name-hud {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 20px;
  border-radius: 25px;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  backdrop-filter: blur(5px);
  border: 2px solid rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

.player-name-hud span {
  color: #ffa726;
  font-family: "Arial Black", Arial, sans-serif;
  letter-spacing: 1px;
}

#controlsArea {
  width: 100%;
  height: 30%;
  background: linear-gradient(135deg, #ffa726 0%, #ff9800 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#controls {
  position: relative;
  pointer-events: all;
}

#joystick {
  position: relative;
  width: 140px;
  height: 140px;
  pointer-events: all;
}

#joystickBase {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  position: absolute;
  top: 0;
  left: 0;
}

#joystickKnob {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.1s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

/* Responsive design */
@media (max-width: 480px) {
  .container {
    padding: 20px;
    width: 95%;
  }

  h1 {
    font-size: 2em;
  }

  h2 {
    font-size: 1.5em;
  }

  #joystick {
    width: 120px;
    height: 120px;
  }

  #joystickKnob {
    width: 50px;
    height: 50px;
  }

  #gameInfo {
    top: 10px;
    left: 10px;
    right: 10px;
  }

  #gameInfo div {
    padding: 8px 12px;
    font-size: 14px;
  }
}

@media (max-height: 600px) {
  #joystick {
    width: 110px;
    height: 110px;
  }

  #joystickKnob {
    width: 45px;
    height: 45px;
  }

  .player-name-hud {
    top: 10px;
    left: 10px;
    font-size: 14px;
    padding: 8px 15px;
  }
}

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

.pulse {
  animation: pulse 0.5s ease-in-out;
}

/* Touch improvements */
#joystick {
  touch-action: none;
}

input {
  touch-action: manipulation;
}

/* Prevent zoom on iOS */
input[type="text"] {
  font-size: 16px;
}

/* Spectator Layout Styles */
.spectator-layout {
  background: linear-gradient(135deg, #ffa726 0%, #ff9800 100%);
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  flex-direction: row;
  position: relative;
}

.spectator-left {
  width: 25%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.spectator-center {
  width: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 15px;
}

.spectator-right {
  width: 25%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.sumo-duck-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sumo-duck-logo img {
  width: 100%;
  max-width: 450px;
  height: auto;
}

.logo-text {
  font-family: "Arial Black", Arial, sans-serif;
  letter-spacing: 2px;
}

.logo-duck {
  font-size: 1.2em;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

.qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

#qrcode {
  display: block;
  width: 280px;
  height: 280px;
  border-radius: 15px;
  background: #fff;
  padding: 10px;
}

.qr-text {
  font-weight: bold;
  color: white;
  font-size: 1.2em;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  letter-spacing: 1px;
}

.game-display {
  width: 100%;
  height: 90%;
  background: #e0e0e0;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
}

#spectatorGameScreen #gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #faf9f7;
  border-radius: 20px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .spectator-layout {
    flex-direction: column;
  }

  .spectator-left,
  .spectator-center,
  .spectator-right {
    width: 100%;
  }

  .spectator-left {
    height: 20%;
  }

  .spectator-center {
    height: 60%;
  }

  .spectator-right {
    height: 20%;
  }

  .sumo-duck-logo {
    font-size: 2em;
  }

  .qr-text {
    font-size: 1em;
  }
}

.spectator-controls {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
}

#spectatorStartGameBtn {
  padding: 20px 40px;
  font-size: 1.5em;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

#spectatorGameStatus {
  font-size: 1.2em;
  font-weight: bold;
  margin-bottom: 15px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Winner display overlay */
.winner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 20px;
}

.winner-overlay.show {
  display: flex;
}

.winner-content {
  text-align: center;
  color: white;
  animation: winnerPulse 2s ease-in-out infinite;
}

.winner-content h1 {
  font-size: 3em;
  margin: 0 0 20px 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  color: #ffd700;
}

.winner-content h2 {
  font-size: 2.5em;
  margin: 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  color: #ffffff;
}

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

/* Mobile responsive for winner display */
@media (max-width: 768px) {
  .winner-content h1 {
    font-size: 2em;
  }

  .winner-content h2 {
    font-size: 1.8em;
  }
}
