/* ============================================================
   Chess 3D — Styles
   ============================================================ */

:root {
  --c3d-navy: #1C1C2E;
  --c3d-gold: #C9A84C;
  --c3d-emerald: #3DAA62;
  --c3d-red: #D4504A;
  --c3d-text: #E8DCC8;
  --c3d-text-dim: #A09AB8;
  --c3d-card: rgba(30, 30, 50, 0.95);
  --c3d-card-border: rgba(201, 168, 76, 0.25);
  /* iOS notch / safe area insets — fallback to 0 on non-notch devices */
  --c3d-safe-top: env(safe-area-inset-top, 0px);
  --c3d-safe-bottom: env(safe-area-inset-bottom, 0px);
  --c3d-safe-left: env(safe-area-inset-left, 0px);
  --c3d-safe-right: env(safe-area-inset-right, 0px);
}

/* ---------- Canvas ---------- */
.chess3d-wrap {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#renderCanvas {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

/* ---------- Overlay base ---------- */
.chess3d-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--c3d-safe-top) var(--c3d-safe-right) var(--c3d-safe-bottom) var(--c3d-safe-left);
  background: rgba(10, 10, 20, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.chess3d-overlay.chess3d-visible {
  display: flex;
}

/* ---------- Modal base ---------- */
.chess3d-modal {
  background: var(--c3d-card);
  border: 1px solid var(--c3d-card-border);
  border-radius: 16px;
  padding: 28px 24px 32px;
  max-width: 420px;
  width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

/* ---------- Main menu ---------- */
.chess3d-menu-icon {
  font-size: 2.5rem;
  margin-bottom: 2px;
  filter: drop-shadow(0 2px 8px rgba(201, 168, 76, 0.4));
}

.chess3d-menu-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 2px;
  letter-spacing: 0.03em;
}

.chess3d-menu-tagline {
  color: var(--c3d-text-dim);
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-size: 0.9rem;
}

.chess3d-elo-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 1rem;
  font-weight: 700;
}

.chess3d-elo-badge {
  font-size: 1.3rem;
}

.chess3d-elo-value {
  color: var(--c3d-gold);
}

.chess3d-menu-stats {
  color: var(--c3d-text-dim);
  font-size: 0.8rem;
  margin-bottom: 10px;
}

/* ---------- Labels ---------- */
.chess3d-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c3d-text-dim);
  margin-bottom: 6px;
}

/* ---------- Button groups ---------- */
.chess3d-btn-group {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.chess3d-diff-btn,
.chess3d-color-btn {
  flex: 1;
  min-width: 70px;
  padding: 8px 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--c3d-text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.chess3d-diff-btn:hover,
.chess3d-color-btn:hover {
  background: rgba(201, 168, 76, 0.15);
  border-color: var(--c3d-gold);
}

.chess3d-diff-btn.selected,
.chess3d-color-btn.selected {
  background: rgba(201, 168, 76, 0.25);
  border-color: var(--c3d-gold);
  color: var(--c3d-gold);
}

.chess3d-diff-elo {
  display: block;
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--c3d-text-dim);
  margin-top: 2px;
}

/* ---------- Buttons ---------- */
.chess3d-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  color: #fff;
  background: var(--c3d-gold);
  min-height: 44px;
}

.chess3d-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.chess3d-btn:active {
  transform: translateY(0);
}

.chess3d-btn-play {
  width: 100%;
  margin-top: 16px;
  font-size: 1.05rem;
  background: linear-gradient(135deg, var(--c3d-gold), #b8942e);
  color: #1a1a2e;
}

.chess3d-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--c3d-text);
}

.chess3d-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
}

.chess3d-btn-disabled {
  width: 100%;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--c3d-text-dim);
  cursor: not-allowed;
  position: relative;
}

.chess3d-btn-disabled:hover {
  filter: none;
  transform: none;
}

.chess3d-coming-soon {
  font-size: 0.6rem;
  background: var(--c3d-gold);
  color: #1a1a2e;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 6px;
  vertical-align: middle;
}

.chess3d-btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}

