:root {
  --bg: #07080c;
  --panel: rgba(15, 17, 24, 0.76);
  --panel-strong: rgba(23, 24, 32, 0.94);
  --line: rgba(234, 205, 150, 0.16);
  --text: #f3eee6;
  --muted: #a9a0a1;
  --red: #a7182d;
  --gold: #c79a43;
  --violet: #7651aa;
  --green: #2ea86f;
  --blue: #4f8bc9;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Tahoma, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.backdrop {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(4, 5, 8, 0.88), rgba(6, 7, 12, 0.54), rgba(4, 5, 8, 0.9)),
    radial-gradient(circle at 28% 16%, rgba(167, 24, 45, 0.22), transparent 32%),
    radial-gradient(circle at 72% 72%, rgba(118, 81, 170, 0.22), transparent 34%),
    url("./assets/cinematic-mafia-bg.jpg") center / cover no-repeat;
  z-index: -3;
}

.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, transparent, rgba(0,0,0,0.52));
  mix-blend-mode: screen;
  opacity: 0.5;
}

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.sidebar,
.panel,
.topbar,
.metric,
.role-card,
.player,
.chat,
.timeline,
.control-strip {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand,
.profile-card,
.room-head,
.player-meta,
.vote-row,
.phase-status,
.top-actions,
.inline {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark,
.avatar,
.role-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--red), #161722 48%, var(--gold));
  color: #fff;
  font-weight: 800;
}

.brand small,
.profile-card small,
.muted,
.eyebrow {
  color: var(--muted);
}

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

.nav button,
.ghost,
.primary,
.danger,
.icon-btn,
.chip,
select,
input,
textarea {
  border: 1px solid rgba(234, 205, 150, 0.18);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255,255,255,0.055);
}

.nav button {
  min-height: 44px;
  padding: 0 12px;
  text-align: right;
  cursor: pointer;
}

.nav button.active,
.primary {
  background: linear-gradient(135deg, #b51d34, #6d183c 58%, #221b2f);
  border-color: rgba(255, 217, 148, 0.34);
}

.primary,
.danger,
.ghost,
.icon-btn {
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}

.danger {
  background: rgba(167, 24, 45, 0.3);
}

.icon-btn {
  width: 42px;
  padding: 0;
}

.content {
  min-width: 0;
}

.topbar {
  min-height: 92px;
  border-radius: 8px;
  padding: 18px 22px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 52px);
}

h2 {
  font-size: 22px;
}

.eyebrow {
  margin-bottom: 8px;
  font-size: 12px;
  text-transform: uppercase;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
}

.dashboard {
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
}

.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel {
  border-radius: 8px;
  padding: 18px;
}

.hero-panel {
  min-height: 292px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: stretch;
  gap: 18px;
  background:
    linear-gradient(135deg, rgba(7,8,12,0.26), rgba(7,8,12,0.9)),
    rgba(10,12,18,0.48);
  overflow: hidden;
  position: relative;
}

.hero-panel > * {
  position: relative;
  z-index: 1;
}

.hero-copy {
  align-self: end;
  max-width: 720px;
}

.hero-copy h2 {
  max-width: 620px;
  line-height: 1.65;
}

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.feature-pills span {
  border: 1px solid rgba(243, 207, 131, 0.18);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.055);
  color: #f7e7c4;
  font-size: 12px;
}

.hero-thumb {
  align-self: center;
  justify-self: end;
  width: 220px;
  height: 292px;
  border: 1px solid rgba(243, 207, 131, 0.32);
  border-radius: 8px;
  background: rgba(0,0,0,0.22);
  box-shadow: 0 28px 70px rgba(0,0,0,0.58), 0 0 42px rgba(167, 24, 45, 0.26);
  transform: rotate(-1.5deg);
  overflow: hidden;
  object-fit: cover;
}

.hero-panel::before {
  content: "";
  position: absolute;
  width: 320px;
  height: 320px;
  left: 6%;
  top: 10%;
  background: radial-gradient(circle, rgba(199, 154, 67, 0.2), transparent 64%);
  filter: blur(6px);
}

.visual-strip {
  min-height: 104px;
  margin: 16px 0;
  border: 1px solid rgba(243, 207, 131, 0.22);
  border-radius: 8px;
  display: grid;
  align-items: end;
  padding: 18px;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(90deg, rgba(7,8,12,0.92), rgba(7,8,12,0.32), rgba(7,8,12,0.8)),
    url("./assets/mafia-lobby-poster.jpg") center 58% / cover no-repeat;
}

