@font-face {
  font-family: Bricolage;
  src: url("/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: Manrope;
  src: url("/fonts/manrope.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --paper: #f5f3eb;
  --ink: #1a2041;
  --muted: #51566b;
  --rule: #c8c8cf;
  --lime: #dbf68d;
  --lavender: #c4b6fa;
  --night: #151b36;
  --panel: #202846;
  --panel-edge: #424b6c;
  --night-text: #f8f6ff;
  --night-muted: #c0c7e0;
  --focus: #5840ac;
  --body: Manrope, system-ui, sans-serif;
  --display: Bricolage, system-ui, sans-serif;
  --gutter: clamp(1rem, 4vw, 3.5rem);
  color-scheme: light;
  font-family: var(--body);
  font-weight: 550;
  color: var(--ink);
  background: var(--paper);
  accent-color: var(--focus);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; text-underline-offset: .21em; }
h1, h2, p, ol { margin: 0; }
h1, h2 { font-family: var(--display); line-height: 1; font-weight: 790; letter-spacing: -.035em; overflow-wrap: anywhere; }
p { line-height: 1.6; }
::selection { color: var(--ink); background: var(--lavender); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
[data-heading]:focus, #app:focus, #sheet-title:focus { outline: none; }
[hidden] { display: none !important; }
.wrap { width: min(100% - 2 * var(--gutter), 77rem); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip { position: fixed; z-index: 3; top: .5rem; left: .5rem; padding: .7rem 1rem; background: var(--paper); color: var(--ink); transform: translateY(-160%); }
.skip:focus { transform: none; }
.skip:not(:focus) { clip-path: inset(50%); }

.masthead { border-bottom: 1px solid var(--rule); }
.header-inner { min-height: 4.2rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wordmark { display: flex; align-items: center; gap: .65rem; background: transparent; border: 0; padding: 0; min-height: 44px; font-family: var(--display); font-weight: 800; font-size: 1.5rem; letter-spacing: -.035em; line-height: 1; }
.wordmark-table { font-weight: 550; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .55rem; min-height: 44px; padding: .58rem .9rem; border: 1px solid transparent; border-radius: .65rem; background: transparent; font-size: .92rem; font-weight: 800; line-height: 1.25; text-align: center; }
.button svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
.header-rules { border: 1px solid var(--rule); border-radius: 2rem; padding-inline: 1.05rem; }
.header-rules:hover, .outline:hover { border-color: var(--ink); background: #eae7dc; }
.primary { background: var(--ink); color: white; border-color: var(--ink); }
.primary:hover { background: #363c68; }
.outline { border-color: #a4a5b3; }
.text-button { padding-inline: 0; color: var(--muted); }
.text-button:hover { color: var(--ink); text-decoration: underline; text-underline-offset: .22em; }
.button:disabled { opacity: .55; }

.home { padding-top: clamp(1.55rem, 5vw, 4.35rem); }
.home-grid { display: grid; gap: 1.7rem; }
.intro h1 { font-size: clamp(4.1rem, 13vw, 6rem); letter-spacing: -.04em; }
.title-dot { color: #6a4ab5; }
.tagline { margin-top: .55rem; font-family: var(--display); font-weight: 770; font-size: clamp(1.72rem, 5.9vw, 3rem); line-height: 1.02; letter-spacing: -.032em; }
.intro-copy { max-width: 32ch; color: var(--muted); margin-top: .85rem; font-size: clamp(.98rem, 1.65vw, 1.13rem); }
.mode-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin-top: 1.15rem; }
.mode-button { min-height: 48px; justify-content: flex-start; }
.mode-button.primary { grid-column: 1 / -1; }
.resume { display: flex; flex-wrap: wrap; gap: 0 .9rem; margin-top: .3rem; }
.showcase { background: var(--lavender); border: 1px solid #8775c6; border-radius: 1.15rem; overflow: hidden; position: relative; min-width: 0; display: flex; flex-direction: column; }
.showcase-rail, .showcase-caption { position: relative; display: flex; justify-content: space-between; align-items: center; gap: .65rem; padding: .7rem clamp(.75rem, 3vw, 1.5rem); }
.showcase-rail { border-bottom: 1px solid #9b8aca; font-weight: 800; font-size: .67rem; letter-spacing: .13em; }
.showcase-art {
  flex: 1;
  min-height: clamp(13rem, 45vw, 22rem);
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background-image: linear-gradient(#3d287b21 1px, transparent 1px), linear-gradient(90deg, #3d287b21 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: center;
}
.orbit { position: absolute; width: 84%; height: 68%; border: 1px solid #5b4694; border-radius: 50%; rotate: -21deg; }
.orbit-inner { width: 68%; height: 47%; opacity: .8; }
.orbit-star { position: absolute; color: #48347f; width: 1.9rem; }
.orbit-star.one { top: 20%; right: 12%; }
.orbit-star.two { bottom: 13%; left: 10%; width: 1rem; }
.demo-card { position: absolute; width: clamp(4.25rem, 23%, 10rem); aspect-ratio: 3 / 4; display: block; container-type: inline-size; filter: drop-shadow(0 12px 9px #29204b40); transform-origin: 50% 65%; transition: transform .45s cubic-bezier(.22,.8,.25,1), opacity .42s ease; }
.demo-card.sample-left { transform: translate(-79%, 10%) rotate(-16deg); }
.demo-card.sample-mid { transform: translate(-3%, -7%) rotate(4deg); }
.demo-card.sample-right { transform: translate(75%, 10%) rotate(18deg); }
.showcase-caption { border-top: 1px solid #9b8aca; min-height: 4.7rem; background: #d5cafb; }
.showcase-caption h2 { font-size: clamp(1.1rem, 3.5vw, 1.5rem); }
.showcase-caption p { margin-top: .22rem; color: #403561; font-size: .82rem; line-height: 1.35; }
.demo-button { border-color: #4c3c78; flex-shrink: 0; }
.demo-button:hover { background: #e6ddff; }
.home-footer { margin-top: clamp(1.55rem, 4vw, 3.25rem); padding: .95rem 0 1.5rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .35rem 1rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: .78rem; font-weight: 700; }

.entry-page, .lobby-page { padding-block: 1.3rem 3rem; }
.entry-inner { max-width: 31rem; margin: clamp(.5rem, 3vw, 2rem) auto 0; }
.entry-page h1, .lobby-page h1 { font-size: clamp(2.45rem, 7vw, 4.1rem); }
.entry-inner p, .lobby-header p { color: var(--muted); margin-top: .55rem; }
.entry-inner form { display: grid; gap: .45rem; margin-top: 1.65rem; }
.entry-inner label { font-weight: 800; font-size: .92rem; }
input { width: 100%; padding: .7rem .9rem; min-height: 48px; border: 1px solid #85889d; background: #fffdfa; border-radius: .55rem; font-size: 1rem; }
input::placeholder { color: #66697d; }
#room-code { text-transform: uppercase; letter-spacing: .11em; font-weight: 800; }
.entry-inner input + label { margin-top: .6rem; }
.entry-inner .primary { justify-content: space-between; margin-top: .8rem; }
.form-error, .table-error { color: #8a2340; font-weight: 800; }
.entry-inner .form-error { color: #8a2340; font-size: .9rem; }
.table-error { margin-bottom: .65rem; padding: .55rem .8rem; border: 1px solid #d29ba5; background: #fff0ef; border-radius: .55rem; width: 100%; }
.lobby-page { max-width: 59rem; padding-top: clamp(2rem, 5vw, 4rem); }
.lobby-header { display: flex; justify-content: space-between; align-items: start; gap: .75rem; margin-bottom: 1.3rem; }
.count-label { flex-shrink: 0; border: 1px solid var(--rule); border-radius: 1.3rem; padding: .45rem .65rem; font-size: .8rem; font-weight: 800; }
.lobby-layout { display: grid; gap: 1.1rem; }
.invite { display: flex; flex-direction: column; align-items: start; gap: .8rem; background: var(--lavender); border: 1px solid #8775c6; border-radius: .95rem; padding: clamp(.9rem, 4vw, 1.5rem); }
.invite h2, .lobby-seats h2 { font-size: 1.34rem; }
.invite-code { font-family: var(--display); font-size: clamp(2.1rem, 10vw, 4.1rem); letter-spacing: .08em; line-height: 1.1; font-weight: 800; user-select: all; }
.invite-buttons, .dialog-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.invite-buttons .outline { border-color: #5e4e87; }
.invite-buttons .outline:hover { background: #e6ddff; }
.lobby-seats ol { list-style: none; padding: 0; margin-top: .75rem; border-top: 1px solid var(--rule); }
.lobby-seats li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--rule); }
.seat-number { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .8rem; }
.seat-name { font-weight: 800; overflow-wrap: anywhere; }
.seat-status, .lobby-seats small { font-size: .78rem; color: var(--muted); }
.lobby-seats p { font-size: .9rem; color: var(--muted); margin: .75rem 0; }
.lobby-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 1.15rem; padding-top: .5rem; border-top: 1px solid var(--rule); }
.lobby-footer span { font-size: .8rem; color: var(--muted); }

:root.at-table { color: var(--night-text); background: var(--night); --focus: var(--lime); }
.at-table body { min-height: 100dvh; color: var(--night-text); background: var(--night); }
.at-table .wordmark { color: var(--night-text); }
.at-table .masthead { border-color: var(--panel-edge); }
.at-table .header-rules { color: var(--night-text); border-color: #667192; }
.at-table .header-rules:hover { background: #333d63; color: var(--night-text); }
.play-toolbar, .game-id { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .55rem; }
.play-toolbar { justify-content: space-between; min-height: 44px; margin-bottom: .5rem; }
.game-id { font-size: .82rem; font-weight: 750; color: var(--night-muted); }
.round-chip { padding: .27rem .55rem; border-radius: 1rem; background: #3c4466; color: var(--night-text); }
.network { display: inline-flex; gap: .27rem; align-items: center; }
.network::before { content: ""; width: .45rem; height: .45rem; border: 1px solid currentColor; border-radius: 50%; }
.network.live::before { background: var(--lime); border-color: var(--lime); }
.score-link { color: var(--night-text); padding-inline: .55rem; }
.score-link:hover { background: #343e61; }
.turn-strip { min-height: 4.6rem; padding: .7rem .8rem; display: flex; align-items: center; justify-content: space-between; gap: .6rem; border: 1px solid var(--panel-edge); border-radius: .75rem; background: var(--panel); transition: border-color .16s ease, background-color .16s ease; }
.turn-strip.own-turn { background: #253a3e; border-color: #8aa980; }
.turn-strip.own-turn h1 { color: #e5f5ca; }
.turn-strip h1 { font-size: clamp(1.34rem, 4.6vw, 2.05rem); }
.turn-strip h1 { overflow-wrap: anywhere; }
.turn-strip p { margin-top: .17rem; font-size: .88rem; line-height: 1.38; }
.play-panel { min-width: 0; background: var(--panel); border: 1px solid var(--panel-edge); border-radius: .8rem; padding: clamp(.7rem, 2.3vw, 1.15rem); }
.play-panel h2 { font-size: clamp(1.12rem, 3.5vw, 1.45rem); }
button.pile-slot::after { content: ''; position: absolute; inset: -3px; border-radius: inherit; border: 1px solid #b1bce8; pointer-events: none; }
.board-heading { display: flex; align-items: center; justify-content: space-between; gap: .45rem; margin-bottom: .55rem; }
.board-heading p { color: var(--night-muted); font-size: .78rem; line-height: 1.4; margin-top: .22rem; }
.slot { display: block; min-width: 0; position: relative; background: transparent; padding: 0; border: 0; border-radius: .62rem; container-type: inline-size; }
button.slot:hover { transform: translateY(-2px); box-shadow: 0 6px 9px #12152c70; }
button.slot:active { transform: translateY(1px); }
.face { width: 100%; height: 100%; position: absolute; inset: 0; display: grid; place-items: center; border: 1px solid #ffffff35; border-radius: inherit; overflow: hidden; background: var(--card-bg); color: #242545; font-family: var(--display); }
.demo-card { border-radius: clamp(.65rem, 2vw, 1.05rem); }
.face::before { content: ""; position: absolute; inset: 6%; border: 1px solid #25254a42; border-radius: .32em; pointer-events: none; }
.face strong { font-size: 53cqi; line-height: .9; font-weight: 800; letter-spacing: -.035em; }
.face.back {
  color: #d4d9ff;
  background-color: #434f83;
  background-image: repeating-radial-gradient(circle at center, transparent 0 6px, #c6cfff20 7px 8px);
  border-color: #818eb9;
}
.face.back::before { border-color: #abb4e693; }
.face.back svg { width: 48%; height: 48%; }
.card-motion-layer { position: fixed; inset: 0; z-index: 2; pointer-events: none; overflow: clip; }
.flying-card.slot { position: absolute; box-shadow: 0 6px 12px #12152c65; }
.slot:has(> .card-in-flight) { box-shadow: inset 0 0 0 1px var(--panel-edge); }
.table-button { background: #2c365c; border-color: #7784ac; color: var(--night-text); }
.table-button:hover { background: #434e79; }
.last-move { color: var(--night-muted); font-size: .79rem; overflow-wrap: anywhere; margin: .45rem 0; }
.score-panel { background: var(--paper); color: var(--ink); border-radius: .9rem; padding: clamp(.9rem, 3vw, 1.5rem); --focus: #5840ac; }
.score-panel h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
.score-panel p { margin-top: .45rem; }
.score-panel .score-note { color: #752545; font-weight: 760; }
.score-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .75rem; }

dialog { width: min(calc(100% - 2rem), 36rem); max-height: min(calc(100% - 2rem), 45rem); padding: 0; border: 1px solid #9e9fb6; border-radius: .9rem; background: var(--paper); color: var(--ink); --focus: #5840ac; box-shadow: 0 8px 20px #0003; }
dialog::backdrop { background: #0e1228aa; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .7rem 1rem .65rem; border-bottom: 1px solid var(--rule); }
.sheet-head h2 { font-size: clamp(1.35rem, 5vw, 2rem); }
.close-button { width: 44px; padding: 0; border-color: #a4a5b3; }
.close-button:hover { background: #eae7dc; }
.sheet-body { padding: .9rem 1rem 1.2rem; }
.rules-list { padding-left: 1.4rem; line-height: 1.65; }
.rules-list li + li { margin-top: .58rem; }
.rules-source, .dialog-actions, .share-input { margin-top: .85rem; }
.score-scroll { overflow-x: auto; margin-top: .65rem; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; line-height: 1.35; font-variant-numeric: tabular-nums; }
.score-panel table { margin-top: .65rem; }
th, td { padding: .5rem .6rem .5rem .1rem; border-bottom: 1px solid var(--rule); text-align: left; overflow-wrap: anywhere; }
td { text-align: right; }
thead th:not(:first-child) { text-align: right; }
th small { color: var(--muted); font-weight: 700; }
.score-scroll th { min-width: 4.5rem; }
.score-scroll td { white-space: nowrap; }

@media (min-width: 38rem) {
  .lobby-layout { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
}
@media (min-width: 49rem) {
}
@media (min-width: 68rem) {
}
@media (min-width: 49rem) {
  .header-inner { min-height: 4.65rem; }
  .home-grid { grid-template-columns: minmax(0, .91fr) minmax(0, 1.33fr); gap: clamp(1.5rem, 4vw, 4rem); align-items: stretch; }
  .intro { padding-block: .6rem .9rem; }
  .mode-list { max-width: 24rem; margin-top: 1.45rem; }
  .mode-button { min-height: 53px; }
  .showcase-art { min-height: clamp(19rem, 29vw, 25rem); }
  .showcase-caption { min-height: 5.2rem; }
  .turn-strip { padding-inline: 1.05rem; }
}
@media (max-width: 22rem) {
  .wordmark-table { display: none; }
  .mode-button { padding-inline: .62rem; }
  .game-id { font-size: .75rem; }
  .score-link { font-size: .8rem; }
  .play-toolbar { align-items: start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
.lobby-seats li:has(.release-button) { grid-template-columns: auto minmax(0, 1fr) auto auto; }
.release-button { width: 44px; padding: 0; }
.release-button:hover { background: #eae7dc; }

[hidden] { display: none !important; }
.whist-art { min-height: clamp(15rem, 35vw, 26rem); }
.whist-face { --card-bg: #fffcf3; color: #151a32; }
.whist-face.red-suit { color: #a3243c; }
.face.back img { width: 48%; height: auto; opacity: .93; }
.card-value { display: grid; justify-items: center; gap: 6cqi; font-family: var(--body); }
.card-value b { font-size: 48cqi; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; }
.card-value svg { width: 25cqi; height: 25cqi; }
.deck-mark, .trick-play .slot, .whist-hand .slot { aspect-ratio: 3 / 4; }

.setup { min-width: 0; margin: .6rem 0; padding: 0; border: 0; }
.setup legend { font-weight: 800; font-size: .92rem; margin-bottom: .55rem; }
.variants { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 7rem), 1fr)); gap: .4rem; }
.variants label { display: flex; align-items: center; gap: .42rem; min-height: 45px; padding: .45rem .55rem; border: 1px solid #a4a5b3; border-radius: .6rem; line-height: 1.25; }
.variants label:has(:checked) { background: #e6ddff; border-color: #7563b3; }
.variants input, .dog-option input { min-height: 0; padding: 0; width: 1rem; height: 1rem; margin: 0; flex: 0 0 auto; }
.mode-description { margin: .65rem 0 .75rem; font-size: .9rem; color: var(--muted); }
.setup [data-option="cards"] { display: grid; grid-template-columns: 1fr 5rem; align-items: center; gap: .6rem; }
.dog-option { display: flex; gap: .55rem; align-items: center; min-height: 44px; }
.lobby-seats details { margin: .8rem 0; }
.lobby-seats summary { cursor: pointer; padding: .35rem 0; width: fit-content; }
.lobby-seats .setup { margin: .45rem 0; }
.lobby-seats .setup .mode-description { margin: .55rem 0; }
.release-button { font-size: 1.2rem; }
.form-error { margin: .5rem 0; }
.at-table .form-error { color: #ffb5c0; }

.whist-table { color: var(--night-text); max-width: 66rem; padding-block: .7rem 2rem; overflow-anchor: none; }
.trump-chip { display: flex; align-items: center; justify-content: flex-end; flex: 0 0 6.5rem; gap: .38rem; font-size: .78rem; font-weight: 800; }
.trump-chip svg { flex: 0 0 auto; }
.trump-chip svg, .choice-row svg { width: 1rem; height: 1rem; }
.whist-grid { display: grid; gap: .65rem; margin-top: .65rem; }
.whist-grid .board-heading > div { min-width: 0; }
.deck-mark { width: 29px; flex: 0 0 auto; margin-right: 3px; box-shadow: 2px 3px 0 #13182e; }
.trick-cards, .whist-hand { display: grid; grid-template-columns: repeat(4, minmax(0, 4.8rem)); gap: .45rem; align-items: start; }
.trick-play { min-width: 0; text-align: center; font-size: .71rem; color: var(--night-muted); line-height: 1.25; }
.trick-name { display: block; color: var(--night-text); font-size: .75rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trick-play .slot { width: 100%; margin-bottom: .3rem; }
.won-trick .slot { outline: 2px solid var(--lime); outline-offset: 1px; }
.won-trick .trick-name { color: var(--lime); }
.card-space { border: 1px dashed var(--panel-edge); }
.empty-trick { grid-column: 1 / -1; color: var(--night-muted); align-self: center; font-size: .9rem; }
.trick-footer { min-height: 1.45rem; margin-top: .5rem; }
.trick-footer .last-move { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.whist-hand .slot { width: 100%; }
.whist-hand button.slot { min-height: 44px; }
.whist-hand .unavailable-card .face { --card-bg: #d9d9d1; }
.whist-hand button.slot:not(:disabled):hover { transform: none; box-shadow: 0 0 0 2px var(--lime); }
.whist-hand .slot:disabled:hover { transform: none; box-shadow: none; }
.choice-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .72rem; }
.choice-row button { min-width: 44px; }
.whist-seats { padding: 0; margin: .6rem 0 0; display: grid; gap: .12rem; list-style: none; }
.whist-seats li { display: flex; align-items: center; justify-content: space-between; gap: .55rem; min-height: 46px; padding: .35rem .5rem; border-radius: .35rem; }
.whist-seats li + li { border-top: 1px solid var(--panel-edge); }
.whist-seats .current-player { background: #30395f; box-shadow: inset 0 0 0 1px #7784ac; }
.whist-seats strong { overflow-wrap: anywhere; }
.seat-info { display: block; color: var(--night-muted); font-size: .74rem; }
.seat-tricks { flex: 0 0 auto; text-align: right; font-size: .86rem; font-variant-numeric: tabular-nums; }
.card-landing > .face { opacity: 0; }
.card-landing { box-shadow: inset 0 0 0 1px var(--panel-edge); }
@media (min-width: 35rem) {
  .trick-cards, .whist-hand { grid-template-columns: repeat(7, minmax(0, 4.8rem)); }
}
@media (min-width: 51rem) {
  .whist-grid { grid-template-columns: minmax(0, 3fr) minmax(12rem, 1fr); grid-template-areas: "trick players" "hand players"; align-items: start; }
  .trick-panel { grid-area: trick; }
  .hand-panel { grid-area: hand; }
  .players-panel { grid-area: players; }
}
