:root {
  --bg: #FBF7EF;
  --surface: #ffffff;
  --surface2: #f3ede3;
  --text: #1a1a1a;
  --text-muted: #9a8f82;
  --accent-red: #FE564B;
  --accent-pink: #EE94B8;
  --accent-yellow: #E9C12A;
  --accent-dusty: #C9756C;
  --star-color: #C9756C;
  --radius: 16px;
  --radius-sm: 10px;
}

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

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

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 28px 24px;
  overflow-y: auto;
  z-index: 1;
}
.screen.active { display: flex; }

.home-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 44px;
  flex: 1;
  z-index: 2;
  position: relative;
}

.logo-block {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-12px) rotate(5deg); }
}

.logo {
  font-family: 'Baloo Bhai 2', cursive;
  font-size: clamp(3rem, 10vw, 5.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
  color: var(--accent-pink);
}
.logo span { color: var(--accent-red); }

.tagline {
  font-family: 'Sarala', sans-serif;
  font-size: 0.95rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.floating-cards {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-cards span {
  position: absolute;
  color: var(--star-color);
  animation: glitter 4s ease-in-out infinite;
  line-height: 1;
  user-select: none;
}

.floating-cards span:nth-child(1)  { top:  5%; left:  3%; font-size: 1.0rem; animation-delay: 0.0s; animation-duration: 3.5s; }
.floating-cards span:nth-child(2)  { top:  8%; left: 20%; font-size: 0.6rem; animation-delay: 0.4s; animation-duration: 4.0s; }
.floating-cards span:nth-child(3)  { top:  3%; left: 45%; font-size: 1.2rem; animation-delay: 0.8s; animation-duration: 3.2s; }
.floating-cards span:nth-child(4)  { top:  7%; left: 68%; font-size: 0.5rem; animation-delay: 1.2s; animation-duration: 4.5s; }
.floating-cards span:nth-child(5)  { top:  2%; left: 85%; font-size: 0.9rem; animation-delay: 0.3s; animation-duration: 3.8s; }
.floating-cards span:nth-child(6)  { top: 15%; left:  8%; font-size: 0.7rem; animation-delay: 1.5s; animation-duration: 4.2s; }
.floating-cards span:nth-child(7)  { top: 18%; left: 92%; font-size: 1.1rem; animation-delay: 0.6s; animation-duration: 3.6s; }
.floating-cards span:nth-child(8)  { top: 25%; left: 30%; font-size: 0.5rem; animation-delay: 2.0s; animation-duration: 5.0s; }
.floating-cards span:nth-child(9)  { top: 28%; left: 55%; font-size: 0.8rem; animation-delay: 0.9s; animation-duration: 3.3s; }
.floating-cards span:nth-child(10) { top: 22%; left: 75%; font-size: 0.6rem; animation-delay: 1.8s; animation-duration: 4.1s; }
.floating-cards span:nth-child(11) { top: 35%; left:  2%; font-size: 1.0rem; animation-delay: 0.2s; animation-duration: 3.9s; }
.floating-cards span:nth-child(12) { top: 38%; left: 18%; font-size: 0.5rem; animation-delay: 2.5s; animation-duration: 4.4s; }
.floating-cards span:nth-child(13) { top: 40%; left: 88%; font-size: 0.9rem; animation-delay: 1.1s; animation-duration: 3.7s; }
.floating-cards span:nth-child(14) { top: 48%; left: 42%; font-size: 0.6rem; animation-delay: 3.0s; animation-duration: 5.2s; }
.floating-cards span:nth-child(15) { top: 52%; left: 65%; font-size: 1.2rem; animation-delay: 0.7s; animation-duration: 3.4s; }
.floating-cards span:nth-child(16) { top: 55%; left: 10%; font-size: 0.7rem; animation-delay: 1.9s; animation-duration: 4.6s; }
.floating-cards span:nth-child(17) { top: 60%; left: 78%; font-size: 0.5rem; animation-delay: 2.3s; animation-duration: 3.1s; }
.floating-cards span:nth-child(18) { top: 65%; left: 25%; font-size: 1.0rem; animation-delay: 0.5s; animation-duration: 4.3s; }
.floating-cards span:nth-child(19) { top: 70%; left: 50%; font-size: 0.6rem; animation-delay: 1.6s; animation-duration: 3.8s; }
.floating-cards span:nth-child(20) { top: 68%; left: 93%; font-size: 0.8rem; animation-delay: 2.8s; animation-duration: 4.7s; }
.floating-cards span:nth-child(21) { top: 78%; left:  5%; font-size: 0.5rem; animation-delay: 0.1s; animation-duration: 3.5s; }
.floating-cards span:nth-child(22) { top: 80%; left: 38%; font-size: 1.1rem; animation-delay: 2.1s; animation-duration: 4.0s; }
.floating-cards span:nth-child(23) { top: 82%; left: 60%; font-size: 0.6rem; animation-delay: 1.3s; animation-duration: 3.6s; }
.floating-cards span:nth-child(24) { top: 88%; left: 82%; font-size: 0.9rem; animation-delay: 3.2s; animation-duration: 5.1s; }
.floating-cards span:nth-child(25) { top: 92%; left: 15%; font-size: 0.7rem; animation-delay: 0.8s; animation-duration: 4.2s; }

@keyframes glitter {
  0%, 100% { opacity: 0.15; transform: scale(1) rotate(0deg); }
  25% { opacity: 0.9; transform: scale(1.3) rotate(20deg); }
  50% { opacity: 0.3; transform: scale(0.8) rotate(-10deg); }
  75% { opacity: 0.8; transform: scale(1.1) rotate(15deg); }
}

.btn {
  padding: 15px 24px;
  border: 2.5px solid var(--text);
  border-radius: 999px;
  font-family: 'Baloo Bhai 2', cursive;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  letter-spacing: 0.01em;
}
.btn:active { transform: translateY(2px) !important; }

.btn-primary {
  background: #7A9476;
  color: #fff;
  width: 100%;
  font-size: 1.05rem;
  box-shadow: 4px 4px 0 var(--text);
}
.btn-primary:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--text); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--accent-yellow);
  color: var(--text);
  width: 100%;
  box-shadow: 4px 4px 0 var(--text);
}
.btn-secondary:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--text); }

