/* The board, rack and miniature theme previews share these materials. */
:root, .theme-sample {
  color-scheme: light;
  --paper: #f6f4ec;
  --surface: #fffef9;
  --text: #20382f;
  --sub: #495e52;
  --muted: #d8ded3;
  --line: #cbd4c8;
  --brand: #204e41;
  --brandwhite: #fffcf0;
  --pale: #e4eee4;
  --board: #b0bdaa;
  --square: #e6eade;
  --axis: #d5dfcf;
  --dw: #e6ada8;
  --dw-ink: #522b2c;
  --tw: #c87866;
  --tw-ink: #361a16;
  --dl: #adcfdb;
  --dl-ink: #213a46;
  --tl: #73a8ad;
  --tl-ink: #0e3037;
  --tile-top: #fff1d3;
  --tile-bottom: #ead7ac;
  --inktile: #26362c;
  --tile-edge: #bcaa80;
  --tile-shade: #9c895f;
  --frame: #456452;
  --rail: #698577;
  --hero-base: #193e36;
  --hero-top: #365e4c;
  --hero-ink: #fff9e7;
  --hero-soft: #e3ebdf;
  --accent: #f1d59d;
  --accent-ink: #233e32;
  --draft-top: #fae2a5;
  --draft-bottom: #e8bc72;
  --draft-ink: #3e2c0a;
  --cursor: #184b40;
  --recent: #55755b;
  --focus: #96580f;
  --grain: none;
  --grain-size: auto;
  --letter: var(--tile-top);
  --gold: var(--accent);
}

:root[data-theme="dark"], .theme-sample[data-theme="dark"] {
  color-scheme: dark;
  --paper: #101620;
  --surface: #1b2533;
  --text: #f0f3fa;
  --sub: #b8c4d5;
  --muted: #344052;
  --line: #515e75;
  --brand: #b8caff;
  --brandwhite: #182338;
  --pale: #29374b;
  --board: #374656;
  --square: #242f3e;
  --axis: #1c2735;
  --dw: #633a50;
  --dw-ink: #ffe6ee;
  --tw: #813d4b;
  --tw-ink: #fff0f3;
  --dl: #2d465e;
  --dl-ink: #d4eaff;
  --tl: #315b67;
  --tl-ink: #e3fcff;
  --tile-top: #405064;
  --tile-bottom: #354255;
  --inktile: #faf1d9;
  --tile-edge: #647489;
  --tile-shade: #1b2532;
  --frame: #252f40;
  --rail: #626d80;
  --hero-base: #151d28;
  --hero-top: #293950;
  --hero-ink: #f5f3ed;
  --hero-soft: #d9e3f1;
  --accent: #e0be85;
  --accent-ink: #251e17;
  --draft-top: #685238;
  --draft-bottom: #56412c;
  --draft-ink: #fff1d2;
  --cursor: #ffdd9a;
  --recent: #b7caff;
  --focus: #ffc981;
}

:root[data-theme="wood"], .theme-sample[data-theme="wood"] {
  color-scheme: light;
  --paper: #eee4cf;
  --surface: #fbf5e8;
  --text: #392a20;
  --sub: #64503e;
  --muted: #e3d5bd;
  --line: #bbae96;
  --brand: #674530;
  --brandwhite: #fff7e7;
  --pale: #eee1c9;
  --board: #b28f66;
  --square: #dcc49f;
  --axis: #ead6b6;
  --dw: #d99d84;
  --dw-ink: #492018;
  --tw: #cd8066;
  --tw-ink: #33150c;
  --dl: #b4c5b8;
  --dl-ink: #253c32;
  --tl: #869f91;
  --tl-ink: #152c26;
  --tile-top: #ffe9bd;
  --tile-bottom: #eaca93;
  --inktile: #3f2818;
  --tile-edge: #b49160;
  --tile-shade: #95703f;
  --frame: #735035;
  --rail: #9d794c;
  --hero-base: #563421;
  --hero-top: #805a3d;
  --hero-ink: #fff6e0;
  --hero-soft: #f8e7cf;
  --accent: #eac488;
  --accent-ink: #342514;
  --draft-top: #f5ce86;
  --draft-bottom: #e7b567;
  --draft-ink: #3a240b;
  --cursor: #57351d;
  --recent: #85522b;
  --focus: #915510;
}

