.game-board {
  container-type: size;
  --board-unit: min(1cqi, 1cqb);
  --gift-background: #000;
  --portal-1: #ee6ce8;
  --portal-2: #6c6cee;
}

.table-ring,
.table-seat,
.held-gift,
.carried-gift {
  position: absolute;
  transform: translate(-50%, -50%);
}

.gap-control,
.is-on-ring:not(.drag-ghost) {
  position: absolute;
  translate: -50% -50%;
}

.table-ring {
  top: 50%;
  left: 50%;
  width: 61.2%;
  height: 58.8%;
  border: clamp(2px, .46 * var(--board-unit), 4px) dashed #fff;
  border-radius: 50%;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 45%));
  pointer-events: none;
}

.portal-connections {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.portal-link {
  fill: none;
  stroke: currentColor;
  stroke-width: clamp(2px, .43 * var(--board-unit), 4px);
  stroke-linecap: round;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 50%));
}

.portal-link.is-consumed {
  opacity: .25;
}

.table-seat {
  z-index: 2;
  --avatar-size: clamp(36px, 12.7 * var(--board-unit), 103px);
  --want-size: clamp(14px, 3.8 * var(--board-unit), 27px);
  width: var(--avatar-size);
  height: var(--avatar-size);
}

.is-dense .table-seat {
  --avatar-size: clamp(32px, 11.8 * var(--board-unit), 92px);
  --want-size: clamp(13px, 3.6 * var(--board-unit), 25px);
}

.piece-control,
.gap-control {
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.piece-control {
  border-radius: 50%;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.piece-control[aria-disabled="false"] {
  cursor: grab;
}

.piece-control[aria-disabled="true"],
.gap-control[tabindex="-1"] {
  cursor: default;
}

.piece-control:is(.is-selected, .is-drop-target, :focus-visible),
.gap-control:is(.is-drop-target, :focus-visible) {
  background-color: rgba(255, 255, 255, 0.336);
  /*outline: 2px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgb(32 25 20 / 45%);*/
}

.guest-control,
.route-control {
  width: 100%;
  height: 100%;
}

.guest-avatar {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}

.guest-turn,
.guest-idle {
  position: absolute;
  inset: 0;
}

.guest-idle {
  animation: guest-wobble 5.6s steps(1, jump-end) infinite;
  animation-delay: calc(var(--wobble-phase) * -.61s);
}

@keyframes guest-wobble {
  0%, 50%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}

@media (prefers-reduced-motion: reduce) {
  .guest-idle { animation: none; }
}

.avatar-portrait {
  position: absolute;
  inset: 11% 7% 7%;
  border-radius: 46% 46% 45% 45%;
  background: var(--coat);
  box-shadow: inset 0 0 0 1px rgb(32 37 26 / 15%), 0 2px 0 rgb(38 59 46 / 12%);
}

.avatar-portrait::before {
  position: absolute;
  inset: -6% 16% 24%;
  z-index: 1;
  border-radius: 50% 49% 44% 46%;
  background: var(--hair);
  box-shadow: inset -2px -2px rgb(31 20 15 / 13%);
  content: "";
}

.avatar-portrait::after {
  position: absolute;
  inset: 36% 22% 13%;
  border-radius: 50% 50% 44% 44%;
  background: #d6a481;
  content: "";
}

.is-locked .guest-avatar {
  filter: brightness(.65) saturate(.72);
}

.guest-lock {
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(15px, 38%, 28px);
  height: clamp(15px, 38%, 28px);
  transform: translate(-50%, -50%);
  color: #161310;
  filter: drop-shadow(0 1px 1px rgb(255 255 255 / 85%));
  pointer-events: none;
}

.lock-symbol::before,
.lock-symbol::after {
  position: absolute;
  content: "";
}

.lock-symbol::before {
  inset: 15% 34% 42%;
  border: max(1px, .12rem) solid currentColor;
  border-radius: 50% 50% 0 0;
}

.lock-symbol::after {
  inset: 42% 24% 19%;
  border-radius: 20%;
  background: currentColor;
}

.guest-wants {
  position: absolute;
  top: calc(100% + 1px);
  left: 50%;
  display: flex;
  gap: clamp(2px, .6 * var(--board-unit), 5px);
  align-items: center;
  padding: 1px 4px;
  transform: translateX(-50%);
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 999px;
  background: var(--gift-background);
  box-shadow: 0 1px 3px rgb(0 0 0 / 30%);
}

.wants-above .guest-wants {
  top: auto;
  bottom: calc(100% + 1px);
}

.guest-want {
  display: flex;
  align-items: center;
  gap: 1px;
}

.guest-want > .gift-icon {
  width: var(--want-size);
  height: var(--want-size);
}

.wish-points {
  color: var(--gift-color);
  font-size: clamp(.64rem, 3.4 * var(--board-unit), 1.19rem);
  line-height: 1;
}

.held-gift,
.carried-gift {
  display: grid;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 36%);
  border-radius: 50%;
  background: var(--gift-background);
  pointer-events: none;
}

.held-gift {
  width: clamp(26px, 7.9 * var(--board-unit), 47px);
  height: clamp(26px, 7.9 * var(--board-unit), 47px);
}

.held-icon {
  display: grid;
  width: 69%;
  height: 69%;
}

.held-icon.is-exchanging {
  opacity: 0;
}

.guest-happiness {
  position: absolute;
  right: -14%;
  bottom: -14%;
  display: grid;
  place-items: center;
  width: clamp(13px, 46%, 21px);
  height: clamp(13px, 46%, 21px);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--accent-strong);
  background: var(--white);
  font-size: clamp(.64rem, 2.9 * var(--board-unit), .9rem);
  line-height: 1;
}

