/* ── Муушиг — Luxe Casino theme ───────────────────────────
   Гүн фетр ногоон + бараан, алтан аксент, serif гарчиг
   (Noto Serif) + цэвэр sans (Noto Sans). Хөзрийн ранк Inter. */
:root {
  --bg-0: #06100b;
  --felt-hi: #1a6b46;
  --felt-mid: #0f4e32;
  --felt-lo: #082f1f;
  --felt-edge: #062316;
  --gold: #f1e6cc;
  --gold-hi: #f1e6cc;
  --gold-deep: #6f8f7c;
  --cream: #efe6d2;
  --on-gold: #0f3d2a;
  --ink: #1a1409;
  --suit-red: #c8322a;
  --panel: rgba(8, 30, 21, .72);
  --panel-2: rgba(13, 42, 30, .9);
  --line: rgba(241, 230, 204, .28);
  --text: #f1e6cc;
  --text-dim: rgba(241, 230, 204, .62);
  --danger: #ff8a94;
  --good: #7fe3a6;
  --back-1: #155740;   /* card-back gradient (felt-toned) */
  --back-2: #0a2c1d;
}
/* Улаан хилэн скин — ижил алт/cream аксент, час улаан ширээн дээр */
body.skin-red {
  --bg-0: #160407;
  --felt-hi: #8a2433;
  --felt-mid: #5e1722;
  --felt-lo: #380b13;
  --felt-edge: #2a0810;
  --panel: rgba(42, 8, 14, .72);
  --panel-2: rgba(60, 14, 22, .9);
  --back-1: #6e1a26;
  --back-2: #2a0a0f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* hidden атрибут нь ямар ч display дүрмээс дээгүүр байна */
[hidden] { display: none !important; }
button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
/* Form controls-д body фонт өвлөгддөггүй — Ү/Ө зөв гарахын тулд заавал */
button, input, select, textarea { font-family: inherit; }

/* Тоглоом — native апп шиг: текст сонголтгүй, хуудас гүйлгэх/үсрэхгүй */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  min-height: calc(100vh / var(--z, 1));
  min-height: calc(100dvh / var(--z, 1));
  background: var(--felt-mid);
  font-family: "Noto Sans", system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ── Тоглоомын хайрцаг ── */
main#app {
  width: 100%;
  max-width: 460px;
  height: calc(100vh / var(--z, 1));
  height: calc(100dvh / var(--z, 1));
  position: relative;
  display: flex;
  flex-direction: column;
  /* Usion бүтэн дэлгэцээр нээгддэг: iPhone-ий камер болон доод "гэр" зураасаас зай авна,
     эс бөгөөс доод товч дарахад iPhone-ий гарах зангаа идэвхждэг. */
  padding: calc(10px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  overflow: hidden;
}
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ── Дэлгэцийн буланд байрлах хөвөгч товчнууд ── */
/* Ширээний өнгө солигч (ногоон ↔ улаан хилэн) */
.skins { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); z-index: 70; }
.skin-toggle {
  width: 30px; height: 30px; border-radius: 50%; padding: 0;
  border: 2px solid var(--gold); cursor: pointer;
  background: linear-gradient(135deg, #1a6b46 0 50%, #8a2433 50% 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.skin-toggle:active { transform: scale(.94); }
/* Хөзрийн төрөл сонгогч (3 жижиг cream карт товч) */
.card-themes { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: calc(max(8px, env(safe-area-inset-left)) + 36px); z-index: 70; display: flex; gap: 5px; }
.card-th {
  min-width: 27px; height: 30px; padding: 0 4px; border-radius: 5px;
  background: var(--cream);
  border: 1.5px solid transparent; cursor: pointer;
  font-family: "Inter", system-ui, sans-serif; font-size: 11px; font-weight: 700; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 1px;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.card-th.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold-hi), 0 2px 8px rgba(0,0,0,.5); }
.card-th[data-id="dark"] { background: #1e2530; }
/* Онооны тэмдэглэлийн товч (chat-toggle-ийн байрлал) */
.score-btn {
  position: fixed; top: calc(8px + env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); z-index: 70;
  width: 44px; height: 44px; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1; cursor: pointer;
  border: 2px solid var(--gold); color: var(--gold-hi);
  background: var(--panel-2);
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.score-btn:active { transform: scale(.94); }
.score-btn svg { width: 20px; height: 20px; }
.score-btn { border: 0; background: rgba(0,0,0,.3); color: var(--cream); box-shadow: none; }
.chat-btn { right: calc(max(8px, env(safe-area-inset-right)) + 50px); }
.score-btn:active { background: rgba(0,0,0,.45); }
/* Оноо, хөзрийн төрөл ширээн дээр; чат хүлээлгийн өрөөнд ч нээлттэй. */
body:not([data-screen="table"]) .score-btn:not(.chat-btn),
body:not([data-screen="table"]) .card-themes { display: none; }
body:not([data-screen="table"]):not([data-screen="waiting"]) .chat-btn { display: none; }
body[data-screen="waiting"] .chat-btn { right: max(8px, env(safe-area-inset-right)); }

/* ── Хөзөр (цэвэр CSS, sprite биш) ── */
.card {
  position: relative;
  width: 54px; height: 76px;
  font-family: "Inter", system-ui, sans-serif;   /* ранк латин — Inter цэвэрхэн */
  font-size: 12px;                               /* суурь; хүүхдүүд em ашиглана */
  border-radius: 7px;
  background: #f5f0e6;
  color: var(--ink);
  box-shadow: 0 2px 5px rgba(0,0,0,.28), inset 0 0 0 1px rgba(26,20,9,.1);
  border: 1.5px solid transparent;
  overflow: hidden;
}
.card.red { color: var(--suit-red); }
.card .corner { position: absolute; display: flex; flex-direction: column; align-items: center; gap: .08em; line-height: .95; font-weight: 700; }
.card .corner.tl { top: .35em; left: .42em; }
.card .corner.br { bottom: .35em; right: .42em; transform: rotate(180deg); }
.card .corner b { font-size: 1.18em; letter-spacing: -.03em; }
.card .pip { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 2.35em; }
/* Хөзрийн төрөл: 4 өнгө / бараан (2 өнгө = анхдагч) */
body[data-cards="dark"] .card {
  background: #1e2530;
  color: var(--cream);
  box-shadow: 0 3px 8px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.06);
}
body[data-cards="dark"] .card.red { color: var(--danger); }

/* Хөзрийн ар тал — бүдэг геометр хээ, нимгэн хүрээ */
.card-back, .mini-back {
  background:
    repeating-linear-gradient(45deg, rgba(241,230,204,.1) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(-45deg, rgba(241,230,204,.1) 0 1px, transparent 1px 9px),
    var(--back-2);
  border: 1px solid rgba(241,230,204,.45);
}
.card-back {
  position: relative;
  width: 54px; height: 76px; border-radius: 7px; flex: 0 0 auto;
  box-shadow: 0 2px 5px rgba(0,0,0,.28);
}
.card-back::before {
  content: ""; position: absolute; inset: 4px; border-radius: 3px;
  border: 1px solid rgba(241,230,204,.3); pointer-events: none;
}
.card-back::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 28%; aspect-ratio: 1;
  transform: translate(-50%,-50%) rotate(45deg);
  border: 1px solid rgba(241,230,204,.6); background: var(--back-2); pointer-events: none;
}
.mini-back {
  width: 17px; height: 24px; border-radius: 3px; flex: 0 0 auto;
  margin-left: -10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.pod-fan .mini-back:first-child { margin-left: 0; }

/* ── Ширээ ── */
#table { gap: 0; }
.felt-wrap { position: relative; width: 100%; flex: 1; min-height: 0; margin: 0 auto; }
.felt { position: absolute; inset: 0; }
.tournament-table-wait { position: absolute; z-index: 3; left: 50%; top: 47%; transform: translate(-50%, -50%); width: 70%; text-align: center; pointer-events: none; }
.tournament-table-wait > span { display: block; font-size: 16px; font-weight: 600; line-height: 1.5; color: var(--cream); }
.tournament-table-wait strong { display: block; margin: 10px 0; font-size: 52px; line-height: 1.1; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--cream); }
.tournament-table-wait small { display: block; font-size: 13px; line-height: 1.6; color: var(--cream); }
@media (max-height: 650px) {
  .tournament-table-wait > span { font-size: 14px; }
  .tournament-table-wait strong { margin: 6px 0; font-size: 40px; }
}
.pod .waiting-presence { position: static; transform: none; padding: 0; background: transparent; border: 0; box-shadow: none; font-size: 12px; line-height: 1.5; color: var(--cream); white-space: nowrap; }
.pod .waiting-presence.arrived { color: var(--good); }
.pod .waiting-presence::after { display: none; }
body:has(#table.tournament-waiting:not([hidden])) #scoreBtn { display: none; }
/* Ул (козырь) өнгийн тэмдэг */
.tsuit { font-size: 1.25em; color: var(--text); vertical-align: -1px; }
.tsuit.r { color: var(--suit-red); }
/* Төвийн эргэдэг (козырь) хөзөр */
.center-trump {
  position: absolute; left: max(8px, env(safe-area-inset-left)); top: 47%;
  transform: translateY(-50%); z-index: 2; text-align: center;
}
.center-trump .flip { position: relative; width: 54px; height: 76px; margin: 0 auto; transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.2,.8,.2,1); }
.center-trump .flip.revealed { transform: rotateY(180deg); }
.center-trump .flip .card,
.center-trump .flip .card-back { position: absolute; inset: 0; width: 100%; height: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.center-trump .flip .fb-front { transform: rotateY(180deg); }
.trump-suit-icon {
  width: 54px; height: 76px;
  display: grid; place-items: center;
  color: var(--ink); font-size: 48px; line-height: 1; /* козирь тод харагдана (өмнө нь .5 бүдэг байсан) */
}
.trump-suit-icon.red { color: var(--suit-red); }
@media (prefers-reduced-motion: reduce) {
  .center-trump .flip { transition: none; }
}

/* Газрын сан (6 мод) — козырийн хажууд, доош харсан */
.pool {
  position: absolute; left: calc(max(8px, env(safe-area-inset-left)) + 64px); top: 47%;
  transform: translateY(-50%); z-index: 2; text-align: center;
}
.pool .lbl {
  font-family: "Noto Sans", sans-serif; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  color: var(--gold); margin-bottom: 5px;
}
.pool .stack { position: relative; width: 58px; height: 50px; margin: 0 auto; }
.pool .stack .card-back { position: absolute; top: 0; width: 34px; height: 48px; border-radius: 5px; box-shadow: 0 1px 4px rgba(0,0,0,.45); }
.pool .cnt {
  font-family: "Noto Sans", sans-serif; font-size: 12px; font-weight: 700; color: var(--gold-hi);
  margin-top: 4px; font-variant-numeric: tabular-nums;
}

/* Ялсан хүн рүү бөөгнөрөх анимэйшн — left/top биш transform (felt-ийн хэмжээтэй давхарга % -аар шилжинэ) */
.gather { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.gather .gather-fly { position: absolute; inset: 0; transition: transform .55s cubic-bezier(.2,.8,.2,1); }
.gather .card { position: absolute; transform: translate(-50%,-50%) scale(.82);
  transition: opacity .55s, transform .55s cubic-bezier(.2,.8,.2,1); }

/* Солионоос хөзөр татах болон улны хөзөр авах animation-ийн давхарга.
   Эхлэх цэг нь сан/улны хөзрийн төв (CSS-ээр), нислэг нь .fly давхаргын transform. */
.deal { position: absolute; inset: 0; z-index: 6; pointer-events: none;
  --pool-x: calc(max(8px, env(safe-area-inset-left)) + 93px);
  --trump-x: calc(max(8px, env(safe-area-inset-left)) + 27px); }
.deal .fly { position: absolute; inset: 0; transition: transform .42s cubic-bezier(.2,.8,.2,1); }
.deal .card-back, .deal .card { position: absolute; top: 47%; transition: opacity .35s ease; }
.deal .card-back { left: var(--pool-x); transform: translate(-50%,-50%); }
.deal .trump-take { left: var(--trump-x); transform: translate(-50%,-50%); z-index: 8; }

/* Гарсан хөзрүүд — ширээний голд */
.played { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.played .card { position: absolute; }
/* Өөрийн тавьсан хөзөр гараас ширээ рүү буух (сервер хариулахыг хүлээлгүй) */
.played .card.landing { animation: cardLand .24s cubic-bezier(.2,.8,.2,1); }
@keyframes cardLand { from { translate: 0 140px; scale: .85; opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .played .card.landing { animation: none; } }
/* Гарсан хөзөр дээр тавьсан хүний зураг */
.played .card .who, .gather .card .who { position: absolute; left: 3px; bottom: 3px; z-index: 2; display: block; }
.played .card .who .ava, .gather .card .who .ava { width: 22px; height: 22px; font-size: 10px; border: 1.5px solid var(--cream); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.played .card, .gather .card { width: clamp(58px, 15vw, 72px); height: auto; aspect-ratio: 5 / 7; font-size: clamp(14px, 3.6vw, 17px); }
/* ── Тоглогчид (ширээний эргэн тойронд) ── */
.pods { position: absolute; inset: 0; z-index: 4; }
.pod { position: absolute; transform: translate(-50%, -50%); width: 97px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pod.me { cursor: pointer; }
/* Ээлжтэй тоглогч — алтан хүрээ (бот ч, хүн ч) */
.pod.turn .ava { box-shadow: 0 0 0 3px var(--gold-hi), 0 0 16px rgba(241,230,204,.55); }
/* Аватарын суурь (pod, lobby, scoreboard хаана ч ажиллана) */
.ava { position: relative; border-radius: 50%; display: grid; place-items: center; font-family: "Noto Sans", sans-serif;
  font-weight: 700; color: var(--cream); overflow: hidden; flex: none; }
.ava img { width: 100%; height: 100%; object-fit: cover; }
.pod-ava { position: relative; display: inline-flex; }
.voice-mark { position: absolute; left: -5px; bottom: -3px; z-index: 6; display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--good); color: #062b21; pointer-events: none; }
.voice-mark svg { width: 13px; height: 13px; }
.voice-mark svg path { transform-box: fill-box; transform-origin: center; }
.voice-mark[data-speaking="true"] svg { stroke-width: 3; }
.voice-mark[data-speaking="true"] path { animation: voiceWave .65s ease-in-out infinite; }
.voice-mark[data-speaking="true"] path:nth-child(2) { animation-delay: -.15s; }
.voice-mark[data-speaking="true"] path:nth-child(3) { animation-delay: -.3s; }
.voice-mark[data-speaking="true"] path:nth-child(4) { animation-delay: -.45s; }
@keyframes voiceWave { 0%, 100% { transform: scaleY(.35); } 50% { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .voice-mark[data-speaking="true"] path { animation: none; } }
.pod .ava { width: 46px; height: 46px; font-size: 18px; border: 0; box-shadow: none; }
.pod.folded { opacity: .5; }
.pod.off { opacity: .85; }
.pod.off .ava { filter: grayscale(1) brightness(.65); }
.pod.kicked { opacity: .35; filter: grayscale(1); }
.pod-fan { display: flex; justify-content: center; min-height: 32px; padding: 3px; }
.opp-name { display: flex; align-items: center; gap: 5px; max-width: 100%; font-size: 13px; font-weight: 600; line-height: 1.25; }
.pname { max-width: 88px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 3px rgba(0,0,0,.85); }
.opp-score { font-family: "Noto Sans", sans-serif; font-size: 16px; font-weight: 700; color: var(--gold-hi);
  font-variant-numeric: tabular-nums; line-height: 1.2; }
.opp-action {
  position: absolute; left: 50%; top: -42px; z-index: 8;
  transform: translateX(-50%);
  max-width: 112px; padding: 7px 12px; border-radius: 14px;
  font-family: "Noto Sans", sans-serif; font-size: 13px; font-weight: 600; line-height: 1.35;
  color: var(--ink); background: var(--cream);
  border: 1px solid var(--gold-deep);
  box-shadow: 0 4px 12px rgba(0,0,0,.38);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.opp-action::after {
  content: ""; position: absolute; left: 50%; bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--cream); border-bottom: 0;
}
.pod.top-seat .opp-action {
  top: calc(100% + 6px);
}
.pod.top-seat .opp-action::after {
  top: -6px; bottom: auto;
  border-top: 0; border-bottom: 6px solid var(--cream);
}
.opp-action.pass, .opp-action.play, .opp-action.off {
  color: var(--ink); background: var(--cream);
}

/* Салсан тэмдэг (аватарын зүүн дээд буланд) */
.pod .off-badge { position: absolute; top: -4px; left: -6px; width: 19px; height: 19px; border-radius: 50%; z-index: 4;
  background: var(--suit-red); color: var(--cream); font-size: 11px; font-weight: 900; display: grid; place-items: center;
  border: 1.5px solid var(--cream); box-shadow: 0 1px 5px rgba(0,0,0,.5); animation: offPulse 1.2s ease-in-out infinite; }
@keyframes offPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.18); opacity: .7; } }
.won-cards {
  position: absolute; left: 50%; top: -24px; z-index: 5;
  display: flex; justify-content: center; transform: translateX(-50%);
}
.won-mini {
  width: 15px; height: 21px; margin-left: -3px; padding-top: 2px;
  display: flex; flex-direction: column; align-items: center;
  border-radius: 2px; border: 1px solid rgba(0,0,0,.28);
  background: #fff; color: var(--ink);
  font-family: "Inter", sans-serif; font-style: normal;
  box-shadow: 0 1px 3px rgba(0,0,0,.45);
}
.won-mini:first-child { margin-left: 0; }
.won-mini.red { color: var(--suit-red); }
.won-mini b { font-size: 6px; line-height: 1; }
.won-mini i { font-size: 8px; line-height: 1; font-style: normal; }
/* Гэр хожиход аватар богино хугацаанд гэрэлтэнэ */
.pod.won-trick .ava { animation: trickWin .9s ease-out; }
@keyframes trickWin { 0% { box-shadow: 0 0 0 0 rgba(241,230,204,.85), 0 3px 10px rgba(0,0,0,.55); }
  100% { box-shadow: 0 0 0 14px rgba(241,230,204,0), 0 3px 10px rgba(0,0,0,.55); } }
/* Дилерийн товч */
.pod .dealer-btn { position: absolute; bottom: -2px; right: -2px; width: 19px; height: 19px; border-radius: 50%; z-index: 4;
  background: var(--cream); color: var(--on-gold);
  font-family: "Noto Sans", sans-serif; font-size: 10px; font-weight: 700; display: grid; place-items: center;
  border: 1.5px solid var(--gold-hi); box-shadow: 0 2px 8px rgba(0,0,0,.55); }
@media (prefers-reduced-motion: reduce) {
  .pod .off-badge { animation: none; }
  .pod.won-trick .ava { animation: none; }
}

/* Ээлжийн pie countdown — дүүрэн дугуй бага багаар хорогдоно */
.seat-timer { position: absolute; inset: -6px; z-index: 3; display: block; pointer-events: none; }
.seat-timer svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.seat-timer .ring-bg { fill: none; stroke: rgba(239,230,210,.18); stroke-width: 1.75; }
.seat-timer .ring-fg {
  fill: none; stroke: var(--cream); stroke-width: 1.75; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 0;
  transition: stroke-dashoffset .22s linear, stroke .3s;
}
.seat-timer.warn .ring-fg { stroke: var(--suit-red); }
.pod-timer { width: auto; height: auto; }

/* ── Миний суудал: гарын фэн + удирдлага ── */
.hand-area { margin-top: 8px; flex: none; }
.hand { display: flex; justify-content: center; align-items: flex-end; height: 122px; padding: 40px 6px 0; }
.hand .card {
  width: 52px; height: 74px; font-size: 13px;
  flex: 0 0 auto;                 /* margin-left-ийг layoutHand() JS-ээр өгнө */
  position: relative; z-index: 1; /* сонгоогүй хөзөр урд */
  cursor: pointer;
  transition: transform .14s cubic-bezier(.2,.8,.2,1), box-shadow .14s, border-color .14s;
}
/* Сонгосон хөзөр фэний АРДААС дээш гарна (зөвхөн үзүүр нь харагдана) */
.hand .card.sel {
  transform: translateY(-34px);
  z-index: 0;
  border-color: var(--gold);
  box-shadow: 0 -3px 12px rgba(241,230,204,.55);
}
/* Хуультай, хуульгүй хөзөр харагдах байдлаар ижил; хуульгүй нь зөвхөн click авахгүй. */
.hand .card.illegal { opacity: 1; filter: none; cursor: default; pointer-events: none;
  border-color: transparent !important; box-shadow: none !important; }
@media (prefers-reduced-motion: reduce) { .hand .card { transition: none; } }

/* min-height: товч байхгүй үед ч ижил өндөр — ширээ үсрэхгүй */
.controls { display: flex; gap: 10px; margin-top: 8px; min-height: 48px; }
.ctrl-btn, .btn-confirm, .chip {
  flex: 1 1 0; min-height: 48px; padding: 0 18px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 16px/1.25 "Noto Sans", sans-serif; cursor: pointer;
  color: var(--text); background: transparent; border: 1.5px solid rgba(241,230,204,.55); box-shadow: none;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s, opacity .15s;
}
.ctrl-btn:active, .btn-confirm:active, .chip:active { transform: scale(.97); }
@media (hover: hover) {
  .ctrl-btn:not(:disabled):hover, .chip:hover { background: rgba(241,230,204,.1); border-color: var(--text); }
  .ctrl-btn.primary:not(:disabled):hover, .btn-confirm:hover { background: #fff8e8; }
}
.ctrl-btn.primary, .btn-confirm { background: var(--cream); color: var(--on-gold); border-color: var(--cream); }
.ctrl-btn.primary:active, .btn-confirm:active { background: #ddd2b8; }
.ctrl-btn:disabled, .ctrl-btn.primary:disabled { background: transparent; color: rgba(241,230,204,.45); border: 1.5px dashed rgba(241,230,204,.3); cursor: default; }
.ctrl-btn.btn-ready-on { background: rgba(241,230,204,.14); color: var(--text); border-color: var(--text); }
/* Икон SVG — ГЛОБАЛ хэмжээ. SVG-д өргөн/өндөр өгөхгүй бол эцгийнхээ хэмжээгээр
   тэлдэг (жишээ нь .btn-confirm доторх play икон 177px болж дэлбэрдэг). */
.ic, .ic-sm { display: inline-block; vertical-align: -2px; flex: none; }
.ic { width: 18px; height: 18px; }
.ic-sm { width: 14px; height: 14px; }
@media (prefers-reduced-motion: reduce) { .ctrl-btn, .btn-confirm, .chip { transition: none; } }
.btn-confirm { width: 100%; flex: none; }

/* ── Оверлей дэлгэцүүд ── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(3, 10, 7, .68);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 16px;
  backdrop-filter: blur(4px);
}
.overlay-card {
  position: relative;
  background:
    var(--felt-lo);
  background-color: var(--felt-lo);
  border: 1px solid var(--gold-deep);
  border-radius: 20px;
  padding: 26px 22px;
  width: 100%; max-width: 380px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.6), inset 0 0 0 1px rgba(241,230,204,.18);
  max-height: 94vh; overflow-y: auto;
}
.setup-foot { font-size: 11px; color: var(--text-dim); margin-top: 14px; line-height: 1.5; }

/* Хүлээлгийн өрөө */
.hall { align-items: center; justify-content: center; gap: 18px; padding: 16px; }
.logo { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.logo-fan { position: relative; width: 112px; height: 92px; animation: bob 3s ease-in-out infinite; filter: drop-shadow(0 12px 30px rgba(241,230,204,.3)); }
.logo-fan .lc { position: absolute; left: 36px; top: 6px; width: 46px; height: 66px; border-radius: 7px; background: var(--cream); color: var(--ink);
  border: 1px solid var(--gold-hi); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: 800 19px/1 "Noto Serif", serif; transform-origin: 50% 120%; box-shadow: 0 4px 10px rgba(0,0,0,.35); }
.logo-fan .lc i { font-style: normal; font-size: 18px; }
.logo-fan .lc.red { color: var(--suit-red); }
.logo-fan .lc:nth-child(1) { transform: translateX(-20px) rotate(-18deg); }
.logo-fan .lc:nth-child(3) { transform: translateX(20px) rotate(18deg); }
.logo b { font-family: "Noto Serif", serif; font-weight: 800; font-size: 28px; letter-spacing: -.01em;
  color: var(--text); }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
@media (prefers-reduced-motion: reduce) { .logo-fan { animation: none; } }
.seats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px 10px; width: 100%; max-width: 340px; }
#waiting:not(.room) .seats > .seat { grid-column: 1 / -1; }
.seat:nth-child(4) { grid-column: 2 / span 2; } /* доод 2 суудал голдоо */
.seat { grid-column: span 2; position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.seat .ava { width: 62px; height: 62px; font-size: 22px; color: #fff; box-shadow: 0 10px 22px rgba(0,0,0,.4); } /* хүрээгүй */
.seat.ready .ava { box-shadow: 0 0 0 3px var(--good), 0 10px 22px rgba(0,0,0,.4); }
.seat .nm { font-size: 13px; font-weight: 500; line-height: 1.4; color: var(--text-dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat.me .nm { color: var(--text); }
.seat .tick { position: absolute; top: 44px; right: calc(50% - 38px); width: 22px; height: 22px; border-radius: 50%; background: var(--good); color: #0b2a18;
  border: 3px solid var(--felt-lo); display: grid; place-items: center; transform: scale(0); transition: transform .25s cubic-bezier(.34, 1.56, .64, 1); }
.seat .tick svg { width: 11px; height: 11px; }
.seat.ready .tick { transform: scale(1); }
.seat .crown { position: absolute; z-index: 2; top: -13px; color: var(--gold-hi); }
.seat .x { position: absolute; top: -6px; right: calc(50% - 42px); width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); font-size: 12px; display: grid; place-items: center; z-index: 2; cursor: pointer; }
.seat .x::after { content: ''; position: absolute; inset: -9px; }
.seat.empty .ava { background: transparent; border: 2px dashed var(--line); box-shadow: none; }
.hint { font-size: 14px; line-height: 1.4; color: var(--text-dim); text-align: center; min-height: 20px; font-weight: 500; }
.choice { display: grid; grid-template-columns: 1fr; gap: 12px; width: 100%; max-width: 360px; }
.tile { min-height: 56px; border-radius: 14px; padding: 14px 18px; border: 1px solid var(--cream);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font: 600 16px/1.35 "Noto Sans", sans-serif; text-align: center; cursor: pointer;
  background: var(--cream); color: var(--on-gold); transition: transform .15s; }
.tile.online { background: rgba(241,230,204,.08); color: var(--cream); border-color: var(--line); }
.tile:disabled { opacity: .5; cursor: default; }
.tile b { font: inherit; }
.tile .tile-ic { width: 24px; height: 24px; flex: none; display: grid; place-items: center; }
.tile .tile-ic svg { width: 24px; height: 24px; }
.chip { flex: none; min-height: 44px; padding: 0 16px; font-size: 14px; }
.tile:active { transform: scale(.98); }
.hall-bar { display: flex; gap: 10px; }
.hall-main { display: flex; gap: 10px; width: 100%; max-width: 360px; }
.hall-actions { display: flex; flex-direction: column; justify-content: flex-end; gap: 12px; width: 100%; max-width: 360px; min-height: 192px; }
.online-room-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none; }
.online-room-bar { position: relative; z-index: 51; justify-content: flex-start; pointer-events: none; margin-top: 48px; padding: 0 6px 8px; font-size: 13px; color: var(--text-dim); }
.online-room-bar button { pointer-events: auto; }
.online-room-bar #onlineLeave { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.online-room-bar #onlineLeave svg { width: 20px; height: 20px; flex: none; }
body[data-screen="table"] .online-room-bar { margin-top: 0; gap: 8px; padding-right: 156px; }
body[data-screen="table"] #onlineLeave { width: 44px; padding: 0; flex: none; }
body[data-screen="table"] #onlineLeave > span { display: none; }
body[data-screen="table"] #tournamentReturn { padding: 0 10px; font-size: 12px; white-space: nowrap; flex: none; }
body[data-screen="table"] .online-room-bar:has(#tournamentReturn:not([hidden])) > span { display: none; }
@media (max-width: 360px) {
  .online-room-bar:has(#tournamentReturn:not([hidden])) > span { display: none; }
}
.leave-dialog { position: fixed; inset: 0; margin: auto; width: calc(100% - 32px); max-width: 340px; padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--felt-lo); color: var(--cream); }
.leave-dialog::backdrop { background: rgba(3,10,7,.7); }
.leave-dialog h2 { font-size: 20px; line-height: 1.35; font-weight: 700; }
.leave-dialog p { margin: 12px 0 24px; font-size: 14px; line-height: 1.6; color: var(--text-dim); }
.leave-actions { display: flex; gap: 12px; }
.leaders-screen { padding: 14px 6px 0; gap: 16px; }
.leaders-head { display: flex; align-items: center; gap: 12px; flex: none; }
.leaders-head h1 { font-size: 22px; font-weight: 700; }
.leaders-head .chip { background: transparent; color: var(--cream); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.leaders-list { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 16px; }
.leaders-empty { padding: 24px 0; text-align: center; font-size: 14px; color: var(--text-dim); }
.online-room-bar .chip { background: transparent; color: var(--cream); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
@media (max-height: 680px) { .hall { gap: 12px; padding: 8px; } .hall .logo-fan { display: none; } }
.room .hint { max-width: 360px; font-size: 13px; line-height: 1.5; }
.room .hall-bar { width: 100%; max-width: 360px; }
.room .hall-bar .chip { flex: 1; min-height: 56px; border-color: var(--line); }
.room #readyBtn { min-height: 56px; background: var(--cream); color: var(--on-gold); border-color: var(--cream); }
.room #readyBtn.btn-ready-on { background: transparent; color: var(--good); border-color: var(--good); }
.room #startBtn { min-height: 56px; }
.you-tag { flex: none; font-size: 10px; font-weight: 600; color: var(--gold); letter-spacing: .04em; }

/* Үр дүн / оноо */
#result { background: var(--felt-mid); backdrop-filter: none;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.result-card { max-width: 360px; max-height: 100%; padding: 16px 0; border: 0; background: transparent; box-shadow: none; }
.winner-emoji { width: 36px; height: 36px; margin: 0 auto 8px; color: var(--gold-hi);
  animation: trophyPop .5s cubic-bezier(.34,1.56,.64,1) both; }
.winner-emoji svg { width: 100%; height: 100%; }
@keyframes trophyPop { from { transform: scale(.4) rotate(-12deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .winner-emoji { animation: none; } }
.winner-label { font-size: 24px; line-height: 1.25; font-weight: 700; color: var(--text); }
.winner-name { font-family: "Noto Sans", sans-serif; font-size: 20px; font-weight: 700; color: var(--text); margin: 18px 0 12px;
  display: flex; align-items: center; justify-content: center; gap: 12px; }
.winner-name .ava { width: 56px; height: 56px; font-size: 22px; border: 2px solid var(--cream); }
.winner-info { min-width: 0; text-align: left; }
.winner-player-name { display: block; line-height: 1.3; overflow-wrap: anywhere; }
.winner-sub { display: block; font-size: 13px; font-weight: 500; line-height: 1.4; color: var(--text-dim); margin-top: 4px; }
.result-summary { font-size: 13px; line-height: 1.5; color: var(--text-dim); margin-bottom: 20px; font-variant-numeric: tabular-nums; }
.result-table-head { display: flex; justify-content: space-between; padding: 0 12px; margin-bottom: 10px;
  font-size: 12px; font-weight: 500; color: var(--text-dim); }
.scoreboard { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.sb-row {
  display: flex; align-items: center; gap: 9px;
  background: rgba(241,230,204,.04); border: 1px solid rgba(241,230,204,.12);
  border-radius: 12px; padding: 10px 12px;
}
.sb-row.me { border-color: rgba(241,230,204,.5); }
.sb-row.lead { background: var(--cream); border-color: var(--cream); color: var(--on-gold); }
.sb-rank { font-size: 12px; font-weight: 700; color: var(--text-dim); width: 16px; text-align: center; flex: none; }
.sb-row.lead .sb-rank, .sb-row.lead .sb-score, .sb-row.lead .you-tag { color: var(--on-gold); }
.sb-row .ava { width: 32px; height: 32px; font-size: 14px; border: 1.5px solid rgba(247,242,228,.22); }
/* flex:1 биш — ингэснээр дараагийн ах дүү .you-tag нэрэндээ наалдаж, оноо руу түлхэгдэхгүй */
.sb-name { flex: 0 1 auto; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-score { font-family: "Noto Sans", sans-serif; font-size: 18px; font-weight: 700; flex: none; width: 52px; margin-left: auto; text-align: right; color: var(--gold-hi);
  font-variant-numeric: tabular-nums; }
.rematch-status { min-height: 18px; font-size: 13px; color: var(--text-dim); margin: 16px 0 12px; line-height: 1.5; }
#result .winner-sub, #result .result-summary, #result .result-table-head, #result .rematch-status { color: var(--cream); }
#rematchBtn { min-height: 52px; }
#championShare { min-height: 52px; }
#championShare:not([hidden]) + #rematchBtn { margin-top: 10px; background: transparent; color: var(--cream); border-color: var(--line); }
#rematchBtn:disabled { opacity: .5; cursor: default; }

/* ── Toast ── */
.toast {
  position: fixed; top: 24%; left: 50%;
  transform: translate(-50%, -50%) scale(.8);
  background: var(--panel-2); border: 1px solid var(--gold-deep);
  border-radius: 14px; padding: 12px 26px; width: max-content; max-width: min(360px, calc(100% - 32px));
  font-family: "Noto Sans", sans-serif; font-size: 15px; font-weight: 600; line-height: 1.45; text-align: center; color: var(--gold-hi);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .25s, transform .25s, visibility 0s linear .25s; z-index: 60;
}
/* display:none → transition үхнэ. Тиймээс .show класс + visibility ашиглана. */
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1);
  transition: opacity .25s, transform .25s, visibility 0s; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } .toast.show { transition: none; } }

/* ── Онооны тэмдэглэл (доороос гарах sheet) ── */
.score-sheet { position: fixed; inset: 0; z-index: 71; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.45); }
.score-paper {
  width: 100%; max-width: 460px; max-height: 86vh; max-height: 86dvh;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--felt-lo); color: var(--text); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 32px rgba(0,0,0,.5); animation: ssUp .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes ssUp { from { transform: translateY(24px); opacity: 0; } }
.score-paper::before { content: ''; width: 36px; height: 4px; border-radius: 999px; background: rgba(241,230,204,.3); margin: 0 auto; flex: none; }
@media (prefers-reduced-motion: reduce) { .score-paper { animation: none; } }
.ss-head { display: flex; align-items: center; gap: 10px; }
.ss-head b { font: 700 18px/1.3 "Noto Sans", sans-serif; }
.ss-head span { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.ss-close { margin-left: auto; }
/* Байр */
.ss-stand { display: flex; flex-direction: column; gap: 6px; flex: none; }
.ss-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: rgba(241,230,204,.06); }
.ss-row.lead { background: rgba(241,230,204,.14); box-shadow: inset 0 0 0 1.5px rgba(241,230,204,.5); }
.ss-rank { width: 16px; flex: none; text-align: center; font: 600 14px "Noto Sans", sans-serif; color: var(--text-dim); }
.ss-row.lead .ss-rank { color: var(--text); }
.ss-row .ava { width: 34px; height: 34px; font-size: 14px; }
.ss-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ss-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-name i { font-style: normal; font-weight: 500; color: var(--text-dim); }
.ss-bar { height: 4px; border-radius: 999px; background: rgba(241,230,204,.12); overflow: hidden; }
.ss-bar b { display: block; height: 100%; border-radius: inherit; background: var(--text); transition: width .4s cubic-bezier(.2,.8,.2,1); }
.ss-score { width: 34px; flex: none; text-align: right; font: 700 22px/1.2 "Noto Sans", sans-serif; font-variant-numeric: tabular-nums; }
.ss-d { flex: none; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ss-d.good { color: var(--good); }
.ss-d.bad { color: var(--danger); }
/* Тойргийн түүх */
.ss-hist { min-height: 0; overflow: auto; overscroll-behavior: contain; border-radius: 14px; background: rgba(0,0,0,.22); }
.ss-hist table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ss-hist th { position: sticky; top: 0; z-index: 1; padding: 8px 4px; background: var(--felt-lo); border-bottom: 1px solid var(--line); }
.ss-hist th .ava { width: 26px; height: 26px; font-size: 11px; margin: 0 auto; }
.ss-hist td { padding: 9px 4px; text-align: center; font-size: 15px; border-bottom: 1px solid rgba(241,230,204,.06); }
.ss-hist td b { font-weight: 800; }
.ss-hist td .ss-d { display: block; font-size: 10.5px; margin-top: 2px; }
.ss-hist .ss-rn { width: 30px; font-size: 12px; font-weight: 700; color: var(--text-dim); }
.ss-hist tr.last td { background: rgba(241,230,204,.07); }
.ss-hist td.fold { color: rgba(241,230,204,.35); }
.ss-hist td.win { font-size: 20px; color: var(--text); }
.ss-empty { padding: 18px; text-align: center; font-size: 13px; color: var(--text-dim); border-radius: 14px; background: rgba(0,0,0,.22); }

/* ── Чатын самбар (доороос гарах sheet) ── */
.emote-picker {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 460px; z-index: 60;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--felt-lo); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(14px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 32px rgba(0,0,0,.5), 0 0 0 100vmax rgba(0,0,0,.45); /* ард бүдгэрүүлэх; гадна дарвал хаагдана */
  animation: csUp .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes csUp { from { transform: translate(-50%, 24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .emote-picker { animation: none; } }
.emote-picker::before { content: ''; width: 36px; height: 4px; border-radius: 999px; background: rgba(241,230,204,.3); margin: 0 auto; }
.cs-head { display: flex; align-items: center; justify-content: space-between; }
.cs-head b { font: 700 18px/1.3 "Noto Sans", sans-serif; color: var(--text); }
.cs-close { width: 36px; height: 36px; margin-right: -6px; border: 0; border-radius: 50%; padding: 0; display: grid; place-items: center;
  background: rgba(241,230,204,.08); color: var(--text); cursor: pointer; position: relative; }
.cs-close::after { content: ''; position: absolute; inset: -4px; }
.cs-close svg { width: 18px; height: 18px; }
/* Мессежийн түүх */
.cs-log { display: flex; flex-direction: column; gap: 8px; max-height: 26vh; min-height: 64px; overflow-y: auto; overscroll-behavior: contain;
  padding: 10px; border-radius: 16px; background: rgba(0,0,0,.22); }
.cs-empty { margin: auto; font-size: 13px; color: var(--text-dim); }
.cs-msg { display: flex; align-items: flex-end; gap: 8px; max-width: 85%; }
.cs-msg .ava { width: 26px; height: 26px; font-size: 12px; }
.cs-msg.me { align-self: flex-end; }
.cs-bub { padding: 8px 12px; border-radius: 16px 16px 16px 4px; background: rgba(241,230,204,.1); color: var(--text);
  font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.cs-msg.me .cs-bub { border-radius: 16px 16px 4px 16px; background: var(--cream); color: var(--on-gold); }
.cs-name { display: block; font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 2px; }
/* Хурдан хариу */
.cs-emojis { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.cs-emoji { aspect-ratio: 1; width: 100%; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  font-size: 22px; line-height: 1; background: rgba(241,230,204,.07); transition: background-color .15s, transform .1s; }
.cs-emoji:active { transform: scale(.88); }
.cs-phrases { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.cs-phrases::-webkit-scrollbar { display: none; }
.cs-phrase { flex: none; min-height: 38px; padding: 0 16px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font: 700 14px "Noto Sans", sans-serif; color: var(--text); background: transparent; border: 1.5px solid rgba(241,230,204,.4);
  transition: background-color .15s, transform .1s; }
.cs-phrase:active { transform: scale(.95); background: rgba(241,230,204,.12); }
@media (hover: hover) { .cs-emoji:hover, .cs-phrase:hover { background: rgba(241,230,204,.14); } }
/* Бичих мөр */
.cs-bar { display: flex; gap: 8px; align-items: center; }
.cs-input { flex: 1; min-width: 0; height: 48px; padding: 0 18px; border-radius: 999px; border: 1.5px solid rgba(241,230,204,.25);
  background: rgba(0,0,0,.25); color: var(--text); font: 500 16px "Noto Sans", sans-serif; outline: none; transition: border-color .15s; }
.cs-input::placeholder { color: var(--text-dim); }
.cs-input:focus { border-color: var(--text); }
.cs-send { width: 48px; height: 48px; flex: none; border: 0; border-radius: 50%; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--cream); color: var(--on-gold); transition: opacity .15s, transform .1s; }
.cs-send:disabled { opacity: .35; cursor: default; }
.cs-send:not(:disabled):active { transform: scale(.92); }
.cs-send svg { width: 20px; height: 20px; }

/* Pod дээр гарах эможи/үг хэллэгийн бөмбөлөг */
.emotes { position: absolute; inset: 0; z-index: 9; pointer-events: none; }
.emote-bubble {
  position: absolute; transform: translate(-50%,-50%) scale(.6); z-index: 9;
  max-width: 160px; text-align: center; white-space: normal; pointer-events: none; opacity: 0;
  padding: 7px 13px; border-radius: 14px;
  font-family: "Noto Sans", sans-serif; font-size: 14px; font-weight: 600; line-height: 1.4;
  color: var(--ink); background: var(--cream);
  border: 1px solid var(--gold-deep);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  transition: opacity .18s ease, transform .22s cubic-bezier(.2,1.4,.5,1);
}
.emote-bubble.emoji-only { font-size: 32px; line-height: 1; padding: 0; background: none; border: none; box-shadow: none;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,.5)); }
.emote-bubble.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }
.emote-bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--cream); border-bottom: none; }
.emote-bubble.emoji-only::after { display: none; }

/* ── Нүүр хуудасны icon: нэг ижил badge — бараан ногоон + алтан icon (ширээний өнгөтэй уялдана) ── */
.tile .tile-ic[class*="b-"] { width: 34px; height: 34px; border-radius: 11px; color: var(--gold-hi);
  background: linear-gradient(180deg, #1d6a45, #0b3a24); border: 1px solid rgba(242,203,107,.4);
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,.16), 0 3px 8px rgba(0,0,0,.28); }
.tile .tile-ic[class*="b-"] svg { width: 19px; height: 19px; filter: drop-shadow(0 1px 0 rgba(0,0,0,.35)); }
.tile .tile-ic.b-play svg { margin-left: 2px; }

/* Тэмцээний үндсэн цэсний тод алтан товч. */
#chTournament { background: #ffc83d; color: #352000; border-color: #ffe39a; font-size: 18px; font-weight: 800; box-shadow: 0 5px 14px rgba(0, 0, 0, .22); }
#chTournament .tile-ic { width: 38px; height: 38px; background: #e7a51e; color: #352000; border-color: #b77b0b; box-shadow: none; }
#chTournament .tile-ic svg { width: 23px; height: 23px; filter: none; }
#chTournament:focus-visible { outline: 3px solid #fff3cb; outline-offset: 4px; }
#chTournament:active { background: #efb324; }
@media (hover: hover) { #chTournament:hover { background: #ffda70; } }

/* ── Дуут яриа ── */
.voice-btn { right: calc(max(8px, env(safe-area-inset-right)) + 100px); }
.table-viewers { position: fixed; z-index: 70; top: calc(8px + env(safe-area-inset-top)); right: calc(max(8px, env(safe-area-inset-right)) + 150px); height: 44px; display: flex; align-items: center; gap: 4px; color: var(--cream); font: 600 12px/1.3 "Noto Sans", sans-serif; font-variant-numeric: tabular-nums; pointer-events: none; }
.table-viewers svg { width: 17px; height: 17px; flex: none; }
.table-viewers.spectator { right: calc(max(8px, env(safe-area-inset-right)) + 50px); }
@media (max-width: 360px) {
  body[data-screen="table"]:has(.table-viewers:not([hidden])) #tournamentReturn { padding: 0 4px; font-size: 11px; }
  .table-viewers { right: calc(max(8px, env(safe-area-inset-right)) + 148px); gap: 3px; font-size: 11px; }
  .table-viewers.spectator { right: calc(max(8px, env(safe-area-inset-right)) + 50px); }
}
body[data-screen="waiting"] .voice-btn { right: calc(max(8px, env(safe-area-inset-right)) + 50px); }
body:not([data-screen="table"]):not([data-screen="waiting"]) .voice-btn { display: none; }
.voice-btn .mic-slash { stroke: currentColor; }
.voice-btn.on { background: #2f8f5b; color: #fff; }
.voice-btn.on .mic-slash { display: none; }
.voice-btn.busy { opacity: .6; }

.voice-btn { overflow: visible; }
.voice-count { position: absolute; top: -3px; right: -3px; min-width: 18px; padding: 1px 5px; border-radius: 9px;
  background: #f2c14e; color: #1b1b1b; font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; pointer-events: none; }
/* нүүр хуудсан дээр (тоглоом сонгох) микрофон хэрэггүй */
body:has(#waiting:not([hidden]) #choice:not([hidden])) .voice-btn { display: none; }

/* Тэмцээн — existing felt and cream palette, scrollable on small screens. */
.tournament-screen { width: 100%; padding: 8px 8px 0; }
.tournament-head { display: flex; align-items: center; gap: 18px; padding-bottom: 22px; flex: none; }
.tournament-head h1 { font: 700 23px "Noto Serif", serif; }
.tournament-head .chip { min-height: 44px; }
.tournament-head .chip, .tournament-actions .chip { background: transparent; color: var(--cream); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.tournament-scroll { min-height: 0; overflow: auto; padding: 0 2px 24px; scrollbar-width: thin; scrollbar-color: var(--gold-deep) transparent; }
.tournament-scroll h2 { font: 800 28px/1.25 "Noto Serif", serif; margin-bottom: 12px; }
.tournament-schedule { font-size: 14px; line-height: 1.6; }
.tournament-participation { padding: 18px; background: #123f2d; border-radius: 16px; }
.tournament-status { padding: 0; }
.tournament-status h3 { font-size: 18px; line-height: 1.5; margin-bottom: 8px; }
.tournament-status p { font-size: 14px; line-height: 1.7; color: var(--cream); }
.tournament-actions { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.tournament-actions:has(button:not([hidden])) { margin-top: 16px; }
.tournament-actions .ctrl-btn { width: 100%; min-height: 48px; }
.tournament-actions .chip { align-self: flex-start; min-height: 44px; }
.tournament-actions button:disabled { opacity: .55; cursor: wait; }
.tournament-actions button:focus-visible { outline: 2px solid var(--cream); outline-offset: 4px; }
.tournament-error { color: var(--danger); font-size: 14px; line-height: 1.6; margin-top: 12px; }
.tournament-stage { margin-top: 28px; }
.tournament-stage h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 17px; margin-bottom: 8px; }
.tournament-stage h3 span { font-size: 12px; font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.tournament-table { padding: 16px 0; border-bottom: 1px solid var(--line); }
.tournament-table.yours { padding: 16px; margin: 0 0 8px; background: #1e5e40; border: 1px solid #a9cba9; border-radius: 14px; }
.tournament-table > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; align-items: baseline; }
.tournament-table strong { font-size: 14px; }
.tournament-table span { font-size: 12px; white-space: nowrap; }
.tournament-table .table-state { font-size: 11px; color: #c9edd3; }
.tournament-table .table-state.done { color: #ffe29b; }
.tournament-table .table-viewer-count { color: #c5d8c6; font-size: 12px; }
.tournament-table p { font-size: 13px; line-height: 1.7; margin-top: 5px; overflow-wrap: anywhere; }
.tournament-winner { color: var(--good); font-weight: 600; }
.tournament-spectate { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; margin-top: 12px; padding: 12px 16px; background: var(--cream); color: var(--on-gold); border: 1px solid var(--cream); border-radius: 12px; font-weight: 700; box-shadow: 0 3px 8px rgba(0,0,0,.15); cursor: pointer; }
.tournament-spectate svg { width: 20px; height: 20px; flex: none; }
.tournament-spectate:hover { filter: brightness(1.05); }
.tournament-spectate:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }
.tournament-spectate:disabled { opacity: .55; cursor: wait; }
.tournament-entrants { list-style: none; padding: 0; margin: 0; }
.tournament-entrants-disclosure { margin-top: 18px; }
.tournament-entrants-disclosure > summary { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer; list-style: none; }
.tournament-entrants-disclosure > summary::-webkit-details-marker { display: none; }
.tournament-entrants-disclosure > summary h3 { flex: 1; margin: 0; }
.tournament-entrants-disclosure > summary h3 span { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 8px; background: #1d6443; color: var(--cream); font-weight: 700; }
.tournament-entrants-disclosure > summary svg { width: 18px; height: 18px; flex: none; }
.tournament-entrants-disclosure[open] > summary svg { transform: rotate(90deg); }
.tournament-entrants-disclosure > summary:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }
.tournament-settings { margin-top: 24px; padding-bottom: 8px; color: #c4d8c8; }
.tournament-settings summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; list-style: none; cursor: pointer; font-size: 13px; }
.tournament-settings summary::-webkit-details-marker { display: none; }
.tournament-settings summary svg { width: 16px; height: 16px; }
.tournament-settings[open] summary svg { transform: rotate(90deg); }
.tournament-settings p { margin: 8px 0 12px; font-size: 13px; line-height: 1.6; }
.tournament-settings .chip { background: transparent; color: var(--cream); border: 1px solid var(--line); border-radius: 10px; font-size: 13px; white-space: normal; cursor: pointer; }
.tournament-settings summary:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }
.tournament-progress { padding-top: 24px; }
.tournament-progress > div { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.tournament-progress strong { font-size: 16px; }
.tournament-progress span { font-size: 12px; color: #cee2d0; }
.tournament-progress progress { display: block; width: 100%; height: 6px; margin-top: 12px; border: 0; border-radius: 6px; overflow: hidden; background: #123d2b; accent-color: #e8cc82; }
.tournament-progress progress::-webkit-progress-bar { background: #123d2b; }
.tournament-progress progress::-webkit-progress-value { background: #e8cc82; }
.tournament-progress progress::-moz-progress-bar { background: #e8cc82; }
.tournament-entrant { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--line); }
.tournament-entrant.me { background: var(--panel-2); }
.tournament-entrant .ava { width: 36px; height: 36px; flex: none; font-size: 15px; }
.tournament-entrant-name { flex: 1; min-width: 0; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.tournament-entrants-empty { padding: 12px 0; font-size: 14px; line-height: 1.6; color: var(--cream); }
.leader-player { min-width: 0; flex: 0 1 auto; }
.tournament-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 16px; margin-bottom: 20px; border-radius: 20px; background: linear-gradient(110deg, #062b21, #1c6245); color: #fff2cd; }
.tournament-banner-info { min-width: 0; }
.tournament-banner h2 { color: inherit; font-size: 23px; line-height: 1.3; margin: 8px 0; }
.tournament-banner .tournament-schedule { color: inherit; font-size: 12px; line-height: 1.5; margin: 0; }
.tournament-banner-time { flex: none; display: flex; align-items: flex-end; flex-direction: column; gap: 4px; text-align: right; }
.tournament-banner-time > span { font-size: 11px; line-height: 1.5; }
.tournament-banner-time strong { font-size: 25px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tournament-banner h2, .tournament-banner-time strong { color: #ffe29b; }
.tournament-daily-offer .leave-actions { flex-wrap: wrap; }
.tournament-daily-offer .leave-actions button { flex: 1 1 120px; }
.leader-player { min-width: 0; flex: 1; }
.leader-player .sb-name { display: block; }
.tournament-entrant.champion-row, .sb-row.champion-row { background: linear-gradient(90deg, rgba(6,43,33,.25), rgba(6,43,33,.15)), #062b21 url('/assets/champion-row-v2.png') center / 100% 100%; color: #fff2cd; }
.champion-label { display: block; margin-top: 3px; font-size: 10px; font-weight: 800; line-height: 1.5; color: #ffe29b; }
.champion-row-stars { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 3px; margin-left: auto; max-width: 96px; flex-shrink: 0; color: #ffe29b; }
.champion-row-stars svg { width: 14px; height: 14px; flex: none; }
.tournament-entrant.champion-row { padding-right: 50px; }
.sb-row.champion-row { padding-right: 50px; }
.sb-row.champion-row .sb-score { width: auto; min-width: 28px; font-variant-numeric: tabular-nums; }
.sb-row.champion-row .champion-row-stars { max-width: 48px; }
.sb-row.champion-row .sb-rank, .sb-row.champion-row .sb-score, .champion-row .you-tag { color: #ffe29b; }
.champions-description { margin: 8px 0 16px; color: var(--cream); font-size: 13px; line-height: 1.6; }
.tournament-views { display: flex; gap: 8px; margin-bottom: 22px; }
.tournament-views button { flex: 1; min-height: 44px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--cream); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.tournament-views button[aria-pressed="true"] { background: var(--cream); border-color: var(--cream); color: #084c34; }
.tournament-views button:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }
.tournament-champions.tournament-stage { margin-top: 0; padding-top: 0; border-top: 0; }
.champions-list { display: grid; gap: 16px; list-style: none; padding: 0; margin: 0; }
.champion-profile { position: relative; display: flex; flex-direction: column; align-items: center; padding: 64px 28px 24px; min-height: 260px; border-radius: 16px; overflow: hidden; background: #062b21 url('/assets/champion-background.png') center / cover; color: #fff2cd; text-align: center; }
.champion-rank { position: absolute; top: 16px; left: 16px; padding: 3px 7px; border-radius: 6px; background: #062b21; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.champion-title { font: 800 15px/1.5 "Noto Serif", serif; color: #ffe29b; margin-bottom: 8px; }
.champion-profile .ava { width: 64px; height: 64px; flex: none; font-size: 26px; border: 2px solid #f2c14e; }
.champion-name { max-width: 100%; overflow-wrap: anywhere; font-size: 19px; line-height: 1.4; margin: 10px 0 6px; }
.champion-stars { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; color: #ffd363; }
.champion-stars svg { width: 19px; height: 19px; flex: none; }
.champion-wins { font-size: 13px; line-height: 1.6; margin-top: 6px; }
.tournament-notify-offer { position: absolute; z-index: 100; left: 16px; right: 16px; bottom: 24px; padding: 18px; border-radius: 16px; background: #122332; color: #e3ecf8; border: 1px solid #496078; box-shadow: 0 12px 36px rgba(0, 0, 0, .4); }
.tournament-notify-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.tournament-notify-heading svg { width: 30px; height: 30px; flex: none; color: #8bbdff; }
.tournament-notify-heading h3 { font-size: 18px; line-height: 1.4; color: #fff; }
.tournament-notify-offer p { font-size: 14px; line-height: 1.65; }
.tournament-notify-actions { display: flex; gap: 10px; margin-top: 16px; }
.tournament-notify-actions button { flex: 1; min-height: 46px; padding: 10px; border: 1px solid #496078; border-radius: 12px; background: #21394e; color: #e3ecf8; font-size: 15px; font-weight: 700; cursor: pointer; }
#tournamentNotifyEnable { background: #2c67bb; color: #fff; border-color: #2c67bb; }
.tournament-notify-actions button:disabled { opacity: .6; cursor: wait; }
@media (hover: hover) { #tournamentNotifyEnable:hover { background: #24579f; } #tournamentNotifyLater:hover { background: #2b4861; } }
.tournament-screen ::selection { color: var(--on-gold); background: var(--cream); }
@media (hover: hover) {
  .tournament-actions .chip:hover, .tournament-head .chip:hover { background: var(--panel-2); }
}

/* Нүүрийн товчнуудын icon болон бичиг ижил баганад. */
#choice .tile { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; padding: 14px 32px; text-align: left; }
#choice #chOnline { font-size: 18px; font-weight: 800; }
#choice .tile .tile-ic { width: 40px; height: 40px; background: none; border: 0; box-shadow: none; }
#choice .tile-ic img { display: block; width: 100%; height: 100%; object-fit: contain; }
