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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #e94560;
  --accent2: #f5a623;
  --text: #eaeaea;
  --text-muted: #8892a4;
  --green: #2ecc71;
  --red: #e74c3c;
  --radius: 14px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* SCREENS */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 20px;
}
.screen.active {
  display: flex;
}

/* LOBBY */
.logo h1 {
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 30px rgba(233,69,96,0.4);
  margin-bottom: 8px;
}
.tagline {
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 32px;
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.card input[type=text] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 10px;
  border: 2px solid var(--surface2);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 20px;
  outline: none;
  transition: border-color 0.2s;
}
.card input[type=text]:focus {
  border-color: var(--accent);
}
.button-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.or {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.join-row {
  display: flex;
  gap: 8px;
}
.join-row input {
  flex: 1;
  margin-bottom: 0 !important;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 700;
}

/* BUTTONS */
.btn {
  padding: 12px 22px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-danger { background: #c0392b; color: white; }
.hidden { display: none !important; }
.error {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(231,76,60,0.15);
  border: 1px solid var(--red);
  border-radius: 8px;
  color: var(--red);
  font-size: 0.9rem;
}

/* WAITING ROOM */
.waiting-card {
  max-width: 500px;
  text-align: center;
}
.waiting-card h2 { font-size: 1.8rem; margin-bottom: 20px; }
.room-code-display {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--accent2);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.room-code-display button {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.2s;
}
.room-code-display button:hover { color: var(--text); }
#player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
  min-height: 50px;
}
.player-chip {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface2);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.player-chip.host::after { content: ' 👑'; }
.hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 16px; }

/* ROUND START OVERLAY */
.overlay-screen {
  background: rgba(10,10,20,0.96);
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 100;
}
.round-announce {
  text-align: center;
  animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
#round-label {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
}
#word-reveal {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--accent2);
  margin-bottom: 12px;
  text-shadow: 0 0 30px rgba(245,166,35,0.5);
}
#role-label {
  font-size: 1rem;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 999px;
  display: inline-block;
}
#role-label.imposter-role {
  background: rgba(233,69,96,0.2);
  color: var(--accent);
  font-weight: 700;
}

/* GAME HEADER */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 10;
}
.info-left { display: flex; gap: 16px; align-items: center; }
.word-tag { font-size: 0.95rem; color: var(--text-muted); }
.word-tag strong { color: var(--accent2); }
#draw-round-label { font-size: 0.85rem; color: var(--text-muted); }
.timer-box {
  background: var(--accent);
  color: white;
  font-size: 1.4rem;
  font-weight: 900;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}
.timer-box.urgent { background: var(--red); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }

/* DRAWING SCREEN */
#screen-drawing {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  position: relative;
}
.canvas-area {
  display: flex;
  flex: 1;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  flex-wrap: wrap;
}
#main-canvas {
  background: white;
  border-radius: 10px;
  cursor: crosshair;
  touch-action: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  max-width: 100%;
}
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  min-width: 70px;
  align-items: center;
}
.colors { display: flex; flex-direction: column; gap: 6px; }
.color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.1s;
}
.color-btn:hover { transform: scale(1.15); }
.color-btn.active { border-color: white; transform: scale(1.2); }
.sizes { display: flex; flex-direction: column; gap: 6px; }
.size-btn {
  width: 36px;
  height: 28px;
  background: var(--surface2);
  color: var(--text);
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
}
.size-btn.active { border-color: var(--accent); color: var(--accent); }
#submitted-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10,10,20,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
}
.submitted-msg {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--green);
  background: var(--surface);
  padding: 32px 40px;
  border-radius: var(--radius);
}
.submitted-msg small { color: var(--text-muted); font-size: 0.85rem; font-weight: 400; }

/* VOTING */
#screen-voting {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
}
.vote-info {
  text-align: center;
  padding: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.drawings-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  padding: 16px;
}
.drawing-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  border: 3px solid transparent;
  transition: all 0.2s;
}
.drawing-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.drawing-card.voted { border-color: var(--accent); background: rgba(233,69,96,0.1); }
.drawing-card img {
  width: 180px;
  height: 130px;
  object-fit: contain;
  background: white;
  border-radius: 8px;
  display: block;
  margin-bottom: 8px;
}
.drawing-card .player-name { font-size: 0.9rem; color: var(--text-muted); }
.player-vote-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 0 16px 16px;
}
.vote-btn {
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--text);
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
}
.vote-btn:hover { border-color: var(--accent); color: var(--accent); }
.vote-btn.voted { border-color: var(--accent); background: rgba(233,69,96,0.2); color: var(--accent); }
.vote-btn:disabled { opacity: 0.5; cursor: default; }

/* ROUND RESULT */
#screen-result { flex-direction: column; }
.result-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 560px;
  width: 100%;
  text-align: center;
  animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
#result-icon { font-size: 4rem; margin-bottom: 12px; }
#result-title { font-size: 2rem; font-weight: 900; margin-bottom: 8px; }
#result-desc { color: var(--text-muted); margin-bottom: 24px; }
.word-reveal-result {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}
.word-box {
  background: var(--surface2);
  border-radius: 10px;
  padding: 12px 20px;
  flex: 1;
}
.word-box.imposter-box { border: 2px solid var(--accent); }
.word-label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.word-value { font-size: 1.2rem; font-weight: 700; color: var(--accent2); }
#vote-breakdown { margin-bottom: 16px; font-size: 0.9rem; color: var(--text-muted); }
.vote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.vote-row .vname { font-weight: 600; color: var(--text); }
.vote-row .vcount { color: var(--accent2); font-weight: 700; }
.imposter-tag {
  font-size: 0.7rem;
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

/* GAME OVER */
#screen-gameover { flex-direction: column; }
.gameover-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  animation: popIn 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
#gameover-icon { font-size: 5rem; margin-bottom: 16px; }
#gameover-title { font-size: 2.4rem; font-weight: 900; margin-bottom: 8px; }
#gameover-desc { color: var(--text-muted); margin-bottom: 24px; }
#final-scoreboard {
  background: var(--bg);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 24px;
  text-align: left;
}
.score-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.95rem;
}
.gameover-card .btn { width: 100%; margin-top: 10px; }

/* RESPONSIVE */
@media (max-width: 600px) {
  .logo h1 { font-size: 2.2rem; }
  .canvas-area { flex-direction: column; align-items: center; }
  .toolbar { flex-direction: row; flex-wrap: wrap; justify-content: center; min-width: unset; width: 100%; }
  .colors { flex-direction: row; }
  .sizes { flex-direction: row; }
  #main-canvas { width: 100% !important; height: auto !important; }
  .word-reveal-result { flex-direction: column; }
  #word-reveal { font-size: 2.5rem; }
}
