:root {
  --cinnabar: #e7625f;
  --freesia: #e2b850;
  --blue: #1f6cb0;
  --rose: #e24c60;
  --ink: #172735;
  --muted: #475b6b;
  --line: #ccd8e0;
  --paper: #f5f7f9;
  font: 16px/1.4 system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
.app-shell { min-height: 100dvh; }
.my-turn { background: var(--rose); }
.my-turn .masthead, .my-turn .match-meta { background: #fff1f3; }
.my-turn .felt { background: #ffe1e6; border-color: #b83148; }
.final-lap { --lap-purple: #bb91ec; --lap-red: #ef7d89; background: var(--lap-purple); }
.final-lap .masthead, .final-lap .match-meta { background: #fcf5ff; }
.final-lap .felt { --lap-purple: #f2e3ff; --lap-red: #ffdee5; background: var(--lap-purple); border-color: #a679cb; }
main { max-width: 66rem; margin: auto; padding: 1rem clamp(.7rem, 3vw, 2rem) 2rem; }
h1, h2, p { margin: 0 0 .7rem; }
h1 { font-size: clamp(1.65rem, 5vw, 2.25rem); }
h2 { font-size: 1.05rem; }
a { color: var(--blue); }
button, input { font: inherit; }
button {
  min-height: 2.65rem;
  padding: .45rem .85rem;
  border: 1px solid transparent;
  border-radius: .5rem;
  color: #fff;
  background: var(--blue);
  font-weight: 650;
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(.91); }
button:disabled { opacity: .55; cursor: default; }
:is(button, a, input, summary):focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
button.secondary { color: var(--blue); border-color: var(--line); background: #fff; }
button.compact { min-height: 2.4rem; font-size: .88rem; }
input {
  min-height: 2.65rem;
  padding: .5rem .65rem;
  border: 1px solid #a8baca;
  border-radius: .5rem;
  color: var(--ink);
  background: #fff;
  width: 100%;
}
form { display: grid; gap: .75rem; }
label { display: grid; gap: .3rem; font-weight: 600; }
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .55rem;
  padding: .75rem clamp(.85rem, 4vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.brand { color: var(--ink); font-size: 1.24rem; font-weight: 800; text-decoration: none; }
.brand-suits { display: inline-flex; gap: .18em; white-space: nowrap; }
.masthead-actions { display: flex; align-items: center; gap: .65rem; }
.suit-symbol {
  display: inline-block;
  width: .85em;
  height: .85em;
  vertical-align: -.06em;
  color: #111820;
  background: currentColor;
  mask: var(--suit-shape) center / contain no-repeat;
}
.suit-symbol:is([data-suit="H"], [data-suit="D"]) { color: #a51730; }
.suit-symbol[data-suit="T"] { --suit-shape: url("/suits/stars.svg"); color: #947019; }
.suit-symbol[data-suit="H"] { --suit-shape: url("/suits/hearts.svg"); }
.suit-symbol[data-suit="S"] { --suit-shape: url("/suits/spades.svg"); }
.suit-symbol[data-suit="D"] { --suit-shape: url("/suits/diamonds.svg"); }
.suit-symbol[data-suit="C"] { --suit-shape: url("/suits/clubs.svg"); }
@media (forced-colors: active) {
  .suit-symbol { forced-color-adjust: none; background: CanvasText; }
}
.surface { background: #fff; border: 1px solid var(--line); border-radius: .85rem; }
.entry, .lobby, .rules { padding: clamp(.9rem, 4vw, 1.65rem); margin: clamp(.6rem, 4vw, 2rem) auto; }
.entry, .lobby { max-width: 29rem; }
.invite, .rename { display: flex; align-items: end; gap: .5rem; margin-block: .9rem; }
.invite label, .rename label { flex: 1; min-width: 0; }
.invite input { font-size: .87rem; }
.lobby-players { padding: .65rem 1.75rem; background: var(--paper); border-radius: .5rem; overflow-wrap: anywhere; }
.quiet, .match-meta { color: var(--muted); }
.error, .connection { background: #fff; border: 1px solid var(--rose); border-radius: .5rem; padding: .55rem .7rem; }
.connection { border-color: var(--freesia); }
.scoreboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(8.5rem, 50%), 1fr)); overflow: hidden; }
.score {
  display: flex;
  justify-content: space-between;
  gap: .4rem;
  padding: .55rem .65rem;
  align-items: center;
  border-top: 3px solid var(--blue);
  border-inline-end: 1px solid var(--line);
}
.score.alternate { border-top-color: var(--rose); }
.score span { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.score-numbers { text-align: right; }
.score-numbers strong { display: block; font-size: 1.6rem; line-height: 1.05; font-variant-numeric: tabular-nums; }
.score small { white-space: nowrap; }
.match-meta { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: .25rem .7rem; font-size: .84rem; margin: .25rem 0; border-radius: .5rem; padding: .55rem; }
.match-meta strong { color: var(--ink); }
.felt {
  display: grid;
  align-content: center;
  min-height: min(43vh, 20rem);
  padding: .75rem;
  gap: .65rem;
  background: #eaf3fa;
  border: 1px solid #bbd0df;
  border-radius: .85rem;
}
.seats { display: flex; justify-content: center; flex-wrap: wrap; gap: .35rem; }
.nameplate {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 4.5rem;
  max-width: 100%;
  padding: .23rem .42rem;
  border: 2px solid transparent;
  border-radius: .5rem;
  background: #f9fcfe;
  text-align: center;
  overflow-wrap: anywhere;
}
.nameplate small { font-size: .71rem; color: var(--muted); }
.nameplate strong { font-size: .88rem; }
.nameplate.current { background: var(--rose); border-color: #b83148; color: #101820; }
.nameplate.current small { color: inherit; }
.nameplate.offline strong { opacity: .65; }
.table-status { text-align: center; font-weight: 750; margin: 0; }
.table-status p { margin: 0; }
.went-out { padding: .55rem .7rem; border-radius: .5rem; background: #fff; }
.went-out strong { color: #602180; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.piles { display: flex; justify-content: center; align-items: stretch; gap: .65rem; }
.pile-slot { display: flex; }
.pile {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: .35rem;
  width: min(39vw, 9rem);
  font-size: .8rem;
  padding: .5rem;
}
.pile:disabled { opacity: .8; }
.pile img, .empty-card { width: clamp(3.2rem, 12vw, 5.25rem); aspect-ratio: 203 / 288; border-radius: .35rem; }
.pile img, .revealed img { box-shadow: 0 1px 4px #1f314751; }
.empty-card { border: 1px dashed #708899; }
.revealed { display: flex; flex-wrap: wrap; justify-content: center; gap: .65rem; text-align: center; }
.revealed-groups, .revealed-meld { display: flex; flex-wrap: wrap; justify-content: center; gap: .16rem; }
.revealed-meld { background: #fff9; border-radius: .35rem; padding: .18rem; }
.revealed img { width: clamp(1.4rem, 5vw, 2.5rem); border-radius: .2rem; }
.revealed-meld.unmelded { background: #ffeaed; }
.unmelded img { border: 2px solid #c12a41; }
.unmelded-label { flex-basis: 100%; color: #8a1931; font-size: .7rem; font-weight: 700; }
.play-dock { padding-block: .65rem; }
.hand-header, .hand-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.hand-header { justify-content: space-between; margin-bottom: .35rem; }
.hand-header h2 { margin: 0; }
.match { --card-width: clamp(2.4rem, min(9vw, 11dvh), 5.1rem); }
.hand-groups { display: flex; align-items: start; flex-wrap: wrap; gap: .45rem; }
.hand-group { padding: .4rem; border: 2px solid var(--line); border-radius: .55rem; background: #fff; max-width: 100%; }
.hand-group.valid { border-color: #35916a; }
.hand { position: relative; display: flex; flex-wrap: wrap; gap: .28rem; padding-block: .25rem; }
.hand .card {
  position: relative;
  width: var(--card-width);
  min-height: 0;
  display: block;
  border: 1px solid var(--line);
  border-radius: .42rem;
  padding: 0;
  background: white;
  box-shadow: 0 1px 3px #1f314731;
}
.hand .card:disabled { opacity: 1; }
.hand .card[data-drag-origin] { position: absolute; inset: 0 auto auto 0; opacity: 0; pointer-events: none; }
.card img { display: block; width: 100%; aspect-ratio: 103 / 160; border-radius: inherit; }
.card.wild { outline: 2px solid #8065b8; outline-offset: -2px; }
.card[aria-pressed="true"], .card:focus-visible { outline: 3px solid var(--blue); outline-offset: 1px; }
.group-drop {
  display: grid;
  place-items: center;
  width: calc(var(--card-width) + .8rem + 4px);
  min-height: calc(var(--card-width) * 160 / 103 + 1.3rem + 4px);
  border-style: dashed;
  border-color: #708899;
  background: #fff8;
  color: var(--muted);
  font-size: 1.35rem;
}
.group-drop[aria-disabled="false"] { cursor: pointer; }
.group-drop:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.group-drop[data-drop-preview], .pile-slot[data-drop-preview] {
  outline: 3px dashed var(--blue);
  outline-offset: -3px;
  border-radius: .55rem;
}
.group-drop[data-drop-preview] > span { visibility: hidden; }
.drop-slot {
  flex: none;
  width: var(--card-width);
  aspect-ratio: 103 / 160;
  border: 2px dashed var(--blue);
  border-radius: .42rem;
}
.dragged-card {
  position: fixed;
  z-index: 4;
  pointer-events: none;
  width: var(--card-width);
  transform: translate(-50%, -50%);
}
.dragged-card img { display: block; width: 100%; border-radius: .42rem; box-shadow: 0 2px 6px #1f314780; }
[data-drag] { touch-action: none; user-select: none; }
.match-results, .table-settings { padding: .65rem .85rem; margin-block: .5rem; }
.history-scores { overflow-x: auto; }
table { border-collapse: collapse; margin: .7rem 0; width: 100%; }
th, td { padding: .25rem .6rem; text-align: left; border-bottom: 1px solid var(--line); }
.history-scores tfoot { background: var(--paper); font-weight: 750; }
summary { cursor: pointer; font-weight: 700; }
.rules h2 { margin-top: 1.3rem; }
.rules li + li { margin-top: .3rem; }
.pile-slot > :disabled { pointer-events: none; }
.hand img, .pile img { position: relative; }
.hand img { pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .final-lap, .final-lap .felt { animation: final-lap-pulse 8s ease-in-out infinite; }
  .went-out-letter { animation: letter-in 3s ease-out infinite both; animation-delay: calc(var(--letter) * 24ms); }
  .my-turn .nameplate.current { animation: turn-pop .34s cubic-bezier(.2,.8,.3,1.5); }
  .revealed { animation: reveal-pop .3s ease-out; }
  .card[aria-pressed="true"] img { transform: translateY(-3px); }
  @keyframes turn-pop {
    from { transform: scale(.9); }
    66% { transform: scale(1.09); }
  }
  @keyframes reveal-pop {
    from { transform: translateY(7px) scale(.94); opacity: .15; }
  }
  @keyframes final-lap-pulse {
    0%, 100% { background-color: var(--lap-purple); }
    50% { background-color: var(--lap-red); }
  }
  @keyframes letter-in {
    0% { opacity: .15; }
    8% { opacity: 1; text-shadow: 0 0 .38em #d9a4f7; }
    15%, 100% { opacity: 1; text-shadow: none; }
  }
}
@media (max-width: 420px) {
  .masthead-actions { gap: .35rem; }
  .masthead-actions .compact, .hand-actions .compact { font-size: .75rem; padding-inline: .35rem; }
  .felt { min-height: 15rem; }
  .score { padding: .35rem; }
}
