:root {
  --primary: #8cb365;
  --accent: #e2b740;
  --bg: #1e1d1b;
  --grey: #6b7280;
  --border: #484c53;
  --danger: #e04e4a;
}

/* Keep every panel child fully inside its parent (padding/borders included) */
.puzzle-panel,
.puzzle-panel * {
  box-sizing: border-box;
  min-width: 0;
}

/* ===== Puzzle panel (same slot as .move-history-box on the other pages) ===== */
.puzzle-panel {
  position: absolute;
  display: none;
  top: 50%;
  transform: translateY(-50%);
  right: 5%;
  flex-direction: column;
  align-items: start;
  justify-content: start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 12px;
  height: 90%;
  width: 230px;
}

.puzzle-panel-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-size: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--grey);
}
.puzzle-panel-header p {
  margin: 0;
  flex: 1;
}
.puzzle-counter {
  color: var(--grey);
  font-size: 12px;
}

.puzzle-progress-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.puzzle-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* Generating / empty states */
.puzzle-generating,
.puzzle-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  text-align: center;
  color: var(--grey);
  font-size: 13px;
}
.puzzle-generating i,
.puzzle-empty i {
  font-size: 26px;
  color: var(--primary);
}
.puzzle-generating-sub {
  font-size: 11px;
  margin: 0;
}

/* Active puzzle */
.puzzle-active {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  height: 100%;
}
.puzzle-prompt {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.puzzle-feedback {
  min-height: 32px;
  font-size: 12.5px;
  line-height: 1.35;
  padding: 6px 8px;
  border-radius: 6px;
  display: none;
}
.puzzle-feedback.info { display: block; color: var(--grey); }
.puzzle-feedback.error { display: block; color: #ff8f8d; background: rgba(224, 78, 74, 0.12); border: 1px solid rgba(224, 78, 74, 0.4); }
.puzzle-feedback.success { display: block; color: #b7d99a; background: rgba(140, 179, 101, 0.12); border: 1px solid rgba(140, 179, 101, 0.4); }

.puzzle-info-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px;
}
.puzzle-info-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.puzzle-info-row i {
  color: var(--grey);
  width: 14px;
  text-align: center;
  font-size: 12px;
}
.puzzle-info-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.puzzle-info-label {
  font-size: 10px;
  color: var(--grey);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.puzzle-info-value {
  font-size: 12.5px;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: break-word;
}
.puzzle-info-value a {
  color: var(--accent);
  text-decoration: none;
}

/* Controls */
.puzzle-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 100%;
}
.puzzle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 4px;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  color: #d6d6d6;
  background: var(--bg);
  transition: border-color 0.2s ease, color 0.2s ease;
}
.puzzle-btn:hover:not(.disabled) {
  border-color: var(--primary);
  color: var(--primary);
}
.puzzle-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.puzzle-btn-primary {
  border-color: var(--primary);
  color: var(--primary);
}

/* Puzzle move list */
.puzzle-moves-container {
  width: 100%;
  max-width: 100%;
  overflow-y: auto;
  flex: 1;
  min-height: 40px;
}
.puzzle-move { cursor: default; }
.puzzle-move-blunder { color: #ff8f8d; }
.puzzle-move-user { color: #b7d99a; }
.puzzle-move-opponent { color: #d6d6d6; }

/* ===== Board square highlights ===== */
.puzzle-square-blunder { background: rgba(224, 78, 74, 0.55) !important; }
.puzzle-square-correct { background: rgba(140, 179, 101, 0.55) !important; }
.puzzle-square-reply { background: rgba(107, 114, 128, 0.45) !important; }
.puzzle-square-wrong {
  background: rgba(224, 78, 74, 0.8) !important;
  animation: wrong-flash 0.9s ease-in-out;
}
@keyframes wrong-flash {
  0%, 100% { background: rgba(224, 78, 74, 0.8) !important; }
  50% { background: rgba(224, 78, 74, 0.25) !important; }
}
#board.shake {
  animation: board-shake 0.4s ease-in-out;
}
@keyframes board-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}
