/* Three Card Poker — game.css
   Every rule is scoped under .tcp- (or #tcp- ids) so this file can neither
   leak into nor be overridden by the shared site stylesheet. No external
   images — card faces, chips and glyphs are all CSS/text (♠ ♥ ♦ ♣). */

:root {
  --tcp-felt-1: #0e4a37;
  --tcp-felt-2: #135f45;
  --tcp-felt-edge: #062820;
  --tcp-panel: #0e241d;
  --tcp-panel-raised: #123a2c;
  --tcp-ink: #f2f7f4;
  --tcp-ink-dim: #a7c4b7;
  --tcp-gold: #e8c25e;
  --tcp-gold-bright: #ffe08a;
  --tcp-red: #e35353;
  --tcp-green-ok: #55c98a;
  --tcp-amber-push: #e8b25e;
  --tcp-card-white: #f8f5ec;
  --tcp-card-back-1: #1c4d6b;
  --tcp-card-back-2: #123449;
  --tcp-shadow: rgba(0, 0, 0, 0.45);
  --tcp-radius-lg: 18px;
  --tcp-radius-md: 12px;
  --tcp-radius-sm: 8px;
  --tcp-max-width: 480px;
  --tcp-safe-top: env(safe-area-inset-top, 0px);
  --tcp-safe-bottom: env(safe-area-inset-bottom, 0px);
  --tcp-safe-left: env(safe-area-inset-left, 0px);
  --tcp-safe-right: env(safe-area-inset-right, 0px);
}

/* Playing state: hide the shared site chrome while a hand is in progress,
   same pattern as the rest of the platform. */
body:has(.tcp-root.is-playing) .tcp-site-header,
body:has(.tcp-root.is-playing) #footer {
  display: none;
}

.tcp-root {
  position: relative;
  min-height: 100dvh;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--tcp-felt-2) 0%, var(--tcp-felt-1) 55%, var(--tcp-felt-edge) 100%);
  color: var(--tcp-ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}

.tcp-root * {
  box-sizing: border-box;
}

.tcp-root button {
  font-family: inherit;
}

/* ---------- Screens ----------
   Fixed-overlay dialog pattern: closed screens sit at opacity 0 with
   pointer-events disabled (never intercepting clicks), open screens fade
   in and become interactive via the .is-open modifier. The Play screen
   overrides this to a full-bleed, non-scrolling-overlay column instead of
   a centered dialog. */

.tcp-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--tcp-safe-top)) calc(16px + var(--tcp-safe-right)) calc(24px + var(--tcp-safe-bottom)) calc(16px + var(--tcp-safe-left));
  opacity: 0;
  transform: scale(0.98);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 20;
  overflow-y: auto;
}

.tcp-screen.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  z-index: 30;
}

/* ---------- Loading ---------- */

.tcp-loading-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.tcp-loading-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--tcp-gold);
  margin-bottom: 20px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.tcp-progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--tcp-panel);
  border: 1px solid rgba(232, 194, 94, 0.25);
  overflow: hidden;
}

.tcp-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--tcp-gold), var(--tcp-gold-bright));
  transition: width 0.25s ease;
}

.tcp-loading-hint {
  margin-top: 12px;
  font-size: 13px;
  color: var(--tcp-ink-dim);
}

/* ---------- Menu ---------- */

.tcp-menu-card {
  width: 100%;
  max-width: var(--tcp-max-width);
  background: linear-gradient(180deg, var(--tcp-panel-raised), var(--tcp-panel));
  border: 1px solid rgba(232, 194, 94, 0.2);
  border-radius: var(--tcp-radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 50px var(--tcp-shadow);
}

.tcp-title {
  margin: 0 0 6px;
  font-size: 32px;
  font-weight: 800;
  color: var(--tcp-gold);
  letter-spacing: 0.01em;
}

.tcp-tagline {
  margin: 0 0 24px;
  color: var(--tcp-ink-dim);
  font-size: 15px;
}

.tcp-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tcp-fineprint {
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--tcp-ink-dim);
  opacity: 0.8;
}

/* ---------- Buttons ---------- */

.tcp-btn {
  appearance: none;
  border: none;
  border-radius: var(--tcp-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;
}

.tcp-btn:active {
  transform: scale(0.97);
}

.tcp-btn-primary {
  background: linear-gradient(180deg, var(--tcp-gold-bright), var(--tcp-gold));
  color: #23180a;
  box-shadow: 0 8px 18px rgba(232, 194, 94, 0.25);
}

.tcp-btn-primary:hover {
  filter: brightness(1.05);
}

.tcp-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--tcp-ink);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.tcp-btn-fold {
  background: rgba(227, 83, 83, 0.16);
  color: #ffd7d7;
  border: 1px solid rgba(227, 83, 83, 0.4);
}

