/* ============================================================================
   TỨ SẮC · style
   Hướng mỹ thuật: giấy dó – lụa Huế – mực tàu – son triện.
   Bốn màu bài: trắng, vàng, đỏ, xanh. Không dùng tông đỏ–vàng Tết.
   ========================================================================== */
:root {
  --paper-0: #fbf6ea;
  --paper-1: #f5ecd9;
  --paper-2: #ecdfc6;
  --paper-3: #e1d0b1;
  --cream: #fffaef;
  --ink: #23312c;
  --ink-2: #4d5c54;
  --ink-3: #7d887f;
  --pine: #1f4a3d;
  --pine-2: #16382e;
  --pine-3: #0f2820;
  --jade: #3f7f69;
  --jade-2: #2f6754;
  --jade-soft: #dbe7dd;
  --gold: #bf964b;
  --gold-2: #9b7531;
  --gold-soft: #ecd9ad;
  --verm: #b23a2b;
  --verm-2: #8f2a1e;
  --plum: #79445a;
  --line: rgba(35, 49, 44, .14);
  --line-2: rgba(35, 49, 44, .24);
  --shadow-1: 0 1px 2px rgba(52, 36, 12, .10), 0 6px 16px rgba(52, 36, 12, .10);
  --shadow-2: 0 2px 4px rgba(52, 36, 12, .12), 0 16px 40px rgba(52, 36, 12, .18);
  --serif: 'Lora', Georgia, 'Times New Roman', serif;
  --sans: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --han: 'Songti SC', 'STSong', 'Noto Serif CJK SC', 'Source Han Serif SC', 'SimSun', serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --cw: 50px;
  --ch: 78px;
  --mw: 30px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: #12241e;
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(191, 150, 75, .16), transparent 60%),
    linear-gradient(160deg, #1b3a30, #122720 60%, #0d1e19);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid var(--verm); outline-offset: 3px; border-radius: 8px; }
svg { display: block; }
[hidden] { display: none !important; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }

/* ---------- khung ứng dụng ---------- */
#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 46% at 50% 0%, rgba(255, 249, 231, .9), transparent 70%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(63, 127, 105, .16), transparent 70%),
    linear-gradient(168deg, #fbf6ea 0%, #f4ead6 48%, #eadcc2 100%);
  box-shadow: 0 0 0 1px rgba(191, 150, 75, .28);
}
#app::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .55;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='46' height='46' viewBox='0 0 46 46'%3E%3Cg fill='none' stroke='%2323312c' stroke-opacity='.035' stroke-width='1'%3E%3Cpath d='M23 0v46M0 23h46'/%3E%3Ccircle cx='23' cy='23' r='9'/%3E%3Cpath d='M0 0l46 46M46 0L0 46'/%3E%3C/g%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
#app::after {
  content: '';
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(191, 150, 75, .28);
  border-radius: 18px;
  pointer-events: none;
  z-index: 0;
}
@media (min-width: 560px) {
  #app { box-shadow: 0 0 0 1px rgba(191,150,75,.3), 0 30px 90px rgba(0,0,0,.55); }
}
.screen {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: calc(10px + var(--safe-t)) 14px calc(10px + var(--safe-b));
  overflow: hidden;
}

/* ---------- nút & viên thuốc ---------- */
.round-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--pine);
  background: rgba(255, 250, 238, .72);
  border: 1px solid rgba(191, 150, 75, .42);
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 2px 6px rgba(60,40,10,.10);
}
.round-btn:active { transform: scale(.94); }
.round-btn .ico { width: 21px; height: 21px; }
.coin-pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 34px; padding: 0 12px 0 5px;
  border-radius: 999px;
  background: rgba(255, 250, 238, .78);
  border: 1px solid rgba(191, 150, 75, .46);
  box-shadow: 0 1px 0 rgba(255,255,255,.85) inset, 0 2px 6px rgba(60,40,10,.08);
  color: var(--ink);
  font-weight: 800; font-size: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}
.coin-pill svg { width: 25px; height: 25px; flex: none; }
.coin-pill.bump { animation: bump .4s ease; }
@keyframes bump { 50% { transform: scale(1.07); } }

.level-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 13px 0 5px;
  border-radius: 999px;
  background: rgba(255, 250, 238, .7);
  border: 1px solid rgba(191, 150, 75, .4);
  font-size: 12px; font-weight: 700; color: var(--ink-2);
}
.level-chip b { color: var(--ink); font-size: 14px; }
.level-orb {
  position: relative; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--pine); color: var(--gold-soft);
  font-family: var(--serif); font-weight: 700; font-size: 13px; letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px rgba(236,217,173,.35);
}

