:root {
  color-scheme: dark;
  --card-w: 86px;
  --bg: #141413;
  --surface: #1f211e;
  --surface-2: #292b27;
  --line: #45483f;
  --text: #f4f1e7;
  --muted: #b8b2a3;
  --accent: #62b6cb;
  --accent-2: #f6c85f;
  --danger: #e76f51;
  --ok: #9bc53d;
  --shadow: 0 18px 48px rgba(0, 0, 0, .28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(98, 182, 203, .10), transparent 30%),
    linear-gradient(225deg, rgba(246, 200, 95, .10), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input,
a {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover:not(:disabled),
button:focus-visible {
  border-color: var(--accent);
}

button:disabled {
  opacity: .46;
  cursor: not-allowed;
}

a {
  color: inherit;
}

#app {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 12px 16px;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

/* On phones, the scoreboard and secondary actions move into an off-canvas
   drawer so the topbar collapses to a single row and the game board gets
   the rest of the screen. The drawer panel is `display: contents` by
   default so its contents keep acting as normal topbar grid items (and the
   layout is unchanged) until the phone breakpoint below turns it into a
   real off-canvas panel. */
.mobile-drawer-panel {
  display: contents;
}

.scoreboard {
  order: 1;
}

.topbar-phase {
  order: 2;
}

.topbar-secondary {
  order: 3;
}

.drawer-handle,
.drawer-backdrop {
  display: none;
}

.topbar-secondary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

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

.topbar .eyebrow {
  display: none;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 2.35vw, 2.45rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.topbar-actions,
.turn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.topbar-actions {
  justify-content: flex-end;
  align-self: center;
}

.topbar-actions > .mode-control > span {
  display: none;
}

.host-controls,
.more-menu-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(31, 33, 30, .78);
}

.host-controls[hidden] {
  display: none;
}

.room-code {
  max-width: 150px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 0 10px;
  font-size: .78rem;
}

.topbar-actions button {
  min-height: 34px;
  padding: 0 11px;
}

.topbar-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 11px;
  text-decoration: none;
}

.topbar-link:hover,
.topbar-link:focus-visible {
  border-color: var(--accent);
}

.mode-control {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: .84rem;
}

select,
input {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 38px 0 12px;
}

input {
  padding-right: 12px;
}

.game-shell {
  display: grid;
  gap: 10px;
}

.lobby-app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 18px 22px;
}

.lobby-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand-lockup {
  display: grid;
  gap: 2px;
  color: var(--text);
  text-decoration: none;
}

.brand-lockup span {
  color: var(--accent-2);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.brand-lockup strong {
  font-size: 1.25rem;
}

.lobby-nav-actions,
.lobby-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.lobby-nav-actions a,
.secondary-action {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(31, 33, 30, .74);
  color: var(--text);
  padding: 0 14px;
  text-decoration: none;
}

.lobby-nav-actions a:hover,
.lobby-nav-actions a:focus-visible,
.secondary-action:hover,
.secondary-action:focus-visible {
  border-color: var(--accent);
}

.lobby-home {
  display: grid;
  gap: 18px;
  align-content: start;
}

.lobby-hero {
  min-height: 390px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, .62fr);
  align-items: center;
  gap: 24px;
}

.lobby-hero-copy {
  max-width: 840px;
}

.lobby-hero h1 {
  max-width: 840px;
  margin-bottom: 14px;
  font-size: clamp(2.4rem, 4.7vw, 4.65rem);
  line-height: 1.06;
}

.lobby-lede {
  max-width: 680px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.lobby-primary {
  min-height: 50px;
  padding: 0 20px;
  font-size: 1.02rem;
}

.lobby-table-preview {
  display: grid;
  place-items: center;
}

.preview-felt {
  position: relative;
  width: min(100%, 470px);
  aspect-ratio: 1.35;
  border: 1px solid rgba(98, 182, 203, .38);
  border-radius: 8px;
  background:
    radial-gradient(circle at 35% 32%, rgba(98, 182, 203, .18), transparent 30%),
    linear-gradient(145deg, rgba(31, 33, 30, .96), rgba(20, 20, 19, .92));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.preview-card {
  position: absolute;
  width: 22%;
  filter: drop-shadow(0 18px 18px rgba(0, 0, 0, .42));
}

.card-a {
  left: 14%;
  top: 27%;
  transform: rotate(-10deg);
}

.card-b {
  left: 31%;
  top: 20%;
  transform: rotate(-4deg);
}

.card-c {
  left: 49%;
  top: 18%;
  transform: rotate(5deg);
}

.card-d {
  left: 66%;
  top: 27%;
  transform: rotate(11deg);
}

.preview-chip {
  position: absolute;
  left: 18px;
  bottom: 18px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: rgba(98, 182, 203, .16);
  color: var(--text);
  padding: 7px 11px;
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.open-tables-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(31, 33, 30, .82);
  padding: 14px;
}

.open-tables-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.open-tables-heading h2 {
  margin-bottom: 0;
  font-size: 1.28rem;
}

.compact-action {
  min-height: 38px;
  padding: 0 13px;
  white-space: nowrap;
}

.open-rooms-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.open-room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  border: 1px solid rgba(241, 238, 230, .13);
  border-radius: 8px;
  background: rgba(12, 13, 12, .34);
  padding: 11px;
}

.open-room-details {
  min-width: 0;
}

.open-room-details strong,
.open-room-details span {
  display: block;
}

.open-room-details strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
}

.open-room-details p {
  margin: 4px 0 2px;
  color: var(--muted);
  font-size: .9rem;
}

.open-room-details span,
.open-rooms-empty {
  color: var(--accent-2);
  font-size: .82rem;
}

.open-rooms-empty {
  margin: 2px 0 0;
}

.create-room-modal {
  width: min(500px, 100%);
}

.modal-heading-row,
.modal-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  min-width: 38px;
  width: 38px;
  height: 38px;
  padding: 0;
  font-weight: 900;
  text-transform: uppercase;
}

.create-room-form {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.create-room-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: .86rem;
}

.create-room-form input,
.create-room-form select,
.create-room-form button {
  width: 100%;
}

.color-picker {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .86rem;
}

.color-swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(26px, 1fr));
  gap: 8px;
}

.color-swatch {
  width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .18);
  background: var(--swatch-color);
  cursor: pointer;
}

.color-swatch:hover,
.color-swatch:focus-visible {
  transform: scale(1.12);
}

.color-swatch[aria-pressed="true"] {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--swatch-color);
}

