:root {
  color-scheme: light;
  --paper: #f5f5f7;
  --surface: #fff;
  --ink: #1d1e20;
  --dim: #62646b;
  --line: #dedee2;
  --blue: #075db8;
  --space: clamp(16px, 2.6vw, 32px);
  --sans: -apple-system, BlinkMacSystemFont, Inter, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.5 var(--sans);
  -webkit-text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
body { min-height: 100dvh; margin: 0; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--blue); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { color: inherit; font: inherit; }
button, summary { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .55; }
:where(a,button,input,select,textarea,summary,[tabindex]):focus-visible { outline: 3px solid #0071e3; outline-offset: 3px; }
h1, h2, h3, h4, p { margin: 0 0 .6em; }
h1, h2, h3, h4 { line-height: 1.1; text-wrap: balance; }
h1, h2, h3, .card > strong, .brand { letter-spacing: -.045em; font-weight: 650; }
h1 { font-size: clamp(2.4rem, 5vw, 4.8rem); }
h2 { font-size: clamp(1.55rem, 2.5vw, 2.15rem); }
h3 { font-size: 1.15rem; }
p:last-child, ul:last-child, ol:last-child { margin-bottom: 0; }
code, kbd { font: .9em/1.4 var(--mono); overflow-wrap: anywhere; }
hr { margin-block: 1.5rem; border: 0; border-top: 1px solid var(--line); }
::selection { color: #132d50; background: #cee4fe; }

.mast {
  display: flex; align-items: center; gap: clamp(12px,3vw,44px);
  padding: 11px max(var(--space), calc((100% - 1200px) / 2));
  background: #fff; border-bottom: 1px solid #e4e4e7;
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-size: 1.12rem; line-height: 1.1; white-space: nowrap; text-decoration: none; }
.brand :is(svg,img) { width: 31px; height: 31px; }
.nav, .mast nav, .tabs { display: flex; align-items: center; gap: 4px; }
.mast :is(.nav,nav) { flex: 1; }
.nav :is(a,button), .mast nav :is(a,button), .tabs :is(a,button) {
  display: inline-flex; align-items: center; justify-content: center; min-height: 39px;
  padding: 7px 14px; border: 1px solid transparent; border-radius: 99px;
  background: transparent; color: #595c63; font-size: .91rem; font-weight: 550; white-space: nowrap; text-decoration: none;
}
.nav :is(a,button):hover, .mast nav :is(a,button):hover, .tabs :is(a,button):hover { color: var(--ink); background: #f2f2f4; }
.nav .active, .mast nav [aria-current="page"], .tabs :is(.active,.primary,[aria-selected="true"],[aria-current="page"]) { background: #e9eaed; color: var(--ink); }
.mast > :last-child:not(.nav):not(nav) { margin-inline-start: auto; }
.wrap, .foot { width: min(100%, calc(1200px + 2 * var(--space))); margin: 0 auto; padding-inline: var(--space); }
.wrap { padding-block: var(--space) 3.5rem; }
.wrap > * + * { margin-top: var(--space); }
.wrap > .over + .toolbar { margin-top: .3rem; }
.hero {
  display: grid; grid-template-columns: minmax(0,.85fr) minmax(0,1.15fr); align-items: stretch; isolation: isolate;
  min-height: clamp(330px,35vw,470px); overflow: hidden; border: 1px solid #e4e3e1; border-radius: 24px;
  background: #faf9f7;
}
.hero > div:first-child { z-index: 1; align-self: center; min-width: 0; padding: clamp(26px,3.8vw,58px); }
.hero h1 { margin-bottom: .18em; max-width: 10ch; font-size: clamp(3.45rem,6.5vw,6.15rem); line-height: .95; letter-spacing: -.073em; text-wrap: initial; font-weight: 670; }
.hero h1 :is(em,span) { font-style: normal; }
.hero .over { margin-bottom: 1.25rem; }
.hero p:not(.over) { max-width: 32ch; margin: 1.2rem 0 1.6rem; color: #57585c; font-size: clamp(1rem,1.38vw,1.17rem); line-height: 1.4; }
.hero > img, .hero picture, .hero picture img { width: 100%; height: 100%; min-height: 0; object-fit: cover; object-position: 50% 55%; }
.hero > img, .hero picture { align-self: stretch; mask-image: linear-gradient(to right,transparent,#000 14%); }
.over { display: block; margin: 0 0 .6rem; color: var(--dim); font-size: .72rem; line-height: 1.3; font-weight: 650; text-transform: uppercase; letter-spacing: .085em; }
.primary, .secondary, .danger, .game-clock, button:not([class]) {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em; min-height: 43px;
  padding: .6rem 1.08rem; border: 1px solid #d5d6da; border-radius: 99px;
  background: var(--surface); color: var(--ink); font-weight: 575; line-height: 1.2; text-decoration: none; text-align: center;
}
.primary, .game-clock, .mast #connect { border-color: var(--blue); background: var(--blue); color: #fff; }
.primary:hover:not(:disabled), .game-clock:hover:not(:disabled), .mast #connect:hover { background: #074e95; }
.secondary:hover:not(:disabled), button:not([class]):hover:not(:disabled) { border-color: #b5b7bd; background: #f2f3f4; }
.danger { color: #a32a28; background: #fff; border-color: #e4cdcd; }
.danger:hover:not(:disabled) { background: #fff1f0; }
:is(.primary,.secondary,.danger,.game-clock):active:not(:disabled) { transform: translateY(1px); }
.game-clock { width: 100%; min-height: 48px; margin: .4rem 0; font-weight: 650; border-radius: 12px; }
.toolbar, .row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.toolbar { justify-content: space-between; }
.toolbar :is(h1,h2,h3,p), .row :is(h2,h3,h4) { margin-block: 0; }
.toolbar > div > p:not(.over) { margin-top: .55rem; color: var(--dim); }
.toolbar .over { margin-bottom: .45rem; }
.toolbar + :is(.cards,.history,.muted,p,.walletline) { margin-top: 14px; }
.tabs { flex-wrap: wrap; padding-bottom: .6rem; border-bottom: 1px solid var(--line); }
.grid, .cards, .tabletop, .formgrid, .lobby-grid { display: grid; gap: var(--space); }
.grid, .lobby-grid { grid-template-columns: minmax(0,1.45fr) minmax(0,1fr); align-items: start; }
.cards { grid-template-columns: repeat(auto-fill,minmax(min(213px,100%),1fr)); gap: 15px; }
.panel, .card, dialog, .match-chat, .lobby-feed {
  min-width: 0; padding: clamp(18px,2.45vw,32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; color: var(--ink);
}
.sidebar { min-width: 0; }
.card { display: grid; align-content: start; justify-items: start; gap: 2px; text-align: left; overflow-wrap: anywhere; }
button.card:hover { border-color: #aeb7c3; box-shadow: 0 4px 18px #2325280c; }
.card :is(h3,strong) { margin-bottom: .15rem; }
.card > strong { font-size: 1.3rem; line-height: 1.15; }
.card > small, .card p, .muted { color: var(--dim); }
.card > .over { margin: .9rem 0 .2rem; font-size: .63rem; }
.card > :is(.piece-sprite,.piece-token,svg) { justify-self: center; width: 122px; height: 122px; }
.card button + button { margin-inline-start: 5px; }
.stack { display: grid; align-content: start; gap: 14px; }
.stack > *, .sidebar > *, .grid > *, .formgrid > *, .lobby-grid > * { min-width: 0; }
.sidebar > * + * { margin-top: 14px; }
.sidebar.stack > * + * { margin-top: 0; }
.tag { display: inline-block; align-self: center; padding: 4px 10px; color: #52555c; background: #ededf0; border: 1px solid #dddfe3; border-radius: 99px; font-size: .76rem; font-weight: 580; overflow-wrap: anywhere; }
.notice, .error { padding: .8rem 1rem; border: 1px solid #c5dbef; border-radius: 10px; background: #eff6fb; color: #234562; overflow-wrap: anywhere; }
.error { border-color: #e2c1c0; background: #fff3f2; color: #833432; }
.notice:empty, .error:empty, .toast:empty { display: none; }

.tabletop { grid-template-columns: minmax(0,1.65fr) minmax(270px,.87fr); align-items: start; gap: clamp(14px,2vw,26px); }
.board-shell, .boardwrap {
  min-width: 0; padding: clamp(6px,1.3vw,15px); border: 1px solid #dad7d2; border-radius: 16px;
  background: #efeeeb; box-shadow: 0 2px 8px #2c22100a;
}
.board, .net-board { display: grid; grid-template-columns: repeat(8,minmax(0,1fr)); width: 100%; margin: 0 auto; overflow: hidden; border-radius: 5px; isolation: isolate; }
.net-board { --files: 8; grid-template-columns: repeat(var(--files),minmax(0,1fr)); max-width: min(100%,calc(var(--files) * clamp(42px,8dvh,90px))); }
.net-board[data-width="4"] { --files: 4; }
.net-board[data-width="5"] { --files: 5; }
.net-board[data-width="6"] { --files: 6; }
.net-board[data-width="7"] { --files: 7; }
.net-board[data-width="8"] { --files: 8; }
.net-board[data-width="9"] { --files: 9; }
.net-board[data-width="10"] { --files: 10; }
.net-board[data-width="11"] { --files: 11; }
.net-board[data-width="12"] { --files: 12; }
.net-board[data-width="13"] { --files: 13; }
.net-board[data-width="14"] { --files: 14; }
.net-board[data-width="15"] { --files: 15; }
.net-board[data-width="16"] { --files: 16; }
.sq, .square, .meme-square, .masked {
  position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; width: 100%; aspect-ratio: 1;
  padding: 0; border: 0; border-radius: 0; box-shadow: none; line-height: 1; touch-action: manipulation;
}
:is(.sq,.square,.meme-square), :is(.sq,.square,.meme-square).light { background: #ede3d4; color: #433a2f; }
:is(.sq,.square,.meme-square).dark { background: #a3917e; color: #211d18; }
:is(.sq,.square,.meme-square).masked, .masked { background: transparent; border: 0; pointer-events: none; }
:is(.sq,.square,.meme-square):disabled { cursor: default; opacity: 1; }
:is(.sq,.square,.meme-square):focus-visible { outline-offset: -3px; z-index: 3; }
:is(.sq,.square,.meme-square):is(:hover:not(:disabled),.last,.last-square,.selected,[aria-pressed="true"])::after {
  content: ""; position: absolute; z-index: 2; inset: 0; box-shadow: inset 0 0 0 2px #473c30; pointer-events: none;
}
:is(.sq,.square,.meme-square):is(.last,.last-square)::after { box-shadow: inset 0 0 0 3px #82672c; }
:is(.sq,.square,.meme-square):is(.selected,[aria-pressed="true"])::after { box-shadow: inset 0 0 0 clamp(2px,.43vw,5px) #075fb9; }
.legal-target::before, .capture-target::before { content: ""; z-index: 3; position: absolute; pointer-events: none; border-radius: 50%; }
.legal-target::before { width: 22%; aspect-ratio: 1; background: #356e929c; box-shadow: 0 0 0 1px #ffffffa0; }
.capture-target::before { inset: 5%; border: clamp(2px,.4vw,5px) solid #b94337; box-shadow: 0 0 0 1px #ffffff90; }
.piece-sprite, .piece-token { display: block; width: 55px; height: 55px; max-width: 100%; object-fit: contain; pointer-events: none; }
:is(.sq,.square,.meme-square) :is(svg,.piece-sprite,.piece-token) { position: relative; z-index: 1; width: 88%; height: 88%; max-height: 100%; pointer-events: none; }
.nic-stage { position:absolute; z-index:2; top:2%; right:3%; padding:0 3px; border-radius:3px; background:#342856; color:white; font-size:clamp(8px,.7vw,12px); font-weight:750; pointer-events:none; }
.side-plinth {
  position: absolute; z-index: 2; bottom: 4%; left: 19%; display: grid; place-items: center; width: 62%; height: 17%;
  border: 1px solid #625d54; border-radius: 50% / 35%; color: #302d27;
  background: linear-gradient(#fffef8 0 26%,#e7e2d7 32%,#f8f4eb 71%,#c4bbaa);
  box-shadow: 0 1px 1px #201c1c66; font: 750 clamp(6px,.72vw,9px)/1 var(--sans); pointer-events: none;
}
.side-plinth:is(.black,[data-side="black"]), [data-side="black"] > .side-plinth {
  background: linear-gradient(#5b5b5d 0 20%,#222328 36%,#38393b 70%,#121316);
  color: #fff; border-color: #1b1b1e; box-shadow: inset 0 1px 0 #909092,0 1px 1px #201c1c66;
}
:is(.sq,.square,.meme-square):has(.side-plinth) > :is(.piece-token,.piece-sprite) { transform: translateY(-5%); }
.meme-square.edit-hole, .square.edit-hole {
  border: 1px dashed #a4aab1;
  background: repeating-linear-gradient(132deg,#e5e8ec 0 6px,#f6f7f9 6px 12px); color: #545d69;
}
.meme-square.edit-hole:hover, .square.edit-hole:hover { border-color: var(--blue); }
.piece-token { position: relative; display: grid; place-items: start center; isolation: isolate; container-type: inline-size; }
.piece-token .token-face {
  position: absolute; top: 7%; left: 17%; z-index: 2; display: grid; place-items: center; width: 66%; aspect-ratio: 1;
  overflow: hidden; border: 2px solid #534e49; border-radius: 48%; background: #fff3d8; color: #242423; font: 650 32cqi/1 var(--sans); text-align: center; object-fit: cover;
}
.piece-token .token-face img { width: 100%; height: 100%; object-fit: cover; }
.piece-token .piece-base { position: absolute; bottom: 6%; left: 13%; width: 74%; height: 38%; background: #504c48; clip-path: polygon(32% 0,68% 0,73% 48%,92% 65%,93% 76%,100% 82%,100% 100%,0 100%,0 82%,7% 76%,8% 65%,27% 48%); }
.piece-token .piece-base::after { content: ""; position: absolute; inset: 1px; background: linear-gradient(90deg,#bca78a,#fff8e8 43%,#c7ae8c); clip-path: inherit; }
.piece-token:is(.dark,.black,[data-side="black"]) .token-face { border-color: #e2ded8; background: #313134; color: #fff; }
.piece-token:is(.dark,.black,[data-side="black"]) .piece-base { background: #d2cfca; }
.piece-token:is(.dark,.black,[data-side="black"]) .piece-base::after { background: linear-gradient(90deg,#161619,#646466 43%,#262629); }
.inspected { display: grid; grid-template-columns: 52px minmax(0,1fr); align-items: center; gap: 2px 12px; margin-block: 1rem; padding: .8rem; border: 1px solid #dce0e4; border-radius: 12px; background: #f5f6f8; }
.inspected > :is(.piece-sprite,.piece-token) { grid-row: 1 / span 2; width: 52px; height: 52px; }
.inspected :is(h3,p) { margin: 0; }
.inspected p { color: var(--dim); font-size: .88rem; }
.inspected p:last-child { grid-column: 1 / -1; padding-top: .4rem; color: var(--ink); }
.inspected:not(:has(.piece-sprite,.piece-token)) { display: block; }
.inspected small { display: inline-block; margin-top: .45rem; color: #4b5561; }
.coord { position: absolute; bottom: 2px; left: 2px; z-index: 2; pointer-events: none; font: 650 clamp(7px,1vw,10px)/1 var(--mono); }
.history { max-height: 22rem; margin-block: .5rem; overflow: auto; overflow-wrap: anywhere; scrollbar-color: #c1c3ca var(--surface); scrollbar-width: thin; }
ol.history, ul.history { padding-left: 1.6rem; }
.history li { padding-block: .35rem; }
.history > :not(:first-child) { border-top: 1px solid var(--line); }
.match-chat :is(.history,[role="log"]), .lobby-feed :is(.history,[role="log"]) { max-height: 20rem; overflow: auto; overflow-wrap: anywhere; }
.match-chat .history p, .lobby-feed .history p { margin: 0; padding-block: .55rem; }
:is(.match-chat,.lobby-feed) strong { color: #224a6e; }
:is(.match-chat,.lobby-feed) label { margin-top: .6rem; }
:is(.match-chat,.lobby-feed) .row { align-items: end; }
:is(.match-chat,.lobby-feed) .row label { flex: 1 1 135px; }

.formgrid { grid-template-columns: repeat(auto-fit,minmax(min(205px,100%),1fr)); gap: 14px; max-height: 35vh; overflow: auto; padding: 4px; }
label { display: grid; gap: 6px; font-size: .93rem; font-weight: 570; }
label:has(input[type="checkbox"]), label:has(input[type="radio"]) { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; max-width: 100%; min-width: 0; min-height: 43px; padding: .58rem .75rem;
  border: 1px solid #bdc1c7; border-radius: 9px; background: var(--surface);
}
input::placeholder, textarea::placeholder { color: #74767e; }
input[type="file"]::file-selector-button { margin-inline-end: 8px; padding: .3em .6em; background: #f3f4f6; border: 1px solid #bfc2ca; border-radius: 6px; color: var(--ink); }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; accent-color: var(--blue); }
textarea { resize: vertical; min-height: 76px; }
fieldset { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
legend { font-weight: 620; padding: 0 5px; }
.modal > * + *, .panel > label, .panel > button { margin-top: .65rem; }
.modal :is(.primary,.secondary,.danger) + button, .panel :is(.primary,.secondary,.danger) + button { margin-inline-start: .4rem; }
.walletline, .ledger { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.walletline { display: flex; align-items: center; justify-content: space-between; gap: .85rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.walletline > div { min-width: 0; }
.walletline :is(.token-icon,img) { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.walletline small, .modal small { display: block; overflow-wrap: anywhere; color: var(--dim); }
.ledger { width: 100%; border-collapse: collapse; }
.ledger th, .ledger td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: start; }
.ledger th { font-size: .78rem; color: var(--dim); }
.ledger code { font-size: .81rem; }
.document { max-width: 78ch; margin-inline: auto; padding: clamp(20px,4vw,48px); }
.document > a:first-child { display: inline-block; margin-bottom: 2rem; }
.document h1 { font-size: clamp(2.35rem,4.4vw,3.85rem); }
.document h2 { margin-top: 1.35em; font-size: clamp(1.45rem,2.6vw,2rem); }
.document h3 { margin-top: 1.25em; }
.document li + li { margin-top: .45em; }
.foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 18px; padding-block: 22px 32px; color: var(--dim); border-top: 1px solid var(--line); font-size: .86rem; }
.foot :is(div,nav) { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.foot a { color: inherit; }
.toast { position: fixed; z-index: 9; bottom: max(16px,env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(35rem,90vw); padding: 12px 18px; border-radius: 11px; background: #26272a; color: #fff; box-shadow: 0 4px 20px #15171b30; overflow-wrap: anywhere; }
.toast.error { background: #953a35; color: #fff; }
dialog, .modal { max-height: 88dvh; overflow-y: auto; }
dialog { width: min(36rem,calc(100% - 26px)); padding: clamp(20px,3vw,32px); box-shadow: 0 20px 70px #12151e24; }
dialog::backdrop { background: #20212666; }
dialog form > * + *, dialog > .secondary { margin-top: 13px; }
@media (max-width: 950px) {
  .mast { gap: 10px; flex-wrap: wrap; }
  .nav :is(a,button), .mast nav :is(a,button) { padding-inline: 9px; }
  .hero { grid-template-columns: minmax(0,.9fr) minmax(0,1.1fr); }
  .tabletop { grid-template-columns: minmax(0,1.6fr) minmax(235px,.85fr); }
}
@media (max-width: 730px) {
  .mast { padding-block: 9px 5px; }
  .mast :is(.nav,nav) { order: 5; flex: 1 1 100%; overflow-x: auto; scrollbar-width: thin; }
  .hero, .grid, .tabletop, .lobby-grid { grid-template-columns: minmax(0,1fr); }
  .tabletop > .stack { display: contents; }
  .tabletop > .sidebar > .panel:first-child { order: 1; }
  .tabletop .match-chat { order: 2; }
  .tabletop > div.stack > section { order: 3; }
  .hero { min-height: 0; }
  .hero > div:first-child { padding: 24px; }
  .hero h1 { max-width: none; font-size: clamp(2.65rem,8.45vw,4.3rem); }
  .hero > img, .hero picture { height: auto; aspect-ratio: 16 / 8; mask-image: none; }
  .wrap { padding-bottom: 28px; }
  .board-shell, .boardwrap { padding: 5px; }
  .coord { font-size: 7px; }
  .foot { align-items: start; justify-content: start; }
  .ledger { font-size: .85rem; }
  .ledger th, .ledger td { padding: 8px 4px; }
  .row input:not([type="checkbox"]):not([type="radio"]) { flex-basis: 100%; }
}
@media (max-width: 480px) {
  .cards { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .card { padding: 13px; }
  .card > strong { font-size: 1.09rem; }
  .card > .over { font-size: .6rem; }
  .card > :is(.piece-sprite,.piece-token,svg) { width: 90px; height: 90px; }
  .mast .secondary { min-height: 37px; padding-inline: 10px; }
  .hero > div:first-child { padding: 20px; }
  .walletline[data-coin] { flex-wrap: wrap; }
  .walletline[data-coin] > label { flex: 1 0 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::after, *::before { scroll-behavior: auto !important; }
  :is(.primary,.secondary,.danger,.game-clock):active:not(:disabled) { transform: none; }
}
