:root {
  --felt: #0e5a43;
  --felt-dark: #073629;
  --felt-light: #16805c;
  --ink: #1f2522;
  --paper: #fbf5e8;
  --paper-edge: #e2d3b5;
  --gold: #e1bc5f;
  --gold-dark: #916f27;
  --joy: #ffe46d;
  --joy-hot: #ff9f43;
  --red: #c7353a;
  --pain: #ff2147;
  --pain-dark: #610514;
  --black: #202124;
  --blue: #265d9f;
  --good: #38d87b;
  --bad: #ff5b5f;
  --tie: #69b7ff;
  --shadow: rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  font-family: "Mali", "Segoe UI", Tahoma, sans-serif;
  background:
    linear-gradient(135deg, rgba(5, 28, 22, 0.92), rgba(9, 69, 50, 0.9)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 8px),
    var(--felt-dark);
  display: grid;
  place-items: center;
  padding: 28px;
}

button,
input {
  font: inherit;
}

input,
select,
textarea {
  font-size: 16px;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.game-shell {
  width: min(1120px, 100%);
  display: grid;
  gap: 18px;
}

.top-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.35;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #fff8e8;
  font-size: 4.8rem;
  line-height: 1.22;
  letter-spacing: 0;
  text-shadow: 0 5px 18px rgba(0, 0, 0, 0.35);
}

.setup {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.count-field {
  display: grid;
  gap: 7px;
  color: rgba(255, 248, 232, 0.78);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.3;
}

.count-field input {
  width: 116px;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  outline: 0;
  padding: 0 14px;
  color: #fff;
  background: rgba(1, 20, 15, 0.44);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.count-field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(225, 188, 95, 0.2);
}

.primary-btn,
.guess-btn {
  border: 0;
  border-radius: 8px;
  color: #1f1a0a;
  font-weight: 900;
  line-height: 1.25;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.48);
  transition: transform 180ms ease, filter 180ms ease, opacity 180ms ease;
}

.primary-btn {
  min-height: 46px;
  padding: 0 22px;
  background: linear-gradient(180deg, #ffe08b, var(--gold));
}

.primary-btn:hover,
.guess-btn:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-2px);
}

.primary-btn:active,
.guess-btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

.table {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  padding: clamp(18px, 3vw, 34px);
  background:
    linear-gradient(140deg, rgba(10, 97, 70, 0.92), rgba(6, 54, 42, 0.98)),
    repeating-radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 9px);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.34), inset 0 0 0 9px rgba(0, 0, 0, 0.12);
}

.table::before,
.table::after {
  content: "";
  position: absolute;
  inset: 14px;
  pointer-events: none;
  border-radius: 12px;
}

.table::before {
  border: 2px solid rgba(225, 188, 95, 0.5);
}

.table::after {
  border: 1px dashed rgba(255, 248, 232, 0.25);
  animation: dashGlow 5s ease-in-out infinite;
}

.table-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 0 34%, rgba(255, 255, 255, 0.1) 45%, transparent 56% 100%);
  transform: translateX(-80%);
  animation: tableSweep 6s ease-in-out infinite;
}

.feedback-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.table.celebrate {
  animation: tableJoy 780ms ease both;
}

