:root {
  --bg: #07140f;
  --felt-dark: #0f4c37;
  --felt: #176847;
  --felt-light: #218259;
  --gold: #e6c071;
  --paper: #f9f5ee;
  --ink: #201d1b;
  --red: #ba2f3b;
  --shadow: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", serif;
  color: #f5f0df;
  background:
    radial-gradient(circle at top, rgba(255, 224, 154, 0.08), transparent 28%),
    linear-gradient(180deg, #08100d 0%, #030706 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent 40%),
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.02) 0,
      rgba(255, 255, 255, 0.02) 2px,
      transparent 2px,
      transparent 10px
    );
  pointer-events: none;
}

.container {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 2.5rem;
}

header,
footer {
  text-align: center;
}

header {
  padding: 1rem 0 1.5rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.35rem;
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(1.7rem, 3vw, 2.5rem);
}

.subtitle {
  color: rgba(245, 240, 223, 0.78);
}

.table-surface {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(230, 192, 113, 0.25);
  border-radius: 28px;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 50% 15%, rgba(255, 255, 255, 0.09), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(0, 0, 0, 0.2), transparent 40%),
    linear-gradient(180deg, var(--felt-light) 0%, var(--felt) 46%, var(--felt-dark) 100%);
  box-shadow:
    inset 0 0 0 14px rgba(80, 42, 18, 0.42),
    inset 0 0 0 16px rgba(219, 193, 143, 0.12),
    0 26px 60px var(--shadow);
}

.table-surface::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px solid rgba(239, 220, 167, 0.18);
  border-radius: 20px;
  pointer-events: none;
}

.hero,
.menu-grid,
.table-grid,
.dice-grid,
.card-grid,
.status-bar,
.card-log {
  position: relative;
  z-index: 1;
}

.hero {
  max-width: 620px;
  padding: 1rem 0 1.5rem;
}

.menu-grid,
.table-grid {
  display: grid;
  gap: 1.2rem;
}

.menu-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.table-grid {
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  align-items: start;
}

.panel {
  border: 1px solid rgba(255, 244, 214, 0.12);
  border-radius: 22px;
  padding: 1.2rem;
  background: rgba(6, 24, 18, 0.34);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.menu-card h3,
.panel h3 {
  margin-bottom: 0.6rem;
}

.menu-card p,
.panel p,
.status-pill {
  color: rgba(245, 240, 223, 0.86);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.8rem 1.3rem;
  border: none;
  border-radius: 999px;
  text-decoration: none;
  color: #1a140d;
  background: linear-gradient(180deg, #f5ddae 0%, var(--gold) 100%);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  font-weight: 700;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn.secondary {
  color: #f5f0df;
  background: rgba(12, 35, 28, 0.72);
  border: 1px solid rgba(255, 244, 214, 0.16);
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.top-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.inline-action {
  margin: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: rgba(7, 20, 15, 0.38);
  border: 1px solid rgba(255, 244, 214, 0.12);
}

.top-nav .status-pill {
  padding: 0.55rem 0.85rem;
  font-size: 0.92rem;
}

.top-nav .btn,
.nav-btn {
  min-height: 38px;
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.table-stack {
  position: relative;
  width: min(200px, 50vw);
  height: 280px;
  margin: 0 auto 1rem;
}

.table-stack-inline {
  margin: 0;
}

.deck-shadow,
.deck-card {
  position: absolute;
  inset: 0;
  border-radius: 20px;
}

.deck-shadow {
  transform: translate(12px, 10px);
  background: rgba(6, 16, 13, 0.42);
}

.deck-card {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.18), transparent 26%),
    linear-gradient(135deg, #6d1721 0%, #8f2533 40%, #4f0f17 100%);
  border: 7px solid #f1eadb;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.card-back-photo {
  background:
    linear-gradient(rgba(12, 8, 6, 0.08), rgba(12, 8, 6, 0.08)),
    var(--card-back-image) center/cover no-repeat,
    #241611;
}

.deck-card::before,
.deck-card::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 14px;
  border: 2px solid rgba(255, 242, 211, 0.58);
}

.deck-card::after {
  inset: 28px;
  border-style: dashed;
  opacity: 0.7;
}

.deck-emblem {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 3rem;
  color: rgba(255, 245, 220, 0.88);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 1rem;
}

.featured-card-wrap {
  display: flex;
  justify-content: center;
  margin: 0;
}

.card-stage {
  display: grid;
  grid-template-columns: 200px minmax(220px, 280px);
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  width: fit-content;
  max-width: 100%;
}

.click-zone-form {
  margin: 0;
}

.click-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 1rem;
  border: 0;
  border-radius: 20px;
  color: inherit;
  background: rgba(7, 20, 15, 0.2);
  cursor: pointer;
}

.click-zone:hover {
  background: rgba(255, 244, 214, 0.06);
}

.click-zone-copy {
  margin-bottom: 0.9rem;
  color: rgba(245, 240, 223, 0.88);
}

.card-click-zone {
  min-height: 520px;
  justify-content: center;
}

.dice-click-zone {
  gap: 0.8rem;
}

.playing-card {
  position: relative;
  perspective: 1200px;
  min-height: 208px;
}

.featured-card {
  width: min(100%, 280px);
  min-height: 390px;
}

.featured-card .playing-card-inner {
  min-height: 390px;
}

.featured-card .card-rank {
  font-size: 2.2rem;
}

.featured-card .card-suit {
  font-size: 1.8rem;
}

.featured-card .card-center {
  font-size: 5rem;
}

.playing-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 208px;
  transform-style: preserve-3d;
  transition: transform 0.85s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.playing-card.is-new .playing-card-inner {
  animation: card-flip 0.95s cubic-bezier(0.22, 0.8, 0.2, 1) both;
}

.playing-card-face {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  backface-visibility: hidden;
  overflow: hidden;
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.22);
}

