/* ===== CSS Variables ===== */
:root {
  --pictionary-green: #2E7D32;
  --pictionary-green-light: #4CAF50;
  --pictionary-green-dark: #1B5E20;
  --white: #FFFFFF;
  --black: #000000;
  --gray: #666666;
  --gray-light: #CCCCCC;
  --gray-dark: #333333;
  --correct-green: #28a745;
  --wrong-red: #dc3545;
  --gold: #D4A843;

  --font-logo: 'Michroma', sans-serif;
  --font-sans: 'Open Sans', sans-serif;
}

/* ===== Reset & Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: var(--white);
}

/* ===== Screen Management ===== */
.screen {
  display: none;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
}

/* ===== Center Content ===== */
.center-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
}

/* ===== Title ===== */
.title {
  font-family: var(--font-logo);
  font-size: 5rem;
  color: var(--pictionary-green-light);
  margin-bottom: 1rem;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* ===== Waiting Screen ===== */
.waiting-text {
  font-size: 2rem;
  color: var(--gray-light);
  margin-bottom: 2rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.room-code-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.room-code-display .label {
  font-size: 1.5rem;
  color: var(--gray);
}

.room-code-display .code {
  font-family: var(--font-logo);
  font-size: 4rem;
  color: var(--pictionary-green-light);
  letter-spacing: 0.5rem;
}

/* ===== Lobby Screen ===== */
.room-code-large {
  font-family: var(--font-logo);
  font-size: 8rem;
  color: var(--pictionary-green-light);
  letter-spacing: 1rem;
  margin: 1rem 0;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.instruction {
  font-size: 1.5rem;
  color: var(--gray-light);
  margin-bottom: 2rem;
}

.player-list {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}

.player-card {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1.5rem 2.5rem;
  min-width: 200px;
  border: 3px solid var(--gray);
}

.player-card.connected {
  border-color: var(--correct-green);
}

.player-card .name {
  font-size: 1.5rem;
  font-weight: 600;
}

.player-card .status {
  font-size: 1rem;
  color: var(--gray);
  margin-top: 0.5rem;
}

.player-card.connected .status {
  color: var(--correct-green);
}

/* ===== Game Screen ===== */
.game-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  background: rgba(0, 0, 0, 0.3);
}

.round-display {
  font-size: 1.5rem;
  color: var(--gray-light);
}

.round-display span {
  color: var(--white);
  font-weight: 600;
}

.drawer-display {
  font-size: 1.75rem;
}

.drawer-display span {
  color: var(--pictionary-green-light);
  font-weight: 700;
}

.timer-display {
  font-family: var(--font-logo);
  font-size: 3rem;
  color: var(--pictionary-green-light);
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem 1.5rem;
  border-radius: 12px;
  min-width: 120px;
  text-align: center;
}

.timer-display.urgent {
  color: var(--wrong-red);
  animation: pulse 1s infinite;
}

/* ===== Game Main ===== */
.game-main {
  flex: 1;
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  overflow: hidden;
}

.canvas-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

#tv-canvas {
  flex: 1;
  width: 100%;
}

.word-hint {
  font-family: var(--font-logo);
  font-size: 2rem;
  color: var(--black);
  text-align: center;
  padding: 1rem;
  background: var(--gray-light);
  letter-spacing: 0.5rem;
}

/* ===== Scoreboard ===== */
.scoreboard {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.score-card {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left: 4px solid transparent;
}

.score-card.drawing {
  border-left-color: var(--pictionary-green-light);
  background: rgba(76, 175, 80, 0.2);
}

.score-card .player-name {
  font-size: 1.25rem;
  font-weight: 600;
}

.score-card .player-score {
  font-family: var(--font-logo);
  font-size: 1.5rem;
  color: var(--pictionary-green-light);
}

.score-card .drawing-label {
  font-size: 0.875rem;
  color: var(--pictionary-green-light);
  margin-top: 0.25rem;
}

/* ===== Guesses Area ===== */
.guesses-area {
  padding: 0.75rem 2rem;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 60px;
}

.wrong-guess {
  background: rgba(220, 53, 69, 0.3);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.875rem;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Result Screen ===== */
#result-display {
  text-align: center;
}

.result-title {
  font-family: var(--font-logo);
  font-size: 4rem;
  margin-bottom: 1rem;
}

.result-title.correct {
  color: var(--correct-green);
}

.result-title.timeout {
  color: var(--wrong-red);
}

.result-winner {
  font-size: 2.5rem;
  color: var(--gold);
  margin-bottom: 1rem;
}

.result-word {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.result-word span {
  color: var(--pictionary-green-light);
  font-weight: 700;
}

.result-points {
  font-size: 1.5rem;
  color: var(--gray-light);
}

/* ===== Winner Screen ===== */
.winner-title {
  font-family: var(--font-logo);
  font-size: 5rem;
  color: var(--gold);
  margin-bottom: 1rem;
  text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.winner-name {
  font-family: var(--font-logo);
  font-size: 4rem;
  color: var(--white);
  margin-bottom: 0.5rem;
}

.winner-score {
  font-size: 2.5rem;
  color: var(--pictionary-green-light);
  margin-bottom: 2rem;
}

.final-standings {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 500px;
}

.standing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  padding: 1rem 2rem;
  border-radius: 8px;
  font-size: 1.5rem;
}

.standing-row.first {
  background: linear-gradient(135deg, rgba(212, 168, 67, 0.3), rgba(212, 168, 67, 0.1));
  border: 2px solid var(--gold);
}

.standing-row .rank {
  font-weight: 700;
  min-width: 40px;
}

.standing-row .name {
  flex: 1;
  margin-left: 1rem;
}

.standing-row .score {
  color: var(--pictionary-green-light);
  font-weight: 600;
}

/* ===== Confetti Canvas ===== */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .title {
    font-size: 3.5rem;
  }

  .room-code-large {
    font-size: 5rem;
  }

  .game-main {
    flex-direction: column;
  }

  .scoreboard {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .score-card {
    min-width: 150px;
  }
}
