/* 1. Design tokens */

.lh-player {
  --table: #e9e3d8;
  --ink: #2b2a28;
  --title: #4d473d;
  --muted: #8a7f6c;
  --gold: #8a7a5c;
  --counter: #9a917f;
  --icon: #7d7466;
  --icon-hover: #4d473d;
  --link: #6b6458;
  --navy: #26436e;
  --blue: #1875d0;
  --blue-edge: #125ca6;
  --white: #fff;
  --pile: #fbfaf7;
  --lattice: rgba(255, 255, 255, 0.10);
  --ring: rgba(255, 255, 255, 0.25);
  --focus: rgba(24, 117, 208, 0.35);
  --edge: #d6cebf;
  --shadow-card: 0 16px 34px rgba(60, 45, 20, 0.20);
  --shadow-card-hover: 0 22px 40px rgba(60, 45, 20, 0.28);
  --shadow-pile: 0 2px 6px rgba(60, 45, 20, 0.12);
  --shadow-panel: 0 10px 30px rgba(60, 45, 20, 0.18);
  --shadow-mini: 0 4px 12px rgba(60, 45, 20, 0.10);
  --radius: 18px;
  --radius-sm: 16px;
  --radius-mini: 12px;
  --radius-inner: 10px;
  --radius-panel: 14px;
  --radius-pill: 999px;
  --font: "Nunito", sans-serif;
  --space-top: 28px;
  --space-mid: 30px;
  --space-actions: 42px;
  --card-w: 540px;
  --tilt: 0deg;
  --pile-x: 0px;
  --pile-y: 0px;
  --pile-tilt: 0deg;
  --fit-size: 28px;
}

body.page-cardset {
  overflow-x: hidden;
  background: var(--table, #e9e3d8);
}

body.page-cardset .mainCenter {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

body.page-cardset footer,
body.page-cardset .footer {
  background: #f4f1eb;
  color: #6b6458;
}

body.page-cardset footer a,
body.page-cardset .footer a {
  color: #6b6458;
}

/* 2. Layout */

.lh-player {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: var(--space-top) 16px 28px;
  overflow-x: hidden;
  background: var(--table);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.lh-player *,
.lh-player *::before,
.lh-player *::after {
  box-sizing: border-box;
}

.lh-player p {
  margin: 0;
  max-width: none;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.lh-player button {
  width: auto;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: 1;
  box-shadow: none;
  cursor: pointer;
}

.lh-player button:hover,
.lh-player button:disabled {
  background: transparent;
  color: inherit;
  box-shadow: none;
  transform: none;
}

.lh-player button:focus {
  outline: none;
}

.lh-player button:focus-visible,
.lh-player a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus);
}

.lh-player .player-heading {
  width: min(100%, var(--card-w));
  margin: 0 auto;
}

.lh-player h1 {
  margin: 0;
  padding: 0;
  color: var(--title);
  font-family: var(--font);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
  text-align: center;
}

.lh-player .player-description {
  width: min(100%, var(--card-w));
  max-width: none;
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.lh-player .player-description a {
  color: var(--link);
  font-weight: 800;
  text-decoration: underline;
}

.lh-player .player-description[hidden] {
  display: none;
}

.lh-player #playView {
  width: min(100%, var(--card-w), calc((100vh - 320px) * 3 / 2));
  margin: var(--space-mid) auto 0;
}

.lh-player #playView[hidden] {
  display: none;
}

.lh-player .player-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  width: 100%;
  margin-top: var(--space-actions);
}

.lh-player .player-ad {
  margin-top: 24px;
}

.lh-player .player-ad:empty {
  display: none;
}

/* 3. Card, pile and card back */

.lh-player .deck {
  position: relative;
  width: 100%;
  margin: 0 auto;
  perspective: 1400px;
}

.lh-player .card-stage {
  position: relative;
  z-index: 2;
  width: 100%;
  transform: rotate(var(--tilt));
  transform-origin: 50% 50%;
}

.lh-player .deck.is-deal-next .card-stage {
  animation: deal-next 260ms ease-out both;
}

.lh-player .deck.is-deal-prev .card-stage {
  animation: deal-prev 260ms ease-out both;
}

@keyframes deal-next {
  from { transform: translateX(60px) rotate(6deg); }
  to { transform: translateX(0) rotate(var(--tilt)); }
}

@keyframes deal-prev {
  from { transform: translateX(-60px) rotate(-6deg); }
  to { transform: translateX(0) rotate(var(--tilt)); }
}