.playing-card-face.front {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.8rem;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), transparent 24%),
    linear-gradient(180deg, #fffdf9 0%, var(--paper) 100%);
  border: 6px solid #f7f1e3;
}

.playing-card-face.back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.16), transparent 24%),
    linear-gradient(135deg, #651321 0%, #8f2332 48%, #470f17 100%);
  border: 6px solid #f7f1e3;
}

.playing-card-face.back::before,
.playing-card-face.back::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px solid rgba(255, 245, 220, 0.62);
  border-radius: 12px;
}

.playing-card-face.back::after {
  inset: 24px;
  border-style: dashed;
}

.card-corner {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  font-weight: 700;
  line-height: 1;
}

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

.card-rank {
  font-size: 1.55rem;
}

.card-suit {
  font-size: 1.25rem;
}

.card-center {
  display: grid;
  place-items: center;
  font-size: 3rem;
  letter-spacing: 0.06em;
}

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

.playing-card.accent .front {
  color: #7d1832;
  background:
    radial-gradient(circle at top, rgba(255, 219, 113, 0.35), transparent 38%),
    linear-gradient(180deg, #fff6e3 0%, #f3e3bc 100%);
}

.playing-card.lowest .front {
  box-shadow: 0 0 0 3px rgba(255, 170, 170, 0.8), 0 16px 28px rgba(0, 0, 0, 0.22);
}

.playing-card.joker-hit .front {
  box-shadow: 0 0 0 3px rgba(255, 225, 117, 0.8), 0 16px 28px rgba(0, 0, 0, 0.22);
}

.card-caption {
  margin-top: 0.55rem;
  text-align: center;
  font-size: 0.95rem;
}

.card-log {
  margin-top: 1.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(7, 20, 15, 0.3);
  border-radius: 16px;
  overflow: hidden;
}

th,
td {
  padding: 0.8rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 244, 214, 0.08);
}

th {
  font-size: 0.92rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 244, 214, 0.75);
}

.laag {
  background: rgba(186, 47, 59, 0.18);
}

.hoog {
  background: rgba(104, 181, 123, 0.18);
}

.joker {
  background: rgba(234, 194, 88, 0.2);
}

.dice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.dice-player {
  padding: 1rem;
  border-radius: 22px;
  background: rgba(7, 20, 15, 0.34);
  border: 1px solid rgba(255, 244, 214, 0.12);
}

.dice-player.hoog {
  outline: 2px solid rgba(154, 231, 173, 0.35);
}

.dice-player.laag {
  outline: 2px solid rgba(255, 160, 160, 0.35);
}

.dice-pair {
  display: flex;
  gap: 0.9rem;
  margin: 1rem 0 0.8rem;
  justify-content: center;
}

