:root {
  background: var(--sw-surface);
  color: var(--sw-on-surface);
  font-family: var(--sw-body);
  line-height: 1.4;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; display: flex; flex-direction: column; min-height: 100dvh; overflow-x: clip; }
[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: .25em; }
button, input, select { font: inherit; }
button, input, select {
  min-height: 2.75rem;
  border: 1px solid var(--sw-border);
  border-radius: calc(var(--sw-radius) / 2);
}
button, .button {
  color: var(--sw-on-raised);
  background: var(--sw-raised);
  font-weight: 680;
  padding: .65rem 1rem;
}
button:not(:disabled):not([aria-disabled="true"]) { cursor: pointer; }
button:disabled { opacity: .64; }
button:not(:disabled):not([aria-disabled="true"]):hover { border-color: var(--sw-accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--sw-focus);
  outline-offset: 3px;
}
input, select {
  width: 100%;
  min-width: 0;
  padding: .55rem .7rem;
  background: var(--sw-surface);
  color: var(--sw-on-surface);
}
input::placeholder { color: var(--sw-muted); }
h1, h2, h3, p { margin: 0; }

.bar {
  display: flex;
  align-items: center;
  gap: clamp(.6rem, 2.5vw, 1.75rem);
  padding: .4rem max(clamp(.75rem, 2.5vw, 1.75rem), env(safe-area-inset-right)) .4rem max(clamp(.75rem, 2.5vw, 1.75rem), env(safe-area-inset-left));
  border-bottom: 1px solid color-mix(in srgb, var(--sw-border) 55%, transparent);
}
.launcher { font-weight: 800; letter-spacing: -.02em; text-decoration: none; font-size: .9rem; color: var(--sw-muted); }
.title { display: flex; align-items: baseline; gap: .75rem; min-width: 0; }
h1 { font: 800 clamp(1.35rem, 3.2vw, 1.9rem)/1.05 var(--sw-display); letter-spacing: -.035em; white-space: nowrap; }
.bar-actions { display: flex; gap: .4rem; margin-inline-start: auto; }
.bar-actions button { padding: .4rem .8rem; white-space: nowrap; }

.table {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(.35rem, 1.2vh, .8rem);
  padding: clamp(.4rem, 1.2vh, .9rem) max(clamp(.6rem, 2vw, 1.5rem), env(safe-area-inset-right)) max(clamp(.4rem, 1.4vh, 1rem), env(safe-area-inset-bottom)) max(clamp(.6rem, 2vw, 1.5rem), env(safe-area-inset-left));
  background: radial-gradient(ellipse at 50% 42%, var(--sw-raised), var(--sw-surface) 78%);
}

/* A chosen background takes over from the Swoggler theme, so every property a theme can set is set here. The body
   carries them, because a theme writes its own on the page itself. */
html[data-backdrop]:not([data-backdrop="plain"]) body {
  color-scheme: dark;
  font-family: "Source Sans 3", system-ui, sans-serif;
  --sw-body: "Source Sans 3", system-ui, sans-serif;
  --sw-radius: 14px;
  --sw-quick: 160ms;
  --sw-positive: var(--target);
  --sw-on-positive: var(--surface);
  --sw-danger: var(--panel);
  --sw-on-danger: var(--text);
  --sw-on-caution: var(--on-action);
  --sw-surface: var(--surface);
  --sw-on-surface: var(--text);
  --sw-raised: var(--panel);
  --sw-on-raised: var(--text);
  --sw-action: var(--action);
  --sw-on-action: var(--on-action);
  --sw-accent: var(--target);
  --sw-caution: var(--action);
  --sw-muted: var(--muted);
  --sw-border: var(--line);
  --sw-focus: var(--action);
  --sw-display: var(--heading);
  color: var(--text);
}
html[data-backdrop]:not([data-backdrop="plain"]) .bar { background: var(--panel); }
html[data-backdrop]:not([data-backdrop="plain"]) .table { background: none; }
html[data-backdrop]:not([data-backdrop="plain"]) :is(.table-header, .invite, .back-banner) { background: var(--panel); border-radius: calc(var(--sw-radius) / 2); padding: .45rem .75rem; }
html[data-backdrop]:not([data-backdrop="plain"]) .hand-card { filter: drop-shadow(0 2px 5px color-mix(in srgb, var(--surface) 70%, transparent)); }