:root[data-theme="coast"], .theme-sample[data-theme="coast"] {
  color-scheme: light;
  --paper: #eaf5f3;
  --surface: #f7fcfb;
  --text: #153d49;
  --sub: #3c6069;
  --muted: #d1e7e3;
  --line: #b3cdcd;
  --brand: #176273;
  --brandwhite: #f6ffff;
  --pale: #d8eeeb;
  --board: #95bdc0;
  --square: #d7eae5;
  --axis: #c5e2df;
  --dw: #f3c3ae;
  --dw-ink: #653126;
  --tw: #e5a08e;
  --tw-ink: #52261e;
  --dl: #bddfed;
  --dl-ink: #1c4253;
  --tl: #85c8cd;
  --tl-ink: #153c46;
  --tile-top: #fafff9;
  --tile-bottom: #d8efea;
  --inktile: #173f49;
  --tile-edge: #a3c9c3;
  --tile-shade: #79a9a8;
  --frame: #387680;
  --rail: #77a5a2;
  --hero-base: #174f61;
  --hero-top: #2b6d7a;
  --hero-ink: #f4fffb;
  --hero-soft: #def5ef;
  --accent: #f2deb1;
  --accent-ink: #183d43;
  --draft-top: #f9ddaa;
  --draft-bottom: #e9c281;
  --draft-ink: #533419;
  --cursor: #14485a;
  --recent: #246e72;
  --focus: #9c4c22;
}

:root[data-theme="deco"], .theme-sample[data-theme="deco"] {
  color-scheme: dark;
  --paper: #102728;
  --surface: #193335;
  --text: #f4edda;
  --sub: #c4d0c4;
  --muted: #314c48;
  --line: #53685d;
  --brand: #ead098;
  --brandwhite: #28352e;
  --pale: #28453f;
  --board: #57716a;
  --square: #294842;
  --axis: #1b3534;
  --dw: #6b4350;
  --dw-ink: #ffdfdc;
  --tw: #82463f;
  --tw-ink: #ffebe3;
  --dl: #314c67;
  --dl-ink: #e4eaff;
  --tl: #256065;
  --tl-ink: #e2f7ed;
  --tile-top: #f8eccd;
  --tile-bottom: #ddca9e;
  --inktile: #243b33;
  --tile-edge: #b9a16f;
  --tile-shade: #75623d;
  --frame: #b49864;
  --rail: #d2ba83;
  --hero-base: #193439;
  --hero-top: #305450;
  --hero-ink: #fff3d2;
  --hero-soft: #e8e3cf;
  --accent: #e7c88e;
  --accent-ink: #2f3526;
  --draft-top: #f7d581;
  --draft-bottom: #dfb65f;
  --draft-ink: #463110;
  --cursor: #ffe2a4;
  --recent: #e7c88e;
  --focus: #f4ce87;
}

/* Honor a system default before the client resolves the device preference. */
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --paper: #101620;
    --surface: #1b2533;
    --text: #f0f3fa;
    --sub: #b8c4d5;
    --muted: #344052;
    --line: #515e75;
    --brand: #b8caff;
    --brandwhite: #182338;
    --pale: #29374b;
    --board: #374656;
    --square: #242f3e;
    --axis: #1c2735;
    --dw: #633a50;
    --dw-ink: #ffe6ee;
    --tw: #813d4b;
    --tw-ink: #fff0f3;
    --dl: #2d465e;
    --dl-ink: #d4eaff;
    --tl: #315b67;
    --tl-ink: #e3fcff;
    --tile-top: #405064;
    --tile-bottom: #354255;
    --inktile: #faf1d9;
    --tile-edge: #647489;
    --tile-shade: #1b2532;
    --frame: #252f40;
    --rail: #626d80;
    --hero-base: #151d28;
    --hero-top: #293950;
    --hero-ink: #f5f3ed;
    --hero-soft: #d9e3f1;
    --accent: #e0be85;
    --accent-ink: #251e17;
    --draft-top: #685238;
    --draft-bottom: #56412c;
    --draft-ink: #fff1d2;
    --cursor: #ffdd9a;
    --recent: #b7caff;
    --focus: #ffc981;
  }
}

