:root {
  color-scheme: dark;
  --felt: #12624d;
  --felt-dark: #0a342d;
  --rail: #51351e;
  --ink: #f7efe4;
  --muted: #b9c8c2;
  --accent: #f0b35a;
  --accent-2: #6ee7b7;
  --danger: #f97373;
  --card: rgba(8, 24, 22, 0.86);
  --line: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #071d19;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.hidden {
  display: none !important;
}

.table-screen {
  overflow: hidden;
}

.table-shell {
  height: 100vh;
  height: 100dvh;
  display: flex;
  padding: clamp(6px, 0.8vmin, 12px);
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.08), transparent 40%),
    linear-gradient(135deg, #092f2a, #051a17);
}

.table-top {
  position: relative;
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: clamp(6px, 0.8vmin, 10px);
  margin: 0;
  padding: clamp(12px, 1.15vmin, 20px);
  border: clamp(9px, 1.2vmin, 14px) solid var(--rail);
  border-radius: clamp(22px, 2.4vmin, 32px);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 70px),
    var(--felt);
  box-shadow: inset 0 0 55px rgba(0, 0, 0, 0.45), 0 30px 90px rgba(0, 0, 0, 0.36);
}

.table-join-overlay {
  position: absolute;
  inset: clamp(72px, 11vmin, 118px) clamp(16px, 2vmin, 28px) clamp(58px, 7vmin, 82px);
  z-index: 2;
  display: grid;
  place-items: center;
  pointer-events: none;
  overflow: hidden;
}

.table-join-card {
  width: min(clamp(230px, 35vmin, 410px), 92%);
  max-height: calc(100% - 10px);
  display: grid;
  justify-items: center;
  gap: clamp(8px, 1.2vmin, 14px);
  border: 1px solid rgba(240, 179, 90, 0.5);
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 28%),
    radial-gradient(circle at top, rgba(110, 231, 183, 0.18), transparent 42%),
    rgba(3, 20, 18, 0.94);
  padding: clamp(14px, 2vmin, 24px);
  text-align: center;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 22px 70px rgba(0, 0, 0, 0.46),
    0 0 50px rgba(110, 231, 183, 0.14);
  backdrop-filter: blur(8px);
}

.table-join-card h2 {
  margin: 0;
  font-size: clamp(1.8rem, 6vmin, 3.3rem);
  line-height: 1;
}

.winner-overlay {
  position: absolute;
  inset: clamp(72px, 11vmin, 118px) clamp(16px, 2vmin, 28px) clamp(58px, 7vmin, 82px);
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
  overflow: hidden;
}

.winner-card {
  width: min(clamp(300px, 44vmin, 520px), 92%);
  max-height: calc(100% - 10px);
  display: grid;
  justify-items: center;
  gap: clamp(8px, 1.2vmin, 14px);
  border: 1px solid rgba(240, 179, 90, 0.72);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), transparent 30%),
    radial-gradient(circle at top, rgba(240, 179, 90, 0.26), transparent 44%),
    rgba(3, 20, 18, 0.95);
  padding: clamp(16px, 2.2vmin, 28px);
  text-align: center;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 24px 80px rgba(0, 0, 0, 0.56),
    0 0 56px rgba(240, 179, 90, 0.22);
  backdrop-filter: blur(8px);
  animation: winnerPop 0.42s ease-out both;
}

.winner-card h2 {
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(2rem, 6.4vmin, 4.2rem);
  line-height: 0.95;
}

.winner-card p:last-child {
  margin: 0;
  max-width: 36rem;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.7vmin, 1.2rem);
  font-weight: 850;
}

