/* ThePit · Copyright (C) 2026 abel0x
   SPDX-License-Identifier: AGPL-3.0-or-later
   Free software with ABSOLUTELY NO WARRANTY; see LICENSE for the terms. */

/* =========================================================
   Poker 11: offline video poker machine
   The cabinet, the pay table, the five cards with their hold buttons
   and the deal button. The frame, the cards and the chips come from
   shared/css.
   ========================================================= */
:root {
  --rail: clamp(8px, 1.3vh, 13px);
}

/* ----------------------- Top bar on phones ----------------------- */
/* The language stays one tap away in the settings, and the way back to the
   lobby stands in for the table's mark. */
@media (max-width: 600px) {
  .topbar { gap: 8px; padding-inline: 10px; }
  .subtitle,
  .topbar .lang-switch,
  .brand-mark { display: none; }
  .topbar-actions { gap: 6px; }
  .brand { gap: 8px; }
  .brand-text h1 { font-size: 14px; letter-spacing: 2.2px; gap: 6px; }
  .brand-number { min-width: 28px; padding: 2px 5px; }
  .balance-pill { min-width: 0; padding: 4px 10px; }
  .balance-value { font-size: 17px; }
  .icon-btn { width: 36px; height: 36px; }
  .toast { top: 64px; }
}

/* ----------------------- The table ----------------------- */
.table-wrap {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.3vh, 14px);
  padding: clamp(6px, 1.4vh, 20px) clamp(8px, 2vw, 26px);
  padding-bottom: max(clamp(6px, 1.4vh, 16px), env(safe-area-inset-bottom));
  overflow: hidden;
}

.machine {
  position: relative;
  width: min(1180px, 100%);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

/* The cabinet: the pit's felt in a walnut rail, as at the other tables. */
.cabinet {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: grid;
  /* The width of a card; the hand is sized around it. */
  --w: clamp(46px, min(15vw, 15vh), 132px);
  grid-template-rows: auto minmax(0, auto) minmax(calc(var(--w) * 1.4 + 34px), 1fr);
  gap: clamp(6px, 1.4vh, 16px);
  padding: clamp(10px, 1.8vh, 22px) clamp(10px, 2vw, 30px);
  border: var(--rail) solid transparent;
  border-radius: clamp(22px, 4vh, 44px);
  background:
    radial-gradient(ellipse 70% 60% at 30% -10%, rgba(255, 247, 218, .1), transparent 66%) padding-box,
    repeating-linear-gradient(4deg, rgba(255,255,255,.016) 0 1px, transparent 1px 4px) padding-box,
    repeating-linear-gradient(94deg, rgba(0,0,0,.024) 0 1px, transparent 1px 5px) padding-box,
    radial-gradient(130% 110% at 50% 10%, var(--felt-highlight) 0%, var(--felt-1) 26%, var(--felt-2) 64%, var(--felt-edge) 100%) padding-box,
    linear-gradient(142deg, rgba(255,232,164,.3), transparent 24%, rgba(0,0,0,.42) 72%, rgba(255,214,117,.2)) border-box,
    repeating-linear-gradient(102deg, #25160b 0 10px, #52371a 10px 18px, #30200f 18px 29px, #694821 29px 34px) border-box;
  box-shadow:
    inset 0 0 0 1px rgba(241, 211, 130, .18),
    inset 0 0 110px rgba(0, 0, 0, .55),
    inset 0 9px 34px rgba(255, 255, 255, .05),
    0 0 0 1px #0b0704,
    0 0 0 4px rgba(105, 72, 31, .58),
    0 30px 60px rgba(0, 0, 0, .6);
}
.table-rim {
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  pointer-events: none;
  border: 2px solid rgba(225, 190, 99, .5);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.5), 0 1px 0 rgba(255,244,205,.16);
  z-index: 0;
}

/* ----------------------- Banner and plaque ----------------------- */
.felt-head {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: ". banner specs";
  align-items: center;
  gap: 12px;
}

.banner {
  grid-area: banner;
  min-width: 0;
  max-width: min(460px, 52vw);
  pointer-events: none;
  padding: 7px 18px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .42);
  border: 1px solid rgba(217, 182, 95, .35);
  font-weight: 600;
  letter-spacing: 1px;
  font-size: clamp(10.5px, 1.6vh, 14px);
  text-transform: uppercase;
  text-align: center;
  color: var(--gold-bright);
  line-height: 1.3;
  text-wrap: balance;
  transition: background .25s, border-color .25s, color .25s;
}
.banner small {
  display: block;
  margin-top: 1px;
  font-size: .8em;
  letter-spacing: .9px;
  opacity: .78;
}
.banner small:empty { display: none; }
.banner.flash-lose { background: rgba(0, 0, 0, .5); border-color: rgba(226, 104, 95, .55); color: #ffd9d6; }

.table-specs {
  grid-area: specs;
  justify-self: end;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid rgba(205,169,82,.46);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(18,24,20,.78), rgba(5,10,8,.78));
  box-shadow: 0 5px 12px rgba(0,0,0,.3), inset 0 1px rgba(255,255,255,.05);
}
.table-spec { min-width: 50px; padding: 5px 10px 6px; text-align: left; }
.table-spec small {
  display: block;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  color: rgba(232, 202, 125, .62);
}
.table-spec strong {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--cream);
}

