:root {
  --felt: #146246;
  --felt-dark: #0b3a2c;
  --wood: #2c170e;
  --wood-edge: #5a3218;
  --gold: #d7b056;
  --gold-dim: #8a6d2e;
  --ink: #f3ead2;
  --muted: #cbbd96;
  --danger: #c45c4a;
  --seat: #10261d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --card-w: 112px;
  --card-h: 158px;
  font-family: "Outfit", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background:
    radial-gradient(1200px 700px at 50% -10%, #4a2414 0%, transparent 55%),
    linear-gradient(180deg, #1a0d08 0%, #0c0705 100%);
  color: var(--ink);
  overflow: hidden;
}

button, input, select { font-family: inherit; }

.hidden { display: none !important; }

#screen-menu, #screen-table { height: 100%; }

#screen-menu {
  display: grid;
  place-items: center;
  padding: 24px;
}

.menu-card {
  width: min(520px, 100%);
  background: linear-gradient(180deg, rgba(44, 23, 14, 0.96), rgba(18, 10, 7, 0.96));
  border: 1px solid var(--gold-dim);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(215, 176, 86, 0.25);
  padding: 36px 34px 30px;
  position: relative;
}

.menu-card:before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(215, 176, 86, 0.18);
  pointer-events: none;
}

.brand {
  text-align: center;
  margin-bottom: 28px;
}

.brand h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0.28em;
  font-size: 52px;
  color: var(--gold);
  line-height: 1;
}

.brand p {
  margin-top: 8px;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input, .field select {
  width: 100%;
  background: #140c08;
  border: 1px solid #6a4a24;
  color: var(--ink);
  padding: 10px 12px;
  font-size: 15px;
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  border: 0;
  cursor: pointer;
  padding: 12px 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
}

.btn-gold {
  background: linear-gradient(180deg, #e6c36a, #b8892e);
  color: #2a1608;
}

.btn-gold:hover { filter: brightness(1.06); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--gold-dim);
}

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

.menu-actions { display: grid; gap: 10px; margin-top: 22px; }

.hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--gold-dim);
  text-align: center;
  line-height: 1.45;
}

#screen-table {
  display: grid;
  grid-template-rows: 52px 1fr 372px;
  min-height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(180deg, #24140c, #160c08);
  border-bottom: 1px solid var(--gold-dim);
}

.topbar .left, .topbar .right { display: flex; gap: 10px; align-items: center; }

.pill {
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 5px 10px;
}

.table-wrap {
  position: relative;
  padding: 12px 16px 0;
}

.table {
  position: relative;
  height: 100%;
  min-height: 360px;
  background:
    radial-gradient(ellipse at center, #1a7a55 0%, var(--felt) 42%, var(--felt-dark) 100%);
  border: 14px solid var(--wood);
  box-shadow:
    inset 0 0 0 6px var(--wood-edge),
    inset 0 0 80px rgba(0, 0, 0, 0.35),
    var(--shadow);
  border-radius: 50% / 18%;
  overflow: hidden;
}

.seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 110px;
}

.seat[data-pos="top"] { top: 18px; left: 50%; transform: translateX(-50%); }
.seat[data-pos="left"] { left: 28px; top: 42%; transform: translateY(-50%); }
.seat[data-pos="right"] { right: 28px; top: 42%; transform: translateY(-50%); }
.seat[data-pos="topleft"] { top: 70px; left: 18%; }
.seat.you { display: none; }

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--seat);
  border: 2px solid var(--gold-dim);
  color: var(--gold);
  overflow: hidden;
}

.avatar svg { width: 100%; height: 100%; display: block; }

