:root {
  --bg: #14123a;
  --bg-2: #1e1b52;
  --card: #262266;
  --card-2: #2f2a7a;
  --line: rgba(255, 255, 255, 0.1);
  --text: #f4f2ff;
  --muted: #b9b4e6;
  --gold: #ffc23d;
  --gold-2: #ff9d1c;
  --green: #22c55e;
  --red: #ff6b6b;
  --violet: #8b7bff;
  --radius: 18px;
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
}
body {
  background: radial-gradient(900px 500px at 50% -10%, #3a2f9a 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-tap-highlight-color: transparent;
}
.app {
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
img {
  user-select: none;
}
.hidden {
  display: none !important;
}
.icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}
bdi {
  font-variant-numeric: tabular-nums;
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 14px;
  padding: 11px 18px;
  font: 800 1rem inherit;
  font-family: inherit;
  cursor: pointer;
  color: #2a1600;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active {
  transform: translateY(2px);
}
.btn:disabled {
  filter: grayscale(0.7) brightness(0.8);
  cursor: default;
}
.btn-gold {
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  box-shadow: 0 4px 0 #b8640a;
}
.btn-green {
  background: linear-gradient(180deg, #4ade80, var(--green));
  color: #052e16;
  box-shadow: 0 4px 0 #15803d;
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.btn-wide {
  width: 100%;
}
.link {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}
.spinner {
  width: 34px;
  height: 34px;
  margin: 8px auto;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* splash */
.splash {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}
.splash-logo {
  width: 168px;
  height: 168px;
  object-fit: contain;
  filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.45));
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  50% {
    transform: translateY(-8px);
  }
}
.splash h1 {
  margin: 14px 0 0;
  font-size: 2rem;
  font-weight: 800;
}
.splash-sub {
  margin: 0;
  color: var(--muted);
}
.splash-bottom {
  width: 100%;
  max-width: 320px;
  margin-top: 40px;
  min-height: 120px;
}
.choice {
  display: grid;
  gap: 12px;
}
.error {
  color: var(--red);
}

/* top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(20, 18, 58, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  white-space: nowrap;
}
.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.chips {
  display: flex;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  border: 0;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font: 800 0.95rem inherit;
  font-family: inherit;
  cursor: pointer;
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.chip .plus {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  color: #052e16;
  font-size: 0.9rem;
  line-height: 1;
}

/* lobby */
.lobby {
  display: grid;
  gap: 14px;
  padding: 16px;
}
.card {
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--card-2), var(--card));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 16px;
}
.reward-banner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 120px;
  padding: 16px;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(120deg, #7b3cff, #c43cff 60%, #ff5fa2);
  color: #fff;
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(160, 60, 255, 0.35);
  overflow: visible;
}
.reward-text {
  display: grid;
  gap: 4px;
  justify-items: start;
}
.reward-text b {
  font-size: 1.35rem;
}
.reward-text small {
  opacity: 0.9;
}
.reward-art {
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin: -24px -6px -16px 0;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35));
}
.play-card {
  text-align: center;
}
.play-card h2 {
  margin: 6px 0 2px;
  font-size: 1.3rem;
}
.play-card p {
  margin: 0 0 14px;
  color: var(--muted);
}
.hands-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}
.hand-sm {
  width: 78px;
  height: 78px;
  object-fit: contain;
}
.btn-play {
  font-size: 1.15rem;
  padding: 14px;
}
.cost {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.15);
}
.shop-card,
.account-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.shop-art {
  width: 70px;
  height: 70px;
  object-fit: contain;
}
.shop-text,
.account-text {
  flex: 1;
  display: grid;
  gap: 4px;
  justify-items: start;
}
.account-text small,
.muted {
  color: var(--muted);
  margin: 0;
}
.account-icon {
  width: 44px;
  height: 44px;
  object-fit: contain;
}
.unclaimed {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 194, 61, 0.14);
  box-shadow: inset 0 0 0 1.5px rgba(255, 194, 61, 0.5);
}
.unclaimed span {
  flex: 1;
  font-weight: 600;
}
.foot {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 8px 0 24px;
  font-size: 0.82rem;
}
.foot a {
  color: var(--muted);
}