.tcp-btn-disabled,
.tcp-btn:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: var(--tcp-ink-dim);
  cursor: not-allowed;
  opacity: 0.7;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tcp-btn:disabled:active {
  transform: none;
}

.tcp-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.12);
  color: var(--tcp-ink-dim);
  padding: 3px 8px;
  border-radius: 999px;
}

.tcp-icon-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--tcp-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: none;
}

/* ---------- Rules / Paytable ---------- */

.tcp-help-card {
  width: 100%;
  max-width: 560px;
  max-height: 100%;
  background: linear-gradient(180deg, var(--tcp-panel-raised), var(--tcp-panel));
  border: 1px solid rgba(232, 194, 94, 0.2);
  border-radius: var(--tcp-radius-lg);
  padding: 24px;
  box-shadow: 0 20px 50px var(--tcp-shadow);
  text-align: left;
}

.tcp-help-title {
  margin: 0 0 10px;
  color: var(--tcp-gold);
  font-size: 22px;
  font-weight: 800;
}

.tcp-help-subhead {
  margin: 20px 0 8px;
  color: var(--tcp-gold-bright);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tcp-help-copy {
  margin: 0 0 4px;
  color: var(--tcp-ink-dim);
  font-size: 14px;
  line-height: 1.55;
}

.tcp-help-copy-small {
  font-size: 12px;
  margin-top: 8px;
}

.tcp-hand-ranks {
  list-style: decimal;
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tcp-hand-rank-row {
  font-size: 14px;
}

.tcp-hand-rank-name {
  display: block;
  font-weight: 700;
  color: var(--tcp-ink);
}

.tcp-hand-rank-note {
  display: block;
  font-size: 12px;
  color: var(--tcp-ink-dim);
}

.tcp-table-wrap {
  overflow-x: auto;
  border-radius: var(--tcp-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin: 10px 0 4px;
}

.tcp-paytable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 320px;
}

.tcp-paytable th,
.tcp-paytable td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.tcp-paytable th {
  color: var(--tcp-gold);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.2);
}

.tcp-paytable td:last-child,
.tcp-paytable td:nth-child(2),
.tcp-paytable th:last-child,
.tcp-paytable th:nth-child(2) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--tcp-gold-bright);
  font-weight: 700;
}

.tcp-paytable tbody tr:last-child td {
  border-bottom: none;
}

.tcp-help-card > .tcp-btn {
  margin-top: 18px;
}

/* ---------- Pause / Menu ---------- */

.tcp-pause-card {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(180deg, var(--tcp-panel-raised), var(--tcp-panel));
  border: 1px solid rgba(232, 194, 94, 0.2);
  border-radius: var(--tcp-radius-lg);
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 20px 50px var(--tcp-shadow);
}

.tcp-pause-title {
  margin: 0 0 20px;
  font-size: 24px;
  font-weight: 800;
  color: var(--tcp-gold);
}

.tcp-pause-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Play screen layout ---------- */

.tcp-screen-play {
  display: none;
  background: transparent;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

.tcp-screen-play.is-open {
  display: flex;
}

.tcp-play-inner {
  width: 100%;
  max-width: var(--tcp-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: calc(12px + var(--tcp-safe-top)) calc(16px + var(--tcp-safe-right)) calc(12px + var(--tcp-safe-bottom)) calc(16px + var(--tcp-safe-left));
  overflow-y: auto;
}

.tcp-play-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: none;
}

.tcp-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;
}

.tcp-balance-label {
  font-size: 11px;
  color: var(--tcp-ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tcp-balance-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--tcp-gold-bright);
  font-variant-numeric: tabular-nums;
}

.tcp-balance-currency {
  font-size: 11px;
  color: var(--tcp-ink-dim);
}

.tcp-table-felt {
  position: relative;
  border-radius: var(--tcp-radius-lg);
  background:
    radial-gradient(120% 140% at 50% 0%, var(--tcp-felt-2) 0%, var(--tcp-felt-1) 60%, var(--tcp-felt-edge) 100%);
  border: 6px solid #3a2211;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45), 0 12px 30px var(--tcp-shadow);
  padding: 14px 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  flex: none;
}

.tcp-wager-strip {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.tcp-wager-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(232, 194, 94, 0.3);
}

.tcp-wager-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tcp-gold);
}

.tcp-wager-value {
  font-weight: 800;
  color: var(--tcp-gold-bright);
  font-variant-numeric: tabular-nums;
}