.btn-small {
  background: var(--surface);
  color: var(--text);
  padding: 8px 18px;
  font-size: 0.85rem;
  border-radius: 999px;
  font-family: 'Baloo Bhai 2', cursive;
  font-weight: 700;
  border: 2px solid var(--text);
  box-shadow: 3px 3px 0 var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn-small:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--text); }

.top-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  z-index: 2;
  position: relative;
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Sarala', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}
.back-btn:hover { color: var(--text); }

.screen-title {
  font-family: 'Baloo Bhai 2', cursive;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
}

.host-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  z-index: 2;
  position: relative;
}

.label {
  font-family: 'Sarala', sans-serif;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.hint {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: 'Sarala', sans-serif;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: #ddd5c8;
  border-radius: 2px;
}

.game-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.game-card {
  background: var(--surface);
  border: 2.5px solid var(--text);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: 4px 4px 0 var(--text);
}
.game-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--text); }
.game-card.selected { background: var(--accent-pink); transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--text); }

.game-icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.game-card h3 { font-family: 'Baloo Bhai 2', cursive; font-size: 1.05rem; font-weight: 800; margin-bottom: 4px; color: var(--text); }
.game-card p { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }

.custom-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 2.5px solid var(--text);
  box-shadow: 4px 4px 0 var(--text);
}

textarea {
  background: var(--surface2);
  border: 2px solid var(--text);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Sarala', sans-serif;
  font-size: 0.95rem;
  padding: 12px 14px;
  resize: vertical;
  min-height: 90px;
  transition: border-color 0.2s;
  line-height: 1.5;
}
textarea:focus { outline: none; border-color: var(--accent-red); }
textarea::placeholder { color: var(--text-muted); }

