:root {
  --bg: #ffffff;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-soft: rgba(255, 255, 255, 0.84);
  --line: #d7d7db;
  --accent: #5a3ff2;
  --accent-soft: #f465c7;
  --text: #171717;
  --muted: #676770;
  --table-ink: #2d2d33;
  --red: #eb4b54;
  --black: #18181d;
  --card: #ffffff;
  --card-width: clamp(86px, 7.2vw, 130px);
  --shadow: 0 16px 36px rgba(17, 17, 17, 0.08);
  --dock-shadow: 0 18px 40px rgba(17, 17, 17, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(90, 63, 242, 0.05), transparent 28%),
    radial-gradient(circle at bottom right, rgba(78, 164, 211, 0.08), transparent 24%),
    var(--bg);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.table-app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  position: relative;
  overflow: hidden;
}

.landing-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  background:
    radial-gradient(circle at top left, rgba(90, 63, 242, 0.05), transparent 28%),
    radial-gradient(circle at bottom right, rgba(78, 164, 211, 0.08), transparent 24%),
    rgba(255, 255, 255, 0.98);
  z-index: 200;
}

.landing-shell {
  width: min(100%, 420px);
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.landing-mark {
  position: relative;
  width: 240px;
  height: 140px;
}

.landing-card {
  position: absolute;
  top: 0;
  left: 50%;
  width: 92px;
  aspect-ratio: 5 / 7;
  border-radius: 16px;
  border: 1.5px solid rgba(42, 42, 48, 0.42);
  background: white;
  box-shadow: 0 10px 26px rgba(17, 17, 17, 0.08);
  display: grid;
  place-items: center;
  font-family: "Times New Roman", Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
}

.landing-card-left {
  transform: translateX(-86px) rotate(-12deg);
}

.landing-card-center {
  transform: translateX(-50%) rotate(0deg);
  z-index: 2;
}

.landing-card-right {
  transform: translateX(-14px) rotate(12deg);
}

.landing-title {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
  text-transform: uppercase;
  font-weight: 800;
}

.landing-copy,
.landing-status {
  margin: 0;
  color: var(--muted);
}

.landing-copy {
  font-size: 1.15rem;
  line-height: 1.4;
}

.landing-mode,
.mode-option {
  display: flex;
  align-items: center;
}

.landing-mode {
  justify-content: center;
}

.mode-option {
  gap: 12px;
  color: var(--table-ink);
  font-size: 1.05rem;
}

.mode-dot {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 3px solid #111;
  box-shadow: inset 0 0 0 5px white;
  background: #111;
}

.landing-field,
.landing-join {
  width: 100%;
  display: grid;
}

.landing-field {
  gap: 8px;
  text-align: left;
  color: var(--muted);
}

.field-count {
  justify-self: end;
  font-size: 0.78rem;
  color: #9a9aa3;
}

.landing-field input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid rgba(23, 23, 23, 0.2);
  background: transparent;
  color: var(--table-ink);
  border-radius: 0;
}

.landing-field input.is-invalid {
  border-bottom-color: var(--red);
  box-shadow: inset 0 -2px 0 var(--red);
}

.landing-button {
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 14px;
  background: #232323;
  color: white;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(17, 17, 17, 0.14);
}

.landing-button-muted {
  background: #e5e5e7;
  color: #7f7f87;
  box-shadow: none;
}

.landing-join {
  gap: 14px;
}

.landing-status {
  min-height: 1.2em;
}

.player-strip {
  min-height: 74px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 3;
}

