:root {
  color-scheme: dark;
  font-family: "Tajawal", "Cairo", "Noto Sans Arabic", system-ui, sans-serif;
  background: #100818;
  color: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(10, 5, 18, 0.28), rgba(10, 5, 18, 0.7)),
    url("/assets/bara-background.png") center / cover fixed,
    #100818;
  overflow-x: hidden;
}

@keyframes soft-rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes soft-pop {
  0% {
    opacity: 0;
    transform: scale(0.82);
  }
  70% {
    opacity: 1;
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes glow-pulse {
  0%, 100% {
    box-shadow: 0 0 0 rgba(0, 212, 255, 0);
  }
  50% {
    box-shadow: 0 0 32px rgba(0, 212, 255, 0.24);
  }
}

@keyframes meter-fill {
  from {
    width: 0;
  }
  to {
    width: var(--ready);
  }
}

@keyframes word-reveal {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.94);
    filter: blur(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.shell {
  position: relative;
  width: min(1160px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
  isolation: isolate;
}

.glow {
  position: fixed;
  z-index: -1;
  width: 240px;
  height: 240px;
  border-radius: 999px;
  filter: blur(42px);
  opacity: 0.52;
}

.glow-a {
  top: 8%;
  right: 6%;
  background: #7c5cff;
}

.glow-b {
  bottom: 8%;
  left: 6%;
  background: #00d4ff;
}

.landing {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  align-items: center;
  gap: 28px;
}

.fast-invite {
  grid-template-columns: minmax(280px, 0.72fr) minmax(320px, 0.58fr);
  justify-content: center;
}

.fast-invite .hero {
  max-width: 560px;
}

.fast-invite .hero h1 {
  font-size: clamp(3rem, 7vw, 5.8rem);
}

.fast-invite .entry {
  border-color: rgba(30, 230, 168, 0.22);
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.32),
    0 0 0 1px rgba(0, 212, 255, 0.07) inset;
}

.hero {
  padding: 16px 4px;
  animation: soft-rise 520ms ease both;
}

.brand,
.steps span,
.tools-link,
.room-option,
.language-switch,
.phase,
.code {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
}

.brand-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  min-height: 58px;
  padding: 7px 15px 7px 8px;
  border-radius: 16px;
  color: #ffe7f0;
  font-weight: 800;
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  object-fit: cover;
  box-shadow: 0 12px 30px rgba(0, 212, 255, 0.16);
}

.language-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 46px;
  padding: 4px;
  border-radius: 14px;
}

.language-switch button {
  min-height: 46px;
  padding: 0 13px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #fff;
  font-weight: 900;
}

.language-switch button.active {
  background: rgba(0, 212, 255, 0.18);
  color: #dff8ff;
  box-shadow: 0 0 0 1px rgba(0, 212, 255, 0.18) inset;
}

.hero h1,
.stage h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(3rem, 8vw, 6.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero p,
.stage-text,
.action p,
.center p,
.secret span,
.muted {
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.75;
}

.hero p {
  max-width: 620px;
  margin: 22px 0;
  font-size: 1.16rem;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.steps span {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 10px 12px;
  border-radius: 14px;
  color: #dff8ff;
  font-weight: 900;
  line-height: 1.35;
}

.steps b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: rgba(0, 212, 255, 0.18);
  color: #7deaff;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.tools-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}

.small-link {
  color: rgba(255, 255, 255, 0.68);
  text-align: center;
  text-decoration: none;
  font-weight: 800;
  line-height: 1.5;
}

.tools-link.subtle {
  color: rgba(255, 255, 255, 0.78);
}

.app-corner-link {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
}

.card {
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.055));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(26px);
}

.entry {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 24px;
  animation: soft-rise 560ms 80ms ease both;
}

.field {
  display: grid;
  gap: 8px;
}

.field span,
.label,
.muted {
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.9rem;
}

.field input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  outline: none;
  background: rgba(4, 3, 10, 0.45);
  color: #fff;
}

.field input:focus {
  border-color: #00d4ff;
  box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.13);
}

.action {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
}

.action h2 {
  margin: 0 0 4px;
}

.action p {
  margin: 0;
}

.action-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.join {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.primary,
.secondary,
.icon,
.code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  font-weight: 900;
}