.scoreboard {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.scoreboard article,
.log-panel {
  background: rgba(31, 33, 30, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.scoreboard article {
  flex: 0 1 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 9px;
}

.scoreboard span {
  color: var(--muted);
  font-size: .78rem;
}

.scoreboard strong {
  font-size: 1.05rem;
  font-weight: 700;
}

.room-lobby {
  display: grid;
  grid-template-columns: minmax(220px, .65fr) minmax(0, 1.5fr);
  gap: 12px;
  align-items: end;
  padding: 14px;
  background: rgba(31, 33, 30, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.room-lobby[hidden] {
  display: none;
}

.room-lobby h2 {
  margin: 2px 0 4px;
  font-size: 1.18rem;
}

.room-lobby p {
  margin: 0;
  color: var(--muted);
}

.room-lobby-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.room-lobby-grid article,
.room-lobby-grid .room-seat-card {
  min-width: 0;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  background: rgba(255, 255, 255, .035);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
}

.room-lobby-grid .room-seat-card {
  color: var(--text);
  cursor: pointer;
}

.room-lobby-grid .room-seat-card:not(:disabled):hover,
.room-lobby-grid .room-seat-card:not(:disabled):focus-visible {
  border-color: var(--accent);
  background: rgba(98, 182, 203, .10);
}

.room-lobby-grid .room-seat-card:disabled {
  cursor: default;
  opacity: .78;
}

.room-lobby-grid span,
.room-lobby-grid em {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-style: normal;
}

.room-lobby-grid strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-lobby-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.table-area {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px 14px;
  align-items: start;
}

.opponent-zone,
.center-zone,
.meld-zone,
.hand-zone {
  min-width: 0;
}

.opponent-zone {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.center-zone {
  display: grid;
  grid-template-columns: 98px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.meld-zone {
  align-self: stretch;
  width: 100%;
}

.hand-zone {
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--line);
}

.player-row,
.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 5px;
}

.opponent-zone .player-row {
  flex: 0 0 auto;
  min-width: 150px;
  margin-bottom: 0;
}

.player-row p,
.section-heading p,
.phase-chip span {
  margin-bottom: 0;
  color: var(--muted);
}

.hand-zone .section-heading {
  align-items: center;
}

.hand-main-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(850px, auto);
  gap: 8px;
}

.hand-title-block {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.hand-title-block h2,
.hand-title-block p {
  margin-bottom: 0;
}

.hand-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: .86rem;
}

.hand-tool-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .86rem;
}

.segmented-control {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}

.segmented-control button {
  min-height: 42px;
  padding: 0 12px;
}

.segmented-control button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.hint-toggle {
  min-height: 42px;
  padding: 0 12px;
}

.hint-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.hand-action-bar {
  margin-bottom: 6px;
  padding: 0;
}

.feedback-message {
  margin: 0;
  border: 1px solid var(--accent-2);
  border-radius: 8px;
  background: rgba(246, 200, 95, .12);
  color: var(--text);
  padding: 8px 10px;
}

.feedback-message:empty,
.feedback-message[hidden] {
  display: none;
}

.phase-chip {
  display: grid;
  gap: 3px;
  min-width: 0;
  text-align: center;
  justify-self: center;
  align-self: center;
}

.topbar-phase {
  max-width: 560px;
}

.phase-chip strong {
  color: var(--accent-2);
}

.topbar-field-label {
  color: var(--muted);
  font-weight: 500;
}

.phase-chip span {
  font-size: .86rem;
}

.phase-chip-help {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.stat-divider {
  margin: 0 3px;
  color: var(--muted);
  font-weight: 500;
}

.turn-actions {
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-self: center;
}

.turn-actions button {
  white-space: nowrap;
}

.mini-melds {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: end;
}

.mini-melds span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: .78rem;
}

.opponent-hand {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 70px;
  overflow: hidden;
}

.opponent-hand img {
  width: 52px;
  height: 74px;
  object-fit: contain;
  margin-right: -28px;
  border-radius: 6px;
  box-shadow: 0 6px 8px rgba(0, 0, 0, .24);
}

.pile {
  position: relative;
  width: 98px;
  min-height: 138px;
  display: grid;
  place-items: center;
  padding: 6px;
}

.pile img,
.card-button img,
.meld-card img,
.discard-card img,
.card-art img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.deck-pile span {
  position: absolute;
  right: 8px;
  bottom: 8px;
  min-width: 30px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 3px 7px;
  font-weight: 700;
}

.deck-pile:disabled {
  opacity: 1;
}

.discard-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
}

.discard-scroll-arrow {
  position: absolute;
  top: 6px;
  bottom: 18px;
  z-index: 5;
  width: 40px;
  min-height: 0;
  border: none;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
  opacity: .92;
  cursor: pointer;
  transition: opacity .14s ease;
}

.discard-scroll-arrow-left {
  left: 0;
  background: linear-gradient(90deg, var(--bg) 22%, rgba(18, 20, 18, 0));
}

.discard-scroll-arrow-right {
  right: 0;
  background: linear-gradient(270deg, var(--bg) 22%, rgba(18, 20, 18, 0));
}

.discard-scroll-arrow:disabled {
  opacity: 0;
  pointer-events: none;
}

.discard-pile {
  display: flex;
  min-height: 150px;
  align-items: start;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 0 12px;
  cursor: grab;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  user-select: none;
  -ms-overflow-style: none;
}

.discard-pile::-webkit-scrollbar {
  display: none;
}

.discard-pile.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
}

.discard-pile.is-dragging .discard-card {
  pointer-events: none;
}

.discard-card {
  flex: 0 0 98px;
  margin-right: calc(98px * -0.4);
  border: 1px solid transparent;
  background: transparent;
  padding: 6px;
  min-height: auto;
  position: relative;
}

.discard-card:last-child {
  margin-right: 0;
}

.discard-card.is-selected {
  transform: translateY(-8px);
  border-color: var(--accent-2);
  z-index: 4;
}

.discard-card.is-free-draw {
  border-color: var(--accent);
  filter: brightness(1.08);
  z-index: 3;
}

.discard-card.is-eligible {
  border-color: var(--accent-2);
  filter: brightness(1.06);
  z-index: 2;
}

.discard-card.is-ineligible {
  opacity: .26;
  filter: grayscale(.35) saturate(.45) brightness(.62);
  cursor: not-allowed;
  z-index: 0;
}

.discard-card.discard-card-latest {
  box-shadow: 0 0 0 2px var(--accent-2), 0 0 10px rgba(246, 200, 95, .45);
  border-radius: 8px;
}

.round-ready-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 12px;
}

.round-ready-status span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: .82rem;
}

.round-ready-status span.is-ready {
  border-color: var(--ok);
  color: var(--ok);
}

.discard-pile.is-locked .discard-card:not(.is-ineligible) {
  cursor: not-allowed;
}

.discard-index {
  position: absolute;
  left: 5px;
  bottom: 5px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 6px;
  font-size: .72rem;
}

.discard-cue {
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 3px 7px;
  font-size: .62rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  z-index: 2;
}

.discard-card.is-free-draw .discard-cue {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.discard-card.is-eligible .discard-cue {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: var(--bg);
}

.phase-label {
  color: var(--accent-2) !important;
  font-weight: 700;
  margin-bottom: 6px !important;
}

.meld-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: start;
  padding-bottom: 4px;
}

.meld-row {
  display: block;
  flex: 0 1 auto;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(31, 33, 30, .66);
}

.meld-drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  padding: 14px 10px;
  border: 2px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 600;
  text-align: center;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}

.meld-drop-zone[hidden] {
  display: none;
}

.meld-drop-zone.is-drop-valid {
  border-color: var(--accent);
  background: rgba(98, 182, 203, .14);
  color: var(--text);
}

