:root {
  --felt: #0f5a3c;
  --felt-dark: #0a3a27;
  --gold: #f5b700;
  --gold-deep: #c98a00;
  --ink: #1d1d1f;
  --paper: #fffdf6;
  --panel: rgba(8, 30, 21, 0.78);
  --text: #f4f1e8;
  --muted: #b9c8bf;
  --stars: #d49a00;
  --hearts: #d6283a;
  --clubs: #1f9a53;
  --spades: #1d1d1f;
  --diamonds: #1f6fd1;
  --cw: 70px;
  --ch: 100px;
  --pw: 64px;
  --ph: 92px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--felt-dark);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
input { -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- shared bits ---------- */
.screen { position: fixed; inset: 0; }
#home, #lobby {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: radial-gradient(ellipse at 50% 20%, #177a52 0%, var(--felt) 40%, var(--felt-dark) 100%);
}
.home-wrap { max-width: 560px; margin: 0 auto; padding: 24px 16px 48px; }
.brand { text-align: center; margin: 8px 0 20px; }
.brand h1 { font-family: Georgia, "Times New Roman", serif; font-size: 44px; margin: 8px 0 0; letter-spacing: 1px; text-shadow: 0 3px 0 rgba(0,0,0,.3); }
.brand h1 em { color: var(--gold); font-style: normal; }
.brand.small h1 { font-size: 30px; }
.brand .tag { margin: 4px 0 0; color: var(--muted); font-style: italic; }
.brand-fan { position: relative; height: 70px; width: 150px; margin: 0 auto; }
.brand-fan span {
  position: absolute; left: 55px; top: 4px; width: 42px; height: 60px; border-radius: 6px;
  background: var(--paper); border: 2px solid var(--gold); transform-origin: 50% 110%;
  box-shadow: 0 3px 8px rgba(0,0,0,.35);
}
.brand-fan span::after { content: "♛"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; }
.brand-fan span:nth-child(1) { transform: rotate(-30deg); } .brand-fan span:nth-child(1)::after { color: var(--stars); }
.brand-fan span:nth-child(2) { transform: rotate(-15deg); } .brand-fan span:nth-child(2)::after { color: var(--hearts); }
.brand-fan span:nth-child(3) { transform: rotate(0deg); }   .brand-fan span:nth-child(3)::after { color: var(--clubs); }
.brand-fan span:nth-child(4) { transform: rotate(15deg); }  .brand-fan span:nth-child(4)::after { color: var(--spades); }
.brand-fan span:nth-child(5) { transform: rotate(30deg); }  .brand-fan span:nth-child(5)::after { color: var(--diamonds); }

.panel { background: var(--panel); border: 1px solid rgba(255,255,255,.08); border-radius: 16px; padding: 16px; margin: 14px 0; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.panel h2 { margin: 0 0 8px; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.hint { color: var(--muted); margin: 6px 0; }
.hint.small { font-size: 13px; }
.field { display: block; margin: 8px 0 4px; }
.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.field input { width: 100%; font-size: 20px; padding: 12px 14px; border-radius: 12px; border: 2px solid rgba(255,255,255,.15); background: rgba(0,0,0,.3); color: var(--text); outline: none; }
.field input:focus { border-color: var(--gold); }
.row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.row.center { justify-content: center; }
.center { text-align: center; }

.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-size: 17px; font-weight: 700; background: rgba(255,255,255,.12); }
.btn:active { transform: translateY(1px); }
.btn.gold { background: linear-gradient(#ffd24a, var(--gold) 50%, var(--gold-deep)); color: #3a2800; box-shadow: 0 3px 0 #8a5d00; }
.btn.gold:disabled { filter: grayscale(.8); opacity: .6; }
.btn.big { width: 100%; font-size: 20px; padding: 14px; }
.btn.ghost { background: transparent; border: 2px solid rgba(255,255,255,.25); }
.btn.danger { background: #a3242f; }
.btn.small { padding: 8px 12px; font-size: 15px; }
.linkish { display: block; margin: 16px auto 0; background: none; border: 0; color: var(--gold); text-decoration: underline; font-size: 15px; }

.count-picker { display: flex; gap: 8px; margin: 8px 0 14px; }
.count-picker button { flex: 1; font-size: 22px; font-weight: 700; padding: 10px 0; border-radius: 12px; border: 2px solid rgba(255,255,255,.2); background: rgba(0,0,0,.25); }
.count-picker button.on { border-color: var(--gold); background: rgba(245,183,0,.2); color: var(--gold); }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #4be08c; box-shadow: 0 0 8px #4be08c; animation: pulse 1.6s infinite; }
.game-list { display: flex; flex-direction: column; gap: 8px; }
.game-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: rgba(255,255,255,.06); }
.game-item .gi-main { flex: 1; min-width: 0; }
.game-item .gi-title { font-weight: 700; font-size: 17px; }
.game-item .gi-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-item .code { font-family: ui-monospace, Menlo, Consolas, monospace; background: rgba(0,0,0,.35); padding: 2px 6px; border-radius: 6px; font-size: 13px; margin-left: 6px; }

.code-row { display: flex; align-items: baseline; justify-content: space-between; }
.code-row strong { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 30px; color: var(--gold); letter-spacing: 4px; }
.seat-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.seat-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.06); }
.seat-list li.empty { opacity: .5; border: 2px dashed rgba(255,255,255,.2); background: transparent; }
.seat-list .avatar { width: 34px; height: 34px; font-size: 16px; }
.seat-list .nm { flex: 1; font-weight: 700; font-size: 17px; }
.seat-list .tag { font-size: 12px; color: var(--muted); }
.seat-list .mini-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; background: rgba(255,255,255,.12); font-size: 16px; }
.seat-list .mini-btn:disabled { opacity: .25; }

