/* ───────────────────────────────────────────────────────────────────────
   Design tokens
   پالت: زمینه‌ی تیره‌ی "میز بازی" (آنتراسیت)، با سه رنگ ماده: سنگِ خاکستری‌آبی
   سرد، کاغذِ کرمِ گرم، قیچیِ نقره‌ای فلزی. لهجه‌ی طلایی برای برد/پول.
─────────────────────────────────────────────────────────────────────── */
:root {
  --bg:           #16181d;
  --bg-elevated:  #1f222a;
  --bg-card:      #262a33;
  --border:       #343945;

  --rock:         #6b7a8f;
  --rock-dim:     #4a5564;
  --paper:        #e8dcc0;
  --paper-dim:    #9c937c;
  --scissors:     #b8bfc9;
  --scissors-dim: #7e8590;

  --gold:         #d4a93a;
  --gold-bright:  #f0c659;
  --danger:       #c1564a;
  --success:      #5a9e6f;

  --text:         #ECEAE3;
  --text-dim:     #9498a3;
  --text-faint:   #5d6270;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --font-display: 'Vazirmatn', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  height: 100%;
  overflow-x: hidden;
}

body {
  background-image:
    radial-gradient(circle at 15% 8%, rgba(212,169,58,0.06), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(107,122,143,0.08), transparent 45%);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 18px 18px 32px;
  position: relative;
}

/* ─── Screens ─────────────────────────────────────────────────────────── */
.screen { display: none; animation: fadeIn .25s ease; }
.screen.active { display: block; }

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

/* ─── Home screen ─────────────────────────────────────────────────────── */
.home-header { text-align: center; padding: 28px 0 22px; }

.brand { display: flex; justify-content: center; gap: 10px; margin-bottom: 14px; }
.brand-shape {
  font-size: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px; height: 52px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  animation: float 3.4s ease-in-out infinite;
}
.brand-shape.rock     { animation-delay: 0s; }
.brand-shape.paper    { animation-delay: .25s; }
.brand-shape.scissors { animation-delay: .5s; }
.scissors-emoji { display: inline-block; transform: rotate(-90deg); }

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-7px) rotate(-4deg); }
}

.home-header h1 {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 12px;
}

.balance-pill {
  display: inline-block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 18px;
  font-size: 13.5px;
  color: var(--text-dim);
}
.balance-pill strong { color: var(--gold-bright); font-weight: 700; }

.home-cards { display: flex; flex-direction: column; gap: 12px; }

.home-cards-row { display: flex; gap: 12px; }
.home-cards-row .mode-card { flex: 1; flex-direction: column; align-items: center; padding: 16px 10px; gap: 8px; }
.home-cards-row .mode-card-icon { width: 44px; height: 44px; font-size: 22px; }
.home-cards-row .mode-card-title { font-size: 14px; text-align: center; }

.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  text-align: right;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
  font-family: inherit;
  color: var(--text);
}
.mode-card:active { transform: scale(0.97); background: var(--bg-elevated); }
.mode-card:hover  { border-color: var(--gold); }

