:root {
  --bg: aliceblue;
  --surface: #606069;
  --text: #000;
  --keyActiveText:#fff;
  --muted: #818384;
  --border: #3a3a3c;
  --correct: #6aaa64;
  --present: #b59f3b;
  --absent: #787C7E;
  --key-bg:#dce1ed;
  /* #C4CBDD; */
   /* #D3D6DA; */
  --key-text: #000;
  --message-bg: #ffffff;
  --message-text: #121213;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100%;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}


.app {
  height: 100dvh;
  max-width: 100vw;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  /* grid-template-rows:auto 1fr auto; */
  flex-direction: column;
  /* padding: 8px; */
  padding-inline: clamp(8px,2vw,16px);
}

header {
  flex: 0 0 60px;
  color: #414a5e;
  display: flex;
  grid-template-columns: 40px 1fr 40px;
  align-items:center ;
  justify-content:center ;
  align-content: center;
  padding: clamp(8px,2vw,14px);
  /* border-bottom: 1px solid var(--border); */
}

header h1 {
  font-size: clamp(1rem,4vw,1.5rem);
  margin: 0;
  text-align: center;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center ;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: none;
  /* transparent; */
  color: #c9bd4d;
   /* var(--text); */
  font-size: 1.4rem;
  cursor: pointer;
  margin-right: 3px;
  margin-left: 3px;
  padding: 6px;
  transition: .2s;
}

.icon-btn img{
    width:24px;
    height:24px;
    display:block;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  transform:scale(1.2);
  color: #65bc2e;
  background: #e6f3e6;
}

.icon-btn:active{
    color: #65bc2e;
    background: #e6f3e6;
}


main {
  margin: 0;
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.board {
  padding: 5px;
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  grid-auto-flow: column;
  gap: 4px;
  width:min(78vw,58vmin);
  max-width: 360px;
  aspect-ratio: 5/6;


}

.row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: clamp(3px,1vw,6px);
}

.tile {
  position: relative;  /* برای قرار گرفتن span شناور درون کاشی */
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* font-size: clamp(1.4rem, 6vw, 2rem); */
  font-size: 1.6rem;
  font-weight: 700;
  text-transform: none;
  background: transparent;
  transition: transform 0.15s ease, background 0.25s ease, border-color 0.25s ease;
}

.tile.pop {
    animation: pop 0.1s ease;
}

.tile.filled {
  border-color: var(--muted);
}

.tile.reveal {
  animation: flip 0.5s ease;
}

.tile.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

.tile.present {
  background: var(--present);
  border-color: var(--present);
  color: #fff;
}

.tile.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: #fff;
}

.tile.win {
  animation: bounce 0.6s ease;
}

