.mg-game-panel[hidden],
.mg-game-panel [hidden] {
  display: none !important;
}

.mg-game-panel {
  --mg-ink: #251f25;
  --mg-muted: #685c65;
  --mg-line: #e9dfe4;
  --mg-accent: #bc2854;
  --mg-berry: #c3315c;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--mg-line);
  color: var(--mg-ink);
}

.mg-game-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .85rem;
}

.mg-game-title {
  flex: 1;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 760;
}

.mg-game-icon {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-content: center;
  border-radius: .6rem;
  color: var(--mg-accent);
  background: #fbe9ef;
  font: 1.16rem/1 'Segoe UI Symbol', sans-serif;
}

.mg-game-panel button {
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.mg-game-panel button:disabled {
  opacity: .55;
  cursor: default;
}

.mg-game-panel button:focus-visible,
.mg-block-board:focus-visible,
.mg-game-title:focus-visible {
  outline: 2px solid var(--mg-berry);
  outline-offset: 2px;
}

.mg-game-panel .mg-game-close {
  display: grid;
  width: 2.15rem;
  height: 2.15rem;
  place-content: center;
  padding: 0;
  border: 1px solid var(--mg-line);
  border-radius: .65rem;
  color: var(--mg-muted);
  background: #fff;
  font-size: 1.4rem;
  line-height: 1;
}

.mg-game-close:hover {
  border-color: #deb3c0;
  color: var(--mg-accent);
}

.mg-game-message {
  margin: 0;
  color: var(--mg-muted);
  font-size: .875rem;
  line-height: 1.55;
}

.mg-game-actions,
.mg-chess-promotion,
.mg-chess-send-error,
.mg-block-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .7rem;
}

.mg-game-actions button,
.mg-chess-promotion button,
.mg-chess-send-error button,
.mg-block-controls button,
.mg-block-retry {
  min-height: 2.35rem;
  padding: .38rem .67rem;
  border: 1px solid var(--mg-line);
  border-radius: .55rem;
  background: #fff;
  font-size: .82rem;
  font-weight: 700;
}

.mg-game-actions button:hover,
.mg-chess-promotion button:hover,
.mg-chess-send-error button:hover,
.mg-block-controls button:not(:disabled):hover,
.mg-block-retry:hover {
  border-color: #e3a9bd;
  background: #fdf0f4;
}

.mg-game-actions .mg-primary {
  border-color: var(--mg-berry);
  color: #fff;
  background: var(--mg-berry);
}

.mg-game-actions .mg-primary:hover {
  border-color: #a8254c;
  background: #a8254c;
}

.mg-chess-instructions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .25rem .65rem;
  margin-bottom: .55rem;
  color: var(--mg-muted);
  font-size: .8rem;
}

.mg-chess-status {
  color: var(--mg-accent);
  font-weight: 750;
}

.mg-chess-board {
  display: grid;
  width: 100%;
  max-width: 22rem;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid #e2c9d4;
  border-radius: .7rem;
  container-type: inline-size;
}

.mg-chess-board .mg-square {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  place-content: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #fff1e9;
  touch-action: manipulation;
}

.mg-chess-board .mg-square-dark {
  background: #dba2b9;
}

.mg-chess-board .mg-square-last {
  background: #f6bd78;
}

.mg-chess-board .mg-square[aria-pressed='true'] {
  box-shadow: inset 0 0 0 3px #a02453;
  background: #f8c9d8;
}

.mg-chess-board .mg-square:focus-visible {
  z-index: 1;
  outline-offset: -3px;
}

.mg-chess-board .mg-square-target::after {
  position: absolute;
  width: 24%;
  aspect-ratio: 1;
  inset: 50% auto auto 50%;
  border-radius: 50%;
  background: #8f2959;
  content: '';
  opacity: .65;
  transform: translate(-50%, -50%);
}

.mg-chess-board .mg-square-target:has(.mg-piece:not(:empty))::after {
  width: 86%;
  border: 2px solid #8f2959;
  background: transparent;
}

.mg-chess-board .mg-square-check {
  background: #ee7895;
}

.mg-piece {
  color: #44263b;
  font: clamp(1rem, 9cqw, 2.25rem)/1 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'DejaVu Sans', sans-serif;
}

.mg-piece-white {
  color: #fffaf4;
  paint-order: stroke fill;
  -webkit-text-stroke: 1px #755166;
}

.mg-coordinate {
  position: absolute;
  right: 2px;
  bottom: 1px;
  left: 2px;
  color: #65364c;
  font-size: clamp(.5rem, 2.75cqw, .65rem);
  font-weight: 750;
  line-height: 1;
  pointer-events: none;
}

.mg-chess-send-error {
  align-items: center;
  color: var(--mg-accent);
  font-size: .8rem;
}

.mg-block-rules {
  margin: 0 0 .65rem;
  color: var(--mg-muted);
  font-size: .8rem;
}

.mg-block-scores {
  display: flex;
  max-width: 22rem;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .35rem;
  margin-bottom: .5rem;
  font-size: .75rem;
  color: var(--mg-muted);
}

.mg-block-scores strong {
  color: var(--mg-ink);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}

.mg-block-board {
  display: grid;
  width: min(100%, 13.5rem);
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 2px;
  padding: .35rem;
  border: 1px solid #e1d6e6;
  border-radius: .7rem;
  background: #f3edf5;
}

.mg-block-cell,
.mg-next-tile > span {
  aspect-ratio: 1;
  border-radius: 20%;
  background-color: #e7dfea;
  background-image: var(--mg-pattern, none);
  background-size: var(--mg-pattern-size, auto);
}

.mg-block-cell[data-color='1'],
.mg-next-tile[data-color='1'] > span {
  --mg-pattern: radial-gradient(#781348 15%, transparent 20%);
  --mg-pattern-size: 7px 7px;
  background-color: #e45a95;
}

.mg-block-cell[data-color='2'],
.mg-next-tile[data-color='2'] > span {
  --mg-pattern: repeating-linear-gradient(135deg, transparent 0 5px, #96600a50 5px 7px);
  background-color: #f4ba4c;
}

.mg-block-cell[data-color='3'],
.mg-next-tile[data-color='3'] > span {
  --mg-pattern: repeating-linear-gradient(0deg, transparent 0 5px, #14625265 5px 7px);
  background-color: #56c5aa;
}

.mg-block-cell[data-color='4'],
.mg-next-tile[data-color='4'] > span {
  --mg-pattern: repeating-linear-gradient(90deg, transparent 0 5px, #3a237a60 5px 7px);
  background-color: #a891eb;
}

.mg-block-meta,
.mg-block-next {
  display: flex;
  align-items: center;
  gap: .35rem;
  color: var(--mg-muted);
  font-size: .72rem;
}

.mg-block-meta {
  min-height: 1.65rem;
  flex-wrap: wrap;
  justify-content: space-between;
  margin-top: .5rem;
}

.mg-block-status {
  color: var(--mg-accent);
  font-weight: 700;
}

.mg-next-tile {
  display: grid;
  grid-template: repeat(2, .44rem) / repeat(3, .44rem);
  gap: 1px;
}

.mg-block-controls {
  margin-top: .4rem;
}

.mg-block-controls button {
  min-width: 2.3rem;
  touch-action: manipulation;
}