.winner-avatar {
  width: clamp(86px, 15vmin, 150px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: clamp(4px, 0.8vmin, 8px) solid rgba(247, 239, 228, 0.95);
  border-radius: 50%;
  background: #ead7ba center / cover no-repeat;
  color: #221307;
  font-size: clamp(2.4rem, 7vmin, 4.8rem);
  font-weight: 950;
  box-shadow:
    0 0 0 6px rgba(240, 179, 90, 0.22),
    0 18px 42px rgba(0, 0, 0, 0.42);
}

.winner-avatar.has-photo {
  background-color: #0b211d;
}

.table-header,
.table-footer,
.player-header,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.player-header {
  position: relative;
  margin: -2px -2px 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 48%),
    rgba(255, 255, 255, 0.045);
  box-shadow:
    0 12px 34px rgba(0, 0, 0, 0.22),
    0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.player-header .avatar {
  width: clamp(48px, 13vw, 64px);
  height: clamp(48px, 13vw, 64px);
  border: 2px solid rgba(247, 239, 228, 0.88);
  box-shadow:
    0 0 0 5px rgba(240, 179, 90, 0.13),
    0 12px 22px rgba(0, 0, 0, 0.26);
}

.player-header .eyebrow {
  display: inline-grid;
  min-height: 24px;
  place-items: center;
  margin-bottom: 5px;
  border: 1px solid rgba(110, 231, 183, 0.3);
  border-radius: 999px;
  background: rgba(110, 231, 183, 0.12);
  padding: 3px 9px;
  color: #92f7cf;
  font-size: 0.68rem;
}

.player-header h1 {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-wrap: balance;
  color: #fff8ec;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.32);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 6vw, 5rem);
  line-height: 0.95;
}

.table-header h1 {
  font-size: clamp(1.55rem, 2.8vw, 2.8rem);
}

h2 {
  margin-bottom: 16px;
}

.status-pill,
.ghost-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--ink);
  padding: 7px 12px;
  font-weight: 800;
  font-size: 0.92rem;
}

.seats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 0.7vmin, 8px);
}

.seat {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: clamp(44px, 4.8vmin, 54px);
  padding: 5px 8px;
  background: rgba(0, 0, 0, 0.2);
}

.seat.active {
  border-color: rgba(240, 179, 90, 0.9);
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  background:
    linear-gradient(135deg, rgba(240, 179, 90, 0.24), rgba(110, 231, 183, 0.12)),
    rgba(0, 0, 0, 0.24);
  box-shadow:
    0 0 0 5px rgba(240, 179, 90, 0.15),
    0 0 34px rgba(240, 179, 90, 0.34);
  animation: tableTurnPulse 0.95s ease-in-out infinite alternate;
}

.seat.ai-seat {
  border-color: rgba(110, 231, 183, 0.44);
  background:
    linear-gradient(135deg, rgba(110, 231, 183, 0.12), transparent),
    rgba(0, 0, 0, 0.22);
}

.seat.ai-seat .avatar {
  background: #b9f2dc;
}

.seat.inactive-warning {
  border-color: var(--danger);
  outline-color: var(--danger);
  box-shadow:
    0 0 0 5px rgba(249, 115, 115, 0.15),
    0 0 34px rgba(249, 115, 115, 0.34);
}

.seat.active::after {
  content: "TURN";
  position: absolute;
  right: 8px;
  top: 50%;
  translate: 0 -50%;
  border-radius: 999px;
  background: var(--accent);
  color: #201204;
  padding: 4px 8px;
  font-size: 0.68rem;
  font-weight: 950;
  box-shadow: 0 0 18px rgba(240, 179, 90, 0.5);
}

.seat.ai-seat.active::after {
  content: "AUTO";
  background: var(--accent-2);
  color: #05201a;
}

.seat.inactive-warning.active::after {
  content: "WAIT";
  background: var(--danger);
  color: #240606;
}

.seat.active > div:not(.avatar) {
  padding-right: 46px;
}

.seat.empty {
  color: var(--muted);
}

.seat strong,
.seat span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat strong {
  font-size: 0.92rem;
  line-height: 1.05;
}

.seat span {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.1;
}

