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

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

/* Screens */
.screen { display: none; width: 100%; height: 100dvh; }
.screen.active { display: flex; }

/* Join Screen */
#join-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

#join-screen h1 {
  font-size: 3rem;
  background: linear-gradient(135deg, #e94560, #0f3460);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
}

#join-screen .subtitle {
  color: #888;
  margin-bottom: 20px;
}

.join-box {
  background: #16213e;
  border-radius: 16px;
  padding: 30px;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.join-box input {
  background: #1a1a2e;
  border: 2px solid #0f3460;
  border-radius: 8px;
  padding: 12px 16px;
  color: #eee;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.join-box input:focus { border-color: #e94560; }

.join-box input::placeholder { color: #555; }

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

.btn:hover { transform: scale(1.02); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: #e94560; color: white; }
.btn-secondary { background: #0f3460; color: white; }

.divider {
  text-align: center;
  color: #555;
  position: relative;
}

.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: #333;
}

.divider::before { left: 0; }
.divider::after { right: 0; }

/* Lobby Screen */
#lobby-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.room-code {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 8px;
  color: #e94560;
  cursor: pointer;
  transition: transform 0.1s;
}

.room-code:hover { transform: scale(1.05); }

.player-list {
  background: #16213e;
  border-radius: 16px;
  padding: 20px;
  width: 360px;
  min-height: 200px;
}

.player-list h3 { margin-bottom: 12px; color: #888; }

.player-item {
  padding: 10px 16px;
  background: #1a1a2e;
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.player-item .host-badge {
  background: #e94560;
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Game Screen */
#game-screen {
  flex-direction: column;
  height: 100dvh;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: #16213e;
  border-bottom: 2px solid #0f3460;
}

.game-header .round-info { font-weight: 600; }

.game-header .word-display {
  font-size: 1.5rem;
  letter-spacing: 6px;
  font-weight: 700;
  font-family: monospace;
}

.game-header .timer {
  font-size: 1.5rem;
  font-weight: 700;
  min-width: 50px;
  text-align: center;
}

.timer.warning { color: #f0a500; }
.timer.danger { color: #e94560; animation: pulse 0.5s infinite alternate; }

@keyframes pulse { to { opacity: 0.5; } }

.game-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Canvas area */
.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1a1a2e;
  min-height: 0;
}

.canvas-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  min-height: 0;
  overflow: hidden;
}

#drawing-canvas {
  background: white;
  border-radius: 8px;
  cursor: crosshair;
  max-width: 100%;
  max-height: 100%;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #16213e;
  border-top: 2px solid #0f3460;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.toolbar.hidden { display: none; }

.color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.2s;
  flex-shrink: 0;
}

.color-btn:hover { transform: scale(1.15); }
.color-btn.active { border-color: white; transform: scale(1.15); }

.size-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #1a1a2e;
  border: 2px solid #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #eee;
  font-weight: 600;
  font-size: 0.8rem;
}

.size-btn.active { border-color: #e94560; background: #0f3460; }

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: #333;
  margin: 0 4px;
}

/* Sidebar */
.sidebar {
  width: 300px;
  display: flex;
  flex-direction: column;
  background: #16213e;
  border-left: 2px solid #0f3460;
}

.scoreboard {
  padding: 12px;
  border-bottom: 2px solid #0f3460;
  max-height: 200px;
  overflow-y: auto;
}

.scoreboard h4 { color: #888; margin-bottom: 8px; }

.score-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.score-item.artist { background: #0f3460; }
.score-item.guessed { color: #4ecca3; }

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg { font-size: 0.85rem; line-height: 1.4; }
.chat-msg .name { font-weight: 600; }
.chat-msg.system { color: #888; font-style: italic; }
.chat-msg.correct { color: #4ecca3; font-weight: 600; }
.chat-msg.close { color: #f0a500; }

.chat-input-area {
  display: flex;
  padding: 8px;
  gap: 8px;
  border-top: 2px solid #0f3460;
}

.chat-input-area input {
  flex: 1;
  background: #1a1a2e;
  border: 2px solid #0f3460;
  border-radius: 8px;
  padding: 10px 14px;
  color: #eee;
  font-size: 0.9rem;
  outline: none;
}

.chat-input-area input:focus { border-color: #e94560; }
.chat-input-area input:disabled { opacity: 0.5; }

/* Game Over Screen */
#gameover-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

#gameover-screen h2 { font-size: 2rem; }

.final-scores {
  background: #16213e;
  border-radius: 16px;
  padding: 20px;
  width: 400px;
}

.final-score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #1a1a2e;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.final-score-item:first-child {
  background: linear-gradient(135deg, #e94560, #0f3460);
  font-size: 1.3rem;
  font-weight: 700;
}

.rank { margin-right: 12px; }

/* Toast notifications */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: #4ecca3;
  color: #1a1a2e;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 600;
  transition: transform 0.3s;
  z-index: 100;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: #e94560; color: white; }

/* How to Play */
.how-to-play {
  margin-top: 10px;
  text-align: center;
}

.how-to-play summary {
  cursor: pointer;
  color: #888;
  font-size: 0.85rem;
  list-style: none;
  transition: color 0.2s;
}

.how-to-play summary:hover { color: #eee; }
.how-to-play summary::-webkit-details-marker { display: none; }

.how-to-play .steps {
  margin-top: 12px;
  text-align: left;
  display: inline-block;
  max-width: 320px;
}

.how-to-play .step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: #aaa;
}

.how-to-play .step-num {
  background: #e94560;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Role banner in game */
.role-banner {
  text-align: center;
  padding: 6px 16px;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.role-banner.artist {
  background: linear-gradient(90deg, rgba(78, 204, 163, 0.2), transparent);
  color: #4ecca3;
}

.role-banner.guesser {
  background: linear-gradient(90deg, rgba(233, 69, 96, 0.2), transparent);
  color: #e94560;
}

/* In-game room code */
.game-room-code {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: #888;
  background: #1a1a2e;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s;
}

.game-room-code:hover { color: #e94560; }

/* Game header compact */
.game-header {
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 768px) {
  .game-body { flex-direction: column; }
  .sidebar { width: 100%; height: 200px; border-left: none; border-top: 2px solid #0f3460; }
  .scoreboard { max-height: 60px; }
  .toolbar { padding: 6px 8px; gap: 4px; }
  .color-btn { width: 24px; height: 24px; }
  .size-btn { width: 28px; height: 28px; font-size: 0.7rem; }
}