.player-strip-inner {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.player-strip-bottom {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.player-strip-main,
.strip-side,
.name-row,
.table-hud,
.hud-menu,
.join-actions,
.log-header,
.floating-controls,
.move-options,
.composer {
  display: flex;
  align-items: center;
}

.player-strip-main {
  gap: 16px;
  min-width: 0;
}

.strip-side {
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: nowrap;
  min-width: max-content;
  justify-self: end;
}

.score-badge {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: white;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.player-meta {
  min-width: 0;
}

.name-row {
  gap: 12px;
}

.player-name {
  margin: 0;
  font-size: clamp(1.25rem, 1.6vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.turn-dot {
  width: 15px;
  height: 15px;
  border-radius: 999px;
  background: #ececf1;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
  transition: background 160ms ease, transform 160ms ease;
}

.turn-dot.is-active {
  background: var(--accent-soft);
  transform: scale(1.05);
}

.strip-status,
.drawer-title,
.join-status,
.rules-kicker,
.rules-summary,
.rules-card h2,
.rules-card ul,
.lobby-banner,
.carton-label {
  margin: 0;
}

.strip-status {
  margin-top: 6px;
  font-size: 0.96rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-chip,
.selection-chip,
.move-option,
.chip-link,
.chip-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: blur(10px);
}

.info-chip,
.selection-chip,
.chip-link,
.chip-button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 14px;
  color: var(--muted);
  font-size: 0.92rem;
  text-decoration: none;
  box-shadow: 0 10px 20px rgba(17, 17, 17, 0.04);
}

.chip-button {
  appearance: none;
  cursor: pointer;
}

.chip-button-primary {
  background: var(--accent);
  color: white;
  border-color: rgba(90, 63, 242, 0.28);
}

.table-field {
  position: relative;
  padding: 18px 24px 18px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  justify-items: center;
  gap: 6px;
}

.table-hud,
.join-panel {
  width: min(100%, 980px);
}

.opponent-slot,
.player-slot,
.center-stage,
.move-stack {
  width: min(100%, 640px);
}

.table-hud {
  position: absolute;
  top: 18px;
  right: max(24px, calc((100vw - 980px) / 2));
  width: auto;
  display: grid;
  justify-items: end;
  gap: 10px;
  z-index: 60;
}

.hud-menu {
  display: grid;
  justify-items: end;
  gap: 10px;
  position: relative;
  z-index: 61;
}

.tool-button {
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--dock-shadow);
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  z-index: 62;
}

.tool-icon-chat {
  position: relative;
  width: 24px;
  height: 18px;
  border: 2.5px solid #2d2d33;
  border-radius: 9px;
  background: white;
}

.tool-icon-chat::after {
  content: "";
  position: absolute;
  left: 4px;
  bottom: -6px;
  width: 8px;
  height: 8px;
  background: white;
  border-right: 2.5px solid #2d2d33;
  border-bottom: 2.5px solid #2d2d33;
  transform: rotate(35deg);
}

.tool-icon-menu {
  width: 24px;
  display: grid;
  gap: 4px;
}

.tool-icon-menu span {
  display: block;
  width: 24px;
  height: 3px;
  border-radius: 99px;
  background: #2d2d33;
}

.join-panel {
  grid-row: 1;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.join-field {
  display: grid;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--muted);
}

.join-field input {
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

.join-field input.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 1px rgba(235, 75, 84, 0.15);
}

.join-actions {
  gap: 10px;
  align-self: end;
}

.join-status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.92rem;
}

.lobby-banner {
  grid-row: 4;
  justify-self: center;
  align-self: center;
  width: fit-content;
  max-width: min(calc(100% - 32px), 440px);
  padding: 10px 16px;
  border: 1px solid rgba(90, 63, 242, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--table-ink);
  box-shadow: var(--shadow);
  text-align: center;
  z-index: 2;
}

.opponent-slot,
.player-slot,
.center-stage,
.move-stack {
  display: flex;
  justify-content: center;
  position: relative;
  isolation: isolate;
}

.opponent-slot {
  grid-row: 2;
  align-items: flex-start;
  min-height: 118px;
  z-index: 1;
  margin-bottom: 18px;
}

.center-stage {
  grid-row: 3;
  padding-right: 0;
  align-items: center;
  align-self: stretch;
  min-height: 154px;
  z-index: 2;
  margin-top: 8px;
  overflow: auto;
  overflow-x: auto;
  overflow-y: auto;
}

.player-slot {
  grid-row: 6;
  align-items: flex-end;
  min-height: 118px;
  margin-bottom: 14px;
  z-index: 14;
}

.move-stack {
  position: absolute;
  left: 50%;
  bottom: calc(var(--card-width) + 22px);
  transform: translateX(-50%);
  width: auto;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0;
  z-index: 22;
  pointer-events: none;
}

.move-stack > * {
  pointer-events: auto;
}

.move-stack.is-throw-anchor {
  bottom: auto;
  gap: 0;
  transform: translate(-50%, -100%);
}

.hand,
.table-spread {
  width: 100%;
}

.hand {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 122px;
  position: relative;
  z-index: 15;
}

.table-spread {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, var(--card-width)));
  grid-auto-rows: max-content;
  justify-content: center;
  align-content: center;
  justify-items: center;
  gap: 12px 12px;
  min-height: 156px;
  width: min(100%, calc((var(--card-width) * 4) + 40px));
  position: relative;
  margin-inline: auto;
}

