.qvh {
  --ink: #172033;
  --muted: #607086;
  --line: #ced7e2;
  --panel: #f6f8fb;
  --light: #e9edd2;
  --dark: #587487;
  --qvh-board-image: none;
  --qvh-dark-overlay: #587487;
  --qvh-dark-overlay-opacity: 1;
  --qvh-sanctuary-stripe: #172033;
  --qvh-sanctuary-stripe-opacity: 0.28;
  --accent: #b42c42;
  --move: #166a50;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.qvh-game {
  width: min(100%, 760px);
  margin: 0 auto;
}

.qvh-top,
.qvh-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.qvh-top h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.1rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.qvh-message {
  margin: 4px 0 0;
  color: var(--muted);
}

.qvh-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.qvh-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 8px 12px;
}

.qvh-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.qvh-rules {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.qvh-rules p {
  margin: 0;
}

.qvh-stats {
  margin: 16px 0;
  border-block: 1px solid var(--line);
  padding: 10px 0;
}

.qvh-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1 / 1;
  width: min(92vw, 640px);
  max-width: 100%;
  margin: 0 auto;
  border: 2px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
  box-sizing: border-box;
  background-image: var(--qvh-board-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: var(--light);
}

.qvh-board::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  right: 0;
  height: 25%;
  background: repeating-linear-gradient(
    135deg,
    transparent 0 clamp(10px, 2.4vw, 18px),
    var(--qvh-sanctuary-stripe) clamp(10px, 2.4vw, 18px) clamp(13px, 3vw, 23px),
    transparent clamp(13px, 3vw, 23px) clamp(22px, 5.2vw, 40px)
  );
  opacity: var(--qvh-sanctuary-stripe-opacity);
  pointer-events: none;
}

.qvh-square {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-sizing: border-box;
  cursor: pointer;
  font: inherit;
  line-height: 1;
}

.qvh-light {
  background: var(--light);
}

.qvh-dark {
  background: var(--dark);
}

.qvh-has-board-image .qvh-light {
  background: rgba(255, 255, 255, 0.08);
}

.qvh-has-board-image .qvh-dark {
  background: transparent;
}

.qvh-dark::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  background: var(--qvh-dark-overlay);
  opacity: var(--qvh-dark-overlay-opacity);
  pointer-events: none;
}

.qvh:not(.qvh-has-board-image) .qvh-dark::before {
  display: none;
}

.qvh-sanctuary::after {
  content: none;
}

.qvh-respawn-marker {
  position: relative;
  z-index: 6;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0.92;
  pointer-events: none;
}

.qvh-respawn-arrival {
  position: relative;
  z-index: 9;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.qvh-respawn-arrival .qvh-respawn-marker {
  position: absolute;
  inset: 0;
  animation: qvh-grave-shake 620ms ease-in-out both;
}

.qvh-dirt-burst {
  position: absolute;
  inset: 0;
  z-index: 9;
  background:
    radial-gradient(circle at 48% 58%, rgba(92, 54, 27, 0.95) 0 8%, transparent 24%),
    radial-gradient(circle at 38% 50%, rgba(123, 77, 38, 0.86) 0 7%, transparent 18%),
    radial-gradient(circle at 58% 44%, rgba(81, 48, 24, 0.78) 0 6%, transparent 17%),
    radial-gradient(circle at 68% 62%, rgba(148, 96, 48, 0.72) 0 5%, transparent 16%),
    radial-gradient(circle at 29% 68%, rgba(68, 43, 24, 0.64) 0 5%, transparent 14%);
  opacity: 0;
  transform: scale(0.26);
  animation: qvh-dirt-burst 760ms ease-out 260ms both;
  pointer-events: none;
}

.qvh-respawn-arrival-piece {
  position: absolute;
  inset: 0;
  z-index: 10;
  opacity: 0;
  transform: translateY(14%) scale(0.88);
  animation: qvh-zombie-arrive 540ms ease-out 520ms both;
  pointer-events: none;
}

.qvh-piece {
  position: relative;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 72%;
  height: 72%;
  max-width: 72%;
  max-height: 72%;
  border-radius: 50%;
  font-family: "Times New Roman", Georgia, serif;
  font-size: clamp(1.35rem, 7.8vw, 4rem);
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.22);
}

.qvh-piece-img {
  position: relative;
  z-index: 10;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}

.qvh-debug-stat {
  display: none;
}

.qvh-piece-glow {
  position: relative;
  z-index: 10;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, var(--qvh-piece-glow-shadow, 0)));
}