/* ---------- TRANG CHỦ ---------- */
.home { padding-top: calc(8px + var(--safe-t)); }
.home::before {
  content: '';
  position: absolute; left: 50%; top: -18%;
  width: 130%; aspect-ratio: 1;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(191,150,75,.20), transparent 58%);
  pointer-events: none;
}
.home-top { display: flex; align-items: center; gap: 8px; position: relative; z-index: 4; }
.home-top .spacer { flex: 1; }
.home-hero { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 2; min-height: 0; }
.home-vine {
  position: absolute; color: var(--jade); opacity: .22;
  pointer-events: none;
}
.home-vine.v1 { width: 84px; height: 260px; left: -8px; bottom: 0; transform: rotate(6deg); }
.home-vine.v2 { width: 70px; height: 220px; right: -10px; bottom: 10px; transform: scaleX(-1) rotate(10deg); }
.hero-sun {
  position: absolute; left: 50%; top: 4%;
  width: min(78vw, 320px); aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 46%, rgba(255,248,227,.95) 0 34%, rgba(236,217,173,.55) 35% 55%, rgba(236,217,173,0) 72%);
  pointer-events: none;
}
.hero-sun::after {
  content: '';
  position: absolute; inset: 12%;
  border-radius: 50%;
  border: 1px solid rgba(191,150,75,.28);
  box-shadow: 0 0 0 10px rgba(191,150,75,.06), 0 0 0 22px rgba(191,150,75,.035);
}
.brand-block { position: relative; text-align: center; z-index: 3; margin-top: 2px; }
.seal-logo {
  width: 54px; height: 54px; margin: 0 auto 6px;
  position: relative;
  background: linear-gradient(155deg, #c14a38, #9c2f22);
  border-radius: 7px;
  box-shadow: 0 3px 8px rgba(120,30,18,.32), inset 0 0 0 1px rgba(255,235,200,.35);
  transform: rotate(-3deg);
  display: grid; place-items: center;
}
.seal-logo::before {
  content: ''; position: absolute; inset: 4px;
  border: 1px solid rgba(255, 235, 200, .55);
  border-radius: 4px;
}
.seal-logo span {
  font-family: var(--serif); color: #ffefd0; font-size: 13px; line-height: 1.04;
  letter-spacing: .02em; text-align: center; text-shadow: 0 1px 0 rgba(80,20,10,.4);
}
.logo {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(44px, 13.4vw, 66px);
  line-height: .98;
  letter-spacing: .06em;
  color: var(--pine);
  text-shadow: 0 1px 0 rgba(255,255,255,.7), 0 4px 16px rgba(31,74,61,.14);
}
.logo em { font-style: normal; color: var(--verm); }
.logo-sub {
  margin: 4px 0 0;
  font-size: 10px; font-weight: 800; letter-spacing: .46em;
  color: var(--gold-2);
  text-indent: .46em;
}
.hero-line {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-2);
  letter-spacing: .01em;
}
.fan {
  position: relative;
  width: 100%;
  height: clamp(150px, 27vh, 230px);
  margin-top: 6px;
  z-index: 2;
}
.fan .card { position: absolute; left: 50%; top: 50%; transform-origin: 50% 92%; }
.hero-card {
  width: clamp(62px, 17vw, 86px);
  height: calc(clamp(62px, 17vw, 86px) * 1.56);
  border-radius: 9px;
  box-shadow: 0 3px 2px rgba(70,45,15,.12), 0 18px 30px rgba(60,40,10,.22), inset 0 0 0 1px rgba(255,255,255,.65);
  transition: transform .5s cubic-bezier(.2, .9, .3, 1.1);
}
.fan .hero-card:nth-child(1) { transform: translate(-50%, -50%) translate(-84px, 18px) rotate(-19deg); }
.fan .hero-card:nth-child(2) { transform: translate(-50%, -50%) translate(-30px, -2px) rotate(-7deg); }
.fan .hero-card:nth-child(3) { transform: translate(-50%, -50%) translate(26px, -2px) rotate(7deg); }
.fan .hero-card:nth-child(4) { transform: translate(-50%, -50%) translate(80px, 18px) rotate(19deg); }
.fan .hero-card:nth-child(1) { z-index: 1; } .fan .hero-card:nth-child(2) { z-index: 2; }
.fan .hero-card:nth-child(3) { z-index: 3; } .fan .hero-card:nth-child(4) { z-index: 4; }
.hero-cta { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 2px; z-index: 5; }
.btn-play {
  position: relative;
  min-width: 210px;
  height: 54px;
  padding: 0 34px;
  border-radius: 15px;
  color: #fff6df;
  background: linear-gradient(180deg, #c24936, #a23325 55%, #8c281c);
  box-shadow:
    0 1px 0 rgba(255, 220, 180, .35) inset,
    0 0 0 1px rgba(120, 30, 18, .35),
    0 8px 18px rgba(120, 30, 18, .26);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .14em;
  text-indent: .14em;
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-play::before {
  content: ''; position: absolute; inset: 4px;
  border: 1px solid rgba(255, 236, 200, .42);
  border-radius: 11px; pointer-events: none;
}
.btn-play:active { transform: translateY(1px) scale(.985); box-shadow: 0 1px 0 rgba(255,220,180,.3) inset, 0 3px 8px rgba(120,30,18,.25); }
.btn-text {
  min-height: 34px; padding: 0 12px;
  font-size: 12px; font-weight: 700; color: var(--pine);
  border-bottom: 1px solid rgba(31,74,61,.35);
}
.btn-text:active { opacity: .65; }
.home-dock {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px; margin-top: 10px; z-index: 4;
}
.dock-item {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 4px 9px;
  border-radius: 14px;
  background: rgba(255, 250, 238, .62);
  border: 1px solid rgba(191, 150, 75, .3);
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset;
  color: var(--pine);
  font-size: 10.5px; font-weight: 700;
  transition: transform .15s ease, background .15s ease;
}
.dock-item .ico { width: 24px; height: 24px; }
.dock-item:active { transform: scale(.96); background: rgba(255,250,238,.9); }
.dock-item .dot {
  position: absolute; top: 7px; right: 12px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--verm);
  box-shadow: 0 0 0 2px var(--paper-1);
  display: none;
}
.dock-item .dot.on { display: block; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { transform: scale(1.35); } }
.home-foot { margin-top: 10px; z-index: 4; }
.xp-line { display: flex; align-items: center; gap: 7px; font-size: 9.5px; font-weight: 700; color: var(--ink-3); }
.xp-bar { flex: 1; height: 5px; border-radius: 99px; background: rgba(35,49,44,.11); overflow: hidden; }
.xp-bar i { display: block; height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, var(--jade), var(--gold)); transition: width .6s ease; }
.disclaimer { margin: 8px 0 0; text-align: center; font-size: 8.5px; line-height: 1.5; color: var(--ink-3); }

/* ---------- BÀN CHƠI ---------- */
.game { padding: calc(6px + var(--safe-t)) 10px calc(8px + var(--safe-b)); gap: 6px; }
.game-top { display: flex; align-items: center; gap: 8px; flex: none; }
.game-top .grow { flex: 1; }
.round-chip {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 5px 13px; border-radius: 999px;
  background: rgba(255, 250, 238, .66);
  border: 1px solid rgba(191,150,75,.34);
  font-size: 9px; font-weight: 800; letter-spacing: .18em; color: var(--gold-2);
}
.round-chip b { font-family: var(--serif); font-size: 15px; letter-spacing: 0; color: var(--pine); }

.table {
  position: relative; flex: 1 1 auto; min-height: 0;
  border-radius: 22px;
  background:
    radial-gradient(ellipse 60% 52% at 50% 46%, rgba(255, 252, 242, .9), rgba(246, 238, 219, .55) 60%, rgba(236, 223, 198, .2) 100%);
  border: 1px solid rgba(191, 150, 75, .34);
  box-shadow: inset 0 0 0 5px rgba(255, 252, 243, .35), inset 0 0 40px rgba(63, 127, 105, .06), 0 8px 20px rgba(60,40,10,.07);
  overflow: hidden;
}
.table::before {
  content: ''; position: absolute; inset: 6px; border-radius: 17px;
  border: 1px solid rgba(191,150,75,.2); pointer-events: none;
}
.table::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cg fill='none' stroke='%233f7f69' stroke-opacity='.055' stroke-width='.9'%3E%3Cpath d='M14 0 28 14 14 28 0 14Z'/%3E%3Ccircle cx='14' cy='14' r='3'/%3E%3C/g%3E%3C/svg%3E");
}
.mat-ring {
  position: absolute; left: 50%; top: 49%;
  width: min(66%, 260px); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(191,150,75,.28);
  box-shadow: 0 0 0 8px rgba(191,150,75,.045), inset 0 0 0 1px rgba(255,252,243,.5);
  pointer-events: none;
}
.mat-crest {
  position: absolute; left: 50%; top: 49%;
  transform: translate(-50%, -50%);
  font-family: var(--serif); font-size: 72px; line-height: 1; letter-spacing: .06em;
  color: var(--jade); opacity: .055; pointer-events: none;
}

/* ghế người chơi */
.seat { position: absolute; display: flex; align-items: center; gap: 7px; z-index: 3; }
.seat-top { top: 7px; left: 50%; transform: translateX(-50%); flex-direction: column; gap: 3px; width: 100%; }
.seat-left { left: 4px; top: 47%; transform: translateY(-50%); flex-direction: column; gap: 3px; width: 86px; }
.seat-right { right: 4px; top: 47%; transform: translateY(-50%); flex-direction: column; gap: 3px; width: 86px; }
.seat-id { display: flex; align-items: center; gap: 6px; }
.seat-top .seat-id { flex-direction: column; gap: 2px; }
.seat-right .seat-id { flex-direction: row-reverse; }
.avatar-wrap { position: relative; width: 38px; height: 38px; flex: none; }
.seat-top .avatar-wrap { width: 42px; height: 42px; }
.avatar-wrap .av {
  width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
  background: var(--paper-2);
  box-shadow: 0 0 0 2px rgba(255,250,238,.9), 0 0 0 3.5px rgba(191,150,75,.5), 0 3px 7px rgba(60,40,10,.15);
}
.avatar-wrap .av svg { width: 100%; height: 100%; }
.avatar-wrap.turn .av { box-shadow: 0 0 0 2px rgba(255,250,238,.95), 0 0 0 4px var(--verm), 0 0 14px rgba(178,58,43,.4); }
.avatar-wrap .crown {
  position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%);
  width: 22px; height: 16px; border-radius: 8px;
  display: none; align-items: center; justify-content: center;
  background: var(--gold); color: #fff7e0;
  box-shadow: 0 1px 3px rgba(80,50,10,.3);
}
.avatar-wrap .crown svg { width: 12px; height: 12px; }
.avatar-wrap.dealer .crown { display: flex; }
.avatar-wrap .turn-pip {
  position: absolute; right: -1px; top: -1px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--verm); box-shadow: 0 0 0 2px var(--paper-0);
  display: none;
}
.avatar-wrap.turn .turn-pip { display: block; animation: pulse 1.2s infinite; }
.seat-name { font-size: 11px; font-weight: 800; color: var(--ink); line-height: 1.15; white-space: nowrap; }
.seat-name small { display: block; font-size: 8px; font-weight: 600; color: var(--ink-3); letter-spacing: .02em; }
.seat-left .seat-name, .seat-right .seat-name { font-size: 10px; }
.seat-melds { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; max-width: 100%; }
.seat-left .seat-melds, .seat-right .seat-melds { flex-direction: column; align-items: center; }
.seat-top .seat-melds { max-width: 300px; }
.meld-group { display: flex; align-items: center; }
.meld-group + .meld-group { margin-left: 2px; }
.meld-group .mini + .mini { margin-left: calc(var(--mw) * -.34); }

