:root {
  --pcl-card-bg: #ffffff; --pcl-card-border: #d1d5db; --pcl-card-text: #111827; --pcl-corner: #374151;
  --pcl-back-a: #0a66e8; --pcl-back-b: #0a96b4;
  --pcl-wild-bg: #fff7e6; --pcl-wild-border: #d97706; --pcl-wild-text: #92400e;
  --pcl-good: #16a34a; --pcl-warn: #d97706; --pcl-low: #dc2626;
  --pcl-pip-ring: rgba(17, 24, 39, 0.18);
}
.dark {
  --pcl-card-bg: #1b2431; --pcl-card-border: #364253; --pcl-card-text: #e8edf3; --pcl-corner: #c5cfdb;
  --pcl-wild-bg: #2b2112; --pcl-wild-border: #f5a13a; --pcl-wild-text: #ffcb6b;
  --pcl-good: #4ade80; --pcl-warn: #f5a13a; --pcl-low: #ff5c7a;
  --pcl-pip-ring: rgba(255, 255, 255, 0.22);
}

.pcl-ic-back { fill: var(--pcl-back-a); }
.pcl-ic-front { fill: var(--pcl-card-bg); stroke: currentColor; stroke-width: 2; }
.pcl-ic-pip { fill: var(--pcl-pip, #008000); stroke: var(--pcl-pip-ring); stroke-width: 0.6; }
.pcl-ic-card { transform-box: fill-box; transform-origin: center; }
.pcl-ic-card.flipping { animation: pcl-icon-flip 0.5s ease-in-out; }
@keyframes pcl-icon-flip { 50% { transform: scaleX(0); } }
.pcl-hero { display: flex; flex-direction: column; align-items: center; }
.pcl-hero .pcl-game-icon { width: 112px; height: 94px; color: var(--pcl-card-border); }

.pcl-topline { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.pcl-help {
  display: flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--lg-level-border, #d1d5db); color: inherit; font-size: 20px; font-weight: 800; line-height: 1;
  cursor: pointer; -webkit-tap-highlight-color: transparent; transition: border-color 0.15s;
}
.pcl-help:hover { border-color: var(--lg-accent-hover, #3b82f6); }
.pcl-header { justify-content: space-between; }
.pcl-header .pcl-help { border-color: var(--ftn-pad-border); color: var(--ftn-text); }

.pcl-mode { position: relative; height: 64px; }
.pcl-mode svg { width: 30px; height: 30px; }
.pcl-mode .pcl-game-icon { width: 40px; height: 34px; color: currentColor; }
.pcl-mode:disabled { cursor: default; opacity: 0.4; }
.pcl-mode:disabled:hover { border-color: var(--lg-mode-off-border); }
.pcl-mode .pcl-lock { position: absolute; top: 6px; right: 8px; width: 14px; height: 14px; }
.pcl-head-icon { margin-left: auto; }
.pcl-head-icon svg { width: 20px; height: 20px; }
.pcl-head-icon .pcl-game-icon { width: 24px; height: 20px; }

.pcl-new { font-size: 22px; }
.lg-table .pcl-date { color: var(--lg-muted); }
.lg-table td.pcl-go { width: 1%; padding-left: 0; }
.lg-table .pcl-open { cursor: pointer; }
.lg-table .pcl-open td { background: color-mix(in srgb, var(--lg-accent) 8%, transparent); }
.lg-table .pcl-open:hover td { background: color-mix(in srgb, var(--lg-accent) 14%, transparent); }
.lg-table .pcl-open td:first-child { border-radius: 10px 0 0 10px; box-shadow: inset 3px 0 0 var(--lg-accent); }
.lg-table .pcl-open td:last-child { border-radius: 0 10px 10px 0; }
.pcl-open-tag {
  display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; vertical-align: 1px;
  background: color-mix(in srgb, var(--lg-accent) 16%, transparent); color: var(--lg-accent); font-size: 12px; font-weight: 700;
}
.dark .pcl-open-tag { color: #93c5fd; }
.pcl-open-tag.won { background: color-mix(in srgb, var(--lg-amber) 18%, transparent); color: var(--lg-amber); }
.pcl-resume {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--lg-accent); color: #ffffff; vertical-align: middle;
}
.pcl-resume:hover:not(:disabled) { background: var(--lg-accent-hover); }
.pcl-resume:disabled { font-size: 0; opacity: 0.6; }
.pcl-resume svg { width: 20px; height: 20px; margin-left: 2px; }
.pcl-go-btns { display: inline-flex; align-items: center; gap: 8px; vertical-align: middle; }
.pcl-stop {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--lg-level-border); color: var(--lg-muted); transition: border-color 0.15s, color 0.15s;
}
.pcl-stop:hover { border-color: var(--pcl-low); color: var(--pcl-low); }
.pcl-stop svg { width: 18px; height: 18px; }
.pcl-end-yes, .pcl-end-no { height: 34px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.pcl-end-yes { background: var(--pcl-low); color: #ffffff; }
.pcl-end-no { border: 2px solid var(--lg-level-border); color: var(--lg-text); }
.lg-table .pcl-gap td { padding: 0; height: 22px; text-align: center; color: var(--lg-muted); border-top: 0; line-height: 1; }
.lg-table .pcl-gap + tr td { border-top: 0; }
.pcl-fan { display: inline-flex; vertical-align: middle; padding: 3px 12px 0 6px; }
.pcl-fan i {
  display: block; width: 25px; height: 34px; margin-right: -12px; padding: 2px 0 0 2px; border-radius: 4px;
  transform: rotate(calc(var(--k) * 2.2deg)) translateY(calc(var(--k) * var(--k) * 0.12px)); transform-origin: 50% 140%;
  font-style: normal; font-size: 10px; font-weight: 900; line-height: 1; letter-spacing: -0.08em; white-space: nowrap;
  box-shadow: -1px 0 0 1px var(--lg-card-bg), 0 0 0 1px var(--pcl-pip-ring) inset;
}

/* ── Playing cards ─────────────────────────────────────────────────── */
.pcl-card {
  --pcl-w: 80px;
  position: relative; display: flex; align-items: center; justify-content: center; flex: none;
  width: var(--pcl-w); height: calc(var(--pcl-w) * 1.4); min-width: 44px; min-height: 44px;
  border-radius: calc(var(--pcl-w) * 0.12); container-type: inline-size;
  border: 2px solid var(--pcl-card-border); background: var(--pcl-card-bg); color: var(--pcl-card-text);
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
  transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.12s, opacity 0.2s;
}
.pcl-card:hover { border-color: var(--lg-accent-hover, #3b82f6); }
.pcl-card:active { transform: translateY(2px); }
.pcl-corner { position: absolute; font-size: 17cqw; font-weight: 800; line-height: 1; color: var(--pcl-corner); }
.pcl-corner.tl { top: 7cqw; left: 9cqw; }
.pcl-corner.br { bottom: 7cqw; right: 9cqw; transform: rotate(180deg); }
.pcl-corner.bl { bottom: 7cqw; left: 8cqw; }
.pcl-spk svg { width: 19cqw; height: 19cqw; display: block; }
.pcl-pip {
  display: flex; align-items: center; justify-content: center; width: 58cqw; height: 58cqw; border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--pcl-pip-ring); font-size: 26cqw; font-weight: 900; line-height: 1;
}
.pcl-wild { background: var(--pcl-wild-bg); border-color: var(--pcl-wild-border); color: var(--pcl-wild-text); }
.pcl-wild .pcl-corner { color: var(--pcl-wild-text); font-size: 24cqw; }
.pcl-wild-name { font-size: 22cqw; font-weight: 900; }

.pcl-card.selected { border-color: #1a73f0; box-shadow: 0 0 0 5px rgba(26, 115, 240, 0.25); transform: translateY(-4px); }
.pcl-card.correct { border-color: var(--ftn-ok-border); background: var(--ftn-ok-bg); box-shadow: 0 0 0 6px rgba(74, 222, 128, 0.25); animation: ftn-pop 0.35s ease-out; }
.pcl-card.wrong { border-color: var(--ftn-bad-border); background: var(--ftn-bad-bg); animation: ftn-shake 0.42s ease-in-out; }
.pcl-card:is(.correct, .wrong) .pcl-corner, .pcl-card:is(.correct, .wrong) .pcl-wild-name { color: #ffffff; }
.pcl-card.revealed { border: 3px solid var(--ftn-rev-border); box-shadow: 0 0 0 6px rgba(74, 222, 128, 0.2); }
.pcl-card.dim { opacity: 0.45; }
.pcl-card.leaving { animation: pcl-leave 0.7s ease-in forwards; }
@keyframes pcl-leave { to { opacity: 0; transform: translateY(60px) rotate(8deg) scale(0.8); } }

.pcl-choose { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 32px; padding: 8px 16px 40px; }
.pcl-heading { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; text-align: center; }
.pcl-grid { display: grid; grid-template-columns: repeat(6, 88px); gap: 14px; }
.pcl-grid .pcl-card { --pcl-w: 88px; }
.pcl-play { width: min(300px, 100%); }
.pcl-play svg { width: 36px; height: 36px; }

/* ── Table ─────────────────────────────────────────────────────────── */
.pcl-health { position: relative; flex: 1 1 auto; height: 14px; border-radius: 8px; background: var(--ftn-track); overflow: hidden; }
.pcl-health i { position: absolute; inset: 0 auto 0 0; border-radius: 8px; background: var(--pcl-good); transition: width 0.45s ease-out, background-color 0.3s; }
.pcl-health i[data-band="warn"] { background: var(--pcl-warn); }
.pcl-health i[data-band="low"] { background: var(--pcl-low); }
.pcl-health i[data-band="full"] {
  background-color: var(--pcl-good); background-size: 28px 28px; animation: pcl-flow 0.9s linear infinite;
  background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.32) 25%, transparent 25% 50%, rgba(255, 255, 255, 0.32) 50% 75%, transparent 75%);
}
@keyframes pcl-flow { to { background-position: 28px 0; } }
.pcl-save { width: auto; gap: 6px; padding: 0 12px 0 8px; font-size: 15px; font-weight: 700; white-space: nowrap; }
.pcl-save svg { width: 22px; height: 22px; }

.pcl-hud { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 72px; padding: 0 40px; }
.pcl-count { display: inline-flex; align-items: center; gap: 8px; font-size: 26px; font-weight: 900; color: var(--ftn-text); }
.pcl-count svg { width: 28px; height: 28px; color: var(--ftn-muted); }

.pcl-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 32px; padding: 16px 16px 32px; }
.pcl-deal-area { display: flex; align-items: flex-end; justify-content: center; gap: 36px; margin-top: 24px; }
.pcl-deck { position: relative; width: 98px; height: 137px; margin: 0 calc(var(--n, 1) * 1.6px) calc(var(--n, 1) * 1.6px) 0; }
.pcl-deck i {
  position: absolute; inset: 0; border-radius: 12px; transform: translate(calc(var(--i) * 1.6px), calc(var(--i) * -1.6px));
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 6px, transparent 6px 12px), linear-gradient(135deg, var(--pcl-back-a), var(--pcl-back-b));
  border: 2px solid rgba(255, 255, 255, 0.55); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
  display: flex; align-items: center; justify-content: center;
}
.pcl-deck b {
  display: flex; align-items: center; justify-content: center; width: 58px; height: 58px; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.85); color: #ffffff; font-family: inherit; font-style: normal; font-weight: 900; font-size: 26px; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.pcl-deck i.arriving { animation: pcl-arrive 0.6s ease-out backwards; animation-delay: calc(var(--d) * 0.15s); }
@keyframes pcl-arrive {
  from { opacity: 0; transform: translate(calc(var(--i) * 1.6px + 60px), calc(var(--i) * -1.6px - 80px)) rotate(18deg); }
}
.pcl-dealt { position: relative; width: 140px; height: 196px; perspective: 800px; }
.pcl-back, .pcl-dealt .pcl-face { position: absolute; inset: 0; backface-visibility: hidden; transition: transform 0.45s; }
.pcl-back {
  display: flex; align-items: center; justify-content: center; border-radius: 17px;
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 8px, transparent 8px 16px), linear-gradient(135deg, var(--pcl-back-a), var(--pcl-back-b));
  border: 3px solid rgba(255, 255, 255, 0.5); box-shadow: 0 14px 34px rgba(10, 102, 232, 0.3);
}
.pcl-dealt .pcl-face { --pcl-w: 140px; width: auto; height: auto; transform: rotateY(180deg); cursor: default; }
.pcl-dealt.face-up .pcl-back { transform: rotateY(-180deg); }
.pcl-dealt.face-up .pcl-face { transform: rotateY(0); }
.pcl-dealt.dealing { animation: pcl-deal 0.3s ease-out; }
@keyframes pcl-deal { from { opacity: 0; transform: translateX(-120px) scale(0.7); } to { opacity: 1; transform: none; } }
.pcl-ring { width: 96px; height: 96px; transform: rotate(-90deg); }
.pcl-ring circle { fill: none; stroke-width: 6; }
.pcl-ring-track { stroke: rgba(255, 255, 255, 0.25); }
.pcl-ring-arc { stroke: #ffffff; stroke-linecap: round; opacity: 0.3; transition: stroke 0.2s; }
.pcl-ring-arc[data-band="warn"] { stroke: #ffcb6b; }
.pcl-ring-arc[data-band="low"] { stroke: #ff8a94; }

.pcl-hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: min(1100px, 100%); }

.pcl-veil {
  position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  padding: 16px; background: var(--ftn-over-bg); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.pcl-veil-head { font-size: 28px; font-weight: 900; letter-spacing: -0.01em; text-align: center; color: var(--ftn-text); }
.pcl-flip { position: relative; width: 170px; height: 238px; perspective: 800px; }
.pcl-flip-back {
  --pcl-w: 170px; position: absolute; inset: 0; backface-visibility: hidden; cursor: default;
  animation: pcl-flip-out 0.6s ease-in-out 0.7s forwards;
}
.pcl-flip-face {
  --pcl-w: 170px; position: absolute; inset: 0; backface-visibility: hidden; border: 3px solid var(--ftn-ok-border);
  box-shadow: 0 0 60px rgba(74, 222, 128, 0.45); transform: rotateY(180deg); animation: pcl-flip-in 0.6s ease-in-out 0.7s forwards;
}
@keyframes pcl-flip-out { to { transform: rotateY(-180deg); } }
@keyframes pcl-flip-in { to { transform: rotateY(0); } }
.pcl-veil .lg-continue { width: min(300px, 100%); }

/* ── Help ──────────────────────────────────────────────────────────── */
.pcl-dialog { max-width: min(520px, calc(100vw - 32px)); border-radius: 16px; padding: 0; background: #ffffff; color: #374151; }
.dark .pcl-dialog { background: #1f2937; color: #d1d5db; }
.pcl-dialog::backdrop { background: rgba(15, 23, 42, 0.5); }
.pcl-dialog-body { padding: 24px; font-size: 15px; line-height: 1.55; }
.pcl-dialog h2 { margin-bottom: 14px; font-size: 20px; font-weight: 800; color: #111827; }
.dark .pcl-dialog h2, .dark .pcl-dialog strong { color: #f3f4f6; }
.pcl-dialog strong { color: #111827; }
.pcl-dialog p + p, .pcl-dialog ol + p { margin-top: 12px; }
.pcl-dialog .pcl-goal { margin-bottom: 4px; padding: 10px 14px; border-radius: 10px; background: #eff6ff; color: #1e3a8a; font-weight: 700; }
.dark .pcl-dialog .pcl-goal { background: #172554; color: #bfdbfe; }
.pcl-dialog h3 { margin: 16px 0 6px; font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #6b7280; }
.pcl-dialog ol { padding-left: 22px; list-style: decimal; }
.pcl-dialog li + li { margin-top: 4px; }
.pcl-dialog .pcl-goal + h3 { margin-top: 14px; }
.pcl-dialog .pcl-tease { margin-top: 16px; font-style: italic; color: #6b7280; }
.pcl-dialog-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
.pcl-dialog-btn { padding: 8px 20px; border-radius: 10px; background: #2563eb; color: #ffffff; font-weight: 600; font-size: 14px; }
.pcl-dialog-btn:hover { background: #1d4ed8; }

/* ── Results ───────────────────────────────────────────────────────── */
.pcl-result-head { font-size: 15px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--lg-muted); }
.pcl-bonus { font-size: 16px; font-weight: 600; color: var(--lg-muted); font-variant-numeric: tabular-nums; }
.pcl-bonus:empty { display: none; }
.pcl-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: min(640px, 100%); }
.pcl-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px 5px 5px; border-radius: 9999px;
  border: 1px solid var(--lg-card-border); background: var(--lg-card-bg); font-variant-numeric: tabular-nums;
}
.pcl-chip-pip {
  display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--pcl-pip-ring); font-size: 14px; font-weight: 900; letter-spacing: -0.06em;
}
.pcl-chip b { font-size: 16px; font-weight: 800; }
.pcl-unlocked { font-size: 17px; font-weight: 700; color: var(--lg-good); }

@media (max-width: 599px) {
  .pcl-open-tag { display: none; }
  .pcl-hud { padding: 0 20px; }
  .pcl-count { font-size: 22px; }
  .pcl-deal-area { gap: 24px; margin-top: 8px; }
  .pcl-deck { width: 80px; height: 112px; }
  .pcl-deck b { width: 48px; height: 48px; border-width: 3px; font-size: 21px; }
  .pcl-dealt { width: 116px; height: 162px; }
  .lg-table .pcl-date { display: none; }
  .pcl-fan { padding: 3px 9px 0 4px; }
  .pcl-fan i { width: 21px; height: 29px; margin-right: -12px; font-size: 9px; }
  .pcl-go-btns { gap: 5px; }
  .pcl-resume, .pcl-stop { width: 30px; height: 30px; }
  .pcl-resume svg { width: 18px; height: 18px; }
  .pcl-stop svg { width: 15px; height: 15px; }
  .pcl-end-yes, .pcl-end-no { height: 30px; padding: 0 9px; }
  .pcl-save { font-size: 14px; padding: 0 8px 0 4px; }
  .pcl-dealt .pcl-face { --pcl-w: 116px; }
  .pcl-ring { width: 80px; height: 80px; }
  .pcl-hand { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
  .pcl-hand .pcl-card { width: auto; height: auto; aspect-ratio: 5 / 7; }
  .pcl-hand .pcl-wild { grid-column: 1 / -1; aspect-ratio: auto; height: 56px; container-type: normal; }
  .pcl-hand .pcl-wild .pcl-corner { font-size: 22px; top: 6px; left: 12px; }
  .pcl-hand .pcl-wild .pcl-corner.br { top: auto; left: auto; bottom: 6px; right: 12px; }
  .pcl-hand .pcl-wild .pcl-wild-name { font-size: 20px; }
  .pcl-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; gap: 10px; }
  .pcl-grid .pcl-card { width: auto; height: auto; aspect-ratio: 5 / 7; }
  .pcl-heading { font-size: 26px; }
  .pcl-hero .pcl-game-icon { width: 90px; height: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  .pcl-card.correct, .pcl-card.wrong, .pcl-dealt.dealing, .pcl-health i[data-band="full"], .pcl-deck i.arriving { animation: none; }
  .pcl-back, .pcl-dealt .pcl-face { transition: none; }
  .pcl-flip-back, .pcl-flip-face, .pcl-card.leaving { animation-duration: 0.01s; }
}
