/* ───── tiles ───── */
.tile {
    --w: 44px;
    position: relative; flex: 0 0 auto;
    width: var(--w); height: calc(var(--w) * 1.36);
    border-radius: calc(var(--w) * 0.13);
    background: linear-gradient(160deg, #fffdf6 0%, #f6eedc 55%, #e8dcc0 100%);
    box-shadow:
        inset 0 calc(var(--w) * -0.04) 0 rgba(150, 120, 70, .18),
        inset 0 1px 0 #fff,
        0 calc(var(--w) * 0.1) 0 #1f7a55,
        0 calc(var(--w) * 0.12) 0 #155c3f,
        0 calc(var(--w) * 0.16) calc(var(--w) * 0.14) rgba(0, 0, 0, .45);
    margin-bottom: calc(var(--w) * 0.12);
}
.tile::after {
    content: ''; position: absolute; inset: 6% 7% 7%;
    background: var(--face) center / contain no-repeat;
    mix-blend-mode: multiply;      /* the painted tiles' ivory melts into the tile face */
}
.tile.back {
    background: radial-gradient(circle at 30% 25%, #4fd39a, #1e8a5d 55%, #136545);
    box-shadow:
        inset 0 0 0 calc(var(--w) * 0.05) rgba(255, 255, 255, .12),
        0 calc(var(--w) * 0.1) 0 #efe4c8,
        0 calc(var(--w) * 0.12) 0 #cbbd98,
        0 calc(var(--w) * 0.16) calc(var(--w) * 0.14) rgba(0, 0, 0, .45);
}
.tile.back::after { background: radial-gradient(circle, rgba(255, 230, 150, .5) 0 18%, transparent 20%) center / 60% 60% no-repeat; }
/* A tile lying sideways (left/right players), and a face turned upside down (the player across). */
.tile.lay { width: calc(var(--w) * 1.36); height: var(--w); margin-bottom: calc(var(--w) * 0.12); }
.tile.lay::after { inset: auto; left: 50%; top: 50%; width: calc(var(--w) * 0.86); height: calc(var(--w) * 1.24); transform: translate(-50%, -50%) rotate(var(--turn, 90deg)); }
.tile.flip::after { transform: rotate(180deg); }
.tile.dim { filter: brightness(.82) saturate(.8); }
.tile.hl { outline: 3px solid #ffd45c; outline-offset: 1px; animation: glow 1.2s ease-in-out infinite alternate; }
@keyframes glow { to { outline-color: #fff2b8; } }

/* ───── base ───── */
:root {
    --ink: #2b1a12; --gold: #e8b64c; --gold-2: #ffd77a; --red: #9e1b1b; --red-2: #c8342c; --jade: #1e8a5d; --cream: #fbf4e2;
    --shadow: 0 6px 18px rgba(0, 0, 0, .35);
    --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a0707 url(art/room.webp) center / cover fixed; color: var(--cream); font: 700 15px/1.3 Nunito, system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; }
[hidden] { display: none !important; }

.btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 11px 18px; border-radius: 14px;
    background: linear-gradient(#fff7e3, #f0dfb8); color: var(--ink); font-weight: 900; box-shadow: 0 3px 0 #b48a3a, var(--shadow); transition: transform .08s; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #b48a3a, var(--shadow); }
.btn small { font-weight: 700; font-size: 12px; opacity: .75; }
.btn.gold { background: linear-gradient(#ffe39a, #e8a93c); box-shadow: 0 3px 0 #9a6516, var(--shadow); }
.btn.jade { background: linear-gradient(#5fdcaa, #1e8a5d); color: #fff; box-shadow: 0 3px 0 #0f5638, var(--shadow); }
.btn.red { background: linear-gradient(#ff7b6b, #b92a24); color: #fff; box-shadow: 0 3px 0 #6e1210, var(--shadow); }
.btn.ghost { background: rgba(255, 255, 255, .12); color: var(--cream); box-shadow: none; }
.btn.big { width: 100%; padding: 14px 18px; font-size: 18px; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 11px; }
.btn:disabled { opacity: .45; pointer-events: none; }
.link { color: var(--gold-2); font-weight: 800; padding: 6px; text-decoration: underline; }
.hint { color: #e9d7b8; font-size: 13px; text-align: center; margin: 4px 0; }
.error { color: #ffb3a6; text-align: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; min-width: 36px; padding: 0 10px; justify-content: center; border-radius: 99px; background: rgba(20, 8, 4, .55); color: var(--cream); font-weight: 800; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.spacer { flex: 1; }
.field { display: grid; gap: 4px; font-size: 12px; color: #e9d7b8; flex: 1; }
.field input, .code-row input { padding: 11px 13px; border-radius: 12px; border: 2px solid rgba(232, 182, 76, .5); background: rgba(255, 248, 230, .95); color: var(--ink); font-weight: 900; font-size: 16px; user-select: text; -webkit-user-select: text; min-width: 0; }

/* ───── menu and panels ───── */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: calc(14px + var(--safe-t)) 14px calc(14px + var(--safe-b)); overflow-y: auto; }
.menu-bg { position: fixed; inset: 0; background: url(art/room.webp) center / cover; filter: saturate(1.1); }
.menu-bg::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(30, 6, 4, .25), rgba(20, 4, 2, .8)); }
.menu-box, .panel { position: relative; width: min(440px, 100%); display: grid; gap: 12px; padding: 22px 20px; border-radius: 24px;
    background: linear-gradient(rgba(70, 14, 10, .88), rgba(40, 8, 6, .92)); border: 1px solid rgba(232, 182, 76, .45); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.panel.wide { width: min(560px, 100%); }
.logo { display: grid; justify-items: center; line-height: 1; margin: -6px 0 2px; }
.logo .zh { font: 400 74px 'Ma Shan Zheng', serif; color: var(--gold-2); text-shadow: 0 3px 0 #7a1a10, 0 0 30px rgba(255, 200, 90, .45); }
.logo .en { font: 400 26px 'Marcellus SC', serif; letter-spacing: 3px; color: #ffe9c0; margin-top: 4px; }
.tag { margin: 0; text-align: center; color: #e9d7b8; font-size: 14px; }
.menu-box { padding-top: 150px; overflow: hidden; }
.menu-box::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 240px; background: url(art/hero.webp) center 40% / cover; -webkit-mask-image: linear-gradient(#000 45%, transparent); mask-image: linear-gradient(#000 45%, transparent); pointer-events: none; }
.menu-box > * { position: relative; }
.me-row { display: flex; gap: 12px; align-items: end; }
.avatar-btn { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; flex: 0 0 auto; border: 3px solid var(--gold); box-shadow: var(--shadow); background: #3a120c; }
.avatar-btn img, .av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.menu-grid { display: grid; gap: 10px; }
.bar { display: flex; align-items: center; gap: 8px; }
.bar h2 { margin: 0; font: 400 24px 'Marcellus SC', serif; flex: 1; color: #ffe9c0; }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; text-transform: uppercase; letter-spacing: 3px; }
.lobby-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lobby-list li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: rgba(255, 240, 210, .08); }
.lobby-list li.offline { opacity: .5; }
.lobby-list .av { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; border: 2px solid var(--gold); }
.lobby-list li.empty { border: 2px dashed rgba(232, 182, 76, .3); background: none; color: #c9b38e; justify-content: center; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.rules-pick { display: grid; gap: 8px; }
.seg { display: flex; background: rgba(0, 0, 0, .3); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 7px 8px; border-radius: 9px; color: #e9d7b8; font-weight: 800; font-size: 13px; display: grid; }
.seg button small { font-weight: 700; font-size: 11px; opacity: .8; }
.seg button.on { background: linear-gradient(#ffe39a, #e8a93c); color: var(--ink); }
.seg.big button { padding: 10px 8px; font-size: 16px; }
.seg[aria-disabled=true] { pointer-events: none; opacity: .75; }
.opt-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #e9d7b8; }
.opt-row > span { width: 110px; flex: 0 0 auto; }
.opt-row .seg { flex: 1; }

/* ───── the table ───── */
#game { position: fixed; inset: 0; --hw: min(calc((100vw - 24px - var(--safe-l) - var(--safe-r)) / 15.6), 9.4vh, 64px); --ow: calc(var(--hw) * .52); --pw: min(calc(var(--hw) * .66), 4.3vh, 36px); --mw: calc(var(--hw) * .68); }
.felt { position: absolute; inset: 0; background: url(art/table.webp) center / cover, #14533a; }
.felt::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, .45)); }
.topbar { position: absolute; top: calc(6px + var(--safe-t)); left: calc(8px + var(--safe-l)); right: calc(8px + var(--safe-r)); display: flex; gap: 6px; z-index: 5; }

.badge { display: flex; align-items: center; gap: 7px; padding: 4px 10px 4px 4px; border-radius: 99px; background: rgba(25, 8, 4, .62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); white-space: nowrap; font-size: 13px; border: 2px solid transparent; transition: border-color .2s, box-shadow .2s; }
.badge .av { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; border: 2px solid var(--gold); flex: 0 0 auto; }
.badge .nm { display: grid; line-height: 1.1; }
.badge .nm small { color: var(--gold-2); font-size: 11px; }
.badge .wind { font: 400 20px 'Ma Shan Zheng', serif; color: var(--gold-2); }
.badge .dealer { font: 900 11px Nunito; background: var(--red-2); color: #fff; border-radius: 6px; padding: 1px 5px; }
.badge.turn { border-color: var(--gold-2); box-shadow: 0 0 18px rgba(255, 215, 120, .7); }
.badge.off { opacity: .55; }

.opp { position: absolute; display: flex; align-items: center; gap: 6px; z-index: 2; }
.opp .rot { display: flex; align-items: center; gap: calc(var(--ow) * .4); }
.opp .backs, .opp .melds { display: flex; gap: 1px; align-items: flex-end; }
.opp .tile { --w: var(--ow); }
.opp .melds .tile, .opp .bonus .tile { --w: calc(var(--ow) * 1.05); }
#opp-2 { top: calc(46px + var(--safe-t)); left: 50%; transform: translateX(-50%); flex-direction: row; }
#opp-2 .rot { flex-direction: row-reverse; }
#opp-1, #opp-3 { top: 50%; transform: translateY(-50%); flex-direction: column; }
#opp-1 { right: calc(6px + var(--safe-r)); }
#opp-3 { left: calc(6px + var(--safe-l)); }
#opp-1 .rot, #opp-3 .rot { flex-direction: column; }
#opp-1 .backs, #opp-3 .backs, #opp-1 .melds, #opp-3 .melds { flex-direction: column; gap: 0; align-items: center; }
#opp-1 .rot { flex-direction: column-reverse; }
.opp .melds .set { display: flex; gap: 0; }
#opp-1 .melds .set, #opp-3 .melds .set { flex-direction: column; }
.opp .melds .tile.lay, .opp .backs .tile.lay { margin-bottom: 0; margin-right: calc(var(--w) * 0.12); }

#center { position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%);
    width: calc(var(--pw) * 6 + var(--pw) * 1.48 * 4 * 2 + var(--pw) * 1.2); height: calc(var(--pw) * 1.48 * 4 * 2 + var(--pw) * 6 + var(--pw) * 1.2); }
.pool { position: absolute; display: grid; gap: 1px; }
.pool .tile { --w: var(--pw); margin-bottom: calc(var(--w) * .08); box-shadow: inset 0 -1px 0 rgba(150, 120, 70, .18), 0 calc(var(--w) * .08) 0 #1f7a55, 0 calc(var(--w) * .12) calc(var(--w) * .1) rgba(0, 0, 0, .4); }
#pool-0 { bottom: 0; left: 50%; transform: translateX(-50%); grid-template-columns: repeat(6, auto); }
#pool-2 { top: 0; left: 50%; transform: translateX(-50%); grid-template-columns: repeat(6, auto); direction: rtl; align-content: end; }
#pool-1, #pool-3 { top: 50%; transform: translateY(-50%); grid-template-rows: repeat(6, auto); grid-auto-flow: column; }
#pool-1 { right: 0; direction: rtl; }
#pool-3 { left: 0; }
#pool-2 { grid-auto-flow: row; }
.pool .tile.last { outline: 3px solid #ffd45c; outline-offset: 1px; animation: glow .8s ease-in-out infinite alternate; }

#compass { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: calc(var(--pw) * 4.4); height: calc(var(--pw) * 4.4); border-radius: 18%;
    background: radial-gradient(circle at 30% 25%, #4b1a12, #200805); border: 2px solid rgba(232, 182, 76, .6); box-shadow: inset 0 0 18px rgba(0, 0, 0, .6), 0 8px 24px rgba(0, 0, 0, .5); }
.cmid { position: absolute; inset: 24%; display: grid; place-items: center; align-content: center; text-align: center; line-height: 1.05; }
.cmid b { font: 400 calc(var(--pw) * .62) 'Ma Shan Zheng', serif; color: var(--gold-2); white-space: nowrap; }
.cmid small { font-size: calc(var(--pw) * .28); color: #e9d7b8; white-space: nowrap; }
.cw { position: absolute; font: 400 calc(var(--pw) * .58) 'Ma Shan Zheng', serif; color: rgba(255, 233, 192, .45); transition: color .2s, text-shadow .2s; }
.cw[data-pos="0"] { bottom: 2%; left: 50%; transform: translateX(-50%); }
.cw[data-pos="1"] { right: 4%; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.cw[data-pos="2"] { top: 2%; left: 50%; transform: translateX(-50%) rotate(180deg); }
.cw[data-pos="3"] { left: 4%; top: 50%; transform: translateY(-50%) rotate(90deg); }
.cw.on { color: #ffe27a; text-shadow: 0 0 12px #ffcc4d; }
.cw.dealer::after { content: '•'; color: #ff7461; margin-left: 2px; }

#me { position: absolute; left: 0; right: 0; bottom: calc(4px + var(--safe-b)); display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: end; gap: 4px 10px; padding: 0 calc(10px + var(--safe-r)) 0 calc(10px + var(--safe-l)); z-index: 3; }
#badge-me { grid-row: 1; grid-column: 1; align-self: center; }
#my-melds { grid-row: 1; grid-column: 2; display: flex; gap: calc(var(--mw) * .3); justify-content: flex-start; align-items: flex-end; min-height: calc(var(--mw) * 1.5); }
#my-melds .tile { --w: var(--mw); }
#my-melds .set { display: flex; gap: 0; }
.bonus { display: flex; gap: 1px; }
.bonus .tile { --w: calc(var(--mw) * .82); }
#my-hand { grid-row: 2; grid-column: 1 / 3; display: flex; justify-content: center; align-items: flex-end; gap: 2px; min-height: calc(var(--hw) * 1.6); touch-action: none; }
#my-hand .tile { --w: var(--hw); cursor: pointer; transition: transform .12s ease-out, filter .12s; }
#my-hand .tile.drawn { margin-left: calc(var(--hw) * .35); }
#my-hand .tile.sel { transform: translateY(calc(var(--hw) * -.32)); box-shadow: 0 0 0 3px #ffd45c, 0 0 18px rgba(255, 212, 92, .8), 0 calc(var(--w) * 0.1) 0 #1f7a55, 0 calc(var(--w) * 0.12) 0 #155c3f; }
#my-hand .tile.tip::before { content: ''; position: absolute; top: calc(var(--hw) * -.22); left: 50%; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: #ffd45c; box-shadow: 0 0 8px #ffd45c; }
#my-hand.wait .tile { cursor: default; }
#my-hand .tile.new { animation: drawIn .35s ease-out; }
@keyframes drawIn { from { transform: translateY(-40%); opacity: 0; } }

#status { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--hw) * 1.9 + var(--mw) * 1.6 + 16px + var(--safe-b)); padding: 6px 14px; border-radius: 99px; background: rgba(25, 8, 4, .66); font-size: 14px; white-space: nowrap; z-index: 4; pointer-events: none; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
#ready { position: absolute; right: calc(10px + var(--safe-r)); bottom: calc(var(--hw) * 1.9 + var(--mw) * 1.6 + 16px + var(--safe-b)); display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 14px; background: rgba(25, 8, 4, .7); font-size: 12px; z-index: 4; }
#ready .tile { --w: calc(var(--mw) * .8); margin-bottom: 4px; }
#actions { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--hw) * 1.75 + var(--mw) * 1.6 + 52px + var(--safe-b)); display: flex; gap: 10px; align-items: center; z-index: 6; flex-wrap: wrap; justify-content: center; max-width: 96vw; }
#actions:empty { display: none; }
#actions .claim-tile { display: grid; justify-items: center; gap: 2px; font-size: 12px; padding: 8px 10px; border-radius: 16px; background: rgba(25, 8, 4, .75); }
#actions .claim-tile .tile { --w: calc(var(--hw) * 1.05); }
.act { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 16px; font-weight: 900; font-size: 17px; box-shadow: 0 3px 0 rgba(0, 0, 0, .35), var(--shadow); }
.act b { font: 400 24px 'Ma Shan Zheng', serif; line-height: 1; }
.act .mini { display: flex; gap: 1px; }
.act .mini .tile { --w: 20px; margin-bottom: 3px; }
.act.win { background: linear-gradient(#ffe39a, #e8a93c); color: var(--ink); animation: pulse 1s ease-in-out infinite alternate; }
.act.pung, .act.kong { background: linear-gradient(#ff8d78, #b92a24); color: #fff; }
.act.chow { background: linear-gradient(#6fe2b4, #1e8a5d); color: #fff; }
.act.pass { background: rgba(255, 255, 255, .16); color: var(--cream); }
@keyframes pulse { to { transform: scale(1.06); box-shadow: 0 0 26px rgba(255, 210, 100, .9); } }
.timer { position: absolute; left: 10px; right: 10px; bottom: 3px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .7); transform-origin: left; }

#toasts { position: absolute; left: 50%; top: 32%; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; z-index: 8; pointer-events: none; }
.call { font: 400 46px 'Ma Shan Zheng', serif; color: #fff1c4; text-shadow: 0 3px 0 #7a1a10, 0 0 24px rgba(255, 190, 80, .9); animation: call 1.3s ease-out forwards; display: flex; align-items: center; gap: 10px; }
.call small { font: 900 16px Nunito; color: #fff; text-shadow: 0 2px 6px #000; }
.call .av { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; border: 2px solid var(--gold); }
@keyframes call { 0% { transform: scale(.4); opacity: 0; } 18% { transform: scale(1.15); opacity: 1; } 30% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
.note { padding: 7px 14px; border-radius: 12px; background: rgba(25, 8, 4, .8); font-size: 14px; animation: call 2.6s ease-out forwards; }
.flying { position: fixed; z-index: 20; pointer-events: none; margin: 0 !important; }

/* ───── sheets (results, menu, how to play) ───── */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 14px; background: rgba(10, 2, 0, .55); }
.sheet { width: min(620px, 100%); max-height: calc(100vh - 28px); overflow-y: auto; padding: 20px; border-radius: 24px; display: grid; gap: 12px;
    background: linear-gradient(rgba(80, 16, 10, .97), rgba(40, 8, 6, .98)); border: 1px solid rgba(232, 182, 76, .55); box-shadow: 0 20px 60px rgba(0, 0, 0, .7); animation: pop .3s cubic-bezier(.2, 1.4, .5, 1); touch-action: pan-y; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.sheet h2 { margin: 0; text-align: center; font: 400 30px 'Marcellus SC', serif; color: #ffe9c0; }
.sheet h2 .zh { font-family: 'Ma Shan Zheng', serif; color: var(--gold-2); margin-right: 8px; font-size: 40px; }
.win-hand { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: flex-end; padding: 10px; border-radius: 16px; background: radial-gradient(ellipse, #1e7a52, #0f4430); }
.win-hand .tile { --w: min(36px, 6.4vw); }
.win-hand .set { display: flex; gap: 0; }
.win-hand .tile.won { outline: 3px solid #ffd45c; outline-offset: 1px; }
.items { display: grid; gap: 4px; }
.items div { display: flex; gap: 10px; align-items: baseline; padding: 4px 10px; border-radius: 10px; background: rgba(255, 240, 210, .07); }
.items .zh { font: 400 20px 'Ma Shan Zheng', serif; color: var(--gold-2); width: 4.5em; flex: 0 0 auto; }
.items .nm { flex: 1; }
.items .n { font-weight: 900; color: var(--gold-2); }
.items .total { background: rgba(232, 182, 76, .2); font-size: 17px; }
.pays { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pays div { display: grid; justify-items: center; gap: 3px; padding: 8px 4px; border-radius: 14px; background: rgba(255, 240, 210, .07); font-size: 12px; text-align: center; }
.pays .av { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; border: 2px solid var(--gold); }
.pays b.up { color: #7ff0b5; } .pays b.down { color: #ff9c8c; }
.pays .total { color: #e9d7b8; }
.podium { display: grid; gap: 8px; }
.podium div { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: rgba(255, 240, 210, .08); font-size: 16px; }
.podium div:first-child { background: linear-gradient(90deg, rgba(232, 182, 76, .4), rgba(232, 182, 76, .1)); }
.podium .av { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; border: 2px solid var(--gold); }
.howto { display: grid; gap: 10px; font-size: 14px; font-weight: 600; color: #f3e6cc; }
.howto h3 { margin: 6px 0 0; color: var(--gold-2); font: 400 20px 'Marcellus SC', serif; }
.howto .tiles { display: flex; flex-wrap: wrap; gap: 3px; align-items: flex-end; }
.howto .tiles .tile { --w: 28px; }
.howto table { border-collapse: collapse; width: 100%; font-size: 13px; }
.howto td { padding: 3px 6px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.howto td:last-child { text-align: right; color: var(--gold-2); font-weight: 900; }

@media (max-height: 520px) {
    #game { --hw: min(calc((100vw - 24px) / 15.6), 12vh, 56px); --pw: min(calc(var(--hw) * .6), 4.6vh, 30px); --ow: min(calc(var(--hw) * .5), calc((100vh - 110px) / 16)); }
    #opp-2 { top: calc(4px + var(--safe-t)); }
    .topbar { left: auto; right: calc(6px + var(--safe-r)); top: auto; bottom: calc(var(--hw) * 1.75 + 8px + var(--safe-b)); flex-direction: column; }
    .topbar .chip { height: 30px; min-width: 30px; padding: 0 6px; font-size: 13px; }
    .topbar .spacer { display: none; }
    /* Side players: badge beside two short columns (hidden tiles | melds). */
    #opp-1, #opp-3 { flex-direction: row; top: 46%; }
    #opp-1 { flex-direction: row-reverse; right: calc(44px + var(--safe-r)); }
    #opp-1 .rot, #opp-3 .rot { flex-direction: row; align-items: center; }
    #opp-1 .rot { flex-direction: row-reverse; }
    .opp .badge { flex-direction: column; padding: 4px; gap: 2px; border-radius: 16px; }
    .opp .badge .nm b { display: none; }
    .opp .badge .nm small { display: block; }
    .badge .av { width: 28px; height: 28px; }
    #opp-2 .badge { flex-direction: row; }
}
/* Portrait phones: the table is happier sideways. */
.turn-hint { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
    .turn-hint { display: flex; position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); z-index: 7; flex-direction: column; align-items: center; gap: 6px;
        padding: 12px 18px; border-radius: 18px; background: rgba(25, 8, 4, .85); text-align: center; font-size: 14px; pointer-events: auto; }
    .turn-hint b { font-size: 30px; animation: tilt 1.6s ease-in-out infinite; }
    .turn-hint.gone { display: none; }
}
@keyframes tilt { 50% { transform: rotate(-90deg); } }
@media (orientation: portrait) {
    #game { --pw: min(calc((100vw - 24px) / 19), 30px); --ow: calc(var(--hw) * .62); }
    #opp-2 { top: calc(48px + var(--safe-t)); }
    #opp-1, #opp-3 { top: 40%; }
    #center { top: 44%; }
}

/* Win celebration: coins and petals raining over the table. */
.burst { position: fixed; inset: 0; pointer-events: none; z-index: 25; overflow: hidden; }
.burst i { position: absolute; top: -40px; font-style: normal; animation: fall var(--d, 2.4s) cubic-bezier(.3, .2, .6, 1) forwards; }
@keyframes fall { to { transform: translate(var(--x, 0), 110vh) rotate(var(--r, 360deg)); opacity: .2; } }
.screen:not(#menu) { background: radial-gradient(ellipse at center, rgba(30, 6, 4, .45), rgba(20, 4, 2, .85)); }