/* lá bài nhỏ */
.mini {
  position: relative; width: var(--mw); height: calc(var(--mw) * 1.52);
  border-radius: 3px;
  background: linear-gradient(155deg, #fffdf6, #f5ead4);
  box-shadow: 0 1px 2px rgba(60,40,10,.18), inset 0 0 0 1px rgba(255,255,255,.65);
  overflow: hidden;
  flex: none;
}
.mini .m-band { position: absolute; left: 0; top: 0; bottom: 0; width: 2.5px; background: var(--ink-c); }
.mini .m-code {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-start;
  padding-left: calc(var(--mw) * .10);
  font-family: var(--sans); font-weight: 800; font-size: calc(var(--mw) * .32); line-height: 1;
  letter-spacing: -.03em; color: var(--ink-c); opacity: .95; white-space: nowrap;
}
.mini .m-val {
  position: absolute; right: 1px; bottom: 0; font-size: 6px; font-weight: 800;
  color: var(--verm); background: rgba(255,250,238,.75); border-radius: 2px; padding: 0 1px;
}

/* trung tâm */
.center-piles {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 13px; z-index: 2;
}
.pile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.pile > small { margin-top: 4px; font-size: 7.5px; font-weight: 800; letter-spacing: .18em; color: var(--ink-3); text-transform: uppercase; }
.noc-stack { position: relative; width: 34px; height: 50px; }
.noc-stack .card { position: absolute; width: 32px; height: 48px; border-radius: 4px; }
.noc-stack .card:nth-child(2) { transform: translate(2px, -2px); }
.noc-stack .card:nth-child(3) { transform: translate(4px, -4px); }
.noc-count {
  position: absolute; top: -7px; right: -9px; bottom: auto; z-index: 2; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; display: grid; place-items: center;
  background: var(--pine); color: var(--gold-soft);
  font-size: 9.5px; font-weight: 800;
  box-shadow: 0 2px 5px rgba(20,40,30,.25);
}
.active-slot {
  position: relative;
  width: calc(var(--cw) * 1.1); height: calc(var(--ch) * 1.1);
  display: grid; place-items: center;
}
.active-slot .card {
  position: relative;
  width: calc(var(--cw) * 1.1); height: calc(var(--ch) * 1.1);
  animation: floaty 3.4s ease-in-out infinite;
  box-shadow: 0 4px 4px rgba(70,45,15,.12), 0 18px 26px rgba(60,40,10,.2), 0 0 0 1px rgba(191,150,75,.55), inset 0 0 0 1px rgba(255,255,255,.65);
}
@keyframes floaty { 50% { transform: translateY(-3px); } }
.active-empty {
  width: calc(var(--cw) * 1.1); height: calc(var(--ch) * 1.1);
  border-radius: 7px; border: 1.5px dashed rgba(35,49,44,.22);
  display: grid; place-items: center;
  font-size: 8px; font-weight: 700; color: var(--ink-3); text-align: center; line-height: 1.35;
  background: rgba(255,250,238,.35);
}
.active-tag {
  position: absolute; top: -17px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 7.5px; font-weight: 800; letter-spacing: .16em;
  color: var(--gold-2); text-transform: uppercase;
}
.dead-stack { position: relative; width: 22px; height: 32px; opacity: .6; }
.dead-stack .mini { position: absolute; width: 20px; height: 30px; }
.dead-stack .mini:nth-child(2) { transform: translate(1px,-1px); }
.dead-stack .mini:nth-child(3) { transform: translate(2px,-2px); }

.turn-banner {
  position: absolute; left: 50%; bottom: 7px; transform: translateX(-50%);
  padding: 4px 12px; border-radius: 999px;
  background: rgba(31, 74, 61, .9); color: var(--gold-soft);
  font-size: 9.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  box-shadow: 0 3px 10px rgba(20,40,30,.22);
  white-space: nowrap;
  opacity: 0; transition: opacity .25s ease;
}
.turn-banner.on { opacity: 1; }

/* khu của bạn */
.self-panel { flex: none; display: flex; flex-direction: column; gap: 5px; z-index: 5; }
.self-row { display: flex; align-items: center; gap: 8px; }
.self-id { display: flex; align-items: center; gap: 6px; min-width: 0; }
.self-avatar { width: 30px; height: 30px; border-radius: 50%; overflow: hidden; flex: none; background: var(--paper-2); box-shadow: 0 0 0 2px rgba(255,250,238,.9), 0 0 0 3px rgba(191,150,75,.45); }
.self-avatar svg { width: 100%; height: 100%; }
.self-id b { display: block; font-size: 12px; font-weight: 800; line-height: 1.1; }
.self-id small { display: block; font-size: 8px; color: var(--ink-3); font-weight: 600; }
.self-metrics { margin-left: auto; display: flex; gap: 6px; }
.metric {
  min-width: 42px; padding: 3px 9px; border-radius: 10px;
  background: rgba(255,250,238,.6); border: 1px solid rgba(191,150,75,.26);
  text-align: center;
}
.metric b { display: block; font-size: 14px; font-weight: 800; line-height: 1.05; color: var(--pine); font-variant-numeric: tabular-nums; }
.metric span { display: block; font-size: 7px; font-weight: 700; letter-spacing: .12em; color: var(--ink-3); text-transform: uppercase; }
.metric.hot b { color: var(--verm); }
.hint-btn {
  height: 30px; padding: 0 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,250,238,.7); border: 1px solid rgba(191,150,75,.32);
  font-size: 9.5px; font-weight: 800; color: var(--ink-2);
}
.hint-btn .ico { width: 14px; height: 14px; }
.hint-btn:active { transform: scale(.96); }

.my-melds { display: flex; gap: 5px; overflow-x: auto; min-height: 0; padding: 1px 1px 2px; scrollbar-width: none; }
.my-melds::-webkit-scrollbar { display: none; }
.my-melds:empty { display: none; }
.my-melds .meld-group { flex: none; padding: 2px 3px; border-radius: 7px; background: rgba(255,250,238,.42); border: 1px solid rgba(191,150,75,.16); }
.my-melds .mini { --mw: 27px; }
.my-melds .mini .m-code { font-size: 9px; }
.my-melds .m-val { font-size: 6.5px; }

