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

:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --accent: #e94560;
  --accent2: #533483;
  --text: #eee;
  --text-dim: #999;
  --green: #4caf50;
  --yellow: #ffc107;
  --radius: 10px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.screen { display: flex; align-items: center; justify-content: center; height: 100vh; }
.hidden { display: none !important; }

.btn {
  padding: 12px 28px; border: none; border-radius: var(--radius);
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}
.btn:hover { transform: scale(1.03); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-small { padding: 8px 14px; font-size: 14px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; }

/* ========= JOIN ========= */
#join-screen, #lobby-screen { position: relative; overflow: hidden; }
#bg-canvas, .bg-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.join-container {
  text-align: center; position: relative; z-index: 1;
  background: rgba(26, 26, 46, 0.85);
  padding: 48px 44px; border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: floatIn 0.7s ease-out;
}
@keyframes floatIn {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.logo {
  font-size: 56px; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), var(--yellow), var(--green), #2196f3, var(--accent2));
  background-size: 200% 200%;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  animation: gradientShift 4s ease infinite;
}
@keyframes gradientShift { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.subtitle { color: var(--text-dim); margin-bottom: 24px; font-size: 18px; }
.join-waiting { margin-bottom: 20px; animation: fadeInUp 0.4s ease; }
.join-waiting-text { color: var(--green); font-size: 14px; margin-bottom: 10px; }
.join-waiting-players { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.join-waiting-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg3); padding: 6px 12px; border-radius: 20px;
  font-size: 13px; border: 1px solid rgba(255,255,255,0.1); animation: fadeInUp 0.3s ease;
}
.join-waiting-chip svg { flex-shrink: 0; }
.join-waiting-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: blink 1.4s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(8px); } }
.join-form { display: flex; flex-direction: column; gap: 14px; width: 300px; margin: 0 auto; }
.join-form input {
  padding: 14px 18px; border: 2px solid #333; border-radius: var(--radius);
  background: var(--bg2); color: var(--text); font-size: 17px; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.join-form input:focus { border-color: var(--accent); box-shadow: 0 0 16px rgba(233,69,96,0.3); }
.join-form .btn-primary {
  font-size: 18px; padding: 14px 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 4px 20px rgba(233,69,96,0.4);
}
.join-form .btn-primary:hover { transform: scale(1.05); box-shadow: 0 6px 28px rgba(233,69,96,0.5); }

/* ========= ONLINE BADGE ========= */
.total-players-badge {
  position: absolute; top: -12px; right: -18px;
  background: var(--green); color: #fff;
  font-size: 12px; font-weight: 800;
  padding: 4px 10px; border-radius: 20px;
  box-shadow: 0 2px 10px rgba(76,175,80,0.5);
  animation: onlinePulse 2s ease-in-out infinite;
  pointer-events: none; z-index: 2;
  white-space: nowrap;
}
.total-players-badge:empty { display: none; }
@media (max-width: 480px) {
  .total-players-badge { right: 2px; }
}
@keyframes onlinePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* ========= ROOM BROWSER (bottom of join screen) ========= */
.room-browser-bottom {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 1; width: 90%; max-width: 560px;
}
.room-list-bottom {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.room-item {
  display: flex; align-items: center; gap: 10px;
  background: rgba(26,26,46,0.85); padding: 10px 16px; border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.1); cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  backdrop-filter: blur(12px);
}
.room-item:hover { border-color: var(--accent); background: rgba(15,52,96,0.9); transform: scale(1.04); }
.room-item-name { font-size: 14px; font-weight: 600; }
.room-item-badge {
  font-size: 10px; padding: 2px 6px; border-radius: 6px;
  background: var(--green); color: #fff; font-weight: 700; text-transform: uppercase; flex-shrink: 0;
}
.room-item-badge.in-game { background: var(--accent); }
.room-item-lang { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }
.room-item-count { font-size: 13px; color: var(--text-dim); flex-shrink: 0; }

/* Toggle public button */
.btn-toggle-public {
  margin-top: 10px; padding: 12px 28px; font-size: 16px;
  background: var(--bg3); color: var(--text); border: none;
  border-radius: var(--radius); cursor: pointer; font-weight: 600;
  transition: background 0.2s, transform 0.1s;
}
.btn-toggle-public:hover { background: var(--accent2); transform: scale(1.03); }
.btn-toggle-public:active { transform: scale(0.97); }
.btn-toggle-public.is-public { background: var(--green); color: #fff; }

/* ========= LOBBY ========= */
.lobby-container {
  text-align: center; position: relative; z-index: 1;
  background: rgba(26,26,46,0.85);
  padding: 40px 44px; border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(16px); box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: floatIn 0.7s ease-out;
}
.lobby-container h2 { margin-bottom: 24px; }
.lobby-players { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }
.lobby-player {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--bg2); padding: 16px 20px; border-radius: var(--radius);
}
.lobby-player .avatar { width: 48px; height: 48px; border-radius: 50%; }
.lobby-player.host { border: 2px solid var(--yellow); }
.lobby-player-status { font-size: 11px; color: var(--green); opacity: 0.8; }
.lobby-waiting { color: var(--text-dim); margin-bottom: 16px; font-size: 15px; }
.lobby-info { color: var(--text-dim); margin-bottom: 16px; }
.lobby-share { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.lobby-link-text { color: var(--yellow); font-size: 13px; word-break: break-all; background: var(--bg); padding: 8px 14px; border-radius: var(--radius); }
.btn-copy { background: var(--bg3); border: 1px solid var(--yellow); color: var(--yellow); }
.btn-copy:hover { background: var(--yellow); color: var(--bg); }

/* Language selector */
.language-selector {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 14px;
}
.language-selector label { font-size: 15px; color: var(--text-dim); }
.language-select {
  padding: 8px 14px; border-radius: var(--radius);
  background: var(--bg3); color: var(--text); border: 1px solid rgba(255,255,255,0.15);
  font-size: 15px; cursor: pointer; outline: none;
}
.language-select:focus { border-color: var(--accent); }

/* ========= GAME LAYOUT ========= */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto 1fr auto;
  height: 100vh; width: 100vw;
}

/* --- Player strip (top) --- */
.players-strip {
  grid-column: 1 / -1;
  display: flex; gap: 10px;
  padding: 18px 16px 10px;
  background: var(--bg2);
  justify-content: center;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  overflow: visible;
  z-index: 10;
  position: relative;
}

.player-card {
  background: var(--bg3);
  border-radius: 14px;
  padding: 0;
  display: flex; flex-direction: row; align-items: stretch;
  position: relative;
  border: 3px solid transparent;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
  width: 220px;
  flex-shrink: 0;
  overflow: hidden;
}

/* Card bounce when score changes */
.player-card.score-up {
  animation: cardBounceUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.player-card.score-down {
  animation: cardShake 0.5s ease-out;
}
@keyframes cardBounceUp {
  0%   { transform: scale(1); }
  25%  { transform: scale(1.12) rotate(-2deg); }
  50%  { transform: scale(0.95) rotate(1deg); }
  75%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}
@keyframes cardShake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px) rotate(-1deg); }
  30% { transform: translateX(5px) rotate(1deg); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-1px); }
}

