/* ===== توکن‌های طراحی =====
   پالت: الهام از تخته‌چوب و کاغذ بازی‌های رومیزی واقعی
   - زمینه: کرم گرم با بافت چوب تیره برای قاب
   - رنگ‌های بازی: قرمز آجری، سبز جنگلی، زرد عسلی، آبی دریایی (پررنگ‌تر و گرم‌تر از رنگ‌های فلت معمولی)
*/
:root {
  --wood-dark: #3a2418;
  --wood-mid: #5c3a26;
  --felt: #1f4d3a;
  --cream: #f6efe2;
  --cream-soft: #efe5d2;
  --ink: #2a1f17;
  --ink-soft: #6b5d4f;

  --red: #c0392b;
  --red-deep: #8e2a1f;
  --green: #1f7a4d;
  --green-deep: #145435;
  --yellow: #d39a2d;
  --yellow-deep: #a8761c;
  --blue: #2563a8;
  --blue-deep: #1a4778;

  --gold: #c9a24a;

  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow-deep: 0 10px 30px rgba(26, 16, 8, 0.35);
  --font-display: 'Vazirmatn', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--wood-dark);
  font-family: var(--font-display);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

body {
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.04), transparent 40%),
    repeating-linear-gradient(115deg, rgba(0,0,0,0.06) 0px, rgba(0,0,0,0.06) 2px, transparent 2px, transparent 14px),
    linear-gradient(160deg, var(--wood-mid), var(--wood-dark) 70%);
}

#app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.35s ease;
}
.screen.active { display: flex; }

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

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
input { font-family: inherit; }

/* ===== دکمه‌ها ===== */
.btn {
  border-radius: var(--radius-md);
  padding: 15px 22px;
  font-size: 16px;
  font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  width: 100%;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(180deg, var(--gold), #a8822f);
  color: #2a1a08;
  box-shadow: 0 4px 0 #7d611f, 0 10px 18px rgba(0,0,0,0.35);
}
.btn-secondary {
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 4px 0 #cbbfa0;
}
.btn-ghost {
  background: transparent;
  color: var(--cream-soft);
  border: 1.5px solid rgba(246,239,226,0.35);
  box-shadow: none;
}
.btn-sm { padding: 9px 14px; font-size: 13px; width: auto; }

/* ===== صفحه لابی ===== */
.lobby-wrap {
  width: 100%;
  max-width: 420px;
  padding: 32px 26px 40px;
  background: var(--cream);
  border-radius: 28px;
  box-shadow: var(--shadow-deep);
  margin: 16px;
  position: relative;
}

.brand { text-align: center; margin-bottom: 30px; }
.brand-token { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }
.dot { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2); }
.dot-red { background: var(--red); }
.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-blue { background: var(--blue); }

.brand h1 {
  font-size: 42px;
  font-weight: 900;
  margin: 0;
  color: var(--ink);
  letter-spacing: -1px;
}
.brand-sub {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
}

.lobby-actions { display: flex; flex-direction: column; gap: 16px; }

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  border-bottom: 1.5px solid #ddd0b6;
}
.divider span { padding: 0 12px; }

.join-row { display: flex; gap: 10px; }
.join-row input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid #ddd0b6;
  background: #fffdf8;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  text-align: center;
  color: var(--ink);
}
.join-row input:focus { outline: 2px solid var(--gold); }
.join-row .btn { width: auto; padding: 14px 20px; }

.error-text {
  color: var(--red-deep);
  font-size: 13px;
  text-align: center;
  margin: 14px 0 0;
  min-height: 16px;
}

/* ===== صفحه انتظار ===== */
.waiting-wrap {
  width: 100%;
  max-width: 420px;
  padding: 34px 26px;
  background: var(--cream);
  border-radius: 28px;
  box-shadow: var(--shadow-deep);
  margin: 16px;
  text-align: center;
}
.room-code-label { color: var(--ink-soft); font-size: 13px; margin: 0 0 6px; font-weight: 600; }
.room-code-box {
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 8px;
  background: #fffdf8;
  border: 2px dashed var(--gold);
  border-radius: var(--radius-md);
  padding: 14px;
  color: var(--ink);
  margin-bottom: 14px;
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 24px 0;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #fffdf8;
  border: 1px solid #ecdfc2;
}
.player-row .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 14px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.18);
}
.player-row .pname { font-weight: 700; font-size: 14px; flex: 1; text-align: right; }
.player-row .pstatus { font-size: 11px; color: var(--ink-soft); }
.player-row.host .pname::after { content: " (میزبان)"; font-size: 11px; color: var(--gold); font-weight: 600; }
.player-row.empty { opacity: 0.4; border-style: dashed; }

.waiting-hint { color: var(--ink-soft); font-size: 13px; margin-bottom: 20px; }

/* ===== صفحه بازی ===== */
.game-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 10px;
  gap: 10px;
}

.game-topbar { width: 100%; max-width: 480px; }
.turn-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--cream);
  border-radius: 999px;
  padding: 9px 18px;
  box-shadow: var(--shadow-deep);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}
.turn-dot {
  width: 12px; height: 12px; border-radius: 50%;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.2);
  transition: background 0.25s ease;
}

.board-stage {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.board-svg {
  width: min(94vw, 480px);
  height: min(94vw, 480px);
  filter: drop-shadow(0 12px 24px rgba(0,0,0,0.4));
}

.game-controls {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.players-strip { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.pstrip-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(246,239,226,0.12);
  border-radius: 999px;
  padding: 6px 12px 6px 6px;
  font-size: 12px;
  color: var(--cream-soft);
  font-weight: 600;
  border: 1px solid rgba(246,239,226,0.15);
}
.pstrip-item.current { background: rgba(201,162,74,0.25); border-color: var(--gold); }
.pstrip-item .mini-dot { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 -2px 0 rgba(0,0,0,0.2); }
.pstrip-item .pcount { font-size: 10px; opacity: 0.7; }

.dice-area { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dice-btn {
  width: 64px; height: 64px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fffdf8, #efe5d2);
  box-shadow: 0 5px 0 #cbbfa0, var(--shadow-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  transition: transform 0.12s ease;
}
.dice-btn:active { transform: scale(0.93) translateY(2px); }
.dice-btn:disabled { opacity: 0.45; filter: grayscale(0.4); cursor: not-allowed; }
.dice-btn.rolling { animation: shake 0.5s ease; }
@keyframes shake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}
.dice-hint { font-size: 11px; color: var(--cream-soft); margin: 0; font-weight: 600; opacity: 0.85; }

/* ===== صفحه پایان ===== */
.over-wrap {
  text-align: center;
  background: var(--cream);
  padding: 40px 30px;
  border-radius: 28px;
  box-shadow: var(--shadow-deep);
  margin: 16px;
  max-width: 380px;
  position: relative;
  overflow: hidden;
}
.over-wrap h2 { font-size: 28px; margin: 0 0 8px; font-weight: 900; }
.over-wrap p { color: var(--ink-soft); margin: 0 0 26px; font-weight: 600; }

/* ===== توست ===== */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink);
  color: var(--cream);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-deep);
  transition: transform 0.3s ease;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* مهره‌ها روی تخته */
.piece {
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), filter 0.15s ease;
}
.piece.movable {
  filter: drop-shadow(0 0 6px rgba(201,162,74,0.9));
  animation: bounce 0.9s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@media (max-width: 360px) {
  .lobby-wrap, .waiting-wrap { padding: 26px 18px; }
  .brand h1 { font-size: 34px; }
}