.table-spread:empty {
  display: grid;
  place-items: center;
}

.table-spread:empty::before {
  content: "Mesa vacia";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
  white-space: nowrap;
  z-index: 1;
}

.card,
.card-back {
  width: var(--card-width);
  aspect-ratio: 5 / 7;
  height: auto;
  min-height: 0;
  max-height: none;
  border-radius: 12px;
  padding: 8px 7px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1.4px solid rgba(42, 42, 48, 0.48);
  background: var(--card);
  box-shadow: 0 8px 18px rgba(17, 17, 17, 0.05);
  position: relative;
  overflow: hidden;
  font-family: "Times New Roman", Georgia, serif;
  transform: rotate(var(--tilt, 0deg)) translateY(var(--lift, 0px));
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.card {
  appearance: none;
  cursor: pointer;
}

.hand .card + .card,
.hand .card-back + .card-back {
  margin-left: clamp(-28px, -2vw, -14px);
}

.hand-player .card:hover,
.hand-player .card.selected,
.hand-player .card.remote-selected {
  --lift: -18px;
  border-color: rgba(90, 63, 242, 0.7);
  box-shadow: 0 18px 32px rgba(38, 35, 80, 0.18);
  z-index: 30;
}

.hand-player {
  overflow: visible;
}

.hand-opponent {
  max-width: 420px;
}

.table-spread .card {
  --lift: calc(var(--table-offset, 0) * -1px);
  margin-left: 0;
  justify-self: center;
  align-self: end;
}

.table-spread .card.selected {
  --lift: -20px;
  border-color: rgba(90, 63, 242, 0.72);
  box-shadow: 0 18px 32px rgba(38, 35, 80, 0.16);
  z-index: 6;
}

.table-spread .card.remote-selected,
.hand-opponent .card-back.remote-selected {
  --lift: -20px;
  border-color: rgba(90, 63, 242, 0.72);
  box-shadow: 0 18px 32px rgba(38, 35, 80, 0.16);
  z-index: 6;
}

.card-back {
  border-color: rgba(78, 164, 211, 0.8);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.5), transparent),
    repeating-linear-gradient(
      45deg,
      rgba(78, 164, 211, 0.14),
      rgba(78, 164, 211, 0.14) 5px,
      rgba(78, 164, 211, 0.04) 5px,
      rgba(78, 164, 211, 0.04) 10px
    ),
    linear-gradient(180deg, #f9fdff 0%, #e4f4fb 100%);
}

.card-back::before,
.card-back::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 10px;
  border: 1.4px solid rgba(78, 164, 211, 0.75);
}

.card-back::after {
  inset: 17px;
  background:
    radial-gradient(circle, rgba(78, 164, 211, 0.24) 0 1px, transparent 1px 100%),
    white;
  background-size: 8px 8px;
}