/* tutorial coach mark */
.coach {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(8, 6, 30, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
  pointer-events: auto;
}
.coach-target {
  z-index: 31;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    box-shadow: 0 0 0 8px rgba(255, 194, 61, 0.45), 0 12px 28px rgba(160, 60, 255, 0.35);
  }
}
.coach-hand {
  position: absolute;
  bottom: -18px;
  left: 40%;
  font-size: 2.6rem;
  animation: tap 1s ease-in-out infinite;
  pointer-events: none;
}
@keyframes tap {
  50% {
    transform: translateY(-10px);
  }
}
.coach-bubble {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 440px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #fff;
  color: #1b1640;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}
.coach-bubble p {
  margin: 0;
}
.coach-avatar {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

/* modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 6, 30, 0.7);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.modal.show {
  opacity: 1;
}
.modal-card {
  width: min(400px, 100%);
  max-height: 90dvh;
  overflow: auto;
  border-radius: 22px;
  padding: 22px;
  background: linear-gradient(180deg, var(--card-2), var(--bg-2));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
  transform: scale(0.94);
  transition: transform 0.2s ease;
}
.modal.show .modal-card {
  transform: none;
}
.modal-card h3 {
  margin: 4px 0 12px;
  font-size: 1.35rem;
}
.modal-card > div > .btn + .btn {
  margin-top: 10px;
}
.rules p {
  color: var(--muted);
}
.rule {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  font-weight: 600;
}
.hand-xs {
  width: 44px;
  height: 44px;
  object-fit: contain;
}
.receipt-check {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 1.8rem;
  font-weight: 800;
}
.receipt-art,
.purchase-art,
.result-art {
  width: 120px;
  height: 120px;
  object-fit: contain;
}
.receipt dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 8px 0 18px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  text-align: start;
}
.receipt dt {
  color: var(--muted);
}
.receipt dd {
  margin: 0;
  font-weight: 700;
}
.purchase-amount,
.result-reward {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 1.1rem;
}
.purchase-price {
  margin: 6px 0 4px;
  color: var(--gold);
  font-weight: 800;
  font-size: 1.2rem;
}
.purchase-status {
  color: var(--muted);
}
.result-score {
  margin-bottom: 8px;
  font-size: 1.1rem;
}
.result-score b {
  font-size: 2rem;
}
.result-reward {
  margin-bottom: 14px;
  color: var(--gold);
}
.claimed {
  color: #86efac;
  font-weight: 700;
}

/* match */
.match {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 16px 20px;
  gap: 12px;
}
.match-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.score {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.25);
}
.side {
  display: grid;
  justify-items: center;
  gap: 2px;
}
.avatar {
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.me-avatar {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: #2a1600;
  font-weight: 800;
  font-size: 0.8rem;
}
.vs,
.result-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.8rem;
  font-weight: 800;
}
.vs i,
.result-score i {
  font-style: normal;
  color: var(--muted);
}
.pips {
  display: flex;
  gap: 4px;
}
.pips i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
}
.pips i.on {
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}
.arena {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-height: 330px;
  padding: 8px 0;
}
.hand-big {
  width: 130px;
  height: 130px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.4));
}
.bot-hand {
  transform: rotate(180deg);
}
.shake.me-hand {
  animation: shake-me 0.3s ease-in-out 3;
}
.shake.bot-hand {
  animation: shake-bot 0.3s ease-in-out 3;
}
@keyframes shake-me {
  50% {
    transform: translateY(-22px);
  }
}
@keyframes shake-bot {
  0%,
  100% {
    transform: rotate(180deg);
  }
  50% {
    transform: rotate(180deg) translateY(-22px);
  }
}
.verdict {
  min-height: 2.6em;
  padding: 6px 14px;
  border-radius: 12px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}
.verdict.win {
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
}
.verdict.lose {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
}
.verdict.draw {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}
.moves {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.move {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 10px 6px 8px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--card-2), var(--card));
  color: var(--text);
  font: 700 1rem inherit;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 0 #15123f, inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.move:active {
  transform: translateY(2px);
}
.move:disabled {
  opacity: 0.55;
  cursor: default;
}
.hand-move {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 2000;
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 16px;
  border-radius: 14px;
  background: #fff;
  color: #1b1640;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, 140%);
  transition: transform 0.25s ease;
}
.toast.show {
  transform: translate(-50%, 0);
}
.toast[data-tone="success"] {
  background: #dcfce7;
  color: #14532d;
}
.toast[data-tone="error"] {
  background: #fee2e2;
  color: #7f1d1d;
}

/* the Baziness sheet (see the wiki's "Bottom sheet" page) — above everything, splash included */
.baziness-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  background: rgba(8, 6, 4, 0.5);
}
.baziness-sheet {
  position: relative;
  width: min(560px, 100%);
  height: 92%;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 22px 22px 0 0;
  overflow: hidden;
  box-shadow: 0 -10px 34px rgba(0, 0, 0, 0.42);
  transform: translateY(100%);
  transition: transform 320ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.baziness-grabber-zone {
  flex: 0 0 auto;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  background: #fff;
}
.baziness-grabber {
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
}
.baziness-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
}
.baziness-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border-radius: 50%;
  border: 4px solid rgba(120, 90, 46, 0.25);
  border-top-color: #b4824a;
  animation: spin 0.9s linear infinite;
}
