.qg-shell {
  max-width: 860px;
  margin: 0 auto;
  border: 1px solid rgba(56, 28, 109, 0.2);
  border-radius: 16px;
  padding: 1rem;
  background: transparent;
}
.qg-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}
.qg-title {
  margin: 0;
  font-size: 1.55rem;
}
.qg-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.qg-controls button,
.qg-controls select {
  border-radius: 10px;
  border: 1px solid rgba(56, 28, 109, 0.28);
  background: var(--surface-strong);
  color: var(--text);
  min-height: 40px;
  padding: 0 0.75rem;
  font: inherit;
}
.qg-controls button {
  cursor: pointer;
  font-weight: 700;
}
.qg-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}
.qg-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}
.qg-chip {
  border: 1px solid rgba(56, 28, 109, 0.2);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  background: var(--surface-strong);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  font-size: 0.92rem;
}
.qg-board-wrap {
  position: relative;
  width: min(100%, 680px, var(--qg-board-fit, 680px));
  max-width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
}
.qg-board {
  display: grid;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 2px solid rgba(35, 22, 72, 0.88);
  border-radius: 6px;
  overflow: hidden;
  touch-action: none;
}
.qg-cell {
  border: 1px solid rgba(28, 22, 47, 0.34);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  margin: 0;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
  font-weight: 800;
  font-size: clamp(0.92rem, 2.5vw, 1.2rem);
  line-height: 1;
  color: #3a245f;
  user-select: none;
  transition: filter 0.16s ease, transform 0.12s ease;
}
.qg-cell:hover {
  filter: brightness(0.97);
}
.qg-cell.qg-mark-x {
  color: rgba(41, 30, 71, 0.8);
  font-weight: 700;
  font-size: clamp(1.06rem, 2.9vw, 1.34rem);
}
.qg-cell.qg-mark-q {
  color: #7c2d12;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
.qg-queen-icon {
  width: 62%;
  height: 62%;
  display: block;
  color: #7c2d12;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.45));
  pointer-events: none;
}
.qg-cell.qg-invalid {
  box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.85);
}
.qg-cell.qg-hint-flash {
  animation: qg-hint-pulse 1.6s ease-out;
}
@keyframes qg-hint-pulse {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(124, 45, 18, 0); }
  18%, 42% { box-shadow: inset 0 0 0 3px rgba(124, 45, 18, 0.92); }
}
.qg-status {
  margin-top: 0.75rem;
  border: 1px solid rgba(56, 28, 109, 0.2);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  min-height: 44px;
  background: var(--surface-strong);
}
.qg-how {
  margin-top: 0.7rem;
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.55;
}
.qg-how-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: -0.08em;
  margin: 0 0.12em;
  color: #7c2d12;
  font-weight: 900;
}
.qg-how-mark--x {
  font-size: 1.36em;
  line-height: 1;
  color: rgba(41, 30, 71, 0.9);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
.qg-how-mark--queen svg {
  width: 1.3em;
  height: 1.3em;
  display: block;
  color: #7c2d12;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.5));
}
.qg-win {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(86%, 450px);
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(115, 76, 226, 0.36);
  background:
    radial-gradient(circle at 12% 20%, rgba(255, 224, 143, 0.32) 0 24px, transparent 25px),
    radial-gradient(circle at 88% 18%, rgba(255, 170, 226, 0.24) 0 20px, transparent 21px),
    radial-gradient(circle at 84% 82%, rgba(132, 214, 255, 0.22) 0 22px, transparent 23px),
    rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 34px rgba(36, 24, 85, 0.18);
  text-align: center;
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.45;
  color: #22133f;
  display: none;
  pointer-events: none;
  z-index: 6;
  backdrop-filter: blur(1.5px);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  overflow: hidden;
}
.qg-win::before,
.qg-win::after {
  content: "✦";
  position: absolute;
  color: rgba(116, 75, 232, 0.7);
  font-size: 1rem;
  animation: qg-sparkle-float 1.8s ease-in-out infinite;
}
.qg-win::before {
  left: 0.85rem;
  top: 0.5rem;
}
.qg-win::after {
  right: 0.85rem;
  bottom: 0.5rem;
  animation-delay: 0.45s;
}
.qg-win.is-visible {
  display: block;
  pointer-events: auto;
  animation: qg-sparkle-pop 0.55s ease-out;
}
.qg-win__title,
.qg-win__detail {
  margin: 0;
  font: inherit;
  font-weight: inherit;
  line-height: inherit;
  color: inherit;
}
.qg-win__detail + .qg-win__detail {
  margin-top: 0.25rem;
}
.qg-win__btn {
  margin-top: 0.65rem;
  width: 100%;
  border: 1px solid rgba(115, 76, 226, 0.36);
  background: var(--surface-strong, rgba(255, 255, 255, 0.95));
  border-radius: 10px;
  min-height: 40px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  color: #22133f;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.qg-win__btn:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, rgba(115, 76, 226, 0.55));
  transform: translateY(-1px);
}
@keyframes qg-sparkle-pop {
  0% { opacity: 0; transform: translate(-50%, -42%) scale(0.94); filter: saturate(0.7) brightness(0.95); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); filter: saturate(1.08) brightness(1); }
}
@keyframes qg-sparkle-float {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.65; }
  50% { transform: translateY(-4px) rotate(10deg); opacity: 1; }
}
[data-theme="dark"] .qg-shell { border-color: rgba(189, 166, 240, 0.35); }
[data-theme="dark"] .qg-cell {
  color: #efe8ff;
  border-color: rgba(215, 198, 255, 0.24);
}
[data-theme="dark"] .qg-cell.qg-mark-x {
  color: #f5ecff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}
[data-theme="dark"] .qg-cell.qg-mark-q { color: #fcd34d; }
[data-theme="dark"] .qg-cell.qg-hint-flash {
  animation-name: qg-hint-pulse-dark;
}
@keyframes qg-hint-pulse-dark {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(252, 211, 77, 0); }
  18%, 42% { box-shadow: inset 0 0 0 3px rgba(252, 211, 77, 0.95); }
}
[data-theme="dark"] .qg-how-mark--x { color: rgba(230, 221, 255, 0.9); }
[data-theme="dark"] .qg-how-mark--queen svg {
  color: #fcd34d;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.45));
}
[data-theme="dark"] .qg-queen-icon {
  color: #fcd34d;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.45));
}
[data-theme="dark"] .qg-chip,
[data-theme="dark"] .qg-status,
[data-theme="dark"] .qg-controls button,
[data-theme="dark"] .qg-controls select {
  border-color: rgba(189, 166, 240, 0.35);
  background: rgba(22, 16, 40, 0.62);
  color: #f3e8ff;
}
[data-theme="dark"] .qg-controls button:disabled {
  opacity: 0.4;
}
[data-theme="dark"] .qg-win {
  border-color: rgba(185, 160, 255, 0.62);
  color: #f2f5ff;
  background:
    radial-gradient(circle at 12% 20%, rgba(255, 224, 143, 0.24) 0 24px, transparent 25px),
    radial-gradient(circle at 88% 18%, rgba(255, 170, 226, 0.18) 0 20px, transparent 21px),
    radial-gradient(circle at 84% 82%, rgba(132, 214, 255, 0.18) 0 22px, transparent 23px),
    rgba(20, 24, 48, 0.9);
  box-shadow: 0 14px 36px rgba(4, 6, 18, 0.5);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .qg-win__btn {
  color: #f2f5ff;
  border-color: rgba(185, 160, 255, 0.45);
  background: rgba(31, 38, 72, 0.85);
}
@media (max-width: 720px) {
  .qg-stats {
    grid-template-columns: 1fr;
  }
}