.message {
  min-height: 32px;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.message.show {
  opacity: 1;
  transform: translateY(0);
  background: var(--message-bg);
  color: var(--message-text);
}

.keyboard {
  width: 100%;
  max-width: 650px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin:0;
  margin-bottom: 5px;
  user-select: none;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  /* gap: clamp(2px,.8vw,6px); */
}

.key {
  min-width: 0;
  height: 58px;
  /* height: clamp(48px,8dvh,70px); */
  border: none;
  border-radius: 10px;
  background: var(--key-bg);
  color: var(--key-text);
  font-family: inherit;
  font-size: 1.05rem;
  /* font-size: clamp(.9rem,3vw,1.2rem); */
  font-weight: bold;
  cursor: pointer;
  padding: 0;
  flex: 1;
  max-width: none;
  transform: scale(.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

.key.wide {
  flex: 1.6;
  font-size: .95rem;
  background-color: #6ec3fc;
  /* font-size: clamp(.65rem,2vw,.85rem); */
}

.key.correct {
  background: var(--correct);
  color: var(--keyActiveText);
}

.key.present {
  background: var(--present);
  color: var(--keyActiveText);
}

.key.absent {
  background: var(--absent);
  color: var(--keyActiveText);
}

.key:active {
  transform: scale(0.96);
}

/* پیام راهنمای بررسی */
#submitHint {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    margin: 8px 0;
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

#submitHint.show {
    opacity: 1;
    transform: translateY(0);
}

/* جلب توجه دکمه بررسی */
@keyframes enterAttention {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

.enter-key.attention {
    animation: enterAttention 0.8s ease-in-out 2;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 25, 25, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.modal.hidden {
  display: none;
}

/* .modal-content {
  position: relative;
  width: min(94vw, 420px);
  max-height: 90vh;
  overflow: auto;
  background: var(--bg);
  border-radius: 12px;
  padding: clamp(16px,4vw,24px);
  line-height: 1.7;
} */

.close-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.6rem;
  cursor: pointer;
}

.modal-content h2 {
  margin-top: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(70px,1fr));
  background-color: var(--surface);
  gap: 10px;
  text-align: center;
  margin: 16px 0;
}

.stats-grid strong {
  display: block;
  font-size: 1.5rem;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal-overlay.hidden {
  display: none;
}
.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  position: relative;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-box {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}


.palette-btn{
    width:42px;
    height:42px;
    border:none;
    border-radius:50%;
    background:var(--bg);
    color:#fff;
    font-size:22px;
    cursor:pointer;
    transition:.2s;
}

.palette-btn:hover{
    background:#666;
}

.color-panel{
    position:absolute;
    top:70px;
    right:15px;
    width:220px;
    background:white;
    padding:15px;
    border-radius:10px;
    box-shadow:0 5px 20px rgba(0,0,0,.2);
    display:none;
}

.color-panel.show{
    display:block;
}

.color-panel label{
    display:block;
    margin-bottom:10px;
}

.color-panel input[type=color]{
    width:100%;
    height:45px;
    border:none;
    cursor:pointer;
}

.actions{
    margin-top:15px;
    text-align:center;
}

.actions button{
    padding:8px 20px;
    border:none;
    border-radius:6px;
    cursor:pointer;
}

@keyframes pop {
  50% {
    transform: scale(1.08);
  }
}

@keyframes flip {
  0% {
    transform: rotateX(0);
    background: transparent;
    border-color: var(--border);
  }

  49% {
    background: transparent;
    border-color: var(--border);
  }

  50% {
    transform: rotateX(90deg);
    background: var(--flip-color);
    border-color: var(--flip-color);
  }

  100% {
    transform: rotateX(0);
    background: var(--flip-color);
    border-color: var(--flip-color);
  }
}

@keyframes bounce {
  0%,
  20% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-12px);
  }
  60% {
    transform: translateY(4px);
  }
  80% {
    transform: translateY(-4px);
  }
  100% {
    transform: translateY(0);
  }
}

/* =========================================================
   Mobile / Responsive layout
   هدف: نمایش کامل بازی در Chrome موبایل بدون اسکرول
   ========================================================= */

@media (max-width:700px){
  html,
  body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}
body {
  min-height: 100dvh;
}

.app {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  max-width: 100vw;
  margin: 0 auto;
  padding-inline: clamp(5px, 2vw, 16px);
  overflow: hidden;
}

header {
  flex: 0 0 48px;
  min-height: 48px;
  padding: 4px clamp(4px, 2vw, 14px);
}

main {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  gap: 4px;
  overflow: hidden;
  justify-content: space-between;
}

.board {
  width: min(68vw, 42dvh);
  max-width: 280px;
  max-height: 45dvh;
  height: auto;
  padding: 3px;
  gap: 3px;
  flex-shrink: 1;
  transform: translateY(60px);
}

.tile {
  font-size: clamp(1.05rem, 5vw, 1.7rem);
}

.keyboard {
  width: 100%;
  max-width: 650px;
  gap: 3px;
  margin: 0 0 3px;
  flex-shrink: 0;
}

.keyboard-row {
  width: 100%;
  gap: 3px;
}

.key {
  height: clamp(36px, 7dvh, 48px);
  font-size: clamp(.72rem, 3.4vw, 1rem);
  border-radius: 8px;
}

.key.wide {
  min-width: 0;
  font-size: clamp(.62rem, 2.9vw, .9rem);
}
}

@media (max-width:600px){
   .app {
    padding-inline: 5px;
  }

    header {
    flex-basis: 44px;
    min-height: 44px;
    padding: 2px 4px;
  }

  header h1 {
    font-size: 1.1rem;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    padding: 4px;
  }

  .icon-btn img {
    width: 22px;
    height: 22px;
  }

  main {
    gap: 3px;
  }

  .board {
    width: min(68vw, 42dvh);
    max-width: 250px;
    max-height: 45dvh;
  }

  .tile {
    font-size: clamp(1.5rem, 5vw, 1.5rem);
    border-radius: 7px;
  }

  .message {
    height: 22px;
    min-height: 22px;
    padding: 2px 8px;
    font-size: .78rem;
  }

  .keyboard{
    gap:2px;
  }

  .keyboard-row{
    gap:2px;
  }

  .key{
    height: clamp(36px, 7dvh, 44px);
    font-size: clamp(1.3rem, 3.3vw, 1.2rem);
    border-radius: 7px;
    /* height:48px;
    font-size:.95rem; */
  }

  .key.wide{
    font-size: clamp(1rem, 2.8vw, 1rem);
    /* min-width:60px; */
  }

  .key.enter,
  .key.backspace {
    grid-column: span 2; /* کلیدهای بزرگ‌تر */
  }
}

