:root {
  color-scheme: light dark;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-synthesis: none;
  --background: #f5f4ef;
  --foreground: #272c29;
  --border: #d4d7ce;
  --board-background: #e8ebe2;
  --cell-background: #fafbf7;
  --player-zero: #286653;
  --player-zero-tint: #e0eee5;
  --player-one: #a54a2d;
  --player-one-tint: #f4e4d9;
  --accent: var(--player-zero);
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: #181b19;
    --foreground: #e5e9e5;
    --border: #465048;
    --board-background: #2a312b;
    --cell-background: #202620;
    --player-zero: #78c9a8;
    --player-zero-tint: #193a2d;
    --player-one: #f1a07e;
    --player-one-tint: #43271f;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
}
body[data-player="1"] {
  --accent: var(--player-one);
}
button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
main {
  --header-height: 76px;
  width: calc(100% - 24px);
  height: calc(100dvh - 12px);
  margin: 0 auto;
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr);
}
#play-area {
  position: relative;
  container-type: inline-size;
  width: min(100%, calc((100dvh - var(--header-height) - 12px) * 3 / 4));
  aspect-ratio: 3 / 4;
  place-self: center;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
h1 {
  font-size: clamp(21px, 4vw, 30px);
  letter-spacing: -1.2px;
  margin: 0;
  font-weight: 650;
}
h1 span {
  opacity: 0.5;
  font-weight: 400;
}
.quiet {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  color: var(--foreground);
  background: var(--background);
  font-size: 12px;
  white-space: nowrap;
}
.quiet:hover {
  border-color: var(--accent);
}
.board {
  display: grid;
  grid-template-columns: repeat(var(--board-size), minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  margin: 0 auto;
  gap: 0.5cqw;
  padding: 0.7cqw;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--board-background);
}
.cell {
  border: 1px solid transparent;
  border-radius: 5px;
  background: var(--cell-background);
  aspect-ratio: 1;
  padding: 0;
  min-width: 0;
}
.cell[aria-disabled="true"] {
  cursor: default;
}
.cell.drop-target {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.hands {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  display: flex;
  height: 25%;
  pointer-events: none;
}
.hand {
  position: relative;
  width: 50%;
  border-bottom: 4px solid var(--player-zero);
}
.hand[data-player="1"] {
  border-color: var(--player-one);
}
.end-turn {
  position: absolute;
  left: 6%;
  top: 50%;
  transform: translateY(-50%);
  font-size: clamp(10px, 1.8cqw, 16px);
  pointer-events: auto;
}
.hand[data-player="1"] .end-turn {
  left: auto;
  right: 6%;
}
#cards {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.hand-cards {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 1;
  transition: opacity 360ms ease-in-out;
}
.hand-cards.withdrawn {
  opacity: 0;
  /* Finish fading while the 360ms slide still has noticeable movement. */
  transition-duration: 180ms;
  transition-timing-function: ease-out;
}
.card {
  position: absolute;
  left: 0;
  top: 0;
  width: 100px;
  height: 100px;
  transform-origin: top left;
  opacity: 1;
  transition: transform 360ms cubic-bezier(0.22, 0.8, 0.25, 1);
  color: var(--player-zero);
  --card-tint: var(--player-zero-tint);
  pointer-events: auto;
}
.card[data-player="1"] {
  color: var(--player-one);
  --card-tint: var(--player-one-tint);
}
.card-face {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 100%;
  padding: 6px;
  border: 1.5px solid currentColor;
  border-radius: 8px;
  color: inherit;
  background: var(--card-tint);
  box-shadow: 0 4px 9px rgb(0 0 0 / 15%);
  touch-action: none;
  user-select: none;
  filter: brightness(1);
  transition: filter 180ms ease-out;
}
.card.subdued .card-face {
  filter: brightness(0.7);
}
.card-face strong {
  font-size: 22px;
  font-weight: 650;
}
.card-face strong:first-child:last-of-type {
  line-height: 1;
}
.card:not([data-kind="literal"]) .card-face {
  display: grid;
  grid-template-rows: 22px 42px 24px;
  align-content: center;
  padding-block: 4px;
  gap: 0;
}
.card-face > * {
  width: 100%;
  text-align: center;
}
.gate-expression {
  grid-row: 3;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.gate-symbol {
  font-size: 24px;
  line-height: 1;
}
.gate-pip {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 15px;
  line-height: 1;
}
.gate-pip:empty::before {
  content: "○";
}
.card:not([data-kind="literal"]) .card-value {
  grid-row: 2;
  grid-column: 1;
}
.card[data-kind="literal"] .card-face strong,
.card-value {
  font-size: 42px;
  font-weight: 500;
  line-height: 1;
}
.card[data-kind="literal"] .card-value:empty {
  display: none;
}
.card-face:disabled {
  cursor: default;
  opacity: 1;
}
.card.selected::before,
.card.current-turn::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 12px;
  background: currentColor;
  opacity: 0.4;
  filter: blur(10px);
  pointer-events: none;
  z-index: -1;
}
.card.shake .card-face {
  animation: gate-shake 320ms ease-in-out;
}
@keyframes gate-shake {
  0%,
  100% {
    transform: rotate(0deg);
  }
  20% {
    transform: rotate(-3deg);
  }
  45% {
    transform: rotate(3deg);
  }
  70% {
    transform: rotate(-2deg);
  }
  85% {
    transform: rotate(1deg);
  }
}
.card.winning .card-face {
  box-shadow:
    inset 0 0 0 4px currentColor,
    0 0 15px currentColor;
}
.card.on-board[data-value="0"] {
  color: var(--player-zero);
  --card-tint: var(--player-zero-tint);
}
.card.on-board[data-value="1"] {
  color: var(--player-one);
  --card-tint: var(--player-one-tint);
}
.card.withdrawn {
  pointer-events: none;
}
.hand-cards.entering,
.card.entering {
  transition: none;
}
@property --drag-scale {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}
.card.dragging {
  transition: --drag-scale 150ms ease-out;
  z-index: 50 !important;
}
.undo-overlay {
  touch-action: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 2px solid currentColor;
  border-radius: 8px;
  padding: 0;
  color: inherit;
  background: var(--card-tint);
  display: grid;
  place-items: center;
}
.undo-overlay svg {
  width: 85%;
  height: 85%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
@media (max-height: 500px) {
  main {
    --header-height: 54px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .card.shake .card-face {
    animation: none;
  }
  .hand-cards,
  .hand-cards.withdrawn,
  .card,
  .card.dragging,
  .card-face {
    transition: none;
  }
}
