/* ------------------------------------------------------------------ پایه */
:root {
  --felt-1: #1b7a4a;
  --felt-2: #0f5a36;
  --felt-3: #083620;
  --gold: #d9b25f;
  --gold-2: #f1d38b;
  --cream: #fffaf0;
  --paper: #fffdf8;
  --ink: #1f2420;
  --muted: #6b7568;
  --red: #c2283a;
  --team-0: #4ea1ff;
  --team-1: #ffb02e;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .28);
  --font: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--cream);
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(255, 255, 255, .08), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(0, 0, 0, .35), transparent 60%),
    linear-gradient(160deg, var(--felt-2), var(--felt-3));
  background-attachment: fixed;
  line-height: 1.7;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .6em; }
.muted { color: rgba(255, 250, 240, .6); }
.red { color: var(--red); }

.container { width: min(1080px, 100% - 32px); margin: 24px auto 48px; }

/* ------------------------------------------------------------------ نوار بالا */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, .22);
  border-bottom: 1px solid rgba(217, 178, 95, .25);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 1.35rem; color: var(--cream); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; gap: 1px; padding: 2px 7px; border-radius: 8px;
  background: var(--cream); color: var(--ink); font-size: 1rem; line-height: 1.5;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: .95rem; }
.nav a { color: var(--cream); }
.nav-user { display: inline-flex; align-items: center; gap: 6px; }
.pill {
  display: inline-block; min-width: 1.8em; padding: 0 .55em; border-radius: 999px;
  background: rgba(217, 178, 95, .2); color: var(--gold-2); font-size: .8rem; text-align: center;
}
.inline-form { display: inline; margin: 0; }
.linklike { background: none; border: 0; color: var(--cream); font: inherit; cursor: pointer; padding: 0; }
.linklike:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ دکمه‌ها و فرم */
.btn {
  --bg: var(--cream); --fg: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: .7em 1.3em; border-radius: 12px; border: 0; cursor: pointer;
  font: 700 1rem var(--font); background: var(--bg); color: var(--fg);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .28), 0 6px 16px rgba(0, 0, 0, .18);
  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
  text-decoration: none !important; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .28); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-gold { --bg: linear-gradient(180deg, var(--gold-2), var(--gold)); --fg: #3a2a08; background: var(--bg); }
.btn-red { --bg: linear-gradient(180deg, #e04a5a, var(--red)); --fg: #fff; background: var(--bg); }
.btn-ghost { --bg: rgba(255, 255, 255, .1); --fg: var(--cream); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.btn-small { padding: .35em .9em; font-size: .9rem; border-radius: 10px; }
.btn-big { padding: .85em 1.6em; font-size: 1.1rem; }
.btn-block { width: 100%; }

.input, .select {
  width: 100%; padding: .7em .9em; border-radius: 10px; font: 1rem var(--font);
  border: 1px solid #d8d1bf; background: #fff; color: var(--ink);
}
.input:focus, .select:focus { outline: 3px solid rgba(217, 178, 95, .55); border-color: var(--gold); }
.code-input { letter-spacing: .35em; text-align: center; font-size: 1.3rem; font-weight: 700; direction: ltr; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-weight: 700; margin-bottom: 4px; }
.help { font-size: .82rem; color: var(--muted); margin-top: 3px; }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--red); font-size: .88rem; }

/* ------------------------------------------------------------------ پنل‌ها */
.panel {
  background: var(--paper); color: var(--ink); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); position: relative;
}
.panel h2 { font-size: 1.2rem; }
.panel .muted { color: var(--muted); }
.panel a { color: #8a5a0c; }
.auth-box { width: min(420px, 100%); margin: 30px auto; }
.auth-box h1 { font-size: 1.5rem; text-align: center; }
.auth-switch { text-align: center; margin-top: 14px; font-size: .95rem; }

.messages { width: min(1080px, 100% - 32px); margin: 14px auto 0; display: grid; gap: 8px; }
.msg { padding: 10px 14px; border-radius: 10px; background: var(--cream); color: var(--ink); box-shadow: var(--shadow); }
.msg-error { background: #ffe3e3; color: #8e1020; }
.msg-success { background: #e2f8e7; color: #135c2b; }

/* ------------------------------------------------------------------ صفحه اصلی */
.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 24px; align-items: center;
  padding: 16px 0 28px;
}
.hero h1 { font-size: clamp(1.8rem, 4.5vw, 2.8rem); font-weight: 900; margin-bottom: .3em; }
.hero h1 .gold { color: var(--gold-2); }
.hero p { font-size: 1.05rem; color: rgba(255, 250, 240, .8); margin: 0 0 1.2em; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }

.fan { position: relative; height: 230px; }
.fan img {
  position: absolute; bottom: 0; left: 50%; width: 118px; transform-origin: 50% 115%;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35));
  animation: fanIn .8s cubic-bezier(.2, .8, .2, 1) both;
}
.fan img:nth-child(1) { transform: translateX(-50%) rotate(-28deg); animation-delay: .05s; }
.fan img:nth-child(2) { transform: translateX(-50%) rotate(-14deg); animation-delay: .12s; }
.fan img:nth-child(3) { transform: translateX(-50%) rotate(0deg); animation-delay: .19s; }
.fan img:nth-child(4) { transform: translateX(-50%) rotate(14deg); animation-delay: .26s; }
.fan img:nth-child(5) { transform: translateX(-50%) rotate(28deg); animation-delay: .33s; }
@keyframes fanIn { from { opacity: 0; translate: 0 40px; } }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.stack { display: grid; gap: 18px; }
.join-form { display: flex; gap: 8px; }
.join-form .input { flex: 1; }

.room-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.room-list li a {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 12px;
  border-radius: 10px; background: #f6f1e3; color: var(--ink); text-decoration: none;
}
.room-list li a:hover { background: #efe6cf; }
.code { font-weight: 900; letter-spacing: .12em; direction: ltr; unicode-bidi: isolate; }
.status-badge { font-size: .8rem; padding: 2px 10px; border-radius: 999px; background: #e3ecff; color: #1b4a9c; }
.status-badge.playing { background: #ffe9c7; color: #8a4b00; }

/* ------------------------------------------------------------------ جدول‌ها */
.table-simple { width: 100%; border-collapse: collapse; }
.table-simple th, .table-simple td { padding: 9px 10px; text-align: right; border-bottom: 1px solid #ece6d6; }
.table-simple th { font-size: .85rem; color: var(--muted); font-weight: 700; }
.table-simple tr.me td { background: #fff4d6; }
.rank-medal { font-weight: 900; }
.win { color: #137a37; font-weight: 700; }
.loss { color: #a32030; font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: #f6f1e3; border-radius: 12px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 1.8rem; font-weight: 900; color: #6b4708; }
.stat span { font-size: .85rem; color: var(--muted); }

/* ------------------------------------------------------------------ قوانین */
.rules h2 { margin-top: 1.2em; }
.rules ul { padding-inline-start: 1.2em; }
.score-table td:first-child { font-weight: 700; white-space: nowrap; }

.footer {
  display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center;
  padding: 18px 16px 28px; font-size: .8rem; color: rgba(255, 250, 240, .55);
}

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding-top: 4px; }
  .fan { height: 170px; order: -1; }
  .fan img { width: 86px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .nav { gap: 10px; font-size: .88rem; }
  .topbar { padding-top: 8px; padding-bottom: 8px; }
  .hide-sm { display: none; }
}