@media (max-width:380px){

    .board{
        width:100%;
    }

    .tile{
        font-size:1.1rem;
    }

    .key{
        height:48px;
        font-size:.9rem;
    }

    .key.wide{
        font-size:.8rem;
    }

}

/* .coin-box{
    display:flex;
    align-items:center;
    gap:4px;
    padding:4px 10px;
    border-radius:18px;
    background:#fff7d6;
    border:1px solid #f2d35b;
    font-weight:bold;
    color:#8b6508;
    min-width:62px;
    justify-content:center;
} */

/* .coin-icon{
    font-size:20px;
} */

.buy-coin-btn{
    width:100%;
    margin-top:16px;
    padding:12px;
    border:none;
    border-radius:8px;
    background:#ffb300;
    color:#fff;
    font-size:16px;
    cursor:pointer;
}

.buy-coin-btn:hover{
    background:#ff9800;
}

.tile.hint-bg {
    color: #aaa;
    opacity: 0.5;
    background: #e0e0e0;
    border-color: #ccc;
    font-weight: 400;
}

/* این انیمیشن فقط روی خود حرف اجرا می‌شود */
@keyframes magicDisappear {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
    text-shadow: 0 0 0 rgba(255, 215, 0, 0);
  }
  100% {
    opacity: 0;
    transform: translateY(-35px) scale(1.4);  /* فقط حرف به بالا می‌پرد */
    filter: blur(5px);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.9); /* جلوه‌ی نوری شعبده‌بازی */
  }
}

.floating-letter {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: inherit;
  font-weight: inherit;
  pointer-events: none;  /* کلیک را رد می‌کند */
  animation: magicDisappear 0.5s ease forwards;
}

/* ===== تم تیره ===== */
body.dark {
  --bg: #1a1a1a;
  --surface: #2a2a2a;
  --text: #e0e0e0;
  --key-bg: #3a3a3a;
  --key-text: #e0e0e0;
  --message-bg: #2a2a2a;
  --message-text: #e0e0e0;
  --border: #555;
}

body.dark .modal-content {
  background: #2a2a2a;
  color: #e0e0e0;
}

body.dark .color-panel {
  background: #2a2a2a;
  color: #e0e0e0;
}

/* body.dark .coin-box {
  background: #3a3a3a;
  border-color: #888;
  color: #f0c040;
} */

/* سفید کردن آیکون‌های انتخاب‌شده در تم تیره */
body.dark #restartBtn img,
body.dark #stats-btn img,
body.dark #setting-btn img {
  filter: invert(1);
}

/* ===== تنظیمات ===== */
.setting-item {
  margin-bottom: 12px;
  font-size: 1rem;
}
.setting-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.setting-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #16a34a;
}

/* ===== استایل دکمه اشتراک‌گذاری ===== */
.share-btn {
  margin-top: 10px;
  padding: 8px 16px;
  background: #1e88e5;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
}
.share-btn:hover {
  background: #1565c0;
}

/* ===== استایل جدید مودال آمار (روشن) ===== */
.stats-modal-v2 {
  direction: ltr;
  font-family: 'Vazirmatn', sans-serif;
  padding: 0 4px;
}

.stats-modal-v2 h2 {
  text-align: center;
  font-size: 1.6rem;
  margin-bottom: 20px;
  font-weight: 700;
}