.visual-strip img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.42;
}

.visual-strip::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.58));
}

.visual-strip > div {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 6px;
}

.visual-strip strong {
  font-size: 22px;
}

.visual-strip span {
  color: var(--muted);
}

.metric {
  border-radius: 8px;
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 26px;
}

.form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  outline: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.room-list,
.roles-list,
.players-grid,
.admin-list,
.log-list {
  display: grid;
  gap: 10px;
}

.room-card,
.admin-row,
.log-item {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255,255,255,0.045);
}

.room-card {
  display: grid;
  gap: 10px;
}

.room-head {
  justify-content: space-between;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  color: #f7e7c4;
  font-size: 12px;
}

.players-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.player {
  border-radius: 8px;
  padding: 12px;
  min-height: 122px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(10,12,18,0.36), rgba(10,12,18,0.92)),
    url("./assets/mafia-lobby-poster.jpg?v=2") center / cover no-repeat;
}

.player > * {
  position: relative;
  z-index: 1;
}

.player::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 18% 20%, rgba(199, 154, 67, 0.24), transparent 34%);
  opacity: 0.9;
}

.player.eliminated {
  opacity: 0.48;
  filter: grayscale(0.8);
}

.player.silenced::after,
.player.protected::after {
  position: absolute;
  top: 10px;
  left: 10px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
}

.player.silenced::after {
  content: "ساکت";
  background: rgba(167, 24, 45, 0.6);
}

.player.protected::after {
  content: "محافظت";
  background: rgba(46, 168, 111, 0.55);
}

.table-stage {
  min-height: 520px;
}

.phase-status {
  justify-content: space-between;
  margin-bottom: 14px;
}

.timer {
  font-size: 38px;
  color: #f3cf83;
  font-variant-numeric: tabular-nums;
}

.control-strip {
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.moderator-chip {
  border-color: rgba(199, 154, 67, 0.4);
  background: rgba(199, 154, 67, 0.12);
}

.vote-audit {
  flex: 1 1 100%;
  border: 1px solid rgba(243, 207, 131, 0.16);
  border-radius: 8px;
  padding: 12px;
  background: rgba(0,0,0,0.22);
  display: grid;
  gap: 8px;
}

.vote-audit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border-top: 1px solid rgba(255,255,255,0.07);
  padding-top: 8px;
}

.vote-audit-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat,
.timeline {
  height: 300px;
  overflow: auto;
}

.message,
.timeline li {
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: 10px 0;
}

.role-card {
  border-radius: 8px;
  min-height: 216px;
  padding: 16px;
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 0.35s ease, border-color 0.35s ease;
}

.role-card:hover {
  transform: perspective(900px) rotateX(4deg) rotateY(-5deg) translateY(-3px);
  border-color: rgba(243, 207, 131, 0.55);
}

.role-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, var(--accent, rgba(167,24,45,0.36)), transparent 42%);
  opacity: 0.8;
}

.role-card > * {
  position: relative;
}

.role-art {
  height: 92px;
  border-radius: 8px;
  margin-bottom: 12px;
  background:
    radial-gradient(circle at 50% 30%, rgba(255,255,255,0.24), transparent 20%),
    linear-gradient(135deg, var(--accent), rgba(0,0,0,0.38)),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.05) 0 1px, transparent 1px 10px);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0,0,0,0.78);
  z-index: 10;
}

.modal.open {
  display: grid;
}

.role-reveal {
  width: min(520px, calc(100vw - 28px));
  display: grid;
  gap: 16px;
  perspective: 1200px;
}

.role-card.big {
  min-height: 440px;
  animation: reveal 0.8s cubic-bezier(.2,.8,.2,1);
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: rotateY(82deg) scale(0.88);
  }
  to {
    opacity: 1;
    transform: rotateY(0deg) scale(1);
  }
}

.toast {
  position: fixed;
  right: 50%;
  bottom: 22px;
  transform: translateX(50%) translateY(18px);
  background: rgba(15,17,24,0.95);
  border: 1px solid rgba(243, 207, 131, 0.35);
  border-radius: 8px;
  padding: 12px 16px;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  z-index: 20;
}

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

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .dashboard,
  .three {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .shell {
    padding: 10px;
  }

  .topbar {
    flex-direction: column;
  }

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

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

  .hero-panel {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .hero-thumb {
    width: 100%;
    height: 160px;
    transform: none;
    justify-self: stretch;
    order: -1;
    object-position: center 34%;
  }
}
