.ttt-stage {
  --ttt-pink: #ff8bde;
  --ttt-lilac: #c5adff;
  max-width: 470px;
  width: 100%;
  margin-inline: auto;
  padding: clamp(14px, 4vw, 24px);
  display: grid;
  gap: 14px;
  text-align: center;
  border: 1px solid #8953a4;
  border-radius: 24px;
  background:
    radial-gradient(ellipse at 50% 0%, #65387670, transparent 55%),
    radial-gradient(ellipse at 0% 100%, #6c388d60, transparent 55%),
    linear-gradient(165deg, #2c163d, #1c102d 60%, #371c4b);
}

.ttt-stage h2, .ttt-stage p { margin: 0; }
.ttt-stage p { color: #e6ccee; font-size: 14px; }
.ttt-stage > .life-primary { background: linear-gradient(145deg, #9a457f, #733cac); }
.ttt-stage > .life-secondary { justify-self: center; }
.ttt-stage .ttt-connection { color: #e9c0ff; }
.ttt-error { color: #ffc2d3; text-align: center; margin: 0; }
.ttt-error:empty { display: none; }

.ttt-emblem {
  --ttt-pink: #ff8bde;
  --ttt-lilac: #c5adff;
  width: min(100%, 114px);
  margin: 8px auto;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  background:
    linear-gradient(90deg, transparent 32%, #c38cde 32% 34%, transparent 34% 66%, #c38cde 66% 68%, transparent 68%),
    linear-gradient(transparent 32%, #c38cde 32% 34%, transparent 34% 66%, #c38cde 66% 68%, transparent 68%);
  transform: rotate(-8deg);
}

.ttt-mark {
  display: block;
  position: relative;
  width: 68%;
  max-width: 66px;
  aspect-ratio: 1;
  margin: auto;
}
.ttt-x { color: var(--ttt-pink); }
.ttt-o { color: var(--ttt-lilac); }
.ttt-x::before, .ttt-x::after {
  content: '';
  position: absolute;
  inset: 0 41%;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(45deg);
}
.ttt-x::after { transform: rotate(-45deg); }
.ttt-o::before {
  content: '';
  position: absolute;
  inset: 7%;
  border: clamp(4px, 1.5vw, 9px) solid currentColor;
  border-radius: 50%;
}
.ttt-emblem .ttt-o::before, .ttt-player .ttt-o::before { border-width: 4px; }

.ttt-costs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  padding: 10px 6px;
  border: 1px solid #9963b6;
  border-radius: 16px;
  background: #60377e4a;
}
.ttt-stat { display: grid; justify-items: center; gap: 5px; }
.ttt-stat + .ttt-stat { border-inline-start: 1px solid #9963b65c; }
.ttt-stat small { color: #e9caf7; }
.ttt-money { display: inline-flex; justify-content: center; align-items: center; gap: 5px; font-weight: 700; font-size: 13px; }
.ttt-money .life-icon { width: 19px; height: 19px; }

.ttt-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(5px, 2vw, 12px);
}
.ttt-player {
  min-width: 0;
  display: grid;
  grid-template-rows: 100px auto;
  justify-items: center;
  align-content: start;
  gap: 5px;
  height: 100%;
  padding: 8px 4px;
  border: 1px solid #9d65b9;
  border-radius: 18px;
  background: linear-gradient(155deg, #5e367bb0, #3e2056b0);
}
.ttt-player.is-turn { border-color: #f9a2f3; box-shadow: inset 0 0 12px #ee8ee436; }
.ttt-player > :first-child { width: min(96px, 97%); height: 100%; object-fit: contain; }
.ttt-player > strong { max-width: 100%; overflow-wrap: anywhere; font-size: 13px; }
.ttt-player small { color: #f0d1f8; }
.ttt-player .ttt-mark { width: 28px; }
.ttt-player.compact { grid-template-rows: 50px auto; }
.ttt-player.compact .ttt-mark { width: 21px; }
.ttt-player.compact small { font-size: 10px; }
.ttt-versus { color: #f3b9f5; font-size: 17px; }
.ttt-silhouette {
  background: linear-gradient(160deg, #b878bd 1%, #251736 44%);
  clip-path: polygon(12% 19%, 18% 4%, 40% 20%, 62% 20%, 84% 4%, 90% 20%, 88% 40%,
    98% 67%, 82% 88%, 66% 96%, 34% 96%, 17% 88%, 2% 67%, 12% 40%);
  opacity: .75;
}
.ttt-countdown {
  justify-self: center;
  display: grid;
  place-items: center;
  width: 66px;
  aspect-ratio: 1;
  border: 2px solid #dda6f2;
  border-radius: 50%;
  color: #f5cafc;
  font-size: 35px;
}
.ttt-spinner {
  justify-self: center;
  width: 32px;
  aspect-ratio: 1;
  border: 3px solid #704385;
  border-top-color: #e9a2ed;
  border-radius: 50%;
  animation: ttt-spin 1s linear infinite;
}
.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(5px, 2vw, 9px);
  width: min(100%, 330px);
  margin-inline: auto;
}
.ttt-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid #b17dd0;
  border-radius: clamp(11px, 3vw, 17px);
  background: linear-gradient(150deg, #63367c, #38204e);
  box-shadow: inset 0 1px 5px #e5acf51c;
}
.ttt-cell:enabled { cursor: pointer; }
.ttt-cell:enabled:hover { background: #794898; }
.ttt-cell:focus-visible { outline: 2px solid #ffe0f9; outline-offset: 2px; }
.ttt-cell:disabled { opacity: 1; }
.ttt-cell.just-played .ttt-mark { animation: ttt-pop .22s ease-out; }
.ttt-cell.is-winning { border-color: #ffadea; background: #884c98; }
.ttt-cell.is-winning .ttt-mark { transform: scale(1.13); }
.ttt-status {
  justify-self: center;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  padding: 7px 12px;
  border: 1px solid #9566a9;
  border-radius: 999px;
  background: #4e2c65;
  font-weight: 700;
}
.ttt-status time { color: #eed5ff; font-variant-numeric: tabular-nums; }
.ttt-stage .ttt-result-title { color: #ffbee9; font-size: clamp(23px, 7vw, 39px); }
.ttt-result-art { justify-self: center; width: min(70%, 185px); position: relative; animation: ttt-pop .55s ease-out; }
.ttt-result-art > :first-child { width: 100%; height: clamp(100px, 38vw, 180px); object-fit: contain; }
.ttt-result-art > .life-icon { width: 42px; height: 42px; position: absolute; right: 0; bottom: 8px; color: #ffcf73; }

@keyframes ttt-spin { to { transform: rotate(360deg); } }
@keyframes ttt-pop { from { opacity: .45; transform: scale(.78); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .ttt-spinner, .ttt-cell .ttt-mark, .ttt-result-art { animation: none; }
}