.die {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  width: 78px;
  height: 78px;
  padding: 0.5rem;
  border-radius: 18px;
  background:
    linear-gradient(180deg, #fffdf9 0%, #e9e1d3 100%);
  box-shadow:
    inset 0 -6px 12px rgba(0, 0, 0, 0.08),
    0 14px 20px rgba(0, 0, 0, 0.22);
}

.die.is-rolling {
  animation: die-roll 0.85s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pip {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: transparent;
}

.pip.active {
  background: radial-gradient(circle at 35% 35%, #444 0%, #111 65%);
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 244, 214, 0.1);
}

footer {
  margin-top: 1.6rem;
  color: rgba(245, 240, 223, 0.62);
}

@keyframes card-flip {
  0% {
    transform: rotateY(180deg) translateY(-8px) scale(0.96);
  }
  55% {
    transform: rotateY(84deg) translateY(-18px) scale(1.03);
  }
  100% {
    transform: rotateY(0deg) translateY(0) scale(1);
  }
}

@keyframes die-roll {
  0% {
    transform: rotate(0deg) scale(0.9);
  }
  35% {
    transform: rotate(120deg) translateY(-8px) scale(1.05);
  }
  70% {
    transform: rotate(250deg) translateY(4px) scale(0.98);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@media (max-width: 860px) {
  .container {
    width: min(100% - 1.2rem, 100%);
    padding-top: 0.8rem;
  }

  header {
    padding: 0.6rem 0 1rem;
  }

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

  .status-bar {
    gap: 0.6rem;
  }

  .top-nav {
    gap: 0.5rem;
  }

  .status-pill,
  .inline-action,
  .inline-action .btn,
  .nav-btn {
    width: 100%;
    justify-content: center;
  }

  .top-nav .status-pill {
    width: auto;
    flex: 1 1 calc(50% - 0.25rem);
    justify-content: center;
  }

  .btn-row {
    flex-direction: column;
  }

  .btn-row .btn,
  .btn-row form,
  .btn-row .status-pill {
    width: 100%;
  }

  .table-stack {
    width: min(180px, 60vw);
    height: 250px;
  }

  .card-click-zone {
    min-height: auto;
  }

  .card-stage {
    width: 100%;
    justify-content: center;
  }

  .featured-card {
    width: min(100%, 260px);
    min-height: 360px;
  }

  .featured-card .playing-card-inner {
    min-height: 360px;
  }

  .card-log table {
    min-width: 560px;
  }
}

@media (max-width: 560px) {
  .container {
    width: min(100% - 1rem, 100%);
  }

  .table-surface {
    padding: 0.9rem;
    border-radius: 22px;
  }

  .table-surface::before {
    inset: 8px;
    border-radius: 16px;
  }

  .panel {
    padding: 0.9rem;
    border-radius: 18px;
  }

  h1 {
    font-size: 1.9rem;
    letter-spacing: 0.05em;
  }

  h2 {
    font-size: 1.4rem;
  }

  h3 {
    font-size: 1.15rem;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-pill {
    padding: 0.7rem 0.85rem;
    font-size: 0.92rem;
  }

  .top-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .top-nav .status-pill,
  .top-nav .inline-action,
  .top-nav .nav-btn,
  .top-nav .inline-action .btn {
    width: 100%;
  }

  .top-nav .status-pill {
    min-height: 42px;
    padding: 0.6rem 0.75rem;
    font-size: 0.88rem;
    text-align: center;
    justify-content: center;
  }

  .top-nav .btn,
  .nav-btn {
    min-height: 40px;
    padding: 0.6rem 0.75rem;
    font-size: 0.88rem;
  }

  .btn {
    width: 100%;
    min-height: 44px;
    padding: 0.75rem 1rem;
  }

  .click-zone {
    padding: 0.8rem;
  }

  .dice-pair {
    justify-content: center;
    gap: 0.6rem;
    margin: 0.7rem 0;
  }

  .die {
    width: 64px;
    height: 64px;
    padding: 0.4rem;
    border-radius: 14px;
  }

  .card-stage {
    grid-template-columns: 1fr;
    gap: 0.8rem;
    width: 100%;
  }

  .table-stack {
    width: min(150px, 48vw);
    height: 210px;
  }

  .featured-card {
    width: min(100%, 210px);
    min-height: 300px;
  }

  .featured-card .playing-card-inner {
    min-height: 300px;
  }

  .featured-card .card-rank {
    font-size: 1.7rem;
  }

  .featured-card .card-suit {
    font-size: 1.4rem;
  }

  .featured-card .card-center {
    font-size: 3.8rem;
  }

  .click-zone-copy,
  .card-caption,
  .result-badge,
  td,
  th {
    font-size: 0.9rem;
  }

  .click-zone-copy {
    margin-bottom: 0.6rem;
    text-align: center;
  }

  .result-badge {
    justify-content: center;
    width: 100%;
    text-align: center;
  }

  th,
  td {
    padding: 0.65rem;
  }

  .card-log table {
    min-width: 480px;
  }
}

@media (max-width: 380px) {
  .container {
    width: calc(100% - 0.6rem);
  }

  .table-surface {
    padding: 0.7rem;
  }

  .top-nav {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 0.8rem;
  }

  .table-stack {
    width: min(132px, 46vw);
    height: 186px;
  }

  .featured-card {
    width: min(100%, 188px);
    min-height: 272px;
  }

  .featured-card .playing-card-inner {
    min-height: 272px;
  }

  .featured-card .card-center {
    font-size: 3.2rem;
  }

  .die {
    width: 58px;
    height: 58px;
  }
}
