
:root {
  color-scheme: dark;
  --bg: #10090d;
  --panel: #1b1117;
  --red: #ed233e;
  --red-dark: #8d1429;
  --text: #f7edf0;
  --muted: #a99ba2;
  --border: #39232d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 0%, #45111f 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

button, input {
  font: inherit;
}

.app {
  width: min(100% - 32px, 620px);
  margin: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}

.brand {
  color: white;
  font-weight: 900;
  font-size: 25px;
  letter-spacing: 3px;
  text-decoration: none;
}

.brand span {
  color: var(--red);
}

.online-label, .eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  color: #ef8291;
}

.online-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.online-label i {
  width: 7px;
  height: 7px;
  background: #48dc91;
  border-radius: 50%;
}

.hero {
  text-align: center;
  padding: 42px 0 30px;
}

.hero h1 {
  font-size: clamp(30px, 8vw, 48px);
  line-height: 1.1;
  letter-spacing: -1px;
  margin: 15px 0;
}

.hero h1 span {
  color: var(--red);
}

.subtitle {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.panel {
  background: linear-gradient(145deg, #21151c, #160e13);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 20px 70px #0005;
}

.hidden {
  display: none !important;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.number {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--red-dark);
  border-radius: 10px;
  color: #ff7286;
  font-weight: bold;
}

h2 {
  font-size: 20px;
  margin: 0 0 6px;
}

.section-heading p, .rules-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

label {
  display: block;
  font-size: 13px;
  margin: 17px 0 8px;
}

label span {
  color: var(--muted);
  font-size: 11px;
}

input {
  display: block;
  width: 100%;
  min-height: 48px;
  border-radius: 9px;
  padding: 12px;
  border: 1px solid var(--border);
  background: #100b0f;
  color: white;
  outline: none;
}

input:focus {
  border-color: var(--red);
}

.button {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px;
  margin-top: 12px;
  border-radius: 9px;
  cursor: pointer;
  font-weight: bold;
  transition: 0.2s;
}

.button:hover {
  transform: translateY(-1px);
}

.primary {
  background: var(--red);
  border: 1px solid var(--red);
  color: white;
}

.secondary {
  background: #251820;
  color: var(--text);
  border: 1px solid var(--border);
}

.message {
  color: #f2a0ad;
  font-size: 13px;
  line-height: 1.6;
  min-height: 18px;
}

.lobby-top {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.room-code {
  background: #100b0f;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 10px;
  text-align: center;
}

.room-code small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 1px;
}

.room-code strong {
  display: block;
  font-size: 22px;
  letter-spacing: 3px;
  margin: 8px 0;
  color: #ff667d;
}

.copy-button {
  background: none;
  border: none;
  color: white;
  text-decoration: underline;
  cursor: pointer;
  font-size: 12px;
}

.player-summary {
  display: flex;
  justify-content: space-between;
  margin-top: 25px;
  font-size: 13px;
}

.player-summary strong {
  color: #ff7488;
}

.progress-track {
  height: 6px;
  margin: 12px 0 20px;
  background: #38232c;
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar {
  width: 10%;
  height: 100%;
  background: var(--red);
  transition: width 0.25s;
}

.players-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 12px 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #160f14;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  background: #3b1723;
  border-radius: 9px;
  color: #ff8799;
  font-weight: bold;
}

.player-info {
  min-width: 0;
}

.player-name {
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: bold;
}

.player-role {
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
}

.host-tag {
  color: #ff899b;
  font-size: 9px;
}

.rules-note {
  border-left: 2px solid var(--red);
  background: #2a151d;
  padding: 13px;
  margin-top: 20px;
}

.rules-note strong {
  font-size: 12px;
  display: block;
  margin-bottom: 5px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 25px 0;
  color: #78636c;
  font-size: 9px;
  letter-spacing: 1px;
}

@media (max-width: 380px) {
  .panel {
    padding: 17px;
  }

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

  .hero {
    padding-top: 30px;
  }
}


/* ====================== شاشة اللعب ====================== */

#game .panel {
  margin-bottom: 14px;
}

#game h2 {
  font-size: 17px;
  margin-bottom: 12px;
}

#game h2.sub-title {
  font-size: 14px;
  margin: 22px 0 10px;
  color: var(--muted);
}

#game .button {
  margin-top: 14px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  margin: 8px 0 12px;
}

.phase-panel {
  text-align: center;
}

.phase-badge {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.phase-badge.night { color: #9db4ff; }
.phase-badge.day { color: #ffd166; }
.phase-badge.ended { color: #ff7a8d; }

.phase-sub {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 8px 0 0;
}

.phase-sub.small {
  font-size: 12px;
  margin: 0;
  min-height: 16px;
}

.phase-panel .progress-track {
  margin: 14px 0 8px;
}

/* بطاقة الدور */
.role-card {
  display: block;
  width: 100%;
  margin-bottom: 14px;
  padding: 20px;
  text-align: center;
  color: var(--text);
  background: repeating-linear-gradient(135deg, #1b1117, #1b1117 10px, #20141b 10px, #20141b 20px);
  border: 1px dashed var(--red-dark);
  border-radius: 18px;
  cursor: pointer;
  font: inherit;
}

.role-card small {
  display: block;
  color: #ef8291;
  font-size: 11px;
  letter-spacing: 1px;
}

.role-card strong {
  display: block;
  font-size: 24px;
  margin: 10px 0 8px;
}

.role-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.role-card em {
  display: block;
  margin-top: 10px;
  font-style: normal;
  font-size: 13px;
  color: #ff9aa9;
}

.role-card.revealed {
  background: linear-gradient(145deg, #1d2a3a, #14202c);
  border: 1px solid #3b5878;
}

.role-card.revealed.mafia {
  background: linear-gradient(145deg, #3a1520, #230d14);
  border: 1px solid var(--red);
}

.role-card.revealed span {
  color: var(--text);
}

.role-card.pulse {
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 #ed233e00; }
  50% { box-shadow: 0 0 0 6px #ed233e33; }
}

/* الاختيارات */
.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 52px;
  padding: 10px 8px;
  color: var(--text);
  background: #160f14;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  overflow-wrap: anywhere;
  transition: 0.15s;
}

.choice small {
  color: var(--muted);
  font-size: 10px;
  font-weight: normal;
}

.choice:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.choice.selected {
  background: #3b1723;
  border-color: var(--red);
  box-shadow: 0 0 0 2px #ed233e55;
}

/* لوائح */
.player-card.dead {
  opacity: 0.55;
}

.player-card.dead .avatar {
  background: #2a2227;
  color: #8b7b83;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.log-list li {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.6;
}

.log-list li:last-child {
  border-bottom: 0;
}

/* النقاش */
.chat-box {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 220px;
  overflow-y: auto;
  padding: 10px;
  background: #100b0f;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.chat-msg {
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.chat-msg b {
  color: #ff8799;
  margin-inline-end: 6px;
}

.chat-msg.mine b {
  color: #9db4ff;
}

.chat-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.chat-row .button {
  width: auto;
  min-width: 80px;
  margin: 0;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: min(92vw, 420px);
  padding: 12px 18px;
  background: #2a151d;
  color: var(--text);
  border: 1px solid var(--red-dark);
  border-radius: 12px;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 10px 40px #000a;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: 0.25s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