.hand-area { position: relative; flex: none; }
.hand { position: relative; width: 100%; touch-action: manipulation; }
.hand .card { position: absolute; transition: left .28s cubic-bezier(.2,.9,.3,1), top .28s cubic-bezier(.2,.9,.3,1), transform .16s ease, box-shadow .16s ease; }
.hand .card.sel { transform: translateY(-11px); box-shadow: 0 2px 2px rgba(70,45,15,.12), 0 12px 20px rgba(60,40,10,.24), 0 0 0 2px var(--gold); }
.hand .card.hint { box-shadow: 0 0 0 2px var(--verm), 0 6px 14px rgba(120,40,30,.22); }
.hand .card.tap { animation: cardTap .3s ease; }
@keyframes cardTap { 40% { transform: translateY(-5px) scale(1.02); } }
.hand-hint {
  display: none;
  position: absolute; left: 50%; bottom: -1px; transform: translateX(-50%);
  font-size: 8.5px; font-weight: 700; color: var(--ink-3);
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .2s;
}
.hand-hint.on { opacity: 1; }
.trash-divider {
  position: absolute; width: 1px; top: 2px; bottom: 2px;
  border-left: 1px dashed rgba(178,58,43,.4);
}

/* lá bài */
.card {
  position: absolute;
  width: var(--cw); height: var(--ch);
  border-radius: calc(var(--cw) * .095);
  background:
    linear-gradient(160deg, #fffdf7 0%, #fbf3e1 46%, #f4e8d1 78%, #efe1c5 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.7),
    inset 0 0 0 2px rgba(191,150,75,.16),
    0 1px 1px rgba(70,45,15,.12),
    0 3px 6px rgba(60,40,10,.13);
  overflow: hidden;
  -webkit-user-drag: none;
}
.card::before {
  content: ''; position: absolute; inset: 13% 8% 12%;
  border-radius: 50%;
  border: 1px solid var(--ink-c);
  opacity: .13;
  pointer-events: none;
}
.card .c-band {
  position: absolute; left: 0; top: 0; right: 0; height: 2.5px;
  background: var(--ink-c); opacity: .9;
}
.card .c-han-mini {
  position: absolute; left: 4px; top: 3px;
  font-family: var(--han); font-size: calc(var(--cw) * .18); line-height: 1;
  color: var(--ink-c); opacity: .9; pointer-events: none;
}
.card .c-rank {
  position: absolute; left: 4px; top: calc(var(--cw) * .25); right: 3px;
  font-size: calc(var(--cw) * .14);
  font-weight: 800; letter-spacing: 0; line-height: 1.05;
  color: var(--ink-c);
  text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: clip;
}
.card .c-name {
  position: absolute; left: 3px; right: 3px; top: 28%; bottom: 20%;
  display: flex; align-items: center; justify-content: flex-start;
  padding-left: calc(var(--cw) * .06);
  font-family: var(--sans); font-weight: 800;
  font-size: calc(var(--cw) * .20); line-height: 1;
  color: var(--ink-c); text-align: left; letter-spacing: -.01em;
  white-space: nowrap; pointer-events: none;
}
.hero-card .c-han-mini { display: block; font-size: calc(var(--cw) * .13); }
.hero-card .c-rank { display: none; }
.hero-card .c-name, .card.plain .c-name {
  justify-content: center; padding-left: 0; text-align: center;
}
.hand .card .c-name { font-size: calc(var(--cw) * .16); }
.card .c-color {
  position: absolute; left: 4px; bottom: 3px;
  font-size: calc(var(--cw) * .12);
  font-weight: 700; letter-spacing: .06em;
  color: var(--ink-c); opacity: .82;
  text-transform: uppercase;
}
.card .c-dot {
  position: absolute; right: 4px; bottom: 4px;
  width: calc(var(--cw) * .1); height: calc(var(--cw) * .1);
  border-radius: 50%; background: var(--ink-c); opacity: .55;
}
.card.trash .c-rank { color: var(--verm); }
.card.trash .c-name { color: var(--verm); }
.card.trash .c-band { background: var(--verm); }
.card.trash::after {
  content: ''; position: absolute; right: 0; top: 0;
  border-top: 7px solid var(--verm); border-left: 7px solid transparent;
  opacity: .75;
}
.card.back {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cg fill='none' stroke='%23e6c47a' stroke-opacity='.26' stroke-width='.8'%3E%3Cpath d='M14 0 28 14 14 28 0 14Z'/%3E%3Ccircle cx='14' cy='14' r='2.6'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(155deg, #235345, #173c31 60%, #102b23);
  box-shadow:
    inset 0 0 0 1px rgba(230,196,122,.35),
    inset 0 0 0 3px rgba(16,43,35,.6),
    0 1px 2px rgba(20,40,30,.25),
    0 4px 9px rgba(20,40,30,.24);
}
.card.back::before {
  inset: 9%;
  border-radius: 4px;
  border: 1px solid rgba(230,196,122,.4);
  opacity: 1;
}
.card.back .back-seal {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-2deg);
  width: 48%; height: 42%;
  display: grid; place-items: center;
  border: 1px solid rgba(230,196,122,.5);
  border-radius: 2px;
  color: #e6c47a;
  font-family: var(--serif);
  font-size: calc(var(--cw) * .17);
  line-height: 1.02;
  letter-spacing: .02em;
  text-align: center;
}
.card.back .back-seal::before {
  content: ''; position: absolute; inset: 2px; border: 1px solid rgba(230,196,122,.22);
}

/* thanh hành động */
.actions { display: flex; gap: 8px; align-items: stretch; min-height: 50px; }
.actions .btn {
  flex: 1; height: 50px; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 13px; font-weight: 800; letter-spacing: .06em;
  transition: transform .14s ease, opacity .14s ease, box-shadow .14s ease;
}
.actions .btn small { font-size: 8px; font-weight: 600; letter-spacing: .04em; opacity: .72; }
.actions .btn:active { transform: scale(.975); }
.actions .btn-main {
  color: #fff8e8;
  background: linear-gradient(180deg, #276152, #1f4a3d 60%, #17382e);
  box-shadow: 0 1px 0 rgba(255,240,205,.22) inset, 0 5px 12px rgba(20,55,44,.22);
}
.actions .btn-seal {
  color: #fff8e8;
  background: linear-gradient(180deg, #c24936, #a23325 60%, #8b281c);
  box-shadow: 0 1px 0 rgba(255,220,190,.28) inset, 0 5px 12px rgba(120,35,22,.24);
}
.actions .btn-ghost {
  color: var(--pine);
  background: rgba(255,250,238,.72);
  border: 1px solid rgba(35,49,44,.18);
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset;
}
.actions .btn[disabled] { opacity: .38; box-shadow: none; transform: none; }
.actions .btn .k {
  display: inline-grid; place-items: center;
  width: 17px; height: 17px; border-radius: 5px;
  background: rgba(255,255,255,.18); font-size: 9px; font-weight: 800;
}
.actions .waiting {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 50px; border-radius: 14px;
  background: rgba(255,250,238,.5); border: 1px dashed rgba(35,49,44,.18);
  font-size: 11px; font-weight: 700; color: var(--ink-3);
}
.dots i { display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: currentColor; margin: 0 1px; animation: dotb 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dotb { 0%,60%,100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

/* ---------- MODAL ---------- */
.modal {
  position: fixed; inset: 0; z-index: 120;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 12px;
  background: rgba(15, 30, 25, .5);
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease;
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal.sheet { align-items: flex-end; }
.modal.center { align-items: center; }
.panel {
  position: relative;
  width: 100%; max-width: 430px;
  max-height: min(86vh, 780px);
  display: flex; flex-direction: column;
  border-radius: 22px;
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(255,250,238,.9), transparent 70%),
    linear-gradient(170deg, #fbf6ea, #f2e6cf);
  box-shadow: 0 30px 70px rgba(10,25,20,.4), inset 0 0 0 1px rgba(255,255,255,.6);
  transform: translateY(24px) scale(.985);
  opacity: .6;
  transition: transform .26s cubic-bezier(.2,.9,.3,1), opacity .2s ease;
  overflow: hidden;
}
.modal.open .panel { transform: translateY(0) scale(1); opacity: 1; }
.panel::before {
  content: ''; position: absolute; inset: 6px; border-radius: 17px;
  border: 1px solid rgba(191,150,75,.22); pointer-events: none;
}
.panel-head {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 12px;
  flex: none;
}
.panel-head h2 {
  margin: 0; font-family: var(--serif); font-weight: 700; font-size: 22px;
  letter-spacing: .01em; color: var(--pine);
}
.panel-head .sub { font-size: 9px; font-weight: 700; letter-spacing: .22em; color: var(--gold-2); margin-top: 2px; text-transform: uppercase; }
.panel-head .close {
  margin-left: auto; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; color: var(--ink-2);
  background: rgba(255,250,238,.7); border: 1px solid rgba(35,49,44,.12);
}
.panel-head .close .ico { width: 17px; height: 17px; }
.panel-body { overflow-y: auto; padding: 0 18px 18px; -webkit-overflow-scrolling: touch; }
.panel-body::-webkit-scrollbar { width: 0; }
.panel-foot { padding: 0 18px 18px; display: flex; gap: 8px; flex: none; }
.panel-foot .btn { flex: 1; height: 48px; border-radius: 13px; font-weight: 800; font-size: 13px; letter-spacing: .05em; display: grid; place-items: center; }
.panel-foot .btn-main { background: var(--pine); color: #fff6df; }
.panel-foot .btn-ghost { background: rgba(255,250,238,.7); border: 1px solid rgba(35,49,44,.16); color: var(--pine); }

.sheet .panel { border-radius: 24px 24px 20px 20px; }
.grabber { width: 38px; height: 4px; border-radius: 99px; background: rgba(35,49,44,.16); margin: 8px auto 0; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b));
  transform: translate(-50%, 12px); z-index: 140;
  padding: 9px 16px; border-radius: 999px;
  background: rgba(23, 56, 46, .94); color: #fff3d6;
  font-size: 12px; font-weight: 600; letter-spacing: .01em;
  box-shadow: 0 8px 20px rgba(10,30,22,.28);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  max-width: 86%; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: rgba(143, 42, 30, .95); }

/* ---------- NỘI DUNG PHỤ ---------- */
.rule-intro { font-size: 12.5px; line-height: 1.65; color: var(--ink-2); margin: 0 0 12px; }
.rule-h { display: flex; align-items: center; gap: 7px; margin: 16px 0 7px; font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--gold-2); text-transform: uppercase; }
.rule-h::after { content: ''; flex: 1; height: 1px; background: rgba(191,150,75,.28); }
.rule-p { font-size: 12px; line-height: 1.65; color: var(--ink-2); margin: 0 0 8px; }
.rule-p b { color: var(--ink); }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 6px 0 2px; }
.set-card {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 8px; border-radius: 11px;
  background: rgba(255,250,238,.6); border: 1px solid rgba(191,150,75,.2);
}
.set-card .mini { --mw: 22px; }
.set-card .t { font-size: 10px; font-weight: 700; line-height: 1.3; color: var(--ink-2); }
.set-card .t b { display: block; color: var(--ink); font-size: 11px; }
.value-table { width: 100%; border-collapse: collapse; font-size: 11.5px; margin: 4px 0 8px; }
.value-table td { padding: 5px 2px; border-bottom: 1px dashed rgba(35,49,44,.12); color: var(--ink-2); }
.value-table td:last-child { text-align: right; font-weight: 800; color: var(--pine); }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 13px;
  background: rgba(255,250,238,.58); border: 1px solid rgba(191,150,75,.18);
}
.list-row .ico { color: var(--pine); flex: none; }
.list-row .txt { flex: 1; min-width: 0; }
.list-row .txt b { display: block; font-size: 12px; font-weight: 700; color: var(--ink); }
.list-row .txt small { display: block; font-size: 10px; color: var(--ink-3); margin-top: 1px; }
.list-row .chev { color: var(--ink-3); font-size: 16px; }
.switch {
  position: relative; width: 42px; height: 25px; border-radius: 99px;
  background: rgba(35,49,44,.18); transition: background .2s ease; flex: none;
}
.switch::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 19px; height: 19px;
  border-radius: 50%; background: #fffaf0; box-shadow: 0 1px 3px rgba(30,40,30,.25);
  transition: transform .2s cubic-bezier(.2,.9,.3,1.2);
}
.switch.on { background: var(--jade); }
.switch.on::after { transform: translateX(17px); }

/* quà / nhiệm vụ */
.gift-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0 12px; }
.gift-day {
  position: relative; padding: 9px 4px 7px; border-radius: 11px; text-align: center;
  background: rgba(255,250,238,.55); border: 1px solid rgba(191,150,75,.2);
}
.gift-day small { display: block; font-size: 8px; font-weight: 700; letter-spacing: .1em; color: var(--ink-3); text-transform: uppercase; }
.gift-day b { display: block; font-size: 12px; margin: 3px 0 1px; color: var(--pine); }
.gift-day .coin-ic { width: 20px; height: 20px; margin: 2px auto 0; }
.gift-day.done { opacity: .55; }
.gift-day.done::after { content: '✓'; position: absolute; right: 5px; top: 4px; font-size: 10px; color: var(--jade); font-weight: 800; }
.gift-day.today { border-color: var(--gold); background: rgba(236,217,173,.4); }
.gift-day.today::before { content: ''; position: absolute; inset: -1px; border-radius: 11px; border: 1px solid var(--verm); opacity: .4; pointer-events: none; }

