/* Use one scalable silhouette per mark. Fixed-width CSS bars and the old
   expiry ring overlapped on small cells, producing the apparent extra glyphs. */
#board .cell {
  overflow: hidden;
  isolation: auto;
}
#board .piece {
  display: block;
  position: relative;
  z-index: 2;
  width: 72%;
  height: auto;
  aspect-ratio: 1;
  flex: 0 0 auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  filter: none;
  pointer-events: none;
  transform-origin: 50% 50%;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}
#board .piece::before,
#board .piece::after {
  content: none;
  display: none;
}
#board .piece.x {
  background: var(--x);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M19 19L81 81M81 19L19 81' fill='none' stroke='black' stroke-width='24' stroke-linecap='round'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M19 19L81 81M81 19L19 81' fill='none' stroke='black' stroke-width='24' stroke-linecap='round'/%3E%3C/svg%3E");
}
#board .piece.o {
  background: var(--o);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='34' fill='none' stroke='black' stroke-width='16'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='34' fill='none' stroke='black' stroke-width='16'/%3E%3C/svg%3E");
}
#board .cell.expiring::before {
  content: none;
  display: none;
}
#board .cell.expiring::after {
  content: "";
  display: block;
  position: absolute;
  inset: 6%;
  border: 1.5px dashed currentColor;
  border-radius: 50%;
  background: none;
  box-shadow: none;
  filter: none;
  opacity: .58;
  transform: none;
  animation: none;
  z-index: 0;
  pointer-events: none;
}
#board .cell.expiring-x::after { color: var(--x); }
#board .cell.expiring-o::after { color: var(--o); }
#board .cell.expiring .piece { opacity: .68; }

/* Fade within the square: rotating/translating departing pieces looked like
   another mark and could cross the grid. Queue/removal timing stays unchanged. */
#board .piece.enter { animation: outmarkMarkEnter .16s ease-out; }
#board .piece.exit { animation: outmarkMarkExit .16s ease-in both; }
#winStrike {
  /* The connection stays behind the marks so both arms of a winning X read clearly. */
  z-index: 1;
  height: clamp(3px, .85vw, 5px);
  background: rgba(16, 16, 16, .76);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--lime) 60%, transparent);
}
@keyframes outmarkMarkEnter {
  from { opacity: 0; transform: scale(.88); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes outmarkMarkExit {
  from { opacity: .68; transform: scale(1); }
  to { opacity: 0; transform: scale(.82); }
}

/* Keep both names legible in the result rail on narrow phones. */
#gamePanel .live-pips .pip { flex-shrink: 0; aspect-ratio: 1; }
#gamePanel .player .name {
  font-weight: 700!important;
  text-transform: none!important;
  white-space: normal;
  overflow-wrap: anywhere;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.15;
}
@media (max-width: 650px) {
  #gamePanel .match-head { grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr)!important; }
  #gamePanel .player,
  #gamePanel .player.right {
    grid-template-columns: minmax(0, 1fr)!important;
    grid-template-rows: minmax(30px, auto) 9px;
    align-content: center;
    gap: 7px!important;
    min-height: 78px!important;
    padding: 10px 6px!important;
    text-align: center;
  }
  #gamePanel .player::before { content: none; display: none; }
  #gamePanel .player .sub { display: none; }
  #gamePanel .player .name,
  #gamePanel .player.right .name {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    min-width: 0;
    max-width: 100%;
    font-size: 12px!important;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: anywhere;
    overflow: visible;
    text-overflow: clip;
  }
  #gamePanel .player .live-pips,
  #gamePanel .player.right .live-pips {
    grid-column: 1;
    grid-row: 2;
    justify-content: center;
    align-self: center;
    gap: 4px!important;
    margin-top: 0!important;
  }
  #gamePanel .live-pips .pip {
    width: 8px!important;
    height: 8px!important;
    flex: 0 0 8px;
    border-width: 1.4px!important;
    border-radius: 50%;
  }
}
@media (max-width: 480px) {
  .result-side { flex-direction: column; justify-content: center; gap: 4px; padding: 8px 4px; font-size: 11px; }
  .result-side.right { flex-direction: column-reverse; }
  .result-avatar { width: 26px; height: 26px; flex-basis: 26px; }
  .result-side span:not(.result-avatar) { max-width: 100%; white-space: nowrap; }
}
