: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: flex-start;
  justify-content: center;
  padding: 24px 12px;
  position: relative;
  overflow: hidden;
}

#bg-physics {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  pointer-events: none;
  z-index: 0;
}

.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;
  z-index: 1;
}

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

.screen.active {
  display: block;
}

.telegram-link {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.telegram-link svg {
  width: 100%;
  height: 100%;
  display: block;
}

.audio-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  user-select: none;
}

.audio-toggle:active {
  transform: translateY(1px) scale(0.98);
}

.hidden {
  display: none !important;
}

.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 card: frosted glass look (blurred background visible through it) */
#screen-landing .card-main {
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  position: relative;
  z-index: 2;
}

/* Frosted glass on menu/lobby screens too (until game starts) */
#screen-host-setup .card,
#screen-join .card,
#screen-lobby .card {
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  position: relative;
  z-index: 2;
}

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

.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);
}

.player-list li span.status.disconnected {
  font-style: italic;
  opacity: 0.85;
}

.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;
}

.lobby-rules {
  margin: 14px 0 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.lobby-exit-btn {
  margin-top: 0.75rem;
  width: 100%;
}

.lobby-rules-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 600;
}

.lobby-rules p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.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;
}

.results-item-earned {
  font-weight: 600;
  margin-right: 0.25em;
}
.results-item-earned:not([data-zero]) {
  color: #2e7d32;
}
.results-item-earned[data-zero] {
  color: #888;
}

.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;
}

.results-ready-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.04);
}

.results-ready-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ready-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: #2e7d32;
}

.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;
}

.activity-indicator {
  margin-top: 12px;
  padding: 8px 0;
  min-height: 36px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.04);
}

.activity-indicator .player-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  animation: chipIn 0.35s ease-out;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 420px);
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}

.manage-players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow: auto;
  margin: 10px 0 12px;
}

.manage-player-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 10px;
}

@keyframes chipIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.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;
  }
}

/* Awards screen */
.awards-card {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.awards-title {
  text-align: center;
  margin: 0 0 20px;
  font-size: 1.5rem;
}

.awards-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.award-item {
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: center;
  transition: transform var(--transition-med), opacity var(--transition-med);
}

.award-item.award-hidden {
  opacity: 0;
  transform: scale(0.7) translateY(20px);
  pointer-events: none;
}

.award-item.award-visible {
  animation: awardReveal 0.6s ease-out forwards;
}

@keyframes awardReveal {
  0% {
    opacity: 0;
    transform: scale(0.7) translateY(24px);
  }
  60% {
    opacity: 1;
    transform: scale(1.08) translateY(0);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.award-item[data-award="bigLiar"] { background: linear-gradient(135deg, #ffecb3 0%, #ffe082 100%); }
.award-item[data-award="genius"] { background: linear-gradient(135deg, #c5e1a5 0%, #aed581 100%); }
.award-item[data-award="innocent"] { background: linear-gradient(135deg, #b3e5fc 0%, #81d4fa 100%); }

.award-icon {
  font-size: 2.5rem;
  margin: 0 0 6px;
}

.award-label {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 700;
}

.award-desc {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.award-winner {
  margin: 0 0 2px;
  font-size: 1.2rem;
  font-weight: 700;
}

.award-count {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

#btn-awards-to-leaderboard.show {
  animation: fadeInUp 0.4s ease-out;
}

.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;
  }
}