.mode-card-icon {
  font-size: 26px;
  width: 50px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.mode-card-title { display: block; font-size: 16.5px; font-weight: 700; margin-bottom: 2px; }
.mode-card-sub   { display: block; font-size: 12.5px; color: var(--text-dim); }
.mode-card > span:not(.mode-card-icon) { flex: 1; }

/* ─── Back / titles ───────────────────────────────────────────────────── */
.back-btn {
  background: none; border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 4px;
  cursor: pointer;
  margin-bottom: 6px;
}
.back-btn:active { color: var(--text); }

.icon-refresh-btn {
  position: absolute;
  top: 18px;
  left: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
}
.icon-refresh-btn:active { color: var(--text); }
.icon-refresh-btn.spinning { animation: icon-refresh-spin .6s linear; }
@keyframes icon-refresh-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.screen-title { font-size: 21px; font-weight: 800; margin: 6px 0 6px; }
.screen-sub   { font-size: 13.5px; color: var(--text-dim); margin-bottom: 20px; line-height: 1.7; }

/* ─── Bot mode selection ──────────────────────────────────────────────── */
.bot-mode-list { display: flex; flex-direction: column; gap: 12px; }

.bot-mode-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: right;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.bot-mode-card.free   { border-color: rgba(90,158,111,0.35); }
.bot-mode-card.paid   { border-color: rgba(212,169,58,0.4); }
.bot-mode-card:active { transform: scale(0.98); }
.bot-mode-card:disabled { opacity: .45; cursor: not-allowed; }

.bot-mode-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.bot-mode-name { font-size: 16px; font-weight: 700; }
.bot-mode-count {
  font-size: 12.5px; color: var(--text-dim);
  background: var(--bg-elevated);
  padding: 3px 10px; border-radius: 999px;
}
.bot-mode-desc { font-size: 12.5px; color: var(--text-dim); }

/* ─── Create / Join 2-player ──────────────────────────────────────────── */
.rounds-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rounds-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 0;
  font-family: inherit;
  font-size: 16px; font-weight: 700;
  color: var(--text);
  cursor: pointer;
}
.rounds-btn:active { background: var(--bg-elevated); transform: scale(0.97); }
.rounds-btn.selected { border-color: var(--gold); background: rgba(212,169,58,0.1); color: var(--gold-bright); }

.create-result { margin-top: 26px; text-align: center; }
.create-result.hidden { display: none; }
.create-result-label { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.code-box {
  font-size: 26px; font-weight: 800; letter-spacing: 4px;
  background: var(--bg-elevated);
  border: 1.5px dashed var(--gold);
  border-radius: var(--radius-md);
  padding: 16px;
  color: var(--gold-bright);
  font-family: monospace, var(--font-display);
}
.copy-btn {
  margin-top: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
}
.waiting-text { margin-top: 18px; color: var(--text-dim); font-size: 14px; }

.create-mode-selector { display: flex; gap: 10px; margin-bottom: 12px; }
.create-mode-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 14px 10px; background: var(--bg-card); border: 2px solid var(--border);
  border-radius: var(--radius-md); cursor: pointer; transition: border-color .15s, background .15s;
}
.create-mode-btn.active { border-color: var(--gold); background: rgba(212,169,58,0.09); }
.create-mode-icon { font-size: 22px; }
.create-mode-label { font-size: 13px; font-weight: 700; color: var(--text); }

.create-stake-row { display: flex; gap: 10px; margin-bottom: 4px; }
.stake-btn {
  flex: 1; padding: 11px 10px; background: var(--bg-card); border: 2px solid var(--border);
  border-radius: var(--radius-md); color: var(--text); font-family: inherit;
  font-size: 13.5px; font-weight: 700; cursor: pointer; transition: border-color .15s, background .15s;
}
.stake-btn.active { border-color: var(--gold); background: rgba(212,169,58,0.09); }

.link-box {
  font-size: 13px;
  word-break: break-all;
  background: var(--bg-elevated);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text);
  font-family: monospace, var(--font-display);
  margin-top: 16px;
}
.link-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.link-actions .copy-btn { margin-top: 0; flex: 1; }
.link-actions .share-btn {
  flex: 1.4;
  background: var(--gold);
  border: none;
  border-radius: 999px;
  color: #1c1505;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 9px 14px;
  cursor: pointer;
}
.link-actions .share-btn:active { background: var(--gold-bright); transform: scale(0.98); }

.list-container { display: flex; flex-direction: column; gap: 10px; }

.empty-state { text-align: center; color: var(--text-dim); font-size: 14px; padding: 30px 0; }

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 15px;
}
.list-row.me { border-color: rgba(212,169,58,0.5); background: rgba(212,169,58,0.07); }

