/* Flat blackjack table: dark room, wood rim, green felt. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: #14120f;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: #f4efe4;
  background: #14120f;
  font-family: ui-sans-serif, system-ui, sans-serif;
  line-height: 1.35;
}

button,
input {
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

button {
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  background: #f3ead7;
  color: #24180f;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid #f4efe4;
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.stage {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 1.25rem;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1.25rem;
  overflow-x: hidden;
}

.table-wrap {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
}

.rim {
  flex: 1 1 auto;
  min-width: 0;
  min-height: min(78vh, 820px);
  padding: 1.15rem;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, #5c341c 0 10px, #7a4b2c 10px 16px);
  box-shadow: inset 0 0 0 3px #3e2414;
}

.felt {
  min-width: 0;
  min-height: 100%;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at center, #1c8f4e 0%, #0e6a38 72%, #0b5830 100%);
  box-shadow: inset 0 0 0 2px rgba(244, 239, 228, 0.28);
  color: #f4efe4;
}

.felt-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem 1rem;
}

.dealer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.8rem;
}

.dealer-bust {
  width: 92px;
  height: 108px;
  flex: none;
}

.dealer-bust svg,
.avatar svg,
.tile svg {
  display: block;
  width: 100%;
  height: 100%;
}

.dealer-play {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.shoe {
  width: 42px;
  height: 58px;
  flex: none;
  border: 2px solid #1a1a1a;
  border-radius: 6px 6px 12px 12px;
  background: #1a1a1a;
  position: relative;
}

.shoe::before {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  top: 8px;
  height: 16px;
  background: #c5342a;
  border-radius: 2px;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  max-width: 100%;
}

.card {
  width: 3rem;
  height: 4.3rem;
  background: #f7f1e4;
  color: #1a1a1a;
  border: 1px solid #1a1a1a;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 3px 4px 4px;
  font-weight: 800;
  line-height: 1;
  font-size: 1.05rem;
}

.card[data-suit="H"],
.card[data-suit="D"] {
  color: #c5342a;
}

.card .suit {
  align-self: flex-end;
  font-size: 0.95em;
}

.card.back {
  background: #b42318;
  color: transparent;
  position: relative;
  align-items: center;
  justify-content: center;
}

.card.back::before {
  content: "";
  width: 38%;
  height: 32%;
  background: #f4efe4;
  transform: rotate(45deg);
}

.chair .card {
  width: 1.7rem;
  height: 2.4rem;
  font-size: 0.68rem;
  padding: 1px 2px;
  border-radius: 4px;
}

.total {
  margin: 0;
  font-weight: 800;
  font-size: 1.15rem;
}

.total.is-bust {
  color: #ffd0c8;
}

.status {
  margin: 0;
  text-align: center;
  font-size: 1.45rem;
  font-weight: 700;
}

.notice,
.cost {
  margin: 0;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
}

.notice {
  color: #ffd0c8;
}

.chairs,
.others {
  display: flex;
  flex-direction: row-reverse;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.chair,
.other {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-align: center;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  background: #f4efe4;
  display: grid;
  place-items: center;
  flex: none;
  color: #f4efe4;
  font-weight: 800;
}

.avatar-lg {
  width: 96px;
  height: 96px;
  font-size: 1.6rem;
}

.avatar.is-turn {
  box-shadow: 0 0 0 3px #f4efe4, 0 0 0 6px #e0b13a;
}

.avatar.init-red { background: #c5342a; }
.avatar.init-gold { background: #b8860b; }
.avatar.init-green { background: #1f7a45; }
.avatar.init-blue { background: #1d4e89; }

.who {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
  align-items: baseline;
  margin: 0;
  max-width: 100%;
  min-width: 0;
}

.seat-num,
.player-name,
.stack,
.open-label {
  min-width: 0;
}

.player-name,
.open-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.seat-num,
.player-name {
  font-weight: 700;
}

.stack {
  font-variant-numeric: tabular-nums;
}

.tag {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.tag.turn {
  color: #f4efe4;
}

.hands {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  max-width: 100%;
}

.hand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
  padding: 2px;
}

.hand.is-active {
  outline: 2px solid #f4efe4;
  border-radius: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.85rem;
  line-height: 1;
}

.chip-bet {
  background: #e0b13a;
  color: #1a1408;
  box-shadow: inset 0 0 0 3px rgba(244, 239, 228, 0.85), inset 0 0 0 5px #e0b13a;
}

.chip-ins {
  background: #c5342a;
  color: #f4efe4;
  box-shadow: inset 0 0 0 3px rgba(244, 239, 228, 0.8), inset 0 0 0 5px #c5342a;
}

.insure {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.insure-word {
  font-weight: 700;
  font-size: 0.85rem;
}

.verdict {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.03em;
  font-size: 0.82rem;
}

.delta {
  margin-left: 0.3rem;
}

.stake {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  max-width: 100%;
}

.plaque {
  flex: 0 0 17rem;
  background: #f3ead7;
  color: #24180f;
  border-radius: 18px;
  padding: 1.1rem 1.15rem 1.25rem;
  min-width: 0;
}

.plaque .status,
.plaque .notice {
  color: #24180f;
  text-align: left;
}

.room-code {
  margin: 0.15rem 0 0.7rem;
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.eyebrow,
.scan-label,
.join-note,
.host-hint {
  margin: 0.35rem 0;
}

.join-urls {
  margin: 0 0 0.6rem;
  padding: 0;
  list-style: none;
}

.join-url {
  color: #24180f;
  overflow-wrap: anywhere;
}

.qr {
  display: block;
  width: min(180px, 100%);
  height: auto;
  background: #fff;
  margin: 0.4rem 0;
}

.plaque button.secondary,
.join-plaque button.sit {
  width: 100%;
  min-height: 52px;
  background: #24180f;
  color: #f3ead7;
}

.chair button.secondary {
  min-height: 34px;
  padding: 0 8px;
  font-size: 0.8rem;
  background: transparent;
  color: #f4efe4;
  border: 1px solid rgba(244, 239, 228, 0.75);
}

.join-plaque {
  width: min(28rem, 100%);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  border-radius: 0;
  overflow-y: auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 700;
  margin: 0.75rem 0;
}

.field input {
  min-height: 48px;
  font-size: 1.15rem;
  border-radius: 10px;
  border: 2px solid #24180f;
  padding: 0 0.75rem;
  background: #fff;
  color: #24180f;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin: 0.4rem 0 0.9rem;
}

.tile {
  aspect-ratio: 1;
  padding: 4px;
  border-radius: 14px;
  background: #fff;
  color: #24180f;
  border: 3px solid transparent;
  min-height: 0;
}

.tile svg {
  width: 100%;
  height: 100%;
}

.tile[aria-selected="true"] {
  border-color: #24180f;
  box-shadow: 0 0 0 3px #e0b13a;
}

.tile-initials {
  font-size: 1.35rem;
  font-weight: 800;
  color: #f4efe4;
}

.tile[data-avatar="init-red"] { background: #c5342a; }
.tile[data-avatar="init-gold"] { background: #b8860b; }
.tile[data-avatar="init-green"] { background: #1f7a45; }
.tile[data-avatar="init-blue"] { background: #1d4e89; }

.form-error {
  min-height: 1.3em;
  margin: 0.55rem 0 0;
  color: #9d1c1c;
  font-weight: 700;
}

body[data-role="play"] {
  background: #14120f;
}

body[data-role="play"].is-seated {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.phone-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0e6a38;
}

.phone-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at center top, #1c8f4e 0%, #0e6a38 70%, #0b5830 100%);
}

.phone-shell .felt,
.phone-shell .felt-inner {
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.phone-shell .felt-inner {
  justify-content: flex-start;
  padding: 0.7rem 0.75rem 1rem;
}

.phone-shell .dealer-bust {
  width: 56px;
  height: 66px;
}

.phone-shell .dealer .card {
  width: 2rem;
  height: 2.85rem;
  font-size: 0.8rem;
}

.phone-shell .shoe {
  width: 28px;
  height: 40px;
}

.you-seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  max-width: 100%;
}

.you-seat .card {
  width: 3.5rem;
  height: 5rem;
  font-size: 1.25rem;
}

.you-seat .who {
  font-size: 1.25rem;
}

.you-seat .verdict {
  font-size: 1.15rem;
}

.others .avatar {
  width: 40px;
  height: 40px;
}

.others .who,
.others .tag,
.others .total,
.others .hand-count {
  font-size: 0.75rem;
}

.hand-count {
  margin: 0;
  font-weight: 700;
}

.rail {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.65rem 0.7rem calc(0.7rem + env(safe-area-inset-bottom));
  background: #6b3f24;
  border-top: 4px solid #3e2414;
  min-height: 18px;
}

.rail button.full {
  width: 100%;
  min-height: 56px;
  font-size: 1.2rem;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.action-row button {
  flex: 1 1 6rem;
}

.banner {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #f3ead7;
  color: #24180f;
  text-align: center;
  font-weight: 800;
  padding: 0.75rem 1rem;
}

body.is-replaced {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 1100px) {
  .chair .card {
    width: 2.3rem;
    height: 3.3rem;
    font-size: 0.95rem;
  }

  .avatar {
    width: 72px;
    height: 72px;
  }
}

@media (max-width: 960px) {
  .stage {
    flex-direction: column;
    padding: 0.75rem;
  }

  .plaque {
    flex: none;
    width: 100%;
  }

  .rim {
    border-radius: 46% / 42%;
    min-height: 70vh;
  }
}

@media (max-width: 420px) {
  .you-seat .card {
    width: 2.9rem;
    height: 4.15rem;
    font-size: 1.05rem;
  }

  .felt-inner,
  .phone-shell .felt-inner {
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }

  .status {
    font-size: 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Display: a wide felt oval. Dealer on the far side, seats along the near curve. */