.lh-player .card-scene {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  transform-style: preserve-3d;
  transition: transform 250ms ease;
}

.lh-player .deck.is-flipped .card-scene {
  transform: rotateY(180deg);
}

.lh-player .deck.is-live .card-scene,
.lh-player .deck.is-waiting .card-scene {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

.lh-player .card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.lh-player .deck:not(.is-flipped) .card-front,
.lh-player .deck.is-flipped .card-back {
  pointer-events: none;
}

.lh-player .card-back {
  transform: rotateY(0deg);
}

.lh-player .card-front {
  transform: rotateY(180deg);
}

.lh-player .card-sheet,
.lh-player .back-sheet {
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow-card);
}

.lh-player .start-card,
.lh-player .pile-card {
  border-radius: var(--radius);
  box-shadow: var(--shadow-pile);
}

.lh-player .start-card {
  background: var(--white);
}

.lh-player .pile-card {
  background: var(--pile);
}

.lh-player .card-sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.lh-player .card-text-box {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  padding: 36px 36px 44px;
  overflow: hidden;
}

.lh-player .card-text {
  width: 100%;
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fit-size);
  font-weight: 800;
  line-height: 1.18;
  text-align: center;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.lh-player .card-count {
  position: absolute;
  right: 0;
  bottom: 14px;
  left: 0;
  margin: 0;
  color: var(--counter);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.lh-player .card-count[hidden] {
  display: none;
}

.lh-player .start-deck {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.lh-player .pile {
  position: absolute;
  inset: -12px;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.lh-player .start-card {
  position: absolute;
  inset: 0;
}

.lh-player .pile-card {
  position: absolute;
  inset: 12px;
}

.lh-player .start-a {
  transform: rotate(-2.5deg);
}

.lh-player .start-b {
  transform: rotate(1.5deg);
}

.lh-player .deck:not(.is-waiting) .start-deck {
  visibility: hidden;
}

.lh-player .pile-card {
  visibility: hidden;
  transform: translate(var(--pile-x), var(--pile-y)) rotate(var(--pile-tilt));
}

.lh-player .pile-card.is-on {
  visibility: visible;
}

.lh-player .deck.is-gathering .pile-card.is-on {
  transform: translate(0, 0) rotate(0deg);
  transition: transform 300ms ease;
}

.lh-player .back-sheet {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  overflow: hidden;
}

.lh-player .back-sheet::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: var(--radius-inner);
  background-color: var(--navy);
  background-image:
    repeating-linear-gradient(45deg, var(--lattice) 0 1.5px, transparent 1.5px 18px),
    repeating-linear-gradient(-45deg, var(--lattice) 0 1.5px, transparent 1.5px 18px);
}

.lh-player .back-badge,
.lh-player .back-fail {
  position: relative;
  z-index: 1;
}

.lh-player .back-badge {
  padding: 18px 40px;
  border-radius: var(--radius-pill);
  background: var(--white);
  box-shadow: 0 0 0 6px var(--ring);
  text-align: center;
}

.lh-player .back-count {
  color: var(--navy);
  font-family: var(--font);
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
}

.lh-player .back-label {
  margin-top: 2px;
  color: var(--gold);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1.2;
}

.lh-player .back-fail {
  max-width: 80%;
  color: var(--white);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
}

.lh-player .back-fail[hidden],
.lh-player .back-badge[hidden],
.lh-player .deck.is-fail .back-badge {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .lh-player .deck.is-waiting:hover .card-stage {
    transform: translateY(-4px) rotate(var(--tilt));
    transition: transform 200ms ease;
  }

  .lh-player .deck.is-waiting:hover .card-sheet,
  .lh-player .deck.is-waiting:hover .back-sheet {
    box-shadow: var(--shadow-card-hover);
  }
}

/* 4. Buttons */

.lh-player .pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 54px;
  min-height: 54px;
  padding: 0 44px;
  border-radius: var(--radius-pill);
  background: var(--blue);
  color: var(--white);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 4px 0 var(--blue-edge);
}

.lh-player .pill-btn:hover {
  background: var(--blue);
  color: var(--white);
  box-shadow: 0 4px 0 var(--blue-edge);
}

.lh-player .pill-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--blue-edge);
}

.lh-player .pill-btn:focus-visible {
  box-shadow: 0 4px 0 var(--blue-edge), 0 0 0 3px var(--focus);
}

