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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
  overflow: hidden;
}

.screen {
  width: 100%;
  height: 100vh;
}

.hidden {
  display: none !important;
}

/* Join Screen */
#join-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.join-container {
  text-align: center;
  padding: 40px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  backdrop-filter: blur(10px);
}

.join-container h1 {
  font-size: 3rem;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: rgba(255, 255, 255, 0.6);
  font-size: 1rem;
  margin-bottom: 30px;
  max-width: 280px;
}

.join-container input {
  display: block;
  width: 280px;
  padding: 14px 20px;
  margin: 12px auto;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 16px;
  transition: border-color 0.3s;
}

.join-container input:focus {
  outline: none;
  border-color: #667eea;
}

.join-container input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

#join-btn {
  width: 280px;
  padding: 14px 20px;
  margin-top: 20px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

#join-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.hint {
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 14px;
}

/* Game Screen */
#game-screen {
  display: flex;
  flex-direction: column;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.room-info {
  font-weight: 600;
  color: #667eea;
}

.players-list {
  display: flex;
  gap: 12px;
}

.player-tag {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  font-size: 14px;
}

.player-tag.you {
  background: rgba(102, 126, 234, 0.3);
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.upload-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: transform 0.2s;
}

.upload-btn:hover {
  transform: translateY(-1px);
}

.upload-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* New Puzzle Button */
.new-puzzle-btn {
  padding: 10px 20px;
  background: rgba(255, 107, 107, 0.8);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.new-puzzle-btn:hover {
  background: rgba(255, 107, 107, 1);
  transform: translateY(-1px);
}

/* Gather Button */
.gather-btn {
  padding: 10px 20px;
  background: rgba(78, 205, 196, 0.8);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.gather-btn:hover {
  background: rgba(78, 205, 196, 1);
  transform: translateY(-1px);
}

#piece-count {
  width: 70px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  text-align: center;
}

#piece-count:focus {
  outline: none;
  border-color: #667eea;
}

#grid-info {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
}

/* Game Area */
.game-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
  position: relative;
}

#puzzle-canvas {
  background: #0f0f23;
  border-radius: 8px;
  cursor: grab;
}

#puzzle-canvas:active {
  cursor: grabbing;
}

/* Complete Message */
#complete-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 40px 80px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  font-size: 2rem;
  font-weight: 700;
  animation: pulse 0.5s ease-out;
  z-index: 100;
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

/* Player Cursors */
.player-cursor {
  position: fixed;
  pointer-events: none;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cursor-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
}

.cursor-name {
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}

/* Preview Button */
.preview-btn {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.preview-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.preview-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Piece Count Group */
.piece-count-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.piece-count-group label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

/* Piece Info Display */
.piece-info {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

/* Preview Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  background: #1a1a2e;
  padding: 20px;
  border-radius: 16px;
  max-width: 90%;
  max-height: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.modal-content img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
  object-fit: contain;
}

.close-btn {
  padding: 10px 30px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s;
}

.close-btn:hover {
  transform: translateY(-1px);
}

/* Zoom Controls */
.zoom-controls {
  position: absolute;
  bottom: 15px;
  right: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 10;
}

.zoom-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.zoom-btn:active {
  background: rgba(255, 255, 255, 0.4);
}

#zoom-level {
  color: #fff;
  font-size: 13px;
  min-width: 45px;
  text-align: center;
}

.zoom-hint {
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  margin-left: 8px;
}
