/* Velha Braba: estilos só deste jogo (prefixo .velha-). Muro de bloco, grade pichada, X vermelho e O dourado de neon. */

/* ---------- palco ---------- */
/* cores das peças: valem no palco e no pôster */
.velha-root,
.velha-poster {
  --velha-red: #ff2d45;
  --velha-red-core: #ffd9de;
  --velha-gold: #f5c22b;
  --velha-gold-core: #fff5c8;
  --velha-last: rgba(246, 240, 230, 0.6);
}
.velha-root {
  position: absolute;
  inset: 0;
  container-type: inline-size;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.2cqi;
  border-radius: 18px;
  background: #0c0a08;
  box-shadow:
    inset 0 0 0 1px rgba(245, 194, 43, 0.16),
    inset 0 0 60px rgba(0, 0, 0, 0.65);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.velha-root > .velha-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
.velha-oldtag {
  font-family: var(--tag);
  font-size: 70px;
  fill: rgba(246, 240, 230, 0.05);
}
.velha-oldtag-sm {
  font-size: 40px;
  fill: rgba(245, 194, 43, 0.06);
}

/* ---------- placar da série (topo) ---------- */
.velha-top {
  position: relative;
  z-index: 1;
  width: 86cqi;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2cqi;
}
.velha-kicker {
  display: block;
  font-family: var(--display);
  font-size: max(9px, 2.5cqi);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
}
.velha-gameno {
  min-width: 14cqi;
  line-height: 1;
  white-space: nowrap;
}
.velha-gameno-n {
  font-family: var(--tag);
  font-weight: 400;
  font-size: max(22px, 8.4cqi);
  color: var(--gold);
  text-shadow:
    0 0 2.4cqi rgba(245, 194, 43, 0.45),
    0.3cqi 0.3cqi 0 rgba(0, 0, 0, 0.6);
}
.velha-gameno small {
  margin-left: 0.5cqi;
  font-family: var(--display);
  font-size: max(11px, 3.2cqi);
  letter-spacing: 0.06em;
  color: var(--muted);
}
.velha-opener {
  min-width: 14cqi;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6cqi;
}
.velha-opener-mark {
  display: block;
  width: max(20px, 6.4cqi);
  height: max(20px, 6.4cqi);
}

.velha-pips {
  display: flex;
  gap: 1.6cqi;
}
.velha-pip {
  position: relative;
  width: max(24px, 8.2cqi);
  height: max(24px, 8.2cqi);
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: max(1.5px, 0.45cqi) dashed rgba(246, 240, 230, 0.2);
  background: rgba(0, 0, 0, 0.4);
  transition:
    border-color 0.3s,
    background 0.3s,
    opacity 0.3s;
}
.velha-pip i {
  font-style: normal;
  font-family: var(--mono);
  font-weight: 700;
  font-size: max(9px, 2.6cqi);
  color: rgba(246, 240, 230, 0.35);
}
.velha-pip svg {
  width: 64%;
  height: 64%;
}
.velha-pip.is-now {
  border-style: solid;
  border-color: var(--gold);
  background: radial-gradient(circle, rgba(245, 194, 43, 0.18), rgba(0, 0, 0, 0.45) 72%);
  animation: velha-pulse 1.6s ease-in-out infinite;
}
.velha-pip.is-now i {
  color: var(--gold-hi);
}
.velha-pip.is-p1 {
  border-style: solid;
  border-color: rgba(255, 45, 69, 0.85);
  background: radial-gradient(circle, rgba(227, 25, 47, 0.34), rgba(0, 0, 0, 0.5) 72%);
}
.velha-pip.is-p2 {
  border-style: solid;
  border-color: rgba(245, 194, 43, 0.9);
  background: radial-gradient(circle, rgba(245, 194, 43, 0.28), rgba(0, 0, 0, 0.5) 72%);
}
.velha-pip.is-velha {
  border-style: solid;
  border-color: rgba(246, 240, 230, 0.4);
  background: rgba(246, 240, 230, 0.07);
}
.velha-pip.is-velha i {
  font-family: var(--display);
  font-size: max(12px, 4cqi);
  color: var(--paper);
}
.velha-pip.is-off {
  opacity: 0.28;
}
.velha-pip.is-off::before {
  content: '';
  position: absolute;
  width: 60%;
  height: max(1.5px, 0.45cqi);
  background: rgba(246, 240, 230, 0.5);
  transform: rotate(-35deg);
  border-radius: 2px;
}
.velha-pip.pop {
  animation: velha-pip-pop 0.6s var(--ease-back);
}
.velha-pip.pop::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid currentColor;
  animation: velha-ring 0.7s ease-out forwards;
  pointer-events: none;
}
.velha-pip.is-p1.pop {
  color: var(--velha-red);
}
.velha-pip.is-p2.pop {
  color: var(--velha-gold);
}
.velha-pip.is-velha.pop {
  color: var(--paper);
}

