/* Rummy table — Dev host + invite-only join
   Author: Dave Greenlaw */

.rm-app {
  --rm-felt: var(--crib-felt, color-mix(in srgb, #14532d 42%, var(--surface, #f5f6f8)));
}

.rm-app > .crib-status {
  display: none !important;
}

.rm-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 260px);
  flex: 1 1 auto;
  min-height: 0;
}

.rm-stage {
  padding: 10px 10px 16px;
  min-height: 0;
}

.rm-table {
  position: relative;
  border-radius: 22px;
  background:
    radial-gradient(120% 90% at 50% 30%, color-mix(in srgb, var(--rm-felt) 82%, #fff), var(--rm-felt));
  border: 1px solid var(--crib-felt-line, var(--border));
  box-shadow:
    0 16px 36px color-mix(in srgb, var(--text, #000) 16%, transparent),
    inset 0 1px 0 color-mix(in srgb, #fff 22%, transparent);
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  color: var(--text, #1a1a1a);
}

.rm-match-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  justify-content: center;
  align-items: baseline;
  padding: 8px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface, #fff) 78%, transparent);
  border: 1px solid var(--border, #ccc);
  color: var(--text, #1a1a1a);
  font-size: 0.82rem;
  line-height: 1.35;
}

.rm-match-status[hidden] {
  display: none;
}

.rm-match-status__turn {
  font-weight: 700;
}

.rm-match-status__play {
  color: var(--text-muted, #5c6470);
}

.rm-seats__opp {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.rm-seats__you {
  display: none;
}

.rm-seat {
  min-width: 8.5rem;
  max-width: 16rem;
  padding: 8px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface, #fff) 55%, transparent);
  border: 1px solid var(--border, rgba(128, 128, 128, 0.28));
  color: var(--text, #1a1a1a);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rm-seat.is-you {
  border-color: var(--accent, #2563eb);
}

.rm-seat.is-actor {
  box-shadow: 0 0 0 2px var(--accent, #2563eb);
}

.rm-seat.is-empty {
  opacity: 0.45;
  min-height: 3rem;
}

.rm-seat__meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.rm-seat__name {
  font-weight: 700;
  font-size: 0.85rem;
}

.rm-seat__tag--turn {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent, #2563eb);
}

.rm-seat__score {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: stretch;
  padding: 6px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent, #2563eb) 16%, var(--surface, #fff));
  border: 1px solid color-mix(in srgb, var(--accent, #2563eb) 42%, var(--border, #ccc));
  color: var(--text, #1a1a1a);
  line-height: 1.15;
}

.rm-seat__score-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted, #5c6470);
}

.rm-seat__score-n {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text, #1a1a1a);
}

.rm-you-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 8px 12px;
  padding: 8px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent, #2563eb) 16%, var(--surface, #fff));
  border: 1px solid color-mix(in srgb, var(--accent, #2563eb) 48%, var(--border, #ccc));
  color: var(--text, #1a1a1a);
}

.rm-you-bar[hidden] {
  display: none;
}

.rm-you-bar__label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted, #5c6470);
}

.rm-you-bar__n {
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text, #1a1a1a);
}

.rm-you-bar__to {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text, #1a1a1a);
}

.rm-match-status__you {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rm-seat__cards {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.rm-seat__cards .crib-card {
  width: 2.2rem;
  height: 3.1rem;
  font-size: 0.68rem;
}

.rm-piles {
  display: flex;
  justify-content: center;
  gap: 18px;
}

.rm-pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--text, #1a1a1a);
  font: inherit;
}

.rm-pile.is-legal {
  cursor: pointer;
}

.rm-pile.is-legal:focus-visible {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: 2px;
  border-radius: 8px;
}

.rm-pile:disabled {
  opacity: 0.85;
  cursor: default;
}

.rm-pile.is-locked {
  opacity: 1;
}

.rm-pile.is-locked .rm-pile__label {
  color: var(--text, #1a1a1a);
}

.rm-pile__label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted, #5c6470);
}

.rm-melds__empty {
  margin: 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted, #5c6470);
}

.rm-meld-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.rm-meld {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--border, rgba(128, 128, 128, 0.28));
  background: color-mix(in srgb, var(--surface, #fff) 70%, transparent);
  color: var(--text, #1a1a1a);
  font: inherit;
  cursor: pointer;
}

.rm-meld.is-target {
  box-shadow: 0 0 0 2px var(--accent, #2563eb);
}

.rm-meld:focus-visible {
  outline: 2px solid var(--accent, #2563eb);
  outline-offset: 2px;
}

.rm-meld__who {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted, #5c6470);
}

.rm-meld__cards {
  display: flex;
  gap: 3px;
}

.rm-meld__cards .crib-card {
  width: 2.1rem;
  height: 3rem;
  font-size: 0.65rem;
}

.rm-hand__row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.rm-hand__row .crib-card {
  width: 3.4rem;
  height: 4.8rem;
}

.rm-hand__row .crib-card.is-legal {
  cursor: pointer;
}

.rm-hand__row .crib-card.is-selected {
  transform: translateY(-8px);
  box-shadow: 0 0 0 2px var(--accent, #2563eb);
}

.rm-hand__hint {
  margin: 6px 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted, #5c6470);
}

.rm-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}

.rm-app.is-game-focus [data-rm-dev-tools],
.rm-app.is-game-focus .crib-chat,
.rm-app.is-game-focus [data-rm-act="create"],
.rm-app.is-game-focus [data-rm-act="copy"],
.rm-app.is-game-focus [data-rm-act="fill_ai"],
.rm-app.is-game-focus [data-rm-act="start"],
.rm-app.is-game-focus .pk-setup-host {
  display: none !important;
}

@media (max-width: 720px) {
  .rm-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .rm-app .crib-chat {
    display: none;
  }

  .rm-hand__row .crib-card {
    width: 2.8rem;
    height: 4rem;
  }

  .rm-actions .pill-btn {
    min-height: 40px;
  }
}

html[data-a11y-view="comfort"] .rm-actions .pill-btn,
html[data-a11y-view="comfort"] .rm-pile,
html[data-a11y-view="comfort"] .rm-meld {
  min-height: 44px;
}

html[data-a11y-view="contrast"] .rm-meld,
html[data-a11y-view="contrast"] .rm-seat {
  border-width: 2px;
}

html[data-theme="dark"] .rm-match-status,
html[data-theme="soft"] .rm-match-status,
html[data-theme="glass"] .rm-match-status,
html[data-theme="dark"] .rm-you-bar,
html[data-theme="soft"] .rm-you-bar,
html[data-theme="glass"] .rm-you-bar,
html[data-theme="dark"] .rm-seat__score,
html[data-theme="soft"] .rm-seat__score,
html[data-theme="glass"] .rm-seat__score {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  color: var(--text);
}

html[data-a11y-view="contrast"] .rm-match-status,
html[data-a11y-view="contrast"] .rm-you-bar,
html[data-a11y-view="contrast"] .rm-seat__score {
  border-width: 2px;
}

html[data-theme="glass"] .rm-table {
  --rm-felt: color-mix(in srgb, #166534 42%, var(--surface, rgba(20, 24, 32, 0.55)));
  border-color: var(--glass-edge, var(--border));
}

html[data-theme="glass"] .rm-seat,
html[data-theme="glass"] .rm-meld {
  background: color-mix(in srgb, var(--surface, rgba(20, 24, 32, 0.55)) 80%, transparent);
  border-color: var(--glass-edge, var(--border));
  color: var(--text);
}