/* کارت‌های اصلی (۴ تایی) */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stats-card {
  background: #f0f2f5;
  border-radius: 12px;
  padding: 12px 6px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.stats-card .number {
  font-size: 1.8rem;
  font-weight: 700;
  display: block;
  line-height: 1.2;
}

.stats-card .label {
  font-size: 0.7rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* خطوط Streak */
.stats-streaks {
  display: flex;
  justify-content: space-around;
  margin-bottom: 16px;
  padding: 8px 0;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
}

.streak-item {
  text-align: center;
}

.streak-item .number {
  font-size: 1.2rem;
  font-weight: 700;
}

.streak-item .label {
  font-size: 0.7rem;
  color: #6b7280;
}

/* دکمه اشتراک‌گذاری */
.share-stats-btn {
  display: block;
  width: 100%;
  padding: 12px;
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 20px;
  transition: 0.2s;
}
.share-stats-btn:hover {
  background: #1557b0;
}

/* جدول توزیع بهترین حدس‌ها */
.best-tries {
  margin-bottom: 16px;
}

.best-tries .title {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.try-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.try-label {
  width: 30px;
  font-weight: 600;
  font-size: 0.85rem;
  color: #6b7280;
}

.try-bar-bg {
  flex: 1;
  height: 24px;
  background: #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.try-bar-fill {
  height: 100%;
  background: #22c55e;
  border-radius: 6px;
  transition: width 0.4s;
}

.try-percent {
  width: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: right;
  color: #22c55e;
}

.try-count {
  width: 30px;
  font-size: 0.85rem;
  color: #6b7280;
  text-align: center;
}

/* دکمه Reset */
.reset-stats-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: transparent;
  color: #ef4444;
  border: 1px solid #ef4444;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}
.reset-stats-btn:hover {
  background: #fee2e2;
}

/* ===== حالت تاریک: استایل قبلی رو نگه می‌داریم ===== */
body.dark .stats-modal-v2 .stats-card {
  background: #2a2a2a;
  color: #e0e0e0;
}
body.dark .stats-modal-v2 .stats-card .label {
  color: #9ca3af;
}
body.dark .stats-modal-v2 .stats-streaks {
  border-color: #3a3a3a;
}
body.dark .stats-modal-v2 .try-bar-bg {
  background: #3a3a3a;
}
body.dark .stats-modal-v2 .try-label,
body.dark .stats-modal-v2 .try-count {
  color: #9ca3af;
}
body.dark .stats-modal-v2 .try-percent {
  color: #4ade80;
}
body.dark .stats-modal-v2 .reset-stats-btn {
  color: #f87171;
  border-color: #f87171;
}
body.dark .stats-modal-v2 .reset-stats-btn:hover {
  background: #450a0a;
}
body.dark .stats-modal-v2 .share-stats-btn {
  background: #2563eb;
}
body.dark .stats-modal-v2 .share-stats-btn:hover {
  background: #1d4ed8;
}

/* ===== مودال اشتراک‌گذاری مسابقه روزانه ===== */
.daily-share-modal {
  direction: rtl;
  font-family: 'Vazirmatn', sans-serif;
  text-align: center;
  padding: 8px 0;
}

.daily-share-modal h2 {
  font-size: 1.5rem;
  margin-bottom: 6px;
  color: #1a1a1a;
}

.daily-share-modal .share-message {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: #1a1a1a;
}

/* تخته کوچک در مودال */
.share-board {
  display: inline-grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 4px;
  background: #f8f9fa;
  padding: 8px;
  border-radius: 10px;
  margin-bottom: 12px;
  width: 200px;
  aspect-ratio: 5/6;
}

.share-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.share-tile {
  aspect-ratio: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  background: #e5e7eb;
  color: #1a1a1a;
  border: 1px solid #d1d5db;
}

.share-tile.correct {
  background: #22c55e;
  border-color: #22c55e;
  color: #fff;
}

.share-tile.present {
  background: #eab308;
  border-color: #eab308;
  color: #fff;
}

.share-tile.absent {
  background: #787c7e;
  border-color: #787c7e;
  color: #fff;
}

.share-tile.empty {
  background: transparent;
  border: 1px solid #d1d5db;
}

/* متادیتا */
.share-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: #4b5563;
  margin-bottom: 16px;
  padding: 0 4px;
}

.share-meta .share-date {
  font-weight: 500;
}

.share-meta .share-attempts {
  font-weight: 700;
  background: #e5e7eb;
  padding: 2px 12px;
  border-radius: 20px;
}

/* دکمه‌ها */
.share-action-btn,
.share-close-btn {
  display: block;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
  margin-bottom: 8px;
}

.share-action-btn {
  background: #1a73e8;
  color: #fff;
}
.share-action-btn:hover {
  background: #1557b0;
}

.share-close-btn {
  background: transparent;
  color: #6b7280;
  border: 1px solid #d1d5db;
}
.share-close-btn:hover {
  background: #f3f4f6;
}

/* حالت تاریک */
body.dark .daily-share-modal h2,
body.dark .daily-share-modal .share-message {
  color: #e0e0e0;
}

body.dark .share-board {
  background: #2a2a2a;
}

body.dark .share-tile {
  background: #3a3a3a;
  border-color: #4a4a4a;
  color: #e0e0e0;
}

body.dark .share-tile.empty {
  background: transparent;
  border-color: #4a4a4a;
}

body.dark .share-meta {
  color: #9ca3af;
}

body.dark .share-meta .share-attempts {
  background: #3a3a3a;
  color: #e0e0e0;
}

body.dark .share-close-btn {
  color: #9ca3af;
  border-color: #4a4a4a;
}
body.dark .share-close-btn:hover {
  background: #2a2a2a;
}
/* دکمه‌های متوجه شدم و ذخیره تنظیمات */
#understood-btn,
#saveSettingsBtn {
    display: block;
    width: fit-content;
    min-width: 140px;
    margin: 15px auto 0;

    background: #16a34a;
    color: #fff;

    border: none;
    border-radius: 8px;

    padding: 10px 24px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;

    cursor: pointer;
    transform: none;
    flex: none;
    max-width: none;
    height: auto;
}

#understood-btn:hover,
#saveSettingsBtn:hover {
    background: #15803d;
}

