/* Kitchen table layout: centre piles, table cards and held hand are independent layers. */

html,
body {
  height: 100%;
  overflow: hidden;
}

.game-shell {
  height: 100vh;
  max-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  padding-top: 10px;
  padding-bottom: 10px;
  overflow: hidden;
}

.room-stage {
  min-height: 0;
  height: 100%;
  margin-top: 4px;
  margin-bottom: 0;
  overflow: hidden;
}

.table { inset: 6% 5% 15%; }
.statusbar { margin-top: 0; min-height: 40px; }

.centre-zone {
  left: 50%;
  top: 43%;
  transform: translate(-50%, -50%);
  z-index: 20;
}

.centre-zone::before {
  inset: -24px -36px;
  background: rgba(0,0,0,.055);
}

.seat-player {
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  width: auto;
  transform: none;
  z-index: 30;
  pointer-events: none;
}

.seat-player > * { pointer-events: auto; }

.self-table-zone {
  position: absolute;
  left: 50%;
  bottom: 27%;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 7px;
  margin: 0;
  z-index: 31;
}

.self-face-row {
  gap: 14px;
  min-height: 92px;
}

.self-face-row .face-stack {
  width: 66px;
  height: 92px;
}

.self-face-row .card { width: 66px; }

.player-label {
  order: 2;
  margin-top: 4px;
  white-space: nowrap;
}

/* Identity sits in the quiet strip between table cards and the held hand. */
.self-identity-row {
  position: absolute;
  left: 50%;
  bottom: 11.5%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 95;
  pointer-events: auto;
}

.self-nameplate {
  position: static;
  transform: none;
  margin: 0;
  white-space: nowrap;
}

/* Beer mats -------------------------------------------------------------- */
.beer-mat {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0;
  background:
    radial-gradient(circle at 50% 42%, rgba(255,255,255,.9) 0 54%, transparent 55%),
    radial-gradient(circle at 50% 50%, #d7c8a1 0 68%, #9e855a 69% 74%, #6c5434 75% 100%);
  color: #2d2116;
  box-shadow: 0 5px 12px rgba(0,0,0,.28), inset 0 0 0 2px rgba(255,255,255,.35);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  user-select: none;
}

.beer-mat::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(80,55,30,.28);
  border-radius: 50%;
}

.beer-mat-drink {
  position: absolute;
  top: -18px;
  right: -4px;
  font-size: 1.8rem;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.3));
  z-index: 3;
}

.beer-mat-name {
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  z-index: 2;
}

.beer-mat-score {
  font-size: 1.7rem;
  font-weight: 900;
  z-index: 2;
}

.beer-mat-label {
  font-size: .58rem;
  font-style: italic;
  opacity: .72;
  z-index: 2;
}

.opponent-beer-mat {
  width: 62px;
  height: 62px;
  margin: 0 auto 8px;
  transform: rotate(-5deg);
}

.seat-right .opponent-beer-mat { transform: rotate(5deg); }
.opponent-beer-mat .beer-mat-drink { top: -15px; font-size: 1.45rem; }
.opponent-beer-mat .beer-mat-name { font-size: .64rem; }
.opponent-beer-mat .beer-mat-score { font-size: 1.35rem; }
.opponent-beer-mat .beer-mat-label { font-size: .48rem; }

.self-beer-mat {
  width: 68px;
  height: 68px;
  transform: rotate(4deg);
}

.self-beer-mat .beer-mat-drink { font-size: 1.55rem; top: -16px; }
.self-beer-mat .beer-mat-score { font-size: 1.45rem; }

/* Held hand -------------------------------------------------------------- */
.hand {
  position: absolute;
  left: 50%;
  bottom: -76px;
  transform: translateX(-50%);
  min-height: 150px;
  width: min(760px, 92%);
  padding: 16px 54px 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  overflow: visible;
  isolation: isolate;
  z-index: 100;
}

