/* Texas Hold'em Poker — game.css
   Every rule is scoped under .thp- (or #thp- ids) so this file can neither
   leak into nor be overridden by the shared site stylesheet. No external
   images — card faces, felt and glyphs are all CSS/text (♠ ♥ ♦ ♣). */

:root {
  --thp-felt-1: #0c3a2a;
  --thp-felt-2: #114f39;
  --thp-felt-edge: #062218;
  --thp-panel: #0e211c;
  --thp-panel-raised: #123729;
  --thp-ink: #f2f7f4;
  --thp-ink-dim: #a9c2b9;
  --thp-gold: #e8c25e;
  --thp-gold-bright: #ffe08a;
  --thp-red: #e35353;
  --thp-green-ok: #55c98a;
  --thp-card-white: #f8f5ec;
  --thp-card-back-1: #1c4d6b;
  --thp-card-back-2: #123449;
  --thp-shadow: rgba(0, 0, 0, 0.45);
  --thp-radius-lg: 18px;
  --thp-radius-md: 12px;
  --thp-radius-sm: 8px;
  --thp-safe-t: env(safe-area-inset-top, 0px);
  --thp-safe-b: env(safe-area-inset-bottom, 0px);
  --thp-safe-l: env(safe-area-inset-left, 0px);
  --thp-safe-r: env(safe-area-inset-right, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

/* Shared site header/footer: visible on the menu/help, hidden while a hand
   is actually being played, same pattern as the rest of the platform. */
body:has(.thp-root.is-playing) .thp-site-header,
body:has(.thp-root.is-playing) #footer {
  display: none;
}

.thp-root {
  --thp-max-width: 560px;
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--thp-felt-2) 0%, var(--thp-felt-1) 55%, var(--thp-felt-edge) 100%);
  color: var(--thp-ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
  box-sizing: border-box;
}

.thp-root.is-playing {
  height: 100vh;
  overflow: hidden;
}

.thp-root *,
.thp-root *::before,
.thp-root *::after {
  box-sizing: border-box;
}

.thp-root button {
  font-family: inherit;
}

/* ---------- Screens (fixed-overlay dialog style, is-open + aria-hidden) ---------- */

.thp-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--thp-safe-t)) calc(16px + var(--thp-safe-r)) calc(20px + var(--thp-safe-b)) calc(16px + var(--thp-safe-l));
  opacity: 0;
  transform: scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 20;
  overflow-y: auto;
}

.thp-screen.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  z-index: 30;
}

/* ---------- Loading ---------- */

.thp-loading-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.thp-loading-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--thp-gold);
  margin-bottom: 20px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.thp-progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--thp-panel);
  border: 1px solid rgba(232, 194, 94, 0.25);
  overflow: hidden;
}

.thp-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--thp-gold), var(--thp-gold-bright));
  transition: width 0.25s ease;
}

.thp-loading-hint {
  margin-top: 12px;
  font-size: 13px;
  color: var(--thp-ink-dim);
}

/* ---------- Menu ---------- */

.thp-menu-card {
  width: 100%;
  max-width: var(--thp-max-width);
  background: linear-gradient(180deg, var(--thp-panel-raised), var(--thp-panel));
  border: 1px solid rgba(232, 194, 94, 0.2);
  border-radius: var(--thp-radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 50px var(--thp-shadow);
}

.thp-menu-glyphs {
  font-size: 24px;
  letter-spacing: 8px;
  margin-bottom: 6px;
  opacity: 0.85;
}

.thp-title {
  margin: 0 0 6px;
  font-size: 32px;
  font-weight: 800;
  color: var(--thp-gold);
  letter-spacing: 0.01em;
}

.thp-tagline {
  margin: 0 0 24px;
  color: var(--thp-ink-dim);
  font-size: 15px;
}

.thp-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.thp-fineprint {
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--thp-ink-dim);
  opacity: 0.8;
}

/* ---------- Buttons ---------- */