/* ---------- Hand rows / cards ---------- */

.tcp-hand-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tcp-hand-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tcp-hand-name {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tcp-ink-dim);
}

.tcp-dealer-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(85, 201, 138, 0.2);
  color: var(--tcp-green-ok);
  border: 1px solid rgba(85, 201, 138, 0.35);
}

.tcp-dealer-badge[hidden] {
  display: none;
}

.tcp-dealer-badge-no {
  background: rgba(227, 83, 83, 0.18);
  color: #ff9d9d;
  border-color: rgba(227, 83, 83, 0.4);
}

.tcp-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

.tcp-card {
  aspect-ratio: 2 / 3;
  perspective: 800px;
}

.tcp-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);
}

.tcp-card.is-flipped .tcp-card-inner {
  transform: rotateY(180deg);
}

.tcp-card.is-winning .tcp-card-inner {
  animation: tcp-card-pop 0.5s ease 0.1s 1;
}

.tcp-card-back,
.tcp-card-front {
  position: absolute;
  inset: 0;
  border-radius: 7px;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tcp-card-back {
  background:
    repeating-linear-gradient(45deg, var(--tcp-card-back-1) 0 6px, var(--tcp-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);
}

.tcp-card-back::after {
  content: '';
  width: 55%;
  height: 55%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
}

.tcp-card-front {
  background: var(--tcp-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;
}

.tcp-card-front.tcp-suit-red {
  color: var(--tcp-red);
}

.tcp-card-rank-top,
.tcp-card-rank-bottom {
  position: absolute;
  font-size: clamp(11px, 4vw, 17px);
  font-weight: 800;
  line-height: 1;
}

.tcp-card-rank-top {
  top: 8%;
  left: 8%;
}

.tcp-card-rank-bottom {
  bottom: 8%;
  right: 8%;
  transform: rotate(180deg);
}

.tcp-card-suit-big {
  font-size: clamp(22px, 8vw, 36px);
}

.tcp-card-empty .tcp-card-suit-big {
  opacity: 0.15;
}

@keyframes tcp-card-pop {
  0% { transform: rotateY(180deg) scale(1); }
  40% { transform: rotateY(180deg) scale(1.12); }
  100% { transform: rotateY(180deg) scale(1); }
}

/* ---------- Result / bonus line ---------- */

.tcp-result {
  min-height: 28px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--tcp-ink-dim);
  padding: 0 4px;
}

.tcp-result.tcp-result-win {
  color: var(--tcp-green-ok);
}

.tcp-result.tcp-result-lose {
  color: var(--tcp-ink-dim);
}

.tcp-result.tcp-result-push {
  color: var(--tcp-amber-push);
}

.tcp-bonus-line {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--tcp-gold-bright);
  margin-top: -6px;
}

.tcp-bonus-line[hidden] {
  display: none;
}

/* ---------- Stats row ---------- */

.tcp-stats-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex: none;
}

.tcp-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(--tcp-radius-sm);
  padding: 8px 10px;
  text-align: center;
}

.tcp-stat-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tcp-ink-dim);
}

.tcp-stat-value {
  display: block;
  font-size: 15px;
  font-weight: 800;
  color: var(--tcp-ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- Controls ---------- */

.tcp-controls {
  margin-top: auto;
  padding-top: 4px;
  flex: none;
}

.tcp-controls-bet,
.tcp-controls-decision,
.tcp-controls-result {
  display: none;
  align-items: center;
  gap: 12px;
}

.tcp-controls--bet .tcp-controls-bet,
.tcp-controls--decision .tcp-controls-decision,
.tcp-controls--result .tcp-controls-result {
  display: flex;
}

.tcp-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;
}

.tcp-bet-label {
  font-size: 11px;
  color: var(--tcp-ink-dim);
  text-transform: uppercase;
  padding-left: 4px;
}

.tcp-bet-btn {
  appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--tcp-ink);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.tcp-bet-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tcp-bet-value {
  min-width: 56px;
  text-align: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.tcp-btn-deal,
.tcp-btn-fold,
.tcp-btn-play-bet,
.tcp-btn-next {
  flex: 1;
  font-size: 17px;
  letter-spacing: 0.03em;
  padding: 15px 16px;
}

.tcp-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Small screens ---------- */

@media (max-width: 380px) {
  .tcp-cards {
    gap: 5px;
  }
  .tcp-title {
    font-size: 26px;
  }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .tcp-card-inner,
  .tcp-progress-bar,
  .tcp-card.is-winning .tcp-card-inner,
  .tcp-screen {
    animation: none !important;
    transition: none !important;
  }
}
