:root {
  --bg-gradient: linear-gradient(135deg, #ff9a9e, #fecfef 40%, #f6d365 70%, #fda085);
  --card-bg: rgba(255, 255, 255, 0.9);
  --primary: #ff4f81;
  --primary-dark: #e53b6c;
  --secondary: #3f51b5;
  --text-main: #222;
  --text-muted: #555;
  --danger: #ff5252;
  --success: #00c853;
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.15);
  --radius-lg: 22px;
  --radius-md: 16px;
  --transition-fast: 0.18s ease-out;
  --transition-med: 0.25s ease-out;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Alef", "Rubik", "Arial Rounded MT Bold", sans-serif;
  background: var(--bg-gradient);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

body {
  direction: rtl;
}

#app {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 12px;
  position: relative;
  overflow: hidden;
}

.bg-emoji {
  position: fixed;
  inset: 0;
  pointer-events: none;
  font-size: 40px;
  opacity: 0.18;
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
}

.screen {
  display: none;
  width: 100%;
  max-width: 480px;
  margin: auto;
  animation: fadeInUp 0.4s var(--transition-med);
}

.screen.active {
  display: block;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 18px 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.card-main {
  margin-top: 12vh;
  text-align: center;
}

.landing-logo {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  margin: 0 auto 12px;
  border-radius: var(--radius-md);
}

.logo-title {
  font-size: 2.4rem;
  margin: 0 0 6px;
  letter-spacing: 1px;
}

.subtitle {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.game-rules {
  text-align: right;
  font-size: 0.9rem;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 0 0 18px;
  line-height: 1.5;
}

.game-rules-title {
  font-size: 1.05rem;
  margin: 0 0 10px;
  color: var(--primary-dark);
}

.game-rules p {
  margin: 0 0 6px;
}

.game-rules ul {
  margin: 0 0 8px;
  padding-right: 20px;
  padding-left: 0;
}

.game-rules li {
  margin-bottom: 4px;
}

.game-rules-score,
.game-rules-winner {
  margin-top: 10px;
}

.game-rules-tip {
  margin-top: 10px;
  font-style: italic;
  color: var(--text-muted);
}

.landing-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-note {
  position: fixed;
  bottom: 10px;
  right: 0;
  left: 0;
  text-align: center;
  color: rgba(0, 0, 0, 0.7);
  font-size: 0.9rem;
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.6);
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast), opacity 0.15s ease-out;
  width: 100%;
}

.btn.big {
  padding: 13px 18px;
  font-size: 1.1rem;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 16px rgba(255, 79, 129, 0.45);
}

.btn.primary:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 2px 6px rgba(255, 79, 129, 0.45);
  background: var(--primary-dark);
}

.btn.secondary {
  background: #fff;
  color: var(--secondary);
  border: 2px solid rgba(63, 81, 181, 0.18);
}

.btn.text {
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
}

h1,
h2,
h3 {
  margin-top: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.field span {
  color: var(--text-muted);
}

input {
  border-radius: 14px;
  border: 2px solid rgba(0, 0, 0, 0.12);
  padding: 10px 12px;
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
    background var(--transition-fast);
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 79, 129, 0.25);
  background: #fffdfc;
}

.latin-input {
  direction: ltr;
  text-transform: uppercase;
}

.room-code-label {
  margin: 0 0 6px;
  color: var(--text-muted);
}

.room-code {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.08);
  direction: ltr;
}

.room-link {
  margin: 6px 0 10px;
  word-break: break-all;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px dashed rgba(0, 0, 0, 0.1);
}

.info-text {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  min-height: 1.2em;
}

.player-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
}

.player-list li {
  padding: 6px 10px;
  margin-bottom: 4px;
  border-radius: 999px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.8);
}

.player-list li span.name {
  font-weight: 600;
}

.player-list li span.status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.category-buttons {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}
.category-buttons .btn {
  text-align: center;
  padding: 12px 16px;
}

.connection-status {
  font-size: 0.85rem;
  margin: 10px 0 0;
  min-height: 1.2em;
}
.connection-status.connecting {
  color: var(--text-muted);
}
.connection-status.connected {
  color: var(--success);
}
.connection-status.disconnected {
  color: var(--danger);
}

.hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.random-message {
  margin-top: 12px;
  font-size: 0.95rem;
  font-weight: 500;
}

.question-text {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.question-text.small {
  font-size: 1.1rem;
}

.timer {
  font-weight: 700;
  font-size: 1.2rem;
  margin: 4px 0;
}

.timer.low {
  color: var(--danger);
  animation: pulse 0.75s infinite;
}

.status-line {
  margin-top: 10px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.answers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.answer-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    border-color var(--transition-fast), background var(--transition-fast);
}

.answer-card .answer-text {
  font-size: 1rem;
}

.answer-card .answer-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.answer-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.16);
}

.answer-card.selected {
  border-color: var(--secondary);
  background: #e8eaf6;
}

.answer-card.correct {
  border-color: var(--success);
  background: #e8f5e9;
}

.answer-card.fake-winner {
  border-color: var(--primary);
  background: #fff0f6;
}

.correct-answer {
  font-weight: 700;
  margin-bottom: 10px;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.results-item {
  font-size: 0.95rem;
}

.bonus-message {
  margin-top: 8px;
  font-weight: 600;
}

.results-scores {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.results-scores h3 {
  font-size: 1rem;
  margin: 0 0 8px;
  color: #555;
}

.results-scores ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.results-scores li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  font-size: 0.95rem;
}

.results-scores li.me {
  font-weight: 700;
}

.results-scores .earned {
  color: #2e7d32;
  font-weight: 600;
}

.results-scores .total {
  font-weight: 700;
  min-width: 2.5em;
  text-align: left;
}

.leaderboard-winner {
  text-align: center;
  padding: 20px 16px;
  margin: 16px 0;
  border-radius: 16px;
  background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
  box-shadow: 0 4px 20px rgba(255, 193, 7, 0.35);
}

.leaderboard-winner.me {
  background: linear-gradient(135deg, #c8e6c9 0%, #a5d6a7 100%);
  box-shadow: 0 4px 20px rgba(76, 175, 80, 0.35);
}

.leaderboard-winner .winner-name {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0 0 4px;
  color: #1a1a1a;
}

.leaderboard-winner .winner-score {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: #2e7d32;
}

.leaderboard-rest-title {
  font-size: 1rem;
  font-weight: 600;
  color: #555;
  margin: 12px 0 6px;
}

.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}

.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  margin-bottom: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
}

.leaderboard-list li.me {
  background: #fffde7;
  box-shadow: 0 3px 10px rgba(255, 235, 59, 0.4);
}

.leaderboard-list .score {
  font-weight: 700;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 50%;
  transform: translateX(50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-out, transform 0.25s ease-out;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(50%) translateY(-4px);
}

.toast.hidden {
  display: none;
}

.host-only {
  margin-top: 10px;
}

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

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.confetti {
  position: fixed;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  pointer-events: none;
  animation: confettiFall linear forwards;
  z-index: 90;
}

@keyframes confettiFall {
  0% {
    transform: translate3d(0, -100%, 0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate3d(0, 100vh, 0) rotate(360deg);
    opacity: 0;
  }
}

.shake {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  50% {
    transform: translateX(4px);
  }
  75% {
    transform: translateX(-2px);
  }
  100% {
    transform: translateX(0);
  }
}

@media (min-width: 600px) {
  #app {
    padding: 24px;
  }

  .card-main {
    margin-top: 10vh;
  }
}

