:root {
  --bg-start: #0f0c29;
  --bg-mid: #302b63;
  --bg-end: #24243e;
  --primary: #ffd200;
  --primary-dark: #f7971e;
  --text: #fff;
  --text-muted: #aaa;
  --text-dim: #888;
  --text-placeholder: #666;
  --card-bg: rgba(255, 255, 255, 0.07);
  --card-border: rgba(255, 255, 255, 0.1);
  --input-border: rgba(255, 255, 255, 0.2);
  --input-bg: rgba(255, 255, 255, 0.08);
  --correct: #48c78e;
  --correct-bg: rgba(72, 199, 142, 0.25);
  --wrong: #ff6464;
  --wrong-bg: rgba(255, 100, 100, 0.2);
  --wrong-bg-light: rgba(255, 100, 100, 0.15);
  --primary-glow: rgba(255, 210, 0, 0.3);
  --primary-bg-light: rgba(247, 151, 30, 0.2);
  --key-bg: rgba(255, 255, 255, 0.07);
  --key-border: rgba(255, 255, 255, 0.15);
  --key-hover-bg: rgba(255, 210, 0, 0.2);
}

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

body {
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg-start);
  background: linear-gradient(135deg, var(--bg-start), var(--bg-mid), var(--bg-end));
  min-height: 100vh;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.app-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

h1 {
  font-size: 2.2rem;
  margin-bottom: 4px;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 520px;
  margin-bottom: 16px;
}

.lobby-title {
  text-align: center;
  margin-bottom: 16px;
}

.room-display {
  font-size: 2.8rem;
  font-weight: bold;
  letter-spacing: 12px;
  color: var(--primary);
  margin: 16px 0 8px;
  text-align: center;
}

.room-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 20px;
  text-align: center;
}

.player-slots {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.slot {
  flex: 1;
  max-width: 180px;
  border: 2px dashed var(--input-border);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  transition: all 0.3s;
}

.slot.filled {
  border-color: var(--primary);
  border-style: solid;
}

.slot-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.slot-name {
  font-size: 1rem;
  font-weight: bold;
}

.slot-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

input[type=text] {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 12px;
  outline: none;
  transition: border 0.2s;
}

input[type=text]:focus {
  border-color: var(--primary);
}

input[type=text]::placeholder {
  color: var(--text-placeholder);
}

.room-code-input {
  text-transform: uppercase;
  letter-spacing: 6px;
  text-align: center;
}

.secret-word-input {
  letter-spacing: 4px;
  font-size: 1.2rem;
  text-transform: uppercase;
}

button {
  padding: 12px 28px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
  color: #111;
  width: 100%;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--input-border);
  width: 100%;
  margin-top: 8px;
}

.word-entry-card {
  text-align: center;
}

.word-entry-card h2 {
  margin-bottom: 8px;
}

.word-entry-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.waiting-card {
  text-align: center;
  padding: 20px 28px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--card-border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.turn-banner {
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  font-weight: bold;
  font-size: 1rem;
  margin-bottom: 16px;
  transition: all 0.3s;
}

.turn-your {
  background: var(--primary-bg-light);
  border: 1px solid var(--primary-dark);
  color: var(--primary);
}

.turn-wait {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
}

.hangman-area {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.gallows-svg {
  filter: drop-shadow(0 0 8px rgba(255, 100, 100, 0.3));
}

.hint-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 16px;
}

.word-display {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.letter-box {
  width: 36px;
  height: 44px;
  border-bottom: 3px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text);
  transition: all 0.3s;
}

.letter-box.space {
  border-color: transparent;
  width: 20px;
}

.letter-box.revealed {
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  0% { transform: scale(0); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.guessed-letters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  min-height: 36px;
}

.guess-chip {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.95rem;
  animation: fadeSlide 0.2s ease;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.guess-chip.correct {
  background: var(--correct-bg);
  border: 1px solid var(--correct);
  color: var(--correct);
}

.guess-chip.wrong {
  background: var(--wrong-bg);
  border: 1px solid var(--wrong);
  color: var(--wrong);
}

.keyboard {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
  margin-bottom: 16px;
}

.key {
  padding: 10px 4px;
  border-radius: 7px;
  border: 1px solid var(--key-border);
  background: var(--key-bg);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.key:hover:not(:disabled) {
  background: var(--key-hover-bg);
  border-color: var(--primary);
}

.key:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.key.correct {
  background: var(--correct-bg);
  border-color: var(--correct);
  color: var(--correct);
}

.key.wrong {
  background: var(--wrong-bg-light);
  border-color: var(--wrong);
  color: var(--wrong);
}

.score-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.score-pill {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
}

.score-pill .sname {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.score-pill .sval {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary);
}

.result-card {
  text-align: center;
}

.result-emoji {
  font-size: 4rem;
  margin-bottom: 12px;
  animation: bounce 0.6s ease;
}

@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

.result-card h2 {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.result-desc {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.msg {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 8px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--correct);
  margin-right: 6px;
  animation: pulse 1.5s infinite;
}

.status-dot-ready {
  background: var(--primary);
}

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

.waiting-slots-area {
  text-align: center;
}