#look { width: min(54rem, calc(100vw - 1.5rem)); }
#look .hint { margin-block: .5rem 1rem; }
#mixed { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .8rem; }
#look-status { min-height: 1.4em; color: var(--sw-accent); font-size: .9rem; }
.check { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.check input { width: 1.2rem; min-height: 1.2rem; }
#volume { flex: 1 1 8rem; padding: 0; border: 0; background: none; accent-color: var(--sw-accent); }

.table-header { display: flex; justify-content: space-between; align-items: center; gap: .4rem 1rem; flex-wrap: wrap; }
.table h2 { font: 700 clamp(1rem, 2.2vw, 1.25rem)/1.15 var(--sw-display); }
#match-status { margin-top: .1rem; color: var(--sw-muted); font-size: .96rem; min-height: 1.4em; }
.table[data-your-turn="true"] #match-status, .table[data-phase="finished"] #match-status { color: var(--sw-accent); }
.table[data-your-turn] #match-status[data-refused="true"], #match-status[data-refused="true"] { color: var(--sw-caution); font-weight: 700; }
.hand-chip { color: var(--sw-muted); font-size: .88rem; white-space: nowrap; }
.table h2.rules-line { color: var(--sw-on-surface); }
#invite-rules:empty, #summary-lines:empty { display: none; }
#invite-rules { margin: 0; }
#summary-lines { margin-bottom: .7rem; }

.felt { flex: 1; min-height: 20rem; display: grid; }
.felt > #table { min-height: 0; }

.primary { color: var(--sw-on-action); background: var(--sw-action); border-color: var(--sw-action); }
.primary:not(:disabled):hover { filter: brightness(1.08); border-color: var(--sw-focus); }
.hint { color: var(--sw-muted); font-size: .9rem; }
.invite { width: min(36rem, 100%); align-self: center; display: grid; gap: .55rem; }
.invite h3 { font: 700 1.05rem/1.2 var(--sw-display); }
.invite label { display: block; margin-bottom: .3rem; font-weight: 720; font-size: .9rem; }
#lobby-seats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .35rem; }
#lobby-seats li { padding: .45rem .7rem; border: 1px solid var(--sw-border); border-radius: calc(var(--sw-radius) / 2); background: var(--sw-raised); color: var(--sw-on-raised); }
#lobby-seats li[data-open="true"] { color: var(--sw-muted); border-style: dashed; }
.join-controls { display: flex; gap: .35rem; }
.join-controls button { flex: 0 0 auto; }
.back-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .4rem .9rem; padding: .35rem .75rem; border: 1px solid var(--sw-caution); border-radius: calc(var(--sw-radius) / 2); }
.back-banner button { min-height: 2.5rem; padding-block: .3rem; }
.played { align-self: center; width: min(34rem, 100%); padding: .4rem .6rem; border: 1px solid color-mix(in srgb, var(--sw-border) 60%, transparent); border-radius: calc(var(--sw-radius) / 2); background: color-mix(in srgb, var(--sw-raised) 85%, transparent); }