/* marca pequena (placar, "abre", fantasma da casa, você) */
.velha-mini {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.velha-mini path {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.velha-mini.velha-p1 {
  color: var(--velha-red);
  filter: drop-shadow(0 0 2px rgba(255, 45, 69, 0.8));
}
.velha-mini.velha-p2 {
  color: var(--velha-gold);
  filter: drop-shadow(0 0 2px rgba(245, 194, 43, 0.8));
}
.velha-mini path {
  stroke: currentColor;
}

/* ---------- tabuleiro ---------- */
.velha-board {
  position: relative;
  z-index: 1;
  width: 80cqi;
  aspect-ratio: 1;
  flex: none;
}
.velha-board::before {
  content: '';
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 194, 43, 0.08), transparent 70%);
  pointer-events: none;
}
.velha-board.is-hit {
  animation: velha-hit 0.4s ease-out;
}
.velha-board.is-shake {
  animation: velha-shake 0.38s ease-in-out;
}
.velha-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

/* grade: tinta cor de papel, meio gasta */
.velha-gridline {
  fill: none;
  stroke: var(--paper);
  stroke-width: 5.5;
  stroke-linecap: round;
  opacity: 0.82;
}
.velha-drip path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
}
.velha-drip circle {
  fill: currentColor;
}
.velha-grid {
  color: rgba(246, 240, 230, 0.78);
}

