/* Ranked play in the house's own hand: blue ink on paper, a red 战 seal, panels like the home
   page's, and the seats as the table's own avatar discs. */
.mm-seal { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 4px; rotate: -4deg; font: 24px/1 var(--ink-font); color: var(--on-seal); background: var(--seal); box-shadow: inset 0 0 0 1.5px var(--seal), inset 0 0 0 3px var(--on-seal); }
.mm-seal.ink { color: var(--paper); background: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink), inset 0 0 0 3px var(--paper); }
/* On the home page, where a game with no ranked queue would offer the search. */
.home .home-panel .mm-casual { display: grid; place-items: center; min-height: 48px; padding: 8px 12px; border-radius: var(--radius-control); background: color-mix(in srgb, var(--ink) 6%, transparent); font-size: var(--text-caption); line-height: 1.45; text-align: center; text-wrap: balance; }
/* A party with a friend, in the same card: the code to send in large letters beside its link,
   then the two partners side by side once both are in. */
.home-actions > .mm-party-start { width: 100%; min-height: 44px; }
.home .home-panel .mm-party-code { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 4px 4px 4px 14px; border-radius: var(--radius-control); box-shadow: inset 0 0 0 1px var(--line); }
.mm-party-code strong { min-width: 0; font: 700 24px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.16em; color: var(--ink); user-select: all; -webkit-user-select: all; }
.mm-party-code button { flex: none; }
.home .home-panel .mm-party-status { font-size: var(--text-caption); line-height: 1.4; color: var(--ink-soft); text-align: right; }
.home .home-panel p.mm-party-status { text-align: center; }
.mm-party-members { display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 0; min-height: 44px; }
.mm-party-member { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--text-label); font-weight: 700; color: var(--ink); }
.mm-party-member .disc { flex: none; width: 36px; height: 36px; }
.mm-party-member b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm-party-member.away { opacity: 0.45; }
.mm-party-and { flex: none; font-size: var(--text-label); font-weight: 700; color: var(--ink-soft); }
.home .home-panel p.mm-party-status:empty { display: none; }
/* A friend's code is typed in capitals, spaced like a room code; its hint reads as words. */
#mm-party-code::placeholder { letter-spacing: 0.02em; text-transform: none; }
/* A short screen keeps the code, the field and the way out, and lets the note go. */
@media (max-height: 640px) { .home .home-panel .mm-party-note { display: none; } }
/* A phone on its side has the least height: the party's rows sit a little closer and lower,
   so its card is no taller than the others'. */