.hand button.card {
  appearance: none;
  width: clamp(88px, 8vw, 104px);
  flex: 0 0 clamp(88px, 8vw, 104px);
  min-height: 126px;
  margin-left: clamp(-44px, -3.3vw, -35px);
  padding: 10px 8px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  line-height: .92;
  font-size: clamp(1.35rem, 2.5vw, 1.9rem);
  letter-spacing: -.04em;
  border-radius: 11px;
  transform-origin: 50% 185%;
  transform: rotate(calc((var(--card-index) - var(--card-mid)) * 5.4deg));
  box-shadow: 0 7px 16px rgba(0,0,0,.38);
  z-index: calc(100 + var(--card-index));
}

.hand button.card:first-child { margin-left: 0; }

.hand button.card::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  width: 31px;
  height: 37px;
  border-radius: 7px;
  background: rgba(255,255,255,.34);
  z-index: -1;
}

.hand button.card:hover,
.hand button.card:focus-visible {
  transform: translateY(-18px) rotate(0deg) scale(1.04);
  outline: none;
  z-index: 150;
}

.hand button.card.selected {
  transform: translateY(-30px) rotate(0deg) scale(1.055);
  z-index: 160;
}

.play-actions {
  position: absolute;
  left: 50%;
  bottom: -112px;
  transform: translateX(-50%);
  z-index: 170;
  min-height: 36px;
  margin: 0;
  white-space: nowrap;
}

.table::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: -10px;
  height: 18px;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(to bottom, rgba(255,255,255,.025), rgba(0,0,0,.25));
  pointer-events: none;
  z-index: 35;
}

body[data-theme="kitchen"] .room-stage {
  background:
    radial-gradient(circle at 9% 11%, rgba(244,205,139,.16) 0 52px, transparent 54px),
    radial-gradient(circle at 91% 12%, rgba(244,205,139,.13) 0 48px, transparent 50px),
    rgba(0,0,0,.17);
}

@media (max-height: 760px) and (min-width: 701px) {
  .game-shell { padding-top: 6px; padding-bottom: 6px; }
  .topbar h1 { font-size: 1.9rem; }
  .eyebrow { font-size: .68rem; }
  .table { inset: 4% 5% 17%; }
  .centre-zone { top: 40%; }
  .self-table-zone { bottom: 25%; }
  .self-identity-row { bottom: 11%; transform: translateX(-50%) scale(.9); }
  .hand { bottom: -68px; transform: translateX(-50%) scale(.9); transform-origin: center top; }
}

@media (max-width: 700px) {
  html, body { overflow: hidden; }

  .game-shell {
    padding: 6px 8px;
    gap: 5px;
  }

  .room-stage {
    min-height: 0;
    height: 100%;
    margin: 0;
  }

  .table { inset: 4% 2.5% 18%; }
  .centre-zone { top: 39%; gap: 28px; }
  .self-table-zone { bottom: 28%; }

  .self-face-row { min-height: 76px; gap: 9px; }
  .self-face-row .face-stack { width: 54px; height: 76px; }
  .self-face-row .card { width: 54px; }

  .self-identity-row {
    bottom: 12%;
    gap: 8px;
    transform: translateX(-50%) scale(.82);
  }

  .opponent-beer-mat {
    width: 50px;
    height: 50px;
    margin-bottom: 5px;
  }
  .opponent-beer-mat .beer-mat-drink { font-size: 1.1rem; top: -11px; }
  .opponent-beer-mat .beer-mat-label { display: none; }

  .hand {
    bottom: -68px;
    width: 98%;
    min-height: 132px;
    padding: 18px 24px 0;
  }

  .hand button.card {
    width: 76px;
    flex-basis: 76px;
    min-height: 108px;
    margin-left: -34px;
    font-size: 1.3rem;
    transform: rotate(calc((var(--card-index) - var(--card-mid)) * 4.8deg));
  }

  .hand button.card:first-child { margin-left: 0; }
  .play-actions { bottom: -104px; }
  .statusbar { min-height: 34px; font-size: .8rem; }
}