:root[data-theme="wood"], .theme-sample[data-theme="wood"] {
  --grain: url("/wood-grain.webp");
  --grain-size: 245px 122px;
}

.hero, .invite {
  color: var(--hero-ink);
  background-color: var(--hero-base);
  background-image: var(--grain), radial-gradient(ellipse at 85% 8%,var(--hero-top),transparent 70%);
  background-size: var(--grain-size),cover;
  border-color: var(--frame);
}
.hero :is(.herolink,.hero-alt), .invite .hero-alt {color: var(--hero-ink);}
.hero p, .invite p {color: var(--hero-soft);}
.gold,.roomcode,.herolink .ico {color: var(--accent);}
.brass,.result .brass {background: var(--accent);color: var(--accent-ink);border-color: var(--accent);box-shadow: 0 2px 0 var(--tile-shade);}
.brandmark {background: var(--hero-base);color: var(--accent);border-color: var(--accent);outline-color: var(--hero-base);box-shadow: 2px 2px 0 var(--tile-shade);}
.artframe {border-color: var(--rail);background-color: var(--frame);}
.artgrid {background: var(--board);border-color: var(--frame);}
.artcell:not(.TW,.DW,.TL,.DL) {background: var(--square);}
.arttile,.loose,.racktile:not(.spent),.sq.tile,.sample-letter,.login-mark {
  background-color: var(--tile-top);
  background-image: var(--grain),linear-gradient(145deg,var(--tile-top),var(--tile-bottom));
  background-size: var(--grain-size),cover;
  color: var(--inktile);border-color: var(--tile-edge);
}
.arttile,.sq.tile,.racktile:not(.spent),.sample-letter,.login-mark {box-shadow: inset 0 1px 0 #ffffff35,0 2px 0 var(--tile-shade);}
.loose {box-shadow: 0 4px 0 var(--tile-shade),0 10px 10px #10181070;}
.sq.draft {background: linear-gradient(140deg,var(--draft-top),var(--draft-bottom));color: var(--draft-ink);border: 1px dashed var(--draft-ink);box-shadow: inset 0 -2px var(--draft-ink);}
.sq.recent {box-shadow: inset 0 -3px var(--recent);}
.board-well > .board-shell, .artframe, .theme-sample {
  background-color: var(--frame);background-image: var(--grain);background-size: var(--grain-size);border-color: var(--rail);
}
.sq,.axis {color: var(--text);}
.axis,.pick-axis {color: var(--sub);}
.DW,.sq.DW {background-color: var(--dw);color: var(--dw-ink);}
.TW,.sq.TW {background-color: var(--tw);color: var(--tw-ink);}
.DL,.sq.DL {background-color: var(--dl);color: var(--dl-ink);}
.TL,.sq.TL {background-color: var(--tl);color: var(--tl-ink);}
.sq.cursor,.board-well .sq.cursor {box-shadow: inset 0 0 0 2px var(--cursor),inset 0 0 0 3px var(--paper);}
.sq.cursor:after {border-left-color: var(--cursor);}
.sq.cursor.down:after {border-left-color: transparent;border-top-color: var(--cursor);}
.result,.admin-mast,.toast {background-color: var(--hero-base);color: var(--hero-ink);}
.result,.admin-mast {border-color: var(--rail);}
.admin-mast .brand,.admin-mast .game-link,.admin-mast .mast-action {color: var(--hero-ink);}
.admin-mast .mast-action {border-color: var(--rail);}
button:focus-visible,a:focus-visible,summary:focus-visible,:is(input,select,textarea):focus-visible,.admin-page textarea:focus-visible {outline-color: var(--focus);}

:root[data-theme="wood"] .rackbox {background-color: var(--surface);background-image: var(--grain);background-size: 340px 170px;border-color: var(--rail);}
:root[data-theme="wood"] .hero:before,:root[data-theme="wood"] .invite:before {background: linear-gradient(102deg,#26170f35,transparent 65%);}
:root[data-theme="coast"] .hero:before,:root[data-theme="coast"] .invite:before {
  background: repeating-radial-gradient(ellipse at 90% 140%,transparent 0 22px,#c3eee916 22px 24px,transparent 24px 39px);
}
:root[data-theme="coast"] .board-well > .board-shell {box-shadow: inset 0 0 0 2px var(--rail),0 2px 5px #244e591c;}
:root[data-theme="deco"] .hero:before,:root[data-theme="deco"] .invite:before {
  background: repeating-conic-gradient(from -45deg at 50% 100%,transparent 0deg 14deg,#e6bf7424 14deg 15deg,transparent 15deg 30deg) 0 0/76px 50px;
}
:root[data-theme="deco"] .hero:after,:root[data-theme="deco"] .invite:after {
  border: 3px double #dac08b7a;border-radius: 5px;
}
:root[data-theme="deco"] .board-well > .board-shell {box-shadow: inset 0 0 0 2px var(--hero-base);border-radius: 3px;}
:root[data-theme="deco"] .rackbox,:root[data-theme="deco"] .admin-mast {border-bottom: 3px double var(--rail);}

/* Each illustrated label is also the radio's tap target. */
.theme-modes,.theme-cards {display: grid;gap: 8px;grid-template-columns: repeat(2,minmax(0,1fr));}
.theme-modes {margin-bottom: 10px;}
.theme-modes:has(> :only-child) {grid-template-columns: 1fr;}
.theme-option,.admin-page .theme-option {display: block;position: relative;min-width: 0;font-weight: 650;cursor: pointer;}
.theme-option input {position: absolute;width: 1px;height: 1px;opacity: 0;}
.theme-option-face {display: flex;align-items: center;min-height: 44px;height: 100%;border: 1px solid var(--line);border-radius: 7px;color: var(--text);background: var(--surface);overflow: hidden;}
.theme-caption {display: flex;gap: 7px;align-items: center;font: 650 .92rem/1.2 var(--sans);padding: 7px 9px;}
.theme-caption:before {content: '';display: block;width: 14px;height: 14px;box-sizing: border-box;border: 1.5px solid var(--sub);border-radius: 50%;flex: none;}
.theme-option input:checked + .theme-option-face {border-color: var(--brand);box-shadow: inset 0 0 0 1px var(--brand);}
.theme-option input:checked + .theme-option-face .theme-caption:before {background: var(--brand);border: 3px solid var(--surface);outline: 2px solid var(--brand);outline-offset: -1px;}
.theme-option input:focus-visible + .theme-option-face {outline: 3px solid var(--focus);outline-offset: 2px;}
.illustrated .theme-option-face {display: grid;grid-template-rows: auto 1fr;align-content: start;padding: 3px;}
.theme-sample {display: grid;grid-template-columns: repeat(3,minmax(0,1fr));align-items: stretch;gap: 2px;width: 100%;height: 43px;padding: 4px;border: 1px solid var(--rail);border-radius: 4px;}
.theme-sample i {display: grid;place-items: center;position: relative;font-style: normal;border-radius: 2px;}
.sample-bonus {font: 750 .64rem/1 var(--sans);}
.theme-sample .sample-letter {border: 1px solid var(--tile-edge);font: 700 1.28rem/1 var(--serif);}
.sample-letter small {position: absolute;right: 7%;bottom: 8%;font: 700 .52rem/1 var(--sans);}
.illustrated .theme-caption {padding: 5px 6px;}
@media (min-width:400px) {.theme-cards {grid-template-columns: repeat(3,minmax(0,1fr));}}
@media (max-height:550px) and (min-width:475px) {dialog[data-panel="appearance"] {width: min(630px,96vw);} .theme-sample {height: 34px;}}

dialog[data-panel="appearance"] #dialogbody {display:flex;flex-direction:column;overflow:hidden;}
#themeform {display:flex;flex-direction:column;min-height:0;}
#themeform fieldset {overflow:auto;overscroll-behavior:contain;min-height:0;padding:3px;}
#themeform>.primary {flex:none;}

/* A consistent finish for the table, its invitation and the home screen. */
body[data-screen] {
  background-image: radial-gradient(ellipse at 50% 0%,color-mix(in srgb,var(--pale) 38%,transparent),transparent 72%);
}
.appearance-glyph {
  display:block;width:20px;height:20px;border-radius:50%;border:2px solid currentColor;
  background:linear-gradient(90deg,currentColor 50%,transparent 50%);transform:rotate(-30deg);
}
.play-facts {display:flex;align-items:center;gap:14px;color:var(--hero-soft);font:600 .82rem/1.25 var(--sans);}
.play-facts span {display:inline-flex;align-items:center;gap:6px;white-space:nowrap;}
.play-facts .ico {width:16px;height:16px;color:var(--accent);}
.hero-copy h1 {text-wrap:balance;}
body[data-screen="home"] .hero {box-shadow:0 10px 28px #11271e20,inset 0 1px 0 #ffffff12;}
.hero .artframe {border-radius:12px;box-shadow:0 5px 0 var(--tile-shade),0 20px 32px #06191080;}
.artgrid i:nth-child(n+25):nth-child(-n+31) {border-bottom:2px solid var(--tile-shade);}
.hero .arttile {border-radius:3px;}
@media(min-width:851px) {
  body[data-screen="home"] .hero {min-height:clamp(250px,36vh,415px);}
  .hero-art .artframe {left:15%;top:46%;transform:translateY(-48%) rotate(-8deg);width:min(34vw,410px);}
  .hero-art .loose.one {left:4%;bottom:7%;transform:rotate(-17deg);}
  .hero-art .loose.two {left:18%;bottom:2%;transform:rotate(9deg);}
}
@media(max-width:580px) {
  .play-facts {font-size:.71rem;gap:9px;flex-wrap:wrap;}
  .play-facts .ico {width:13px;height:13px;}
}
@media(max-height:550px), (max-width:360px) and (max-height:620px) {.play-facts {display:none;}}
.publicbox,.compact-directory,.return,.side-scores,.side-turns {box-shadow:0 2px 5px #122a2010;}
.return .return-label {display:grid;min-width:0;text-align:left;}
.return > div {min-width:0;}
.return .return-label>small {font-size:.76rem;line-height:1.15;color:var(--sub);}
.return .return-label>strong {max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text);}
.return-code {font:650 .75rem/1 var(--sans);color:var(--sub);letter-spacing:.1em;}
.return button {flex:none;}
.directory-status {font-size:.85rem;color:var(--sub);margin:4px 0;}
.waiting-room .code-tiles {display:inline-flex;gap:.095em;align-items:center;letter-spacing:0;margin-block:.11em;}
.code-tiles i {
  display:grid;place-items:center;width:.83em;height:1.04em;border-radius:.11em;font-style:normal;
  color:var(--inktile);background:var(--tile-top);background-image:var(--grain),linear-gradient(140deg,var(--tile-top),var(--tile-bottom));
  background-size:var(--grain-size),cover;box-shadow:inset 0 1px 0 #ffffff50,0 .06em 0 var(--tile-shade);
}
@media (max-width:400px) {.waiting-room .roomcode {font-size:clamp(1.45rem,7.3vw,1.95rem);}}
.board-well > .board-shell {box-shadow:inset 0 1px 0 #ffffff35,0 2px 0 var(--frame),0 5px 14px #14271c24;}
.board-well .sq:not(.tile)>span[aria-hidden] {display:grid;place-items:center;line-height:1;font-size:1.4em;}
.bag-button {
  display:inline-flex;align-items:center;gap:4px;min-height:44px;padding:3px 7px;
  font:inherit;font-variant-numeric:tabular-nums;color:var(--brand);background:transparent;border:1px solid transparent;border-radius:7px;
}
.bag-button b {font-size:1rem;}
.rackbox {border-color:var(--rail);box-shadow:inset 0 1px 0 #ffffff25,0 2px 0 var(--line);}
.table-side .rack {padding:2px 1px 4px;background:linear-gradient(transparent 85%,color-mix(in srgb,var(--frame) 24%,transparent));border-radius:5px;}
.table-heading[data-cue="your-turn"] h1,.table-heading[data-cue="finished"] h1 {color:var(--brand);}
.table-heading[data-cue="your-turn"] h1::before {
  content:"";display:inline-block;width:.32em;height:.32em;margin:0 .28em .18em .08em;
  background:var(--brand);border-radius:50%;box-shadow:0 0 0 .09em var(--pale);
}
.table-heading[data-cue="finished"] h1 .ico {width:.8em;height:.8em;margin-right:.24em;vertical-align:baseline;}
.table-heading[data-cue="paused"] .table-title {border-inline-start:3px double var(--focus);padding-inline-start:8px;}
.final-scores .finish-place {display:inline-grid;place-items:center;min-width:1.1em;margin-right:.36em;font-size:.85em;color:var(--sub);font-variant-numeric:tabular-nums;}
.finish-place .ico {width:1.1em;height:1.1em;color:var(--brand);}
.final-scores .winning-seat {background:var(--pale);}
.winning-seat th:first-child {box-shadow:inset 3px 0 var(--brand);padding-left:7px;}
.tracker-totals {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:12px 0;}
.tracker-totals>div {display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;background:var(--pale);border-radius:8px;padding:6px 10px;}
.tracker-totals strong {font:700 1.5rem/1.2 var(--serif);color:var(--brand);}
.tracker-totals span,.tile-tracker p {font-size:.86rem;color:var(--sub);}
.tracker-letters {display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:5px;list-style:none;margin:0;padding:0;}
.tracker-letters li {display:flex;align-items:center;justify-content:space-between;gap:2px;padding:4px 5px;border:1px solid var(--tile-edge);border-radius:5px;background:var(--tile-top);color:var(--inktile);font:700 1.04rem/1.2 var(--serif);}
.tracker-letters b {font:600 .69rem/1 var(--sans);font-variant-numeric:tabular-nums;}
.tracker-letters .exhausted {background:var(--surface);border:1px dashed var(--line);color:var(--sub);}
.tile-tracker p {margin:9px 0 0;line-height:1.4;}
body #connection:not([hidden]) {display:flex;align-items:center;justify-content:center;gap:8px;min-height:36px;padding:0 8px;font-weight:600;background:var(--accent);color:var(--accent-ink);}
#retry-connection {min-height:40px;padding:2px 8px;border:0;color:inherit;background:transparent;font-weight:700;text-decoration:underline;text-underline-offset:3px;}
.game-clock.time-low {font-weight:750;color:var(--focus);font-variant-numeric:tabular-nums;}
@media(hover:hover) and (pointer:fine) {
  .bag-button:hover {background:var(--pale);border-color:var(--line);}
  .table-play .board-well .sq:not(.tile):hover {outline:2px solid var(--cursor);outline-offset:-2px;z-index:1;}
  .racktile:not(.dragging,.spent):hover {filter:brightness(1.06);}
}
@media(prefers-reduced-motion:no-preference) {
  .word-landed {animation:tile-land .42s cubic-bezier(.2,.7,.25,1) both;}
  @keyframes tile-land {0% {transform:translateY(-12%) scale(.91);opacity:.65;}65% {transform:translateY(1%) scale(1.04);}100% {transform:none;opacity:1;}}
  .score[data-score-gain],.score-chip b[data-score-gain] {position:relative;animation:score-change .65s ease-out;}
  .score[data-score-gain]::after,.score-chip b[data-score-gain]::after {
    content:attr(data-score-gain);content:attr(data-score-gain) / "";position:absolute;bottom:78%;right:-2px;z-index:2;border-radius:99px;
    padding:3px 5px;background:var(--brand);color:var(--brandwhite);font:700 .7rem/1 var(--sans);
    pointer-events:none;animation:points-rise 1.5s ease-out both;
  }
  @keyframes score-change {35% {transform:scale(1.1);} }
  @keyframes points-rise {0% {opacity:0;transform:translateY(4px);}18%,70% {opacity:1;}100% {opacity:0;transform:translateY(-8px);} }
  .hero .brass:active,.hero-alt:active {transform:translateY(1px);}
}