/* Score change animation */
.score-pop {
  font-size: 32px;
  font-weight: 900;
  text-shadow: 0 0 12px currentColor, 0 0 24px currentColor, 0 2px 4px rgba(0,0,0,0.6);
  letter-spacing: 1px;
  will-change: transform, opacity;
  animation: scoreFloat 1.6s ease-out forwards;
}
.score-pop.positive { color: #2ecc71; }
.score-pop.negative { color: #e74c3c; }
@keyframes scoreFloat {
  0%   { opacity: 0; transform: translateX(-50%) translateY(8px) scale(0.4); }
  5%   { opacity: 0.4; transform: translateX(-50%) translateY(4px) scale(0.7); }
  10%  { opacity: 0.8; transform: translateX(-50%) translateY(0px) scale(1.0); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(-4px) scale(1.2); }
  20%  { opacity: 1; transform: translateX(-50%) translateY(-8px) scale(1.3); }
  25%  { opacity: 1; transform: translateX(-50%) translateY(-12px) scale(1.25); }
  30%  { opacity: 1; transform: translateX(-50%) translateY(-16px) scale(1.15); }
  35%  { opacity: 1; transform: translateX(-50%) translateY(-20px) scale(1.1); }
  40%  { opacity: 1; transform: translateX(-50%) translateY(-24px) scale(1.05); }
  50%  { opacity: 1; transform: translateX(-50%) translateY(-32px) scale(1.0); }
  60%  { opacity: 0.95; transform: translateX(-50%) translateY(-40px) scale(0.97); }
  70%  { opacity: 0.8; transform: translateX(-50%) translateY(-48px) scale(0.93); }
  80%  { opacity: 0.55; transform: translateX(-50%) translateY(-56px) scale(0.88); }
  90%  { opacity: 0.25; transform: translateX(-50%) translateY(-64px) scale(0.82); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-72px) scale(0.75); }
}

.score-particle {
  width: 7px; height: 7px;
  border-radius: 50%;
  will-change: transform, opacity;
  animation: particleBurst 1s ease-out forwards;
}
@keyframes particleBurst {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  10%  { opacity: 1; transform: translate(calc(var(--px) * 0.15), calc(var(--py) * 0.15)) scale(1.1); }
  20%  { opacity: 1; transform: translate(calc(var(--px) * 0.35), calc(var(--py) * 0.35)) scale(1.05); }
  30%  { opacity: 0.95; transform: translate(calc(var(--px) * 0.5), calc(var(--py) * 0.5)) scale(1); }
  40%  { opacity: 0.9; transform: translate(calc(var(--px) * 0.63), calc(var(--py) * 0.63)) scale(0.9); }
  50%  { opacity: 0.8; transform: translate(calc(var(--px) * 0.73), calc(var(--py) * 0.73)) scale(0.8); }
  60%  { opacity: 0.65; transform: translate(calc(var(--px) * 0.82), calc(var(--py) * 0.82)) scale(0.65); }
  70%  { opacity: 0.45; transform: translate(calc(var(--px) * 0.89), calc(var(--py) * 0.89)) scale(0.5); }
  80%  { opacity: 0.3; transform: translate(calc(var(--px) * 0.94), calc(var(--py) * 0.94)) scale(0.35); }
  90%  { opacity: 0.12; transform: translate(calc(var(--px) * 0.98), calc(var(--py) * 0.98)) scale(0.2); }
  100% { opacity: 0; transform: translate(var(--px), var(--py)) scale(0); }
}
.player-card.drawing { border-color: var(--yellow); box-shadow: 0 0 12px rgba(255, 193, 7, 0.3); }
.player-card.disconnected { opacity: 0.35; }
.player-card.guessed {
  border-color: var(--green);
  box-shadow: 0 0 14px rgba(46, 204, 113, 0.35);
  animation: guessedPulse 0.5s ease-out;
}
@keyframes guessedPulse {
  0%   { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.6); }
  50%  { box-shadow: 0 0 20px 6px rgba(46, 204, 113, 0.4); }
  100% { box-shadow: 0 0 14px rgba(46, 204, 113, 0.35); }
}