.you-avatar {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.you-avatar .avatar { width: 52px; height: 52px; }

.seat.turn .avatar {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(215, 176, 86, 0.28);
}

.seat-name { font-size: 13px; font-weight: 600; }
.seat-meta { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.seat.out { opacity: 0.82; }

.bot-hand {
  display: flex;
  height: 34px;
}

.mini-back {
  width: 22px;
  height: 32px;
  margin-left: -12px;
  border-radius: 3px;
  background:
    repeating-linear-gradient(45deg, #6b1d28 0 4px, #4a1018 4px 8px);
  border: 1px solid #2a0c10;
  box-shadow: 0 2px 4px rgba(0,0,0,.35);
}

.mini-back:first-child { margin-left: 0; }

.center {
  position: absolute;
  inset: 22% 18% 24%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.pile {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 168px;
  width: min(520px, 78%);
}

.pile .card { position: relative; margin-left: -54px; }
.pile .card:first-child { margin-left: 0; }

.deal-piles {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 18px;
  min-height: 180px;
  width: 100%;
}

.deal-pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
}

.deal-pile .card {
  box-shadow: 0 10px 18px rgba(0,0,0,.4), 0 0 0 2px rgba(215, 176, 86, 0.35);
}

.deal-pile:hover .card { transform: translateY(-8px); }

.deal-pile.taken {
  cursor: default;
  opacity: 0.45;
}

.deal-pile.taken:hover .card { transform: none; }

.deal-stack {
  position: absolute;
  top: 8px;
  left: 8px;
  width: calc(var(--card-w) - 16px);
  height: 10px;
  background: repeating-linear-gradient(45deg, #7a2230 0 4px, #4e121c 4px 8px);
  border-radius: 2px;
  z-index: 0;
}

.deal-tag {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #efe3b8;
  text-shadow: 0 1px 4px #000;
}

.rank-line {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 640px;
}

.rank-chip {
  min-width: 44px;
  height: 52px;
  padding: 0 10px;
  border: 1px solid #c9a227;
  background: #fbf6e9;
  color: #1a1208;
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 6px;
}

.rank-chip:hover { transform: translateY(-4px); }

.rank-chip.miss,
.rank-chip:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(1);
}

.ask-banner {
  font-family: "Fraunces", Georgia, serif;
  font-size: 22px;
  color: #efe3b8;
  text-shadow: 0 2px 8px #000;
}

.deal-pile.yours .card {
  box-shadow: 0 0 0 3px #e6c36a, 0 10px 18px rgba(0,0,0,.4);
}

.status {
  text-align: center;
  font-family: "Fraunces", Georgia, serif;
  color: #efe3b8;
  text-shadow: 0 2px 10px rgba(0,0,0,.5);
  min-height: 28px;
  font-size: 18px;
}

@keyframes pulse {
  from { transform: scale(1); box-shadow: 0 0 0 0 rgba(240, 195, 106, 0.5); }
  to { transform: scale(1.06); box-shadow: 0 0 24px 4px rgba(240, 195, 106, 0.35); }
}

.hand-dock {
  background:
    linear-gradient(180deg, #3a2416 0 12px, #1b100b 12px, #120a07 100%);
  border-top: 3px solid var(--gold-dim);
  box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.35);
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.hand-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hand-actions {
  position: relative;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 4px 0 28px;
}

.hand-actions .btn {
  padding: 12px 22px;
  font-size: 13px;
  opacity: 1;
}

.btn-complete {
  background: #4a2c28;
  color: #c4b39a;
  border: 1px solid #6a4a3a;
  letter-spacing: 0.14em;
}

.btn-complete:disabled {
  background: #3a2a26;
  color: #7a6a5a;
  border-color: #5a4034;
  cursor: not-allowed;
  animation: none;
  filter: grayscale(0.35);
}

.btn-complete:not(:disabled) {
  background: #8b1e1e;
  color: #fff4d6;
  border: 2px solid #f0c36a;
  font-weight: 800;
  animation: pulse 0.7s ease-in-out infinite alternate;
}

.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 178px;
  padding: 8px 0 10px;
  overflow: visible;
}

.hand .card {
  margin-left: -48px;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  cursor: pointer;
}

.hand .card:first-child { margin-left: 0; }
.hand .card:hover { transform: translateY(-18px); z-index: 5; }
.hand .card.legal {
  box-shadow:
    0 10px 18px rgba(0,0,0,.38),
    0 0 0 3px #e6c36a,
    0 0 16px rgba(230, 195, 106, 0.5);
  z-index: 4;
  cursor: pointer;
}
.hand .card.legal:hover { transform: translateY(-18px); z-index: 5; }
.hand .card.selected {
  transform: translateY(-28px);
  box-shadow: 0 16px 24px rgba(0,0,0,.45), 0 0 0 3px var(--gold);
  z-index: 6;
  filter: none;
  opacity: 1;
}
.hand .card.dim {
  filter: grayscale(1) brightness(0.72);
  cursor: not-allowed;
}
.hand .card.dim:hover { transform: none; }
.hand .card.complete-ready {
  transform: translateY(-14px);
  box-shadow: 0 0 0 3px #f0c36a, 0 0 22px rgba(200, 40, 40, 0.7);
  z-index: 5;
}
.hand .card.shake { animation: shake 0.35s ease; }

.btn-play { background: var(--gold); color: #2a1608; }
.btn-play:disabled {
  background: #6a5420;
  color: #2a1c08;
  cursor: not-allowed;
  filter: grayscale(0.25);
}
.btn-pass {
  background: #5a3824;
  color: var(--ink);
  border: 1px solid #8a6a44;
  min-width: 148px;
  padding: 16px 36px !important;
  font-size: 16px !important;
  letter-spacing: 0.16em;
}
.btn-pass:disabled {
  background: #3a2818;
  color: #8a7a68;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

.play-hint {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-dim);
  line-height: 1.35;
  text-align: center;
  margin-top: 2px;
}

.card {
  width: var(--card-w);
  height: var(--card-h);
  background: #fbf6e9;
  border-radius: 10px;
  border: 1px solid #cfc3a8;
  box-shadow: 0 10px 18px rgba(0,0,0,.38);
  color: #1b1b1b;
  position: relative;
  user-select: none;
  flex-shrink: 0;
  overflow: hidden;
}

.card svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.card.red { color: #c41e3a; }

.card.two-clear {
  box-shadow: 0 10px 18px rgba(0,0,0,.38), 0 0 0 2px #c9a227;
}

.card.back {
  background:
    repeating-linear-gradient(45deg, #7a2230 0 6px, #4e121c 6px 12px);
  border-color: #3a0e14;
}

.card.flying {
  position: fixed;
  z-index: 60;
  width: var(--card-w) !important;
  height: var(--card-h) !important;
  margin: 0 !important;
  transform-origin: center center;
  transition: transform 0.36s cubic-bezier(.22,.82,.28,1);
  pointer-events: none;
  overflow: hidden;
  will-change: transform;
}

#fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 55;
}

.bomb-fx { position: fixed; inset: 0; }

.bomb-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 42%, rgba(255, 220, 120, 0.85), rgba(255, 80, 0, 0.35) 28%, transparent 62%);
  animation: flash 1.1s ease-out forwards;
}

.bomb-ball {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 86px;
  height: 86px;
  margin: -43px;
  background: radial-gradient(circle at 35% 30%, #555, #111 62%);
  border-radius: 50%;
  box-shadow: inset -8px -10px 0 #000, 0 0 30px #ff7a00;
  animation: toss 0.35s ease-out, pop 0.75s 0.32s ease-out forwards;
}

.bomb-ball:before {
  content: "";
  position: absolute;
  left: 62px;
  top: 8px;
  width: 18px;
  height: 10px;
  background: #c9a227;
  border-radius: 3px;
  transform: rotate(-38deg);
}

.bomb-burst {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 24px;
  height: 24px;
  margin: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffd24a 18%, #ff4d00 42%, transparent 68%);
  animation: burst 0.9s 0.28s ease-out forwards;
  opacity: 0;
}

.bomb-word {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) scale(0.4);
  font-family: "Fraunces", Georgia, serif;
  font-size: 84px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #ffe58a;
  text-shadow: 0 0 18px #ff9a1a, 0 6px 0 #7a1800;
  animation: boomtext 1.05s 0.28s ease-out forwards;
  opacity: 0;
}

.spark {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 10px;
  height: 10px;
  margin: -5px;
  background: #ffd36a;
  border-radius: 1px;
  animation: spark 0.85s ease-out forwards;
}

.card.shatter {
  z-index: 62;
  transform-origin: center center;
  transition:
    transform 0.88s cubic-bezier(.15,.75,.2,1),
    opacity 0.88s ease,
    filter 0.7s ease;
  filter: brightness(1.15);
}

.card.shatter.go {
  opacity: 0;
  filter: brightness(2.4) sepia(1) hue-rotate(-25deg) saturate(1.6) blur(1.2px);
}

.ember {
  position: fixed;
  z-index: 63;
  width: 7px;
  height: 7px;
  margin: -3px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff4c8 0%, #ff9a1a 45%, #c43000 100%);
  pointer-events: none;
  animation: ember 0.8s ease-out forwards;
}

@keyframes ember {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--ex), var(--ey)) scale(0.2); opacity: 0; }
}