.chess3d-btn-row .chess3d-btn {
  flex: 1;
  width: auto;
}

/* ---------- HUD ---------- */
.chess3d-hud {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.chess3d-hud > * {
  pointer-events: auto;
}

/* Player bars */
.chess3d-player-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--c3d-card);
  border: 1px solid var(--c3d-card-border);
  border-radius: 10px;
  font-size: 0.85rem;
}

.chess3d-timer {
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--c3d-text);
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 10px;
  border-radius: 6px;
  margin-left: auto;
  min-width: 50px;
  text-align: center;
}

.chess3d-timer.active {
  color: var(--c3d-gold);
  background: rgba(201, 168, 76, 0.15);
}

.chess3d-timer.warning {
  color: var(--c3d-red);
  background: rgba(212, 80, 74, 0.15);
  animation: timerPulse 1s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.chess3d-game-clock {
  font-size: 0.75rem;
  color: var(--c3d-text-dim);
  margin-left: 8px;
}

.chess3d-player-top {
  top: calc(52px + var(--c3d-safe-top));
}

.chess3d-player-bottom {
  bottom: calc(12px + var(--c3d-safe-bottom));
}

.chess3d-player-info {
  display: flex;
  flex-direction: column;
  min-width: 60px;
}

.chess3d-player-name {
  font-weight: 700;
  color: #fff;
  font-size: 0.85rem;
}

.chess3d-player-elo {
  font-size: 0.7rem;
  color: var(--c3d-text-dim);
}

.chess3d-captured {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  font-size: 0.85rem;
  opacity: 0.75;
  flex: 1;
}

.chess3d-material-adv {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--c3d-gold);
  min-width: 24px;
  text-align: right;
}

/* Turn indicator — sits below the top player bar */
.chess3d-turn-indicator {
  position: absolute;
  top: calc(96px + var(--c3d-safe-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 14px;
  background: var(--c3d-card);
  border: 1px solid var(--c3d-card-border);
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--c3d-gold);
  white-space: nowrap;
}

/* AI thinking */
.chess3d-thinking {
  position: absolute;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--c3d-card);
  border: 1px solid var(--c3d-card-border);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--c3d-text-dim);
}

.chess3d-thinking-dots {
  display: flex;
  gap: 3px;
}

.chess3d-thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c3d-gold);
  animation: chess3d-dot 1.2s infinite ease-in-out;
}

.chess3d-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.chess3d-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chess3d-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

/* Move history */
.chess3d-move-history {
  position: absolute;
  right: calc(12px + var(--c3d-safe-right));
  top: calc(96px + var(--c3d-safe-top));
  bottom: calc(70px + var(--c3d-safe-bottom));
  width: 140px;
  background: var(--c3d-card);
  border: 1px solid var(--c3d-card-border);
  border-radius: 10px;
  overflow: hidden;
  display: none;
}

.chess3d-move-list {
  height: 100%;
  overflow-y: auto;
  padding: 8px;
  font-size: 0.72rem;
  font-family: 'Courier New', monospace;
  color: var(--c3d-text);
  scrollbar-width: thin;
  scrollbar-color: var(--c3d-gold) transparent;
}

.chess3d-move-row {
  display: flex;
  gap: 6px;
  padding: 2px 0;
}

.chess3d-move-num {
  color: var(--c3d-text-dim);
  min-width: 22px;
  text-align: right;
}

.chess3d-move-white,
.chess3d-move-black {
  min-width: 42px;
  cursor: default;
}

.chess3d-move-white:hover,
.chess3d-move-black:hover {
  color: var(--c3d-gold);
}

/* Mobile move history drawer */
.chess3d-mobile-moves {
  display: none; /* Only shown on mobile via media query */
  position: absolute;
  left: calc(6px + var(--c3d-safe-left));
  right: calc(6px + var(--c3d-safe-right));
  bottom: calc(100px + var(--c3d-safe-bottom));
  background: var(--c3d-card);
  border: 1px solid var(--c3d-card-border);
  border-radius: 10px;
  z-index: 40;
  overflow: hidden;
  transition: max-height 0.3s ease;
  max-height: 36px; /* Collapsed: header only */
}

