:root {
  --bg-page: #f4f6fb;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --accent-soft: #eff6ff;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --error: #dc2626;
  --error-bg: #fee2e2;
  --border: #cbd5e1;
  --cell-size: 38px;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding: 24px 16px;
}

.app-container {
  max-width: 1120px;
  margin: 0 auto;
}

.app-header {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.app-header h1 {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-main);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 4px;
}

.progress-card {
  min-width: 220px;
  background: var(--accent-soft);
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid var(--primary-light);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.progress-count {
  color: var(--primary);
}

.progress-bar-bg {
  height: 8px;
  background: #cbd5e1;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.workspace {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 24px;
  align-items: start;
}

.board-section,
.clues-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.active-clue-banner {
  background: var(--accent-soft);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 20px;
}

.clue-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  display: block;
  margin-bottom: 2px;
}

.clue-text {
  font-size: 0.95rem;
  color: var(--text-main);
}

.board-wrapper {
  display: flex;
  justify-content: center;
  overflow-x: auto;
  padding: 4px 0 16px;
}

.crossword-grid {
  display: grid;
  gap: 3px;
  background: transparent;
  user-select: none;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  position: relative;
}

.cell.empty {
  background: transparent;
}

.cell.active-cell {
  background: #ffffff;
  border: 2px solid #94a3b8;
  border-radius: 5px;
  transition: border-color 0.15s, background-color 0.15s;
}

.cell.active-cell.in-word {
  background: var(--primary-light);
  border-color: var(--primary);
}

.cell.active-cell.focused {
  background: #bfdbfe;
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.cell.active-cell.correct {
  background: var(--success-bg);
  border-color: var(--success);
}

.cell.active-cell.incorrect {
  background: var(--error-bg);
  border-color: var(--error);
}

.cell-number {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  pointer-events: none;
  line-height: 1;
}

.cell-input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  padding-top: 6px;
}

.actions-bar {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.feedback-toast {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
}

.feedback-toast.success {
  background: var(--success-bg);
  color: #166534;
}

.feedback-toast.info {
  background: var(--primary-light);
  color: #1e40af;
}

.feedback-toast.error {
  background: var(--error-bg);
  color: #991b1b;
}

.hidden {
  display: none !important;
}

.clues-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.clues-group h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 2px solid var(--bg-page);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.clues-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clue-item {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.15s, border-color 0.15s;
}

.clue-item:hover {
  background: var(--bg-page);
}

.clue-item.active {
  background: var(--accent-soft);
  border-color: var(--primary-light);
}

.clue-item.solved {
  background: var(--success-bg);
  border-color: #bbf7d0;
}

.clue-item-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--primary);
}

.clue-item.solved .clue-item-header {
  color: var(--success);
}

.clue-explanation {
  font-size: 0.82rem;
  color: #166534;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #bbf7d0;
}

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 200;
}

.mambo-container {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 130px;
  height: 130px;
  cursor: pointer;
  z-index: 250;
  user-select: none;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.25));
  animation: mamboEntrance 1.2s ease-in-out forwards;
}

@keyframes mamboEntrance {
  0% {
    bottom: 50%;
    right: 50%;
    transform: translate(50%, 50%) scale(3);
  }
  40% {
    bottom: 50%;
    right: 50%;
    transform: translate(50%, 50%) scale(3);
  }
  100% {
    bottom: 28px;
    right: 28px;
    transform: translate(0, 0) scale(1);
  }
}

.mambo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: mamboSpin 2.8s linear infinite;
  transition: transform 0.12s ease;
}

.mambo-container.mambo-fast .mambo-img {
  animation-duration: 0.93s;
}

.mambo-container.mambo-pop {
  animation: mamboPop 0.25s ease-out;
}

@keyframes mamboSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes mamboPop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.28);
  }
  100% {
    transform: scale(1);
  }
}

.explosion-overlay {
  position: fixed;
  inset: 0;
  background: #000000;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.explosion-overlay video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  :root {
    --cell-size: 32px;
  }
}
