/* Gin (member request, henry: "Add playable PvP gin"). public/gin.js. The table is the letterboard's felt; the cards are
   real paper cards (they stay white in dark mode), and their backs are little indigo letterboards that say FAM. */
.gin, .gin-invite {
  --card: #ffffff;
  --card-ink: #1d2140;
  --card-red: #c0262d;
  --card-edge: #1d214033;
  --gsel: #9aa4ff;       /* your picks, and melds they'd fit on */
  --letter-2: #f5f5f2b8;
}

/* ---------- a card ---------- */
.gc { --cw: 54px; position: relative; flex: none; display: block; width: var(--cw); height: calc(var(--cw) * 1.4); padding: 0; border: 0; border-radius: calc(var(--cw) * .1); background: var(--card); color: var(--card-ink); box-shadow: 0 0 0 1px var(--card-edge), 0 2px 0 #0000004d; font-family: var(--font); letter-spacing: 0; text-transform: none; text-shadow: none; text-align: left; user-select: none; -webkit-user-select: none; }
.gc.red { color: var(--card-red); }
.gc-i { position: absolute; left: 0; top: calc(var(--cw) * .06); width: calc(var(--cw) * .42); display: flex; flex-direction: column; align-items: center; line-height: 1; }
.gc-i b { font-weight: 700; font-size: calc(var(--cw) * .32); letter-spacing: -.04em; }
.gc-i i { font-style: normal; font-size: calc(var(--cw) * .28); margin-top: 1px; }
.gc-p { position: absolute; right: calc(var(--cw) * .1); bottom: calc(var(--cw) * .08); font-size: calc(var(--cw) * .56); line-height: 1; }
.gc-fig { font-weight: 700; font-size: calc(var(--cw) * .5); }
.gc.back { background-color: #3340a0; background-image: repeating-linear-gradient(to bottom, transparent 0 4px, #0000002e 4px 5px); box-shadow: inset 0 0 0 3px #3340a0, inset 0 0 0 4px #f5f5f266, 0 2px 0 #0000004d; display: grid; place-items: center; }
.gc.back span { font: 600 calc(var(--cw) * .24)/1 var(--board); letter-spacing: .12em; text-transform: uppercase; color: var(--letter); transform: rotate(-90deg); text-shadow: 0 1px 0 #000a; }
.gc.sm { --cw: 40px; }
.gc.xs { --cw: 32px; }
.gc.xs .gc-p { display: none; }

/* ---------- seat colours: four far-apart hues, one per seat, so nobody at a table shares a colour ----------
   --c is bright for the felt, --cd is deep for paper (cards, the score sheet, the chat card). No yellow, no periwinkle (that's picks). */
[data-seat="0"] { --c: #ff9a3c; --cd: #c2410c; } /* orange */
[data-seat="1"] { --c: #3fd4e0; --cd: #0e7490; } /* aqua */
[data-seat="2"] { --c: #a3e060; --cd: #3f7d1f; } /* lime */
[data-seat="3"] { --c: #ff7eb6; --cd: #be185d; } /* pink */

/* ---------- the card in the chat: a mini letterboard with a hand fanned on it ---------- */
.gin-invite { margin: 16px 0 8px; }
.gi-who { font-size: 14px; color: #eef0f7; margin: 0 0 5px 2px; text-shadow: 0 1px 2px rgb(0 0 0 / .75), 0 0 8px rgb(0 0 0 / .35); }
.gi-card { display: block; width: min(100%, 330px); padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--paper); color: var(--ink); text-align: left; box-shadow: 0 1px 0 #1d214020; }
.gi-card:disabled { opacity: .6; cursor: default; }
.gi-board { position: relative; display: block; padding: 14px 16px 13px; min-height: 76px; }
.gi-board .row1 { display: block; font-size: 30px; }
.gi-board .row2 { display: block; margin-top: 6px; padding-right: 96px; }
.gi-fan { position: absolute; right: 16px; top: 12px; width: 84px; height: 56px; }
.gi-fan .gc { --cw: 36px; position: absolute; left: 22px; top: 4px; transform-origin: 50% 110%; }
.gi-fan .gc:nth-child(1) { transform: rotate(-16deg) translateX(-14px); }
.gi-fan .gc:nth-child(3) { transform: rotate(16deg) translateX(14px); }
.gi-foot { display: flex; align-items: center; gap: 10px; padding: 11px 16px 12px; }
.gi-seats { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 15px; }
.gi-seat b { color: var(--cd); }
@media (prefers-color-scheme: dark) { .gi-seat b { color: var(--c); } }
.gi-seat span { color: var(--ink-2); }
.gi-cta { flex: none; margin-left: auto; font-weight: 700; font-size: 15px; color: var(--indigo); }
@media (prefers-color-scheme: dark) { .gi-cta { color: var(--ink); } }
.gi-card.turn .gi-cta { background: var(--indigo); color: var(--indigo-ink); padding: 6px 12px; border-radius: 10px; }
.gi-card:active { transform: translateY(1px); }

/* ---------- the overlay ---------- */
.gin { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h); z-index: 30; display: flex; flex-direction: column; background: var(--felt); color: var(--letter); opacity: 0; transition: opacity .18s; overscroll-behavior: contain; }
.gin.in { opacity: 1; }
.gin-top { flex: none; display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px 8px; }
.gin-title { flex: 1; min-width: 0; }
.gin-title .row2 { margin-top: 5px; }
.gin-back, .gin-x { flex: none; width: 44px; height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; color: var(--letter); }
.gin-back { border: 0; background: none; }
.gin:not(.at-table) .gin-back { visibility: hidden; width: 8px; }
.gin-x { border: 2px solid var(--letter); background: none; }
.gin-back svg { width: 26px; height: 26px; } .gin-x svg { width: 20px; height: 20px; }
.gin-body { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 820px; margin: 0 auto; }
.gin :focus-visible { outline: 2px solid var(--letter); outline-offset: 2px; }
.gin .btn.quiet { border-color: #f5f5f266; color: var(--letter); }
.gin .btn:disabled { opacity: .35; }
.gin .wait { pointer-events: none; }

/* ---------- all tables ---------- */
.gin-home { flex: 1; overflow-y: auto; padding: 18px 16px calc(28px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.gh-new { display: flex; align-items: center; gap: 14px; }
.gh-new p { margin: 0; font-size: 15px; color: var(--letter-2); }
.gin-home h3 { margin: 26px 0 8px; font-size: 16px; }
.gh-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid #f5f5f222; }
.gh-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #f5f5f222; }
.gh-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 11px 0; border: 0; background: none; text-align: left; color: inherit; }
.gh-names { display: flex; flex-wrap: wrap; gap: 0 12px; font-weight: 700; }
.gh-names span { color: var(--c); }
.gh-names b { color: var(--letter); font-weight: 400; }
.gh-st { font-size: 14.5px; color: var(--letter-2); }
.gh-btn { flex: none; min-width: 72px; padding: 8px 12px; border-radius: 10px; border: 1.5px solid #f5f5f266; background: none; color: var(--letter); font-weight: 700; font-size: 15px; }
.gh-btn.hot { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.gh-row.turn .gh-st { color: var(--letter); font-weight: 700; }
.gh-empty { color: var(--letter-2); margin-top: 26px; }
.gh-rules { margin-top: 30px; border-top: 1px solid #f5f5f222; padding-top: 14px; max-width: 64ch; }
.gh-rules summary { font-weight: 700; cursor: pointer; padding: 6px 0; }
.gh-rules p { color: var(--letter-2); font-size: 15.5px; margin: 10px 0; }
.gh-rules b { color: var(--letter); }

/* ---------- seats (before the first deal) ---------- */
.gin-seats { flex: 1; overflow-y: auto; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 24px; }
.gs-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gs-seat { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px 14px; border-radius: 12px; background: #f5f5f20f; text-align: center; }
.gs-seat .mface { width: 64px; height: 64px; }
.gs-seat .mface img, .gs-seat .mface svg { width: 100%; height: 100%; display: block; }
.gs-seat b { color: var(--c, var(--letter)); }
.gs-seat:not(.empty) { box-shadow: inset 0 -4px 0 var(--c); }
.gs-seat span:not(.mface) { font-size: 13.5px; color: var(--letter-2); }
.gs-seat.empty { background: none; border: 1.5px dashed #f5f5f240; }
.gs-seat.empty b { color: var(--letter-2); font-weight: 400; }
.gs-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.gs-note { flex-basis: 100%; margin: 4px 0 0; font-size: 15px; color: var(--letter-2); }

/* ---------- at the table ---------- */
.g-chips { flex: none; display: flex; gap: 6px; padding: 10px 12px 4px; overflow-x: auto; scrollbar-width: none; }
.g-chip { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 7px; padding: 4px 8px 4px 4px; border-radius: 12px; border: 1.5px solid transparent; }
.g-chip .mface { flex: none; width: 36px; height: 36px; }
.g-chip .mface img, .g-chip .mface svg { width: 100%; height: 100%; display: block; }
.g-chip-t { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.g-chip-t b { font-size: 14.5px; color: var(--c); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-chip-t > span { display: flex; align-items: center; gap: 7px; font-size: 14px; }
.g-count { font-style: normal; font-size: 12.5px; color: var(--letter-2); display: inline-flex; align-items: center; gap: 3px; }
.g-count::before { content: ""; width: 8px; height: 11px; border-radius: 2px; background: #3340a0; box-shadow: 0 0 0 1px #f5f5f266; }
.g-chip { box-shadow: inset 0 -3px 0 var(--c); }
.g-chip.turn { border-color: var(--letter); background: #f5f5f214; }
.g-last { flex: none; padding: 4px 16px 0; min-height: 1.4em; font-size: 14px; color: var(--letter-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.g-piles { flex: none; display: flex; align-items: flex-end; gap: 14px; padding: 10px 0 10px 14px; }
.g-stock { position: relative; flex: none; padding: 0; border: 0; background: none; border-radius: 6px; }
.g-stock .gc { --cw: 48px; }
.g-stock .g-left { position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); padding: 0 6px; border-radius: 8px; background: var(--felt); color: var(--letter); font-size: 12.5px; font-weight: 700; line-height: 16px; }
.g-stock:disabled { cursor: default; }
.g-stock.empty { width: 48px; height: 67px; border-radius: 5px; border: 1.5px dashed #f5f5f240; display: grid; place-items: center; }
.g-piles.pickable .g-stock:not(:disabled) .gc { box-shadow: inset 0 0 0 3px #3340a0, inset 0 0 0 4px #f5f5f266, 0 0 0 3px var(--gsel); }
.g-discard { flex: 1; min-width: 0; display: flex; align-items: flex-end; overflow-x: auto; padding: 10px 14px 4px 2px; scrollbar-width: none; min-height: 81px; }
.g-discard::-webkit-scrollbar, .g-chips::-webkit-scrollbar { display: none; }
.g-discard .gc { --cw: 48px; }
.g-discard .gc + .gc { margin-left: -26px; }
.g-discard .gc.picked { transform: translateY(-9px); box-shadow: 0 0 0 3px var(--gsel), 0 2px 0 #0000004d; }
.g-empty { font-size: 13px; color: var(--letter-2); align-self: center; }
.g-discard > .g-empty { height: 67px; display: grid; place-items: center; padding: 0 14px; border-radius: 5px; border: 1.5px dashed #f5f5f240; }

.g-melds { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 14px 8px; border-top: 1px solid #f5f5f21c; -webkit-overflow-scrolling: touch; }
.g-none { color: var(--letter-2); font-size: 14.5px; margin: 12px 0; }
.g-group { margin-top: 8px; }
.g-owner { font-size: 13.5px; font-weight: 700; color: var(--c); margin-bottom: 4px; }
.g-row { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.g-meld { display: flex; padding: 4px; border: 1.5px solid transparent; border-radius: 8px; background: none; }
.g-meld .gc + .gc { margin-left: -19px; }
/* who scores each card on the table: a stripe in their seat colour */
.g-meld .gc::after { content: ""; position: absolute; left: 3px; right: 3px; bottom: 2px; height: 4px; border-radius: 2px; background: var(--cd); }
.g-meld.fits { border-color: var(--gsel); background: #9aa4ff26; }

.g-bar { flex: none; padding: 8px 12px 6px; border-top: 1px solid #f5f5f21c; }
.g-hint { font-size: 15px; line-height: 1.35; min-height: 2.7em; color: var(--letter); }
.g-acts { display: flex; align-items: center; gap: 8px; margin-top: 6px; min-height: 44px; }
.g-acts .sp { flex: 1; }
.g-acts .btn { padding: 10px 16px; }
.g-sort { border: 0; background: none; color: var(--letter-2); font-size: 14.5px; text-decoration: underline; padding: 8px 2px; }

.g-hand { flex: none; --hw: 54px; --step: 30px; display: flex; flex-wrap: wrap; justify-content: center; padding: 16px 10px calc(12px + env(safe-area-inset-bottom)); }
.g-hand { position: relative; }
.g-hand .gc { --cw: var(--hw); margin-left: calc(var(--step) - var(--hw)); transition: transform .14s cubic-bezier(.2, .8, .2, 1), translate .18s cubic-bezier(.2, .8, .2, 1); }
.g-hand.mine .gc { touch-action: none; -webkit-touch-callout: none; cursor: grab; }
.g-hand .gc.rowstart { margin-left: 0; }
.g-hand .gc.sel { transform: translateY(-14px); box-shadow: 0 0 0 3px var(--gsel), 0 2px 0 #0000004d; z-index: 1; }
.g-hand .gc.fresh::before { content: ""; position: absolute; top: -5px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--gsel); }
.g-hand .gc.must { box-shadow: 0 0 0 2px var(--felt), 0 0 0 4px var(--gsel), 0 2px 0 #0000004d; }
.g-hand .gc.must.sel { box-shadow: 0 0 0 3px var(--gsel), 0 2px 0 #0000004d; }
.g-hand.watching { min-height: calc(12px + env(safe-area-inset-bottom)); padding: 0; }
.g-hand .gc.drag { z-index: 5; transform: scale(1.08) rotate(-3deg); transition: transform .14s cubic-bezier(.2, .8, .2, 1); box-shadow: 0 0 0 1px var(--card-edge), 0 12px 20px #00000066; cursor: grabbing; }
.g-hand .gc.drag.sel, .g-hand .gc.drag.must { box-shadow: 0 0 0 3px var(--gsel), 0 12px 20px #00000066; }
.g-hand .rowbreak { flex-basis: 100%; height: 6px; }

/* ---------- scores between hands ---------- */
.gin-scores { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
.sc-sheet { background: var(--card); color: var(--card-ink); border-radius: 4px; padding: 14px 16px 10px; }
.sc-head { font-size: 21px; font-weight: 700; line-height: 1.2; }
.sc-sub { font-size: 14.5px; color: #5b6079; margin-top: 3px; }
.sc-list { list-style: none; margin: 10px 0 0; padding: 0; }
.sc-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid #cfd5de; }
.sc-row .mface { flex: none; width: 40px; height: 40px; }
.sc-row .mface img, .sc-row .mface svg { width: 100%; height: 100%; display: block; }
.sc-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sc-mid b { color: var(--cd); }
.sc-mid > span { font-size: 14px; color: #5b6079; }
.sc-left { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; }
.sc-left .gc { box-shadow: 0 0 0 1px #1d21404d; }
.sc-num { flex: none; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.sc-hand { font-size: 14px; color: #5b6079; }
.sc-num b { font-size: 22px; }
.sc-row.won .sc-num b { color: #3340a0; }
.sc-older { margin: 4px 0 0; padding-top: 10px; border-top: 1px solid #cfd5de; font-size: 13.5px; color: #5b6079; }

@media (min-width: 600px) {
  .g-piles .gc { --cw: 56px; }
  .g-stock.empty, .g-discard > .g-empty { width: 56px; height: 78px; }
  .g-discard .gc + .gc { margin-left: -30px; }
  .gc.sm { --cw: 46px; }
  .g-meld .gc + .gc { margin-left: -22px; }
}
@media (prefers-reduced-motion: reduce) { .gin, .g-hand .gc, .g-hand .gc.drag { transition: none; } }

/* ---------- "your turn" slip: a mini letterboard that drops in and buzzes (gin.js slip) ---------- */
.gin-turn { position: fixed; z-index: 35; left: 50%; top: calc(10px + env(safe-area-inset-top)); width: min(calc(100% - 24px), 380px); padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: none; text-align: left; color: var(--letter); transform: translate(-50%, calc(-100% - 20px - env(safe-area-inset-top))); transition: transform .32s cubic-bezier(.2, .9, .3, 1.2); box-shadow: 0 0 0 1px #f5f5f21f, 0 3px 0 #0000004d; touch-action: none; visibility: hidden; }
.gin-turn.in { transform: translate(-50%, 0); visibility: visible; }
.gin-turn:not(.in) { transition: transform .22s ease-in, visibility 0s .22s; }
.gt-board { position: relative; display: block; padding: 12px 74px 12px 16px; min-height: 64px; }
.gt-board .row1 { display: block; font-size: 24px; }
.gt-board .row2 { display: block; margin-top: 5px; font-size: 14px; }
.gt-card { position: absolute; right: 18px; top: 50%; margin-top: -24px; transform: rotate(9deg); }
.gt-card .gc { --cw: 34px; }
.gin-turn.shake .gt-board { animation: gt-buzz .42s .3s linear 1; }
.gin-turn.shake .gt-card { animation: gt-tap .42s .3s ease-out 1; }
@keyframes gt-buzz { 0%, 100% { transform: none; } 10%, 30%, 60%, 80% { transform: translateX(-3px); } 20%, 40%, 70%, 90% { transform: translateX(3px); } 50% { transform: none; } }
@keyframes gt-tap { 0%, 100% { transform: rotate(9deg); } 25% { transform: rotate(-6deg) translateY(-3px); } 60% { transform: rotate(14deg); } }
.gin-turn:active .gt-board { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) { .gin-turn, .gin-turn:not(.in) { transition: none; } .gin-turn.shake .gt-board, .gin-turn.shake .gt-card { animation: none; } }
/* at the table the slip lands on the felt header, so it gets the periwinkle "your move" ring and a deeper shadow to lift off it */
.gin-turn.here { box-shadow: 0 0 0 2px var(--gsel, #9aa4ff), 0 10px 22px #00000080; }

/* Nudges (henry: "Add a button in all turn based games to send a notif to whoever's turn it is"): the Nudge button sits
   where your moves would go while you wait; whoever's turn it is gets the "your turn" slip, with the nudger's head on a disk. */
.nudge-btn.wait { pointer-events: none; opacity: .6; }
.nudge-slip { z-index: 40; }
.gt-face { position: absolute; right: 16px; top: 50%; width: 46px; height: 46px; margin-top: -23px; border-radius: 50%; background: var(--letter, #f5f5f2); overflow: hidden; transform: rotate(-6deg); }
.gt-face .mface { display: block; width: 100%; height: 100%; }
.gt-face .mface img, .gt-face .mface svg { display: block; width: 100%; height: 100%; object-fit: cover; }
.gt-face .mface.flat svg { padding: 3px; }
.gin-turn.shake .gt-face { animation: gt-tap .42s .3s ease-out 1; }
@media (prefers-reduced-motion: reduce) { .gin-turn.shake .gt-face { animation: none; } }