.table.pain {
  animation: tablePain 760ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.table.pain::before {
  animation: borderPain 720ms ease both;
}

.table.pain .score-row,
.table.pain .progress,
.table.pain .arena,
.table.pain .result-banner,
.table.pain .history-wrap {
  animation: contentPainShake 760ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.table.celebrate .score-box {
  animation: scoreCelebrate 720ms ease both;
}

.impact-ring,
.joy-ring,
.hurt-slash,
.feedback-particle {
  position: absolute;
  left: 50%;
  top: 47%;
  pointer-events: none;
}

.impact-ring,
.joy-ring {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.joy-ring {
  border: 3px solid rgba(255, 228, 109, 0.86);
  box-shadow: 0 0 28px rgba(255, 228, 109, 0.74), inset 0 0 20px rgba(255, 255, 255, 0.2);
  animation: joyRing 720ms ease-out both;
}

.impact-ring {
  border: 4px solid rgba(255, 33, 71, 0.88);
  box-shadow: 0 0 34px rgba(255, 33, 71, 0.82), inset 0 0 22px rgba(255, 33, 71, 0.4);
  animation: impactRing 620ms ease-out both;
}

.hurt-slash {
  width: min(56vw, 520px);
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95) 10%, var(--pain) 34%, #360109 74%, transparent);
  box-shadow: 0 0 18px rgba(255, 33, 71, 0.95), 0 0 44px rgba(255, 33, 71, 0.5);
  transform: translate(-50%, -50%) rotate(-18deg) scaleX(0);
  animation: slashCut 640ms cubic-bezier(0.2, 0.85, 0.15, 1) both;
}

.feedback-particle {
  --x: 0px;
  --y: 0px;
  --size: 10px;
  --delay: 0ms;
  width: var(--size);
  height: var(--size);
  transform: translate(-50%, -50%);
  animation-delay: var(--delay);
}

.feedback-particle.spark {
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 22%, var(--joy) 23% 62%, var(--joy-hot) 63% 100%);
  box-shadow: 0 0 14px rgba(255, 228, 109, 0.88);
  animation: sparkBurst 900ms cubic-bezier(0.18, 0.9, 0.16, 1) both;
}

.feedback-particle.ribbon {
  width: 8px;
  height: 18px;
  border-radius: 2px;
  background: hsl(var(--h), 88%, 62%);
  box-shadow: 0 0 12px hsla(var(--h), 90%, 66%, 0.55);
  animation: ribbonBurst 980ms cubic-bezier(0.18, 0.9, 0.16, 1) both;
}

.feedback-particle.shard {
  width: var(--size);
  height: calc(var(--size) * 0.46);
  clip-path: polygon(0 50%, 72% 0, 100% 100%);
  background: linear-gradient(90deg, #fff, var(--pain), var(--pain-dark));
  box-shadow: 0 0 12px rgba(255, 33, 71, 0.88);
  animation: shardBlast 760ms cubic-bezier(0.12, 0.8, 0.2, 1) both;
}

.score-row,
.arena,
.result-banner,
.actions,
.history-wrap,
.progress {
  position: relative;
  z-index: 1;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.score-box {
  min-height: 72px;
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(3, 28, 22, 0.46);
}

.score-box span {
  display: block;
  color: rgba(255, 248, 232, 0.68);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
}

.score-box strong {
  display: block;
  margin-top: 4px;
  color: #fff8e8;
  font-size: 2.25rem;
  line-height: 1.12;
}

.progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  margin-bottom: clamp(22px, 4vw, 42px);
  background: rgba(1, 20, 15, 0.54);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.45);
}

.progress div {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), #fff2a8, var(--good));
  box-shadow: 0 0 18px rgba(225, 188, 95, 0.45);
  transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.arena {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  align-items: center;
  gap: clamp(14px, 4vw, 42px);
  min-height: 330px;
  perspective: 1100px;
}

.card-stack {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
}

.card-shadow {
  position: absolute;
  bottom: 34px;
  width: min(58%, 210px);
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.34);
  filter: blur(9px);
}

.playing-card {
  position: relative;
  width: clamp(138px, 20vw, 224px);
  aspect-ratio: 5 / 7;
  color: var(--black);
  transform-style: preserve-3d;
  transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1), filter 260ms ease;
}

.card-face,
.card-back {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 14px;
  backface-visibility: hidden;
  box-shadow: 0 20px 34px var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.62);
}

.card-face {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(12px, 2vw, 18px);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0) 32%),
    var(--paper);
  border: 1px solid var(--paper-edge);
}

.card-face::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 2px solid rgba(145, 111, 39, 0.23);
  border-radius: 10px;
}

.card-back {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 18%;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 28% 70%, rgba(0, 0, 0, 0.18)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.16) 0 3px, transparent 3px 12px),
    linear-gradient(135deg, #265d9f, #153a67);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transform: rotateY(180deg);
}

.card-back span {
  width: 82%;
  height: 13px;
  border-radius: 999px;
  background: rgba(255, 248, 232, 0.72);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.2);
}

.playing-card.is-back {
  transform: rotateY(180deg);
}

.playing-card.is-empty {
  filter: saturate(0.6) opacity(0.7);
}

.rank,
.suit {
  position: relative;
  z-index: 1;
  font-weight: 950;
  line-height: 1;
}