.lh-player .pill-btn:disabled {
  background: var(--counter);
  color: var(--white);
  box-shadow: 0 4px 0 var(--edge);
  cursor: not-allowed;
}

.lh-player .round-btn {
  justify-self: end;
  visibility: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--white);
  color: var(--title);
  font-size: 28px;
  font-weight: 800;
  box-shadow: 0 2px 0 var(--edge);
}

.lh-player .round-btn.is-shown {
  visibility: visible;
}

.lh-player .round-btn:hover {
  background: var(--white);
  color: var(--title);
  box-shadow: 0 2px 0 var(--edge);
}

.lh-player .round-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--edge);
}

.lh-player .round-btn:focus-visible {
  box-shadow: 0 2px 0 var(--edge), 0 0 0 3px var(--focus);
}

.lh-player .round-btn:disabled {
  background: var(--white);
  color: var(--title);
  cursor: not-allowed;
}

.lh-player .player-tools {
  position: relative;
  z-index: 6;
  display: flex;
  justify-self: start;
  align-items: center;
  min-width: 0;
  gap: 2px;
}

.lh-player .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--icon);
}

.lh-player .icon-btn svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lh-player .icon-btn:hover {
  background: transparent;
  color: var(--icon-hover);
}

.lh-player .pill-btn[hidden],
.lh-player .icon-btn[hidden] {
  display: none;
}

.lh-player.is-end #nextBtn {
  visibility: hidden;
}

/* 5. End card */

.lh-player .card-front.is-end .card-sheet {
  justify-content: center;
  gap: 0;
}

.lh-player .card-front.is-end .card-text-box {
  flex: 0 1 auto;
  max-height: none;
  padding: 28px 28px 0;
}

.lh-player .card-front.is-end .card-text {
  font-size: 46px;
  font-weight: 900;
  line-height: 1.1;
}

.lh-player .end-actions {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px 28px;
}

.lh-player .end-actions[hidden] {
  display: none;
}

.lh-player .end-kicker {
  color: var(--muted);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.lh-player .end-actions .pill-btn {
  margin-top: 8px;
}

.lh-player .try-another,
.lh-player .try-another a {
  color: var(--link);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.lh-player .try-another a:hover {
  color: var(--link);
  text-decoration: underline;
}

/* 6. Options panel and See all cards */

.lh-player .options-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 8;
  width: min(280px, calc(100vw - 48px));
  padding: 14px;
  border-radius: var(--radius-panel);
  background: var(--white);
  box-shadow: var(--shadow-panel);
  color: var(--ink);
  font-family: var(--font);
  text-align: left;
}

.lh-player .options-panel[hidden] {
  display: none;
}

.lh-player .options-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.lh-player .order-tabs {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--edge);
  border-radius: 8px;
}

.lh-player .order-tabs button {
  flex: 1 1 0;
  height: 40px;
  border-right: 1px solid var(--edge);
  background: var(--white);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.lh-player .order-tabs button:last-child {
  border-right: 0;
}

.lh-player .order-tabs button:hover {
  background: var(--table);
  color: var(--ink);
}

.lh-player .order-tabs button.is-active,
.lh-player .order-tabs button.is-active:hover {
  background: var(--table);
  color: var(--ink);
}

.lh-player .order-confirm {
  margin: 10px 0 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.lh-player .order-confirm[hidden] {
  display: none;
}

.lh-player .order-confirm button {
  margin-left: 4px;
  padding: 4px;
  color: var(--title);
  font-weight: 800;
}

.lh-player .see-all-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--edge);
  background: transparent;
  color: var(--title);
  font-size: 15px;
  font-weight: 800;
  text-align: left;
}

.lh-player .see-all-btn:hover {
  color: var(--ink);
}