.meld-drop-zone.is-drop-invalid {
  border-color: var(--danger);
  background: rgba(231, 111, 81, .14);
  color: var(--text);
}

.meld-row.is-drop-valid {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(98, 182, 203, .3);
}

.meld-row.is-drop-invalid {
  position: relative;
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(231, 111, 81, .3);
}

.meld-row.is-drop-invalid::after {
  content: "\26D4";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  color: var(--danger);
  background: rgba(18, 20, 18, .55);
  border-radius: 7px;
  pointer-events: none;
}

.meld-row-label {
  display: block;
  margin-bottom: 5px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.15;
}

.meld-cards {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  padding-right: 4px;
}

.meld-card {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: var(--card-w);
  margin-right: calc(var(--card-w) * -0.42);
  border: 2px solid transparent;
  border-radius: 7px;
  position: relative;
  display: inline-block;
}

.meld-card:last-child {
  margin-right: 0;
}

.meld-card.meld-card-misty {
  border: 2px dashed rgba(255, 255, 255, .85);
  border-radius: 7px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .14);
}

.meld-card-misty img {
  border-radius: 5px;
}

.meld-card {
  --owner-color: var(--player-color, var(--muted));
  border-color: var(--owner-color);
}

.meld-card-human {
  --owner-color: var(--player-color, var(--accent-2));
}

.meld-card-cpu {
  --owner-color: var(--player-color, var(--accent));
}

.meld-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  border-radius: 0 0 4px 4px;
  background: var(--owner-color);
  pointer-events: none;
}

.meld-card-enter {
  animation: cpu-meld-enter .42s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes cpu-meld-enter {
  from {
    opacity: 0;
    transform: translateY(64px) scale(.82) rotate(-3deg);
  }

  70% {
    opacity: 1;
    transform: translateY(4px) scale(1.03) rotate(1deg);
  }

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

.meld-card-marker {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 5px;
  display: block;
  border-radius: 999px;
  padding: 1px 4px;
  color: var(--bg);
  font-size: .58rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.card-art {
  position: relative;
  display: block;
}


.card-art .meld-card-value {
  top: 77.5%;
}

.meld-card-value {
  position: absolute;
  top: 5px;
  left: 50%;
  z-index: 2;
  min-width: 34px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, .85);
  border-radius: 999px;
  background: rgba(20, 20, 19, .92);
  color: #fff;
  padding: 2px 6px;
  font-size: .58rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.meld-card-human .meld-card-marker {
  background: var(--accent-2);
}

.meld-card-cpu .meld-card-marker {
  background: var(--accent);
}

.meld-card-unknown .meld-card-marker {
  background: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .meld-card-enter {
    animation: none;
  }
}

/* Room presence and seat invitations */
.room-presence-chip {
  align-self: center;
  cursor: pointer;
  padding: .55rem .8rem;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 999px;
  color: #d9e6e7;
  background: rgba(255, 255, 255, .055);
  font-size: .78rem;
  white-space: nowrap;
}
.room-presence-chip:empty { display: none; }
#reconnectClock {
  display: block;
  margin-top: 3px;
  color: #f6c85f;
  font-size: .72rem;
}
.invite-panel { max-width: 32rem; }
.room-people-panel { max-width: 42rem; }
.admin-room-closed-panel { max-width: 32rem; }
.room-people-list { display: grid; gap: 8px; }
.room-person-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .10);
}
.room-person-row.is-admin-watcher {
  color: #ff7777;
  background: rgba(173, 45, 45, .10);
  border-radius: 7px;
  padding-inline: 8px;
}
.room-person-row.is-admin-watcher .room-person-identity span { color: #ff7777; }
.room-person-identity { display: flex; align-items: center; gap: 8px; min-width: 0; }
.room-person-text { display: grid; gap: 2px; min-width: 0; }
.room-person-identity span { color: var(--muted); font-size: .78rem; }
.room-person-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .07);
}
.room-person-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.room-person-actions button { min-height: 30px; padding: 0 9px; font-size: .78rem; }
.danger-action { border-color: rgba(220, 110, 110, .55); color: #ffd6d6; }
.room-closed-label {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: .84rem;
}

.hand-slider {
  position: relative;
  min-width: 0;
}

.hand-slider::before,
.hand-slider::after {
  position: absolute;
  top: 10px;
  bottom: 6px;
  z-index: 5;
  width: 46px;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s ease;
}

.hand-slider::before {
  content: "<";
  left: 0;
  background: linear-gradient(90deg, var(--bg) 22%, rgba(18, 20, 18, 0));
}

.hand-slider::after {
  content: ">";
  right: 0;
  background: linear-gradient(270deg, var(--bg) 22%, rgba(18, 20, 18, 0));
}

.hand-slider.can-scroll-left::before,
.hand-slider.can-scroll-right::after {
  opacity: .92;
}

.hand {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 12px 0 4px;
  user-select: none;
}

.hand::-webkit-scrollbar {
  display: none;
}

.hand.is-dragging {
  cursor: grabbing;
  scroll-behavior: auto;
}

.hand.is-dragging .card-button {
  pointer-events: none;
}

.card-button {
  flex: 0 0 var(--card-w);
  min-height: auto;
  padding: 0;
  border: 2px solid transparent;
  background: transparent;
  border-radius: 8px;
  position: relative;
  transition: transform .12s ease, border-color .12s ease, filter .12s ease, opacity .12s ease, box-shadow .12s ease;
}

.card-button:hover:not(:disabled),
.card-button:focus-visible:not(:disabled) {
  transform: translateY(-3px);
  z-index: 2;
}

.card-button.is-selected {
  border-color: var(--accent-2);
  transform: translateY(-6px);
  z-index: 3;
  touch-action: none;
  cursor: grab;
}

.card-button.is-lifted {
  opacity: .35;
}

body.is-card-dragging {
  cursor: grabbing;
  -webkit-user-select: none;
  user-select: none;
}

body.is-card-dragging.drag-invalid-cursor {
  cursor: not-allowed;
}

.card-drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 500;
  display: flex;
  pointer-events: none;
  will-change: transform;
}

.card-drag-ghost-card {
  width: var(--card-w);
  margin-left: calc(var(--card-w) * -0.55);
  transform: rotate(calc(var(--i, 0) * 4deg - 4deg));
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .45));
}

.card-drag-ghost-card:first-child {
  margin-left: 0;
}

.card-drag-ghost-count {
  align-self: flex-end;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-2);
  color: var(--bg);
  font-size: .72rem;
  font-weight: 800;
}

.hand.hints-on .card-button.is-dimmed {
  opacity: .34;
  filter: saturate(.55) brightness(.72);
}

.hand.hints-on .card-button.is-playable {
  box-shadow: 0 12px 24px rgba(98, 182, 203, .16);
  filter: brightness(1.16) saturate(1.08);
}

.card-button.is-new-card {
  box-shadow: 0 0 0 2px rgba(98, 182, 203, .24), 0 12px 24px rgba(98, 182, 203, .12);
}

.hand.hints-on .card-button.is-dimmed:hover:not(:disabled),
.hand.hints-on .card-button.is-dimmed:focus-visible:not(:disabled) {
  opacity: .58;
}