.avatar {
  width: clamp(30px, 3.3vmin, 36px);
  height: clamp(30px, 3.3vmin, 36px);
  flex: 0 0 clamp(30px, 3.3vmin, 36px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ead7ba;
  background-position: center;
  background-size: cover;
  color: #221307;
  font-weight: 900;
  object-fit: cover;
}

.board-wrap {
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(34px, 3.5vmin, 42px) 1fr clamp(34px, 3.5vmin, 42px);
  align-items: center;
  gap: clamp(6px, 0.8vmin, 10px);
}

.board {
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.16);
  border-radius: 8px;
}

.open-end {
  width: clamp(34px, 3.5vmin, 42px);
  height: clamp(34px, 3.5vmin, 42px);
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--accent);
  font-size: 1.28rem;
  font-weight: 900;
}

.domino,
.hand-domino {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  border: 2px solid #15120f;
  border-radius: 8px;
  background: #f5ead8;
  color: #17100b;
  box-shadow: 0 14px 22px rgba(0, 0, 0, 0.22);
}

.domino {
  width: var(--domino-w, clamp(82px, 5.8vw, 116px));
  height: var(--domino-h, clamp(41px, 2.9vw, 58px));
  grid-template-columns: 1fr 1fr;
}

.domino.double,
.domino.vertical-bend {
  width: var(--domino-h, clamp(41px, 2.9vw, 58px));
  height: var(--domino-w, clamp(82px, 5.8vw, 116px));
  grid-template-columns: none;
  grid-template-rows: 1fr 1fr;
}

.trail-domino {
  position: absolute;
}

.domino span,
.hand-domino span {
  display: grid;
  place-items: center;
  font-size: 1.45rem;
  font-weight: 950;
}

.domino.traditional,
.hand-domino.traditional {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.74), transparent 42%),
    #f2e7d4;
}

.domino.traditional span,
.hand-domino.traditional span {
  min-width: 0;
  min-height: 0;
}

.domino span:first-child,
.hand-domino span:first-child {
  border-bottom: 2px solid #15120f;
}

.domino span:first-child {
  border-right: 2px solid #15120f;
  border-bottom: 0;
}

.domino.double span:first-child,
.domino.vertical-bend span:first-child {
  border-right: 0;
  border-bottom: 2px solid #15120f;
}

.pip-half {
  padding: max(5px, calc(var(--domino-h, 58px) * 0.13));
}

.hand-domino .pip-half {
  padding: 8px 18px;
}

.pip-grid {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
}

.pip {
  width: clamp(6px, calc(var(--domino-h, 58px) * 0.17), 11px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #14100c;
  border: 1px solid rgba(0, 0, 0, 0.32);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.42),
    inset 0 -2px 3px rgba(0, 0, 0, 0.24),
    0 1px 2px rgba(0, 0, 0, 0.32);
}

.hand-domino .pip {
  width: clamp(10px, 3.5vw, 18px);
}

.pip-1 {
  grid-area: 1 / 1;
}

.pip-2 {
  grid-area: 1 / 2;
}

.pip-3 {
  grid-area: 1 / 3;
}

.pip-4 {
  grid-area: 2 / 1;
}

.pip-5 {
  grid-area: 2 / 2;
}

.pip-6 {
  grid-area: 2 / 3;
}

.pip-7 {
  grid-area: 3 / 1;
}

.pip-8 {
  grid-area: 3 / 2;
}

.pip-9 {
  grid-area: 3 / 3;
}

.domino.double .pip-value-6 .pip-1,
.domino.vertical-bend .pip-value-6 .pip-1 {
  grid-area: 1 / 1;
}

.domino.double .pip-value-6 .pip-2,
.domino.vertical-bend .pip-value-6 .pip-2 {
  grid-area: 2 / 1;
}

.domino.double .pip-value-6 .pip-3,
.domino.vertical-bend .pip-value-6 .pip-3 {
  grid-area: 3 / 1;
}

.domino.double .pip-value-6 .pip-7,
.domino.vertical-bend .pip-value-6 .pip-7 {
  grid-area: 1 / 3;
}