/* ----------------------- The pay table ----------------------- */
/* Printed on the glass above the cards: the pays in coins for one to five
   coins, the column of the coins bet lit, the winning row bright. */
.paytable-frame {
  position: relative;
  z-index: 2;
  min-height: 0;
  display: flex;
  justify-content: center;
}
.paytable {
  width: min(720px, 100%);
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid rgba(205, 169, 82, .46);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(10, 16, 13, .78), rgba(3, 8, 6, .82));
  box-shadow: 0 8px 18px rgba(0,0,0,.35), inset 0 1px rgba(255,255,255,.05);
  font-size: clamp(10px, 1.65vh, 15px);
  line-height: 1.22;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}
.paytable thead th {
  padding: 2px 10px;
  font-size: .78em;
  font-weight: 700;
  letter-spacing: 1px;
  color: rgba(232, 202, 125, .62);
  text-align: right;
  border-bottom: 1px solid rgba(205, 169, 82, .25);
}
.paytable tbody th {
  padding: 1px 10px;
  font-weight: 600;
  letter-spacing: .5px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.paytable td {
  padding: 1px 10px;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}
.paytable [data-coins].active { background: rgba(217, 182, 95, .2); color: #fff4cf; }
.paytable thead [data-coins].active { color: #fff4cf; }
.paytable tr[data-category="royalFlush"] td[data-coins="5"] { color: #ffe08a; }
.paytable tr.won th,
.paytable tr.won td { background: linear-gradient(180deg, #f3d985, #c9a24b); color: #2a1d05; }
.paytable tr.won { animation: rowWin 1.1s ease-in-out 3; }
@keyframes rowWin { 50% { filter: brightness(1.25); } }

/* ----------------------- The hand ----------------------- */
.hand {
  position: relative;
  z-index: 2;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--w) * .1);
}
.hand-slot {
  display: grid;
  justify-items: center;
  gap: 6px;
  cursor: pointer;
}
.slot-card {
  width: var(--w);
  height: calc(var(--w) * 1.4);
  border-radius: calc(var(--w) * .105);
  /* An empty place for a card, until the first deal. */
  background: rgba(0, 0, 0, .18);
  box-shadow: inset 0 0 0 1px rgba(217, 182, 95, .22);
  transition: translate .18s ease;
}
.slot-card:has(.card) { background: none; box-shadow: none; }
.slot-card .card.deal-ready { animation: dealIn .3s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes dealIn {
  from { opacity: 0; translate: 0 -40px; }
  to { opacity: 1; translate: 0 0; }
}
body[data-animation-speed="fast"] .slot-card .card.deal-ready { animation-duration: .2s; }
body[data-animation-speed="cinematic"] .slot-card .card.deal-ready { animation-duration: .45s; }

.hold-btn {
  width: var(--w);
  min-height: 26px;
  padding: 3px 2px;
  border-radius: 5px;
  border: 1px solid rgba(217, 182, 95, .36);
  background: linear-gradient(180deg, var(--action-top), var(--action-bottom));
  color: var(--gold-bright);
  font-size: clamp(9.5px, 1.4vh, 12px);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
}
.hold-btn:disabled { cursor: default; opacity: .45; }
.hand-slot.held .slot-card { translate: 0 -6px; }
.hand-slot.held .hold-btn {
  opacity: 1;
  border-color: var(--gold);
  background: linear-gradient(180deg, #f3d985, #c9a24b);
  color: #2a1d05;
}
.hand-slot.coach-pick .slot-card { outline: 3px solid #8fe0b0; outline-offset: 3px; }
.hand-slot.winning .card { filter: drop-shadow(0 0 8px rgba(255, 226, 140, .75)); }
body:not([data-phase="holding"]) .hand-slot { cursor: default; }

/* ----------------------- Controls ----------------------- */
.controls {
  position: relative;
  z-index: 3;
  width: min(1180px, 100%);
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 1.2vh, 14px) clamp(8px, 1.6vw, 22px);
}
.chips-tray {
  flex: 0 0 auto;
  display: flex;
  gap: clamp(6px, 1.1vw, 14px);
  justify-content: center;
  padding: clamp(8px, 1.3vh, 13px) clamp(10px, 1.6vw, 18px);
  padding-top: clamp(12px, 1.8vh, 18px);
  background:
    linear-gradient(180deg, rgba(255,255,255,.045), transparent 36%),
    linear-gradient(180deg, var(--tray-top), var(--tray-bottom));
  border: 1px solid rgba(217,182,95,.25);
  border-radius: 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.055), inset 0 -8px 16px rgba(0,0,0,.24), 0 12px 25px rgba(0,0,0,.24);
}
.action-row {
  flex: 1 0 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(8px, 1.4vw, 18px);
}
.bet-buttons { display: flex; gap: clamp(5px, .7vw, 9px); }
.bet-buttons .btn-tool { min-width: 66px; padding-block: 9px; }
.bet-total {
  display: grid;
  justify-items: end;
  gap: 1px;
  min-width: 92px;
  text-align: right;
}
.bet-total small {
  color: rgba(244, 239, 226, .55);
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.bet-total strong {
  font-family: var(--font-display);
  font-size: clamp(17px, 2.3vh, 22px);
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bet-total .last-win { letter-spacing: .6px; text-transform: none; font-size: 10px; }
.bet-total .last-win b { color: rgba(214, 255, 233, .85); font-variant-numeric: tabular-nums; }

.bet-total .coins-line { letter-spacing: .4px; text-transform: none; font-size: 10px; }

.win-meter {
  display: grid;
  justify-items: end;
  gap: 1px;
  min-width: 92px;
  text-align: right;
}
.win-meter small {
  color: rgba(244, 239, 226, .55);
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.win-meter strong {
  font-family: var(--font-display);
  font-size: clamp(17px, 2.3vh, 22px);
  color: #d6ffe9;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.win-meter .last-win { letter-spacing: .6px; text-transform: none; font-size: 10px; }
.win-meter .last-win b { color: rgba(214, 255, 233, .85); font-variant-numeric: tabular-nums; }

/* Deal and draw: a round brass button, the largest on the machine. */
.deal-btn {
  flex: 0 0 auto;
  width: clamp(70px, 10.5vh, 92px);
  height: clamp(70px, 10.5vh, 92px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  border: 1px solid rgba(80, 56, 12, .9);
  background:
    radial-gradient(120% 90% at 40% 20%, rgba(255,255,255,.5), transparent 45%),
    linear-gradient(180deg, #f3d985, #c9a24b 62%, #8c6a1c);
  box-shadow:
    0 0 0 3px rgba(20, 13, 4, .55),
    0 0 0 5px rgba(240, 215, 143, .5),
    0 10px 22px rgba(0,0,0,.5),
    inset 0 -6px 10px rgba(110, 76, 14, .55);
  color: #2a1d05;
  font-family: var(--font-display);
  font-weight: 800;
  cursor: pointer;
  transition: transform .14s ease, filter .2s ease;
}
.deal-label { font-size: clamp(12px, 1.8vh, 15px); letter-spacing: .14em; text-transform: uppercase; }
.deal-btn:not(:disabled):hover { transform: translateY(-2px); filter: brightness(1.06); }
.deal-btn:not(:disabled):active { transform: translateY(1px) scale(.97); }
.deal-btn:disabled { cursor: not-allowed; filter: grayscale(.55) brightness(.62); }
.deal-btn.ready { animation: dealReady 2.4s ease-in-out infinite; }
@keyframes dealReady {
  0%, 100% { box-shadow: 0 0 0 3px rgba(20,13,4,.55), 0 0 0 5px rgba(240,215,143,.5), 0 10px 22px rgba(0,0,0,.5), inset 0 -6px 10px rgba(110,76,14,.55); }
  50% { box-shadow: 0 0 0 3px rgba(20,13,4,.55), 0 0 0 5px rgba(244,226,166,.95), 0 0 26px rgba(244,226,166,.45), inset 0 -6px 10px rgba(110,76,14,.55); }
}

/* ----------------------- Dialogs ----------------------- */
/* A miniature of this machine on each cloth: five cards in a row. */
.theme-preview::before {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  top: 30%;
  bottom: 30%;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, #fbf8ef 0 16%, transparent 16% 21%);
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.45));
}
.theme-option[data-set-theme="midnight"] { --preview-felt-top: #2b6288; --preview-felt-bottom: #0b2b47; }
.theme-option[data-set-theme="bordeaux"] { --preview-felt-top: #8e3a49; --preview-felt-bottom: #3e111c; }
.theme-option[data-set-theme="onyx"] { --preview-felt-top: #5d6268; --preview-felt-bottom: #2a2d31; }
.theme-option[data-set-theme="amethyst"] { --preview-felt-top: #7a54a8; --preview-felt-bottom: #36215a; }
.payout-table .settings-hint + .settings-hint { margin-top: 0; }
.toast.coach { border-color: var(--gold-bright); color: var(--cream); }

/* ----------------------- Every hold ----------------------- */
/* The button shows only with the strategy hint on. */
body:not([data-coach="true"]) .holds-btn { display: none; }
.holds-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  counter-reset: hold;
}
.hold-choice {
  width: 100%;
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid rgba(217, 182, 95, .2);
  background: rgba(0, 0, 0, .2);
  color: var(--cream);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  counter-increment: hold;
}
.hold-choice::before {
  content: counter(hold);
  color: rgba(232, 202, 125, .55);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.hold-choice:hover { border-color: rgba(217, 182, 95, .55); }
.hold-choice.best { border-color: #8fe0b0; background: rgba(60, 140, 95, .2); }
.hold-choice.current { box-shadow: inset 0 0 0 2px var(--gold); }
.hold-cards { font-weight: 600; letter-spacing: .04em; overflow-wrap: anywhere; }
.hold-value { color: var(--gold-bright); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ----------------------- Phones and short screens ----------------------- */
@media (max-width: 760px) {
  .felt-head { grid-template-columns: minmax(0, 1fr); grid-template-areas: "banner"; }
  .table-specs { display: none; }
  .banner { justify-self: center; max-width: 100%; }
  .controls { justify-content: center; }
  .chips-tray { width: 100%; gap: 4px; padding-inline: 6px; }
  .chips-tray .chip { --size: clamp(36px, 12vw, 50px); }
  .action-row { width: 100%; justify-content: space-between; }
}

/* Narrow phones: the pay table keeps the column of the coins bet. */
@media (max-width: 560px) {
  .paytable [data-coins]:not(.active) { display: none; }
  .paytable { width: auto; min-width: 70%; }
}

/* Small phones: the eleven rows of Double Bonus sit closer, and the coins
   bet are read from the bet below instead of a heading. */
@media (max-width: 560px) and (max-height: 700px) {
  .paytable { line-height: 1.08; }
  .paytable thead { display: none; }
}

@media (max-width: 420px) {
  .cabinet { padding-inline: 8px; }
  .bet-buttons .btn-tool { min-width: 0; padding-inline: 7px; font-size: 9.5px; }
  .bet-total, .win-meter { min-width: 0; }
  .win-meter .last-win { display: none; }
}

/* Phones on their side: the pay table beside the cards. */
@media (max-height: 480px) {
  .topbar { padding-block: 4px; }
  .table-wrap { padding-block: 4px; gap: 4px; }
  .cabinet {
    --w: clamp(40px, min(9vw, 19vh), 96px);
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "head head" "pays hand";
    padding: 6px 12px;
    gap: 4px 12px;
    border-radius: 20px;
  }
  .felt-head { grid-area: head; grid-template-columns: 1fr auto; grid-template-areas: "banner specs"; }
  .paytable-frame { grid-area: pays; align-items: center; }
  .hand { grid-area: hand; }
  .paytable { font-size: 10px; line-height: 1.12; }
  .paytable [data-coins]:not(.active) { display: none; }
  .banner { padding: 3px 12px; font-size: 10px; }
  .banner small { display: inline; margin-left: 6px; }
  .table-specs { display: flex; }
  .hold-btn { min-height: 22px; }
  /* The tray and every action share one row, with slimmer coins and buttons. */
  .controls { flex-wrap: nowrap; gap: 8px; }
  .chips-tray { width: auto; gap: 4px; padding: 6px 8px; }
  .chips-tray .chip { --size: 30px; }
  .action-row { width: auto; gap: 8px; }
  .bet-buttons { gap: 4px; }
  .bet-buttons .btn-tool { min-width: 0; padding-inline: 7px; font-size: 9.5px; }
  .bet-total, .win-meter { min-width: 0; }
  .deal-btn { width: 58px; height: 58px; }
  .win-meter .last-win, .bet-total .coins-line { display: none; }
}

/* No transitions at all for reduced motion: each step appears in place. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }
}