.qvh-piece-glow::before {
  content: "";
  position: absolute;
  inset: 8%;
  z-index: 0;
  border-radius: 50%;
  background: var(--qvh-piece-glow-color, #7dd3fc);
  box-shadow:
    0 0 10px var(--qvh-piece-glow-color, #7dd3fc),
    0 0 22px var(--qvh-piece-glow-color, #7dd3fc),
    0 0 34px var(--qvh-piece-glow-color, #7dd3fc);
  opacity: var(--qvh-piece-glow-mid, 0);
  animation: qvh-piece-glow-pulse 1800ms ease-in-out infinite;
  animation-delay: var(--qvh-piece-glow-delay, 0ms);
  transform: translateZ(0);
  will-change: opacity, transform;
  pointer-events: none;
}

.qvh-piece-glow > * {
  position: relative;
  z-index: 1;
}

.qvh-piece-corner-wrap {
  position: relative;
  z-index: 10;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.qvh-piece-corner-glyph {
  position: absolute;
  right: 2%;
  bottom: 1%;
  z-index: 12;
  display: grid;
  place-items: center;
  width: 31%;
  height: 31%;
  color: #fff7d6;
  font-family: "Times New Roman", Georgia, serif;
  font-size: clamp(16px, 1.85rem, 34px);
  line-height: 1;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.82),
    0 0 5px rgba(0, 0, 0, 0.74);
  pointer-events: none;
}

.qvh-piece-flip {
  position: relative;
  z-index: 10;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 180ms ease;
  pointer-events: none;
}

.qvh-square:hover .qvh-piece-flip,
.qvh-square:focus-visible .qvh-piece-flip {
  transform: rotateY(180deg);
}

.qvh-piece-flip .qvh-piece-img,
.qvh-piece-flip .qvh-piece-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}

.qvh-piece-flip .qvh-piece-back {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0;
  transform: rotateY(180deg);
}

.qvh-queen {
  color: #111827;
  background: rgba(255, 255, 255, 0.46);
}

.qvh-pawn {
  color: #f8fafc;
  background: rgba(19, 27, 38, 0.62);
}

.qvh-boss {
  color: #fff7d6;
  background: rgba(92, 26, 41, 0.72);
  box-shadow: inset 0 0 0 2px rgba(255, 247, 214, 0.48);
}

.qvh-legal::after,
.qvh-capture::after {
  content: "";
  position: absolute;
  z-index: 12;
  inset: 30%;
  border: 3px solid var(--move);
  border-radius: 50%;
  background: rgba(22, 106, 80, 0.2);
  pointer-events: none;
}

.qvh-capture::after {
  inset: 12%;
  border-color: var(--accent);
  border-style: dashed;
  background: rgba(180, 44, 66, 0.18);
}

.qvh-queen-home {
  outline: 4px solid rgba(255, 255, 255, 0.48);
  outline-offset: -6px;
}

@keyframes qvh-piece-glow-pulse {
  0%,
  100% {
    opacity: var(--qvh-piece-glow-low, 0);
    transform: scale(0.88);
  }
  50% {
    opacity: var(--qvh-piece-glow-high, 0);
    transform: scale(1.04);
  }
}

@keyframes qvh-grave-shake {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
    filter: brightness(1);
  }
  16% {
    transform: translate(-3%, 1%) rotate(-2deg);
  }
  32% {
    transform: translate(3%, -1%) rotate(2deg);
  }
  48% {
    transform: translate(-2%, -2%) rotate(-1deg);
    filter: brightness(1.1);
  }
  64% {
    transform: translate(2%, 1%) rotate(1deg);
  }
  80% {
    transform: translate(-1%, 2%) rotate(-1deg);
    opacity: 0.7;
  }
}

@keyframes qvh-dirt-burst {
  0% {
    opacity: 0;
    transform: scale(0.24);
    filter: blur(0);
  }
  22% {
    opacity: 0.95;
  }
  58% {
    opacity: 0.78;
    transform: scale(1.04);
    filter: blur(1px);
  }
  100% {
    opacity: 0;
    transform: scale(1.42);
    filter: blur(3px);
  }
}

@keyframes qvh-zombie-arrive {
  0% {
    opacity: 0;
    transform: translateY(18%) scale(0.84);
    filter: brightness(0.76);
  }
  62% {
    opacity: 1;
    transform: translateY(-3%) scale(1.04);
    filter: brightness(1.08);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
}

.qvh-over {
  margin-top: 16px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: #fff7f8;
  padding: 16px;
  text-align: center;
}

.qvh-over h3 {
  margin: 0 0 6px;
  letter-spacing: 0;
}

.qvh-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 520px) {
  .qvh-game {
    width: 100%;
    max-width: none;
  }

  .qvh-board {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    border-left-width: 0;
    border-right-width: 0;
    border-radius: 0;
  }

  .qvh-actions,
  .qvh-button {
    width: 100%;
  }

  .qvh-actions {
    flex-direction: column;
  }
}