.card-corner,
.card-center,
.card-figure {
  display: flex;
}

.card-corner {
  position: absolute;
  top: 8px;
  left: 7px;
  flex-direction: column;
  align-items: flex-start;
  line-height: 0.88;
  z-index: 1;
}

.card-corner-bottom {
  top: auto;
  right: 7px;
  bottom: 8px;
  left: auto;
  transform: rotate(180deg);
}

.corner-rank {
  font-size: clamp(1.2rem, 1.7vw, 1.65rem);
}

.corner-suit {
  font-size: clamp(0.9rem, 1.2vw, 1.05rem);
}

.card-center {
  position: absolute;
  inset: 18% 16%;
  align-items: center;
  justify-content: center;
  font-size: clamp(2.1rem, 3.3vw, 3.5rem);
  line-height: 1;
  z-index: 2;
}

.card-figure {
  position: absolute;
  inset: 17% 15%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  line-height: 0.95;
  overflow: hidden;
  z-index: 2;
}

.figure-rank {
  font-size: clamp(1.95rem, calc(var(--card-width) * 0.34), 2.7rem);
  line-height: 1;
}

.figure-suit {
  font-size: clamp(1rem, calc(var(--card-width) * 0.16), 1.5rem);
  line-height: 1;
}

.suit-hearts,
.suit-diamonds {
  color: var(--red);
}

.suit-clubs,
.suit-spades {
  color: var(--black);
}

.selection-chip {
  color: var(--table-ink);
  min-width: min(100%, 320px);
  min-height: 62px;
  justify-content: center;
  text-align: center;
}