body[data-role="display"] {
  height: 100dvh;
  overflow: hidden;
}

body[data-role="display"] .stage {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  align-items: center;
  padding: 1rem 1.15rem;
  gap: 1rem;
}

body[data-role="display"] .plaque {
  align-self: center;
  flex: 0 0 16rem;
  max-height: calc(100dvh - 2rem);
  overflow: auto;
}

body[data-role="display"] .join-url {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: normal;
  word-break: normal;
}

body[data-role="display"] .table-wrap {
  container-type: size;
  height: 100%;
  min-height: 0;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}

body[data-role="display"] .rim {
  display: flex;
  flex-direction: column;
  width: min(100cqw, calc(100cqh * 1.72));
  height: min(100cqh, calc(100cqw / 1.72));
  min-height: 0;
  padding: 0.85rem 1rem;
  border-radius: 50%;
}

body[data-role="display"] .felt {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: auto;
  overflow: hidden;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 72% 68% at 50% 42%, #249454 0%, #12743c 62%, #0b5830 100%);
}

body[data-role="display"] .felt-inner {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  justify-content: flex-start;
  gap: 0.25rem;
  padding: 3% 2% 2.4%;
}

body[data-role="display"] .dealer-bust {
  width: 92px;
  height: 108px;
}

body[data-role="display"] .status {
  font-size: clamp(1.25rem, 2vw, 1.7rem);
}