.thp-btn {
  appearance: none;
  border: none;
  border-radius: var(--thp-radius-md);
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
  touch-action: manipulation;
}

.thp-btn:active {
  transform: scale(0.97);
}

.thp-btn-primary {
  background: linear-gradient(180deg, var(--thp-gold-bright), var(--thp-gold));
  color: #23180a;
  box-shadow: 0 8px 18px rgba(232, 194, 94, 0.25);
}

.thp-btn-primary:hover {
  filter: brightness(1.05);
}

.thp-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--thp-ink);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.thp-btn-disabled,
.thp-btn:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: var(--thp-ink-dim);
  cursor: not-allowed;
  opacity: 0.7;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.thp-btn:disabled:active {
  transform: none;
}

.thp-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.12);
  color: var(--thp-ink-dim);
  padding: 3px 8px;
  border-radius: 999px;
}

.thp-icon-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--thp-ink);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- Help / Paytable ---------- */

.thp-help-card {
  width: 100%;
  max-width: var(--thp-max-width);
  background: linear-gradient(180deg, var(--thp-panel-raised), var(--thp-panel));
  border: 1px solid rgba(232, 194, 94, 0.2);
  border-radius: var(--thp-radius-lg);
  padding: 24px;
  box-shadow: 0 20px 50px var(--thp-shadow);
}

.thp-help-title {
  margin: 0 0 10px;
  color: var(--thp-gold);
  font-size: 22px;
  font-weight: 800;
}

.thp-help-copy {
  margin: 0 0 14px;
  color: var(--thp-ink-dim);
  font-size: 14px;
  line-height: 1.5;
}

.thp-help-copy-small {
  font-size: 12px;
  margin-top: 4px;
  margin-bottom: 16px;
}

.thp-table-wrap {
  overflow-x: auto;
  border-radius: var(--thp-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
}

.thp-paytable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 280px;
}

.thp-paytable th,
.thp-paytable td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.thp-paytable th {
  color: var(--thp-gold);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.2);
}

.thp-paytable td:last-child,
.thp-paytable th:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--thp-gold-bright);
  font-weight: 700;
}

.thp-paytable tr.thp-row-top td {
  color: var(--thp-gold-bright);
}

.thp-paytable tbody tr:last-child td {
  border-bottom: none;
}

/* ---------- Play screen ---------- */

.thp-screen-play {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  display: none;
  background: transparent;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  gap: 10px;
}

.thp-screen-play.is-open {
  display: flex;
  opacity: 1;
  transform: none;
}

.thp-screen-play > * {
  width: 100%;
  max-width: var(--thp-max-width);
  margin: 0 auto;
  flex-shrink: 0;
}

.thp-play-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(12px + var(--thp-safe-t)) calc(12px + var(--thp-safe-r)) 0 calc(12px + var(--thp-safe-l));
}

.thp-balance-chip {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(232, 194, 94, 0.25);
  border-radius: 999px;
  padding: 8px 16px;
}

.thp-balance-label {
  font-size: 11px;
  color: var(--thp-ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.thp-balance-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--thp-gold-bright);
  font-variant-numeric: tabular-nums;
}

.thp-balance-currency {
  font-size: 11px;
  color: var(--thp-ink-dim);
}

.thp-table-felt {
  position: relative;
  border-radius: var(--thp-radius-lg);
  background:
    radial-gradient(120% 140% at 50% 0%, var(--thp-felt-2) 0%, var(--thp-felt-1) 60%, var(--thp-felt-edge) 100%);
  border: 6px solid #3a2211;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45), 0 12px 30px var(--thp-shadow);
  padding: 16px 12px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 12px auto 0;
  overflow: hidden;
}

.thp-seat {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.thp-seat-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--thp-ink-dim);
  min-height: 16px;
}

.thp-seat-hand-label {
  color: var(--thp-gold-bright);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 700;
  font-size: 12px;
}

.thp-community-wrap {
  width: 100%;
  padding: 8px 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
}

/* ---------- Cards ---------- */

.thp-cards {
  display: grid;
  gap: 8px;
  width: 100%;
  margin: 0 auto;
}