/* Avatar / Video area */
.avatar-area {
  width: 115px; height: 101px;
  position: relative;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  border-radius: 11px 0 0 11px;
}
.avatar-area .avatar-small {
  display: flex; align-items: center; justify-content: center;
}
.avatar-video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* Player info — sits to the right of avatar */
.player-card .player-info {
  flex: 1; min-width: 0;
  padding: 10px 10px 10px 8px;
  display: flex; flex-direction: column; justify-content: center;
  text-align: left;
  background: var(--bg3);
}
.player-card .player-name {
  font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.3;
}
.player-card .player-score {
  font-size: 17px; color: var(--yellow); font-weight: 700;
  margin-top: 2px;
}
.player-card .drawing-icon {
  position: absolute; top: 4px; right: 6px; font-size: 16px;
  background: rgba(0,0,0,0.5); border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}

/* Media buttons — overlaid on avatar area */
.media-btns {
  position: absolute; bottom: 4px; right: 4px;
  display: flex; gap: 3px; z-index: 2;
}
.media-btn {
  width: 28px; height: 28px;
  border: none; border-radius: 8px;
  background: rgba(0,0,0,0.55);
  color: var(--text-dim);
  font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
  padding: 0; line-height: 1;
  backdrop-filter: blur(4px);
}
.media-btn:hover { background: rgba(0,0,0,0.7); color: #fff; }
.media-btn.active { background: var(--green); color: #fff; }

/* --- Main area: canvas --- */
.game-main {
  grid-column: 1; grid-row: 2;
  display: flex; min-height: 0; min-width: 0;
}
.center {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}
.canvas-container {
  flex: 1; background: #fff;
  position: relative; overflow: hidden;
}
.canvas-container canvas { display: block; }

/* --- Bottom bar: palette+tools (left) | word (center) | timer (right) --- */
.game-bottom-bar {
  grid-column: 1 / -1; grid-row: 3;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 18px;
  background: var(--bg2);
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* Palette toggle — hidden on desktop */
.palette-toggle { display: none; }
.bottom-tools-area {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  flex-shrink: 0;
}
.bottom-word-area {
  flex: 1;
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  min-width: 0;
}
.word-display {
  font-size: 30px; letter-spacing: 4px; font-family: monospace;
  white-space: pre; overflow: hidden; text-overflow: ellipsis;
}
.timer-display {
  font-size: 28px; font-weight: 700; color: var(--yellow);
  width: 60px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border-radius: 8px;
  flex-shrink: 0;
}
.timer-display.warning { color: var(--accent); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.15); } }
.color-palette {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
}
.color-swatch {
  width: 28px; height: 28px; border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer; transition: transform 0.1s, border-color 0.1s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.color-swatch.active { border-color: #fff; transform: scale(1.25); box-shadow: 0 0 8px rgba(255,255,255,0.3); }
.color-swatch:hover { transform: scale(1.15); }

.draw-tools {
  display: flex; flex-direction: column; gap: 6px;
}
.draw-tools-row {
  display: flex; align-items: center; gap: 8px;
}
.brush-sizes { display: flex; gap: 4px; }
.brush-size {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid #555;
  background: var(--bg3); color: var(--text); cursor: pointer;
  font-size: 11px; font-weight: 700;
}
.brush-size.active { border-color: var(--accent); background: var(--accent); }
.brush-size:hover { border-color: var(--accent); }
.tool-btn {
  padding: 7px 14px; border: 2px solid #555; border-radius: var(--radius);
  background: var(--bg3); color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 600;
}
.tool-btn:hover { border-color: var(--accent); }
.tool-btn.active { border-color: var(--accent); background: var(--accent); }

/* ========= CHAT ========= */
.chat-panel {
  grid-column: 2; grid-row: 2;
  background: var(--bg2);
  display: flex; flex-direction: column;
  border-left: 1px solid rgba(255,255,255,0.06);
  min-height: 0;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.chat-msg { font-size: 16px; line-height: 1.5; }
.chat-msg .name { font-weight: 700; }
.chat-msg.correct { color: var(--green); font-weight: 600; }
.chat-msg.system { color: var(--text-dim); font-style: italic; }
.chat-msg.error { color: var(--accent); font-weight: 700; font-size: 17px; padding: 8px 0; }
.chat-input-row {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid #333;
  align-items: stretch;
}
.chat-input-row input {
  flex: 1; padding: 14px 16px; border: 2px solid transparent; border-radius: var(--radius);
  background: #ffffff; color: #111; font-size: 16px; outline: none;
  min-height: 50px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.chat-input-row input:focus {
  border-color: var(--accent); box-shadow: 0 0 12px rgba(233,69,96,0.25);
}
.chat-input-row input::placeholder { color: #999; transition: color 0.3s; }

/* Disabled/drawing state — grayed out */
.chat-input-row input:disabled {
  background: #3a3a4a; color: #666;
  border-color: transparent; box-shadow: none;
  cursor: not-allowed;
}
.chat-input-row input:disabled::placeholder { color: #555; }
.chat-input-row .btn-small:disabled {
  background: #3a3a4a; color: #666; cursor: not-allowed;
}

/* Guessing state — animated pulsing glow on the input */
.chat-input-row.guessing input {
  border-color: var(--green);
  box-shadow: 0 0 10px rgba(76,175,80,0.3);
  animation: guessInputPulse 2s ease-in-out infinite;
}
.chat-input-row.guessing input::placeholder {
  animation: guessPlaceholderPulse 2s ease-in-out infinite;
}
@keyframes guessInputPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(76,175,80,0.2); }
  50% { box-shadow: 0 0 20px rgba(76,175,80,0.5); }
}
@keyframes guessPlaceholderPulse {
  0%, 100% { color: #bbb; }
  50% { color: #4caf50; }
}

.chat-input-row .btn-small {
  padding: 14px 24px; font-size: 16px; font-weight: 700;
  min-height: 50px;
}

/* ========= OVERLAYS ========= */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.overlay-content {
  background: var(--bg2); padding: 32px 40px; border-radius: 16px;
  text-align: center; max-width: 420px;
}
.word-choices { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
.word-choice-btn {
  padding: 14px 24px; background: var(--bg3);
  border: 2px solid var(--accent); border-radius: var(--radius);
  color: var(--text); font-size: 18px; cursor: pointer;
}
.word-choice-btn:hover { background: var(--accent); }
.overlay-content { position: relative; }
.pick-timer {
  position: absolute; top: -18px; right: -18px;
  font-size: 24px; font-weight: 800; color: var(--yellow);
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border-radius: 50%;
  border: 3px solid var(--yellow);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  z-index: 10;
}
.pick-timer.warning { color: var(--accent); border-color: var(--accent); animation: pulse 0.5s infinite alternate; }
#final-scores { margin: 16px 0; }
.score-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 16px; }
.score-row .score-val { color: var(--yellow); font-weight: 700; }

/* ========= HOW TO PLAY ========= */
.btn-how-to-play {
  position: absolute; bottom: 24px; left: 24px; z-index: 2;
  padding: 10px 20px; border: none; border-radius: var(--radius);
  background: #e67e22; color: #fff;
  font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 14px rgba(230,126,34,0.4);
  transition: transform 0.1s, box-shadow 0.2s;
}
.btn-how-to-play:hover { transform: scale(1.05); box-shadow: 0 5px 20px rgba(230,126,34,0.5); }
.btn-how-to-play:active { transform: scale(0.97); }

.how-to-play-content { max-width: 460px; text-align: left; }
.how-to-play-content h2 { text-align: center; margin-bottom: 18px; }
.how-to-play-list {
  list-style: none; padding: 0; margin: 0 0 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.how-to-play-list li {
  font-size: 15px; line-height: 1.5; padding-left: 28px; position: relative;
}
.how-to-play-list li::before {
  content: '🎨'; position: absolute; left: 0; top: 0;
}
.how-to-play-list li:nth-child(2)::before { content: '✏️'; }
.how-to-play-list li:nth-child(3)::before { content: '💬'; }
.how-to-play-list li:nth-child(4)::before { content: '⏱️'; }
.how-to-play-list li:nth-child(5)::before { content: '⭐'; }
.how-to-play-list li:nth-child(6)::before { content: '🏆'; }
.how-to-play-list li:nth-child(7)::before { content: '🌍'; }
.how-to-play-content .btn-primary { display: block; margin: 0 auto; }

/* ========= FEEDBACK ========= */
.btn-feedback {
  position: absolute; bottom: 24px; right: 24px; z-index: 2;
  padding: 10px 20px; border: none; border-radius: var(--radius);
  background: #8e44ad; color: #fff;
  font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 14px rgba(142,68,173,0.4);
  transition: transform 0.1s, box-shadow 0.2s;
}
.btn-feedback:hover { transform: scale(1.05); box-shadow: 0 5px 20px rgba(142,68,173,0.5); }
.btn-feedback:active { transform: scale(0.97); }

.feedback-content { max-width: 480px; text-align: left; }
.feedback-content h2 { text-align: center; margin-bottom: 20px; font-size: 22px; }
.feedback-text { font-size: 14px; line-height: 1.7; color: var(--text-dim); margin-bottom: 16px; }
.feedback-text:last-of-type { margin-bottom: 24px; }
.feedback-email-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 24px; background: var(--bg); padding: 12px 18px; border-radius: var(--radius);
}
.feedback-email {
  color: var(--yellow); font-size: 15px; font-weight: 600;
}
.feedback-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 4px; }
.feedback-buttons .btn-primary { text-decoration: none; }

/* ========= TOAST ========= */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg3); padding: 10px 18px; border-radius: var(--radius);
  font-size: 14px; animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.5s forwards;
  border-left: 4px solid var(--accent);
}
.toast.success { border-left-color: var(--green); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(50%); } }

/* Wrong guess */
.wrong-guess-pop {
  position: fixed; z-index: 300;
  font-size: 22px; font-weight: 800;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(233,69,96,0.6), 0 2px 4px rgba(0,0,0,0.5);
  pointer-events: none; transform: translate(-50%, 0);
  animation: wrongPop 0.85s ease-out forwards;
}
@keyframes wrongPop {
  0% { opacity: 1; transform: translate(-50%, 0) scale(0.5) rotate(-5deg); }
  20% { opacity: 1; transform: translate(-50%, -10px) scale(1.3) rotate(3deg); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(0.8) rotate(-2deg); }
}

/* ========= RESPONSIVE ========= */

/* --- Shared mobile base: stack everything vertically, reorder --- */
@media (max-width: 768px), (max-height: 500px) {
  .game-layout {
    display: flex; flex-direction: column; overflow: hidden;
  }
  .players-strip  { order: 1; flex-shrink: 0; }
  .game-main      { order: 2; flex: 1; min-height: 0; }
  .game-bottom-bar { order: 3; flex-shrink: 0; }
  .chat-panel {
    order: 4; width: 100%; flex-shrink: 0;
    border-left: none; border-top: 1px solid rgba(255,255,255,0.06);
  }
  .chat-messages { flex: 1; min-height: 0; overflow-y: auto; }
  .chat-input-row { flex-shrink: 0; }

  /* Stack bottom bar vertically so palette never overlaps word/timer */
  .game-bottom-bar {
    flex-direction: column; align-items: stretch; gap: 6px;
    padding: 6px 8px;
  }
  .bottom-tools-area { flex-shrink: 1; justify-content: center; }
  .bottom-word-area { justify-content: center; }

  /* Palette toggle + collapse on all mobile */
  .palette-toggle { display: inline-block; align-self: center; }
  .color-palette.collapsed, .draw-tools.collapsed { display: none !important; }
}

/* --- Narrow screens (portrait phones / small tablets) --- */
@media (max-width: 768px) {
  .players-strip { gap: 6px; padding: 6px 8px; }
  .player-card { width: 80px; flex-direction: column; }
  .avatar-area { width: 80px; height: 60px; border-radius: 11px 11px 0 0; }
  .player-card .player-info { text-align: center; padding: 4px 6px 6px; }
  .player-card .player-name { font-size: 11px; }
  .player-card .player-score { font-size: 11px; margin-top: 0; }
  .color-swatch { width: 20px; height: 20px; }
  .color-palette { grid-template-rows: repeat(2, 1fr); }
  .chat-panel { max-height: 140px; }
  .chat-input-row .btn-small { padding: 8px 14px; font-size: 14px; min-height: auto; }
  .chat-input-row input { min-height: auto; }
  .word-display { font-size: 18px; letter-spacing: 2px; }
  .timer-display { font-size: 18px; width: 44px; height: 36px; }
}

/* --- Landscape / short screens --- */
@media (max-height: 500px) {
  .players-strip {
    gap: 4px; padding: 4px 6px;
    flex-wrap: nowrap; overflow-x: auto;
  }
  .player-card { width: 64px; flex-direction: column; }
  .avatar-area { width: 64px; height: 44px; border-radius: 11px 11px 0 0; }
  .player-card .player-info { text-align: center; padding: 2px 4px 4px; }
  .player-card .player-name { font-size: 9px; }
  .player-card .player-score { font-size: 9px; margin-top: 0; }

  .game-bottom-bar { padding: 4px 6px; gap: 4px; }
  .color-swatch { width: 18px; height: 18px; }

  .chat-panel { max-height: 30vh; min-height: 70px; }
  .chat-input-row { padding: 4px 6px; }
  .chat-input-row input { padding: 6px 10px; font-size: 13px; min-height: auto; }
  .word-display { font-size: 16px; letter-spacing: 2px; }
  .timer-display { width: 36px; height: 30px; font-size: 15px; }
}