.list-row-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.list-row-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.list-row-title { font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row-sub { font-size: 12px; color: var(--text-dim); }
.list-row-rank { font-size: 16px; font-weight: 800; min-width: 28px; text-align: center; flex-shrink: 0; }

.list-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.list-row-score { font-size: 14px; font-weight: 700; color: var(--text-dim); }
.list-row-badge { font-size: 12px; font-weight: 700; }
.list-row-badge.win  { color: var(--success); }
.list-row-badge.lose { color: var(--danger); }
.list-row-badge.draw,
.list-row-badge.pending { color: var(--text-dim); }

.code-input {
  width: 100%;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  text-align: center;
  color: var(--text);
  font-family: monospace, var(--font-display);
  margin-bottom: 14px;
}
.code-input:focus { outline: none; border-color: var(--gold); }
.code-input::placeholder { color: var(--text-faint); letter-spacing: normal; font-size: 15px; }

.primary-btn {
  width: 100%;
  background: var(--gold);
  border: none;
  border-radius: var(--radius-md);
  padding: 15px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 700;
  color: #1c1505;
  cursor: pointer;
}
.primary-btn:active { background: var(--gold-bright); transform: scale(0.98); }
.primary-btn:disabled { opacity: .5; }

.error-text { color: var(--danger); font-size: 13px; margin-top: 10px; text-align: center; }
.error-text.hidden { display: none; }

/* ─── Game screen ─────────────────────────────────────────────────────── */
.game-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.game-hand-label { font-size: 14px; font-weight: 700; color: var(--text-dim); }
.game-mode-badge {
  font-size: 11.5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 4px 11px;
  border-radius: 999px;
  color: var(--text-dim);
}

.sound-toggle-btn {
  background: none;
  border: none;
  font-size: 19px;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
  color: var(--text-dim);
}
.sound-toggle-btn:active { transform: scale(0.88); }

.score-row { display: flex; gap: 10px; margin-bottom: 22px; }
.score-box {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px 0;
  text-align: center;
  border: 1px solid var(--border);
}
.score-box.me   { border-color: rgba(212,169,58,0.4); }
.score-box.opp  { border-color: rgba(107,122,143,0.4); }
.score-label { display: block; font-size: 11.5px; color: var(--text-dim); margin-bottom: 4px; }
.score-value { display: block; font-size: 22px; font-weight: 800; }
.score-box.me .score-value { color: var(--gold-bright); }

.arena {
  display: flex; align-items: center; justify-content: center;
  gap: 18px;
  margin: 10px 0 18px;
}
.arena-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hand-display {
  width: 96px; height: 96px;
  border-radius: 24px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
  transition: transform .2s ease, border-color .2s ease;
}
.hand-display.reveal { animation: reveal .45s cubic-bezier(.34,1.56,.64,1); }
.hand-display.win  { border-color: var(--success); box-shadow: 0 0 22px rgba(90,158,111,0.35); }
.hand-display.lose { border-color: var(--danger);  box-shadow: 0 0 22px rgba(193,86,74,0.25); }
.hand-display.shake { animation: shake .5s ease; }

@keyframes reveal {
  0%   { transform: scale(0.5) rotate(-15deg); opacity: 0; }
  60%  { transform: scale(1.12) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.arena-tag { font-size: 12px; color: var(--text-dim); }
.arena-vs  { font-size: 13px; font-weight: 800; color: var(--text-faint); }

.status-line {
  text-align: center;
  font-size: 14.5px;
  color: var(--text-dim);
  margin-bottom: 18px;
  min-height: 20px;
}

.choices-row { display: flex; gap: 12px; }
.choice-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 0;
  cursor: pointer;
  font-family: inherit;
  transition: transform .12s ease, border-color .12s ease;
}
.choice-btn:active { transform: scale(0.92); }
.choice-btn:disabled { opacity: .35; cursor: not-allowed; }
.choice-btn.selected { border-color: var(--gold); background: rgba(212,169,58,0.1); }
.choice-emoji { font-size: 34px; }
.choice-name { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }

/* ─── Result screen ───────────────────────────────────────────────────── */
#screen-result.active {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 64px);
}
.result-content { text-align: center; }
.result-emoji { font-size: 64px; margin-bottom: 12px; }
.result-title { font-size: 25px; font-weight: 800; margin-bottom: 10px; }
.result-score { font-size: 15px; color: var(--text-dim); margin-bottom: 8px; }
.result-money {
  font-size: 16px; font-weight: 700;
  color: var(--gold-bright);
  margin-bottom: 6px;
}
.result-money.hidden { display: none; }
.result-meta { font-size: 12.5px; color: var(--text-faint); margin-bottom: 26px; }

/* ─── Toast ────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--danger);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  max-width: 90%;
  text-align: center;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast.hidden { display: none; }

/* ─── Loading ──────────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(22,24,29,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.loading-overlay.hidden { display: none; }
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* ─── Tournament ───────────────────────────────────────────────────────── */
.tournament-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin: 20px 0 10px;
}