.rank {
  font-size: 2.5rem;
}

.suit {
  margin-top: 6px;
  font-size: 2rem;
}

.center-suit {
  position: relative;
  z-index: 1;
  align-self: center;
  justify-self: center;
  color: currentColor;
  font-size: 7.4rem;
  line-height: 1;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.06);
}

.bottom {
  justify-self: end;
  align-self: end;
  transform: rotate(180deg);
}

.playing-card.red {
  color: var(--red);
}

.playing-card.black {
  color: var(--black);
}

.current-card {
  animation: currentFloat 3.4s ease-in-out infinite;
}

.next-card {
  animation: deckPulse 2.8s ease-in-out infinite;
}

.next-card.reveal {
  animation: revealDeal 660ms cubic-bezier(0.2, 0.9, 0.15, 1.25) both;
}

.next-card.reveal.correct {
  animation: revealDeal 520ms cubic-bezier(0.2, 0.9, 0.15, 1.25) both, cardJoy 900ms ease 500ms both;
}

.next-card.reveal.wrong {
  animation: revealDeal 480ms cubic-bezier(0.2, 0.9, 0.15, 1.15) both, wrongPunish 760ms cubic-bezier(0.36, 0.07, 0.19, 0.97) 450ms both;
}

.next-card.reveal.tie {
  animation: revealDeal 600ms cubic-bezier(0.2, 0.9, 0.15, 1.25) both, tieNudge 780ms ease 520ms both;
}

.current-card.receive {
  animation: receiveCard 420ms ease both, currentFloat 3.4s ease-in-out infinite 420ms;
}

.current-card.receive.correct {
  animation: receiveCard 360ms ease both, cardJoy 860ms ease 320ms both, currentFloat 3.4s ease-in-out infinite 1.1s;
}

.current-card.receive.wrong {
  animation: receiveCard 300ms ease both, wrongPunish 700ms cubic-bezier(0.36, 0.07, 0.19, 0.97) 300ms both, currentFloat 3.4s ease-in-out infinite 1.08s;
}

.playing-card.correct .card-face {
  animation: correctGlow 920ms ease;
}

.playing-card.wrong .card-face {
  animation: painFlash 760ms ease both;
}

.playing-card.tie .card-face {
  animation: tieGlow 820ms ease;
}

.card-caption {
  color: rgba(255, 248, 232, 0.74);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.25;
}

.versus {
  display: grid;
  place-items: center;
}

.versus span {
  min-width: 72px;
  min-height: 72px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(225, 188, 95, 0.5);
  border-radius: 50%;
  color: #fff2c3;
  font-weight: 950;
  line-height: 1.2;
  background: rgba(3, 28, 22, 0.5);
  box-shadow: inset 0 0 24px rgba(225, 188, 95, 0.15), 0 12px 30px rgba(0, 0, 0, 0.24);
}

.result-banner {
  min-height: 42px;
  margin: 8px auto 20px;
  display: grid;
  place-items: center;
  color: #fff8e8;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
}

.result-banner.good {
  color: var(--good);
  text-shadow: 0 0 14px rgba(56, 216, 123, 0.6);
  animation: joyTextPop 620ms cubic-bezier(0.17, 0.9, 0.2, 1.25) both;
}

.result-banner.bad {
  color: var(--bad);
  text-shadow: 0 0 14px rgba(255, 91, 95, 0.7);
  animation: painTextDrop 620ms cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.result-banner.tie {
  color: var(--tie);
  animation: textPop 420ms ease both;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 220px));
  justify-content: center;
  gap: 14px;
}

.guess-btn {
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.24rem;
}

.guess-btn:disabled {
  opacity: 0.48;
}