.domino.double .pip-value-6 .pip-8,
.domino.vertical-bend .pip-value-6 .pip-8 {
  grid-area: 2 / 3;
}

.domino.double .pip-value-6 .pip-9,
.domino.vertical-bend .pip-value-6 .pip-9 {
  grid-area: 3 / 3;
}

.color-dots .pip-value-1 .pip {
  background: radial-gradient(circle at 35% 28%, #8ee6ff, #0ea5e9 48%, #075985);
}

.color-dots .pip-value-2 .pip {
  background: radial-gradient(circle at 35% 28%, #8df7b3, #15803d 50%, #064e3b);
}

.color-dots .pip-value-3 .pip {
  background: radial-gradient(circle at 35% 28%, #ff8fbd, #d81b60 52%, #831843);
}

.color-dots .pip-value-4 .pip {
  background: radial-gradient(circle at 35% 28%, #e6d28a, #8a6a1f 52%, #4a3210);
}

.color-dots .pip-value-5 .pip {
  background: radial-gradient(circle at 35% 28%, #93c5fd, #1d4ed8 52%, #172554);
}

.color-dots .pip-value-6 .pip {
  background: radial-gradient(circle at 35% 28%, #fff2a8, #f4b400 52%, #a16207);
}

.domino small {
  position: absolute;
  left: 50%;
  bottom: -22px;
  width: 92px;
  color: var(--ink);
  font-size: 0.72rem;
  text-align: center;
  text-shadow: 0 1px 4px #000;
  transform: translateX(-50%);
}

.empty-board {
  width: 100%;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.table-footer {
  align-items: flex-end;
}

.table-footer p {
  margin-bottom: 0;
  font-size: 0.95rem;
  font-weight: 800;
}

.qr-code {
  width: clamp(150px, 22vmin, 275px);
  min-width: 142px;
  aspect-ratio: 1;
  height: auto;
  display: grid;
  place-items: center;
  border: clamp(7px, 1vmin, 12px) solid #fff;
  border-radius: 12px;
  background: #fff center / cover no-repeat;
  box-shadow:
    0 12px 34px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(0, 0, 0, 0.24) inset;
}

.qr-code.qr-loading::after {
  content: attr(data-loading-text);
  max-width: 80%;
  color: #078dcc;
  font-size: clamp(0.74rem, 1.8vmin, 1rem);
  font-weight: 900;
  line-height: 1.15;
  text-transform: uppercase;
}

.player-screen {
  background:
    linear-gradient(180deg, rgba(9, 47, 42, 0.95), rgba(7, 29, 25, 0.98)),
    #071d19;
}

.request-debug {
  width: 100%;
  border: 1px solid rgba(110, 231, 183, 0.3);
  border-radius: 14px;
  background: rgba(2, 14, 13, 0.92);
  padding: 10px;
  color: #f7efe4;
}

.request-debug pre {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c8d7d1;
  font: 0.72rem/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.mobile-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px;
  display: grid;
  align-items: stretch;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.join-card,
.hand-card,
.closed-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  padding: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}

.hand-card {
  position: relative;
  min-height: calc(100vh - 24px);
  min-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.join-card h1,
.hand-card h1,
.closed-card h1 {
  font-size: 2.2rem;
}

.hand-card.your-turn {
  border-color: rgba(240, 179, 90, 0.86);
  box-shadow: 0 0 0 4px rgba(240, 179, 90, 0.18), 0 26px 70px rgba(0, 0, 0, 0.42);
}

.hand-card.round-finished {
  border-color: rgba(110, 231, 183, 0.7);
}

.hand-card.game-paused {
  border-color: rgba(247, 239, 228, 0.34);
  box-shadow: 0 0 0 4px rgba(247, 239, 228, 0.08), 0 24px 60px rgba(0, 0, 0, 0.3);
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  padding: 10px 12px;
}

form button,
.actions button {
  min-height: 48px;
  border-radius: 8px;
  background: var(--accent);
  color: #201204;
  padding: 10px 14px;
  font-weight: 950;
}

.turn-box {
  margin: 12px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.105), transparent 52%),
    rgba(255, 255, 255, 0.065);
  padding: 13px 14px;
  color: var(--ink);
  font-weight: 850;
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.16),
    0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.turn-box strong,
.turn-box span {
  display: block;
}

.turn-box strong {
  color: var(--accent);
  font-size: clamp(1.45rem, 8vw, 2.25rem);
  line-height: 0.95;
  text-transform: uppercase;
  text-shadow: 0 2px 12px rgba(240, 179, 90, 0.18);
}

.turn-box span {
  margin-top: 4px;
  color: rgba(247, 239, 228, 0.86);
  font-size: 0.95rem;
  line-height: 1.18;
}

.turn-warning {
  margin-top: 8px;
  color: var(--danger);
  font-weight: 950;
}

.your-turn .turn-box {
  border-color: rgba(240, 179, 90, 0.86);
  background: linear-gradient(135deg, rgba(240, 179, 90, 0.26), rgba(110, 231, 183, 0.16));
  animation: turnPulse 1.1s ease-in-out infinite alternate;
}

.game-over-panel,
.waiting-panel {
  display: grid;
  gap: 10px;
  margin: 18px 0;
  border: 1px solid rgba(110, 231, 183, 0.5);
  border-radius: 14px;
  background: rgba(4, 35, 30, 0.92);
  padding: 16px;
}

.game-over-panel h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1;
}

.game-over-panel p,
.waiting-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 800;
}

.game-over-actions,
.waiting-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.game-over-actions button,
.waiting-actions button {
  min-height: 48px;
  border-radius: 8px;
  background: var(--accent-2);
  color: #05201a;
  padding: 10px 14px;
  font-weight: 950;
}

.game-over-actions button:last-child,
.waiting-actions button:last-child {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}

.reclaim-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin: 0 0 12px;
  border: 1px solid rgba(240, 179, 90, 0.52);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(240, 179, 90, 0.16), rgba(255, 255, 255, 0.06)),
    rgba(7, 27, 24, 0.9);
  padding: 12px;
}

.reclaim-panel strong,
.reclaim-panel span {
  display: block;
}

.reclaim-panel strong {
  color: var(--ink);
  font-size: 1rem;
}

.reclaim-panel span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.reclaim-panel button {
  min-height: 44px;
  border-radius: 999px;
  background: var(--accent);
  color: #201204;
  padding: 10px 14px;
  font-weight: 950;
}

.action-sheet {
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 10;
  width: min(460px, calc(100vw - 20px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 34%),
    rgba(5, 18, 16, 0.94);
  padding: 10px;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.56),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  backdrop-filter: blur(18px);
  transform: translateY(calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.action-sheet.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.action-sheet-grabber {
  grid-column: 1 / -1;
  justify-self: center;
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: rgba(247, 239, 228, 0.28);
}

.action-sheet p {
  grid-column: 1 / -1;
  margin: 0 4px 2px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 950;
  text-align: center;
}

.actions button {
  min-height: 52px;
  border-radius: 14px;
  background: var(--accent);
  color: #201204;
  padding: 10px 12px;
  font-weight: 950;
}

.actions button:nth-of-type(3),
.actions button:last-child {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}

.actions button.unavailable-end {
  background: rgba(255, 255, 255, 0.11);
  color: rgba(247, 239, 228, 0.64);
  outline: 2px dashed rgba(249, 115, 115, 0.55);
}

.actions button.end-rejected {
  animation: rejectEnd 0.48s ease both;
}

.actions button.pass-now {
  background: var(--danger);
  color: #240606;
  outline: 4px solid rgba(249, 115, 115, 0.36);
  animation: passPulse 0.82s ease-in-out infinite alternate;
}

.hand {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-top: 8px;
  padding: 3px 2px 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.hand-domino {
  width: 100%;
  min-height: 74px;
  height: 74px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
  overflow: hidden;
  border: 2px solid rgba(21, 18, 15, 0.88);
  border-radius: 16px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.34) 42%, transparent 43%),
    linear-gradient(180deg, #fff8ed, #eadfcd);
  box-shadow:
    0 13px 28px rgba(0, 0, 0, 0.34),
    0 1px 0 rgba(255, 255, 255, 0.84) inset,
    0 -12px 20px rgba(91, 63, 34, 0.1) inset;
  transition: transform 0.16s ease, box-shadow 0.16s ease, outline-color 0.16s ease;
}

.hand-domino span:first-child {
  border-right: 3px solid rgba(21, 18, 15, 0.82);
  border-bottom: 0;
}

.hand-domino.playable {
  outline: 2px solid rgba(110, 231, 183, 0.82);
  outline-offset: 2px;
}

.hand-domino.selected {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  transform: translateY(-2px) scale(1.012);
  box-shadow:
    0 16px 32px rgba(0, 0, 0, 0.36),
    0 0 0 5px rgba(240, 179, 90, 0.18),
    0 1px 0 rgba(255, 255, 255, 0.72) inset;
}

.small-text {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--danger);
}

.closed-card {
  align-self: center;
}

@keyframes turnPulse {
  from {
    box-shadow: inset 0 0 0 rgba(240, 179, 90, 0);
  }

  to {
    box-shadow: inset 0 0 28px rgba(240, 179, 90, 0.28);
  }
}

@keyframes tableTurnPulse {
  from {
    transform: scale(1);
  }

  to {
    transform: scale(1.018);
  }
}

@keyframes winnerPop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes rejectEnd {
  0% {
    transform: translateX(0);
    background: var(--danger);
    color: #240606;
  }

  18% {
    transform: translateX(-10px);
  }

  36% {
    transform: translateX(10px);
  }

  54% {
    transform: translateX(-7px);
  }

  72% {
    transform: translateX(7px);
  }

  100% {
    transform: translateX(0);
  }
}

@keyframes passPulse {
  from {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(249, 115, 115, 0);
  }

  to {
    transform: scale(1.04);
    box-shadow: 0 0 26px rgba(249, 115, 115, 0.58);
  }
}

@media (max-width: 900px) {
  .table-shell {
    padding: 10px;
  }

  .table-top {
    padding: 14px;
    border-width: 10px;
    border-radius: 26px;
  }

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

  .board-wrap {
    grid-template-columns: 1fr;
  }

  .open-end {
    display: none;
  }

  .board {
    min-height: 220px;
  }

  .table-join-overlay {
    inset: 136px 18px 92px;
  }

  .winner-overlay {
    inset: 136px 18px 92px;
  }

  .qr-code {
    width: clamp(145px, 32vmin, 220px);
    height: auto;
  }
}

@media (max-height: 620px) {
  .table-join-overlay {
    inset: 58px 14px 46px;
  }

  .winner-overlay {
    inset: 58px 14px 46px;
  }

  .table-join-card,
  .winner-card {
    width: min(300px, 84%);
    gap: 7px;
    padding: 12px;
  }

  .table-join-card h2,
  .winner-card h2 {
    font-size: clamp(1.5rem, 5vmin, 2.3rem);
  }

  .winner-avatar {
    width: clamp(70px, 16vmin, 100px);
  }

  .qr-code {
    width: clamp(132px, 24vmin, 190px);
  }
}

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

  .player-header {
    align-items: flex-start;
    justify-content: flex-start;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .mobile-shell {
    width: min(100%, 820px);
    align-items: stretch;
  }

  .hand-card {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 12px;
    align-items: start;
  }

  .player-header,
  .turn-box,
  .game-over-panel,
  .actions,
  .small-text {
    grid-column: 1;
  }

  .hand {
    grid-column: 2;
    grid-row: 1 / span 4;
    margin-top: 0;
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    padding-right: 4px;
  }

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