.tournament-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.tournament-card:active { background: var(--bg-elevated); transform: scale(0.98); }
.tournament-card.mine   { border-color: rgba(212,169,58,0.45); background: rgba(212,169,58,0.05); }

.tournament-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.tournament-card-title { font-size: 15.5px; font-weight: 700; }
.tournament-card-prize {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-bright);
  background: rgba(212,169,58,0.12);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.tournament-card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tournament-card-meta { font-size: 12px; color: var(--text-dim); }
.tournament-card-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.progress-bar-wrap {
  width: 60px; height: 5px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 999px;
  transition: width .3s ease;
}

/* Tournament detail */
.tournament-detail-header {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  text-align: center;
}
.tournament-detail-prize {
  font-size: 28px;
  font-weight: 800;
  color: var(--gold-bright);
  margin-bottom: 4px;
}
.tournament-detail-meta { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; }

.tournament-status-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 999px;
}
.tournament-status-badge.waiting  { background: rgba(90,158,111,0.15); color: var(--success); }
.tournament-status-badge.active   { background: rgba(212,169,58,0.15); color: var(--gold-bright); }
.tournament-status-badge.finished { background: rgba(107,122,143,0.15); color: var(--text-dim); }

.my-match-card {
  background: rgba(212,169,58,0.08);
  border: 1.5px solid rgba(212,169,58,0.45);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  text-align: center;
}
.my-match-label { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.my-match-round { font-size: 14px; font-weight: 700; color: var(--gold-bright); margin-bottom: 4px; }
.my-match-opp   { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; }

/* Bracket */
.bracket-wrap { display: flex; flex-direction: column; gap: 16px; margin-bottom: 16px; }
.bracket-round-title {
  font-size: 12px; font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.bracket-match {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.bracket-player {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-size: 13.5px;
}
.bracket-player:first-child { border-bottom: 1px solid var(--border); }
.bracket-player.winner { color: var(--gold-bright); font-weight: 700; }
.bracket-player.loser  { color: var(--text-faint); }
.bracket-player-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bracket-win-icon { font-size: 13px; margin-right: 4px; }

/* Size/fee selector */
.selector-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.selector-btn {
  padding: 14px 10px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
}
.selector-btn:active { transform: scale(0.97); }
.selector-btn.selected { border-color: var(--gold); background: rgba(212,169,58,0.1); color: var(--gold-bright); }

/* ── Spectate ─────────────────────────────────────────────────── */
.spectate-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 16px;
  margin: 12px 0;
}
.spectate-player {
  text-align: center;
  flex: 1;
}
.spectate-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.spectate-score {
  font-size: 36px;
  font-weight: 800;
  color: var(--accent);
}
.spectate-vs {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 12px;
}
.spectate-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 8px;
  font-size: 14px;
}
.watch-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px;
  background: var(--card-bg-2, #2a2a3a);
  border: 1px solid var(--border, #444);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