.game-meta { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.room-pill {
  background: var(--accent-yellow);
  color: var(--text);
  font-family: 'Baloo Bhai 2', cursive;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 4px 14px;
  border-radius: 999px;
  border: 2px solid var(--text);
  letter-spacing: 0.08em;
  box-shadow: 3px 3px 0 var(--text);
}

.game-content { flex: 1; display: flex; align-items: center; justify-content: center; z-index: 2; position: relative; }

.word-stage { display: flex; flex-direction: column; align-items: center; gap: 22px; width: 100%; max-width: 440px; }

.round-label { font-family: 'Sarala', sans-serif; font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.14em; }

.word-card {
  background: var(--surface);
  border: 2.5px solid var(--text);
  border-radius: 24px;
  padding: 40px 32px;
  width: 100%;
  text-align: center;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 6px 6px 0 var(--text);
  position: relative;
  overflow: hidden;
}
.word-card::before { content: '★'; position: absolute; top: 12px; right: 16px; font-size: 1rem; color: var(--star-color); opacity: 0.8; }
.word-card::after { content: '✦'; position: absolute; bottom: 12px; left: 16px; font-size: 0.8rem; color: var(--star-color); opacity: 0.8; }

#current-word, #player-current-word {
  font-family: 'Baloo Bhai 2', cursive;
  font-size: clamp(1.8rem, 6vw, 3rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
  position: relative;
  z-index: 1;
}

.word-actions { display: flex; gap: 12px; width: 100%; }
.word-actions .btn { flex: 1; }

.score-bar { display: flex; gap: 20px; font-size: 0.82rem; color: var(--text-muted); font-family: 'Sarala', sans-serif; }

.players-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.player-chip {
  background: var(--accent-dusty);
  color: #fff;
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.75rem;
  font-family: 'Baloo Bhai 2', cursive;
  font-weight: 700;
  border: 2px solid var(--text);
  box-shadow: 2px 2px 0 var(--text);
}

.player-view { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; gap: 20px; z-index: 2; position: relative; text-align: center; }
.player-hint { font-size: 0.82rem; color: var(--text-muted); font-family: 'Sarala', sans-serif; }

.pulse-ring {
  width: 60px; height: 60px; border-radius: 50%;
  background: rgba(238, 148, 184, 0.15);
  border: 2.5px solid var(--accent-pink);
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

.screen.active { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.word-card.flip { animation: flip 0.25s ease; }
@keyframes flip {
  0% { transform: scale(1); }
  50% { transform: scale(0.96); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

/* HOST LOBBY */
.lobby-content { display: flex; flex-direction: column; gap: 20px; max-width: 480px; margin: 0 auto; width: 100%; z-index: 2; position: relative; }

.lobby-code-block {
  background: var(--accent-yellow);
  border: 2.5px solid var(--text);
  border-radius: var(--radius);
  padding: 24px 20px 18px;
  text-align: center;
  box-shadow: 5px 5px 0 var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.lobby-code-display {
  font-family: 'Baloo Bhai 2', cursive;
  font-size: clamp(2.8rem, 12vw, 4.5rem);
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.18em;
  line-height: 1;
}

.lobby-code-hint { font-size: 0.78rem; color: var(--text-muted); font-family: 'Sarala', sans-serif; }

.lobby-share-block {
  background: var(--surface);
  border: 2.5px solid var(--text);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 4px 4px 0 var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-link-row { display: flex; align-items: center; gap: 10px; }

.lobby-link-text {
  font-family: 'Sarala', sans-serif;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-players-block {
  background: var(--surface);
  border: 2.5px solid var(--text);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 4px 4px 0 var(--text);
  min-height: 90px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lobby-player-count { font-family: 'Baloo Bhai 2', cursive; font-size: 1rem; font-weight: 700; color: var(--text-muted); }
.lobby-players-list { display: flex; flex-wrap: wrap; gap: 8px; }

.lobby-player-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 14px 5px 10px;
  font-family: 'Baloo Bhai 2', cursive;
  font-size: 0.82rem;
  font-weight: 700;
  border: 2px solid var(--text);
  box-shadow: 2px 2px 0 var(--text);
  color: var(--text);
  animation: popIn 0.2s ease;
}

@keyframes popIn { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.lobby-player-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text); opacity: 0.4; flex-shrink: 0; }

.lobby-launch-block { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.lobby-launch-hint { font-size: 0.75rem; color: var(--text-muted); font-family: 'Sarala', sans-serif; text-align: center; }

/* JOIN SCREEN */
.join-content { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; z-index: 2; position: relative; width: 100%; }

.join-card {
  background: var(--surface);
  border: 2.5px solid var(--text);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 6px 6px 0 var(--text);
}

.join-field { display: flex; flex-direction: column; gap: 6px; }

.join-input {
  background: var(--surface2);
  border: 2px solid var(--text);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Sarala', sans-serif;
  font-size: 1rem;
  padding: 12px 14px;
  transition: border-color 0.2s;
  width: 100%;
}
.join-input:focus { outline: none; border-color: var(--accent-red); }
.join-input::placeholder { color: var(--text-muted); }

.join-input-code {
  font-family: 'Baloo Bhai 2', cursive;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
}

.join-error {
  background: #fde8e6;
  border: 2px solid var(--accent-red);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.82rem;
  color: var(--accent-red);
  font-family: 'Sarala', sans-serif;
  text-align: center;
}