html[data-layout="phone-landscape"] .home-panel .home-actions:has(.mm-party-start, .mm-party-code) { gap: 6px; }
html[data-layout="phone-landscape"] .home-actions > .mm-party-start { min-height: 40px; }
html[data-layout="phone-landscape"] .home .home-panel .mm-party-code { min-height: 44px; padding-block: 2px; }
html[data-layout="phone-landscape"] .home-panel .home-join:has(#mm-party-code) :is(input, button) { min-height: 40px; }
html[data-layout="phone-landscape"] .home-panel .home-sub:has(.mm-party-status) { min-height: 40px; }
html[data-layout="phone-landscape"] .mm-party-members { min-height: 36px; }

/* ---------- the queue ---------- */
.mm-queue {
  display: flex; flex-direction: column; min-height: 100%; width: min(100%, 1080px); margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top, 0px)) max(28px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(28px, env(safe-area-inset-left, 0px));
}
.mm-queue-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.mm-wordmark { font-size: 28px; font-weight: 900; line-height: 1; letter-spacing: 0.02em; }
.mm-queue-kind { min-width: 0; font-size: var(--text-caption); font-weight: 600; color: var(--ink-soft); text-align: right; }
.mm-queue-body { flex: 1 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); align-items: center; align-content: center; gap: 24px 56px; padding: 20px 0; }
.mm-queue-stage { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.mm-queue-title { display: flex; align-items: center; gap: 12px; }
.mm-queue h1 { margin: 0; font-size: clamp(22px, 2.6vw, 34px); line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; }
.mm-intro { margin: 0; max-width: 46ch; font-size: var(--text-label); line-height: 1.5; color: var(--ink-soft); }

/* The table: a plain surface with the clock where the pile would be. Your disc sits at the near
   edge; the other seats are dashed rings while open, face-down discs once reserved. */
.mm-table { --seat: 56px; --side: 104px; --near: 96px; position: relative; width: 100%; max-width: 540px; height: 280px; margin: 16px auto 0; }
.mm-table-4 { height: 350px; }
.mm-surface { position: absolute; inset: 12px var(--side) var(--near); display: grid; place-items: center; padding: 8px; border-radius: 999px; background: color-mix(in srgb, var(--panel) 60%, transparent); box-shadow: inset 0 0 0 1px var(--line); }
.mm-table-4 .mm-surface { top: var(--near); }
.mm-clock { margin: 0; font-size: var(--text-body); font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; text-align: center; color: var(--ink); }
.mm-table-ready .mm-clock { font-size: var(--text-heading); }
.mm-clock.urgent { color: var(--alert); }
.mm-seat { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 5px; width: var(--side); text-align: center; }
.mm-seat-bottom, .mm-seat-top { left: 50%; width: 180px; translate: -50% 0; }
.mm-seat-bottom { bottom: 0; }
.mm-seat-top { top: 0; }
/* The side seats' discs sit level with the middle of the surface. */
.mm-seat-left, .mm-seat-right { top: calc((100% + 12px - var(--near)) / 2 - var(--seat) / 2); }
.mm-table-4 :is(.mm-seat-left, .mm-seat-right) { top: calc(50% - var(--seat) / 2); }
.mm-seat-left { left: 0; }
.mm-seat-right { right: 0; }
.mm-token { position: relative; display: block; flex: none; width: var(--seat); height: var(--seat); border-radius: 50%; }
.mm-token .disc { display: block; width: 100%; height: 100%; }
.mm-token.mm-open { border: 2px dashed var(--ink-faint); animation: mm-turn 16s linear infinite; }
.mm-token.mm-reserved {
  background: repeating-linear-gradient(45deg, rgba(246, 241, 222, 0.16) 0 1px, transparent 1px 5px), repeating-linear-gradient(-45deg, rgba(246, 241, 222, 0.16) 0 1px, transparent 1px 5px), var(--back);
  box-shadow: 0 0 0 1.5px var(--ink);
}
@keyframes mm-turn { to { rotate: 1turn; } }
.mm-seat-label { max-width: 100%; font-size: var(--text-caption); font-weight: 600; line-height: 1.25; color: var(--ink-soft); overflow-wrap: anywhere; }
.mm-self .mm-seat-label { font-size: var(--text-label); font-weight: 700; color: var(--ink); }
.mm-mate .mm-seat-label { font-weight: 700; color: var(--ink); }
.mm-table-ready .mm-seat-label { color: var(--ink); }

/* What you can do while it is found: a panel like the home page's. */
.mm-queue-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.mm-queue-slip { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; border-radius: var(--radius-panel); background: var(--panel); box-shadow: 0 0 0 1px var(--line), 0 14px 32px -20px rgba(31, 59, 143, 0.45); }
.mm-live { margin: 0; font-size: var(--text-label); font-weight: 700; line-height: 1.4; }
.mm-queue-ready .mm-live { font-size: var(--text-heading); font-variant-numeric: tabular-nums; }
.mm-search-limit, .mm-search-note { margin: 0; font-size: var(--text-caption); line-height: 1.5; color: var(--ink-soft); }
.mm-search-controls:not([hidden]) { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.mm-queue-slip button { width: 100%; white-space: normal; }
.mm-queue-slip button.primary { min-height: 48px; }
.mm-waiting { margin: 0; font-size: var(--text-caption); line-height: 1.4; color: var(--ink-soft); text-align: center; }
.mm-waiting:empty { display: none; }
.mm-rules { margin: 0; padding-inline: 8px; font-size: var(--text-caption); line-height: 1.5; color: var(--ink-soft); text-align: center; }

/* Upright or narrow: one column, the panel held low where the thumb is. */
@media (max-width: 760px) {
  .mm-queue-body { display: flex; flex-direction: column; align-items: stretch; gap: 16px; padding: 16px 0 0; }
  .mm-queue-stage, .mm-queue-side { width: min(100%, 460px); margin-inline: auto; }
  .mm-queue-stage { flex: 1 0 auto; }
  .mm-queue .mm-table { margin-block: auto; }
}
@media (orientation: portrait) {
  html[data-layout="wide"] .mm-queue-body { display: flex; flex-direction: column; align-items: stretch; gap: 24px; }
  html[data-layout="wide"] :is(.mm-queue-stage, .mm-queue-side) { width: min(100%, 460px); margin-inline: auto; }
}
html[data-layout="phone-portrait"] .mm-queue { padding: max(10px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)); }
html[data-layout="phone-portrait"] .mm-table { --seat: 48px; --side: 76px; --near: 84px; height: 228px; }
html[data-layout="phone-portrait"] .mm-table-4 { height: 300px; }
html[data-layout="phone-portrait"] .mm-queue-slip { padding: 14px 16px; }
@media (max-width: 360px) {
  .mm-queue h1 { font-size: 20px; }
  html[data-layout="phone-portrait"] .mm-table { --side: 72px; }
  .mm-table-ready .mm-clock { font-size: var(--text-body); }
}
/* A short upright screen (an SE): a smaller table, so the buttons stay in view. */
@media (max-height: 640px) and (orientation: portrait) {
  .mm-queue .mm-seal { width: 32px; height: 32px; font-size: 19px; }
  .mm-queue-body { gap: 12px; padding-top: 8px; }
  .mm-queue-stage { gap: 8px; }
  .mm-intro { font-size: var(--text-caption); }
  html[data-layout="phone-portrait"] .mm-table { --seat: 40px; --near: 70px; height: 184px; }
  html[data-layout="phone-portrait"] .mm-table-4 { height: 236px; }
  .mm-queue-slip { gap: 8px; }
}
/* A phone on its side: the table on the left, the panel on the right. */
html[data-layout="phone-landscape"] .mm-queue { padding: max(6px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
html[data-layout="phone-landscape"] .mm-queue-header { min-height: 36px; }
html[data-layout="phone-landscape"] .mm-wordmark { font-size: 22px; }
html[data-layout="phone-landscape"] .mm-queue-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 12px 24px; padding: 4px 0 0; }
html[data-layout="phone-landscape"] .mm-queue-stage { gap: 6px; }
html[data-layout="phone-landscape"] .mm-queue .mm-seal { width: 32px; height: 32px; font-size: 19px; }
html[data-layout="phone-landscape"] .mm-queue h1 { font-size: 20px; }
html[data-layout="phone-landscape"] .mm-intro { font-size: var(--text-caption); }
html[data-layout="phone-landscape"] .mm-table { --seat: 40px; --side: 84px; --near: 66px; max-width: 460px; height: 196px; margin-top: 4px; }
html[data-layout="phone-landscape"] .mm-table-4 { height: 226px; }
html[data-layout="phone-landscape"] .mm-queue-side { gap: 8px; }
html[data-layout="phone-landscape"] .mm-queue-slip { gap: 8px; padding: 12px 14px; }

/* ---------- sign in, the scorebook and the leaderboard ---------- */
.mm-overlay { position: fixed; z-index: 500; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; background: var(--scrim); }
.mm-dialog { width: min(100%, 440px); max-height: calc(100dvh - 40px); overflow-y: auto; overscroll-behavior: contain; padding: 20px 24px 24px; border-radius: var(--radius-dialog); background: var(--panel); box-shadow: var(--shadow-dialog); text-align: left; }
.mm-dialog-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.mm-dialog-head h2 { flex: 1; min-width: 0; margin: 0; font-size: 21px; line-height: 1.2; font-weight: 800; }
.mm-dialog-head [data-mm="close"] { flex: none; margin-right: -12px; }
.mm-dialog-note { margin: 0; font-size: var(--text-label); line-height: 1.5; color: var(--ink-soft); }
.mm-dialog > p:not([class]) { margin: 12px 0; font-size: var(--text-label); line-height: 1.5; color: var(--ink-soft); }
.mm-dialog form { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.mm-dialog label { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; font-size: var(--text-caption); font-weight: 600; color: var(--ink-soft); }
.mm-dialog input { min-height: 44px; font-size: 18px; font-weight: 700; color: var(--ink); }
.mm-dialog form small { font-size: var(--text-caption); line-height: 1.4; color: var(--ink-soft); }
.mm-dialog .mm-form-error { min-height: 20px; margin: 8px 0 4px; font-size: var(--text-caption); font-weight: 600; line-height: 1.4; color: var(--alert); }
.mm-dialog form .primary { width: 100%; min-height: 48px; }
.mm-dialog button { min-height: var(--control-height); white-space: normal; }
.mm-dialog form ~ button { width: 100%; }
.mm-dialog form + button { margin-top: 8px; }
/* The scorebook: you, a rating for each table size in big numerals, then the games as rows. */
.mm-profile-name { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; font-size: var(--text-heading); }
.mm-profile-name .disc { flex: none; width: 48px; height: 48px; }
.mm-profile-name strong { min-width: 0; font-weight: 800; overflow-wrap: anywhere; }
.mm-ratings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mm-rating-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 12px 14px; border-radius: var(--radius-panel); box-shadow: inset 0 0 0 1px var(--line); }
/* An odd game out takes the whole row rather than leave a hole beside it. */
.mm-rating-row:last-child:nth-child(odd) { grid-column: 1 / -1; }
.mm-rating-row > span { font-size: var(--text-caption); font-weight: 600; line-height: 1.3; color: var(--ink-soft); }
.mm-rating-row strong { margin-top: 4px; font: 600 42px/1 var(--rank-font); font-variant-numeric: tabular-nums; }
.mm-rating-row small { font-size: var(--text-caption); line-height: 1.3; color: var(--ink-soft); }
.mm-dialog .mm-subtle { margin: 12px 0; font-size: var(--text-caption); line-height: 1.5; color: var(--ink-soft); }
.mm-dialog [data-mm="leaders"] { width: 100%; }
.mm-dialog h3 { margin: 22px 0 4px; font-size: 15px; line-height: 1.3; font-weight: 800; }
.mm-records, .mm-leaders { margin: 0; padding: 0; list-style: none; }
.mm-records li, .mm-leaders li { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0; }
.mm-records li + li, .mm-leaders li + li { border-top: 1px solid var(--line); }
.mm-records li { justify-content: space-between; font-size: var(--text-label); font-weight: 600; }
.mm-records small, .mm-leaders small { display: block; margin-top: 2px; font-size: var(--text-caption); font-weight: 400; color: var(--ink-soft); }
.mm-records strong { flex: none; font: 600 24px/1 var(--rank-font); font-variant-numeric: tabular-nums; }
.mm-records strong.mm-void { font: 600 var(--text-caption)/1.3 var(--sans); color: var(--ink-soft); }
.mm-dialog [data-mm="logout"] { width: 100%; margin-top: 12px; }
/* Account settings below the scorebook, each a short form that returns to it. */
.mm-dialog .mm-warn { margin: 8px 0; font-size: var(--text-caption); font-weight: 600; line-height: 1.5; color: var(--alert); }
.mm-manage { display: grid; gap: 8px; margin-top: 8px; }
.mm-manage button, .mm-dialog [data-mm="delete"] { width: 100%; }
.mm-dialog button.mm-danger { color: var(--alert); }
.mm-dialog form button.mm-danger { width: 100%; min-height: 48px; border-color: var(--alert); }
.mm-dialog .mm-avatars { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 16px 0 0; padding: 0; border: 0; }
.mm-avatars legend { margin-bottom: 6px; padding: 0; font-size: var(--text-caption); font-weight: 600; color: var(--ink-soft); }
.mm-dialog .mm-avatars label { position: relative; display: grid; place-items: center; margin: 0; padding: 3px; aspect-ratio: 1; border: 2px solid transparent; border-radius: 50%; cursor: pointer; }
.mm-dialog .mm-avatars input { position: absolute; width: 1px; height: 1px; min-height: 0; margin: 0; opacity: 0; }
.mm-avatars .disc { display: block; width: min(100%, 40px); height: auto; aspect-ratio: 1; }
.mm-avatars label:has(:checked) { border-color: var(--ink); }
.mm-avatars label:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.mm-dialog #mm-code { letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.mm-code { margin: 16px 0; padding: 14px 8px; border-radius: var(--radius-panel); box-shadow: inset 0 0 0 1px var(--line); font: 700 20px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; text-align: center; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.mm-leaders { margin-top: 8px; }
.mm-leaders li { min-height: 56px; }
.mm-position { flex: none; width: 22px; font: 600 20px/1 var(--rank-font); text-align: center; color: var(--ink-soft); }
.mm-leaders .disc { flex: none; width: 36px; height: 36px; }
.mm-leader-name { flex: 1; min-width: 0; font-size: var(--text-label); font-weight: 700; overflow-wrap: anywhere; }
.mm-leaders strong { flex: none; font: 600 26px/1 var(--rank-font); font-variant-numeric: tabular-nums; }
/* Upright on a phone, each dialog is a sheet that rises from the bottom. */
html[data-layout="phone-portrait"] .mm-overlay { align-items: flex-end; padding: max(16px, env(safe-area-inset-top, 0px)) 0 0; }
html[data-layout="phone-portrait"] .mm-dialog { width: 100%; max-height: 100%; padding: 16px 16px max(20px, env(safe-area-inset-bottom, 0px)); border-radius: 18px 18px 0 0; animation: sheetUp var(--motion-panel) ease-out; }
html[data-layout="phone-landscape"] .mm-overlay { padding: 12px; }
html[data-layout="phone-landscape"] .mm-dialog { max-height: calc(100dvh - 24px); padding: 14px 20px 18px; }
html[data-layout="phone-landscape"] .mm-dialog-head { margin-bottom: 8px; }
html[data-layout="phone-landscape"] .mm-dialog .mm-seal { width: 32px; height: 32px; font-size: 19px; }
/* On its side, sign-in keeps its button in view: the note goes, the fields sit closer. */
html[data-layout="phone-landscape"] :is(.mm-dialog-login, .mm-dialog-register) .mm-dialog-note { display: none; }
html[data-layout="phone-landscape"] .mm-dialog label { margin-top: 4px; }
html[data-layout="phone-landscape"] .mm-dialog .mm-form-error { margin: 4px 0 2px; }

/* ---------- the rating in a ranked round's result ---------- */
.mm-result-rating { display: flex; flex-direction: column; align-items: inherit; gap: 4px; margin: 12px 0 8px; }
.mm-result-rating > span { font-size: var(--text-caption); line-height: 1.3; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.mm-result-rating > span:first-child { font-weight: 600; }
.mm-result-rating strong { display: flex; align-items: center; gap: 10px; font: 600 48px/1 var(--rank-font); font-variant-numeric: tabular-nums; color: var(--ink); }
.mm-result-rating small { padding: 4px 9px; border-radius: 999px; font: 700 var(--text-label)/1 var(--sans); font-variant-numeric: tabular-nums; box-shadow: inset 0 0 0 1.5px currentColor; }
.mm-result-rating p { margin: 0; font-size: var(--text-caption); color: var(--ink-soft); }
.mm-forfeit, .mm-void-note { margin: 4px 0 0; font-size: var(--text-caption); font-weight: 600; line-height: 1.5; color: var(--ink); }
.ranked-result .result-head { padding-top: 15px; }
.ranked-result .result-head .round-score { display: none; }
@media (prefers-reduced-motion: reduce) {
  .mm-token.mm-open, .mm-dialog, html[data-layout] .mm-dialog { animation: none; }
}