.carried-gift {
  z-index: 4;
  width: clamp(25px, 7.8 * var(--board-unit), 44px);
  height: clamp(25px, 7.8 * var(--board-unit), 44px);
  border-color: rgb(255 255 255 / 57%);
  box-shadow: 0 2px 5px rgb(0 0 0 / 29%);
}

.carried-gift > .gift-icon {
  width: 69%;
  height: 69%;
}

.carried-gift.is-centered {
  width: clamp(53px, 15.5 * var(--board-unit), 94px);
  height: clamp(53px, 15.5 * var(--board-unit), 94px);
  box-shadow: 0 3px 5px rgb(0 0 0 / 27%);
}

.gap-control {
  width: clamp(30px, 9.4 * var(--board-unit), 49px);
  height: clamp(30px, 9.4 * var(--board-unit), 49px);
}

.route-control.is-on-ring {
  z-index: 3;
  width: clamp(33px, 10.6 * var(--board-unit), 57px);
  height: clamp(33px, 10.6 * var(--board-unit), 57px);
  border-radius: 50%;
}

.gap-control {
  z-index: 1;
  border-radius: 50%;
}

.gap-control::before {
  width: 46%;
  height: 46%;
  border: 1.5px dashed #a4aa90;
  border-radius: 50%;
  background: var(--paper);
  content: "";
}

.gap-control.can-place::before,
.is-drag-active .gap-control::before {
  border-color: #fff;
}

.gap-control.can-place {
  cursor: pointer;
}

.piece-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 96%;
  height: 96%;
  color: var(--accent-strong);
}

.start-label {
  position: absolute;
  bottom: calc(100% - 4px);
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  -webkit-text-stroke: 2px #000;
  paint-order: stroke fill;
  font-size: clamp(.65rem, 5.1 * var(--board-unit, 1vw), 1.3rem);
  line-height: 1.15;
  white-space: nowrap;
  pointer-events: none;
}

.piece-symbol {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.start-icon .piece-symbol,
.arrow-icon .piece-symbol {
  border: 1px solid var(--accent);
  border-radius: 38%;
  background: var(--panel);
  box-shadow: 0 2px 0 rgb(38 59 46 / 10%);
}

.start-icon .piece-symbol {
  color: var(--white);
  background: var(--accent);
}

.start-icon .piece-symbol::before,
.arrow-icon .piece-symbol::before {
  width: 62%;
  height: 52%;
  background: currentColor;
  clip-path: polygon(0 37%, 51% 37%, 51% 4%, 100% 50%, 51% 96%, 51% 63%, 0 63%);
  content: "";
}

.start-icon .piece-symbol::before {
  width: 68%;
  height: 62%;
}

.portal-icon {
  font: 700 clamp(.94rem, 3vw, 1.45rem)/1 system-ui, sans-serif;
}

.portal-pair-1 {
  color: var(--portal-1, #ee6ce8);
}

.portal-pair-2 {
  color: var(--portal-2, #6c6cee);
}

.portal-icon .piece-symbol {
  border: 1.5px dashed currentColor;
  border-radius: 50%;
  background: #fbf2fb;
}

.portal-out .piece-symbol {
  border-style: solid;
}

.portal-pair-2 .piece-symbol {
  border-radius: 31%;
  background: #eef7f8;
}

.route-control.is-consumed {
  opacity: .28;
}

.tool-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: 5px;
  min-height: 46px;
  border-radius: 10px;
}

.tool-tray.is-drop-target {
  outline: 2px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgb(32 25 20 / 45%);
}

.tool-slot {
  display: grid;
  place-items: center;
  width: clamp(30px, 9.8vw, 43px);
  height: clamp(30px, 9.8vw, 43px);
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--white);
}

.tool-slot-icon {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  opacity: .28;
}

.is-dragging {
  opacity: .36;
}

.drag-ghost {
  position: fixed;
  z-index: 10;
  transform: translate(-50%, -50%) scale(1.08);
  opacity: .92;
  pointer-events: none;
  filter: drop-shadow(0 5px 5px rgb(34 42 29 / 20%));
}

.gift-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--gift-color);
}

.gift-symbol {
  position: relative;
  width: 85%;
  height: 85%;
}

.gift-symbol::before,
.gift-symbol::after {
  position: absolute;
  content: "";
}