.primary {
  padding: 0 20px;
  background: linear-gradient(135deg, #ff4d8d, #7c5cff 56%, #00d4ff);
  box-shadow: 0 16px 34px rgba(124, 92, 255, 0.34);
}

.primary:not(:disabled) {
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.primary:not(:disabled):hover,
.secondary:not(:disabled):hover,
.code:hover,
.room-option:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.secondary,
.icon {
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.1);
}

.compact {
  min-height: 40px;
  padding: 0 13px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.wide {
  width: 100%;
}

.muted-box {
  color: rgba(255, 255, 255, 0.66);
  line-height: 1.55;
}

.open-rooms {
  display: grid;
  gap: 10px;
}

.room-option {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  color: #fff;
  text-align: right;
  animation: soft-rise 320ms calc(var(--item, 0) * 45ms) ease both;
}

.room-option strong {
  color: #ffd166;
  font-size: 1.2rem;
  letter-spacing: 1px;
}

.room-option span {
  color: rgba(255, 255, 255, 0.74);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-option em,
.fast-join-note {
  border: 1px solid rgba(0, 212, 255, 0.18);
  background: rgba(0, 212, 255, 0.1);
  color: #9ff3ff;
  font-style: normal;
  font-weight: 900;
}

.room-option em {
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
}

.fast-join-note {
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.55;
}

.error,
.toast.error-toast {
  color: #ffd7e4;
  background: rgba(255, 77, 141, 0.13);
  border: 1px solid rgba(255, 77, 141, 0.28);
}

.error,
.success {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
}

.success,
.toast.success-toast {
  color: #d8fff2;
  background: rgba(30, 230, 168, 0.13);
  border: 1px solid rgba(30, 230, 168, 0.3);
}

.fast-action {
  border: 1px solid rgba(30, 230, 168, 0.24);
  background: linear-gradient(145deg, rgba(30, 230, 168, 0.13), rgba(255, 255, 255, 0.07));
}

.fast-action .primary {
  min-height: 58px;
  font-size: 1.08rem;
}

.room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: auto 1fr;
  gap: 20px;
}

.topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  animation: soft-rise 420ms ease both;
}

.top-share {
  justify-self: start;
}

.code {
  min-width: 112px;
  margin-top: 6px;
  padding: 0 16px;
  font-size: 1.35rem;
  letter-spacing: 2px;
}

.phase {
  justify-self: center;
  padding: 12px 18px;
  border-radius: 999px;
  color: #dff8ff;
  font-weight: 900;
}

.icon {
  width: 48px;
  padding: 0;
}

.stage {
  display: grid;
  align-content: center;
  gap: 20px;
  min-height: calc(100vh - 128px);
  animation: soft-rise 460ms ease both;
}

.round {
  margin: 0 0 -8px;
  color: #ffd166;
  font-weight: 900;
}

.stage h1 {
  font-size: clamp(2.4rem, 7vw, 5.6rem);
}

.stage-text {
  max-width: 610px;
  margin: 0;
  font-size: 1.08rem;
}

.center,
.secret,
.vote,
.results {
  width: min(620px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border-radius: 24px;
  animation: soft-rise 420ms 80ms ease both;
}

.big-icon {
  font-size: 2.3rem;
}

.center h2,
.secret h2,
.results h2 {
  margin: 0;
  font-size: 2rem;
}

.lobby-meter {
  position: relative;
  overflow: hidden;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.lobby-meter span {
  position: relative;
  z-index: 1;
  color: #fff;
  font-weight: 900;
}

.lobby-meter i {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--ready);
  background: linear-gradient(90deg, rgba(30, 230, 168, 0.42), rgba(0, 212, 255, 0.28));
  animation: meter-fill 700ms ease both;
}

[dir="rtl"] .lobby-meter i {
  right: 0;
  left: auto;
}

.lobby-avatars {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lobby-avatar {
  animation: soft-pop 360ms calc(var(--item, 0) * 55ms) ease both;
}

.center .copy-invite-link {
  border-color: rgba(30, 230, 168, 0.28);
  background: rgba(30, 230, 168, 0.14);
}

.secret {
  overflow: hidden;
}

.secret-locked {
  border-color: rgba(0, 212, 255, 0.22);
}

.secret-locked h2 {
  padding: 0;
  background: transparent;
  font-size: clamp(1.8rem, 5vw, 2.7rem);
}

.secret h2 {
  width: 100%;
  padding: 28px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  text-align: center;
  font-size: clamp(2.4rem, 8vw, 4.5rem);
  animation: word-reveal 520ms ease both;
}

.secret.outsider h2 {
  background: linear-gradient(135deg, rgba(255, 77, 141, 0.28), rgba(124, 92, 255, 0.22));
}

.vote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.vote-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 118px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.075);
  color: #fff;
  font-weight: 900;
  animation: soft-rise 340ms calc(var(--item, 0) * 55ms) ease both;
}

.vote-card.selected {
  border-color: #00d4ff;
  box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.12);
  animation: glow-pulse 900ms ease both;
}

.lines {
  display: grid;
  gap: 10px;
}