.chess3d-mobile-moves.expanded {
  max-height: 200px;
}

.chess3d-mobile-moves-header {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--c3d-text);
  cursor: pointer;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
}

.chess3d-mobile-moves-count {
  background: var(--c3d-gold);
  color: var(--c3d-navy);
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.chess3d-mobile-moves-last {
  color: var(--c3d-gold);
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: auto;
  opacity: 0.9;
}

.chess3d-mobile-moves.expanded .chess3d-mobile-moves-last {
  display: none;
}

.chess3d-mobile-moves-arrow {
  font-size: 0.6rem;
  color: var(--c3d-text-dim);
  transition: transform 0.3s;
}

.chess3d-mobile-moves.expanded .chess3d-mobile-moves-arrow {
  transform: rotate(180deg);
}

.chess3d-mobile-moves-body {
  max-height: 160px;
  overflow-y: auto;
  padding: 0 12px 8px;
  border-top: 1px solid var(--c3d-card-border);
}

/* HUD buttons */
.chess3d-hud-buttons {
  position: absolute;
  left: calc(12px + var(--c3d-safe-left));
  bottom: calc(70px + var(--c3d-safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chess3d-hud-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--c3d-card-border);
  border-radius: 8px;
  background: var(--c3d-card);
  color: var(--c3d-text);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  font-family: inherit;
}

.chess3d-hud-btn:hover {
  background: rgba(201, 168, 76, 0.2);
  border-color: var(--c3d-gold);
}

.chess3d-hud-btn-danger {
  color: var(--c3d-red);
}

.chess3d-hud-btn-danger:hover {
  background: rgba(192, 57, 43, 0.2);
  border-color: var(--c3d-red);
}

/* ---------- Promotion dialog ---------- */
.chess3d-promotion-modal h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  color: var(--c3d-gold);
}

.chess3d-promotion-choices {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.chess3d-promo-btn {
  width: 64px;
  height: 64px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.chess3d-promo-btn:hover {
  border-color: var(--c3d-gold);
  background: rgba(201, 168, 76, 0.2);
  transform: scale(1.1);
}

/* ---------- Resign dialog ---------- */
.chess3d-resign-modal h2 {
  margin: 0 0 8px;
  color: var(--c3d-red);
  font-size: 1.2rem;
}

.chess3d-resign-modal p {
  color: var(--c3d-text-dim);
  margin: 0 0 14px;
  font-size: 0.85rem;
}

/* ---------- Game over ---------- */
.chess3d-gameover-modal h2 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  color: #fff;
}

.chess3d-gameover-reason {
  color: var(--c3d-text-dim);
  margin: 0 0 12px;
  font-size: 0.85rem;
}

.chess3d-elo-change {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 10px;
}

.chess3d-elo-change.positive { color: var(--c3d-emerald); }
.chess3d-elo-change.negative { color: var(--c3d-red); }
.chess3d-elo-change.neutral { color: var(--c3d-text-dim); }

.chess3d-gameover-stats {
  font-size: 0.8rem;
  color: var(--c3d-text-dim);
  margin-bottom: 6px;
}

/* ---------- Accessibility ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Responsive ---------- */
@media (min-width: 768px) {
  .chess3d-move-history {
    display: block;
  }

  .chess3d-player-top {
    left: auto;
    right: 164px;
    max-width: 350px;
  }

  .chess3d-player-bottom {
    left: auto;
    right: 164px;
    max-width: 350px;
  }

  .chess3d-turn-indicator {
    top: calc(96px + var(--c3d-safe-top));
  }
}

@media (max-width: 480px) {
  .chess3d-mobile-moves {
    display: block;
  }

  .chess3d-modal {
    padding: 20px 16px;
  }

  .chess3d-diff-btn,
  .chess3d-color-btn {
    min-width: 60px;
    min-height: 44px;
    padding: 7px 4px;
    font-size: 0.76rem;
  }

  /* Center HUD buttons for both-hand access */
  .chess3d-hud-buttons {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: calc(52px + var(--c3d-safe-bottom));
    flex-direction: row;
    gap: 10px;
  }

  .chess3d-hud-btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 0.95rem;
  }

  /* Compact player bars — less height, more space for board */
  .chess3d-player-bar {
    left: 6px;
    right: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 8px;
  }

  .chess3d-player-name {
    font-size: 0.78rem;
  }

  .chess3d-timer {
    font-size: 0.85rem;
    padding: 2px 8px;
  }

  .chess3d-player-top { top: calc(52px + var(--c3d-safe-top)); }
  .chess3d-player-bottom { bottom: calc(6px + var(--c3d-safe-bottom)); }

  /* Turn indicator — below top player bar with 8px gap */
  .chess3d-turn-indicator {
    top: calc(92px + var(--c3d-safe-top));
    font-size: 0.7rem;
    padding: 3px 10px;
  }

  /* Game clock smaller */
  .chess3d-game-clock {
    font-size: 0.65rem;
  }
}

@media (max-width: 360px) {
  .chess3d-diff-btn {
    min-width: 52px;
    font-size: 0.70rem;
    padding: 6px 3px;
  }

  .chess3d-coming-soon {
    display: block;
    margin-left: 0;
    margin-top: 2px;
  }
}

/* ---------- Focus visible ---------- */
.chess3d-btn:focus-visible,
.chess3d-diff-btn:focus-visible,
.chess3d-color-btn:focus-visible,
.chess3d-hud-btn:focus-visible,
.chess3d-promo-btn:focus-visible {
  outline: 2px solid var(--c3d-gold);
  outline-offset: 2px;
}

/* ---------- Settings Button (icon-only in row) ---------- */
.chess3d-btn-settings {
  flex: 0 0 44px !important;
  width: 44px;
  min-width: 44px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--c3d-text-dim);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 1.1rem;
  padding: 8px;
}