.card-button:disabled {
  cursor: not-allowed;
  opacity: 1;
}

.new-card-marker {
  position: absolute;
  left: 50%;
  top: -7px;
  transform: translateX(-50%);
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  padding: 3px 8px;
  font-size: .62rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
  z-index: 3;
}

.turn-actions button.is-ready {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: var(--bg);
  box-shadow: 0 0 0 2px rgba(246, 200, 95, .18), 0 12px 28px rgba(246, 200, 95, .16);
}

.primary-action {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

.discard-action {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--bg);
  font-weight: 700;
}

.discard-action:hover:not(:disabled),
.discard-action:focus-visible {
  border-color: var(--danger);
  filter: brightness(1.08);
}

.discard-action.is-ready {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--bg);
  box-shadow: 0 0 0 2px rgba(231, 111, 81, .18), 0 12px 28px rgba(231, 111, 81, .16);
}

.round-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(10, 10, 9, .68);
}

.round-modal[hidden] {
  display: none;
}

.round-modal-panel {
  width: min(560px, 100%);
  background: rgba(31, 33, 30, .98);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.round-modal-panel h2,
.round-score-card h3 {
  margin: 0;
}

.round-modal-reason {
  margin: 8px 0 14px;
  color: var(--muted);
}

.round-score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.round-score-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.round-score-card dl {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
}

.round-score-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.round-score-card dt {
  color: var(--muted);
}

.round-score-card dd {
  margin: 0;
  font-weight: 700;
}

.round-modal-result {
  margin: 14px 0;
  color: var(--accent-2);
  font-weight: 700;
}

.misty-suit-panel {
  width: min(440px, 100%);
}

.game-summary-table {
  max-height: min(50vh, 360px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.game-summary-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.game-summary-grid th,
.game-summary-grid td {
  padding: 8px 12px;
  text-align: right;
}

.game-summary-grid th:first-child,
.game-summary-grid td:first-child {
  text-align: left;
  color: var(--muted);
}

.game-summary-grid thead th {
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.game-summary-grid tbody tr:not(:last-child) td {
  border-bottom: 1px solid rgba(69, 72, 63, .5);
}

.game-summary-grid tfoot th {
  border-top: 2px solid var(--line);
  color: var(--accent-2);
  font-weight: 700;
}

.game-summary-coaching,
.round-modal-coaching {
  margin: 10px 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(69, 72, 63, .25);
  overflow-y: auto;
}

/* Feedback across every round played so far - the fullest of the coaching boxes, so it gets the most room. */
.game-summary-coaching {
  max-height: min(55vh, 420px);
}

/* Just the round that ended - shorter by nature, but still scrolls if a rough round runs long. */
.round-modal-coaching {
  max-height: min(40vh, 280px);
}

.coaching-headline {
  margin: 0;
  font-weight: 700;
}

.coaching-difficulty-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: .88rem;
}

.coaching-lines {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: .85rem;
  color: var(--muted);
}

.coaching-lines li {
  margin: 4px 0;
}

.guest-join-panel {
  width: min(430px, 100%);
}

.guest-name-field {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: .86rem;
}

.misty-suit-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.misty-suit-option {
  min-height: 46px;
  font-weight: 800;
}

.misty-suit-hearts {
  border-color: #f07a72;
}

.misty-suit-spades {
  border-color: #62b6cb;
}

.misty-suit-diamonds {
  border-color: var(--accent-2);
}

.misty-suit-clubs {
  border-style: dashed;
}

.log-panel {
  padding: 12px;
}

.game-log {
  margin: 0;
  max-height: 150px;
  overflow: auto;
  color: var(--muted);
}

.log-entry {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.log-entry + .log-entry {
  margin-top: 5px;
}

.log-time {
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.text-muted {
  color: var(--muted);
}

.rules-page {
  margin-top: 18px;
  display: grid;
  gap: 14px;
  scroll-margin-top: 18px;
}

.rules-hero,
.rules-section,
.quick-facts article {
  min-width: 0;
  background: rgba(31, 33, 30, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.rules-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  overflow: hidden;
}

.rules-hero h2 {
  margin: 0 0 8px;
  font-size: clamp(1.55rem, 3vw, 2.6rem);
}

.rules-lede {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
}

.rule-card-preview {
  display: flex;
  align-items: center;
  min-width: 210px;
}

.rule-card-preview img {
  width: 82px;
  height: auto;
  border-radius: 7px;
  filter: drop-shadow(0 14px 14px rgba(0, 0, 0, .3));
}

.rule-card-preview img + img {
  margin-left: -36px;
}

.rules-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rules-jump a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 12px;
  text-decoration: none;
}

.rules-jump a:hover,
.rules-jump a:focus-visible {
  border-color: var(--accent);
  color: var(--text);
}

.quick-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.quick-facts article {
  padding: 12px;
}

.quick-facts span {
  display: block;
  color: var(--muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.quick-facts strong {
  display: block;
  margin: 3px 0 6px;
  color: var(--accent-2);
  font-size: 1.3rem;
}

.quick-facts p,
.rules-section p,
.rules-steps {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.rules-layout {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.rules-section {
  padding: 14px;
  scroll-margin-top: 18px;
}

.rules-section .section-heading {
  margin-bottom: 12px;
}

.rules-section h2 {
  font-size: 1.08rem;
}

.rules-section h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: .94rem;
}

.rules-steps {
  padding-left: 22px;
}

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

.rule-note,
.example-line {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.rule-note {
  color: var(--accent-2) !important;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.rule-grid article {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 20, 19, .38);
}

.score-formula {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.score-formula span,
.score-formula strong,
.score-formula b {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
}

.score-formula span,
.score-formula strong {
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 0 11px;
}

.score-formula b {
  color: var(--accent-2);
}

.score-formula strong {
  color: var(--bg);
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.reference-section {
  grid-column: 1 / -1;
}

.reference-table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.reference-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.reference-table th,
.reference-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.reference-table th {
  color: var(--accent-2);
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.reference-table td:first-child {
  width: 34%;
  color: var(--text);
  font-weight: 700;
}

.reference-table td:last-child {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .lobby-hero {
    grid-template-columns: minmax(0, 1fr) minmax(280px, .45fr);
  }

  .lobby-hero h1 {
    font-size: clamp(2.25rem, 4.2vw, 3.8rem);
  }
}

@media (max-width: 900px) {
  .room-lobby {
    grid-template-columns: 1fr;
  }

  .room-lobby-actions {
    justify-content: flex-start;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar-secondary,
  .topbar-actions {
    justify-content: flex-start;
  }

  .topbar-phase {
    justify-self: stretch;
    text-align: left;
  }

  .scoreboard {
    gap: 6px;
  }

  .scoreboard article {
    min-width: 0;
    flex-basis: auto;
  }

  .center-zone {
    grid-template-columns: 104px minmax(0, 1fr);
  }

  .opponent-zone {
    flex-wrap: wrap;
  }

  .hand-main-row {
    grid-template-columns: 1fr;
  }

  .phase-chip {
    text-align: left;
    justify-self: stretch;
  }

  .turn-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .lobby-hero,
  .open-rooms-list {
    grid-template-columns: 1fr;
  }

  .pile {
    width: 116px;
    min-height: 162px;
  }

  .discard-card {
    flex-basis: 116px;
    margin-right: calc(116px * -0.4);
  }

  .rules-hero {
    grid-template-columns: 1fr;
  }

  .rule-card-preview {
    min-width: 0;
  }

  .quick-facts,
  .rules-layout,
  .rule-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px), (orientation: landscape) and (max-height: 500px) {
  :root {
    --card-w: clamp(46px, 14vw, 62px);
  }

  .hand {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    gap: 0;
    padding: 16px 2px 6px;
  }

  .card-button {
    scroll-snap-align: center;
    margin-right: calc(var(--card-w) * -0.45);
  }

  .card-button:last-child {
    margin-right: 0;
  }

  /* Scale the opponent's face-down cards with the same --card-w the rest
     of the table uses, so everything shrinks together as the screen gets
     smaller instead of the opponent row staying desktop-sized. */
  .opponent-hand img {
    width: calc(var(--card-w) * .62);
    height: calc(var(--card-w) * .88);
    margin-right: calc(var(--card-w) * -.33);
  }

  /* Two rows instead of three: secondary controls (group-by, Misty, hints)
     share a compact row, and the two per-turn actions (play/discard) get
     a bigger primary row below. */
  .turn-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-areas:
      "group group misty hints"
      "play play discard discard";
    gap: 6px;
    width: 100%;
  }

  .turn-actions .hand-tool-group {
    grid-area: group;
    margin-bottom: 0;
    min-width: 0;
  }

  .turn-actions .hand-tool-group > span {
    display: none;
  }

  .turn-actions .segmented-control {
    width: 100%;
  }

  .turn-actions .segmented-control button {
    flex: 1 1 0;
  }

  #mistyButton {
    grid-area: misty;
  }

  #playableHintsButton {
    grid-area: hints;
  }

  #playMeldButton {
    grid-area: play;
  }

  #discardButton {
    grid-area: discard;
  }

  .turn-actions > button {
    min-height: 36px;
    padding: 0 6px;
    font-size: .82rem;
  }

  #mistyButton,
  #playableHintsButton {
    padding: 0 3px;
    font-size: .72rem;
    white-space: normal;
    line-height: 1.15;
  }

  #playMeldButton,
  #discardButton {
    min-height: 40px;
    font-size: .88rem;
  }

  .segmented-control button,
  .hint-toggle {
    min-height: 34px;
    padding: 0 8px;
    font-size: .82rem;
  }

  /* The player's own name is redundant on the hand you're holding; keep
     just the held/table point count. */
  .hand-title-block .player-identity {
    display: none;
  }

  .table-area .opponent-zone,
  .table-area .center-zone {
    padding: 8px;
  }

  /* An empty melds box is dead weight on a small screen; it reappears
     once something is actually on the table. */
  .meld-zone:has(#tableMelds > .text-muted) {
    display: none;
  }

  .opponent-zone .player-row {
    margin-bottom: 4px;
  }

  .opponent-zone .player-identity > div {
    display: flex;
    align-items: baseline;
    gap: 6px;
  }

  .opponent-zone .player-identity h2 {
    font-size: .92rem;
  }

  .opponent-zone .player-identity p {
    font-size: .8rem;
  }

  .phase-chip-help {
    display: none;
  }

  /* Collapse the topbar to a single row: a menu handle plus the turn
     indicator. Everything else (score, room, host controls, rules,
     account, surrender) lives in the off-canvas drawer. */
  .topbar {
    grid-template-columns: auto 1fr;
    gap: 8px;
  }

  .drawer-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    order: 0;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-2);
    cursor: pointer;
  }

  .drawer-handle::before {
    content: "\2630";
    font-size: 1.05rem;
    color: var(--text);
  }

  .drawer-toggle:checked ~ .drawer-handle::before {
    content: "\2715";
  }

  .topbar-phase {
    order: 1;
  }

  .mobile-drawer-panel {
    display: none;
    flex-direction: column;
    gap: 14px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 320px);
    z-index: 300;
    padding: 16px;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow);
  }

  .drawer-toggle:checked ~ .mobile-drawer-panel {
    display: flex;
  }

  .drawer-toggle:checked ~ .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 290;
    background: rgba(0, 0, 0, .55);
    cursor: default;
  }
}

@media (max-width: 560px) {
  #app {
    padding: 10px;
  }

  .hand-zone {
    padding: 9px 0 10px;
  }

  .lobby-app {
    padding: 14px 10px;
  }

  .lobby-nav {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 18px;
  }

  .lobby-nav-actions,
  .lobby-actions {
    align-items: stretch;
  }

  .lobby-nav-actions > *,
  .lobby-actions > * {
    flex: 1 1 140px;
  }

  .lobby-hero {
    min-height: 0;
  }

  .lobby-table-preview {
    order: -1;
  }

  .open-tables-heading,
  .open-room-card {
    align-items: stretch;
    flex-direction: column;
  }

  .open-room-card .compact-action {
    width: 100%;
  }

  .preview-felt {
    max-width: 360px;
  }

  .scoreboard {
    gap: 8px;
  }

  .scoreboard article {
    flex: 1 1 100px;
    min-width: 96px;
  }

  .center-zone {
    grid-template-columns: calc(var(--card-w) + 14px) minmax(0, 1fr);
    gap: 8px;
  }

  .pile {
    width: calc(var(--card-w) + 14px);
    min-height: calc((var(--card-w) + 14px) * 1.4);
  }

  .discard-card {
    flex-basis: calc(var(--card-w) + 14px);
    margin-right: calc((var(--card-w) + 14px) * -0.4);
  }

  .round-score-grid {
    grid-template-columns: 1fr;
  }

  .rules-hero,
  .rules-section {
    padding: 12px;
  }

  .rule-card-preview img {
    width: 70px;
  }

  .rules-jump a {
    flex: 1 1 120px;
    justify-content: center;
  }
}