#understood-btn:active,
#saveSettingsBtn:active {
    background: #166534;
    transform: scale(.97);
}

.board-wrapper {
  position: relative;
  display: inline-block;
}

#board {
  /* عرض جدول شما */
  width: 300px;
}

#restartBtn,
#reloadBtn {
    position: absolute;
    bottom: 0;
    width: 40px;
    height: 40px;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
}

#restartBtn {
    right: -50px;
}

#reloadBtn {
    left: -50px;
}

#restartBtn img,
#reloadBtn img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    display: block;
}

/* برای موبایل، فاصله را کمتر کنید */
@media (max-width: 480px) {
  #restartBtn {
    right: -40px;
  }
}
/* =========================================
   Settings Dialog
   ========================================= */

#settingsDialog {
  position: fixed;

  top: 50%;
  left: 50%;

  transform: translate(-50%, -50%);
  z-index: 9999;

  width: min(28rem, calc(100vw - 1.5rem));
  max-height: min(88vh, 40rem);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 24px;

  background: var(--bg, #faf8f3);
  color: var(--fg, #0c0a09);

  border: 1px solid var(--border, #d8d5ce);
  border-radius: 44px;

  box-shadow:
    0 18px 45px rgba(0, 0, 0, 0.16),
    0 4px 12px rgba(0, 0, 0, 0.08);

  direction: rtl;

  animation: settingsDialogOpen 180ms ease-out;
}


/* =========================================
   عنوان
   ========================================= */

#settingsDialog > div:first-child {
  margin-bottom: 28px;
  text-align: center;
}

#settingsDialog h2 {
  margin: 0;
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.5px;
}


/* =========================================
   لیست تنظیمات
   ========================================= */

#settingsDialog > div:nth-child(2) {
  display: flex;
  flex-direction: column;
  gap: 24px;
}


/* =========================================
   هر ردیف تنظیمات
   ========================================= */

#settingsDialog label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  box-sizing: border-box;
}


/* متن تنظیمات */

#settingsDialog label > span {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}


/* عنوان هر تنظیم */

#settingsDialog label > span > span:first-child {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--fg, #211f1d);
}


/* توضیح حالت سخت */

/* #settingsDialog label > span > span:nth-child(2) {
  display: block;
  margin-top: 3px;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--muted, #77736e);
} */


/* =========================================
   Switch
   ========================================= */

#settingsDialog [role="switch"] {
  position: relative;
  flex: 0 0 auto;

  width: 88px;
  height: 28px;

  padding: 0;
  border: 2px solid #d8d3c9;
  border-radius: 999px;
  background: #eee9df;
  cursor: pointer;
  outline: none;

  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;

  -webkit-tap-highlight-color: transparent;
}


/* =========================================
   حالت روشن
   ========================================= */

#settingsDialog [role="switch"][data-state="checked"] {
  background: #477c6d;
  border-color: #477c6d;
}


/* =========================================
   دایره Switch
   ========================================= */
/* =========================================
   Switch
   ========================================= */

#settingsDialog [role="switch"] {
  position: relative;
  flex: 0 0 auto;

  width: 48px;
  height: 28px;

  padding: 0;

  border: 2px solid #d8d3c9;
  border-radius: 999px;

  background: #eee9df;

  cursor: pointer;
  outline: none;

  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;

  -webkit-tap-highlight-color: transparent;
}