.thp-cards-2 {
  grid-template-columns: repeat(2, 1fr);
  max-width: 160px;
}

.thp-cards-5 {
  grid-template-columns: repeat(5, 1fr);
  max-width: 420px;
}

.thp-card {
  aspect-ratio: 2 / 3;
  perspective: 800px;
}

.thp-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.thp-card.is-flipped .thp-card-inner {
  transform: rotateY(180deg);
}

.thp-card.is-winning .thp-card-inner {
  animation: thp-card-pop 0.5s ease 0.1s 1;
}

.thp-card-back,
.thp-card-front {
  position: absolute;
  inset: 0;
  border-radius: 7px;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thp-card-back {
  background:
    repeating-linear-gradient(45deg, var(--thp-card-back-1) 0 6px, var(--thp-card-back-2) 6px 12px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.thp-card-back::after {
  content: '';
  width: 55%;
  height: 55%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
}

.thp-card-front {
  background: var(--thp-card-white);
  color: #1a1a1a;
  transform: rotateY(180deg);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  flex-direction: column;
  padding: 6% 6%;
  position: absolute;
}

.thp-card-front.thp-suit-red {
  color: var(--thp-red);
}

.thp-card-rank-top,
.thp-card-rank-bottom {
  position: absolute;
  font-size: clamp(11px, 3.4vw, 16px);
  font-weight: 800;
  line-height: 1;
}

.thp-card-rank-top {
  top: 8%;
  left: 8%;
}

.thp-card-rank-bottom {
  bottom: 8%;
  right: 8%;
  transform: rotate(180deg);
}

.thp-card-suit-big {
  font-size: clamp(18px, 6vw, 30px);
}

.thp-card-empty .thp-card-suit-big {
  opacity: 0.15;
}

@keyframes thp-card-pop {
  0% { transform: rotateY(180deg) scale(1); }
  40% { transform: rotateY(180deg) scale(1.12); }
  100% { transform: rotateY(180deg) scale(1); }
}

/* ---------- Result ---------- */

.thp-result {
  min-height: 20px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--thp-ink-dim);
  padding: 0 6px;
}

.thp-result.thp-result-win {
  color: var(--thp-green-ok);
}

.thp-result.thp-result-push {
  color: var(--thp-gold-bright);
}

.thp-result.thp-result-lose {
  color: var(--thp-ink-dim);
}

/* ---------- Stats row ---------- */

.thp-stats-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 0 calc(12px + var(--thp-safe-r)) 0 calc(12px + var(--thp-safe-l));
  margin-top: 12px;
}

.thp-stat {
  flex: 1;
  max-width: 160px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--thp-radius-sm);
  padding: 8px 10px;
  text-align: center;
}

.thp-stat-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--thp-ink-dim);
}

.thp-stat-value {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: var(--thp-ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- Controls ---------- */

.thp-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px calc(12px + var(--thp-safe-r)) calc(16px + var(--thp-safe-b)) calc(12px + var(--thp-safe-l));
}

.thp-bet-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 6px 10px;
}

.thp-bet-label {
  font-size: 11px;
  color: var(--thp-ink-dim);
  text-transform: uppercase;
  padding-left: 4px;
}

.thp-bet-btn {
  appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--thp-ink);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.thp-bet-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.thp-bet-value {
  min-width: 56px;
  text-align: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.thp-btn-deal {
  flex: 1;
  font-size: 18px;
  letter-spacing: 0.04em;
  padding: 16px 20px;
}

.thp-btn-deal:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Small screens ---------- */

@media (max-width: 380px) {
  .thp-cards-5 {
    gap: 5px;
  }
  .thp-cards-2 {
    gap: 6px;
    max-width: 130px;
  }
  .thp-title {
    font-size: 26px;
  }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .thp-card-inner,
  .thp-progress-bar,
  .thp-card.is-winning .thp-card-inner,
  .thp-screen {
    animation: none !important;
    transition: none !important;
  }
}
