@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; }

.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); }
.flipped .sample-right { animation: turn-over .45s cubic-bezier(.2,.72,.22,1) both; }
@keyframes turn-over {
  0% { transform: translate(75%, 10%) rotate(18deg) scaleX(.12); }
  60%, 100% { transform: translate(75%, 10%) rotate(18deg) scaleX(1); }
}
.clear .demo-card { opacity: .13; }
.clear .sample-left { transform: translate(-30%, 28%) rotate(-7deg) scale(.75); }
.clear .sample-mid { transform: translate(3%, 24%) rotate(4deg) scale(.75); }
.clear .sample-right { transform: translate(34%, 28%) rotate(10deg) scale(.75); }
.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-stamp { background: var(--lavender); color: var(--ink); border-radius: .65rem; display: grid; place-items: center; width: 3.25rem; height: 3.25rem; margin-bottom: 1rem; }
.entry-stamp svg { width: 1.65rem; }
.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; }
.at-table .wordmark { color: var(--night-text); }
.at-table .masthead { border-color: var(--panel-edge); }
.at-table .header-inner { min-height: 3.45rem; }
.at-table .header-rules { border-color: #667192; }
.at-table .header-rules:hover { background: #333d63; color: var(--night-text); }
.play-wrap { max-width: 61rem; padding-block: .7rem 2rem; }
.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.4rem; padding: .7rem .8rem; display: flex; align-items: center; justify-content: space-between; gap: .6rem; border: 1px solid #636e97; border-radius: .75rem; background: #30395f; }
.turn-strip.own-turn { background: var(--lime); color: var(--ink); border-color: var(--lime); }
.turn-strip h1 { font-size: clamp(1.34rem, 4.6vw, 2.05rem); }
.turn-strip p { margin-top: .17rem; font-size: .88rem; line-height: 1.38; }
.final-label { flex-shrink: 0; padding: .35rem .55rem; border: 1px solid currentColor; border-radius: .4rem; font-weight: 800; font-size: .7rem; }
.play-grid { display: grid; grid-template-areas: "piles" "board" "tools" "rival"; gap: .65rem; margin-top: .65rem; }
.play-grid.is-scored { grid-template-areas: "board" "rival"; }
.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); }
.piles { grid-area: piles; }
.pile-row { display: flex; align-items: start; justify-content: flex-start; gap: clamp(.65rem, 4vw, 1rem); margin-top: .55rem; }
.pile-unit { display: grid; gap: .35rem; width: clamp(3rem, 15vw, 4.6rem); text-align: center; }
.pile-label { font-size: .76rem; line-height: 1.2; font-weight: 800; color: var(--night-text); }
.pile-slot { aspect-ratio: 1 / 1.12; }
button.pile-slot::after { content: ''; position: absolute; inset: -3px; border-radius: inherit; border: 1px solid #b1bce8; pointer-events: none; }
.piles .table-button { margin-top: .65rem; }
.your-board { grid-area: board; }
.board-heading { display: flex; align-items: center; justify-content: space-between; gap: .45rem; margin-bottom: .55rem; }
.board-heading p, .rival-summary { color: var(--night-muted); font-size: .78rem; line-height: 1.4; margin-top: .22rem; }
.board-total { display: grid; text-align: right; min-width: 2.6rem; }
.board-total strong { font-family: var(--display); font-size: 1.45rem; line-height: 1; }
.board-total span { color: var(--night-muted); font-size: .7rem; font-weight: 800; }
.card-grid { width: min(100%, 29.5rem); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(.35rem, 1.4vw, .75rem); }
.card-grid .slot { aspect-ratio: 1 / 1.08; }
.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 .index { position: absolute; font-size: 15cqi; line-height: 1; font-weight: 800; }
.index.top { top: 13%; left: 13%; }
.index.bottom { bottom: 13%; right: 13%; transform: rotate(180deg); }
.face.lime { --card-bg: #dbf68d; }
.face.violet { --card-bg: #cabafa; }
.face.ice { --card-bg: #bbece9; }
.face.gold { --card-bg: #f9db88; }
.face.coral { --card-bg: #ffb49f; }
.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%; }
.face.empty { color: #a8b2d4; border: 1px dashed #7c87ad; background: #191f3d; font-size: 48cqi; }
.face.empty::before { display: none; }
.suggested { outline: 2px dashed var(--lime); outline-offset: 3px; }
.suggested:focus-visible { outline-style: solid; }
.opponent { grid-area: rival; }
.seat-tabs { display: flex; flex-wrap: wrap; gap: .25rem .35rem; margin-top: .5rem; }
.opponent-tab { display: inline-flex; align-items: center; justify-content: start; gap: .32rem; min-height: 44px; max-width: 100%; overflow-wrap: anywhere; padding: .35rem .55rem; color: var(--night-text); background: #263052; border: 1px solid #657199; border-radius: .52rem; font-size: .8rem; font-weight: 750; text-align: left; }
.opponent-tab[aria-pressed="true"], .opponent-tab:hover { background: #3c4771; }
.opponent-tab[aria-pressed="true"] { border-color: #c2cbef; }
.opponent-tab strong { font-variant-numeric: tabular-nums; }
.status-dot { border: 1px solid #a9b5db; border-radius: 50%; width: .42rem; height: .42rem; flex-shrink: 0; }
.status-dot.current { background: var(--lime); border-color: var(--lime); }
.mini { width: min(100%, 16rem); margin-top: .55rem; gap: .4rem; }
.mini .slot { border-radius: .4rem; }
.mini .index { display: none; }
.table-tools { grid-area: tools; min-width: 0; }
.tools-buttons { display: flex; flex-wrap: wrap; gap: .45rem; }
.table-button { background: #2c365c; border-color: #7784ac; color: var(--night-text); }
.table-button:hover { background: #434e79; }
.hint-note { background: #273552; border: 1px solid #8aab92; margin-top: .55rem; padding: .55rem .7rem; border-radius: .55rem; }
.hint-note p { margin-top: .2rem; font-size: .83rem; color: var(--night-muted); }
.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; }
.logic-summary { margin-bottom: .55rem; font-weight: 800; }
.logic-summary ~ p { margin-top: .65rem; color: var(--muted); }
.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; }
  .play-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); grid-template-areas: "board piles" "board rival" "tools rival"; grid-template-rows: auto 1fr auto; align-items: start; }
  .play-grid.is-scored { grid-template-areas: "board rival"; grid-template-rows: auto; }
  .your-board .card-grid { margin-inline: auto; }
}
@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; }
