/* ── Board wrap ────────────────────────────────────────────────────────────── */
.board-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Square board ──────────────────────────────────────────────────────────── */
.square-board {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px;
}

/* ── Cells ─────────────────────────────────────────────────────────────────── */
.cell {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.cell:hover:not(.taken):not(.disabled) {
  background: var(--surface3);
  border-color: var(--border2);
  transform: scale(1.04);
}

.cell.taken   { cursor: default; }
.cell.disabled {
  opacity: 0.28;
  cursor: not-allowed;
  background: var(--bg2);
}

/* Frozen cell — pulsing blue border */
.cell.frozen {
  border-color: rgba(100,180,255,0.6);
  box-shadow: inset 0 0 8px rgba(100,180,255,0.2);
  animation: freeze-pulse 1.4s ease-in-out infinite;
}
@keyframes freeze-pulse {
  0%,100% { border-color: rgba(100,180,255,0.4); }
  50%      { border-color: rgba(100,180,255,0.9); }
}

/* Bonus cell — subtle gold rim */
.cell.bonus-cell { border-color: rgba(255,195,0,0.5); }

/* Heat overlay */
.cell::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255,120,0, calc(var(--heat, 0) * 0.35));
  pointer-events: none;
  transition: background 0.4s;
}

/* ── Win flash ─────────────────────────────────────────────────────────────── */
.cell.win-cell { animation: win-flash 0.5s ease forwards; }
@keyframes win-flash {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.09); }
  100% { transform: scale(1); }
}

/* ── Vanish warning ────────────────────────────────────────────────────────── */
/* NOTE: specificity must be LOWER than .mark-inner.vanishing below */
.cell.will-vanish .mark-inner { animation: will-vanish-pulse 1s ease-in-out infinite; }
@keyframes will-vanish-pulse {
  0%,100% { opacity: 0.45; }
  50%      { opacity: 0.15; }
}

/* ── Mark inner wrapper ────────────────────────────────────────────────────── */
.mark-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pop-in 0.28s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes pop-in {
  0%   { opacity: 0; transform: scale(0.35); }
  70%  { transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}
/* Specificity (0,2,1) — beats .cell.will-vanish .mark-inner (0,2,1) by source order,
   and the JS removes will-vanish from the cell before this class is added anyway. */
.cell .mark-inner.vanishing { animation: vanish-out 0.28s ease forwards; }
@keyframes vanish-out {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.2); }
}

/* ── SVG mark strokes ──────────────────────────────────────────────────────── */
.x-path {
  stroke: var(--x-color);
  stroke-width: 9;
  stroke-linecap: round;
  fill: none;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--x-color) 60%, transparent));
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: draw-stroke 0.32s ease forwards;
}
.o-path {
  stroke: var(--o-color);
  stroke-width: 9;
  stroke-linecap: round;
  fill: none;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--o-color) 60%, transparent));
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  animation: draw-stroke 0.38s ease forwards;
}
@keyframes draw-stroke { to { stroke-dashoffset: 0; } }

/* ── Blind mark ────────────────────────────────────────────────────────────── */
.blind-mark {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface3);
  border: 2px dashed var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--text2);
}
.blind-mark.revealing { animation: blind-reveal 0.4s ease forwards; }
@keyframes blind-reveal {
  0%   { opacity: 1; transform: scale(1) rotateY(0deg); }
  50%  { opacity: 0.3; transform: scale(0.8) rotateY(90deg); }
  100% { opacity: 0; transform: scale(1) rotateY(180deg); }
}

/* ── Win line overlay ──────────────────────────────────────────────────────── */
.win-line-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.win-line {
  stroke-linecap: round;
  fill: none;
  stroke-width: 5;
  opacity: 0.9;
  stroke-dasharray: 800;
  stroke-dashoffset: 800;
  animation: draw-win-line 0.42s ease forwards;
}
@keyframes draw-win-line { to { stroke-dashoffset: 0; } }

/* ── Hex board ─────────────────────────────────────────────────────────────── */
.hex-svg {
  display: block;
  filter: drop-shadow(0 4px 24px rgba(0,0,0,0.4));
}
.hex-cell {
  fill: var(--surface2);
  stroke: var(--border2);
  stroke-width: 1.5;
  transition: fill 0.18s;
  cursor: pointer;
}
.hex-hover   { fill: var(--surface3) !important; }
.hex-taken   { fill: var(--surface) !important; cursor: default; }
.hex-win     { fill: var(--surface3) !important; stroke-width: 2.5; }
.hex-disabled{ fill: var(--bg2) !important; opacity: 0.3; cursor: not-allowed; }
.hex-frozen  { stroke: rgba(100,180,255,0.7) !important; stroke-width: 2.5; }
.hex-bonus   { stroke: rgba(255,195,0,0.6) !important; stroke-width: 2; }
.will-vanish .hex-cell,
.hex-cell.will-vanish { animation: will-vanish-pulse 1s ease-in-out infinite; }

/* ── Gomoku board ──────────────────────────────────────────────────────────── */
.gomoku-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  overflow: hidden;
}
.gomoku-scroll {
  overflow: auto;
  max-width: 90vw;
  max-height: 70vh;
}
.gomoku-svg { display: block; }
.grid-line  { stroke: var(--border2); stroke-width: 0.8; }
.star-point { fill: var(--text2); }

/* Gomoku stones */
.stone-x {
  fill: var(--x-color);
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--x-color) 55%, transparent));
  animation: stone-pop 0.25s cubic-bezier(0.34,1.56,0.64,1) forwards;
  transform-box: fill-box;
  transform-origin: center;
}
.stone-o {
  fill: var(--o-color);
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--o-color) 55%, transparent));
  animation: stone-pop 0.25s cubic-bezier(0.34,1.56,0.64,1) forwards;
  transform-box: fill-box;
  transform-origin: center;
}
.stone-win { stroke: #fff; stroke-width: 2; }

@keyframes stone-pop {
  0%   { transform: scale(0.2); opacity: 0; }
  80%  { transform: scale(1.15); }
  100% { transform: scale(1);   opacity: 1; }
}