.lh-player .options-keys {
  display: none;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

@media (min-width: 481px) {
  .lh-player .options-keys {
    display: block;
  }

  .lh-player .pile {
    inset: -22px;
  }

  .lh-player .pile-card {
    inset: 22px;
  }
}

.lh-player .see-all[hidden] {
  display: none;
}

.lh-player .see-all {
  width: min(100%, 880px);
  margin: 12px auto 0;
}

.lh-player .see-toolbar {
  margin: 0 0 12px;
}

.lh-player .see-toolbar-bottom {
  margin: 16px 0 0;
}

.lh-player .text-btn {
  padding: 8px 0;
  background: transparent;
  color: var(--title);
  font-size: 16px;
  font-weight: 800;
}

.lh-player .text-btn:hover {
  color: var(--ink);
  text-decoration: underline;
}

.lh-player .see-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.lh-player .mini-card {
  padding: 14px 14px 16px;
  border-radius: var(--radius-mini);
  background: var(--white);
  box-shadow: var(--shadow-mini);
}

.lh-player .mini-num {
  color: var(--counter);
  font-size: 13px;
  font-weight: 700;
}

.lh-player .mini-text {
  margin-top: 6px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* 7. Full screen */

.lh-player:fullscreen,
.lh-player:-webkit-full-screen {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 16px 24px 20px;
  overflow: auto;
  background: var(--table);
}

.lh-player:fullscreen .player-heading,
.lh-player:-webkit-full-screen .player-heading {
  width: 100%;
  max-width: none;
  align-self: stretch;
}

.lh-player:fullscreen h1,
.lh-player:-webkit-full-screen h1 {
  color: var(--muted);
  font-size: 16px;
}

.lh-player:fullscreen .player-description,
.lh-player:-webkit-full-screen .player-description {
  display: none;
}

.lh-player:fullscreen #playView:not([hidden]),
.lh-player:-webkit-full-screen #playView:not([hidden]) {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(100%, calc((100vh - 160px) * 3 / 2));
  min-height: 0;
  margin-top: 12px;
}

.lh-player:fullscreen .deck,
.lh-player:-webkit-full-screen .deck {
  width: 100%;
}

.lh-player:fullscreen .player-actions,
.lh-player:-webkit-full-screen .player-actions {
  width: 100%;
}

.lh-player:fullscreen .player-ad,
.lh-player:-webkit-full-screen .player-ad {
  display: none;
}

.lh-player:fullscreen.is-idle,
.lh-player:fullscreen.is-idle *,
.lh-player:-webkit-full-screen.is-idle,
.lh-player:-webkit-full-screen.is-idle * {
  cursor: none;
}

.lh-player:fullscreen.is-idle .player-heading,
.lh-player:fullscreen.is-idle .player-description,
.lh-player:fullscreen.is-idle .player-actions,
.lh-player:-webkit-full-screen.is-idle .player-heading,
.lh-player:-webkit-full-screen.is-idle .player-description,
.lh-player:-webkit-full-screen.is-idle .player-actions {
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

/* 8. Phones */

@media (max-width: 480px) {
  .lh-player {
    --radius: var(--radius-sm);
    padding: 24px 16px 28px;
  }

  .lh-player #playView,
  .lh-player .player-heading,
  .lh-player .player-description {
    width: 100%;
  }

  .lh-player .deck {
    width: 100%;
  }

  .lh-player .card-scene {
    aspect-ratio: 4 / 3;
  }

  .lh-player .card-text-box {
    padding: 28px 22px 40px;
  }

  .lh-player .pill-btn {
    height: 52px;
    min-height: 52px;
    padding: 0 24px;
  }

  .lh-player .round-btn {
    width: 52px;
    height: 52px;
  }

  .lh-player .player-actions {
    grid-template-columns: 52px minmax(0, 1fr) 44px;
    column-gap: 8px;
  }

  .lh-player .round-btn {
    justify-self: stretch;
  }

  .lh-player #nextBtn {
    width: 100%;
  }

  .lh-player .full-btn {
    display: none;
  }

  .lh-player .see-grid {
    grid-template-columns: 1fr;
  }

  .lh-player .options-keys {
    display: none;
  }

  .lh-player .card-front.is-end .card-text {
    font-size: 36px;
  }
}

/* 9. Reduced motion */

@media (prefers-reduced-motion: reduce) {
  .lh-player .card-scene,
  .lh-player .deck.is-flipped .card-scene,
  .lh-player .card-back,
  .lh-player .card-front {
    transform: none;
    transition: none;
  }

  .lh-player .card-back,
  .lh-player .card-front {
    transition: opacity 200ms linear;
  }

  .lh-player .deck:not(.is-flipped) .card-front { opacity: 0; }
  .lh-player .deck.is-flipped .card-front { opacity: 1; }
  .lh-player .deck.is-flipped .card-back { opacity: 0; }

  .lh-player .deck.is-deal-next .card-stage,
  .lh-player .deck.is-deal-prev .card-stage {
    animation: none;
  }

  .lh-player .deck.is-gathering .pile-card.is-on {
    transition: none;
  }

  .lh-player .card-stage,
  .lh-player .deck.is-waiting:hover .card-stage {
    transition: none;
  }
}
