:root {
  --felt-light: #1f7a50;
  --felt-dark: #0b3a25;
  --gold: #ffd65a;
  --ink: #f4f1ea;
  --card-ease: cubic-bezier(0.2, 0.8, 0.25, 1);
  --cw: clamp(58px, min(10vw, 12.5vh), 112px);
}

* {
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(ellipse at 50% 35%, var(--felt-light), var(--felt-dark) 75%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  user-select: none;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.22);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-start {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.home-link {
  position: relative;
  display: flex;
  align-items: center;
  padding-right: 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
  transition: opacity 0.15s;
}

.home-link:hover {
  opacity: 0.8;
}

.home-link-mark {
  display: block;
  width: 30px;
  height: 30px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--ink);
  color: #1d1d27;
  font-size: 20px;
}

h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 750;
}

.stats {
  display: flex;
  gap: 6px;
  margin: 0;
}

.stat {
  min-width: 64px;
  padding: 5px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  text-align: center;
}

.stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.65;
}

.stat-value {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

button {
  font: inherit;
  cursor: pointer;
}

.ghost-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  opacity: 0.85;
}

.ghost-button:hover {
  background: rgba(255, 255, 255, 0.1);
  opacity: 1;
}

#table {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.4vh, 22px);
  padding: 20px;
}

.shoe {
  position: absolute;
  top: 20px;
  right: 24px;
  width: calc(var(--cw) * 0.8);
  height: calc(var(--cw) * 1.12);
  border: calc(var(--cw) * 0.04) solid #f6f2e8;
  border-radius: calc(var(--cw) * 0.07);
  background: var(--card-back-art);
  box-shadow:
    -3px 3px 0 -1px #f6f2e8,
    -6px 6px 0 -2px #e8e3d6,
    0 10px 20px rgba(0, 0, 0, 0.4);
  transform: rotate(8deg);
}

.hand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.hand-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}

.total {
  min-width: 30px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 14px;
  letter-spacing: 0;
  text-align: center;
  text-transform: none;
}

.total:empty {
  visibility: hidden;
}

.cards {
  display: flex;
  justify-content: center;
  min-width: calc(var(--cw) * 2);
  height: calc(var(--cw) * 1.4);
}

.result {
  min-height: 38px;
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  transition: background 0.2s, color 0.2s;
}

.result:empty {
  visibility: hidden;
}

.result[data-kind="neutral"] {
  background: rgba(0, 0, 0, 0.22);
  color: rgba(244, 241, 234, 0.85);
  font-weight: 600;
}

.result[data-kind="win"] {
  background: var(--gold);
  color: #2a2205;
  animation: result-pop 0.35s var(--card-ease);
}

.result[data-kind="lose"] {
  background: rgba(120, 20, 30, 0.75);
  color: #ffe3e3;
  animation: result-pop 0.35s var(--card-ease);
}

.result[data-kind="push"] {
  background: rgba(244, 241, 234, 0.9);
  color: #1d1d27;
  animation: result-pop 0.35s var(--card-ease);
}

@keyframes result-pop {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.action {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 112px;
  justify-content: center;
  padding: 12px 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  transition: transform 0.1s, background 0.15s, opacity 0.15s;
}

.action:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.42);
}

.action:active:not(:disabled) {
  transform: scale(0.96);
}

.action:disabled {
  opacity: 0.38;
  cursor: default;
}

.action.primary {
  border-color: transparent;
  background: var(--gold);
  color: #2a2205;
}

.action.primary:hover:not(:disabled) {
  background: #ffe07d;
}

kbd {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.14);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  opacity: 0.8;
}

.action.primary kbd {
  background: rgba(0, 0, 0, 0.12);
}

.rules-note {
  margin: 0;
  font-size: 12px;
  opacity: 0.55;
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 5px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 10px;
  opacity: 0.7;
}

.site-footer a {
  color: inherit;
}

.card {
  position: relative;
  flex: none;
  width: var(--cw);
  height: calc(var(--cw) * 1.4);
  perspective: 900px;
}

.card + .card {
  margin-left: calc(var(--cw) * -0.36);
}

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.45s var(--card-ease);
}

.card.down .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: calc(var(--cw) * 0.08);
  backface-visibility: hidden;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    -3px 4px 10px rgba(0, 0, 0, 0.28);
}

.card-front {
  background: linear-gradient(160deg, #ffffff, #f1efe7);
  color: #1d1d27;
}

.card.red .card-front {
  color: #c8262e;
}

:root {
  --card-back-art:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.22), transparent 55%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.09) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.09) 0 2px, transparent 2px 9px),
    linear-gradient(135deg, #8c2445, #521433);
}

.card-back {
  transform: rotateY(180deg);
  border: calc(var(--cw) * 0.05) solid #f6f2e8;
  background: var(--card-back-art);
}

.corner {
  position: absolute;
  top: 4%;
  left: 5%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-weight: 750;
  line-height: 1;
  letter-spacing: -1px;
}

.corner .rank {
  font-size: max(calc(var(--cw) * 0.2), 11px);
}

.corner .suit {
  font-size: max(calc(var(--cw) * 0.15), 9px);
}

.corner.bottom {
  top: auto;
  left: auto;
  right: 5%;
  bottom: 4%;
  transform: rotate(180deg);
}

.pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--cw) * 0.52);
}

.pip.court {
  inset: 20% 21%;
  overflow: hidden;
}

.court-image {
  position: absolute;
  inset: 4% 4% 0;
  width: 92%;
  height: 96%;
  object-fit: contain;
  pointer-events: none;
}

.pips {
  position: absolute;
  inset: 13% 25%;
}

.pip-mark {
  position: absolute;
  font-size: calc(var(--cw) * 0.21);
  line-height: 1;
  transform: translate(-50%, -50%);
}

.pip-mark.inverted {
  transform: translate(-50%, -50%) rotate(180deg);
}

@media (max-width: 640px) {
  header {
    flex-wrap: wrap;
    padding: 8px 12px;
  }

  .stat {
    min-width: 52px;
    padding: 4px 6px;
  }

  .shoe {
    display: none;
  }

  .action {
    min-width: 0;
    padding: 12px 16px;
  }

  .action kbd {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-inner {
    transition-duration: 0.01s;
  }

  .result[data-kind] {
    animation: none;
  }
}

.guide {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 20px 64px;
  color: rgba(244, 241, 234, 0.86);
  font-size: 16px;
  line-height: 1.65;
  user-select: text;
}

.guide h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 24px;
}

.guide h3 {
  margin: 22px 0 6px;
  color: var(--ink);
  font-size: 17px;
}

.guide p,
.guide li {
  margin: 0 0 10px;
}

.guide ul {
  padding-left: 22px;
}

.guide kbd {
  padding: 1px 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  font: inherit;
  font-size: 13px;
}

.guide h2:not(:first-child) {
  margin-top: 40px;
}

.guide a,
.more-games a {
  color: var(--gold);
}

.more-games {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px 64px;
  user-select: text;
}

.more-games h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.more-games ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.noscript-note {
  margin: 0;
  padding: 12px 20px;
  background: var(--gold);
  color: #2a2205;
  text-align: center;
}

@media (max-width: 640px) {
  .site-footer {
    flex-wrap: wrap;
    row-gap: 2px;
    column-gap: 12px;
  }

  .site-footer > [aria-hidden="true"] {
    display: none;
  }
}