.quest { padding: 10px 12px; border-radius: 13px; background: rgba(255,250,238,.55); border: 1px solid rgba(191,150,75,.18); margin-bottom: 8px; }
.quest-top { display: flex; align-items: center; gap: 8px; }
.quest-top b { font-size: 12px; font-weight: 700; flex: 1; }
.quest-top .reward { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 800; color: var(--gold-2); }
.quest-top .reward svg { width: 16px; height: 16px; }
.quest-bar { height: 6px; border-radius: 99px; background: rgba(35,49,44,.1); overflow: hidden; margin-top: 7px; }
.quest-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--jade), var(--gold)); transition: width .4s ease; }
.quest-bottom { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.quest-bottom small { font-size: 9.5px; color: var(--ink-3); flex: 1; }
.mini-btn { height: 27px; padding: 0 11px; border-radius: 99px; background: var(--pine); color: #fff6df; font-size: 9.5px; font-weight: 800; letter-spacing: .04em; }
.mini-btn[disabled] { background: rgba(35,49,44,.12); color: var(--ink-3); }

/* bộ sưu tập */
.collection-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.collection-grid.avatars-grid { grid-template-columns: repeat(4, 1fr); }
.coll-item { position: relative; border-radius: 13px; padding: 9px 7px 8px; text-align: center; background: rgba(255,250,238,.55); border: 1px solid rgba(191,150,75,.18); }
.coll-item.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.coll-preview { width: 44px; height: 66px; margin: 0 auto 6px; }
.coll-preview .card { position: relative; width: 44px; height: 66px; margin: 0 auto; }
.coll-item b { display: block; font-size: 9.5px; font-weight: 700; }
.coll-item small { display: block; font-size: 8px; color: var(--ink-3); margin-top: 1px; }
.coll-item .buy { margin-top: 5px; font-size: 8.5px; font-weight: 800; color: var(--gold-2); }
.coll-item.locked { opacity: .6; }
.coll-item .lock-badge { position: absolute; top: 6px; right: 6px; width: 15px; height: 15px; color: var(--ink-3); }

/* kết quả */
.result { text-align: center; padding-top: 4px; }
.result .seal-stamp {
  width: 92px; height: 92px; margin: 4px auto 10px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 2px solid var(--verm);
  color: var(--verm);
  font-family: var(--serif); font-weight: 700; font-size: 30px; letter-spacing: .06em;
  transform: rotate(-5deg) scale(1);
  position: relative;
  animation: stamp .5s cubic-bezier(.15,1.4,.4,1) both;
}
.result .seal-stamp::before { content: ''; position: absolute; inset: 5px; border: 1px solid currentColor; border-radius: 6px; opacity: .55; }
.result .seal-stamp.lose { border-color: var(--ink-3); color: var(--ink-3); }
@keyframes stamp { 0% { transform: rotate(-14deg) scale(1.6); opacity: 0; } 100% { transform: rotate(-5deg) scale(1); opacity: 1; } }
.result h3 { margin: 0 0 2px; font-family: var(--serif); font-size: 25px; color: var(--pine); }
.result .r-sub { font-size: 11px; color: var(--ink-3); margin: 0 0 12px; }
.result-stats { display: flex; gap: 8px; margin: 10px 0 14px; }
.result-stat { flex: 1; padding: 9px 4px; border-radius: 11px; background: rgba(255,250,238,.6); border: 1px solid rgba(191,150,75,.18); }
.result-stat b { display: block; font-size: 18px; font-family: var(--serif); color: var(--pine); }
.result-stat span { font-size: 8px; font-weight: 700; letter-spacing: .12em; color: var(--ink-3); text-transform: uppercase; }
.result-breakdown { text-align: left; margin: 6px 0 2px; }
.result-breakdown .line { display: flex; gap: 8px; font-size: 10.5px; padding: 4px 0; border-bottom: 1px dashed rgba(35,49,44,.1); }
.result-breakdown .line span:first-child { flex: 1; color: var(--ink-2); }
.result-breakdown .line b { color: var(--pine); }
.result-breakdown .line.total { border-bottom: 0; padding-top: 8px; font-size: 12px; }
.result-breakdown .line.total b { color: var(--verm); font-size: 14px; }

/* hướng dẫn lần đầu */
.slide-visual { position: relative; height: 128px; margin: 4px 0 10px; display: flex; align-items: center; justify-content: center; }
.slide-visual .fan { height: 128px; margin: 0; }
.slide-visual .fan .hero-card { width: 54px; height: 84px; }
.slide-visual .fan .hero-card:nth-child(1) { transform: translate(-50%, -50%) translate(-60px, 10px) rotate(-16deg); }
.slide-visual .fan .hero-card:nth-child(2) { transform: translate(-50%, -50%) translate(-20px, -2px) rotate(-5deg); }
.slide-visual .fan .hero-card:nth-child(3) { transform: translate(-50%, -50%) translate(20px, -2px) rotate(5deg); }
.slide-visual .fan .hero-card:nth-child(4) { transform: translate(-50%, -50%) translate(60px, 10px) rotate(16deg); }
.slide-title { font-family: var(--serif); font-size: 20px; margin: 0 0 4px; color: var(--pine); text-align: center; }
.slide-p { font-size: 12px; line-height: 1.65; color: var(--ink-2); text-align: center; margin: 0 0 10px; }
.slide-dots { display: flex; justify-content: center; gap: 5px; margin: 4px 0 12px; }
.slide-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(35,49,44,.18); }
.slide-dots i.on { background: var(--verm); width: 16px; border-radius: 99px; }
.tip-list { display: flex; flex-direction: column; gap: 8px; }
.tip-item { display: flex; gap: 9px; align-items: flex-start; padding: 9px 10px; border-radius: 11px; background: rgba(255,250,238,.55); border: 1px solid rgba(191,150,75,.16); }
.tip-item .n { width: 20px; height: 20px; border-radius: 50%; background: var(--pine); color: var(--gold-soft); display: grid; place-items: center; font-size: 10px; font-weight: 800; flex: none; }
.tip-item p { margin: 0; font-size: 11px; line-height: 1.55; color: var(--ink-2); }
.tip-item p b { color: var(--ink); }

/* splash */
.splash {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255,250,238,.96), rgba(244,234,214,.96) 55%, rgba(234,220,194,1));
  transition: opacity .5s ease, visibility .5s ease;
}
.splash.hide { opacity: 0; visibility: hidden; }
.splash .seal-logo { width: 64px; height: 64px; margin-bottom: 14px; }
.splash .seal-logo span { font-size: 15px; }
.splash h1 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 42px; letter-spacing: .08em; color: var(--pine); }
.splash p { margin: 6px 0 0; font-size: 9px; font-weight: 800; letter-spacing: .5em; color: var(--gold-2); text-indent: .5em; }
.splash .load { width: 92px; height: 2px; background: rgba(35,49,44,.12); border-radius: 9px; margin-top: 26px; overflow: hidden; }
.splash .load i { display: block; height: 100%; width: 40%; border-radius: 9px; background: linear-gradient(90deg, transparent, var(--gold), transparent); animation: load 1.1s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }

/* hiệu ứng rung nhẹ khi thao tác sai */
.shake { animation: shake .35s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

/* màn hình thấp */
@media (max-height: 720px) {
  :root { --cw: 44px; --ch: 68px; }
  .home-hero { justify-content: flex-start; padding-top: 4px; }
  .fan { height: 150px; }
  .hero-line { display: none; }
  .home-dock { margin-top: 4px; }
  .logo { font-size: clamp(38px, 11.8vw, 54px); }
  .home-foot .xp-line { display: none; }
  .seat-top .avatar-wrap { width: 36px; height: 36px; }
  .seat-left, .seat-right { width: 76px; }
  .actions .btn { height: 46px; }
  .actions { min-height: 46px; }
}
@media (max-height: 640px) {
  .home-vine { display: none; }
  .fan { height: 128px; }
  .hero-card { width: 54px; height: 84px; }
  .disclaimer { display: none; }
  .seat-left, .seat-right { top: 44%; }
  .center-piles { gap: 8px; }
}

/* tôn trọng giảm chuyển động */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- bổ sung: nút tiếp tục, modal không tiêu đề, lưng bài, chiếu ---------- */
.btn-resume {
  min-height: 40px;
  padding: 0 20px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--pine);
  background: rgba(255, 250, 238, .82);
  border: 1px solid rgba(31, 74, 61, .28);
  box-shadow: 0 2px 6px rgba(60,40,10,.08);
}
.btn-resume:active { transform: scale(.98); }
.modal.no-head .panel-head { display: none; }
.modal.no-head .panel-body { padding-top: 20px; }
.modal.no-head .grabber { margin-top: 10px; }

.fan { --cw: clamp(62px, 17vw, 86px); --ch: calc(var(--cw) * 1.56); }
.hero-card { width: var(--cw); height: var(--ch); }
.slide-visual .fan { --cw: 54px; --ch: 84px; height: 128px; }
.slide-visual .hero-card { width: var(--cw); height: var(--ch); }