/* Multiplayer table polish */
.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 6px;
  min-width: min(100%, 400px);
}

.scoreboard article {
  min-width: 0;
  flex: none;
  display: grid;
  gap: 2px;
  padding: 7px 9px;
  border-top: 2px solid var(--line);
}

.scoreboard .stat-player {
  border-top-color: var(--player-color, var(--accent));
}

.scoreboard .stat-opponent {
  border-top-color: var(--player-color, var(--accent-2));
}

.scoreboard .stat-currency {
  border-top-color: #b887d8;
}

.scoreboard span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scoreboard strong {
  font-size: 1.15rem;
  line-height: 1;
}

.host-menu {
  position: relative;
}

.host-menu[hidden] {
  display: none;
}

.host-menu > summary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.host-menu > summary::-webkit-details-marker {
  display: none;
}

.host-menu > summary::after {
  content: "⌄";
  margin-left: 7px;
  color: var(--accent-2);
}

.host-menu[open] > summary,
.host-menu > summary:hover,
.host-menu > summary:focus-visible {
  border-color: var(--accent);
}

.host-menu[open] > summary::after {
  content: "⌃";
}

.host-controls,
.more-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 270px;
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(31, 33, 30, .98);
  box-shadow: var(--shadow);
}

.host-controls .mode-control {
  gap: 5px;
}

