/* Phỏm (Tá Lả) - matches the Tiến Lên look: navy panels, felt table, 4-colour deck, Poppins. */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #0f1726; --panel: #18233b; --panel2: #0b1220; --line: rgba(255,255,255,0.09);
  --text: #e8eef9; --muted: #93a3c0; --accent: #10b981; --accent-ink: #06281e;
  --gold: #f4c150; --rose: #fb7185; --felt: #0e3a2f; --felt2: #0a2d24;
  --red: #e11d48; --blue: #2563eb; --green: #15803d; --black: #0f172a;
  --cw: 50px; --ch: 72px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font-family: 'Poppins', system-ui, sans-serif; font-weight: 300; overflow-x: hidden; }
.wrap { max-width: 880px; margin: 0 auto; padding: 10px 16px 40px; }
h1 { font-weight: 700; letter-spacing: .3px; margin: 6px 0 0; text-align: center; font-size: 1.7rem; }
h1 span { color: var(--gold); font-weight: 500; }
h2, h3 { font-weight: 600; margin: 0 0 8px; }
.sub { text-align: center; color: var(--muted); margin: 0 0 10px; font-size: .85rem; }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar .grow { flex: 1; }
.back { color: #ffeb3b; font-size: .9rem; text-decoration: none; }
.back:hover { text-decoration: underline; }

button { font-family: inherit; font-size: .9rem; cursor: pointer; border: none; border-radius: 11px; font-weight: 600;
  padding: 10px 12px; background: var(--accent); color: var(--accent-ink); transition: filter .15s, transform .06s; }
button:hover:not(:disabled) { filter: brightness(1.08); }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { background: #33415a; color: #7e8aa3; cursor: not-allowed; }
button.ghostbtn, .chip-btn { background: rgba(255,255,255,.08); color: var(--text); font-weight: 500; padding: 7px 11px; font-size: .82rem; border: 1px solid var(--line); }
button.alt { background: #3b82f6; color: #fff; }
button.warn { background: var(--gold); color: #3a2a00; }
button.danger { background: #f43f5e; color: #fff; }
button .vi { display: block; line-height: 1.15; }
button .en { display: block; font-weight: 400; font-size: .68em; opacity: .85; line-height: 1.15; }

.box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 12px auto; max-width: 480px; }
label.f { display: block; margin: 10px 0 4px; font-size: .82rem; color: var(--muted); }
label.f b { color: var(--text); font-weight: 500; }
input[type=text], select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid rgba(255,255,255,.14);
  border-radius: 9px; padding: 9px 10px; font-family: inherit; font-size: .95rem; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; background: var(--bg); color: var(--text); border: 1px solid rgba(255,255,255,.14); font-weight: 500; padding: 9px 4px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.fine { font-size: .78rem; color: var(--muted); margin: 8px 0 0; }
.life { font-size: .8rem; color: var(--muted); text-align: center; margin-top: 10px; }

/* ---------- cards ---------- */
.red { color: var(--red); } .blue { color: var(--blue); } .green { color: var(--green); } .black { color: var(--black); }
.card { position: relative; width: var(--cw); height: var(--ch); flex: none; background: #fff; border-radius: 8px; border: 2px solid transparent;
  padding: 0; margin: 0; font-weight: 700; text-align: left; box-shadow: 0 1px 3px rgba(0,0,0,.45); transition: transform .15s, box-shadow .15s, border-color .15s; }
.card .idx { position: absolute; left: 3px; top: 2px; display: flex; flex-direction: column; align-items: center; line-height: 1; font-size: calc(var(--cw) * .3); }
.card .idx i { font-style: normal; font-size: .95em; }
.card .pip { position: absolute; right: 3px; bottom: 1px; font-size: calc(var(--cw) * .6); line-height: 1; opacity: .9; }
.card.sel { transform: translateY(-14px); border-color: var(--gold); box-shadow: 0 8px 16px rgba(0,0,0,.5); z-index: 5; }
.card.eatenc { border-color: var(--gold); background: #fff8e1; }
.card.eatenc::after { content: 'eaten'; position: absolute; left: 3px; bottom: 2px; font-size: 9px; font-weight: 600; color: #8a6100; }
.card.preview { box-shadow: 0 0 0 2px #34d399, 0 0 12px 2px rgba(52,211,153,.8); }
.card.hint { box-shadow: 0 0 0 2px #60a5fa, 0 0 12px 3px rgba(96,165,250,.9); }
.card.newc { animation: newglow 1.4s ease-out 1; }
.card.deal { animation: dealin .35s ease-out both; }
.card .bar { position: absolute; left: 0; right: 0; bottom: -6px; height: 4px; border-radius: 2px; }
@keyframes newglow { 0% { box-shadow: 0 0 0 3px #fff, 0 0 18px 5px var(--gold); } 100% { box-shadow: 0 1px 3px rgba(0,0,0,.45); } }
@keyframes dealin { from { transform: translateY(-30px) scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }

.mc { display: inline-flex; flex: none; align-items: center; justify-content: center; width: var(--mw, 22px); height: var(--mh, 31px); background: #fff; border-radius: 4px;
  font-size: var(--mf, 10px); font-weight: 700; line-height: 1; border: 1px solid rgba(0,0,0,.2); gap: 0; flex-direction: column; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.mc i { font-style: normal; font-size: 1.05em; }
.mc.eatenc { border-color: var(--gold); background: #fff8e1; }
.mc.back, .card.back { background: repeating-linear-gradient(45deg, #1d4ed8 0 4px, #1e3a8a 4px 8px); border: 2px solid #fff; color: transparent; }
.mc.empty { background: transparent; border: 1px dashed rgba(255,255,255,.22); box-shadow: none; }
.mc.sm { --mw: 16px; --mh: 23px; --mf: 8px; }

/* ---------- seats ---------- */
.seats { display: grid; gap: 8px; margin: 10px 0 8px; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); }
.seat, .me { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 7px; min-width: 0; transition: box-shadow .2s, border-color .2s; }
.seat.turn, .me.turn { border-color: var(--accent); animation: glow 1.3s ease-in-out infinite; }
@keyframes glow { 0%,100% { box-shadow: 0 0 6px 1px rgba(16,185,129,.5); } 50% { box-shadow: 0 0 16px 4px rgba(16,185,129,.9); } }
.s-head { display: flex; align-items: center; gap: 4px; justify-content: space-between; }
.s-name { font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-badges { display: flex; gap: 3px; flex-wrap: wrap; min-height: 15px; margin-top: 1px; }
.s-sub { display: flex; justify-content: space-between; font-size: .68rem; color: var(--muted); margin-top: 1px; gap: 4px; }
.bal { font-weight: 600; color: #6ee7b7; } .bal.neg { color: var(--rose); } .bal.zero { color: var(--muted); }
.badge { display: inline-block; font-size: .6rem; padding: 1px 5px; border-radius: 8px; background: rgba(244,193,80,.18); color: var(--gold); font-weight: 600; white-space: nowrap; }
.badge.b2 { background: rgba(96,165,250,.18); color: #93c5fd; }
.s-hand { display: flex; align-items: center; margin: 6px 0 4px; min-height: 31px; }
.s-hand .mc + .mc { margin-left: -14px; }
.s-hand em { font-style: normal; font-weight: 700; margin-left: 6px; font-size: .95rem; }
.s-row { display: flex; gap: 2px; flex-wrap: wrap; min-height: 18px; align-items: center; margin-top: 3px; }
.s-row .lab { font-size: .56rem; color: var(--muted); width: 100%; text-transform: uppercase; letter-spacing: .4px; }
.laid { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.meld { display: inline-flex; gap: 1px; padding: 2px; border-radius: 6px; background: rgba(255,255,255,.06); align-self: flex-start; transition: background .15s, box-shadow .15s; max-width: 100%; flex-wrap: wrap; }
.meld.target { background: rgba(52,211,153,.28); box-shadow: 0 0 0 2px #34d399; cursor: pointer; animation: glow 1.1s infinite; }
.meld.flash { animation: flash 1s ease-out 1; }
@keyframes flash { 0% { background: rgba(244,193,80,.7); } 100% { background: rgba(255,255,255,.06); } }
.me { margin-top: 8px; }
.me .s-row { margin-top: 4px; }

/* ---------- felt ---------- */
.felt { background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt2) 100%); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; min-height: 128px; }
.slot { text-align: center; font-size: .68rem; color: #b9d8cc; }
.slot .big { margin: 0 auto 3px; }
#pile { position: relative; width: var(--cw); height: var(--ch); margin: 0 auto 3px; }
#pile .card.back { position: absolute; left: 0; top: 0; }
#pile .card.back:nth-child(2) { left: 2px; top: -2px; } #pile .card.back:nth-child(3) { left: 4px; top: -4px; }
#pile .cnt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 1.1rem; z-index: 4; text-shadow: 0 1px 3px #000; }
#up { width: var(--cw); height: var(--ch); margin: 0 auto 3px; border-radius: 8px; border: 2px dashed rgba(255,255,255,.25); }
#up .card { margin: -2px; }
#up.eatable { animation: eatpulse .9s ease-in-out infinite; border-color: transparent; }
#up.eatable .card { border-color: var(--gold); }
@keyframes eatpulse { 0%,100% { box-shadow: 0 0 6px 2px rgba(244,193,80,.6); } 50% { box-shadow: 0 0 22px 8px rgba(244,193,80,1); } }
.statusbox { flex: 1 1 150px; min-width: 130px; text-align: center; }
#status { font-weight: 500; font-size: .92rem; min-height: 2.6em; }
#status .en { display: block; font-size: .74rem; color: #b9d8cc; font-weight: 300; }
#eatbanner { display: none; margin-top: 4px; padding: 4px 8px; border-radius: 8px; background: var(--gold); color: #3a2a00; font-weight: 700; font-size: .8rem; }
#eatbanner.show { display: inline-block; animation: pop .35s ease-out; }
#nobanner { font-size: .7rem; color: #9fb8ae; margin-top: 4px; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ---------- my hand ---------- */
#hand { display: flex; justify-content: center; align-items: flex-end; padding: 18px 0 12px; min-height: calc(var(--ch) + 30px); }
.handinfo { text-align: center; font-size: .78rem; color: var(--muted); min-height: 1.3em; }
.handinfo b { color: var(--gold); }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.actions .full { grid-column: 1 / -1; }
.actions.tools { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 6px; }
.actions.tools button { padding: 8px 4px; font-size: .8rem; }
button.pulse { animation: btnpulse .9s ease-in-out infinite; }
@keyframes btnpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(244,193,80,.7); } 50% { box-shadow: 0 0 0 8px rgba(244,193,80,0); } }
#log { margin-top: 12px; text-align: left; background: var(--panel2); color: #6ee7b7; padding: 8px 10px; font-family: ui-monospace, monospace; height: 92px; overflow-y: auto; font-size: .74rem; border-radius: 9px; border: 1px solid rgba(255,255,255,.06); }
#log div { margin: 1px 0; }

/* ---------- toast / fx / modal ---------- */
#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #000d; color: #fff; padding: 8px 14px; border-radius: 20px; font-size: .85rem; z-index: 300; max-width: 92vw; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.ghost { position: fixed; margin: 0 !important; z-index: 210; will-change: transform; pointer-events: none; }
.ubanner { position: fixed; top: 38%; left: 0; right: 0; text-align: center; font-size: 3.2rem; font-weight: 700; color: var(--gold); text-shadow: 0 0 24px #000, 2px 2px 6px #000; z-index: 220; animation: pop .5s ease-out; pointer-events: none; }
.ubanner small { display: block; font-size: 1rem; color: #fff; font-weight: 400; }

.modal { position: fixed; inset: 0; background: rgba(8,12,20,.82); z-index: 250; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 16px; }
.modal .sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; width: 100%; max-width: 720px; margin: auto 0; text-align: left; }
.modal h2 { font-size: 1.15rem; color: var(--gold); }
.modal h3 { font-size: .95rem; color: var(--gold); margin-top: 14px; }
.modal p, .modal li { font-size: .88rem; line-height: 1.5; color: #d5deee; margin: 5px 0; }
.modal ul { padding-left: 20px; margin: 4px 0; }
.modal .close { float: right; width: auto; padding: 6px 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .82rem; margin: 6px 0; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 5px 7px; text-align: left; vertical-align: top; }
.tbl th { background: rgba(255,255,255,.05); font-weight: 600; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }
.sumrow .melds { display: flex; flex-wrap: wrap; gap: 3px; }
.place { font-weight: 700; color: var(--gold); white-space: nowrap; }
.pos { color: #6ee7b7; font-weight: 600; } .neg { color: var(--rose); font-weight: 600; }
.btnrow { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; } .btnrow button { flex: 1; min-width: 130px; }

@media (min-width: 720px) {
  :root { --cw: 62px; --ch: 90px; }
  .mc { --mw: 30px; --mh: 43px; --mf: 13px; } .mc.sm { --mw: 22px; --mh: 31px; --mf: 10px; }
  .s-hand .mc + .mc { margin-left: -18px; }
  .s-name { font-size: 1rem; } .s-sub { font-size: .76rem; }
  .actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .actions .full { grid-column: auto; }
  h1 { font-size: 2.1rem; }
}
@media (max-width: 400px) {
  .seats { gap: 5px; } .seat { padding: 5px; }
  .s-name { font-size: .78rem; }
  .mc { --mw: 19px; --mh: 27px; --mf: 9px; }
  .s-hand .mc + .mc { margin-left: -12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }

/* ---------- round summary list ---------- */
.slist { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.srow { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.srow.mine { border-color: var(--accent); }
.shead { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.shead .sname { flex: 1; min-width: 60px; }
.shead .spts { color: var(--muted); font-size: .8rem; }
.shead .sround { font-weight: 700; font-size: 1.05rem; min-width: 2ch; text-align: right; }
.sdet { margin: 2px 0 6px !important; }
.sc { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; margin-top: 4px; }
.sc .lab { width: 5.2em; font-size: .62rem; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.sc .meld { flex-wrap: nowrap; }
