* { 
  box-sizing: border-box; 
}

body { 
  margin: 0; 
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; 
  background: #0d1117; 
  color: #e6edf3;
  overscroll-behavior: contain;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.wrap { 
  max-width: 960px; 
  margin: 0 auto; 
  padding: 16px; 
}

header { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 12px;
  flex-wrap: wrap;
}

h1 { 
  margin: 0; 
  font-size: 24px; 
}

.room { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
}

#room { 
  padding: 8px 10px; 
  border-radius: 10px; 
  border: 1px solid #30363d; 
  background: #161b22; 
  color: #e6edf3; 
  width: 180px; 
}

#join, #rematch { 
  padding: 8px 12px; 
  border: 0; 
  border-radius: 12px; 
  background: #238636; 
  color: white; 
  cursor: pointer; 
  box-shadow: 0 2px 0 #1a5f29;
  font-size: 14px;
}

#join:hover, #rematch:hover { 
  filter: brightness(1.1); 
}

#lobby { 
  opacity: 0.8; 
}

/* Thumb Selector */
#thumbSelector { 
  margin: 20px 0; 
  display: flex; 
  justify-content: center; 
  gap: 15px;
  flex-wrap: wrap;
}

.thumbOption { 
  width: 60px; 
  height: 60px; 
  cursor: pointer; 
  border: 2px solid #30363d; 
  border-radius: 50%; 
  transition: all 0.2s ease;
  background: #161b22;
}

.thumbOption:hover, .thumbOption:active { 
  transform: scale(1.1); 
  border-color: #ffd166; 
  box-shadow: 0 0 15px rgba(255, 209, 102, 0.3);
}

/* Game Canvas */
.game-area {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

canvas { 
  display: block; 
  max-width: 100%;
  height: auto; 
  border-radius: 16px; 
  background: radial-gradient(circle at 50% 10%, #1f2733, #0b0f14); 
  box-shadow: inset 0 0 0 2px #30363d;
  touch-action: none;
}

footer { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  margin-top: 10px;
  flex-wrap: wrap;
  gap: 10px;
}

.controls { 
  opacity: 0.8;
  font-size: 12px;
}

.hide { 
  display: none !important; 
}

/* HUD Elements */
.badge { 
  position: absolute; 
  top: 12px; 
  right: 16px; 
  background: #30363d; 
  padding: 6px 10px; 
  border-radius: 10px; 
  font-size: 12px; 
}

.centerBanner { 
  position: absolute; 
  left: 50%; 
  top: 50%; 
  transform: translate(-50%, -50%); 
  background: rgba(0,0,0,0.8); 
  padding: 14px 18px; 
  border-radius: 14px; 
  font-size: 22px;
  text-align: center;
  border: 1px solid #30363d;
}

#rematch {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3000;
  font-size: 18px;
  padding: 12px 24px;
}

/* Mobile Controls - Hidden by default */
#mobile-controls {
  display: none;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
  body {
    font-size: 16px;
  }
  
  .wrap {
    padding: 12px;
  }
  
  header {
    flex-direction: column;
    gap: 15px;
  }
  
  h1 {
    font-size: 20px;
  }
  
  .room {
    width: 100%;
    justify-content: center;
  }
  
  #room {
    width: 150px;
  }
  
  canvas {
    width: 100% !important;
    height: auto !important;
    border-radius: 12px;
  }
  
  .thumbOption {
    width: 50px;
    height: 50px;
  }
  
  footer {
    justify-content: center;
    text-align: center;
  }
  
  .controls {
    display: none;
  }
}

/* Mobile Touch Controls */
@media (max-width: 1024px) and (pointer: coarse) {
  #mobile-controls {
    display: block;
  }
  
  .controls {
    display: none;
  }
  
  #raise-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 2000;
    padding: 15px 20px;
    border-radius: 15px;
    background: rgba(35, 134, 54, 0.9);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    touch-action: manipulation;
    user-select: none;
    cursor: pointer;
    min-width: 80px;
    text-align: center;
  }
  
  #raise-btn:active {
    background: rgba(35, 134, 54, 1);
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  }
  
  .joystick {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.15), rgba(0,0,0,0.4));
    border: 2px solid rgba(255,255,255,0.2);
    z-index: 2000;
    touch-action: none;
    user-select: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  }
  
  #joystick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 50px;
    height: 50px;
    margin-left: -25px;
    margin-top: -25px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9), rgba(200,200,200,0.8));
    border: 1px solid rgba(0,0,0,0.3);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    transition: transform 50ms linear;
    pointer-events: none;
  }
}

/* Desktop - Hide mobile controls */
@media (min-width: 1025px), (pointer: fine) {
  #mobile-controls {
    display: none !important;
  }
}