.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 18px; border: 2px solid rgba(255,255,255,.9); box-shadow: 0 2px 6px rgba(0,0,0,.4); flex: none; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.offline .avatar { filter: grayscale(1) brightness(.7); }

/* ---------- table ---------- */
#table { overflow: hidden; touch-action: none; }
.felt {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(255,255,255,.10), transparent 60%),
    repeating-radial-gradient(circle at 30% 30%, rgba(0,0,0,.025) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at 50% 40%, #1a7a50 0%, var(--felt) 45%, var(--felt-dark) 100%);
}
.topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 6px calc(10px + var(--safe-r)) 0 calc(10px + var(--safe-l)); z-index: 5; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.round-info { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.wild-pill { background: linear-gradient(#ffd24a, var(--gold-deep)); color: #3a2800; padding: 4px 14px; border-radius: 999px; font-size: 19px; font-weight: 900; box-shadow: 0 0 12px rgba(245,183,0,.6); text-shadow: none; }
.top-buttons { display: flex; gap: 6px; }
.icon-btn { height: 34px; min-width: 34px; padding: 0 8px; border-radius: 10px; border: 0; background: rgba(0,0,0,.35); font-size: 16px; display: flex; align-items: center; gap: 4px; }
.icon-btn span { font-size: 13px; font-weight: 700; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* opponents */
.seat { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; width: 96px; z-index: 2; transition: filter .3s; }
.seat .seat-top { position: relative; }
.seat .name { margin-top: 2px; font-size: 13px; font-weight: 700; max-width: 96px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(0,0,0,.4); padding: 1px 8px; border-radius: 999px; }
.seat .score { font-size: 11px; color: var(--muted); }
.seat .mini-fan { position: relative; height: 26px; width: 70px; margin-top: 2px; }
.seat .mini-fan .mb { position: absolute; bottom: 0; left: 50%; width: 16px; height: 23px; margin-left: -8px; border-radius: 3px; transform-origin: 50% 120%; }
.seat .count { position: absolute; right: -4px; bottom: -2px; background: #fff; color: #222; font-weight: 800; font-size: 11px; border-radius: 999px; padding: 0 5px; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.dealer-chip { position: absolute; left: -10px; top: -6px; width: 20px; height: 20px; border-radius: 50%; background: #fff; color: #222; font-size: 11px; font-weight: 900; display: grid; place-items: center; border: 2px solid var(--gold); box-shadow: 0 1px 4px rgba(0,0,0,.4); z-index: 1; }
.out-crown { position: absolute; left: 50%; top: -20px; transform: translateX(-50%); font-size: 20px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); animation: bob 1.4s ease-in-out infinite; }
.seat.turn .avatar, .me-seat.turn .avatar { box-shadow: 0 0 0 3px var(--gold), 0 0 18px 6px rgba(245,183,0,.75); animation: glow 1.2s ease-in-out infinite; }
.seat.turn .name { background: var(--gold); color: #3a2800; }
.last-turn { font-size: 10px; color: var(--gold); font-weight: 800; letter-spacing: .5px; }

/* center piles */
#center { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); display: flex; gap: 22px; z-index: 1; }
.pile-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pile { position: relative; width: var(--pw); height: var(--ph); border-radius: calc(var(--pw) * .1); }
.pile-label { font-size: 12px; font-weight: 700; color: var(--muted); text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.pile .card { position: absolute; left: 0; top: 0; width: var(--pw); height: var(--ph); }
.discard-pile:empty { border: 2px dashed rgba(255,255,255,.3); }
.pile.can-act { cursor: pointer; }
.pile.can-act::after { content: ""; position: absolute; inset: -6px; border-radius: 12px; border: 3px solid var(--gold); box-shadow: 0 0 18px rgba(245,183,0,.8); animation: pulse 1.2s ease-in-out infinite; pointer-events: none; }
.pile.drop-hot::after { content: ""; position: absolute; inset: -8px; border-radius: 12px; border: 4px solid #fff; box-shadow: 0 0 24px #fff; pointer-events: none; }
.draw-pile .stack-shadow { position: absolute; inset: 0; border-radius: inherit; }

/* status + banner */
.status { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--ch) + 30px + var(--safe-b)); z-index: 3; font-size: 14px; font-weight: 700; padding: 5px 14px; border-radius: 999px; background: rgba(0,0,0,.45); white-space: nowrap; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; }
.status.mine { background: var(--gold); color: #3a2800; box-shadow: 0 0 16px rgba(245,183,0,.7); animation: pop .35s ease-out; }
.status .go-out-btn { margin-left: 8px; }
.out-banner { align-self: center; background: rgba(0,0,0,.5); border: 2px solid var(--gold); border-radius: 12px; padding: 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; max-width: 34vw; text-align: center; }
.out-banner .melds { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.meld { display: flex; }
.meld .card + .card { margin-left: -12px; }

/* me */
.me-seat { position: absolute; left: calc(8px + var(--safe-l)); bottom: calc(var(--ch) + 26px + var(--safe-b)); display: flex; align-items: center; gap: 6px; z-index: 3; }
.me-seat .avatar { width: 34px; height: 34px; font-size: 15px; }
.me-seat .me-name { font-size: 13px; font-weight: 700; line-height: 1.1; }
.me-seat .me-name small { display: block; color: var(--muted); font-weight: 400; }
.me-seat .dealer-chip { left: -6px; top: -6px; }
.me-seat .av-wrap { position: relative; }

.hand-tools { position: absolute; right: calc(8px + var(--safe-r)); bottom: calc(var(--ch) + 26px + var(--safe-b)); display: flex; gap: 6px; align-items: center; z-index: 3; }
.chip { border: 0; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 800; background: rgba(0,0,0,.4); }
.chip:active { background: rgba(245,183,0,.4); }
.hand-points { font-size: 12px; font-weight: 700; color: var(--muted); padding: 0 4px; }

/* hand */
.hand { position: absolute; left: 0; right: 0; bottom: calc(8px + var(--safe-b)); height: calc(var(--ch) + 14px); z-index: 4; }
.hand .card { position: absolute; bottom: 0; width: var(--cw); height: var(--ch); transition: transform .18s ease, left .25s ease, box-shadow .2s; touch-action: none; }
.hand .card.selected { transform: translateY(-18px); box-shadow: 0 0 0 3px var(--gold), 0 8px 18px rgba(0,0,0,.5); }
.hand .card.dragging { opacity: .25; }
.hand .card.fresh { animation: fresh 1.6s ease-out; }
.hand .card.pending, .pile .card.pending { visibility: hidden; }
.drag-ghost { position: fixed; z-index: 50; pointer-events: none; width: var(--cw); height: var(--ch); transform: rotate(4deg) scale(1.08); box-shadow: 0 16px 30px rgba(0,0,0,.5) !important; }
.insert-mark { position: absolute; bottom: 0; width: 4px; height: calc(var(--ch) + 8px); background: var(--gold); border-radius: 4px; box-shadow: 0 0 10px var(--gold); z-index: 20; }

/* ---------- cards ---------- */
.card {
  --w: var(--cw);
  position: relative; border-radius: calc(var(--w) * .1); background: var(--paper);
  box-shadow: 0 1px 0 rgba(0,0,0,.15), 0 3px 8px rgba(0,0,0,.35);
  color: var(--ink); overflow: hidden; font-family: Georgia, "Times New Roman", serif;
  border: 1px solid rgba(0,0,0,.15);
}
.pile .card { --w: var(--pw); }
.card .c-rank { position: absolute; left: 7%; top: 3%; font-weight: 800; font-size: calc(var(--w) * .36); line-height: 1; letter-spacing: -1px; }
.card .c-suit { position: absolute; left: 8%; top: calc(3% + var(--w) * .38); font-size: calc(var(--w) * .26); line-height: 1; }
.card .c-big { position: absolute; left: 0; right: 0; bottom: 8%; text-align: center; font-size: calc(var(--w) * .62); line-height: 1; opacity: .92; }
.card .c-rank-br { position: absolute; right: 7%; bottom: 3%; font-weight: 800; font-size: calc(var(--w) * .2); transform: rotate(180deg); line-height: 1; opacity: .6; }
.card.s-stars { color: var(--stars); }
.card.s-hearts { color: var(--hearts); }
.card.s-clubs { color: var(--clubs); }
.card.s-spades { color: var(--spades); }
.card.s-diamonds { color: var(--diamonds); }
.card.s-stars .c-big { text-shadow: 0 0 1px #8a6200; }
.card.s-joker { background: linear-gradient(135deg, #fff6d8, #ffe08a 40%, #ffc6e0 70%, #c8e4ff); color: #6a1b9a; }
.card.s-joker .c-big { font-size: calc(var(--w) * .55); bottom: 18%; }
.card.s-joker .c-rank { font-size: calc(var(--w) * .17); letter-spacing: 0; writing-mode: vertical-rl; text-orientation: upright; top: 6%; }
.card .c-points { display: none; }

/* wild marker */
.card.wild { border: calc(var(--w) * .045) solid var(--gold); box-shadow: 0 0 0 1px #8a5d00, 0 0 14px rgba(245,183,0,.85), 0 3px 8px rgba(0,0,0,.35); }
.card.wild::before {
  content: "WILD"; position: absolute; right: -24%; top: 10%; width: 80%; transform: rotate(45deg);
  background: linear-gradient(#ffd24a, var(--gold-deep)); color: #3a2800; text-align: center;
  font: 900 calc(var(--w) * .13)/1.5 "Trebuchet MS", sans-serif; letter-spacing: .5px; box-shadow: 0 1px 3px rgba(0,0,0,.35); z-index: 1;
}
.card.wild::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.65) 45%, transparent 60%); background-size: 250% 100%; animation: shimmer 3s linear infinite; pointer-events: none; }
.card .go-out-mark { position: absolute; left: 50%; top: -2px; transform: translateX(-50%); font-size: calc(var(--w) * .28); filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); z-index: 2; animation: bob 1.2s ease-in-out infinite; }

/* card back */
.card.back, .mb {
  background:
    radial-gradient(circle at 50% 50%, rgba(245,183,0,.9) 0 12%, transparent 13%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 4px, transparent 4px 8px),
    linear-gradient(135deg, #3b1f6e, #6a2c91 50%, #2a1552);
  border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.4);
}
.card.back::after { content: "♛"; position: absolute; inset: 0; display: grid; place-items: center; color: #3a2800; font-size: calc(var(--w) * .2); }
.card.back > * { display: none; }

/* small cards (round summary, out banner) */
.mini .card, .card.mini { --w: 30px; width: 30px; height: 43px; border-radius: 4px; }
.mini .card.wild::before { display: none; }
.mini .card .c-big { display: none; }
.mini .card .c-rank-br { display: none; }
.mini .card.wild { border-width: 2px; }

/* flying cards */
#fx { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.fly { position: fixed; left: 0; top: 0; margin: 0; will-change: transform; perspective: 600px; }
.fly .flip { position: absolute; inset: 0; transform-style: preserve-3d; }
.fly .flip > .card { position: absolute; inset: 0; width: 100%; height: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.fly .flip > .card.face { transform: rotateY(180deg); }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 12px; animation: fade .2s ease-out; }
.sheet { position: relative; background: #12301f; border: 1px solid rgba(255,255,255,.12); border-radius: 18px; padding: 16px 18px; max-width: 94vw; max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: rise .25s ease-out; }
.sheet.narrow { width: 420px; }
.sheet.wide { width: 900px; }
.sheet h2 { margin: 0 0 10px; font-family: Georgia, serif; }
.sheet .close { position: absolute; right: 10px; top: 10px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); font-size: 16px; }
.sheet .btn { margin-top: 8px; }
.sheet .btn.ghost, .sheet .btn.danger { width: 100%; }
.toggle { display: flex; gap: 10px; align-items: center; font-size: 15px; margin: 8px 0; }
.toggle input { width: 22px; height: 22px; }
.rules { margin-top: 14px; font-size: 13px; color: var(--muted); }
.rules h3 { color: var(--text); margin: 0 0 4px; font-size: 15px; }
.rules p { margin: 4px 0; }
.claim-list { display: flex; flex-direction: column; gap: 8px; }
.claim-list button { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; border: 0; background: rgba(255,255,255,.08); font-size: 17px; font-weight: 700; text-align: left; }

.score-table-wrap { overflow-x: auto; }
table.scores { border-collapse: collapse; width: 100%; font-size: 14px; }
table.scores th, table.scores td { padding: 5px 8px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.08); white-space: nowrap; }
table.scores th { font-size: 13px; }
table.scores td.rd { color: var(--muted); text-align: left; }
table.scores tr.current td { background: rgba(245,183,0,.12); }
table.scores tr.total td { font-weight: 900; font-size: 16px; border-top: 2px solid rgba(255,255,255,.3); }
table.scores td.zero { color: #4be08c; font-weight: 800; }
table.scores td.leader { color: var(--gold); }
table.scores .th-name { display: inline-flex; align-items: center; gap: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.result-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: rgba(255,255,255,.05); margin-bottom: 6px; }
.result-row.out { background: rgba(245,183,0,.15); border: 1px solid rgba(245,183,0,.5); }
.result-row .who { width: 110px; flex: none; display: flex; align-items: center; gap: 6px; font-weight: 700; }
.result-row .who .avatar { width: 28px; height: 28px; font-size: 13px; }
.result-row .cards { flex: 1; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.result-row .left { display: flex; gap: 3px; padding: 3px; border-radius: 6px; background: rgba(214,40,58,.25); outline: 1px dashed rgba(255,120,120,.6); }
.result-row .pts { width: 70px; text-align: right; font-weight: 900; font-size: 18px; }
.result-row .pts small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.winner-banner { text-align: center; font-size: 22px; margin: 4px 0 12px; }
.winner-banner .big { font-size: 48px; display: block; animation: float 1.4s ease-in-out infinite; }

/* go-out show */
.goout { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: radial-gradient(circle, rgba(245,183,0,.35), rgba(0,0,0,.85) 70%); animation: fade .25s ease-out; }
.goout canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.goout-inner { position: relative; text-align: center; }
.goout-crown { font-size: 22vh; line-height: 1; animation: crownDrop .9s cubic-bezier(.2,1.6,.4,1) both, float 1.6s ease-in-out .9s infinite; filter: drop-shadow(0 0 30px rgba(245,183,0,.9)); }
.goout-name { font-family: Georgia, serif; font-size: 11vh; font-weight: 900; color: #fff; text-shadow: 0 0 20px var(--gold), 0 4px 0 #8a5d00; animation: zoomIn .6s .3s cubic-bezier(.2,1.6,.4,1) both; }
.goout-sub { font-size: 7vh; font-weight: 900; letter-spacing: 6px; color: var(--gold); text-shadow: 0 3px 0 #5a3d00; animation: zoomIn .6s .55s cubic-bezier(.2,1.6,.4,1) both; }
.goout-note { margin-top: 10px; font-size: 3.2vh; color: #fff; opacity: .9; animation: fade .6s 1s both; }
.goout.shake { animation: shake .5s ease-in-out; }

.rotate { display: none; }
@media (orientation: portrait) {
  body.in-game .rotate { display: flex; position: fixed; inset: 0; z-index: 100; flex-direction: column; align-items: center; justify-content: center; background: var(--felt-dark); font-size: 20px; text-align: center; padding: 24px; }
  .rotate-phone { font-size: 80px; animation: turn 2s ease-in-out infinite; }
}

.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 90; background: #222; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700; box-shadow: 0 8px 20px rgba(0,0,0,.5); animation: rise .2s ease-out; max-width: 90vw; }
.toast.err { background: #a3242f; }

.your-turn-flash { position: absolute; inset: 0; z-index: 25; pointer-events: none; box-shadow: inset 0 0 60px 10px rgba(245,183,0,.7); animation: fadeOut 1.2s ease-out forwards; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes glow { 0%,100% { box-shadow: 0 0 0 3px var(--gold), 0 0 10px 3px rgba(245,183,0,.6); } 50% { box-shadow: 0 0 0 3px var(--gold), 0 0 22px 8px rgba(245,183,0,.95); } }
@keyframes bob { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -4px); } }
@keyframes float { 0%,100% { transform: none; } 50% { transform: translateY(-8px); } }
@keyframes crownDrop { from { transform: translateY(-80vh) rotate(-30deg) scale(.4); } to { transform: none; } }
@keyframes zoomIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }
@keyframes fresh { 0% { box-shadow: 0 0 0 3px #fff, 0 0 20px #fff; } 100% { box-shadow: 0 1px 0 rgba(0,0,0,.15), 0 3px 8px rgba(0,0,0,.35); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { 0% { transform: translateX(-50%) scale(.7); } 70% { transform: translateX(-50%) scale(1.08); } 100% { transform: translateX(-50%) scale(1); } }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translate(-8px, 4px); } 40% { transform: translate(8px, -4px); } 60% { transform: translate(-6px, -3px); } 80% { transform: translate(6px, 3px); } }
@keyframes turn { 0%,20% { transform: rotate(0); } 50%,80% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }

/* discard button above the selected card */
.discard-btn { position: absolute; bottom: calc(var(--ch) + 24px); transform: translateX(-50%); z-index: 40; white-space: nowrap; border: 0; border-radius: 999px; padding: 7px 14px; font-weight: 900; font-size: 14px; background: linear-gradient(#ffd24a, var(--gold) 50%, var(--gold-deep)); color: #3a2800; box-shadow: 0 3px 0 #8a5d00, 0 6px 14px rgba(0,0,0,.4); animation: rise .15s ease-out; }
.discard-btn.go { font-size: 16px; padding: 9px 18px; box-shadow: 0 3px 0 #8a5d00, 0 0 24px 6px rgba(245,183,0,.9); animation: rise .15s ease-out, pulse 1s ease-in-out infinite; }
.status button { margin-left: 8px; border: 0; border-radius: 999px; padding: 2px 10px; font-weight: 800; background: var(--gold); color: #3a2800; }

/* round intro */
.round-intro { position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%); text-align: center; z-index: 31; animation: zoomIn .45s cubic-bezier(.2,1.6,.4,1) both; pointer-events: none; }
.round-intro.out { animation: fadeOut .3s ease-in forwards; }
.round-intro .ri-round { font-family: Georgia, serif; font-size: 12vh; font-weight: 900; color: #fff; text-shadow: 0 4px 0 rgba(0,0,0,.35), 0 0 30px rgba(0,0,0,.5); }
.round-intro .ri-wild { display: inline-block; margin-top: 4px; font-size: 5vh; font-weight: 900; padding: 4px 18px; border-radius: 999px; background: linear-gradient(#ffd24a, var(--gold-deep)); color: #3a2800; box-shadow: 0 0 30px rgba(245,183,0,.9); }
.round-intro .ri-dealer { margin-top: 8px; font-size: 3.4vh; font-weight: 700; text-shadow: 0 2px 4px rgba(0,0,0,.6); }
.celebrate { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 70; pointer-events: none; }
.sort-label { font-size: 11px; font-weight: 700; color: var(--muted); }
.chip.on { background: rgba(245,183,0,.35); }

/* game history */
#historyBtn { margin-top: 4px; }
.win-tally { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.win-chip { background: rgba(245,183,0,.15); border: 1px solid rgba(245,183,0,.5); border-radius: 999px; padding: 4px 12px; font-size: 14px; }
.win-chip b { color: var(--gold); margin-left: 4px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item { background: rgba(255,255,255,.06); border-radius: 12px; overflow: hidden; }
.history-item.open { background: rgba(255,255,255,.1); }
.history-item.incomplete .hi-title { color: var(--muted); }
.hi-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.hi-main { flex: 1; min-width: 0; }
.hi-date { font-size: 12px; color: var(--muted); }
.hi-title { font-size: 16px; margin: 2px 0; }
.hi-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi-del { border: 0; background: rgba(0,0,0,.25); border-radius: 10px; width: 36px; height: 36px; font-size: 16px; flex: none; }
.hi-detail { padding: 0 12px 12px; overflow-x: auto; }
#login { overflow-y: auto; background: radial-gradient(ellipse at 50% 20%, #177a52 0%, var(--felt) 40%, var(--felt-dark) 100%); }
.back-link { display: inline-block; color: var(--muted); text-decoration: none; font-weight: 700; font-size: 15px; padding: 4px 0; }
.back-link:active { color: var(--gold); }
/* Pop-ups opened from the round/game results must sit above them */
#scores, #menu { z-index: 65; }