.higher {
  background: linear-gradient(180deg, #82f3a5, var(--good));
}

.lower {
  color: #fff8e8;
  background: linear-gradient(180deg, #ff8488, var(--bad));
}

.arrow {
  font-size: 0.92em;
  transform: translateY(-1px);
}

.history-wrap {
  margin-top: 22px;
  overflow: hidden;
}

.history {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  scrollbar-color: rgba(255, 248, 232, 0.4) transparent;
}

.mini-card {
  flex: 0 0 auto;
  width: 39px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(226, 211, 181, 0.72);
  border-radius: 6px;
  color: var(--black);
  background: var(--paper);
  font-weight: 950;
  box-shadow: 0 7px 14px rgba(0, 0, 0, 0.22);
  animation: miniDeal 300ms ease both;
}

.mini-card.red {
  color: var(--red);
}

.mini-card.pending {
  color: rgba(255, 248, 232, 0.72);
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(4, 31, 24, 0.48);
}

@keyframes tableSweep {
  0%,
  42% {
    transform: translateX(-84%);
  }
  72%,
  100% {
    transform: translateX(84%);
  }
}

@keyframes dashGlow {
  0%,
  100% {
    opacity: 0.42;
  }
  50% {
    opacity: 0.85;
  }
}

@keyframes currentFloat {
  0%,
  100% {
    transform: translateY(0) rotateZ(-1deg);
  }
  50% {
    transform: translateY(-7px) rotateZ(1deg);
  }
}

@keyframes deckPulse {
  0%,
  100% {
    transform: rotateY(180deg) translateY(0);
  }
  50% {
    transform: rotateY(180deg) translateY(-5px);
  }
}

@keyframes revealDeal {
  0% {
    transform: rotateY(180deg) translateX(0) translateY(0) scale(1);
  }
  48% {
    transform: rotateY(92deg) translateX(-14px) translateY(-26px) scale(1.05);
  }
  100% {
    transform: rotateY(0deg) translateX(0) translateY(0) scale(1);
  }
}

@keyframes receiveCard {
  0% {
    transform: translateY(-16px) scale(0.96) rotateZ(4deg);
    opacity: 0.4;
  }
  100% {
    transform: translateY(0) scale(1) rotateZ(-1deg);
    opacity: 1;
  }
}

@keyframes cardJoy {
  0%,
  100% {
    transform: translateY(0) rotateZ(0) scale(1);
    filter: brightness(1);
  }
  28% {
    transform: translateY(-20px) rotateZ(-3deg) scale(1.08);
    filter: brightness(1.2);
  }
  58% {
    transform: translateY(4px) rotateZ(2deg) scale(1.02);
  }
  78% {
    transform: translateY(-7px) rotateZ(-1deg) scale(1.04);
  }
}

@keyframes wrongPunish {
  0% {
    transform: translateX(0) translateY(0) rotateZ(0) scale(1);
    filter: brightness(1);
  }
  10% {
    transform: translateX(-20px) translateY(8px) rotateZ(-7deg) scale(0.98);
    filter: brightness(0.9) saturate(1.5);
  }
  22% {
    transform: translateX(24px) translateY(-6px) rotateZ(8deg) scale(1.03);
  }
  36% {
    transform: translateX(-16px) translateY(5px) rotateZ(-5deg) scale(0.96);
    filter: brightness(0.72) saturate(2.1);
  }
  54% {
    transform: translateX(12px) translateY(2px) rotateZ(3deg) scale(0.98);
  }
  72% {
    transform: translateX(-7px) translateY(0) rotateZ(-2deg) scale(0.99);
  }
  100% {
    transform: translateX(0) translateY(0) rotateZ(0) scale(1);
    filter: brightness(1);
  }
}

@keyframes tieNudge {
  0%,
  100% {
    transform: translateY(0) rotateZ(0);
  }
  35% {
    transform: translateY(-8px) rotateZ(-2deg);
  }
  70% {
    transform: translateY(4px) rotateZ(2deg);
  }
}

@keyframes correctGlow {
  0%,
  100% {
    box-shadow: 0 20px 34px var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.62);
  }
  45% {
    box-shadow:
      0 20px 34px rgba(0, 0, 0, 0.32),
      0 0 24px rgba(56, 216, 123, 0.9),
      0 0 56px rgba(255, 228, 109, 0.72),
      inset 0 0 0 3px rgba(255, 228, 109, 0.82);
  }
}

@keyframes painFlash {
  0%,
  100% {
    box-shadow: 0 20px 34px var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.62);
    filter: none;
  }
  22%,
  54% {
    box-shadow:
      0 20px 34px rgba(0, 0, 0, 0.42),
      0 0 30px rgba(255, 33, 71, 0.9),
      inset 0 0 0 4px rgba(255, 33, 71, 0.82);
    filter: sepia(0.4) saturate(2.2) brightness(0.86);
  }
}

