@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);
  --shell-gutter: 14px;
}

* { 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)) var(--shell-gutter) calc(16px + var(--tg-bottom));
}
.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; }
.sound-toggle span { display: block; font-size: 17px; line-height: 1; }
.sound-toggle[aria-pressed="false"] { color: #bac9b9; opacity: .72; }

.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; }
.game-mode-menu { display: grid; gap: 10px; margin-top: 17px; }
.mode-button { width: 100%; min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 17px; border: 1px solid transparent; border-radius: 14px; text-align: right; }
.mode-button-copy { display: grid; gap: 2px; }
.mode-button-copy strong { font-size: 15px; font-weight: 900; line-height: 1.4; }
.mode-button-copy small { color: #6d5936; font-size: 11px; font-weight: 600; line-height: 1.5; }
.mode-button-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; background: rgba(72, 53, 24, .1); font-size: 19px; }
.mode-button--online { border-color: rgba(255, 239, 204, .17); background: linear-gradient(135deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .035)); color: #e5e8d9; cursor: not-allowed; }
.mode-button--online .mode-button-copy small { color: #c6b786; }
.mode-button--online .mode-button-icon { color: #f0ce83; background: rgba(246, 190, 82, .1); }
.mode-button--online:disabled { opacity: .78; filter: none; }
.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); }
.turn-status-row { display: flex; align-items: stretch; gap: 8px; }
.turn-status-row .turn-banner { flex: 1; }
.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 { display: block; font-size: 15px; }
.opponent-stats { display: flex; align-items: center; gap: 9px; color: #c3d0c2; font-size: 9px; white-space: nowrap; }
.opponent-stats b { color: #e9bb69; font-size: 14px; font-weight: 800; }
.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; }
.treasury-bar { display: flex; justify-content: flex-start; padding: 7px 11px 0; }
.treasury { position: relative; direction: rtl; }
.treasury-summary { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid rgba(246, 190, 82, .32); border-radius: 99px; background: rgba(246, 190, 82, .08); color: #f2d38a; cursor: pointer; list-style: none; font-size: 9px; white-space: nowrap; }
.treasury-summary::-webkit-details-marker { display: none; }
.treasury-summary b { color: #d8d4bf; font-size: 8px; }
.treasury-summary strong { display: inline-flex; align-items: center; gap: 3px; padding: 3px 6px; border-radius: 99px; background: rgba(246, 190, 82, .18); color: #ffe3a0; font-size: 8px; }
.treasury-popover { position: absolute; z-index: 6; top: calc(100% + 7px); left: calc(100% - 100vw + var(--shell-gutter) + 22px); right: auto; width: calc(100vw - 20px); max-height: min(70dvh, 520px); overflow-y: auto; padding: 14px; border: 1px solid rgba(246, 190, 82, .28); border-radius: 16px; background: #143e35; box-shadow: 0 12px 28px rgba(2, 17, 13, .38); }
.treasury-title { display: block; margin-bottom: 7px; color: #ffdda0; font-size: 10px; }
.treasury-piles { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.treasury-pile { display: grid; gap: 3px; min-width: 0; padding: 6px; border-radius: 7px; background: rgba(255, 255, 255, .055); color: #dce5d6; font-size: 9px; }
.treasury-pile-heading { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-width: 0; }
.treasury-pile-heading span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.treasury-pile-heading b { flex: none; color: #ffdc8d; font-size: 8px; }
.treasury-values { display: flex; flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 5px; direction: ltr; color: #c0cfbd; font-size: 8px; line-height: 1.4; }
.treasury-values > span { direction: ltr; unicode-bidi: isolate; }
.treasury-empty { direction: rtl !important; }
.market-panel { position: relative; z-index: 3; overflow: visible; }
.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-turquoise { --card-bg: linear-gradient(160deg, #d6f6e9, #8dd4c0); --card-ink: #17574e; }
.card-pearl { --card-bg: linear-gradient(160deg, #fff4d5, #edd9ae); --card-ink: #69491c; }
.card-silk { --card-bg: linear-gradient(160deg, #e3edee, #bacfd1); --card-ink: #324b54; }
.card-termeh { --card-bg: linear-gradient(160deg, #ead5ee, #c7a5d3); --card-ink: #583d66; }
.card-saffron { --card-bg: linear-gradient(160deg, #ffe5a8, #e7a446); --card-ink: #70451a; }
.card-pottery { --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 1 0; min-height: 0; width: 100%; overflow: hidden; 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-icon-fallback { position: absolute; }
.card-product-image { position: absolute; z-index: 1; inset: 0; display: block; width: 100%; height: 100%; max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; border-radius: 5px; }
.card-product-image[hidden] { display: none; }
.card--herd .card-product-image { width: auto; height: 27px; max-width: 100%; }
.card-label { position: relative; z-index: 1; flex: none; min-height: 11px; margin-top: 3px; width: 100%; overflow: hidden; color: var(--card-ink); text-align: center; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; font-weight: 800; line-height: 1.2; }
.card.has-product-image .card-label { display: none; }
.card--hand .card-label { min-height: 10px; 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.card-flight { border-color: rgba(255, 226, 158, .85); box-shadow: 0 12px 30px rgba(0, 0, 0, .38), 0 0 16px rgba(255, 220, 141, .38); transition: none !important; }
.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; align-items: center; 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-details { display: grid; flex: 1; gap: 4px; min-width: 0; text-align: right; }
.result-details small { color: #bdcfbd; font-size: 10px; line-height: 1.6; }
.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); }
.toast.is-action-popup { top: 50%; bottom: auto; width: min(calc(100% - 32px), 460px); max-width: none; padding: 22px 20px; border: 1px solid rgba(255, 226, 158, .55); border-radius: 18px; background: linear-gradient(150deg, #23594b, #123d36); color: #fff7e8; box-shadow: 0 22px 70px rgba(0, 0, 0, .55); font-size: 17px; line-height: 1.8; opacity: 0; transform: translate(-50%, -50%) scale(.96); }
.toast.is-action-popup::before { content: attr(data-title); display: block; margin-bottom: 6px; color: #ffdda0; font-size: 14px; font-weight: 800; }
.toast.is-action-popup.is-visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* Larger type for comfortable reading on phones. */
.icon-button { width: 40px; height: 40px; font-size: 17px; }
.score-name { font-size: 14px; }
.round-label { font-size: 12px; }
.round-label strong { font-size: 19px; }
.turn-banner { min-height: 40px; font-size: 14px; }
.opponent-stats { gap: 12px; font-size: 13px; }
.treasury-summary { gap: 8px; padding: 8px 12px; font-size: 13px; }
.treasury-summary b, .treasury-summary strong { font-size: 12px; }
.treasury-title { font-size: 15px; }
.treasury-pile { gap: 5px; padding: 9px; font-size: 13px; }
.treasury-pile-heading b { font-size: 12px; }
.treasury-values { font-size: 12px; }
.section-kicker { font-size: 12px; }
.section-heading h2, .hand-heading h2 { font-size: 17px; }
.market-count { font-size: 12px; }
.market-footnote { font-size: 12px; }
.player-name-wrap strong { font-size: 16px; }
.herd-label { font-size: 11px; }
.herd-label strong { font-size: 15px; }
.herd-hint { font-size: 11px; }
.hand-heading span { font-size: 12px; }
.card-label { font-size: 10px; }
.card--hand .card-label { font-size: 9px; }
.hand-empty, .action-hint { font-size: 12px; }
.action-row button { font-size: 12px; }
.match-footer { font-size: 10px; }
.rules-list { font-size: 14px; }
.rules-tip { font-size: 12px; }
.result-row { font-size: 13px; }
.result-message { font-size: 13px; }

@media (max-width: 380px) {
  :root { --shell-gutter: 10px; }
  .app-shell { padding-inline: var(--shell-gutter); }
  .opponent-stats { gap: 8px; font-size: 12px; }
  .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; }
}

/* Visual polish: a warmer, more tactile Iranian bazaar tabletop. */
body {
  background:
    radial-gradient(circle at 12% 28%, rgba(246, 190, 82, .045) 0 1px, transparent 1.5px) 0 0 / 22px 22px,
    radial-gradient(ellipse at 50% -15%, rgba(75, 145, 105, .42), transparent 58%),
    linear-gradient(180deg, #16483e 0%, #10372f 100%);
}
.score-strip {
  border-color: rgba(255, 231, 174, .2);
  background: linear-gradient(135deg, rgba(9, 48, 40, .82), rgba(27, 81, 68, .76));
  box-shadow: inset 0 1px rgba(255, 255, 255, .045), 0 7px 20px rgba(3, 24, 19, .14);
}
.panel {
  border-color: rgba(255, 239, 204, .17);
  background: linear-gradient(145deg, rgba(38, 91, 75, .98), rgba(22, 65, 56, .98));
  box-shadow: inset 0 1px rgba(255, 255, 255, .045), 0 10px 28px rgba(4, 22, 17, .2);
}
.market-panel {
  border-color: rgba(246, 190, 82, .38);
  background: linear-gradient(145deg, rgba(39, 91, 73, .98), rgba(22, 65, 55, .98));
  box-shadow: inset 0 1px rgba(255, 239, 198, .08), 0 10px 30px rgba(4, 22, 17, .24), 0 0 22px rgba(246, 190, 82, .055);
}
.section-heading h2, .hand-heading h2 { text-shadow: 0 2px 9px rgba(0, 0, 0, .18); }
.card {
  border: 1px solid rgba(71, 51, 29, .3);
  box-shadow: 0 5px 9px rgba(4, 20, 16, .22), inset 0 1px rgba(255, 255, 255, .55);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.card::before {
  inset: 4px;
  border-color: rgba(255, 255, 255, .64);
  box-shadow: inset 0 0 0 1px rgba(76, 54, 33, .08);
}
.card--market { border-radius: 12px; }
.card--hand { border-radius: 11px; }
.card.is-selectable:hover, .card.is-selectable:focus-visible {
  transform: translateY(-3px) scale(1.015);
  box-shadow: 0 9px 16px rgba(4, 20, 16, .28), inset 0 1px rgba(255, 255, 255, .7);
}
.card.is-selected {
  transform: translateY(-6px) scale(1.025);
  outline: 2px solid #ffe08c;
  box-shadow: 0 11px 20px rgba(3, 22, 18, .34), 0 0 0 4px rgba(248, 200, 92, .16);
}
.primary-button {
  background: linear-gradient(115deg, #ffe08a, #f4bd55 58%, #edaa3f);
  box-shadow: inset 0 1px rgba(255, 255, 255, .45), 0 8px 22px rgba(236, 165, 57, .22);
}
.secondary-button, .sell-button, .cancel-button {
  box-shadow: inset 0 1px rgba(255, 255, 255, .12), 0 4px 10px rgba(3, 22, 18, .12);
}
@media (prefers-reduced-motion: reduce) {
  .card, .card.is-selectable, .primary-button, .secondary-button, .sell-button, .cancel-button {
    transition-duration: .01ms !important;
  }
}

/* Fit the complete game board inside short phone and Telegram viewports. */
@media (max-width: 539px) and (max-height: 1000px) {
  body.game-active { min-height: 0; height: 100dvh; overflow: hidden; overscroll-behavior: none; }
  body.game-active .app-shell {
    height: 100dvh;
    min-height: 0;
    padding: max(5px, env(safe-area-inset-top)) var(--shell-gutter) max(5px, env(safe-area-inset-bottom));
    overflow: hidden;
  }
  body.game-active .match-screen {
    height: 100%;
    min-height: 0;
    justify-content: space-between;
    gap: clamp(5px, .8vh, 8px);
    overflow: hidden;
  }
  body.game-active .score-strip { min-height: 50px; padding: 3px 9px; }
  body.game-active .turn-banner { min-height: 36px; }
  body.game-active .opponent-panel { min-height: 58px; padding: 7px 10px; }
  body.game-active .section-heading { padding-top: 7px; }
  body.game-active .market-grid { min-height: 112px; padding-block: 7px 5px; }
  body.game-active .card--market { height: 100px; padding-block: 9px 6px; }
  body.game-active .player-panel { padding: 9px 10px; }
  body.game-active .player-summary { padding-bottom: 7px; }
  body.game-active .herd-row { min-height: 47px; padding-block: 5px 3px; }
  body.game-active .hand-heading { padding-block: 7px 3px; }
  body.game-active .hand-grid { min-height: 84px; }
  body.game-active .card--hand { height: 78px; }
  body.game-active .action-hint { min-height: 25px; margin-top: 5px; }
  body.game-active .action-row { gap: 5px; margin-top: 5px; }
  body.game-active .action-row button { min-height: 38px; padding-block: 5px; }
}

@media (max-width: 539px) and (max-height: 920px) {
  body.game-active .app-shell { --shell-gutter: 9px; }
  body.game-active .match-screen { gap: 5px; }
  body.game-active .score-strip { min-height: 43px; padding: 2px 7px; border-radius: 13px; }
  body.game-active .score-player { min-width: 0; gap: 5px; }
  body.game-active .avatar { width: 25px; height: 25px; font-size: 14px; }
  body.game-active .seal-count { min-width: 21px; height: 21px; font-size: 11px; }
  body.game-active .round-label { font-size: 10px; }
  body.game-active .round-label strong { font-size: 15px; }
  body.game-active .turn-status-row { gap: 5px; }
  body.game-active .turn-banner { min-height: 32px; padding-inline: 5px; font-size: 12px; line-height: 1.3; }
  body.game-active .icon-button { width: 32px; height: 32px; }
  body.game-active .opponent-panel { min-height: 44px; padding: 5px 9px; }
  body.game-active .opponent-copy strong { font-size: 13px; }
  body.game-active .opponent-stats { gap: 7px; font-size: 11px; }
  body.game-active .opponent-stats b { font-size: 12px; }
  body.game-active .treasury-bar { padding: 3px 8px 0; }
  body.game-active .treasury-summary { gap: 6px; padding: 4px 7px; font-size: 11px; }
  body.game-active .treasury-summary b, body.game-active .treasury-summary strong { font-size: 10px; }
  body.game-active .section-heading { padding: 4px 9px 0; }
  body.game-active .section-kicker { font-size: 10px; }
  body.game-active .section-heading h2 { font-size: 15px; }
  body.game-active .market-count { padding: 3px 6px; font-size: 10px; }
  body.game-active .market-grid { min-height: clamp(88px, 13vh, 100px); gap: 4px; padding: 5px 7px 4px; }
  body.game-active .card--market { height: clamp(74px, 11vh, 86px); padding: 7px 2px 4px; }
  body.game-active .card-label { min-height: 9px; font-size: 8px; }
  body.game-active .market-footnote { gap: 5px; padding: 0 9px 5px; font-size: 10px; line-height: 1.3; }
  body.game-active .player-panel { padding: 6px 8px; }
  body.game-active .player-summary { padding-bottom: 4px; }
  body.game-active .player-name-wrap { gap: 6px; }
  body.game-active .player-name-wrap .section-kicker { font-size: 10px; }
  body.game-active .player-name-wrap strong { margin-top: 0; font-size: 13px; }
  body.game-active .herd-row { min-height: 40px; gap: 5px; padding: 3px 0; }
  body.game-active .herd-label { min-width: 37px; font-size: 9px; }
  body.game-active .herd-label strong { font-size: 12px; }
  body.game-active .herd-cards { gap: 3px; padding: 0; }
  body.game-active .card--herd { width: 34px; min-width: 34px; height: 34px; padding: 2px 1px; }
  body.game-active .card--herd .card-icon { font-size: 19px; }
  body.game-active .card--herd .card-product-image { height: 21px; }
  body.game-active .herd-hint { font-size: 9px; }
  body.game-active .hand-heading { padding: 4px 1px 2px; }
  body.game-active .hand-heading h2 { font-size: 14px; }
  body.game-active .hand-heading span { font-size: 10px; }
  body.game-active .hand-grid { min-height: clamp(62px, 10vh, 74px); gap: 3px; }
  body.game-active .card--hand { height: clamp(56px, 9vh, 68px); padding: 5px 2px 3px; }
  body.game-active .card--hand .card-icon { font-size: 19px; }
  body.game-active .card--hand .card-label { min-height: 8px; font-size: 7px; }
  body.game-active .hand-empty { min-height: 52px; }
  body.game-active .action-hint { min-height: 22px; margin-top: 4px; padding: 3px 6px; font-size: 10px; line-height: 1.3; }
  body.game-active .action-row { gap: 4px; margin-top: 4px; }
  body.game-active .action-row button { min-height: 34px; padding: 4px; border-radius: 10px; font-size: 10px; line-height: 1.25; }
  body.game-active .secondary-button span { width: 16px; height: 16px; }
  body.game-active .match-footer { font-size: 8px; }
}

@media (max-width: 539px) and (max-height: 660px) {
  body.game-active .app-shell { --shell-gutter: 7px; padding-top: max(3px, env(safe-area-inset-top)); padding-bottom: max(3px, env(safe-area-inset-bottom)); }
  body.game-active .match-screen { gap: 4px; }
  body.game-active .score-strip { min-height: 37px; }
  body.game-active .avatar { width: 22px; height: 22px; font-size: 12px; }
  body.game-active .seal-count { min-width: 19px; height: 19px; font-size: 10px; }
  body.game-active .round-label { font-size: 9px; }
  body.game-active .round-label strong { font-size: 13px; }
  body.game-active .turn-banner { min-height: 29px; font-size: 11px; }
  body.game-active .icon-button { width: 29px; height: 29px; }
  body.game-active .opponent-panel { min-height: 39px; padding-block: 3px; }
  body.game-active .opponent-copy strong { font-size: 12px; }
  body.game-active .opponent-stats { font-size: 10px; }
  body.game-active .market-grid { min-height: clamp(68px, 12vh, 78px); padding-block: 3px; }
  body.game-active .card--market { height: clamp(58px, 10.5vh, 69px); padding-block: 4px 2px; }
  body.game-active .card-icon { font-size: 21px; }
  body.game-active .market-footnote { font-size: 9px; }
  body.game-active .player-panel { padding: 4px 6px; }
  body.game-active .player-summary { padding-bottom: 2px; }
  body.game-active .player-name-wrap .section-kicker { font-size: 9px; }
  body.game-active .player-name-wrap strong { font-size: 12px; }
  body.game-active .herd-row { min-height: 34px; padding-block: 2px; }
  body.game-active .herd-label { font-size: 8px; }
  body.game-active .herd-label strong { font-size: 11px; }
  body.game-active .card--herd { width: 29px; min-width: 29px; height: 29px; }
  body.game-active .card--herd .card-icon { font-size: 17px; }
  body.game-active .card--herd .card-product-image { height: 18px; }
  body.game-active .herd-hint { font-size: 8px; }
  body.game-active .hand-heading { padding-block: 2px 1px; }
  body.game-active .hand-heading h2 { font-size: 13px; }
  body.game-active .hand-heading span { font-size: 9px; }
  body.game-active .hand-grid { min-height: clamp(50px, 9vh, 60px); }
  body.game-active .card--hand { height: clamp(45px, 8vh, 55px); padding-block: 3px 2px; }
  body.game-active .card--hand .card-icon { font-size: 16px; }
  body.game-active .card--hand .card-label { min-height: 7px; font-size: 6px; }
  body.game-active .hand-empty { min-height: 42px; }
  body.game-active .action-hint { min-height: 19px; margin-top: 2px; padding-block: 2px; font-size: 9px; }
  body.game-active .action-row { gap: 3px; margin-top: 3px; }
  body.game-active .action-row button { min-height: 30px; padding: 3px; font-size: 9px; }
  body.game-active .match-footer { font-size: 7px; }
}