body[data-role="display"] .felt-inner > .chairs {
  width: 62%;
  align-self: center;
  margin-top: auto;
  align-items: flex-end;
}

body[data-role="display"] .chair {
  justify-content: flex-end;
  gap: 0.3rem;
}

body[data-role="display"] .chair .cards {
  flex-wrap: nowrap;
}

body[data-role="display"] .chair .who {
  flex-wrap: nowrap;
  font-size: 0.98rem;
}

body[data-role="display"] .chair[data-seat="1"],
body[data-role="display"] .chair[data-seat="5"] {
  margin-bottom: 7%;
}

body[data-role="display"] .chair[data-seat="2"],
body[data-role="display"] .chair[data-seat="4"] {
  margin-bottom: 2.2%;
}

body[data-role="display"] .seat-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px dashed rgba(244, 239, 228, 0.78);
  background: transparent;
}

@media (min-width: 1100px) {
  body[data-role="display"] .seat-mark {
    width: 68px;
    height: 68px;
  }

  body[data-role="display"] .chair .card {
    width: 2.35rem;
    height: 3.3rem;
    font-size: 0.95rem;
  }
}

@media (max-width: 960px) {
  body[data-role="display"] {
    height: 100dvh;
    overflow: hidden;
  }

  body[data-role="display"] .stage {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    align-items: stretch;
  }

  body[data-role="display"] .plaque {
    align-self: stretch;
    flex: 0 1 auto;
    width: 100%;
    max-height: 46dvh;
  }

  body[data-role="display"] .qr {
    width: min(132px, 40vw);
  }

  body[data-role="display"] .room-code {
    font-size: 1.7rem;
    margin-bottom: 0.25rem;
  }

  body[data-role="display"] .table-wrap {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    width: 100%;
  }

  body[data-role="display"] .rim {
    width: 100%;
    height: 100%;
    border-radius: 36% 36% 14px 14px;
  }

  body[data-role="display"] .felt {
    border-radius: inherit;
  }

  body[data-role="display"] .felt-inner {
    padding: 0.75rem 0.35rem 0.4rem;
  }

  body[data-role="display"] .felt-inner > .chairs {
    width: 100%;
  }

  body[data-role="display"] .chair[data-seat="1"],
  body[data-role="display"] .chair[data-seat="2"],
  body[data-role="display"] .chair[data-seat="4"],
  body[data-role="display"] .chair[data-seat="5"] {
    margin-bottom: 0;
  }

  body[data-role="display"] .dealer-bust {
    width: 64px;
    height: 76px;
  }

  body[data-role="display"] .avatar,
  body[data-role="display"] .seat-mark {
    width: 40px;
    height: 40px;
  }

  body[data-role="display"] .chair .card {
    width: 1.28rem;
    height: 1.8rem;
    font-size: 0.58rem;
  }

  body[data-role="display"] .chair .who,
  body[data-role="display"] .chair .total,
  body[data-role="display"] .chair .verdict,
  body[data-role="display"] .chair .tag {
    font-size: 0.68rem;
  }

  body[data-role="display"] .chair .who {
    flex-wrap: wrap;
    row-gap: 0;
  }

  body[data-role="display"] .chip {
    width: 1.7rem;
    height: 1.7rem;
    font-size: 0.68rem;
  }

  body[data-role="display"] .status {
    font-size: 1rem;
  }

  body[data-role="display"] .chair button.secondary {
    min-height: 28px;
    padding: 0 6px;
    font-size: 0.68rem;
  }
}