@keyframes wrongShake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-11px) rotateZ(-2deg);
  }
  40% {
    transform: translateX(10px) rotateZ(2deg);
  }
  60% {
    transform: translateX(-7px) rotateZ(-1deg);
  }
  80% {
    transform: translateX(5px) rotateZ(1deg);
  }
}

@keyframes tableJoy {
  0%,
  100% {
    box-shadow: 0 28px 60px rgba(0, 0, 0, 0.34), inset 0 0 0 9px rgba(0, 0, 0, 0.12);
  }
  36% {
    box-shadow:
      0 28px 60px rgba(0, 0, 0, 0.34),
      0 0 44px rgba(255, 228, 109, 0.38),
      inset 0 0 0 9px rgba(255, 228, 109, 0.2);
  }
}

@keyframes tablePain {
  0%,
  100% {
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.32), inset 0 0 0 6px rgba(0, 0, 0, 0.12);
  }
  34% {
    box-shadow:
      0 18px 36px rgba(0, 0, 0, 0.34),
      0 0 42px rgba(255, 33, 71, 0.38),
      inset 0 0 0 6px rgba(255, 33, 71, 0.2);
  }
}

@keyframes contentPainShake {
  0%,
  100% {
    transform: translateX(0) rotateZ(0);
  }
  10% {
    transform: translateX(-10px) rotateZ(-0.7deg);
  }
  22% {
    transform: translateX(12px) rotateZ(0.8deg);
  }
  36% {
    transform: translateX(-8px) rotateZ(-0.45deg);
  }
  54% {
    transform: translateX(7px) rotateZ(0.35deg);
  }
  76% {
    transform: translateX(-3px) rotateZ(-0.18deg);
  }
}

@keyframes borderPain {
  0%,
  100% {
    border-color: rgba(225, 188, 95, 0.5);
  }
  32% {
    border-color: rgba(255, 33, 71, 0.95);
    box-shadow: inset 0 0 26px rgba(255, 33, 71, 0.24);
  }
}

@keyframes scoreCelebrate {
  0%,
  100% {
    transform: translateY(0);
  }
  36% {
    transform: translateY(-4px);
    border-color: rgba(255, 228, 109, 0.58);
    box-shadow: 0 0 22px rgba(255, 228, 109, 0.18);
  }
}

@keyframes joyRing {
  0% {
    opacity: 0.92;
    transform: translate(-50%, -50%) scale(0.2);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(12);
  }
}

@keyframes impactRing {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.15);
  }
  72% {
    opacity: 0.82;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(15);
  }
}

@keyframes slashCut {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-18deg) scaleX(0);
  }
  16% {
    opacity: 1;
  }
  52% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-18deg) scaleX(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-18deg) scaleX(1.08) translateY(28px);
  }
}

@keyframes sparkBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(0.12);
  }
}

@keyframes ribbonBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(0deg) scale(0.55);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(420deg) scale(0.75);
  }
}

@keyframes shardBlast {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(0deg) scale(0.35);
  }
  12% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(620deg) scale(0.82);
  }
}

@keyframes tieGlow {
  0%,
  100% {
    box-shadow: 0 20px 34px var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.62);
  }
  45% {
    box-shadow: 0 20px 34px rgba(0, 0, 0, 0.32), 0 0 34px rgba(105, 183, 255, 0.86), inset 0 0 0 3px rgba(105, 183, 255, 0.7);
  }
}