.host-controls .room-code {
  max-width: none;
  margin-top: 4px;
}

.topbar-actions {
  align-items: center;
}

.topbar-actions #newGameButton {
  border-color: rgba(231, 111, 81, .55);
}

.player-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.player-identity > div {
  min-width: 0;
}

.player-identity h2 {
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat-marker {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .07);
}

.seat-human .seat-marker {
  background: var(--player-color, var(--accent));
}

.seat-opponent .seat-marker {
  background: var(--player-color, var(--accent-2));
}

.opponent-zone,
.center-zone {
  padding: 10px;
  border: 1px solid rgba(69, 72, 63, .72);
  border-radius: 10px;
  background: rgba(31, 33, 30, .38);
}

.log-panel {
  overflow: hidden;
}

.log-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  color: var(--text);
  font-weight: 800;
}

.log-panel > summary::-webkit-details-marker {
  display: none;
}

.log-panel > summary::before {
  content: "＋";
  color: var(--accent-2);
  font-size: 1.1rem;
}

.log-panel[open] > summary::before {
  content: "－";
}

.log-summary-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 500;
}

.log-panel[open] > summary {
  margin-bottom: 10px;
}

@media (max-width: 900px) {
  .scoreboard {
    min-width: 0;
  }

  .host-controls,
  .more-menu-panel {
    right: auto;
    left: 0;
  }
}

@media (max-width: 560px) {
  .scoreboard {
    grid-template-columns: repeat(2, minmax(96px, 1fr));
  }

  .scoreboard .stat-tally {
    display: none;
  }

  .log-summary-hint {
    display: none;
  }
}

.card-flight-layer {
  position: fixed;
  inset: 0;
  z-index: 120;
  pointer-events: none;
}

.card-flight {
  position: absolute;
  width: 48px;
  height: 68px;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 12px rgba(0, 0, 0, .34);
  will-change: transform, opacity;
  animation: opponent-card-flight .62s cubic-bezier(.2, .8, .2, 1) both;
}

.card-flight-meld {
  box-shadow: 0 8px 12px rgba(98, 182, 203, .28);
}

.card-flight-discard {
  box-shadow: 0 8px 12px rgba(246, 200, 95, .30);
  animation-name: opponent-discard-flight;
}

@keyframes opponent-card-flight {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(.72) rotate(-8deg);
  }

  16% {
    opacity: 1;
  }

  72% {
    opacity: 1;
    transform: translate3d(calc(var(--flight-x) * .82), calc(var(--flight-y) * .82 - 18px), 0) scale(.96) rotate(3deg);
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--flight-x), var(--flight-y), 0) scale(.88) rotate(0);
  }
}

@keyframes opponent-discard-flight {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(.72) rotate(7deg);
  }

  18% {
    opacity: 1;
  }

  74% {
    opacity: 1;
    transform: translate3d(calc(var(--flight-x) * .82), calc(var(--flight-y) * .82 - 10px), 0) scale(.98) rotate(-4deg);
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--flight-x), var(--flight-y), 0) scale(.9) rotate(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-flight {
    animation-duration: .01ms;
    animation-delay: 0ms !important;
  }
}

/* Accounts: nav, auth pages, account page */
.account-nav-link,
.account-nav-button {
  white-space: nowrap;
}

.lobby-nav-actions .account-nav-user {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent-2);
}

.lobby-nav-actions .account-nav-button {
  min-height: 42px;
}

.topbar-actions .account-nav-user {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--accent-2);
}

.auth-main {
  justify-items: center;
}

.auth-card {
  width: min(480px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(31, 33, 30, .86);
  box-shadow: var(--shadow);
  padding: 22px;
}

.auth-card-wide {
  width: min(960px, 100%);
}

.auth-card h1 {
  margin: 0 0 10px;
  font-size: clamp(1.7rem, 3vw, 2.3rem);
}

.auth-card h2 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

.auth-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--accent-2);
}

.auth-note {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  margin: 14px 0;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: .9rem;
}

.auth-links a,
.auth-card a:not(.primary-action):not(.secondary-action) {
  color: var(--accent);
}

.auth-link-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 14px;
  text-decoration: none;
  color: var(--bg);
}

.auth-link-button[hidden],
.auth-restore[hidden],
.account-verify[hidden] {
  display: none;
}

.auth-restore {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
}

.auth-restore p {
  margin: 0;
}

.feedback-message.is-error {
  border-color: var(--danger);
  background: rgba(231, 111, 81, .14);
}

.feedback-message.is-success {
  border-color: var(--ok);
  background: rgba(155, 197, 61, .14);
}

.flash-banner {
  width: min(960px, 100%);
  justify-self: center;
}

.field-error {
  color: #ffb4a3;
  font-size: .8rem;
}

input[aria-invalid="true"] {
  border-color: var(--danger);
}

.rule-hints {
  margin: -2px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: .8rem;
}

.rule-hints li::before {
  content: "\2022";
  display: inline-block;
  width: 1.1em;
}

.rule-hints li.is-ok {
  color: var(--ok);
}

.rule-hints li.is-ok::before {
  content: "\2713";
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 14px;
  margin: 14px 0;
}

.account-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 20, 19, .4);
  padding: 14px;
  margin-top: 14px;
}

.account-grid > .account-section {
  margin-top: 0;
}

.account-danger {
  border-color: rgba(231, 111, 81, .5);
}

.account-facts {
  display: grid;
  gap: 6px;
  margin: 0;
}

.account-facts > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  padding-bottom: 5px;
}

.account-facts dt {
  color: var(--muted);
}

.account-facts dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.account-verify {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid var(--accent-2);
  border-radius: 8px;
  background: rgba(246, 200, 95, .1);
  padding: 10px;
}

.account-verify p {
  margin: 0;
}

.account-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}

.stats-block[hidden] {
  display: none;
}

.sign-in-notice {
  margin: 0;
}

@media (max-width: 640px) {
  .lobby-nav {
    flex-wrap: wrap;
  }

  .auth-card {
    padding: 16px;
  }
}

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

.secondary-action[hidden],
.primary-action[hidden] {
  display: none;
}

/* Game modes (2026-10-12e) */
.lobby-auth-actions { margin-bottom: 12px; }
.lobby-calicoins { color: var(--muted); font-weight: 600; }
.mode-hint { margin: 0; color: var(--muted); font-size: .85rem; }
.mode-hint:empty { display: none; }
.host-controls #copyInviteButton { margin-top: 6px; }
.stat-pill-flag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: rgba(231, 111, 81, .85); color: #fff; font-weight: 700; font-size: .78rem; }
.admin-flag-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 10px; }
.admin-flag-item { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 4px; justify-items: start; }

a.primary-action {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 14px;
  text-decoration: none;
}

a.primary-action.lobby-primary {
  min-height: 50px;
  padding: 0 20px;
}

[hidden] {
  display: none !important;
}

/* Signed-in user menu */
.user-menu {
  position: relative;
  display: inline-block;
}