/* X e O: traço grosso da cor + miolo claro (neon) */
.velha-mark,
.velha-strike {
  transform-box: fill-box;
  transform-origin: center;
}
.velha-ink,
.velha-core {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.velha-ink {
  stroke: currentColor;
  stroke-width: 13;
}
.velha-core {
  stroke-width: 4.2;
}
.velha-dots circle {
  fill: currentColor;
}
.velha-p1 {
  color: var(--velha-red);
}
.velha-p2 {
  color: var(--velha-gold);
}
.velha-p1 .velha-core {
  stroke: var(--velha-red-core);
}
.velha-p2 .velha-core {
  stroke: var(--velha-gold-core);
}
.velha-mark {
  transition: opacity 0.45s;
}
.velha-mark.is-new {
  animation: velha-mark-in 0.42s ease-out both;
}
.velha-mark.is-new .velha-s0 {
  animation: velha-draw 0.17s cubic-bezier(0.4, 0.1, 0.5, 1) both;
}
.velha-mark.is-new .velha-s1 {
  animation: velha-draw 0.17s 0.15s cubic-bezier(0.4, 0.1, 0.5, 1) both;
}
.velha-mark.is-new.velha-o .velha-s0 {
  animation-duration: 0.32s;
}
.velha-mark.is-new .velha-dots,
.velha-mark.is-new .velha-drip {
  animation: velha-fade 0.3s 0.22s both;
}
.velha-marks,
.velha-strikes {
  transition: opacity 0.22s;
}
.velha-marks.is-gone,
.velha-strikes.is-gone {
  opacity: 0;
}
.velha-marks.is-dim .velha-mark:not(.is-line) {
  opacity: 0.26;
}

/* risco da linha vencedora */
.velha-strike .velha-ink {
  stroke-width: 15;
  opacity: 0.95;
}
.velha-strike .velha-core {
  stroke-width: 5;
}
.velha-strike.is-new .velha-ink,
.velha-strike.is-new .velha-core {
  animation: velha-draw 0.36s cubic-bezier(0.5, 0, 0.3, 1) both;
}
.velha-strike.is-new .velha-drip {
  animation: velha-fade 0.3s 0.32s both;
}
.velha-strike.is-final {
  animation: velha-throb 1s ease-in-out infinite alternate;
}

/* casas (botões por cima do desenho) */
.velha-cells {
  position: absolute;
  inset: 3.125%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}
.velha-cell {
  all: unset;
  box-sizing: border-box;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 10%;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  min-width: 40px;
  min-height: 40px;
}
.velha-can .velha-cell.is-free {
  cursor: pointer;
}
/* casas livres na sua vez: pontinho de tinta */
.velha-cell::after {
  content: '';
  width: max(6px, 2cqi);
  height: max(6px, 2cqi);
  border-radius: 50%;
  background: rgba(246, 240, 230, 0.2);
  opacity: 0;
  transform: scale(0.4);
  transition:
    opacity 0.25s,
    transform 0.3s var(--ease-back);
}
.velha-can .velha-cell.is-free::after {
  opacity: 1;
  transform: scale(1);
}
.velha-cell:focus-visible {
  outline: max(2px, 0.5cqi) dashed var(--gold);
  outline-offset: -1.4cqi;
}
/* última jogada: cantoneiras em volta da casa */
.velha-cell::before {
  content: '';
  position: absolute;
  inset: 8%;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  --velha-c: linear-gradient(var(--velha-last), var(--velha-last));
  background:
    var(--velha-c) left top / 20% 2px no-repeat,
    var(--velha-c) left top / 2px 20% no-repeat,
    var(--velha-c) right top / 20% 2px no-repeat,
    var(--velha-c) right top / 2px 20% no-repeat,
    var(--velha-c) left bottom / 20% 2px no-repeat,
    var(--velha-c) left bottom / 2px 20% no-repeat,
    var(--velha-c) right bottom / 20% 2px no-repeat,
    var(--velha-c) right bottom / 2px 20% no-repeat;
}
.velha-cell.is-last::before {
  opacity: 0.8;
}
.velha-ghost {
  position: absolute;
  inset: 25%;
  opacity: 0;
  transform: scale(0.8);
  transition:
    opacity 0.15s,
    transform 0.2s var(--ease-back);
  pointer-events: none;
}
.velha-can .velha-cell.is-free:focus-visible .velha-ghost {
  opacity: 0.4;
  transform: scale(1);
}
@media (hover: hover) {
  .velha-can .velha-cell.is-free:hover .velha-ghost {
    opacity: 0.4;
    transform: scale(1);
  }
  .velha-can .velha-cell.is-free:hover::after {
    opacity: 0;
  }
}

/* "VELHA!" carimbado no muro */
.velha-stamp {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  pointer-events: none;
  white-space: nowrap;
  line-height: 1;
  font-family: var(--tag);
  font-size: 19cqi;
  color: var(--paper);
  opacity: 0;
  transform: translate(-50%, -50%) rotate(-10deg) scale(0.5);
  text-shadow:
    0.5cqi 0.5cqi 0 var(--p1),
    1.1cqi 1.1cqi 0 rgba(0, 0, 0, 0.6),
    0 0 5cqi rgba(246, 240, 230, 0.35);
}
.velha-stamp.on {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(-10deg) scale(1);
}
.velha-stamp.pop {
  animation: velha-stamp 0.5s var(--ease-back) forwards;
}
.velha-stamp.is-gone {
  animation: velha-out 0.22s ease-in forwards;
}

/* "jogo 3" no começo de cada jogo */
.velha-callout {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  pointer-events: none;
  white-space: nowrap;
  line-height: 1;
  opacity: 0;
  font-family: var(--tag);
  font-size: 15cqi;
  color: var(--gold);
  text-shadow:
    0 0 3cqi rgba(245, 194, 43, 0.5),
    0.6cqi 0.6cqi 0 rgba(0, 0, 0, 0.65);
  transform: translate(-50%, -50%) rotate(-6deg);
}
.velha-callout.pop {
  animation: velha-callout 1.2s var(--ease-out) forwards;
}

/* rolo de tinta limpando o muro entre um jogo e outro */
.velha-roller {
  position: absolute;
  top: -6%;
  bottom: -6%;
  left: 0;
  width: 70%;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.03) 0 2px, transparent 2px 6px),
    linear-gradient(90deg, transparent, rgba(18, 14, 12, 0.97) 20%, rgba(18, 14, 12, 0.97) 80%, transparent);
}
.velha-roller.go {
  animation: velha-roll 0.32s ease-in-out;
}

