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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Fredoka', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.screen {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hidden {
  display: none !important;
}

/* Login Screen */
.login-container {
  text-align: center;
  padding: 2.5rem;
  background: #16213e;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  max-width: 90vw;
}

.game-title {
  margin-bottom: 1.5rem;
  font-size: clamp(1.8rem, 8vw, 3rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 3px 3px 0px rgba(0,0,0,0.3);
  white-space: nowrap;
}

.game-title .letter {
  display: inline-block;
  transition: transform 0.2s ease;
}

/* Alternating vertical bounce effect */
.game-title .letter:nth-child(odd) {
  transform: translateY(-4px);
}

.game-title .letter:nth-child(even) {
  transform: translateY(4px);
}

.game-title .letter:hover {
  transform: scale(1.2) rotate(-5deg) !important;
}

/* Alternating rainbow colors */
.game-title .c1 { color: #FF6B6B; } /* Red */
.game-title .c2 { color: #4ECDC4; } /* Teal */
.game-title .c3 { color: #FFE66D; } /* Yellow */
.game-title .c4 { color: #95E1D3; } /* Mint */
.game-title .c5 { color: #F38181; } /* Coral */
.game-title .c6 { color: #AA96DA; } /* Purple */
.game-title .c7 { color: #FCBAD3; } /* Pink */
.game-title .c8 { color: #A8D8EA; } /* Sky Blue */
.game-title .c9 { color: #F9F871; } /* Lime */
.game-title .c10 { color: #FF6B6B; } /* Red (exclamation) */

.login-container input {
  display: block;
  width: 100%;
  padding: 0.85rem 1.2rem;
  margin-bottom: 1rem;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-family: inherit;
  background: #0f3460;
  color: #eee;
}

.login-container input::placeholder {
  color: #888;
}

.login-container button {
  width: 100%;
  padding: 0.85rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 600;
  background: linear-gradient(135deg, #FF6B6B, #4ECDC4);
  color: white;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.login-container button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
}

.login-container button:active {
  transform: translateY(0);
}

/* Game Screen */
#game-screen {
  position: relative;
  /* Table texture background - falls back to solid color if table.png not found */
  background-color: #3d2817;
  background-image: url('/table.png');
  background-repeat: repeat;
  background-size: auto;
}

#puzzle-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  /* Canvas is transparent so table shows through */
  background: transparent;
}

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

/* Admin Panel */
#admin-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  max-height: 100vh;
  overflow-y: auto;
  padding: 1rem;
  background: rgba(22, 33, 62, 0.95);
  border-right: 1px solid #0f3460;
  z-index: 100;
}

#admin-panel h3 {
  margin-bottom: 1rem;
  color: #e94560;
  border-bottom: 1px solid #0f3460;
  padding-bottom: 0.5rem;
}

.admin-section {
  margin-bottom: 1rem;
}

.admin-section label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  color: #aaa;
}

.admin-section input[type="text"],
.admin-section select {
  width: 100%;
  padding: 0.5rem;
  border: none;
  border-radius: 4px;
  background: #0f3460;
  color: #eee;
  font-size: 0.9rem;
}

.admin-section input[type="file"] {
  font-size: 0.85rem;
}

.admin-section button {
  width: 100%;
  padding: 0.5rem;
  margin-top: 0.25rem;
  border: none;
  border-radius: 4px;
  background: #e94560;
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
}

.admin-section button:hover {
  background: #ff6b6b;
}

.admin-section input[type="checkbox"] {
  margin-right: 0.5rem;
}

#toggle-admin {
  position: fixed;
  top: 10px;
  left: 10px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: rgba(22, 33, 62, 0.9);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 99;
}

/* Scoreboard Button */
#toggle-scoreboard {
  position: fixed;
  top: 10px;
  left: 60px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: rgba(22, 33, 62, 0.9);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 99;
  transition: transform 0.2s, background 0.2s;
}

#toggle-scoreboard:hover {
  background: rgba(78, 205, 196, 0.9);
  transform: scale(1.05);
}

/* When admin button is hidden, move scoreboard button to the left */
#toggle-admin.hidden + #toggle-scoreboard {
  left: 10px;
}

/* Scoreboard Flyout */
#scoreboard {
  position: fixed;
  top: 60px;
  left: 10px;
  width: 220px;
  max-height: 60vh;
  background: rgba(22, 33, 62, 0.95);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 98;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.scoreboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: rgba(15, 52, 96, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.scoreboard-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #4ECDC4;
}

#close-scoreboard {
  background: none;
  border: none;
  color: #888;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

#close-scoreboard:hover {
  color: #FF6B6B;
}

#scoreboard-list {
  padding: 0.5rem;
  overflow-y: auto;
  flex: 1;
}

.no-scores {
  color: #888;
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
  margin: 0;
}

.score-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  margin: 0.25rem 0;
  background: rgba(15, 52, 96, 0.4);
  border-radius: 6px;
  transition: background 0.2s;
}

.score-entry:hover {
  background: rgba(15, 52, 96, 0.7);
}

.score-entry .player-name {
  font-weight: 500;
  color: #eee;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.score-entry .player-score {
  font-weight: 700;
  color: #4ECDC4;
  font-size: 1.1rem;
}

.score-entry.first-place {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 165, 0, 0.2));
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.score-entry.first-place .player-name::before {
  content: '👑 ';
}

.score-entry.self {
  border-left: 3px solid #4ECDC4;
}

/* Zoom Controls */
#zoom-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: rgba(22, 33, 62, 0.9);
  border-radius: 8px;
  z-index: 50;
}

#zoom-controls button {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 4px;
  background: #0f3460;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
}

#zoom-controls button:hover {
  background: #e94560;
}

#zoom-level {
  min-width: 50px;
  text-align: center;
  font-size: 0.85rem;
}

/* Debug highlighting */
.debug-mode #puzzle-canvas {
  background-image: 
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 50px 50px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  #admin-panel {
    width: 100%;
    max-height: 50vh;
    bottom: 0;
    top: auto;
    border-right: none;
    border-top: 1px solid #0f3460;
  }
  
  #toggle-admin {
    bottom: 10px;
    top: auto;
  }
}
