/* Pinoy Mahjong — senior-friendly, big 3D tiles */
:root {
  --scale: 1;
  --felt: #0d5a37;
  --felt-dark: #083822;
  --gold: #ffcf3f;
  --ink: #1d1b16;
  --balls: #1456b8;
  --sticks: #13803a;
  --chars: #c4231f;
  --tw-hand: max(40px, min(calc((100vw - 40px) / 18.2), calc(84px * var(--scale))));
  --tw-opp: calc(24px * var(--scale));
  --tw-disc: calc(32px * var(--scale));
  --tw-last: calc(84px * var(--scale));
  --tw-meld: calc(38px * var(--scale));
  font-size: calc(20px * var(--scale));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color: #fff;
  background: radial-gradient(ellipse at 50% 40%, #13744a 0%, var(--felt) 45%, var(--felt-dark) 100%);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; }
[hidden] { display: none !important; }

/* ---------- Screens ---------- */
.screen { display: none; height: 100dvh; }
.screen.active { display: flex; }
.page { overflow-y: auto; }
.page-wrap { max-width: 900px; margin: 0 auto; padding: 24px 20px 60px; width: 100%; }
.page h2 { font-size: 1.8rem; margin: 18px 0; color: var(--gold); }
.page h3 { color: var(--gold); margin-top: 28px; }
.page p, .page li { font-size: 1.15rem; line-height: 1.55; }

/* ---------- Buttons ---------- */
.btn {
  border: 0; border-radius: 16px; padding: 14px 22px; min-height: 64px; min-width: 64px;
  font-weight: 800; font-size: 1.15rem; cursor: pointer; color: var(--ink);
  background: #f4efe1; box-shadow: 0 5px 0 #b9ae8c, 0 8px 14px rgba(0,0,0,.35);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #b9ae8c, 0 3px 6px rgba(0,0,0,.3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(#ffe066, #ffbf1f); box-shadow: 0 5px 0 #b77f00, 0 8px 16px rgba(0,0,0,.4); }
.btn-xl { font-size: 1.7rem; padding: 18px 48px; min-height: 84px; }
.btn-soft { background: #e9f4ee; }
.btn-ghost { background: transparent; color: #fff; box-shadow: none; text-decoration: underline; }
.btn-icon { min-width: 56px; min-height: 56px; padding: 6px; font-size: 1.6rem; }
.btn-todas { background: linear-gradient(#5ef08a, #19b851); font-size: 1.5rem; animation: pulse 1s ease-in-out infinite; box-shadow: 0 5px 0 #0c7a32, 0 0 26px #6bff9a; }
.btn-scud { background: linear-gradient(#ff9f6b, #ff5a1f); color: #fff; box-shadow: 0 5px 0 #a8320a, 0 0 22px #ff8a50; }
.btn-claim { background: linear-gradient(#8fd3ff, #3a9ce8); color: #04223a; box-shadow: 0 5px 0 #1f5f94, 0 8px 14px rgba(0,0,0,.35); }
.btn-pass { background: #ddd; }
@keyframes pulse { 50% { transform: scale(1.07); } }

/* ---------- Home (landing art) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#screen-home { position: relative; background: #0d6fc4 url(img/landing-blur.jpg) center / cover no-repeat; align-items: stretch; overflow: hidden; }
.home-art { flex: none; height: 100dvh; aspect-ratio: 941 / 1672; background: url(img/landing.jpg) center / contain no-repeat; box-shadow: 0 0 60px rgba(0, 0, 0, .5); }
.home-wrap {
  flex: 1 1 auto; margin: auto 0; text-align: center; padding: 24px clamp(16px, 4vw, 48px); max-height: 100dvh; overflow-y: auto;
  background: rgba(4, 44, 24, .82); backdrop-filter: blur(6px); align-self: center; border-radius: 26px; margin-inline: clamp(12px, 3vw, 40px);
  border: 3px solid rgba(255, 207, 63, .7); box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
}
.tagline { font-size: 1.5rem; font-weight: 800; color: var(--gold); margin: 0 0 14px; }
@media (orientation: portrait), (max-width: 760px) {
  #screen-home { flex-direction: column; overflow-y: auto; }
  .home-art { position: absolute; inset: 0; height: auto; aspect-ratio: auto; background-size: 100% auto; background-position: top center; box-shadow: none; }
  .home-wrap { position: relative; margin: auto 10px 10px; margin-top: max(46dvh, 240px); align-self: stretch; flex: none; max-height: none; padding: 16px 14px; }
}
.big-label { display: block; font-size: 1.3rem; margin: 10px 0 8px; }
.big-input { width: min(520px, 90%); font-size: 1.6rem; padding: 14px 18px; border-radius: 14px; border: 3px solid var(--gold); text-align: center; color: var(--ink); }
.chips-line { margin: 14px 0 20px; font-size: 1.25rem; }
.home-row { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin: 22px 0 8px; }
.fineprint { opacity: .8; font-size: 1rem; }

/* ---------- 3D TILE (white traditional face, green back) ---------- */
.tile {
  --w: var(--tw, 56px);
  font-size: var(--w);
  width: 1em; height: 1.38em; flex: 0 0 auto;
  position: relative; border-radius: .13em;
  background: linear-gradient(165deg, #ffffff 0%, #fafaf6 55%, #e9e8e1 100%);
  box-shadow:
    inset 0 .02em 0 #fff, inset 0 -.03em .05em rgba(0, 0, 0, .08),
    0 .015em 0 #e4e3dc, 0 .03em 0 #d9d8cf, 0 .045em 0 #cfcdc2,
    0 .06em 0 #1f8a55, 0 .075em 0 #1b7a4b, 0 .09em 0 #176b41, 0 .105em 0 #135c38,
    0 .16em .18em rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink); user-select: none; transform-style: preserve-3d;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s;
  margin-bottom: .12em;
}
.tile .face { width: 94%; height: 94%; display: block; pointer-events: none; }
.tile.joker {
  background: linear-gradient(165deg, #fffdf0 0%, #fff3c4 60%, #f5d878 100%);
  outline: .04em solid #e2a400;
  box-shadow:
    0 0 .18em .04em rgba(255, 208, 64, .85),
    0 .015em 0 #e6c56a, 0 .03em 0 #d9b552, 0 .045em 0 #c9a23e,
    0 .06em 0 #1f8a55, 0 .075em 0 #1b7a4b, 0 .09em 0 #176b41, 0 .105em 0 #135c38,
    0 .16em .18em rgba(0, 0, 0, .45);
}
.tile.joker::after {
  content: "JOKER"; position: absolute; top: -.02em; left: 50%; transform: translate(-50%, -55%);
  font-size: .16em; font-weight: 900; letter-spacing: .04em; color: #4a2c00;
  background: var(--gold); border-radius: .4em; padding: .05em .35em; box-shadow: 0 .1em .2em rgba(0,0,0,.35);
  white-space: nowrap;
}
.tile.back {
  background: repeating-linear-gradient(45deg, #1f8f59 0 .06em, #1a7d4d .06em .12em);
  box-shadow: inset 0 0 0 .04em #2bb371, 0 .03em 0 #f0e7cd, 0 .06em 0 #e2d6b2, 0 .12em .14em rgba(0,0,0,.4);
}
.tile.back > * { display: none; }

/* ---------- Game layout ---------- */
#screen-game { flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: rgba(0,0,0,.28); flex-wrap: wrap; }
.pill { background: rgba(0,0,0,.35); border-radius: 999px; padding: 6px 16px; font-size: 1.05rem; white-space: nowrap; }
.pill b { color: var(--gold); font-size: 1.2rem; }
.joker-box { display: flex; align-items: center; gap: 10px; background: rgba(255, 207, 63, .16); border: 2px solid var(--gold); border-radius: 16px; padding: 4px 12px 4px 14px; margin-left: auto; }
.joker-box span { font-weight: 900; color: var(--gold); }
#joker-tile .tile { --tw: calc(40px * var(--scale)); animation: shimmer 2s ease-in-out infinite; }
@keyframes shimmer { 50% { filter: brightness(1.15); transform: rotateY(18deg) translateY(-3px); } }

.table {
  flex: 1 1 auto; min-height: 0; display: grid; gap: 6px; padding: 6px 10px; overflow: hidden;
  grid-template-columns: minmax(120px, 18%) 1fr minmax(120px, 18%);
  grid-template-rows: auto 1fr;
  grid-template-areas: "top top top" "left center right";
}
.opp-top { grid-area: top; justify-self: center; }
.opp-left { grid-area: left; }
.opp-right { grid-area: right; }
.center { grid-area: center; display: flex; flex-direction: column; align-items: center; min-height: 0; overflow: hidden; }
.opp {
  background: rgba(0,0,0,.22); border-radius: 16px; padding: 8px 10px; min-width: 0;
  display: flex; flex-direction: column; gap: 6px; border: 3px solid transparent; transition: border-color .2s, box-shadow .2s;
  overflow: hidden; min-height: 0;
}
.opp-top { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 14px; padding: 6px 14px; }
.opp-top .backs { flex-wrap: nowrap; }
.opp.turn, .me.turn { border-color: var(--gold); box-shadow: 0 0 22px rgba(255, 207, 63, .55); }
.opp .who { font-size: 1.1rem; font-weight: 800; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.opp .who .chips { color: var(--gold); }
.opp .backs { display: flex; flex-wrap: wrap; gap: 1px; }
.opp .backs .tile { --tw: var(--tw-opp); margin-right: -4px; }
.opp .count { font-size: .95rem; opacity: .9; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 900; }
.badge-scud { background: #ff5a1f; color: #fff; animation: pulse 1s infinite; }
.badge-mano { background: var(--gold); color: #4a2c00; }
.melds { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.meld { display: flex; gap: 2px; background: rgba(0,0,0,.18); padding: 4px 4px 2px; border-radius: 8px; }
.meld .tile { --tw: var(--tw-meld); }
.opp .meld .tile { --tw: calc(28px * var(--scale)); }
.flowers { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
.flowers .tile { --tw: calc(26px * var(--scale)); }

.status { font-size: 1.35rem; font-weight: 800; text-align: center; padding: 6px 14px; background: rgba(0,0,0,.3); border-radius: 12px; margin-bottom: 6px; min-height: 2.1em; }
.last-discard { min-height: calc(var(--tw-last) * 1.5); display: flex; flex-direction: column; align-items: center; justify-content: center; perspective: 700px; }
.last-discard .tile { --tw: var(--tw-last); animation: tossIn .55s cubic-bezier(.2,.9,.25,1.1) both; }
.last-discard .tile.dead { filter: grayscale(.7) brightness(.8); }
.last-discard .cap { font-size: 1.05rem; margin-top: 6px; text-align: center; }
@keyframes tossIn { from { transform: translateY(45vh) rotateX(75deg) rotateZ(30deg) scale(1.5); opacity: 0; } }
.discards { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; overflow-y: auto; max-height: 100%; padding: 4px; }
.discards .tile { --tw: var(--tw-disc); }
.discards .tile.dead { filter: grayscale(.8) brightness(.75); }

.me { background: rgba(0,0,0,.28); padding: 4px 10px 8px; border-top: 3px solid transparent; flex: 0 0 auto; position: relative; z-index: 3; }
.me-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; min-height: 40px; }
.me-info { font-size: 1.2rem; }
.me-info .chips { color: var(--gold); font-weight: 900; }
.hand { display: flex; flex-wrap: nowrap; justify-content: center; gap: 3px; padding: 22px 4px 4px; perspective: 1000px; min-height: calc(var(--tw-hand) * 1.6); }
.hand .tile { --tw: var(--tw-hand); transform: rotateX(16deg); cursor: pointer; }
.hand .tile:hover { transform: rotateX(6deg) translateY(-.06em); }
.hand .tile.sel { transform: translateY(-.26em) rotateX(0deg) scale(1.08); z-index: 2; filter: drop-shadow(0 0 .12em #ffe066); }
.hand .tile.new { margin-left: .35em; animation: newGlow 1s ease-in-out infinite alternate; }
.hand .tile.hint { outline: .05em dashed #ff3b3b; outline-offset: .03em; }
@keyframes newGlow { to { filter: drop-shadow(0 0 .14em #7dffb0); } }
.hand.dealing .tile { animation: dealIn .6s cubic-bezier(.2,.8,.25,1) both; }
@keyframes dealIn { from { transform: translateY(-55vh) rotateX(85deg) rotateZ(-25deg); opacity: 0; } to { transform: rotateX(16deg); opacity: 1; } }
.actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; min-height: 64px; }

/* ---------- Bunot overlay (big, legible draw) ---------- */
.bunot-overlay {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 45%, rgba(0, 0, 0, .45), rgba(0, 0, 0, .85)); perspective: 1400px; cursor: pointer;
}
.bunot-title { font-size: clamp(40px, 9vw, 96px); font-weight: 900; color: var(--gold); text-shadow: 0 5px 0 #7a5200, 0 0 30px rgba(255, 207, 63, .7); margin-bottom: 10px; animation: popIn .45s ease-out both; }
.bunot-overlay .tile { --tw: min(30vh, 30vw); animation: bunotSpin 1.15s cubic-bezier(.18, .85, .25, 1) both; }
.bunot-name { font-size: clamp(32px, 7vw, 76px); font-weight: 900; margin-top: 18px; text-shadow: 0 4px 12px rgba(0,0,0,.6); animation: popIn .5s .6s ease-out both; text-align: center; }
.bunot-sub { font-size: 1.3rem; margin-top: 8px; opacity: .9; animation: popIn .5s .8s both; }
.bunot-rays { position: absolute; width: 140vmax; height: 140vmax; background: repeating-conic-gradient(rgba(255, 207, 63, .13) 0 8deg, transparent 8deg 20deg); animation: spin 12s linear infinite; z-index: -1; }
@keyframes bunotSpin {
  0% { transform: translateY(45vh) rotateY(900deg) rotateX(50deg) scale(.15); opacity: 0; }
  65% { transform: translateY(-3vh) rotateY(-12deg) rotateX(-6deg) scale(1.06); opacity: 1; }
  82% { transform: translateY(1vh) rotateY(6deg) scale(.98); }
  100% { transform: none; }
}
@keyframes popIn { from { transform: scale(.4); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal & toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .6); padding: 12px; }
.modal-card { background: #fbf7ea; color: var(--ink); border-radius: 22px; padding: 20px 22px; max-width: 980px; width: 100%; max-height: 94dvh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: popIn .3s ease-out both; }
.modal-card h2 { margin: 0 0 8px; font-size: 2rem; color: #0d5a37; }
.modal-card .sub { font-size: 1.2rem; margin-bottom: 10px; }
.modal-card .tiles-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 16px; align-items: flex-end; }
.modal-card .tiles-row .tile { --tw: calc(46px * var(--scale)); }
.modal-card table { width: 100%; border-collapse: collapse; font-size: 1.15rem; margin: 8px 0 14px; }
.modal-card td, .modal-card th { padding: 8px 6px; border-bottom: 1px solid #e3dccb; text-align: left; }
.modal-card td.amt, .modal-card th.amt { text-align: right; font-weight: 800; }
.modal-card .plus { color: #0b8a3e; } .modal-card .minus { color: #c4231f; }
.result-grid { display: grid; gap: 0 24px; }
@media (min-width: 760px) { .result-grid { grid-template-columns: 1fr 1fr; } }
.modal-card .row-btns.sticky { position: sticky; bottom: -20px; background: linear-gradient(transparent, #fbf7ea 30%); padding: 18px 0 14px; margin-bottom: -6px; }
.modal-card .row-btns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.claim-tile { display: flex; align-items: center; gap: 18px; justify-content: center; margin: 6px 0 14px; perspective: 800px; }
.claim-tile .tile { --tw: calc(96px * var(--scale)); animation: tossIn .5s both; }
.claim-tile .name { font-size: 1.8rem; font-weight: 900; }
.chow-opt { display: inline-flex; gap: 2px; align-items: center; }
.chow-opt .tile { --tw: calc(30px * var(--scale)); margin: 0; }
.big-banner { font-size: 1.5rem; font-weight: 900; padding: 10px 14px; border-radius: 14px; margin: 10px 0; text-align: center; }
.banner-gold { background: linear-gradient(#ffe57a, #ffc531); color: #4a2c00; }
.banner-gray { background: #e8e2d0; }
.toast {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: rgba(10, 30, 20, .94); border: 3px solid var(--gold); color: #fff; border-radius: 18px;
  padding: 14px 26px; font-size: 1.5rem; font-weight: 900; text-align: center; max-width: 92vw;
  animation: popIn .25s ease-out both; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.toast small { display: block; font-size: 1.05rem; font-weight: 600; margin-top: 4px; color: #ffe9a3; }

/* ---------- Settings / board ---------- */
.settings { display: grid; gap: 18px; }
.settings .field { background: rgba(0,0,0,.22); padding: 14px 16px; border-radius: 14px; }
.settings .field > label, .settings legend { font-weight: 800; font-size: 1.2rem; display: block; margin-bottom: 8px; color: var(--gold); }
.settings select, .settings input[type=text] { font-size: 1.2rem; padding: 10px; border-radius: 10px; min-width: 240px; }
.settings .check { display: flex; align-items: center; gap: 12px; font-size: 1.2rem; margin: 8px 0; }
.settings input[type=checkbox] { width: 30px; height: 30px; }
.board { width: 100%; border-collapse: collapse; font-size: 1.2rem; }
.board th, .board td { padding: 10px 8px; border-bottom: 1px solid rgba(255,255,255,.2); text-align: left; }
.board .amt { text-align: right; color: var(--gold); font-weight: 800; }
.rules-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.rules-table td, .rules-table th { border-bottom: 1px solid rgba(255,255,255,.2); padding: 8px; text-align: left; font-size: 1.1rem; }

/* ---------- Portrait phones ---------- */
@media (orientation: portrait) {
  :root { --tw-hand: max(36px, min(calc((100vw - 40px) / 9.8), calc(84px * var(--scale)))); --tw-last: calc(72px * var(--scale)); --tw-disc: calc(28px * var(--scale)); }
  .table { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: auto 1fr; grid-template-areas: "left top right" "center center center"; }
  .opp-top { justify-self: stretch; }
  .opp .backs { display: none; }
  .hand { flex-wrap: wrap; padding-top: 16px; min-height: 0; }
  .topbar { gap: 6px; } .pill { font-size: .85rem; padding: 4px 10px; }
  .opp { padding: 5px 7px; gap: 3px; border-radius: 12px; }
  .opp .who { font-size: .85rem; gap: 4px; }
  .opp .count { font-size: .75rem; }
  .opp .meld .tile { --tw: calc(18px * var(--scale)); }
  .status { font-size: 1rem; min-height: 0; padding: 4px 10px; }
  .last-discard { min-height: 0; }
  .me-row { min-height: 0; gap: 8px; }
  .me-info { font-size: 1rem; }
  .bunot-overlay .tile { --tw: min(34vh, 52vw); }
  .hide-sm { display: none; }
  .joker-box { margin-left: 0; }
}
@media (max-height: 520px) and (orientation: landscape) {
  :root { --tw-last: calc(58px * var(--scale)); --tw-disc: calc(26px * var(--scale)); --tw-opp: calc(16px * var(--scale)); }
  .btn { min-height: 52px; padding: 8px 16px; }
  .status { font-size: 1.1rem; }
  .hand { padding-top: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Setup scene: piled walls + 3D dice ---------- */
.setup-overlay {
  position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 45%, #14794c 0%, #0b4a2d 60%, #062a19 100%); padding: 10px;
}
.setup-box {
  --sw: clamp(16px, min(3.3vw, 4.6vh), 34px);
  display: grid; gap: 10px; align-items: center; justify-items: center; perspective: 900px;
  grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "top top top" "left center right" "bottom bottom bottom";
  width: min(100%, 1100px);
}
.wb-top { grid-area: top; } .wb-bottom { grid-area: bottom; } .wb-left { grid-area: left; } .wb-right { grid-area: right; }
.wb-center { grid-area: center; text-align: center; min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 10px; }
.wall { display: flex; gap: 2px; }
.wall-v { flex-direction: column; }
.wall .tile { --tw: var(--sw); animation: pileIn .5s cubic-bezier(.2, .8, .25, 1) both; margin: 0; }
.wall-v .tile { width: 1.38em; height: 1em; --tw: calc(var(--sw) * .78); }
.wall .tile.cut { outline: .12em solid var(--gold); box-shadow: 0 0 .5em .15em #ffd54f; transform: translateY(-.25em); }
.wall .tile.dealt-from { filter: brightness(1.35); }
@keyframes pileIn { from { transform: translateY(-40vh) rotateX(70deg); opacity: 0; } }
.setup-msg { font-size: clamp(20px, 2.6vw, 30px); font-weight: 800; line-height: 1.35; }
.setup-msg b { color: var(--gold); }
.big-choice { display: inline-block; margin-top: 8px; padding: 8px 18px; border-radius: 14px; background: var(--gold); color: #3d2600; }
.dice-row { display: flex; gap: 22px; align-items: center; min-height: 100px; perspective: 600px; }
.die {
  width: 88px; height: 88px; border-radius: 18px; padding: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  background: linear-gradient(150deg, #ffffff, #e9e6dc);
  box-shadow: inset 0 -6px 0 #cfc9b8, 0 6px 0 #b3ac98, 0 14px 22px rgba(0, 0, 0, .45);
  transform: rotateX(14deg) rotateZ(-6deg);
}
.die:nth-child(2) { transform: rotateX(14deg) rotateZ(8deg); }
.die span { display: block; border-radius: 50%; }
.die .pip { background: radial-gradient(circle at 35% 35%, #444, #111); }
.die .pip.red { background: radial-gradient(circle at 35% 35%, #ff5a4f, #b01810); }
.die.rolling { animation: dieRoll .22s linear infinite; }
@keyframes dieRoll {
  0% { transform: rotateX(0) rotateY(0) translateY(0); }
  50% { transform: rotateX(180deg) rotateY(90deg) translateY(-18px); }
  100% { transform: rotateX(360deg) rotateY(180deg) translateY(0); }
}
.dice-sum { font-size: 64px; font-weight: 900; color: var(--gold); text-shadow: 0 4px 0 #7a5200; animation: popIn .4s both; }

/* ---------- Money moving ---------- */
.money-float {
  position: fixed; z-index: 49; transform: translate(-50%, -10px); pointer-events: none;
  font-size: clamp(22px, 2.6vw, 32px); font-weight: 900; padding: 2px 12px; border-radius: 999px;
  animation: moneyUp 2.6s ease-out both; white-space: nowrap; box-shadow: 0 6px 14px rgba(0, 0, 0, .4);
}
.money-float.plus { background: #1fbf5b; color: #fff; }
.money-float.minus { background: #d93025; color: #fff; }
@keyframes moneyUp { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -14px) scale(1.1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -70px) scale(1); } }
.pill.bump { animation: popIn .5s; box-shadow: 0 0 0 3px var(--gold); }

/* ---------- Joker method picker & House Rules ---------- */
.method-list { display: grid; gap: 12px; }
.method { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 4px; font-size: 1.3rem; }
.method span { font-weight: 600; font-size: 1rem; }
fieldset.field { border: 0; margin: 0; }
fieldset.field legend { float: left; width: 100%; }
fieldset.field p { font-size: 1.1rem; line-height: 1.5; clear: both; }
fieldset.field .check { clear: both; }
@media (orientation: portrait) {
  .setup-box { --sw: clamp(12px, 4.4vw, 26px); }
  .die { width: 70px; height: 70px; padding: 9px; }
}

/* ---------- SVG icons ---------- */
.ic { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; display: inline-block; }
.btn .ic { margin-right: .15em; }
.btn-icon .ic { width: 1.4em; height: 1.4em; margin: 0; }
h2 .ic, h3 .ic { vertical-align: -0.15em; }
.who-ic .ic { width: 1em; height: 1em; opacity: .9; }
.toast .ic { color: var(--gold); }

/* ---------- Home: three ways to play ---------- */
.home-main { display: grid; gap: 12px; margin-top: 4px; }
.home-main .btn-xl { font-size: 1.45rem; min-height: 72px; padding: 12px 20px; }
#btn-rejoin { width: 100%; margin-bottom: 12px; }

/* ---------- House Rules editor with amounts ---------- */
.rule-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, .12); }
.rule-row.sub { padding-left: 42px; border-bottom: 0; font-size: .95rem; }
.rule-row .check { margin: 0; flex: 1 1 260px; }
.check.fixed { display: flex; align-items: center; gap: 12px; font-size: 1.15rem; }
.check.fixed .ic { color: #7dffb0; }
.amt-in { display: inline-flex; align-items: center; gap: 4px; font-weight: 900; font-size: 1.2rem; color: var(--gold); }
.amt-in input { width: 7ch; font-size: 1.2rem; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--gold); text-align: right; font-weight: 800; color: var(--ink); }
.amt-in.big input { width: 9ch; font-size: 1.6rem; }
.modal-card .amt-in { color: #0d5a37; }
.settings select[data-pace] { min-width: 0; }

/* ---------- Join / lobby ---------- */
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 900; }
.code-card { background: rgba(0, 0, 0, .28); border: 3px solid var(--gold); border-radius: 20px; padding: 16px; text-align: center; margin: 12px 0 20px; }
.code-big { font-size: clamp(40px, 9vw, 72px); font-weight: 900; letter-spacing: .18em; color: var(--gold); line-height: 1.1; }
.fine { opacity: .85; font-size: 1rem; word-break: break-all; }
.seats { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.seat { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: rgba(0, 0, 0, .25); border-radius: 14px; padding: 10px 14px; font-size: 1.25rem; min-height: 64px; }
.seat.empty { opacity: .8; border: 2px dashed rgba(255, 255, 255, .35); }
.badge { background: rgba(255, 255, 255, .16); color: #fff; }
.badge-you { background: #3a9ce8; color: #fff; }
.badge-away { background: #8a8a8a; color: #fff; }
.badge .ic { width: 1em; height: 1em; }
.err { color: #ffb4a8; font-weight: 800; font-size: 1.2rem; }
.menu-col { flex-direction: column; align-items: stretch; }

/* ---------- Admin: top-up requests ---------- */
.admin-reqs { position: fixed; right: 12px; bottom: 12px; z-index: 75; display: grid; gap: 10px; max-width: min(380px, 92vw); }
.admin-req { background: #fbf7ea; color: var(--ink); border: 3px solid var(--gold); border-radius: 18px; padding: 14px 16px; box-shadow: 0 14px 40px rgba(0, 0, 0, .5); animation: popIn .3s both; }
.ar-title { font-weight: 900; color: #0d5a37; font-size: 1.15rem; display: flex; gap: 6px; align-items: center; }
.ar-body { font-size: 1.25rem; margin: 8px 0 12px; }
.ar-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-todas-lite { background: linear-gradient(#5ef08a, #19b851); }

/* ---------- Claim prompt shows your own hand ---------- */
.modal-card.wide { max-width: 1240px; }
.claim-hand-label { font-weight: 800; font-size: 1.1rem; margin-top: 4px; }
.claim-hand { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; padding: 14px 6px 8px; background: #0d5a37; border-radius: 16px; margin: 6px 0 12px; }
.claim-hand .tile { --tw: min(calc((min(100vw, 1240px) - 110px) / 17.5), calc(64px * var(--scale))); }
.claim-hand .tile.match { transform: translateY(-.18em); filter: drop-shadow(0 0 .12em #ffe066); outline: .05em solid #ffcf3f; outline-offset: .02em; }
.claim-hand .tile.dim { opacity: .55; }
.claim-tile { margin: 0 0 6px; }
.rule-row { clear: both; }
fieldset.field legend { float: none; padding: 0; margin-bottom: 6px; }
.rule-row .check input[type=checkbox] { width: 30px; height: 30px; flex: none; }

/* ---------- Blinking avatars ---------- */
.av { position: relative; display: inline-block; flex: none; border-radius: 50%; overflow: hidden; background: #f7eede;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .85), 0 5px 12px rgba(0, 0, 0, .4); vertical-align: middle; }
.av img { width: 100%; height: 100%; display: block; object-fit: cover; }
.av .lid { position: absolute; border-radius: 50%; transform: scaleY(0); transform-origin: 50% 0;
  box-shadow: inset 0 -2px 0 rgba(58, 30, 18, .8); animation: blink var(--blink-period, 5s) var(--blink-delay, 0s) infinite; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(0); } 94.5%, 96% { transform: scaleY(1); } }
.av-sm { width: calc(40px * var(--scale)); height: calc(40px * var(--scale)); }
.av-md { width: calc(54px * var(--scale)); height: calc(54px * var(--scale)); }
.av-lg { width: calc(96px * var(--scale)); height: calc(96px * var(--scale)); }
.av-xl { width: clamp(96px, 16vh, 150px); height: clamp(96px, 16vh, 150px); }
.av.winner { box-shadow: 0 0 0 4px var(--gold), 0 0 26px rgba(255, 207, 63, .8); }
@media (prefers-reduced-motion: reduce) { .av .lid { animation: none; } }

.opp .who { flex-wrap: nowrap; }
.who-txt { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; min-width: 0; }
.me-info { display: flex; align-items: center; gap: 8px; }
.avatar-pick { background: none; border: 0; cursor: pointer; display: inline-flex; flex-direction: column; align-items: center; gap: 6px; color: #fff; font: inherit; padding: 4px; }
.avatar-pick .ap-label { font-size: 1rem; font-weight: 800; text-decoration: underline; }
.join-me { display: flex; align-items: center; gap: 14px; }
.join-me .big-input { flex: 1; }
.av-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(110px * var(--scale)), 1fr)); gap: 14px; justify-items: center; margin-top: 10px; }
.av-choice { background: none; border: 4px solid transparent; border-radius: 50%; padding: 3px; cursor: pointer; }
.av-choice:hover, .av-choice:focus-visible { border-color: #3a9ce8; }
.av-choice.on { border-color: var(--gold); }
.win-head { display: flex; align-items: center; gap: 16px; }
.seat-who { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.claim-tile .av { margin-right: 4px; }
@media (orientation: portrait) { .opp .av-md { width: 34px; height: 34px; } .opp .who { flex-direction: column; align-items: flex-start; } }