/* Over the table, so a message never changes the size of the table. */
.activity {
  position: fixed;
  inset: auto 0 max(.75rem, env(safe-area-inset-bottom));
  z-index: 4;
  width: fit-content;
  max-width: calc(100vw - 1.5rem);
  margin-inline: auto;
  padding: .45rem .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  border: 1px solid var(--sw-border);
  border-radius: calc(var(--sw-radius) / 2);
  background: var(--sw-raised);
  color: var(--sw-accent);
  font-size: .9rem;
}
.activity:has(p:empty):has(button[hidden] + button[hidden] + button[hidden]) { display: none; }
.activity #deal-next { position: relative; }
/* Between hands the trick area is empty, so the next deal waits there rather than over your seat. */
.activity:has(#deal-next:not([hidden])) { inset: 50% 0 auto; translate: 0 -50%; }
/* The open summary has its own Deal button, so the one on the table waits until the summary is closed. */
body:has(#summary[open]) #deal-next { display: none; }
body:has(#summary[open]) .activity:has(p:empty):not(:has(#retry-command:not([hidden]), #reconnect:not([hidden]))) { display: none; }

.moon {
  position: fixed;
  inset: 22% 0 auto;
  z-index: 7;
  width: fit-content;
  max-width: calc(100vw - 1.5rem);
  margin-inline: auto;
  padding: 1rem 1.6rem;
  display: grid;
  gap: .25rem;
  text-align: center;
  color: var(--sw-on-action);
  background: var(--sw-action);
  border: 3px solid var(--sw-on-action);
  border-radius: calc(var(--sw-radius) * 1.4);
  box-shadow: 0 0 0 .5rem color-mix(in srgb, var(--sw-action) 35%, transparent), 0 1rem 3rem color-mix(in srgb, var(--sw-surface) 70%, transparent);
  pointer-events: none;
}
.moon strong { font: 800 clamp(1.5rem, 6vw, 2.4rem)/1.1 var(--sw-display); letter-spacing: -.03em; }
.moon[data-show="true"] { animation: moon-rise 650ms cubic-bezier(.2, 1.3, .4, 1); }
@keyframes moon-rise { from { transform: translateY(1.5rem) scale(.7); opacity: 0; } 60% { transform: scale(1.06); } }

dialog {
  width: min(34rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  padding: clamp(1rem, 3vw, 1.5rem);
  color: var(--sw-on-raised);
  background: var(--sw-raised);
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius);
  overflow: auto;
}
dialog::backdrop { background: color-mix(in srgb, var(--sw-surface) 72%, transparent); }
dialog header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
dialog h2 { font: 700 1.5rem/1.1 var(--sw-display); }
dialog h3 { font: 700 1.1rem/1.1 var(--sw-display); margin-block: 1.1rem .5rem; }
dialog.sheet { position: fixed; inset: auto 0 max(1rem, env(safe-area-inset-bottom)); z-index: 6; margin-inline: auto; width: min(30rem, calc(100vw - 1.5rem)); max-height: min(34rem, calc(100dvh - 1.5rem)); box-shadow: 0 .5rem 2rem color-mix(in srgb, var(--sw-surface) 70%, transparent); }
#summary h2 { margin-bottom: .25rem; color: var(--sw-accent); }
#summary-detail { margin-bottom: .6rem; }
#summary .actions { margin: .3rem 0 .2rem; }
#summary-note { margin-bottom: .7rem; }
.close { min-width: 2.75rem; padding: 0; }
.options { border: 0; padding: 0; margin: 0 0 1rem; display: grid; gap: .4rem; min-width: 0; }
.options legend { padding: 0; margin-bottom: .4rem; font-weight: 720; font-size: .9rem; }
.options label { position: relative; display: block; cursor: pointer; }
.options input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; }
.options span { display: block; border: 2px solid color-mix(in srgb, var(--sw-border) 60%, transparent); border-radius: calc(var(--sw-radius) / 2); padding: .5rem .75rem; }
.options small { display: block; color: var(--sw-muted); font-size: .84rem; }
.options input:checked + span { border-color: var(--sw-accent); }
.options input:checked + span strong { color: var(--sw-accent); }
.options input:focus-visible + span { outline: 2px solid var(--sw-focus); outline-offset: 2px; }
.sizes { grid-template-columns: repeat(2, 1fr); }
.sizes legend { grid-column: 1 / -1; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .6rem; }
#create-solo, #start-now { grid-column: 1 / -1; }
#start-now { white-space: normal; }
.computer-play { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .5rem; margin-bottom: .9rem; font-weight: 720; font-size: .9rem; }
.computer-play select { width: auto; padding-inline: .6rem; background: var(--sw-raised); color: var(--sw-on-raised); }
.open-games { display: grid; gap: .45rem; padding-bottom: .9rem; margin-bottom: .9rem; border-bottom: 1px solid var(--sw-border); }
.open-games-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
dialog .open-games h3, .start-heading { margin: 0; }
.start-heading { margin-bottom: .6rem; }
#open-status { color: var(--sw-muted); font-size: .9rem; }
#open-status:empty, #open-list:empty, #open-note:empty { display: none; }
#open-note { color: var(--sw-caution); font-size: .9rem; }
#open-list { list-style: none; padding: .2rem; margin: -.2rem; display: grid; gap: .35rem; max-height: 12rem; overflow: auto; }
#open-list button { width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .3rem .75rem; text-align: start; }
#open-list button > span:first-child { min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
#open-list button > span:last-child { flex: none; color: var(--sw-accent); }
.menu-tools { display: flex; flex-wrap: wrap; gap: .5rem; }
.button { display: inline-grid; place-items: center; min-height: 2.75rem; border: 1px solid var(--sw-border); border-radius: calc(var(--sw-radius) / 2); text-decoration: none; }
.menu-tools .button { padding-inline: 1rem; }
.settings { border: 0; padding: 0; margin: 1rem 0 0; display: grid; gap: .5rem; }
.settings legend { padding: 0; margin-bottom: .4rem; font-weight: 720; }
.settings .check { margin: 0; }
.field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .5rem; }
.field select { width: auto; background: var(--sw-raised); color: var(--sw-on-raised); }
#history-status:empty, #match-list:empty { display: none; }
#match-list { list-style: none; padding: 3px; margin: 0; display: grid; gap: .35rem; max-height: 14rem; overflow: auto; }
#match-list button { width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .15rem .5rem; text-align: left; padding: .45rem .65rem; }
#match-list button[aria-current="true"] { border-color: var(--sw-accent); }
#match-list button span { color: var(--sw-muted); font-size: .8rem; font-weight: 500; }
details { margin-block: 1rem; }
summary { cursor: pointer; font-weight: 720; min-height: 2.75rem; align-content: center; }
.realm { display: flex; margin-top: 1rem; font-size: .84rem; }
.realm a { color: var(--sw-muted); padding: .45rem .6rem; text-decoration: none; }
.realm a[aria-current] { color: var(--sw-on-raised); font-weight: 720; text-decoration: underline; }

@media (max-width: 40rem) {
  .bar { gap: .5rem; }
  .launcher { display: none; }
  .bar-actions button { padding-inline: .55rem; font-size: .9rem; }
  h1 { font-size: 1.2rem; }
  .felt { min-height: 24rem; }
  .actions { grid-template-columns: 1fr; }
}
@media (max-width: 22rem) {
  .bar .launcher { display: none; }
}
@media (max-width: 24rem) {
  .join-controls { flex-wrap: wrap; }
}
/* A phone on its side has little height, so everything but the table gives way. */
@media (max-height: 30rem) {
  .bar { padding-block: .2rem; }
  .bar button { min-height: 2.25rem; padding-block: .2rem; }
  .table { gap: .15rem; padding-block: .2rem; }
  .table-header { flex-wrap: nowrap; gap: 0 .6rem; }
  .table-header h2 { display: none; }
  .felt { min-height: 0; }
  .hint { display: none; }
  #match-status { margin: 0; font-size: .85rem; min-height: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .headline { min-width: 0; }
  .hand-chip { font-size: .78rem; }
  .pass-prompt { display: none; }
  .pass-confirm { min-height: 2.25rem; padding-block: .2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .moon[data-show="true"] { animation: none; }
}

/* Player records: the open list's people, the end-of-game standings, My record and the level a host asks for. */
.open-people { flex: 1 0 100%; order: 2; display: flex; flex-wrap: wrap; gap: .2rem .8rem; font-size: .85rem; }
#open-list button > span:last-child { order: 1; }
.open-person { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .1rem .35rem; min-width: 0; }
.open-person-name { overflow-wrap: anywhere; }
#open-filter { margin-block: .1rem .2rem; }
#open-filter .lobby-filter fieldset, #open-filter fieldset { padding: .3rem .6rem; }
#open-filter select { width: auto; }
#min-level { width: auto; padding-inline: .6rem; background: var(--sw-raised); color: var(--sw-on-raised); }
#min-level-hint { margin: -.5rem 0 .8rem; }
.standings { list-style: none; margin: .4rem 0 .2rem; padding: 0; display: grid; gap: .3rem; }
.standings li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .05rem .6rem; padding: .3rem .55rem; border: 1px solid color-mix(in srgb, var(--sw-border) 55%, transparent); border-radius: calc(var(--sw-radius) / 2.4); }
.standings li[data-you="true"] { border-color: var(--sw-accent); }
.standing-place { font-weight: 800; min-width: 2.2rem; }
.standing-name { font-weight: 720; overflow-wrap: anywhere; }
.standing-points { color: var(--sw-muted); }
.standing-rating { margin-inline-start: auto; font-variant-numeric: tabular-nums; font-weight: 720; }
.standing-rating[data-sign="1"] { color: var(--sw-positive); }
.standing-rating[data-sign="-1"] { color: var(--sw-caution); }
.standings-note:empty, #summary-standings:empty { display: none; }
.standings-note { margin: .2rem 0 .6rem; }
#lobby-seats li .rating-badge { margin-inline-start: .3rem; }
#record { width: min(62rem, calc(100vw - 1.5rem)); }
#record .my-record { max-width: none; }
#record header { justify-content: flex-end; margin-bottom: 0; }
#record .my-record { padding: 0; }
#record .my-record button { background: var(--sw-action); color: var(--sw-on-action); }

/* The host's Remove asks for a second tap, which is outlined in the warning color and reworded. */
.remove-seat { display: block; min-height: 2.75rem; margin-top: .3rem; padding: .3rem .6rem; font-size: .84rem; text-align: start; }
.remove-seat[data-confirm="true"] { border-color: var(--sw-caution); color: var(--sw-caution); font-weight: 700; }

/* A name in the waiting room that opens its profile. */
.profile-link { color: inherit; text-underline-offset: 3px; }