/* rodapé: quem é você */
.velha-foot {
  position: relative;
  z-index: 1;
  width: 80cqi;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2cqi;
  font-family: var(--display);
  font-size: max(11px, 3.1cqi);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.velha-you {
  display: flex;
  align-items: center;
  gap: 1.4cqi;
  min-height: max(18px, 5cqi);
  transition: color 0.25s;
}
.velha-you-mark {
  display: block;
  width: max(16px, 4.6cqi);
  height: max(16px, 4.6cqi);
}
.velha-you-mark:empty {
  display: none;
}
.velha-mine .velha-you {
  color: var(--paper);
}
.velha-mine .velha-you-label {
  text-shadow: 0 0 2cqi rgba(245, 194, 43, 0.45);
}
.velha-hint {
  color: var(--dim);
  white-space: nowrap;
}

/* recusa do servidor */
.velha-msg {
  position: absolute;
  left: 50%;
  bottom: 14%;
  z-index: 6;
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  padding: 0.5em 1.1em;
  border-radius: 99px;
  white-space: nowrap;
  font-weight: 800;
  font-size: max(13px, 3.4cqi);
  color: var(--paper);
  background: rgba(14, 12, 11, 0.92);
  border: 1px solid rgba(227, 25, 47, 0.65);
  box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.8);
  transition:
    opacity 0.2s,
    transform 0.25s var(--ease-out);
}
.velha-msg.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- pôster do catálogo ---------- */
.velha-poster {
  position: absolute;
  inset: 0;
}
.velha-poster .velha-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.velha-poster-board {
  position: absolute;
  left: 50%;
  top: 36%;
  width: 72cqi;
  height: 72cqi;
  overflow: visible;
  transform: translate(-50%, -50%) rotate(-5deg);
  transition: transform 0.4s var(--ease-out);
}
.poster:hover .velha-poster-board {
  transform: translate(-50%, -53%) rotate(-3deg) scale(1.04);
}
@media (max-width: 640px) {
  .velha-poster-board {
    top: 31%;
    width: 42cqi;
    height: 42cqi;
  }
}

/* ---------- animações ---------- */
@keyframes velha-draw {
  from {
    stroke-dasharray: 100 120;
    stroke-dashoffset: 101;
  }
  to {
    stroke-dasharray: 100 120;
    stroke-dashoffset: 0;
  }
}
@keyframes velha-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes velha-mark-in {
  0% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes velha-throb {
  from {
    opacity: 0.72;
  }
  to {
    opacity: 1;
  }
}
@keyframes velha-pulse {
  50% {
    box-shadow:
      0 0 0 0.7cqi rgba(245, 194, 43, 0.12),
      0 0 3cqi rgba(245, 194, 43, 0.4);
  }
}
@keyframes velha-pip-pop {
  0% {
    transform: scale(0.3);
  }
  60% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes velha-ring {
  from {
    opacity: 0.9;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(1.9);
  }
}
@keyframes velha-hit {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.025);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes velha-shake {
  20% {
    transform: translateX(-1.4cqi);
  }
  45% {
    transform: translateX(1.2cqi);
  }
  70% {
    transform: translateX(-0.7cqi);
  }
  100% {
    transform: none;
  }
}
@keyframes velha-stamp {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-10deg) scale(1.8);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-10deg) scale(0.94);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-10deg) scale(1);
  }
}
@keyframes velha-out {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-10deg) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-10deg) scale(0.9);
  }
}
@keyframes velha-callout {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%) rotate(-6deg) scale(0.7);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-6deg) scale(1.05);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-6deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -62%) rotate(-6deg) scale(1);
  }
}
@keyframes velha-roll {
  from {
    opacity: 1;
    transform: translateX(-150%);
  }
  to {
    opacity: 1;
    transform: translateX(150%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .velha-pip.is-now,
  .velha-strike.is-final {
    animation: none;
  }
  .velha-board.is-hit,
  .velha-board.is-shake {
    animation: none;
  }
}