.gift-icon--candle .gift-symbol::before {
  inset: 41% 31% 6%;
  border-radius: 13%;
  background: currentColor;
}

.gift-icon--candle .gift-symbol::after {
  inset: 10% 36% 60%;
  transform: rotate(45deg);
  border-radius: 0 55% 55% 55%;
  background: currentColor;
}

.gift-icon--mug .gift-symbol::before {
  inset: 24% 31% 13% 10%;
  border-radius: 10% 10% 36% 36%;
  background: currentColor;
}

.gift-icon--mug .gift-symbol::after {
  inset: 33% 7% 29% 56%;
  border: 2px solid currentColor;
  border-radius: 26% 46% 46% 26%;
}

.gift-icon--book .gift-symbol::before {
  inset: 11% 18% 11% 17%;
  transform: rotate(-12deg);
  border-radius: 12%;
  background: currentColor;
}

.gift-icon--book .gift-symbol::after {
  inset: 25% 30% 62% 34%;
  transform: rotate(-12deg);
  border-radius: 2px;
  background: var(--panel);
}

.gift-icon--scarf .gift-symbol::before {
  inset: 5%;
  transform: rotate(-12deg);
  background: currentColor;
  clip-path: polygon(19% 11%, 82% 11%, 90% 42%, 68% 57%, 69% 100%, 47% 100%, 47% 60%, 41% 62%, 34% 87%, 12% 83%, 21% 55%, 10% 38%);
}

.gift-icon--socks .gift-symbol::before,
.gift-icon--socks .gift-symbol::after {
  inset: 4% 33% 19% 4%;
  transform: rotate(9deg);
  border-radius: 20% 22% 28% 40%;
  background: currentColor;
  clip-path: polygon(48% 0, 100% 0, 94% 85%, 72% 100%, 0 100%, 0 67%, 47% 58%);
}

.gift-icon--socks .gift-symbol::after {
  inset: 21% 0 2% 38%;
  opacity: .78;
}

.gift-icon--bell .gift-symbol::before {
  inset: 9% 10% 24%;
  border-radius: 49% 49% 16% 16%;
  background: currentColor;
  clip-path: polygon(19% 38%, 29% 8%, 70% 8%, 82% 39%, 85% 68%, 100% 93%, 0 93%, 15% 68%);
}

.gift-icon--bell .gift-symbol::after {
  inset: 71% 36% 9%;
  border-radius: 50%;
  background: currentColor;
}

.gift-icon--cookie .gift-symbol::before {
  inset: 8%;
  border-radius: 46% 50% 48% 49%;
  background:
    radial-gradient(circle at 32% 35%, var(--panel) 7%, transparent 9%),
    radial-gradient(circle at 68% 41%, var(--panel) 7%, transparent 9%),
    radial-gradient(circle at 49% 68%, var(--panel) 7%, transparent 9%),
    currentColor;
}

.gift-icon--ornament .gift-symbol::before {
  inset: 25% 13% 5%;
  border-radius: 50%;
  background: currentColor;
}

.gift-icon--ornament .gift-symbol::after {
  inset: 8% 37% 69%;
  border: 1.5px solid currentColor;
  border-radius: 43% 43% 0 0;
}

.gift-icon--mitten .gift-symbol::before {
  inset: 7%;
  transform: rotate(-16deg);
  background: currentColor;
  clip-path: polygon(29% 83%, 10% 62%, 11% 49%, 24% 45%, 34% 55%, 33% 28%, 40% 11%, 55% 5%, 73% 12%, 84% 29%, 84% 62%, 74% 80%, 74% 100%, 29% 100%);
}

.gift-icon--star .gift-symbol::before {
  inset: 4%;
  background: currentColor;
  clip-path: polygon(50% 0, 63% 34%, 100% 37%, 72% 63%, 80% 100%, 50% 79%, 20% 100%, 28% 63%, 0 37%, 37% 34%);
}

.gift-icon > .art-image,
.piece-icon > .art-image,
.guest-idle > .art-image,
.guest-lock > .art-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.has-art > :is(.gift-symbol, .piece-symbol, .avatar-portrait, .lock-symbol) {
  visibility: hidden;
}

@media (max-width: 740px) {
  .table-seat {
    --want-size: clamp(16px, 4.5 * var(--board-unit), 30px);
  }

  .is-dense .table-seat {
    --want-size: clamp(16px, 4.4 * var(--board-unit), 28px);
  }

  .held-gift,
  .carried-gift {
    width: clamp(32px, 9.5 * var(--board-unit), 56px);
    height: clamp(32px, 9.5 * var(--board-unit), 56px);
  }

  .held-icon,
  .carried-gift > .gift-icon {
    width: 76%;
    height: 76%;
  }

  .carried-gift.is-centered {
    width: clamp(60px, 18.5 * var(--board-unit), 104px);
    height: clamp(60px, 18.5 * var(--board-unit), 104px);
  }

  .tool-tray {
    gap: 4px;
  }
}

@media (max-width: 360px) {
  .is-dense .guest-wants {
    padding-inline: 2px;
  }
}