@keyframes shake {
  0%, 100% { transform: translateY(-28px) rotate(0); }
  25% { transform: translateY(-28px) rotate(-6deg); }
  75% { transform: translateY(-28px) rotate(6deg); }
}

@keyframes flash {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes toss {
  from { transform: translateY(-40px) scale(0.6); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes pop { to { transform: scale(0); opacity: 0; } }

@keyframes burst {
  0% { opacity: 1; transform: scale(0.2); }
  100% { opacity: 0; transform: scale(18); }
}

@keyframes boomtext {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  35% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1.2); }
}

@keyframes spark {
  to { transform: translate(var(--sx), var(--sy)) rotate(120deg); opacity: 0; }
}

.log {
  position: absolute;
  left: 18px;
  bottom: 14px;
  width: 240px;
  max-height: 92px;
  overflow: hidden;
  font-size: 11px;
  color: #d9f0e3;
  text-shadow: 0 1px 4px #000;
  pointer-events: none;
}

.log div { opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 4, 2, 0.72);
  display: grid;
  place-items: center;
  z-index: 20;
}

.modal {
  width: min(560px, 92vw);
  background: #1a100b;
  border: 1px solid var(--gold);
  padding: 24px;
  box-shadow: var(--shadow);
}

.modal h2 {
  font-family: "Fraunces", Georgia, serif;
  color: var(--gold);
  margin-bottom: 10px;
}

.modal p, .modal li { color: var(--muted); font-size: 14px; line-height: 1.5; }
.modal ol, .modal ul { padding-left: 18px; margin: 8px 0 16px; }

.exchange-hand { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; justify-content: center; }
.exchange-hand .card { margin: 0; cursor: pointer; width: 84px; height: 118px; }
.exchange-hand .card.selected { box-shadow: 0 0 0 2px var(--gold); transform: translateY(-8px); }
.exchange-hand .card.selected:after { display: none; }

.finish-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #3a2a18;
}

@media (max-width: 820px) {
  :root { --card-w: 78px; --card-h: 110px; }
  #screen-table { grid-template-rows: 48px 1fr 280px; }
  .table { border-width: 10px; border-radius: 36px; }
  .hand { min-height: 128px; }
  .hand .card { margin-left: -42px; }
  .log { display: none; }
  .brand h1 { font-size: 40px; }
  .play-hint { display: none; }
}