@keyframes joyTextPop {
  0% {
    transform: translateY(10px) scale(0.9);
    opacity: 0.1;
  }
  46% {
    transform: translateY(-5px) scale(1.12);
    opacity: 1;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes painTextDrop {
  0% {
    transform: translateY(-12px) scale(1.08);
    opacity: 0.25;
  }
  22% {
    transform: translateY(7px) scale(0.96);
    opacity: 1;
  }
  38% {
    transform: translateX(-9px) translateY(0);
  }
  52% {
    transform: translateX(8px) translateY(0);
  }
  70% {
    transform: translateX(-4px) translateY(0);
  }
  100% {
    transform: translateX(0) translateY(0) scale(1);
  }
}

@keyframes textPop {
  0% {
    transform: translateY(8px) scale(0.96);
    opacity: 0.4;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes miniDeal {
  0% {
    transform: translateY(-8px) rotateZ(7deg);
    opacity: 0;
  }
  100% {
    transform: translateY(0) rotateZ(0);
    opacity: 1;
  }
}

@media (max-width: 760px) {
  body {
    padding: 16px;
  }

  h1 {
    font-size: 3.35rem;
  }

  .top-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .setup {
    justify-content: stretch;
  }

  .count-field {
    flex: 1 1 130px;
  }

  .count-field input,
  .primary-btn {
    width: 100%;
  }

  .table {
    border-radius: 14px;
    padding: 18px;
  }

  .score-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .score-box {
    min-height: 64px;
    padding: 11px 10px;
  }

  .score-box strong {
    font-size: 1.8rem;
  }

  .arena {
    grid-template-columns: 1fr;
    min-height: auto;
    gap: 14px;
  }

  .versus {
    order: 2;
  }

  .versus span {
    min-width: 58px;
    min-height: 58px;
  }

  .card-stack:first-child {
    order: 1;
  }

  .card-stack:last-child {
    order: 3;
  }

  .playing-card {
    width: min(46vw, 168px);
  }

  .rank {
    font-size: 1.95rem;
  }

  .suit {
    font-size: 1.55rem;
  }

  .center-suit {
    font-size: 5.3rem;
  }

  .guess-btn {
    font-size: 1.05rem;
  }

  .actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: 2.55rem;
  }

  .score-row {
    grid-template-columns: 1fr;
  }

  .playing-card {
    width: min(62vw, 174px);
  }

  .actions {
    grid-template-columns: 1fr;
  }
}

/* Mobile-first play layout */
body {
  display: block;
  overflow-x: hidden;
  padding: 10px 10px calc(98px + env(safe-area-inset-bottom));
}

.game-shell {
  width: min(960px, 100%);
  margin: 0 auto;
  gap: 10px;
}

.top-panel {
  align-items: stretch;
  flex-direction: column;
  gap: 10px;
}

.title-block {
  display: grid;
  gap: 10px;
}

.back-link {
  width: max-content;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: rgba(255, 248, 232, 0.88);
  background: rgba(3, 28, 22, 0.36);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.25;
  text-decoration: none;
}

.eyebrow {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  text-transform: none;
}

h1 {
  font-size: 2.35rem;
  line-height: 1.22;
}

.setup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(118px, 0.8fr);
  align-items: end;
  gap: 10px;
}

.count-field {
  min-width: 0;
  gap: 5px;
}

.count-field input {
  width: 100%;
  min-height: 52px;
  text-align: center;
  font-size: 1.08rem;
  font-weight: 800;
}

.primary-btn {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
}

.table {
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.32), inset 0 0 0 6px rgba(0, 0, 0, 0.12);
}

.table::before,
.table::after {
  inset: 8px;
  border-radius: 8px;
}

.score-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 9px;
}

.score-box {
  min-height: 52px;
  padding: 8px 6px;
  text-align: center;
}

.score-box span {
  font-size: 0.68rem;
}

.score-box strong {
  font-size: 1.35rem;
}

.progress {
  height: 8px;
  margin-bottom: 12px;
}

.arena {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  min-height: auto;
}

.card-stack {
  gap: 7px;
}

.card-stack:first-child {
  order: 1;
}

.card-stack:last-child {
  order: 2;
}

.versus {
  order: 0;
  grid-column: 1 / -1;
}

.versus span {
  min-width: 56px;
  min-height: 34px;
  border-radius: 999px;
  font-size: 0.86rem;
}

.card-shadow {
  bottom: 27px;
  width: 72%;
  height: 18px;
}

.playing-card {
  width: min(38vw, 148px);
}

.card-face {
  padding: 10px;
}

.rank {
  font-size: 1.75rem;
}

.suit {
  margin-top: 3px;
  font-size: 1.36rem;
}

.center-suit {
  font-size: 4.25rem;
}

.card-caption {
  font-size: 0.72rem;
}

.result-banner {
  min-height: 36px;
  margin: 8px auto 10px;
  padding: 0 8px;
  font-size: 1rem;
}