/* روشن */

#settingsDialog [role="switch"][data-state="checked"] {
  background: #477c6d;
  border-color: #477c6d;
}


/* دایره */

#settingsDialog [role="switch"] > span {
  position: absolute;

  top: 50%;
  right: 3px;

  width: 20px;
  height: 20px;

  transform: translate(0, -50%);
  border-radius: 50%;
  background: #211f1d;

  box-shadow:
    0 2px 5px rgba(0, 0, 0, 0.12);

  transition:
    transform 180ms ease,
    background-color 180ms ease;
}


/* دایره در حالت روشن → سمت چپ */

#settingsDialog
[role="switch"][data-state="checked"]
> span {
  transform: translate(-20px, -50%);

  background: #f4f0e8;
}

/* =========================================
   Focus
   ========================================= */

#settingsDialog [role="switch"]:focus-visible {
  box-shadow:
    0 0 0 3px rgba(71, 124, 109, 0.25);
}


/* =========================================
   Hover
   ========================================= */

#settingsDialog [role="switch"]:hover {
  filter: brightness(0.98);
}


/* =========================================
   دکمه بستن
   ========================================= */

#closeSettingsBtn {
  position: absolute;

  top: 16px;
  left: 18px;

  display: flex;

  align-items: center;
  justify-content: center;

  width: 40px;
  height: 40px;

  padding: 0;
  border: 0;
  border-radius: 10px;

  background: transparent;
  color: #706c66;

  cursor: pointer;

  transition:
    background-color 150ms ease,
    color 150ms ease,
    transform 100ms ease;
}


/* آیکون × */

#closeSettingsBtn svg {
  width: 25px;
  height: 25px;

  stroke-width: 2.2;
}


/* Hover × */

#closeSettingsBtn:hover {
  background: #eeeae2;
  color: #24211e;
}


/* کلیک */

#closeSettingsBtn:active {
  transform: scale(0.92);
}


/* =========================================
   انیمیشن باز شدن
   ========================================= */

@keyframes settingsDialogOpen {

  from {
    opacity: 0;

    transform:
      translate(-50%, -50%)
      scale(0.95);
  }

  to {
    opacity: 1;

    transform:
      translate(-50%, -50%)
      scale(1);
  }

}


/* =========================================
   حالت تاریک
   ========================================= */

body.dark #settingsDialog {

  background: var(--surface, #242321);
  color: var(--fg, #f5f2eb);
  border-color: #45423d;

  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.45);
}


body.dark #settingsDialog
label > span > span:first-child {

  color: #f5f2eb;
}

/* 
body.dark #settingsDialog
label > span > span:nth-child(2) {

  color: #aaa69f;
}


body.dark #settingsDialog
[role="switch"] {

  background: #3a3834;
  border-color: #514e48;
}


body.dark #settingsDialog
[role="switch"][data-state="checked"] {

  background: #477c6d;
  border-color: #477c6d;
}


body.dark #settingsDialog
[role="switch"] > span {

  background: #171614;
} */


/* body.dark #settingsDialog
[role="switch"][data-state="checked"]
> span {

  background: #f0ede5;
}


body.dark #closeSettingsBtn {

  color: #aaa69f;
}


body.dark #closeSettingsBtn:hover {

  background: #373531;
  color: #fff;
} */


/* =========================================
   موبایل
   ========================================= */

@media (max-width: 600px) {

  #settingsDialog {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    padding: 22px;
    border-radius: 32px;
  }


  #settingsDialog > div:first-child {
    margin-bottom: 24px;
  }


  #settingsDialog h2 {
    font-size: 23px;
  }


  #settingsDialog > div:nth-child(2) {
    gap: 22px;
  }


  #settingsDialog label {
    gap: 14px;
  }


  #settingsDialog label > span > span:first-child {
    font-size: 19px;
  }


  #settingsDialog label > span > span:nth-child(2) {
    font-size: 14px;
  }


  #settingsDialog [role="switch"] {
    width: 74px;
    height: 42px;
  }


  #settingsDialog [role="switch"] > span {
    width: 34px;
    height: 34px;
    right: 3px;
    transform: translate(0, -50%);
  }

  #settingsDialog
  [role="switch"][data-state="checked"]
  > span {
    transform: translate(-34px, -50%);
  }


  #closeSettingsBtn {
    top: 12px;
    left: 14px;

    width: 38px;
    height: 38px;
  }

}