.seat-melds .mini { --mw: 15px; }
.seat-melds { gap: 4px; }
.seat-melds .meld-group {
  padding: 1px 2px; border-radius: 4px;
  background: rgba(255, 250, 238, .46);
  border: 1px solid rgba(191, 150, 75, .16);
}
.seat-melds .meld-group.is-quan { border-color: rgba(191, 150, 75, .55); }
.my-melds .mini { --mw: 27px; }
.set-card .mini { --mw: 22px; }

/* lưng bài: biến thể */
.card.back {
  --back-a: #235345;
  --back-b: #173c31;
  --back-c: #e6c47a;
  --back-line: rgba(230, 196, 122, .26);
  --back-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cg fill='none' stroke='%23e6c47a' stroke-opacity='.26' stroke-width='.8'%3E%3Cpath d='M14 0 28 14 14 28 0 14Z'/%3E%3Ccircle cx='14' cy='14' r='2.6'/%3E%3C/g%3E%3C/svg%3E");
  background-image: var(--back-pattern), linear-gradient(155deg, var(--back-a), var(--back-b) 62%, var(--back-b));
}
.card.back::before { border-color: var(--back-c); opacity: .5; }
.card.back .back-seal { border-color: var(--back-c); color: var(--back-c); }
.card.back .back-seal::before { border-color: var(--back-c); opacity: .35; }
.back-sen { --back-a: #7a3b50; --back-b: #4a2030; --back-c: #efcfab; --back-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cg fill='none' stroke='%23efcfab' stroke-opacity='.22' stroke-width='.8'%3E%3Cpath d='M15 4c3 4 3 8 0 11-3-3-3-7 0-11Z'/%3E%3Cpath d='M15 15c5-1 8 2 8 6-5 1-8-2-8-6Z'/%3E%3Cpath d='M15 15c-5-1-8 2-8 6 5 1 8-2 8-6Z'/%3E%3C/g%3E%3C/svg%3E"); }
.back-may { --back-a: #286b66; --back-b: #16433f; --back-c: #d9e6df; --back-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='24' viewBox='0 0 32 24'%3E%3Cg fill='none' stroke='%23d9e6df' stroke-opacity='.2' stroke-width='.9'%3E%3Cpath d='M0 18c5 0 5-8 10-8s5 8 10 8 5-8 10-8'/%3E%3Cpath d='M0 24c5 0 5-8 10-8s5 8 10 8 5-8 10-8'/%3E%3C/g%3E%3C/svg%3E"); }
.back-muc { --back-a: #33322e; --back-b: #1b1b19; --back-c: #d9c9a5; --back-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 26 26'%3E%3Cg fill='none' stroke='%23d9c9a5' stroke-opacity='.16' stroke-width='.9'%3E%3Cpath d='M0 13h26M13 0v26'/%3E%3Ccircle cx='13' cy='13' r='5'/%3E%3C/g%3E%3C/svg%3E"); }
.back-gam { --back-a: #9e3325; --back-b: #5e1a12; --back-c: #f2d69a; --back-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cg fill='none' stroke='%23f2d69a' stroke-opacity='.25' stroke-width='.8'%3E%3Cpath d='M15 2 28 15 15 28 2 15Z'/%3E%3Cpath d='M15 7 23 15 15 23 7 15Z'/%3E%3Ccircle cx='15' cy='15' r='2'/%3E%3C/g%3E%3C/svg%3E"); }
.back-trang { --back-a: #f4ecd9; --back-b: #e5d7bb; --back-c: #6d4b5c; --back-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 26 26'%3E%3Cg fill='none' stroke='%236d4b5c' stroke-opacity='.22' stroke-width='.9'%3E%3Ccircle cx='13' cy='13' r='9'/%3E%3Cpath d='M13 4v18M4 13h18'/%3E%3C/g%3E%3C/svg%3E"); }
.back-trang .back-seal { background: rgba(109,75,92,.06); }

/* bộ sưu tập */
.coll-preview .card { position: relative; width: 44px; height: 66px; margin: 0 auto; border-radius: 5px; }
.coll-preview .back-seal { font-size: 11px; }
.coll-preview .card::before { inset: 12% 8%; }
.mat-preview {
  width: 100%; height: 42px; margin: 0 auto 6px; border-radius: 8px;
  border: 1px solid rgba(191,150,75,.25);
  background:
    radial-gradient(ellipse at 50% 50%, rgba(255,252,243,.7), transparent 70%),
    repeating-linear-gradient(45deg, rgba(138,106,52,.10) 0 2px, transparent 2px 6px),
    linear-gradient(160deg, #e8dcc0, #d9c8a4);
}
.mat-preview.mat-lua {
  background:
    radial-gradient(ellipse at 50% 50%, rgba(255,255,255,.35), transparent 70%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.08) 0 2px, transparent 2px 7px),
    linear-gradient(160deg, #3f7f69, #245444);
}
.mat-preview.mat-gam {
  background:
    radial-gradient(ellipse at 50% 50%, rgba(255,240,200,.2), transparent 70%),
    repeating-linear-gradient(45deg, rgba(242,214,154,.18) 0 1px, transparent 1px 8px),
    linear-gradient(160deg, #a33a2a, #7b2318);
}
.av-preview { width: 46px; height: 46px; margin: 0 auto 6px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px rgba(191,150,75,.4); }
.av-preview svg { width: 100%; height: 100%; }

/* chiếu bàn */
.table.mat-lua {
  background:
    radial-gradient(ellipse 60% 52% at 50% 46%, rgba(240,250,245,.85), rgba(207,231,220,.55) 60%, rgba(180,214,199,.25) 100%);
}
.table.mat-gam {
  background:
    radial-gradient(ellipse 60% 52% at 50% 46%, rgba(255,241,224,.9), rgba(244,213,190,.55) 60%, rgba(230,190,165,.22) 100%);
}
.table.mat-lua::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cg fill='none' stroke='%231f4a3d' stroke-opacity='.06' stroke-width='.9'%3E%3Cpath d='M14 0 28 14 14 28 0 14Z'/%3E%3Ccircle cx='14' cy='14' r='3'/%3E%3C/g%3E%3C/svg%3E"); }
.table.mat-gam::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cg fill='none' stroke='%239b3d2c' stroke-opacity='.06' stroke-width='.9'%3E%3Cpath d='M15 2 28 15 15 28 2 15Z'/%3E%3Cpath d='M15 7 23 15 15 23 7 15Z'/%3E%3C/g%3E%3C/svg%3E"); }

/* self avatar khi tới lượt */
.self-avatar.turn { box-shadow: 0 0 0 2px rgba(255,250,238,.95), 0 0 0 4px var(--verm), 0 0 12px rgba(178,58,43,.35); }

/* nút gợi ý tắt */
.hint-btn:disabled { opacity: .35; }

/* lịch sử thành tích */
.hist-row { display: flex; gap: 5px; flex-wrap: wrap; padding: 4px 0 6px; }
.hist-dot { width: 18px; height: 18px; border-radius: 5px; display: inline-block; }
.hist-dot.w { background: var(--pine); }
.hist-dot.l { background: rgba(178,58,43,.55); }
.hist-dot.d { background: rgba(35,49,44,.18); }

/* ---------- tinh chỉnh bàn chơi ---------- */
.panel:focus { outline: none; }
.center-piles { top: 47%; gap: 22px; }
.turn-banner { bottom: 40px; }
.mat-crest { top: 61%; font-size: 72px; }
.dead-tray {
  position: absolute; left: 50%; bottom: 9px; transform: translateX(-50%);
  max-width: 92%;
  display: flex; align-items: center; gap: 7px;
  padding: 4px 9px; border-radius: 9px;
  background: rgba(255, 250, 238, .42);
  border: 1px solid rgba(191, 150, 75, .16);
  z-index: 2;
}
.tray-label {
  font-size: 7.5px; font-weight: 800; letter-spacing: .12em;
  color: var(--ink-3); text-transform: uppercase; white-space: nowrap;
}
.tray-label b { color: var(--ink-2); margin-left: 2px; }
.tray-cards { display: flex; align-items: center; gap: 2px; overflow: hidden; max-width: 210px; }
.tray-cards .mini { --mw: 13px; opacity: .7; }
.tray-cards .mini .m-code { font-size: 5px; }
.tray-cards .mini .m-band { width: 1.8px; }
.card.trash { outline: 2px solid rgba(178, 58, 43, .82); outline-offset: -2px; }
.card.trash .c-color { color: var(--verm); font-weight: 800; }
.card.trash .c-color::after { content: ' · RÁC'; font-size: .82em; letter-spacing: 0; }
.table-lotus {
  position: absolute; left: 50%; bottom: 46px; width: 118px; height: 98px;
  transform: translateX(-50%); color: var(--jade); opacity: .1; pointer-events: none;
}
.my-melds-label {
  flex: none; align-self: center; padding-right: 2px;
  font-size: 7px; font-weight: 800; letter-spacing: .12em;
  color: var(--ink-3); text-transform: uppercase; white-space: nowrap;
}

/* nút dùng trong thân modal (nhận quà, v.v.) */
.btn { display: inline-flex; align-items: center; justify-content: center; font-weight: 800; letter-spacing: .05em; }
.btn-main {
  color: #fff8e8;
  background: linear-gradient(180deg, #276152, #1f4a3d 60%, #17382e);
  box-shadow: 0 1px 0 rgba(255,240,205,.22) inset, 0 5px 14px rgba(20,55,44,.2);
}
.btn-main:disabled { opacity: .45; box-shadow: none; }

/* biến thể lưng bài — specificity cao hơn .card.back */
.card.back.back-sen { --back-a: #7a3b50; --back-b: #4a2030; --back-c: #efcfab; --back-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cg fill='none' stroke='%23efcfab' stroke-opacity='.22' stroke-width='.8'%3E%3Cpath d='M15 4c3 4 3 8 0 11-3-3-3-7 0-11Z'/%3E%3Cpath d='M15 15c5-1 8 2 8 6-5 1-8-2-8-6Z'/%3E%3Cpath d='M15 15c-5-1-8 2-8 6 5 1 8-2 8-6Z'/%3E%3C/g%3E%3C/svg%3E"); }
.card.back.back-may { --back-a: #286b66; --back-b: #16433f; --back-c: #d9e6df; --back-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='24' viewBox='0 0 32 24'%3E%3Cg fill='none' stroke='%23d9e6df' stroke-opacity='.2' stroke-width='.9'%3E%3Cpath d='M0 18c5 0 5-8 10-8s5 8 10 8 5-8 10-8'/%3E%3Cpath d='M0 24c5 0 5-8 10-8s5 8 10 8 5-8 10-8'/%3E%3C/g%3E%3C/svg%3E"); }
.card.back.back-muc { --back-a: #33322e; --back-b: #1b1b19; --back-c: #d9c9a5; --back-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 26 26'%3E%3Cg fill='none' stroke='%23d9c9a5' stroke-opacity='.16' stroke-width='.9'%3E%3Cpath d='M0 13h26M13 0v26'/%3E%3Ccircle cx='13' cy='13' r='5'/%3E%3C/g%3E%3C/svg%3E"); }
.card.back.back-gam { --back-a: #9e3325; --back-b: #5e1a12; --back-c: #f2d69a; --back-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cg fill='none' stroke='%23f2d69a' stroke-opacity='.25' stroke-width='.8'%3E%3Cpath d='M15 2 28 15 15 28 2 15Z'/%3E%3Cpath d='M15 7 23 15 15 23 7 15Z'/%3E%3Ccircle cx='15' cy='15' r='2'/%3E%3C/g%3E%3C/svg%3E"); }
.card.back.back-trang { --back-a: #f4ecd9; --back-b: #e5d7bb; --back-c: #6d4b5c; --back-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 26 26'%3E%3Cg fill='none' stroke='%236d4b5c' stroke-opacity='.22' stroke-width='.9'%3E%3Ccircle cx='13' cy='13' r='9'/%3E%3Cpath d='M13 4v18M4 13h18'/%3E%3C/g%3E%3C/svg%3E"); }
.card.back.back-trang .back-seal { background: rgba(109,75,92,.06); }

.meta-pub { display: none; }

/* màn hình rất thấp (iPhone SE 1 / 4") — bỏ bộ công khai của nhà trên, thu gọn bàn */
@media (max-height: 620px) {
  .meta-pub { display: inline; }
  .game { padding: calc(4px + var(--safe-t)) 8px calc(6px + var(--safe-b)); gap: 3px; }
  .game-top { height: 36px; }
  .round-btn { width: 34px; height: 34px; }
  .round-btn .ico { width: 18px; height: 18px; }
  .round-chip { padding: 3px 10px; }
  .round-chip b { font-size: 13px; }
  .coin-pill { height: 30px; padding-right: 9px; font-size: 12px; }
  .coin-pill svg { width: 21px; height: 21px; }
  .table { border-radius: 16px; }
  .seat-top { top: 3px; }
  .seat-top .avatar-wrap { width: 30px; height: 30px; }
  .seat-top .seat-name { font-size: 10px; }
  .seat-top .seat-name small { font-size: 7px; }
  .seat-top .seat-melds { display: none; }
  .seat-left, .seat-right { width: 64px; top: 44%; }
  .seat-left .avatar-wrap, .seat-right .avatar-wrap { width: 28px; height: 28px; }
  .seat-left .seat-name, .seat-right .seat-name { font-size: 9px; }
  .seat-left .seat-name small, .seat-right .seat-name small { font-size: 6.5px; }
  .seat-melds .mini { --mw: 11px; }
  .seat-melds .meld-group { padding: 0 1px; }
  .center-piles { top: 48%; gap: 12px; }
  .noc-stack { width: 28px; height: 42px; }
  .noc-stack .card { width: 26px; height: 40px; }
  .noc-count { min-width: 17px; height: 17px; font-size: 8px; }
  .pile > small { font-size: 6.5px; margin-top: 2px; }
  .active-tag { top: -12px; font-size: 6.5px; }
  .mat-ring { width: 64%; }
  .mat-crest { font-size: 52px; }
  .table-lotus { width: 80px; height: 66px; bottom: 34px; }
  .turn-banner { bottom: 30px; font-size: 8px; padding: 3px 9px; }
  .dead-tray { padding: 3px 6px; bottom: 5px; }
  .tray-label { font-size: 6.5px; }
  .tray-cards .mini { --mw: 11px; }
  .self-panel { gap: 3px; }
  .self-row { gap: 5px; }
  .self-avatar { width: 26px; height: 26px; }
  .self-id b { font-size: 11px; }
  .self-id small { font-size: 7px; }
  .metric { min-width: 36px; padding: 2px 6px; }
  .metric b { font-size: 12px; }
  .metric span { font-size: 6px; }
  .hint-btn { height: 26px; padding: 0 8px; font-size: 8.5px; }
  .hint-btn .ico { width: 12px; height: 12px; }
  .my-melds .mini { --mw: 22px; }
  .my-melds .mini .m-code { font-size: 7.5px; }
  .my-melds .m-val { font-size: 5.5px; }
  .my-melds-label { font-size: 6px; }
  .actions { min-height: 42px; }
  .actions .btn { height: 42px; border-radius: 12px; font-size: 12px; }
  .actions .btn small { font-size: 7.5px; }
}