.action-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0 24px;
  border: 1px solid rgba(90, 63, 242, 0.2);
  border-radius: 999px;
  background: linear-gradient(180deg, #20bcde 0%, #1fa9d9 100%);
  color: white;
  cursor: pointer;
  box-shadow: var(--dock-shadow);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.action-button-secondary {
  background: #434348;
}

.action-button-arrow {
  width: 58px;
  height: 60px;
  min-height: 60px;
  padding: 0;
  border: 0;
  display: grid;
  place-items: center;
  background: transparent;
  box-shadow: none;
  transition: opacity 120ms ease;
}

.action-button-arrow svg {
  width: 42px;
  height: 52px;
  fill: #2994f1;
}

.table-announcement {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(4px);
  color: var(--table-ink);
  z-index: 4000;
  pointer-events: auto;
}

.table-app.has-modal-dialog .player-strip,
.table-app.has-modal-dialog .table-hud,
.table-app.has-modal-dialog .message-bubbles,
.table-app.has-modal-dialog .move-stack {
  z-index: 0 !important;
  pointer-events: none;
}

.table-announcement-actions {
  display: flex;
  justify-content: center;
}

.table-dialog {
  width: min(100vw - 40px, 760px);
  padding: 20px 20px 18px;
  display: grid;
  gap: 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(90, 63, 242, 0.22);
  box-shadow: var(--dock-shadow);
}

.table-dialog-scrollable {
  max-height: 85vh;
  overflow: auto;
}

.table-dialog-title {
  margin: 0;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.table-dialog-copy {
  margin: 0;
  text-align: center;
  line-height: 1.45;
}

.table-dialog-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.table-dialog-note {
  color: var(--muted);
  font-size: 0.92rem;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(90, 63, 242, 0.14);
  background: #fbfbfd;
}

.summary-table.summary-table-wide th,
.summary-table.summary-table-wide td {
  padding: 9px 10px;
  font-size: 0.92rem;
}

.summary-table.summary-table-wide th:first-child,
.summary-table.summary-table-wide td:first-child {
  text-align: left;
  min-width: 110px;
}

.summary-table.summary-table-wide th:not(:first-child),
.summary-table.summary-table-wide td:not(:first-child) {
  text-align: center;
  min-width: 120px;
}

.winner-summary {
  display: grid;
  gap: 14px;
}

.score-chart {
  display: grid;
  gap: 8px;
}

.score-chart-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.score-chart-svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
}

.score-chart-grid {
  stroke: rgba(23, 23, 23, 0.08);
  stroke-width: 1;
}

.score-chart-axis-label,
.score-chart-caption {
  fill: var(--muted);
  font-size: 12px;
  font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.score-chart-name {
  font-size: 11px;
  font-weight: 700;
  font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.score-chart-dot-south {
  fill: #5a3ff2;
}

.score-chart-dot-north {
  fill: #20bcde;
}

.winner-summary-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(90, 63, 242, 0.04);
  border: 1px solid rgba(90, 63, 242, 0.1);
  color: var(--muted);
  font-size: 0.9rem;
}

.winner-summary-meta strong {
  color: var(--table-ink);
}

.summary-table th,
.summary-table td {
  padding: 10px 12px;
  text-align: left;
}

.summary-table th {
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(90, 63, 242, 0.05);
}

.summary-table td {
  border-top: 1px solid rgba(215, 215, 219, 0.7);
}

.summary-table td:nth-child(n + 2),
.summary-table th:nth-child(n + 2) {
  text-align: center;
}

.table-announcement-button {
  appearance: none;
  min-height: 34px;
  padding: 6px 16px;
  border: 1px solid rgba(90, 63, 242, 0.24);
  border-radius: 999px;
  background: #2994f1;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.table-announcement-button-secondary {
  background: #434348;
  border-color: rgba(67, 67, 72, 0.22);
}

.move-options {
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.move-option {
  appearance: none;
  min-height: 52px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--table-ink);
  cursor: pointer;
  gap: 10px;
  box-shadow: var(--shadow);
}

.move-option:hover,
.chip-button:hover,
.chip-link:hover {
  border-color: rgba(90, 63, 242, 0.38);
  transform: translateY(-1px);
}

.move-detail {
  color: var(--muted);
}

.floating-controls {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  gap: 16px;
  z-index: 4;
}

.floating-button,
.close-button {
  border: 0;
  cursor: pointer;
}

.floating-button {
  width: 68px;
  height: 68px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #434348;
  color: white;
  box-shadow: var(--dock-shadow);
  font-size: 1.8rem;
}

.floating-button-primary {
  background: linear-gradient(180deg, #20bcde 0%, #1fa9d9 100%);
}

.log-drawer {
  position: fixed;
  right: 20px;
  bottom: 120px;
  width: min(360px, calc(100vw - 32px));
  max-height: min(420px, calc(100vh - 180px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  box-shadow: 0 22px 50px rgba(17, 17, 17, 0.16);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 80;
}

.log-header {
  justify-content: space-between;
  gap: 12px;
}

.drawer-title {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.close-button {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #f1f1f4;
  color: var(--table-ink);
  font-size: 1.4rem;
}

.messages {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding-bottom: 6px;
}

.message {
  padding: 10px 12px;
  border-radius: 14px;
  background: #f6f6f8;
  color: var(--table-ink);
  line-height: 1.35;
  display: grid;
  gap: 4px;
}

.message strong,
.message-bubble strong {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.composer {
  margin-top: 14px;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
  align-items: stretch;
  padding-bottom: 2px;
}

.composer-select,
.composer-input {
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--table-ink);
}

.composer-select {
  min-width: 180px;
}

.composer-input {
  flex: 1 1 180px;
  min-width: 0;
  min-height: 76px;
  max-height: 120px;
  resize: none;
  overflow-y: auto;
  line-height: 1.35;
  font: inherit;
}

.message-bubbles {
  position: absolute;
  top: 50%;
  right: -220px;
  transform: translateY(-50%);
  width: 200px;
  display: grid;
  gap: 10px;
}

.animation-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
}

.fly-card {
  position: fixed;
  margin: 0;
  transform-origin: center center;
  backface-visibility: hidden;
  transition:
    left 260ms ease,
    top 260ms ease,
    transform 260ms ease,
    opacity 260ms ease;
}

.fly-card.is-revealing {
  animation: fly-card-reveal 220ms ease;
}

.fly-card.is-collapsing {
  transition:
    left 300ms ease,
    top 300ms ease,
    transform 300ms ease,
    opacity 300ms ease;
}

@keyframes fly-card-reveal {
  0% {
    opacity: 0.35;
    transform: rotateY(88deg) scale(0.96);
  }

  100% {
    opacity: 1;
    transform: rotateY(0deg) scale(1);
  }
}

.message-bubble {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(90, 63, 242, 0.16);
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
}

.carton-widget {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.carton-label {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.carton-stack {
  position: relative;
  width: 64px;
  height: 86px;
}

.card-back-mini {
  width: 56px;
  border-radius: 10px;
  display: none;
}

.carton-stack.has-stack-back .card-back-mini {
  display: block;
}

.carton-preview {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.carton-mini-card {
  position: absolute;
  width: 56px;
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  padding: 6px 5px;
  border: 1px solid rgba(42, 42, 48, 0.3);
  background: white;
  box-shadow: 0 6px 12px rgba(17, 17, 17, 0.08);
  font-family: "Times New Roman", Georgia, serif;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.carton-mini-card:first-child {
  left: -3px;
  top: 8px;
  transform: rotate(-9deg);
}

.carton-mini-card:last-child {
  left: 5px;
  top: 2px;
  transform: rotate(8deg);
}

.carton-mini-card .card-corner {
  line-height: 0.86;
}

.carton-mini-card .corner-rank {
  font-size: 1rem;
}

.carton-mini-card .corner-suit {
  font-size: 0.78rem;
}

.carton-mini-card .card-center,
.carton-mini-card .card-figure {
  font-size: 1.15rem;
  justify-content: center;
}

.carton-mini-card .card-corner-bottom {
  transform: rotate(180deg);
}

.carton-count {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #2994f1;
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
}

.rules-page {
  padding: 36px 18px 60px;
}

.rules-shell {
  width: min(100%, 920px);
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.rules-back {
  width: fit-content;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  text-decoration: none;
}

.rules-hero,
.rules-card {
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.rules-kicker {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.rules-hero h1 {
  margin: 8px 0 12px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  letter-spacing: -0.05em;
}

.rules-summary {
  max-width: 68ch;
  line-height: 1.55;
  color: var(--table-ink);
}

.rules-card h2 {
  margin-bottom: 12px;
  font-size: 1.2rem;
}

.rules-card ul {
  padding-left: 18px;
  line-height: 1.55;
}

.rules-card li + li {
  margin-top: 8px;
}

.rules-examples {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.rules-example {
  padding: 13px 14px;
  border: 1px solid rgba(32, 188, 222, 0.28);
  border-radius: 18px;
  background: rgba(208, 243, 251, 0.72);
}

.rules-example strong {
  display: block;
  margin-bottom: 6px;
  font-size: 0.94rem;
  color: var(--table-ink);
}

.rules-example p {
  margin: 0;
  line-height: 1.5;
  color: var(--table-ink);
}

@media (max-width: 900px) {
  :root {
    --card-width: clamp(82px, 12vw, 115px);
  }

  .player-strip {
    min-height: 68px;
    padding: 9px 14px;
  }

  .table-field {
    padding: 14px 14px 0;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  }

  .opponent-slot,
  .player-slot,
  .center-stage,
  .move-stack {
    width: min(100%, 560px);
  }

  .center-stage {
    padding-right: 0;
    min-height: 146px;
  }

  .table-spread {
    gap: 10px 10px;
    min-height: 144px;
  }

  .message-bubbles {
    position: fixed;
    top: 50%;
    right: max(12px, env(safe-area-inset-right));
    transform: translateY(-50%);
    width: min(200px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    margin-top: 0;
    z-index: 70;
    pointer-events: none;
  }

  .join-panel {
    grid-template-columns: 1fr;
  }

  .join-actions {
    justify-content: flex-start;
  }

  .strip-status {
    max-width: 42vw;
  }
}

@media (min-width: 720px) and (max-width: 900px) {
  .opponent-slot,
  .player-slot,
  .center-stage {
    width: min(100%, 600px);
  }

  .center-stage {
    padding: 4% 3%;
    box-sizing: border-box;
  }

  .table-spread {
    width: max-content;
    min-width: min(100%, calc((var(--card-width) * 4) + 40px));
  }

  .move-stack {
    bottom: calc(var(--card-width) + 10px);
  }
}

@media (max-aspect-ratio: 4 / 5) {
  :root {
    --card-width: clamp(77px, 16.8vw, 108px);
  }

  .table-field {
    padding: 12px 10px 18px;
    gap: 4px;
  }

  .opponent-slot,
  .player-slot,
  .center-stage,
  .move-stack {
    width: min(100%, 420px);
  }

  .opponent-slot,
  .player-slot,
  .center-stage {
    overflow-x: auto;
    overflow-y: visible;
    padding: 7%;
    justify-content: flex-start;
    box-sizing: border-box;
  }

  .opponent-slot {
    min-height: 110px;
    margin-bottom: 24px;
  }

  .center-stage {
    min-height: 146px;
    margin-top: 10px;
  }

  .player-slot {
    min-height: 102px;
    margin-bottom: 12px;
    z-index: 18;
  }

  .hand {
    min-height: 104px;
    z-index: 19;
  }

  .move-stack {
    min-height: 0;
    z-index: 22;
  }

  .table-spread {
    width: max-content;
    min-width: calc((var(--card-width) * 4) + 24px);
    min-height: 124px;
    gap: 8px 8px;
    margin-inline: auto;
  }

  .hand {
    width: max-content;
    min-width: 100%;
    margin-inline: auto;
  }

  .lobby-banner {
    max-width: min(calc(100% - 24px), 360px);
    padding: 9px 14px;
    font-size: 0.94rem;
  }
}

@media (max-width: 640px) {
  :root {
    --card-width: clamp(74px, 19.2vw, 101px);
  }

  .player-strip,
  .player-strip-bottom {
    align-items: center;
    flex-direction: row;
  }

  .strip-side,
  .strip-side-bottom {
    justify-content: flex-end;
  }

  .carton-widget {
    justify-content: flex-end;
  }

  .strip-status {
    max-width: none;
    white-space: nowrap;
  }

  .table-hud {
    justify-content: flex-start;
  }

  .player-name {
    font-size: clamp(1rem, 5vw, 1.35rem);
  }

  .score-badge {
    width: 42px;
    height: 42px;
    font-size: 1.18rem;
  }

  .carton-widget {
    gap: 6px;
  }

  .carton-label,
  .strip-status {
    font-size: 0.88rem;
  }

  .hand .card + .card,
  .hand .card-back + .card-back {
    margin-left: -18px;
  }

  .selection-chip {
    min-width: 0;
    width: 100%;
  }

  .move-options {
    width: 100%;
  }

  .move-option {
    width: 100%;
    text-align: center;
  }

  .floating-controls {
    bottom: 18px;
  }

  .composer {
    flex-direction: column;
  }

  .composer-select,
  .composer-input,
  .composer .chip-button {
    width: 100%;
  }

  .composer-input {
    min-height: 64px;
    max-height: 96px;
  }
}

@media (max-width: 520px) {
  .player-strip,
  .player-strip-bottom {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .strip-side,
  .strip-side-bottom {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .carton-widget {
    justify-content: flex-start;
  }
}
