@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800;900&display=swap');

:root {
  color-scheme: dark;
  font-family: Vazirmatn, Tahoma, sans-serif;
  background: #123d36;
  color: #fff7e8;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #fff7e8;
  --muted: #b8c7ad;
  --deep: #123d36;
  --deep-2: #1b5147;
  --panel: #1b4b42;
  --panel-soft: #24584d;
  --cream: #fff4dc;
  --gold: #f6be52;
  --gold-deep: #ce8428;
  --line: rgba(255, 244, 220, .12);
  --tg-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--deep); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% -15%, rgba(57, 117, 88, .48), transparent 58%),
    linear-gradient(180deg, #16483e 0%, #10372f 100%);
  color: var(--ink);
}
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid #ffda7e; outline-offset: 3px; }
[hidden] { display: none !important; }

.app-shell {
  width: min(100%, 620px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 14px calc(16px + var(--tg-bottom));
}
.topbar { height: 52px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid rgba(255, 218, 126, .62); border-radius: 50%; color: #ffdc83; font-family: Georgia, serif; font-size: 25px; line-height: 1; box-shadow: 0 0 20px rgba(255, 197, 84, .11); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; font-weight: 800; line-height: 1.25; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.icon-button { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.04); color: #f7d37d; font-weight: 800; cursor: pointer; }

.hero-card {
  overflow: hidden;
  min-height: 555px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  border: 1px solid rgba(255, 235, 177, .15);
  border-radius: 27px;
  background: linear-gradient(160deg, #2b6654 0%, #1c5045 44%, #123b34 100%);
  box-shadow: 0 24px 70px rgba(4, 19, 15, .28);
}
.hero-art { position: absolute; inset: 0 0 auto; height: 57%; overflow: hidden; background: linear-gradient(180deg, #f6bf68 0%, #eea953 39%, #d77947 70%, #643e3a 100%); }
.hero-art::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(12, 56, 45, .05), rgba(12, 56, 45, .25)); }
.sun { position: absolute; width: 124px; height: 124px; top: 28px; right: 42px; border-radius: 50%; background: #ffe4a0; box-shadow: 0 0 44px rgba(255, 235, 167, .38); }
.dune { position: absolute; width: 150%; height: 110px; left: -20%; border-radius: 50% 50% 0 0; transform: rotate(-7deg); }
.dune--one { bottom: -38px; background: #c06b47; }
.dune--two { bottom: -70px; left: 16%; background: #7b4e3d; transform: rotate(8deg); }
.market-stall { position: absolute; left: 17%; bottom: 14px; width: 125px; height: 112px; display: grid; place-items: center; border: 4px solid #65432f; border-bottom: 0; border-radius: 5px 5px 0 0; background: repeating-linear-gradient(90deg, #edcf8e 0 22px, #b94f40 22px 44px); color: rgba(255,245,207,.72); font-size: 50px; box-shadow: 10px 18px 0 rgba(56, 41, 31, .18); }
.market-stall::before { content: ''; position: absolute; width: 146px; height: 27px; top: -20px; left: -14px; border: 4px solid #674433; border-radius: 50% 50% 7px 7px; background: repeating-linear-gradient(90deg, #b94f40 0 24px, #f6d58e 24px 48px); }
.hero-camel { position: absolute; right: 13%; bottom: 5px; font-size: 100px; filter: drop-shadow(8px 11px 5px rgba(52, 35, 25, .25)); transform: scaleX(-1); }
.floating-gem { position: absolute; font-size: 29px; filter: drop-shadow(0 4px 6px rgba(73, 47, 14, .25)); }
.gem--one { top: 53px; left: 22%; transform: rotate(-13deg); }
.gem--two { right: 19%; top: 111px; font-size: 25px; transform: rotate(12deg); }
.hero-copy { z-index: 1; position: relative; padding: 25px 24px 27px; border-radius: 25px 25px 0 0; background: linear-gradient(180deg, rgba(26, 75, 63, .84), #17483e 18%); }
.eyebrow, .section-kicker { margin: 0; color: #eec26f; font-size: 10px; font-weight: 700; letter-spacing: .02em; }
.hero-copy h1 { margin: 7px 0 8px; font-size: clamp(26px, 8vw, 37px); font-weight: 900; line-height: 1.35; }
.hero-description { max-width: 420px; margin: 0; color: #d4dfca; font-size: 13px; line-height: 1.9; }
.hero-facts { display: flex; flex-wrap: wrap; gap: 8px 15px; margin: 16px 0 19px; color: #cad7c6; font-size: 10px; }
.hero-facts span { display: inline-flex; align-items: center; gap: 5px; }
.hero-facts b { color: #f6ce7c; font-size: 12px; }
.primary-button, .secondary-button, .sell-button, .cancel-button { border: 0; border-radius: 13px; cursor: pointer; font-size: 13px; font-weight: 800; transition: transform .15s ease, filter .15s ease, opacity .15s ease; }
.primary-button:active, .secondary-button:active, .sell-button:active, .cancel-button:active { transform: scale(.98); }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 13px; min-height: 46px; padding: 0 18px; background: linear-gradient(135deg, #ffd777, #efad42); color: #3c311d; box-shadow: 0 8px 22px rgba(236, 165, 57, .19); }
.primary-button:disabled, .secondary-button:disabled, .sell-button:disabled { opacity: .42; cursor: not-allowed; filter: saturate(.45); }
.hero-start { width: 100%; min-height: 51px; justify-content: space-between; padding-inline: 19px; }
.hero-start span:last-child { font-size: 18px; }
.hero-note { margin: 11px 0 0; color: #aebfaf; text-align: center; font-size: 10px; }
.home-caption { margin: 15px 0 0; color: #91aa9b; text-align: center; font-size: 10px; }

.match-screen { display: flex; flex-direction: column; gap: 10px; }
.score-strip { min-height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 7px 11px; border: 1px solid var(--line); border-radius: 17px; background: rgba(11, 48, 41, .5); }
.score-player { display: flex; align-items: center; gap: 7px; min-width: 118px; }
.score-player--you { justify-content: flex-end; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #2c6455; font-size: 17px; }
.avatar--opponent { background: #694e43; }
.score-name { color: #d6dfce; font-size: 11px; font-weight: 700; }
.seal-count { min-width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid rgba(248, 206, 118, .52); border-radius: 50%; color: #ffdd89; font-size: 12px; font-weight: 900; background: rgba(246, 190, 82, .08); }
.round-label { display: grid; place-items: center; line-height: 1.15; color: var(--muted); font-size: 9px; }
.round-label strong { color: #f6cf82; font-size: 16px; }
.turn-banner { min-height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 10px; background: rgba(246, 190, 82, .11); color: #f6cf82; font-size: 11px; font-weight: 700; }
.turn-banner.is-thinking { color: #c4d5c2; background: rgba(255, 255, 255, .055); }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, rgba(32, 83, 70, .96), rgba(24, 67, 58, .96)); box-shadow: 0 8px 26px rgba(4, 22, 17, .12); }
.opponent-panel { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 13px; }
.opponent-copy strong, .opponent-copy .section-kicker { display: block; }
.opponent-copy strong { margin-top: 3px; font-size: 12px; }
.opponent-stats { display: flex; align-items: center; gap: 9px; color: #c3d0c2; font-size: 9px; white-space: nowrap; }
.hidden-hand { color: #e6c881; letter-spacing: -3px; font-size: 11px; }
.opponent-herd b { color: #e9bb69; font-weight: 600; }
.opponent-score b { color: #fff1cd; font-size: 12px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 13px 2px; }
.section-heading h2, .hand-heading h2 { margin: 2px 0 0; font-size: 14px; font-weight: 800; }
.market-count { padding: 5px 8px; border: 1px solid var(--line); border-radius: 99px; color: #b6c7b6; font-size: 9px; white-space: nowrap; }
.market-grid { min-height: 129px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; align-items: center; padding: 10px 10px 8px; }
.market-grid.is-empty { min-height: 91px; grid-template-columns: 1fr; }
.market-empty { color: #acbcad; text-align: center; font-size: 10px; }
.market-footnote { display: flex; align-items: center; gap: 6px; padding: 0 13px 11px; color: #a8bba9; font-size: 9px; }
.market-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: #f4c464; }
.card { position: relative; min-width: 0; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: space-between; border: 1px solid rgba(56, 45, 31, .22); border-radius: 10px; background: var(--card-bg, #f2dec0); color: var(--card-ink, #30291f); cursor: pointer; box-shadow: 0 4px 7px rgba(4, 20, 16, .18); user-select: none; -webkit-tap-highlight-color: transparent; }
.card::before { content: ''; position: absolute; inset: 4px; pointer-events: none; border: 1px solid rgba(255, 255, 255, .56); border-radius: 7px; }
.card::after { content: ''; position: absolute; width: 80px; height: 80px; border-radius: 50%; background: rgba(255,255,255,.12); top: -47px; left: -29px; }
.card--market { height: 117px; padding: 13px 3px 8px; }
.card--hand { height: 91px; padding: 9px 3px 6px; }
.card--herd { width: 41px; min-width: 41px; height: 52px; padding: 5px 2px; }
.card-gem { --card-bg: linear-gradient(160deg, #ffe4ba, #f8c798); --card-ink: #742d40; }
.card-gold { --card-bg: linear-gradient(160deg, #ffedbd, #f3d076); --card-ink: #69491c; }
.card-silver { --card-bg: linear-gradient(160deg, #e3edee, #bacfd1); --card-ink: #324b54; }
.card-cloth { --card-bg: linear-gradient(160deg, #ead5ee, #c7a5d3); --card-ink: #583d66; }
.card-spice { --card-bg: linear-gradient(160deg, #dcecc4, #a7c784); --card-ink: #36512f; }
.card-leather { --card-bg: linear-gradient(160deg, #ecd3b1, #c7955e); --card-ink: #543820; }
.card-camel { --card-bg: linear-gradient(160deg, #f3e6c8, #ddc59a); --card-ink: #55402a; }
.card-icon { position: relative; z-index: 1; display: grid; place-items: center; flex: 1; font-size: clamp(23px, 7vw, 34px); line-height: 1; filter: drop-shadow(0 2px 1px rgba(38, 25, 10, .13)); }
.card--hand .card-icon { font-size: clamp(19px, 6vw, 27px); }
.card--herd .card-icon { font-size: 24px; }
.card-label { position: relative; z-index: 1; width: 100%; overflow: hidden; color: var(--card-ink); text-align: center; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; font-weight: 800; }
.card--hand .card-label { font-size: 8px; }
.card-count { position: absolute; z-index: 1; top: 7px; inset-inline-start: 7px; min-width: 16px; height: 16px; display: grid; place-items: center; border-radius: 20px; background: rgba(44, 43, 31, .12); color: inherit; font-size: 8px; font-weight: 900; }
.card.is-selectable { transition: transform .14s ease, box-shadow .14s ease; }
.card.is-selectable:hover { transform: translateY(-2px); }
.card.is-selected { transform: translateY(-6px); border-color: #fff5cc; outline: 2px solid #f8c85c; box-shadow: 0 9px 18px rgba(3, 22, 18, .28); }
.card.is-blocked { opacity: .44; cursor: not-allowed; filter: grayscale(.35); }
.card-back { background: repeating-linear-gradient(45deg, #bd8651 0 5px, #e3bd7b 5px 8px); color: #fff0c5; }
.card-back .card-icon { font-size: 17px; }

.player-panel { padding: 13px 12px 12px; }
.player-summary { display: flex; align-items: center; justify-content: space-between; padding-bottom: 11px; border-bottom: 1px solid var(--line); }
.player-name-wrap { display: flex; align-items: center; gap: 8px; }
.player-name-wrap .section-kicker, .player-name-wrap strong { display: block; }
.player-name-wrap strong { margin-top: 2px; font-size: 12px; }
.player-score { display: grid; justify-items: end; line-height: 1.1; }
.player-score strong { color: #ffe2a0; font-size: 19px; }
.player-score small { color: #bac9b9; font-size: 8px; }
.herd-row { min-height: 54px; display: flex; align-items: center; gap: 8px; padding: 8px 0 6px; border-bottom: 1px solid var(--line); }
.herd-label { display: grid; justify-items: center; min-width: 45px; color: #cbd6c6; font-size: 8px; }
.herd-label strong { color: #ffdb8d; font-size: 13px; }
.herd-cards { display: flex; flex: 1; gap: 5px; overflow-x: auto; min-width: 0; padding: 2px 2px 4px; scrollbar-width: thin; }
.herd-hint { color: #9eb2a3; font-size: 8px; white-space: nowrap; }
.herd-cards:empty::after { content: 'هنوز شتری نداری'; color: #94a99b; font-size: 9px; align-self: center; }
.hand-heading { display: flex; justify-content: space-between; align-items: center; padding: 11px 1px 6px; }
.hand-heading span { color: #b7c9b8; font-size: 9px; }
.hand-heading span b { color: #ffdb8d; }
.hand-grid { min-height: 98px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; align-items: center; }
.hand-empty { grid-column: 1 / -1; display: grid; place-items: center; min-height: 80px; border: 1px dashed rgba(255, 245, 220, .18); border-radius: 12px; color: #98ad9d; font-size: 10px; }
.action-hint { min-height: 28px; display: flex; align-items: center; justify-content: center; margin-top: 7px; padding: 5px 8px; border-radius: 8px; background: rgba(7, 38, 33, .25); color: #c2d0bf; text-align: center; font-size: 9px; line-height: 1.5; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 8px; }
.action-row button { min-height: 43px; padding: 7px 8px; font-size: 10px; }
.secondary-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: #316858; color: #e2efdc; border: 1px solid rgba(255,255,255,.11); }
.secondary-button span { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(245, 202, 114, .18); color: #ffdc91; }
.sell-button { background: #bd6c4f; color: #fff2df; }
.take-button { grid-column: 1 / 2; }
.cancel-button { background: rgba(255,255,255,.08); color: #d4dfce; }
.match-footer { display: flex; justify-content: space-between; padding: 1px 4px; color: #90a99a; font-size: 8px; }

.rules-dialog, .result-dialog { width: min(calc(100% - 26px), 500px); max-height: min(85dvh, 720px); overflow: auto; padding: 26px 22px 20px; border: 1px solid rgba(255, 226, 158, .35); border-radius: 22px; background: linear-gradient(155deg, #23594b, #123d36); color: var(--ink); box-shadow: 0 24px 90px rgba(0,0,0,.48); }
.rules-dialog::backdrop, .result-dialog::backdrop { background: rgba(3, 19, 16, .72); backdrop-filter: blur(4px); }
.rules-dialog form { position: absolute; top: 10px; inset-inline-end: 12px; }
.dialog-close { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.1); color: #f6d181; font-size: 23px; line-height: 1; cursor: pointer; }
.rules-dialog h2, .result-dialog h2 { margin: 5px 0 16px; color: #ffdda0; font-size: 22px; }
.rules-list { display: grid; gap: 12px; margin: 0; padding: 0 20px 0 0; color: #d8e3d5; font-size: 12px; line-height: 1.85; }
.rules-list li::marker { color: #f6c66b; font-weight: 800; }
.rules-list b { color: #ffe2a4; }
.rules-tip { margin: 15px 0 16px; padding: 10px; border-radius: 10px; background: rgba(246, 190, 82, .1); color: #f1d38b; font-size: 10px; line-height: 1.7; }
.rules-ok, .result-continue { width: 100%; }
.result-dialog { max-width: 390px; text-align: center; }
.result-seal { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 12px; border: 1px solid rgba(255, 218, 126, .7); border-radius: 50%; background: rgba(246, 190, 82, .13); color: #ffdb85; font-size: 30px; }
.result-dialog h2 { margin-bottom: 11px; }
.round-results { display: grid; gap: 7px; margin: 12px 0; }
.result-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.04); font-size: 11px; }
.result-row strong { color: #ffdda0; }
.result-message { min-height: 22px; margin: 11px 0 17px; color: #c7d7c7; font-size: 11px; line-height: 1.7; }
.toast { position: fixed; z-index: 10; bottom: calc(18px + var(--tg-bottom)); left: 50%; max-width: calc(100% - 28px); padding: 10px 15px; border: 1px solid rgba(255, 226, 158, .24); border-radius: 12px; background: #e7c279; color: #26382d; box-shadow: 0 9px 35px rgba(0,0,0,.28); text-align: center; font-size: 11px; font-weight: 700; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .app-shell { padding-inline: 10px; }
  .opponent-stats { gap: 6px; }
  .hidden-hand { font-size: 9px; }
  .card--market { height: 109px; }
  .market-grid { gap: 4px; padding-inline: 7px; }
  .card-label { font-size: 8px; }
  .hand-grid { gap: 4px; }
  .action-row button { font-size: 9px; }
}
@media (min-width: 540px) {
  .app-shell { padding-top: 20px; }
  .hero-card { min-height: 640px; }
  .hero-art { height: 60%; }
  .match-screen { gap: 12px; }
  .market-grid { gap: 10px; padding-inline: 20px; }
  .card--market { height: 130px; }
  .hand-grid { gap: 10px; }
  .card--hand { height: 100px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
