* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: radial-gradient(
    ellipse at 50% 42%,
    #105748,
    #032a23 65%,
    #011713
  );
  color: #fff3d6;
  font:
    16px/1.45 system-ui,
    sans-serif;
  min-height: 100dvh;
  display: grid;
  place-items: center;
}
body:before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.075;
  background: url("pattern.svg");
  mask-image: linear-gradient(
    90deg,
    black,
    transparent 36%,
    transparent 64%,
    black
  );
}
main {
  width: min(1240px, 97vw);
  position: relative;
}
button,
input {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 1px solid #c6a35d;
  border-radius: 11px;
  padding: 10px 17px;
  background: linear-gradient(#104638, #04251f);
  font-weight: 600;
  transition:
    filter 0.15s,
    transform 0.15s;
  touch-action: manipulation;
}
button:hover {
  filter: brightness(1.18);
}
button:active {
  transform: translateY(2px);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button:focus-visible,
input:focus {
  outline: 3px solid #62eaaa;
}
.gold {
  background: linear-gradient(165deg, #ffe5a0, #e2ad48 55%, #ffdb83);
  color: #241702;
  box-shadow:
    inset 0 0 0 2px #ffdf8644,
    0 4px 14px #0005;
  border-color: #ffe5a4;
}
.wide {
  display: block;
  width: 100%;
  margin: 12px 0;
}
.home,
.panel,
.table,
dialog {
  border: 1px solid #dcb462;
  border-radius: 22px;
  background: #042c25;
  box-shadow:
    0 24px 65px #0007,
    inset 0 0 0 5px #05261e,
    inset 0 0 0 6px #ba965042;
  overflow: hidden;
}
header,
nav,
footer,
.players,
.line,
.rank,
.seat,
.gallery,
.user {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
header {
  padding: 14px 24px;
  border-bottom: 1px solid #ccab6066;
}
.star,
.brand {
  margin-right: auto;
  color: #ffda82;
  font: bold 23px Georgia;
  letter-spacing: 1px;
}
.star {
  font-size: 36px;
}
.user {
  padding: 4px 13px 4px 5px;
}
.user img,
.rank img,
.gallery img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e7bd69;
}
.hero {
  position: relative;
  isolation: isolate;
  background: radial-gradient(ellipse at 23% 40%, #0c4939, transparent 54%);
}
.art {
  position: absolute;
  inset: 0 0 0 35%;
  background: url(hero.webp) center/cover;
  mask-image: linear-gradient(90deg, transparent, #000 17%);
  z-index: -1;
  animation: breathe 9s ease-in-out infinite alternate;
  transform-origin: right bottom;
}
.intro {
  width: 35%;
  margin-left: 4%;
  padding: 4% 0;
}
.intro button {
  font: bold clamp(18px, 2vw, 28px) Georgia;
  padding: 14px;
}
.intro .practice {
  font: 600 16px system-ui;
  border-color: transparent;
  background: none;
  color: #ffe39e;
}
h1 {
  font: bold clamp(42px, 7.2vw, 96px)/0.91 Georgia;
  text-align: center;
  letter-spacing: -0.045em;
  margin: 0 0 7%;
  background: linear-gradient(
    #fff4ae,
    #f5bd4d 38%,
    #ffebaa 55%,
    #ce8b2c 90%,
    #fff1ad
  );
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 1px #160d00);
}
nav {
  border-top: 1px solid #cfa967;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
nav button {
  background: none;
  border: 0;
  font: 20px Georgia;
  color: #ffdf95;
}
dialog,
.panel {
  width: min(510px, 94vw);
  padding: 30px;
  color: inherit;
  overflow: auto;
  overflow-wrap: anywhere;
}
dialog::backdrop {
  background: #000a;
  backdrop-filter: blur(5px);
}
dialog button,
.panel button {
  margin: 4px;
}
.close {
  float: right;
  padding: 1px 12px;
  font-size: 25px;
}
.panel {
  margin: 5vh auto;
  text-align: center;
}
.panel .players {
  flex-wrap: wrap;
  margin: 30px 0;
}
h2,
h3,
strong {
  font-family: Georgia;
  color: #ffda8e;
}
h2 {
  margin: 6px 0 20px;
  font-size: 30px;
}
input {
  width: 100%;
  padding: 12px;
  background: #001f19;
  border: 1px solid #af985c;
  border-radius: 8px;
  margin: 7px 0 14px;
  font-size: 16px;
}
.gallery {
  flex-wrap: wrap;
  gap: 1px;
}
.gallery button {
  padding: 3px;
  border-radius: 50%;
}
.gallery img {
  display: block;
  width: 53px;
  height: 53px;
}
.chosen {
  outline: 3px solid #5bf7a4;
}
small {
  display: block;
  color: #e0cfaa;
  font-size: 13px;
}
.rank {
  justify-content: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid #ffffff20;
}
.rank strong {
  margin-left: auto;
}
aside {
  position: fixed;
  bottom: 12%;
  left: 50%;
  transform: translateX(-50%);
  background: #231606;
  color: #ffe5a9;
  border-radius: 15px;
  z-index: 99;
  padding: 12px;
  pointer-events: none;
}
aside:empty {
  display: none;
}
#messages {
  max-height: 40vh;
  overflow: auto;
}
.table {
  min-height: 96dvh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse, #14634d, #073b30 70%, #02221d);
  --w: clamp(33px, min(5.3vw, 7vh), 68px);
}
.table header {
  background: #01271f;
  padding: 8px 18px;
}
.players {
  justify-content: space-evenly;
  padding: 15px 0;
}
.seat {
  position: relative;
  font: bold 17px Georgia;
  min-width: 0;
  overflow-wrap: anywhere;
}
.face {
  position: relative;
  flex: none;
  width: 66px;
  height: 66px;
  padding: 4px;
  border-radius: 50%;
  background: #d4aa59;
}
.face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #17251d;
}
.portrait-clock {
  display: grid;
  justify-items: center;
  gap: 5px;
  flex: none;
  position: relative;
}
.active-clock {
  --ring: #51ed85;
  --elapsed: 0deg;
}
.face img {
  display: block;
}
.live {
  background: conic-gradient(
    from 0deg,
    #21443b 0deg var(--elapsed),
    var(--ring) var(--elapsed) 360deg
  );
  box-shadow: 0 0 17px #0007;
}
.pulse {
  animation: pulse 0.55s infinite alternate;
}
.live::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 50% 2px,
    #fff 0 1.5px,
    var(--ring) 2px 3px,
    transparent 3.5px
  );
  transform: rotate(var(--elapsed));
  pointer-events: none;
}
.crown,
em {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
#sec {
  font:
    700 15px/1.25 system-ui,
    sans-serif;
  color: var(--ring);
  background: #031c16;
  border: 1px solid var(--ring);
  border-radius: 16px;
  padding: 1px 6px;
}
.crown {
  top: -26px;
  font-size: 29px;
}
em {
  bottom: 100%;
  background: #fff4ce;
  color: #132923;
  padding: 6px 10px;
  border-radius: 12px;
  z-index: 5;
  width: max-content;
  max-width: 140px;
  animation: pop 0.2s;
}
.line {
  padding: 5px 3%;
  justify-content: space-between;
}
.board,
.rack,
.meld {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.board {
  flex: 1 0 140px;
  align-content: center;
  gap: 16px;
  padding: 14px;
  overflow: auto;
  max-height: 55vh;
  border-block: 1px solid #cfaa5640;
  background: #001e161a;
}
.dense {
  --w: 36px;
}
.meld {
  border-radius: 8px;
  padding: 4px;
  gap: 3px;
}
.bad {
  outline: 2px dashed #ff8969;
}
.meld [data-add] {
  padding: 7px;
}
.new {
  border-style: dashed;
}
.tile {
  width: var(--w);
  height: calc(var(--w) * 1.37);
  padding: 0 0 8px;
  position: relative;
  background: linear-gradient(130deg, #fffdf0, #f5e4bf);
  box-shadow:
    inset 1px 2px 2px white,
    0 4px #b0986d,
    0 7px 7px #0007;
  border: 1px solid #f5e2bc;
  border-radius: 12%;
  font: bold calc(var(--w) * 0.79) Georgia;
  touch-action: none;
  user-select: none;
  margin-bottom: 5px;
  animation: place 0.16s;
}
.tile:after {
  content: "";
  position: absolute;
  bottom: 7%;
  left: 37%;
  width: 26%;
  aspect-ratio: 1;
  background: currentColor;
  forced-color-adjust: none;
  pointer-events: none;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.tile:has(img):after {
  display: none;
}
.c0 {
  color: #f00016;
}
.c1 {
  color: #124896;
}
.c2 {
  color: #191714;
}
.c3 {
  color: #009435;
}
.tile:not(:has(img)) {
  padding-bottom: calc(var(--w) * 0.25);
  text-shadow: 0 1px 0 #0003;
}
.tile.c0:after {
  border-radius: 50%;
}
.tile.c1:after {
  transform: rotate(45deg) scale(0.85);
}
.tile.c3:after {
  left: 34%;
  width: 32%;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
#sec {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tile.fresh {
  outline: 2px solid #5ee7b4;
}
.tile.selected {
  transform: translateY(-7px);
  outline: 3px solid #ffce36;
  filter: brightness(1.1);
}
.bottom {
  justify-content: flex-end;
  padding-block: 11px;
}
.bottom .seat {
  margin-right: auto;
}
.rack {
  margin: 0 3%;
  padding: 14px 10px 10px;
  min-height: 50px;
  border: 5px ridge #90532c;
  border-radius: 15px;
  background: repeating-linear-gradient(
    2deg,
    #472212,
    #582912 4px,
    #401e10 7px
  );
  box-shadow:
    inset 0 8px 14px #0009,
    0 5px 8px #0007;
}
.hint {
  text-align: center;
  font-size: 14px;
  padding: 10px;
}
footer {
  padding: 0 0 14px;
}
.ghost {
  position: fixed;
  pointer-events: none;
  z-index: 100;
  transform: translate(-50%, -50%);
  --w: 48px;
}
.confetti {
  position: fixed;
  top: 0;
  width: 8px;
  height: 13px;
  pointer-events: none;
  z-index: 30;
}
@keyframes breathe {
  to {
    transform: scale(1.025);
  }
}
@keyframes pulse {
  to {
    box-shadow: 0 0 19px #ff3939;
  }
}
@keyframes pop {
  from {
    opacity: 0;
    bottom: 60%;
  }
}
@keyframes place {
  from {
    opacity: 0.7;
    translate: 0 3px;
  }
}
@media (max-width: 760px), (max-height: 560px) {
  button {
    font-size: 13px;
    padding: 8px 9px;
  }
  header,
  footer,
  .players,
  .line,
  .seat {
    gap: 5px;
  }
  header,
  .table header {
    padding: 7px 9px;
  }
  .brand,
  .seat {
    font-size: 14px;
  }
  small {
    font-size: 11px;
  }
  .face {
    width: 45px;
    height: 45px;
    padding: 3px;
  }
  .table {
    min-height: 98dvh;
    border-radius: 12px;
  }
  .board {
    gap: 7px;
    padding: 7px;
  }
  .rack {
    margin: 0 5px;
    padding: 9px 4px 4px;
  }
  .hint {
    font-size: 12px;
    padding: 5px;
  }
  .bottom {
    padding: 8px;
  }
  .players {
    padding: 9px 3px;
  }
  .table header small {
    display: none;
  }
  .intro {
    padding: 2% 0;
  }
  .intro button {
    padding: 9px;
  }
  .intro .practice {
    font-size: 13px;
  }
  nav {
    padding: 6px;
  }
  nav button {
    font-size: 16px;
  }
}
@media (max-width: 650px) and (orientation: portrait) {
  .home {
    margin: 10px auto;
    width: 94vw;
  }
  .art {
    position: relative;
    inset: auto;
    height: 32dvh;
    background-position: center 35%;
    mask-image: linear-gradient(black 76%, transparent);
  }
  .intro {
    width: 86%;
    margin: -24px auto 0;
    padding: 0;
    position: relative;
  }
  h1 {
    font-size: 10vw;
    margin: 0 0 18px;
  }
  h1 br {
    display: none;
  }
  h1 br:after {
    content: " ";
  }
  nav {
    grid-template-columns: 1fr 1fr;
  }
  .players .seat {
    flex-direction: column;
    text-align: center;
    max-width: 31%;
  }

  .table {
    --w: clamp(32px, 11vw, 49px);
  }
  .line small {
    max-width: 29%;
  }
  .bottom small {
    max-width: none;
  }
  .bottom .seat {
    font-size: 12px;
  }
  .brand {
    font-size: 12px;
  }
  .board {
    max-height: 43vh;
  }
  .dense {
    --w: 29px;
  }
}
@media (max-height: 560px) and (orientation: landscape) {
  .table {
    display: grid;
    grid-template-columns: 150px 1fr;
    grid-template-rows: auto auto minmax(94px, 1fr) auto auto auto auto;
    --w: clamp(28px, 5vw, 40px);
  }
  .table header {
    grid-column: 1/3;
  }
  .players {
    flex-direction: column;
  }
  .table .players {
    grid-row: 2/6;
    grid-column: 1;
  }
  .table .line,
  .table .board,
  .table .rack {
    grid-column: 2;
  }
  .table .hint,
  .table footer {
    grid-column: 1/3;
  }
  .board {
    max-height: 38vh;
  }
  .bottom {
    padding: 2px;
  }
  #sec {
    font-size: 13px;
    padding: 0 4px;
  }
  .bottom .face {
    width: 32px;
    height: 32px;
  }
  .rack {
    padding: 5px 2px;
  }
  .hint {
    padding: 1px;
  }
  footer {
    padding: 0 0 4px;
  }
  .hero .intro {
    padding: 0;
  }
  .intro h1 {
    font-size: 38px;
    margin: 6px;
  }
  .wide {
    margin: 4px 0;
  }
  .home header,
  nav {
    padding: 2px 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
.gallery .portrait img {
  width: 74px;
  height: 74px;
}
.gallery .portrait {
  margin: 5px;
}
.tile:has(img):hover img {
  animation: joke 0.5s ease;
}
@keyframes joke {
  40% {
    transform: rotate(-12deg) scale(1.13);
  }
  75% {
    transform: rotate(8deg);
  }
}
.gallery .portrait {
  border-radius: 15px;
  padding: 7px 9px;
  background: #03261f;
  border-color: #967845;
}
.gallery .portrait span {
  display: block;
  color: #ffe3a0;
  font: 600 16px Georgia;
  margin: 7px auto 1px;
}
.gallery .portrait.chosen {
  background: #125440;
  outline: 2px solid #efc96a;
}
.gallery .portrait img {
  margin: auto;
}
@media (max-width: 440px) {
  .gallery .portrait img {
    width: 58px;
    height: 58px;
  }
  .gallery .portrait {
    padding: 5px;
    margin: 3px;
  }
}
/* A bounded table gives the tile fitter the actual space between controls. */
body:has(.table) {
  min-height: 100dvh;
}
main:has(.table) {
  width: min(1500px, 99vw);
}
.table {
  height: 99dvh;
  min-height: 0;
  box-sizing: border-box;
}
.table header {
  padding: 4px 15px;
}
.table .players {
  padding: 5px 0;
}
.table .face {
  width: 50px;
  height: 50px;
}
.table .portrait-clock {
  gap: 3px;
}
.table .line {
  padding-block: 3px;
}
.table .board {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  max-height: none;
  align-content: safe center;
  justify-content: safe center;
  gap: calc(var(--w) * 0.24) calc(var(--w) * 0.35);
  padding: 6px;
  overflow: hidden;
}
.table .meld {
  flex: none;
  flex-wrap: nowrap;
  padding: 2px;
  gap: max(1px, calc(var(--w) * 0.055));
}
.table .meld [data-add] {
  padding: 0;
  width: calc(var(--w) * 0.65);
  height: var(--w);
  font-size: calc(var(--w) * 0.57);
  border-radius: 5px;
}
.table .new {
  padding: 4px 7px;
  font-size: clamp(10px, var(--w), 15px);
}
.table .rack {
  flex: none;
  min-height: 0;
  margin: 0 1%;
  padding: 6px 4px 4px;
  gap: 2px;
  border-width: 3px;
  align-content: center;
}
.table .tile,
.winning .tile {
  flex: none;
  margin-bottom: 2px;
  box-shadow:
    inset 0 1px 1px white,
    0 2px #aa8d5a,
    0 3px 4px #0007;
  font-size: calc(var(--w) * 0.76);
  line-height: 1;
  padding-inline: 0;
}
.table .tile.selected {
  transform: translateY(-3px);
}
.table .hint {
  padding: 3px;
  font-size: 13px;
}
.table footer {
  padding: 0 0 6px;
}
.table .tile.played,
.winning .tile {
  background: linear-gradient(145deg, #fffabf, #ffcf38);
  outline: 2px solid #fff6ac;
  box-shadow:
    0 0 10px 3px #ffbd1f,
    0 2px #9c650a;
}
.table .tile.played.selected {
  outline: 3px solid #72ffff;
}
.winning {
  --w: 36px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  pointer-events: none;
}
@media (max-width: 650px) and (orientation: portrait) {
  .table .face {
    width: 42px;
    height: 42px;
  }
  .table .players {
    padding: 5px 0;
  }
  .table .line {
    padding-inline: 5px;
  }
  .table .bottom button {
    padding: 7px;
  }
  .table .hint {
    font-size: 11px;
  }
  .table .rack {
    padding-block: 5px;
  }
}
@media (max-height: 560px) and (orientation: landscape) {
  .table {
    grid-template-columns: 110px minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto auto auto;
  }
  .table .players {
    min-height: 0;
    gap: 2px;
    padding: 0 3px;
  }
  .table .face {
    width: 34px;
    height: 34px;
  }
  .table .seat {
    font-size: 12px;
  }
  .table .seat small {
    font-size: 10px;
  }
  .table header,
  .table .line,
  .table .hint,
  .table footer {
    padding-block: 1px;
  }
  .table header button,
  .table footer button,
  .bottom button {
    padding: 4px 8px;
  }
  .table .hint {
    font-size: 10px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .table .rack {
    padding: 4px 2px 1px;
    border-width: 2px;
  }
  .table .board {
    padding: 3px;
  }
  .table #sec {
    font-size: 12px;
    padding: 0 3px;
  }
}
.tile-lens {
  --w: 54px;
  position: fixed;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 80;
  outline: 2px solid #ffcc61;
  box-shadow: 0 5px 20px #0009;
}
.deck-info {
  text-align: center;
  font: 600 14px system-ui;
  color: #ffe3a0;
}
.friends-strip {
  display: flex;
  justify-content: space-evenly;
  gap: 4px;
  margin: 14px auto;
  text-align: center;
}
.friends-strip img {
  width: clamp(34px, 4vw, 55px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid #e9bb68;
  display: block;
  margin: auto;
}
.friends-strip small {
  font-size: clamp(10px, 1.1vw, 14px);
  margin-top: 4px;
}
.intro .restore {
  display: block;
  margin: 10px auto;
  font: 14px system-ui;
  padding: 7px 12px;
}
.table.many .players {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: start;
}
.table.many .players .seat {
  flex-direction: column;
  text-align: center;
  max-width: none;
  gap: 2px;
  font-size: 14px;
}
.table.many .players .face {
  width: 39px;
  height: 39px;
}
@media (max-width: 650px) and (orientation: portrait) {
  .table.many .players {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .table.many .players .face {
    width: 30px;
    height: 30px;
  }
  .table.many .players .seat,
  .table.many .players small {
    font-size: 10px;
  }
}
@media (max-height: 560px) and (orientation: landscape) {
  .table.many .players {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: center;
  }
  .table.many .players .face {
    width: 24px;
    height: 24px;
    padding: 2px;
  }
  .table.many .players .seat,
  .table.many .players small {
    font-size: 9px;
    line-height: 1.05;
  }
  .table.many .players #sec {
    font-size: 10px;
  }
}
.intro .home-friend {
  background: none;
  border: 0;
  padding: 2px;
  min-width: 0;
}
.intro .home-friend:hover img {
  outline: 2px solid #ffe19a;
}