.chess3d-btn-settings:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--c3d-text);
}

/* ---------- Rejoin Button ---------- */
.chess3d-btn-rejoin {
  width: 100%;
  margin-bottom: 8px;
  background: rgba(212, 80, 74, 0.2);
  color: var(--c3d-red);
  border: 1px solid rgba(212, 80, 74, 0.5);
  font-weight: 700;
  animation: rejoinPulse 2s ease-in-out infinite;
}

.chess3d-btn-rejoin:hover {
  background: rgba(212, 80, 74, 0.3);
}

@keyframes rejoinPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 80, 74, 0.3); }
  50% { box-shadow: 0 0 12px 4px rgba(212, 80, 74, 0.2); }
}

/* ---------- Board Theme Selector ---------- */
.chess3d-theme-select {
  margin-bottom: 10px;
}

.chess3d-theme-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.chess3d-theme-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  min-width: 64px;
}

.chess3d-theme-btn:hover {
  border-color: rgba(201, 168, 76, 0.5);
  background: rgba(201, 168, 76, 0.1);
}

.chess3d-theme-btn.selected {
  border-color: var(--c3d-gold);
  background: rgba(201, 168, 76, 0.18);
}

.chess3d-theme-swatch {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.chess3d-theme-name {
  font-size: 0.65rem;
  color: var(--c3d-text-dim);
  font-weight: 600;
}

.chess3d-theme-btn.selected .chess3d-theme-name {
  color: var(--c3d-gold);
}

/* ---------- Piece Skin Selector ---------- */
.chess3d-skin-select {
  margin-bottom: 10px;
}

.chess3d-skin-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.chess3d-skin-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  position: relative;
  min-width: 72px;
}

.chess3d-skin-btn:hover {
  border-color: rgba(201, 168, 76, 0.5);
  background: rgba(201, 168, 76, 0.1);
}

.chess3d-skin-btn.selected {
  border-color: var(--c3d-gold);
  background: rgba(201, 168, 76, 0.18);
}

.chess3d-skin-btn.locked {
  opacity: 0.5;
}

.chess3d-skin-btn.locked:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
}

.chess3d-skin-icon {
  font-size: 1.5rem;
  color: var(--c3d-text);
  line-height: 1;
}