.user-menu > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  max-width: 200px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--accent-2);
  font-weight: 600;
}

.user-menu.user-menu-compact > summary {
  min-height: 34px;
  padding: 0 11px;
}

.more-menu-panel .user-menu {
  display: block;
  width: 100%;
}

.more-menu-panel .user-menu > summary {
  width: 100%;
  max-width: none;
  justify-content: center;
}

.user-menu > summary::-webkit-details-marker {
  display: none;
}

.user-menu > summary:hover,
.user-menu > summary:focus-visible,
.user-menu[open] > summary {
  border-color: var(--accent);
}

.user-menu-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-caret {
  font-size: .75em;
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  width: min(320px, 92vw);
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.user-menu-head {
  display: grid;
  gap: 2px;
  padding: 6px 8px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.user-menu-head small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.user-menu-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.user-menu-title strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-coins {
  color: var(--accent-2);
  font-weight: 700;
  white-space: nowrap;
}

.user-menu .user-menu-item {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 9px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.user-menu .user-menu-item:hover,
.user-menu .user-menu-item:focus-visible {
  background: rgba(255, 255, 255, .07);
}

.user-menu .user-menu-logout {
  color: var(--danger);
}

/* Player stats sheet (/stats) */
.stats-page {
  display: grid;
  gap: 16px;
  align-content: start;
  padding-top: 16px;
}

.stats-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.stats-heading h1 {
  margin: 0;
}

.stats-filter input {
  min-height: 42px;
  width: min(240px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 12px;
}

.stats-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.stats-views button {
  min-height: 36px;
  padding: 0 12px;
}

.stats-summary {
  flex: 1 1 260px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
}

.stats-summary strong {
  color: var(--text);
}

/* Leaderboard table */
.stats-sheet {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(40, 43, 39, .92), rgba(26, 28, 25, .94));
  box-shadow: 0 14px 36px rgba(0, 0, 0, .28);
}

.stats-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .96rem;
}

.stats-caption {
  padding: 14px 20px;
  color: var(--muted);
  font-size: .84rem;
  text-align: left;
}

.stats-table th,
.stats-table td {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, .06);
  background-image: linear-gradient(var(--row-tint, transparent), var(--row-tint, transparent));
  text-align: right;
  white-space: nowrap;
}

.stats-table thead th {
  --row-tint: rgba(255, 255, 255, .035);
  border-top-color: rgba(255, 255, 255, .1);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.stats-table tbody tr:nth-child(even) { --row-tint: rgba(255, 255, 255, .025); }
.stats-table tbody tr:hover { --row-tint: rgba(255, 255, 255, .075); }
.stats-table tbody tr.is-leader { --row-tint: rgba(246, 200, 95, .085); }
.stats-table tbody tr.is-leader:hover { --row-tint: rgba(246, 200, 95, .14); }

.stats-table .stats-rank-col {
  width: 56px;
  min-width: 56px;
  padding-right: 4px;
  text-align: center;
}

.stats-table .stats-player-col {
  min-width: 160px;
  text-align: left;
}

/* Only the wide "All" view scrolls sideways, so only there are the rank and player columns pinned. */
.stats-sheet.is-scrolling .stats-rank-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background-color: var(--surface);
}

.stats-sheet.is-scrolling .stats-player-col {
  position: sticky;
  left: 56px;
  z-index: 1;
  background-color: var(--surface);
}

.stats-table td.stats-number {
  font-variant-numeric: tabular-nums;
}

.stats-table td.is-sorted {
  background-color: rgba(246, 200, 95, .06);
  color: var(--accent-2);
  font-weight: 700;
}

.stats-table td.is-zero {
  color: var(--muted);
  font-weight: 400;
}

.stats-table td.is-positive { color: #7bdc9a; }
.stats-table td.is-negative { color: #ff9b8f; }

.stats-medal {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.stats-medal.medal-1 { background: #f6c85f; color: #2a2208; }
.stats-medal.medal-2 { background: #cfd3da; color: #23262b; }
.stats-medal.medal-3 { background: #cd8b5a; color: #2b1809; }

.stats-player-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stats-avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: hsl(var(--avatar-hue, 200) 55% 36%);
  box-shadow: inset 0 0 0 2px hsl(var(--avatar-hue, 200) 60% 58% / .55);
  color: #fff;
  font-size: .9rem;
  font-weight: 800;
}

.stats-table .stats-player-link {
  font-size: 1.02rem;
  font-weight: 700;
}

.stats-rate {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.stats-rate > span:last-child {
  min-width: 3.6em;
}

.stats-bar {
  width: 84px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
}

.stats-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.stats-table .stats-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 0;
  padding: 2px 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.stats-table .stats-sort:hover,
.stats-table .stats-sort:focus-visible,
.stats-table th[aria-sort="ascending"] .stats-sort,
.stats-table th[aria-sort="descending"] .stats-sort {
  color: var(--accent-2);
}

.stats-sort-arrow {
  display: inline-block;
  min-width: 1em;
  font-size: .7em;
}

.stats-label-short {
  display: none;
}

.stats-filter input {
  min-height: 36px;
}

@media (max-width: 700px) {
  .stats-label-full {
    display: none;
  }

  .stats-label-short {
    display: inline;
  }

  .stats-table {
    font-size: .8rem;
  }

  .stats-table th,
  .stats-table td {
    padding: 10px 5px;
  }

  .stats-table .stats-rank-col {
    width: 34px;
    min-width: 34px;
    padding: 10px 2px;
  }

  .stats-sheet.is-scrolling .stats-player-col {
    left: 34px;
  }

  .stats-table .stats-player-col {
    min-width: 0;
    max-width: 92px;
    padding-left: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stats-medal {
    width: 24px;
    height: 24px;
    font-size: .72rem;
  }

  .stats-avatar,
  .stats-bar {
    display: none;
  }

  .stats-table .stats-player-link {
    font-size: .9rem;
  }

  .stats-table .stats-sort {
    padding: 2px 0;
    white-space: normal;
    text-align: center;
    line-height: 1.15;
  }

  .stats-table thead th {
    vertical-align: bottom;
  }

  .stats-caption {
    display: none;
  }

  .stats-views {
    flex-wrap: wrap;
  }

  .stats-filter {
    flex: 1 1 140px;
  }

  .stats-filter input {
    width: 100%;
  }
}

/* Player stats: card layout */
.stats-card {
  display: grid;
  gap: 14px;
  padding: 16px 18px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(31, 33, 30, .78);
}

.stats-card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.stats-card-name {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.35rem;
}

.stats-headline {
  display: grid;
  justify-items: end;
  line-height: 1.15;
  text-align: right;
}

.stats-headline strong {
  color: var(--accent-2);
  font-size: 1.6rem;
}

.stats-headline span {
  color: var(--muted);
  font-size: .78rem;
}

.stats-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 26px;
}

.stats-group h3 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.stats-group dl {
  display: grid;
  gap: 2px;
  margin: 0;
}

.stats-metric {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 6px;
}

.stats-metric dt {
  color: var(--muted);
  font-size: .86rem;
}

.stats-metric dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.stats-metric.is-sorted {
  background: rgba(246, 200, 95, .1);
}

.stats-metric.is-sorted dt {
  color: var(--text);
}

.stats-metric.is-sorted dd {
  color: var(--accent-2);
}

@media (max-width: 700px) {
  .stats-card {
    padding: 14px;
  }

  .stats-metric dt {
    font-size: .8rem;
  }

}

/* Player stats: links and the single-player page */
.stats-player-link {
  color: inherit;
  text-decoration: none;
}

.stats-player-link:hover,
.stats-player-link:focus-visible {
  color: var(--accent-2);
  text-decoration: underline;
}

.stats-player {
  display: grid;
  gap: 18px;
}

.stats-player-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
}

.stats-back {
  flex: 1 1 100%;
  color: var(--accent);
  font-size: .9rem;
  text-decoration: none;
}

.stats-back:hover,
.stats-back:focus-visible {
  text-decoration: underline;
}

.stats-player-name {
  margin: 0;
  font-size: 2rem;
}

.stats-player-since {
  margin: 0;
  color: var(--muted);
}

.stats-player-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 16px;
  align-items: start;
}

.stats-card-head.no-rank {
  grid-template-columns: minmax(0, 1fr) auto;
}

.stats-empty {
  margin: 0;
  color: var(--muted);
}

.stats-recent {
  display: grid;
  gap: 8px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(31, 33, 30, .78);
}

.stats-recent h3 {
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.stats-recent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.stats-recent-table th,
.stats-recent-table td {
  padding: 7px 10px 7px 0;
  border-top: 1px solid rgba(255, 255, 255, .07);
  text-align: left;
  white-space: nowrap;
}

.stats-recent-table thead th {
  border-top: 0;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}

.stats-result-win {
  color: #7bdc9a;
  font-weight: 700;
}

.stats-result-loss {
  color: #ff9b8f;
  font-weight: 700;
}

.stats-result-abandoned {
  color: var(--muted);
}

.stats-card-head.has-badge {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.stats-difficulty-badge {
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .08);
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
}

.stats-recent-row {
  cursor: pointer;
}

.stats-recent-row:hover,
.stats-recent-row:focus-visible {
  background: rgba(255, 255, 255, .04);
  outline: none;
}

.stats-recent-row td:first-child::before {
  display: inline-block;
  width: 1em;
  margin-right: 4px;
  color: var(--muted);
  content: "\25b8";
  transition: transform .12s ease;
}

.stats-recent-row[aria-expanded="true"] td:first-child::before {
  transform: rotate(90deg);
}

.stats-recent-detail-row td {
  padding: 0;
  border-top: none;
}

.stats-recent-detail {
  padding: 4px 0 16px 22px;
}

.stats-rounds {
  display: inline-block;
  min-width: 260px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, .18);
}

.stats-rounds-table {
  border-collapse: collapse;
  font-size: .85rem;
}

.stats-rounds-table th,
.stats-rounds-table td {
  padding: 7px 18px;
  text-align: right;
  white-space: nowrap;
}

.stats-rounds-table th:first-child,
.stats-rounds-table td:first-child {
  text-align: left;
  color: var(--muted);
}

.stats-rounds-table thead th {
  background: rgba(255, 255, 255, .05);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--line);
}

.stats-rounds-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.stats-rounds-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, .025);
}

.stats-rounds-score-col {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

@media (max-width: 700px) {
  .stats-player-name {
    font-size: 1.6rem;
  }

  .stats-recent {
    padding: 12px;
    overflow-x: auto;
  }

  .stats-recent-table {
    font-size: .8rem;
  }

  .stats-recent-table th,
  .stats-recent-table td {
    padding-right: 6px;
  }
}


/* ==== 2026-11-09 compact phone layout ====
   Portrait: trim dead space. Landscape phones (short viewport) previously got the full
   desktop layout; they now use the phone rules above plus a two-column table. */
.round-modal {
  overflow-y: auto;
  align-items: safe center;
  overscroll-behavior: contain;
}

@media (max-width: 700px) {
  /* Plenty of vertical room once the dead space is gone: larger, more legible cards. */
  :root { --card-w: clamp(52px, 17vw, 72px); }
  #app { padding: 8px; }
  .topbar { margin-bottom: 4px; }
  .table-area { gap: 6px; }
  .hand-zone { padding: 4px 0 6px; }
  .hand-zone .section-heading { margin-bottom: 2px; }
  .hand-title-block p { font-size: .82rem; }
  .hand { padding-top: 12px; }

  .center-zone { padding: 6px; gap: 6px; }
  .discard-pile { min-height: 0; padding-bottom: 10px; }
  .pile { padding: 3px; }
  .deck-pile span { right: 3px; bottom: 3px; min-width: 0; padding: 1px 5px; font-size: .7rem; }
  .discard-cue { font-size: .54rem; padding: 2px 5px; bottom: -6px; }
  .discard-index { font-size: .6rem; padding: 1px 4px; left: 3px; bottom: 3px; }
  .discard-card { padding: 3px; }

  /* Opponent: name/count and face-down cards share one row. */
  .opponent-zone { padding: 6px 8px; gap: 10px; flex-wrap: nowrap; align-items: center; }
  .opponent-zone .player-row { min-width: 0; flex: 0 0 auto; }
  .opponent-zone .player-identity > div { display: block; }
  .opponent-hand { min-width: 0; overflow: hidden; }

  .log-panel { padding: 0; }
  .log-panel > summary { padding: 8px 12px; min-height: 0; font-size: .9rem; }
  .card-button { margin-right: calc(var(--card-w) * -0.38); }
  .opponent-hand img { margin-right: calc(var(--card-w) * -.42); }
}

@media (orientation: landscape) and (max-height: 500px) {
  #app { padding: 4px 8px; }
  :root { --card-w: clamp(44px, 15vh, 62px); }
  .pile { width: calc(var(--card-w) + 10px); min-height: 0; }
  .center-zone { grid-template-columns: calc(var(--card-w) + 10px) minmax(0, 1fr); padding: 4px 6px; gap: 6px; }
  .discard-pile { min-height: 0; padding-bottom: 8px; }
  .discard-card { flex-basis: calc(var(--card-w) + 8px); margin-right: calc((var(--card-w) + 8px) * -0.4); padding: 3px; }
  .opponent-zone { padding: 4px 8px; gap: 8px; flex-wrap: nowrap; }
  .opponent-zone .player-row { min-width: 0; }
  .opponent-zone .player-identity > div { display: block; }
  .opponent-hand { min-width: 0; overflow: hidden; }
  .turn-actions > button, .segmented-control button { min-height: 32px; }
  .table-area {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 4px 10px;
    align-items: start;
  }
  .hand-zone { grid-column: 1; grid-row: 1 / span 3; }
  .center-zone { grid-column: 2; grid-row: 1; }
  .meld-zone { grid-column: 2; grid-row: 2; }
  .opponent-zone { grid-column: 2; grid-row: 3; }
  .turn-actions { grid-template-columns: repeat(4, 1fr); }
  .topbar-phase { padding: 0; }
  .round-modal { padding: 8px; }
  .round-modal-panel { padding: 12px; }
  .log-panel { margin-top: 4px; }
}