.lines p {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.lines span {
  color: rgba(255, 255, 255, 0.64);
}

.result-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
}

.result-hero p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.6;
}

.result-reveal {
  display: grid;
  gap: 8px;
  padding: 22px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 209, 102, 0.22), transparent 34%),
    rgba(255, 255, 255, 0.08);
  text-align: center;
  animation: word-reveal 520ms ease both;
}

.result-reveal span {
  color: rgba(255, 255, 255, 0.66);
  font-weight: 900;
}

.result-reveal strong {
  font-size: clamp(2.2rem, 7vw, 4.6rem);
  line-height: 1;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-grid p {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.result-grid span,
.score-row span {
  color: rgba(255, 255, 255, 0.64);
}

.score-board {
  display: grid;
  gap: 9px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(4, 3, 10, 0.22);
}

.score-board h3 {
  margin: 0 0 4px;
  font-size: 1.08rem;
}

.score-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  animation: soft-rise 320ms calc(var(--item, 0) * 55ms) ease both;
}

.score-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-row b {
  color: #ffd166;
}

.rank {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff !important;
  font-weight: 900;
}

.score-row.outsider {
  outline: 1px solid rgba(255, 209, 102, 0.34);
}

.score-row.accused {
  background: rgba(0, 212, 255, 0.11);
}

.results.caught {
  border-color: rgba(30, 230, 168, 0.26);
}

.results.escaped {
  border-color: rgba(255, 209, 102, 0.28);
}

.players {
  align-self: start;
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 24px;
  animation: soft-rise 520ms 120ms ease both;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
}

.player-list {
  display: grid;
  gap: 10px;
}

.invite-box {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.invite-box h3 {
  margin: 0 0 5px;
  font-size: 1.15rem;
}

.invite-box p {
  margin: 0;
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.55;
  font-size: 0.94rem;
}

.qr-code {
  width: min(220px, 100%);
  aspect-ratio: 1;
  justify-self: center;
  padding: 10px;
  border-radius: 18px;
  background: #fff;
}

.share-field input {
  direction: ltr;
  text-align: left;
  font-size: 0.86rem;
}

.share-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.player {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  animation: soft-rise 320ms calc(var(--item, 0) * 45ms) ease both;
}

.player.me {
  outline: 2px solid rgba(0, 212, 255, 0.24);
}

.player.me .avatar {
  box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.12);
}

.player.offline {
  opacity: 0.48;
}

.player div {
  min-width: 0;
}

.player strong,
.player span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player div span {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.86rem;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--avatar);
  color: #fff;
  font-weight: 900;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.player:hover .avatar,
.vote-card:hover .avatar {
  transform: scale(1.06);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  animation: toast-in 260ms ease both;
}

.phase-results .results {
  animation: soft-pop 520ms ease both;
}

.phase-voting .vote {
  animation: soft-rise 360ms ease both;
}

.phase-reveal .secret {
  animation: soft-pop 460ms ease both;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 820px) {
  .shell {
    padding: 18px;
  }

  .landing,
  .room {
    grid-template-columns: 1fr;
  }

  .fast-invite {
    align-content: start;
    padding-top: 74px;
  }

  .fast-invite .entry {
    order: -1;
  }

  .fast-invite .hero {
    text-align: center;
  }

  .fast-invite .brand-row {
    justify-content: center;
  }

  .room {
    grid-template-rows: auto;
  }

  .hero h1,
  .stage h1 {
    font-size: clamp(2.7rem, 15vw, 4.6rem);
  }

  .steps {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: 1fr auto auto;
  }

  .top-share {
    grid-column: 1 / -1;
    width: 100%;
  }

  .phase {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    text-align: center;
  }

  .stage {
    min-height: auto;
  }

  .players {
    order: 3;
  }

  .center,
  .secret,
  .vote,
  .results {
    width: 100%;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .app-corner-link {
    top: 14px;
    left: 14px;
    min-height: 40px;
    padding: 0 12px;
    font-size: 0.9rem;
  }

  .join {
    grid-template-columns: 1fr;
  }

  .action-head {
    display: grid;
  }

  .room-option {
    grid-template-columns: auto 1fr;
  }

  .room-option em {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .primary,
  .secondary {
    width: 100%;
  }

  .center,
  .secret,
  .vote,
  .results {
    padding: 18px;
  }

  .result-hero {
    grid-template-columns: 1fr;
  }

  .score-row {
    grid-template-columns: auto auto minmax(0, 1fr);
  }

  .score-row span:not(.avatar):not(.rank),
  .score-row b {
    grid-column: 3;
  }

  .share-actions {
    grid-template-columns: 1fr;
  }
}