.chess3d-skin-name {
  font-size: 0.65rem;
  color: var(--c3d-text-dim);
  font-weight: 600;
}

.chess3d-skin-btn.selected .chess3d-skin-name {
  color: var(--c3d-gold);
}

.chess3d-skin-lock {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.6rem;
}

.chess3d-skin-btn:not(.locked) .chess3d-skin-lock {
  display: none;
}

.chess3d-skin-lock-tip {
  display: none;
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c3d-card);
  border: 1px solid var(--c3d-gold);
  color: var(--c3d-gold);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.6rem;
  white-space: nowrap;
  z-index: 10;
  font-weight: 600;
}

/* ---------- Daily Puzzle Button ---------- */
.chess3d-btn-puzzle {
  margin-top: 0;
  background: rgba(61, 170, 98, 0.2);
  color: var(--c3d-emerald);
  border: 1px solid rgba(61, 170, 98, 0.4);
}

.chess3d-btn-puzzle:hover {
  background: rgba(61, 170, 98, 0.3);
  border-color: var(--c3d-emerald);
}

.chess3d-puzzle-badge {
  font-size: 0.6rem;
  background: var(--c3d-emerald);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 6px;
  vertical-align: middle;
}

/* ---------- Puzzle HUD Overlay ---------- */
.chess3d-puzzle-hud {
  position: fixed;
  top: calc(130px + var(--c3d-safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  pointer-events: auto;
}

.chess3d-puzzle-card {
  background: var(--c3d-card);
  border: 1px solid var(--c3d-card-border);
  border-radius: 12px;
  padding: 10px 16px;
  text-align: center;
  min-width: 220px;
  max-width: 300px;
}

.chess3d-puzzle-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.chess3d-puzzle-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 1px 4px rgba(61, 170, 98, 0.4));
}

.chess3d-puzzle-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.chess3d-puzzle-diff {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--c3d-emerald);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chess3d-puzzle-desc {
  display: block;
  font-size: 0.7rem;
  color: var(--c3d-text-dim);
}

.chess3d-puzzle-status {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--c3d-text-dim);
  margin: 4px 0;
}

.chess3d-puzzle-status.correct {
  color: var(--c3d-emerald);
}

.chess3d-puzzle-status.wrong {
  color: var(--c3d-red);
}

.chess3d-puzzle-status.solved {
  color: var(--c3d-gold);
}

.chess3d-puzzle-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 6px;
}

/* ---------- Turn change animations ---------- */
.chess3d-turn-flash {
  animation: turnFlash 0.6s ease;
}

@keyframes turnFlash {
  0% { transform: translateX(-50%) scale(1); border-color: var(--c3d-gold); }
  30% { transform: translateX(-50%) scale(1.15); border-color: var(--c3d-gold); box-shadow: 0 0 12px rgba(201, 168, 76, 0.5); }
  100% { transform: translateX(-50%) scale(1); }
}

.chess3d-bar-pulse {
  animation: barPulse 0.6s ease;
}

@keyframes barPulse {
  0% { border-color: var(--c3d-card-border); }
  30% { border-color: var(--c3d-gold); box-shadow: 0 0 10px rgba(201, 168, 76, 0.3); }
  100% { border-color: var(--c3d-card-border); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .chess3d-thinking-dots span { animation: none; opacity: 0.7; }
  .chess3d-promo-btn:hover { transform: none; }
  .chess3d-btn:hover { transform: none; }
}

/* ---------- Responsive — theme/skin selectors ---------- */
@media (max-width: 480px) {
  .chess3d-theme-btn {
    min-width: 56px;
    padding: 4px 6px;
  }

  .chess3d-theme-swatch {
    width: 26px;
    height: 26px;
  }

  .chess3d-skin-btn {
    min-width: 60px;
    padding: 4px 8px;
  }

  .chess3d-skin-icon {
    font-size: 1.2rem;
  }

  .chess3d-puzzle-hud {
    top: calc(115px + var(--c3d-safe-top));
  }

  .chess3d-puzzle-card {
    min-width: 180px;
    padding: 8px 12px;
  }
}