.actions {
  position: fixed;
  left: 50%;
  bottom: calc(8px + env(safe-area-inset-bottom));
  width: min(960px, calc(100% - 20px));
  transform: translateX(-50%);
  z-index: 4;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 -4px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(2, 23, 18, 0.78);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}

.guess-btn {
  min-height: 66px;
  border-radius: 10px;
  font-size: 1.12rem;
}

.history-wrap {
  margin-top: 10px;
}

.history {
  min-height: 46px;
  gap: 6px;
  padding-bottom: 6px;
}

.mini-card {
  width: 32px;
  height: 43px;
  font-size: 0.78rem;
}

@media (max-width: 360px) {
  .setup {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2rem;
  }

  .playing-card {
    width: min(40vw, 132px);
  }

  .guess-btn {
    min-height: 62px;
    font-size: 1rem;
  }
}

@media (min-width: 761px) {
  body {
    display: grid;
    place-items: center;
    padding: 28px;
  }

  .game-shell {
    width: min(1120px, 100%);
    gap: 18px;
  }

  .top-panel {
    align-items: end;
    flex-direction: row;
    justify-content: space-between;
    gap: 18px;
  }

  .back-link {
    min-height: 36px;
  }

  .eyebrow {
    margin: 0 0 4px;
  }

  h1 {
    font-size: 4.2rem;
  }

  .setup {
    display: flex;
    align-items: end;
    justify-content: flex-end;
    gap: 12px;
  }

  .count-field input {
    width: 116px;
    min-height: 46px;
  }

  .primary-btn {
    width: auto;
    min-height: 46px;
    padding: 0 22px;
  }

  .table {
    border-radius: 18px;
    padding: 34px;
    box-shadow: 0 28px 60px rgba(0, 0, 0, 0.34), inset 0 0 0 9px rgba(0, 0, 0, 0.12);
  }

  .table::before,
  .table::after {
    inset: 14px;
    border-radius: 12px;
  }

  .score-row {
    gap: 12px;
    margin-bottom: 16px;
  }

  .score-box {
    min-height: 72px;
    padding: 13px 16px;
    text-align: left;
  }

  .score-box span {
    font-size: 0.78rem;
  }

  .score-box strong {
    font-size: 2.25rem;
  }

  .progress {
    height: 9px;
    margin-bottom: 42px;
  }

  .arena {
    grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
    gap: 42px;
    min-height: 330px;
  }

  .card-stack:first-child,
  .card-stack:last-child,
  .versus {
    order: initial;
  }

  .versus {
    grid-column: auto;
  }

  .versus span {
    min-width: 72px;
    min-height: 72px;
    border-radius: 50%;
    font-size: 1rem;
  }

  .card-shadow {
    bottom: 34px;
    width: min(58%, 210px);
    height: 26px;
  }

  .playing-card {
    width: clamp(160px, 18vw, 224px);
  }

  .card-face {
    padding: 18px;
  }

  .rank {
    font-size: 2.5rem;
  }

  .suit {
    margin-top: 6px;
    font-size: 2rem;
  }

  .center-suit {
    font-size: 7.4rem;
  }

  .card-caption {
    font-size: 0.82rem;
  }

  .result-banner {
    min-height: 42px;
    margin: 8px auto 20px;
    font-size: 1rem;
  }

  .actions {
    position: relative;
    left: auto;
    bottom: auto;
    width: auto;
    transform: none;
    grid-template-columns: repeat(2, minmax(130px, 220px));
    justify-content: center;
    gap: 14px;
    margin: -4px 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
  }

  .guess-btn {
    min-height: 58px;
    font-size: 1.24rem;
  }

  .history-wrap {
    margin-top: 22px;
  }

  .history {
    min-height: 56px;
    gap: 8px;
    padding-bottom: 10px;
  }

  .mini-card {
    width: 39px;
    height: 52px;
    font-size: 1rem;
  }
}

/* Lighter typography */
.back-link,
.eyebrow,
.count-field,
.score-box span,
.card-caption,
.versus span,
.result-banner,
.guess-btn,
.primary-btn,
.mini-card,
.rank,
.suit,
.center-suit {
  font-weight: 600;
}

.score-box strong,
h1 {
  font-weight: 700;
}
