/* =====================================================================
   Kids Sudoku Game Styles (Ages 5-7)
   4x4 Animal Logic Puzzle Board, Row/Col Highlights & Animal Palette
   ===================================================================== */

:root {
  --wood-border: #78350f;
  --wood-warm: #b45309;
  --wood-light: #fef3c7;
  --board-bg: #fffbeb;
  --quad-line: #92400e;
  --cell-size: 72px;
}

body {
  background: radial-gradient(circle at 50% 15%, #bbf7d0 0%, #86efac 40%, #6ee7b7 100%);
  color: #1e293b;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow: hidden;
}

.game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
}

/* ---------------------------------------------------------------------
   Workspace Layout
   --------------------------------------------------------------------- */

.sudoku-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 4px 12px 10px;
  box-sizing: border-box;
  position: relative;
}

/* ---------------------------------------------------------------------
   Status Bar
   --------------------------------------------------------------------- */

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 12px;
  margin-bottom: 4px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid #16a34a;
  border-radius: 20px;
  padding: 4px 14px;
  font-weight: 800;
  font-size: 0.95rem;
  color: #14532d;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.badge-icon {
  font-size: 1.25rem;
}

/* ---------------------------------------------------------------------
   Sudoku Board
   --------------------------------------------------------------------- */

.board-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: auto 0;
}

.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  width: min(340px, 86vw, 44vh);
  height: min(340px, 86vw, 44vh);
  aspect-ratio: 1 / 1;
  background: var(--board-bg);
  border: 6px solid var(--wood-border);
  border-radius: 22px;
  box-shadow: 0 12px 28px rgba(120, 53, 15, 0.25), inset 0 0 12px rgba(180, 83, 9, 0.15);
  overflow: hidden;
}

.sudoku-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  line-height: 1;
  background: #ffffff;
  border: 1px dashed rgba(180, 83, 9, 0.35);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease;
  box-sizing: border-box;
}

/* Thick quadrant division borders */
.sudoku-cell[data-col="1"] {
  border-right: 3px solid var(--quad-line);
}
.sudoku-cell[data-col="2"] {
  border-left: 1px solid var(--quad-line);
}
.sudoku-cell[data-row="1"] {
  border-bottom: 3px solid var(--quad-line);
}
.sudoku-cell[data-row="2"] {
  border-top: 1px solid var(--quad-line);
}

/* Fixed clue cell */
.sudoku-cell.fixed-cell {
  background: #fef3c7;
  cursor: default;
}

/* Focus and related highlighting */
.sudoku-cell.highlight-related {
  background: #ffedd5;
}

.sudoku-cell.selected-cell {
  background: #fde68a !important;
  box-shadow: inset 0 0 0 3px #f59e0b, 0 0 16px rgba(245, 158, 11, 0.5);
  transform: scale(1.02);
  z-index: 5;
}

/* Conflict state */
.sudoku-cell.conflict-cell {
  background: #fee2e2 !important;
  border-color: #ef4444;
  animation: conflictShake 0.4s ease-in-out;
}

@keyframes conflictShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Completed line flash */
.sudoku-cell.line-flash {
  animation: lineGlow 0.6s ease-out;
}

@keyframes lineGlow {
  0% { filter: brightness(1.4) drop-shadow(0 0 8px #facc15); }
  100% { filter: brightness(1); }
}

/* ---------------------------------------------------------------------
   Controls & Animal Palette
   --------------------------------------------------------------------- */

.controls-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.animal-palette {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  width: 100%;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 3px solid #16a34a;
  border-radius: 20px;
  padding: 8px 12px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.animal-btn {
  flex: 1;
  aspect-ratio: 1 / 1;
  max-width: 68px;
  border-radius: 18px;
  background: linear-gradient(135deg, #ffffff 0%, #fef3c7 100%);
  border: 2px solid #f59e0b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.12s ease, filter 0.15s ease;
  padding: 0;
}

.animal-btn:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.08);
  filter: brightness(1.1);
}

.animal-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.animal-emoji {
  font-size: 2.2rem;
  line-height: 1;
}

/* Actions Row */
.actions-row {
  display: flex;
  gap: 8px;
  width: 100%;
}

.action-btn {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 10px 16px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s ease, filter 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.action-btn:active {
  transform: scale(0.96);
}

.erase-btn {
  flex: 1;
  background: #64748b;
  border-bottom: 3px solid #475569;
}

.erase-btn:hover {
  background: #475569;
}

.reset-btn {
  flex: 1;
  background: #0284c7;
  border-bottom: 3px solid #0369a1;
}

.reset-btn:hover {
  background: #0369a1;
}

.next-btn {
  flex: 2;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-bottom: 4px solid #b45309;
  font-size: 1.15rem;
}

.play-again-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-bottom: 4px solid #047857;
  padding: 12px 28px;
  font-size: 1.12rem;
}

.hidden {
  display: none !important;
}

/* Accessibility focus ring */
.sudoku-cell:focus-visible,
.animal-btn:focus-visible,
.action-btn:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
   Sparks & Celebration Modal
   --------------------------------------------------------------------- */

.sparks-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 40;
}

.sparkle {
  position: absolute;
  font-size: 1.5rem;
  animation: sparkBurst 0.8s ease-out forwards;
}

@keyframes sparkBurst {
  0% { transform: translate(0, 0) scale(0.5); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.3); opacity: 0; }
}

.celebration-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 16px;
}

.celebration-card {
  background: #ffffff;
  border: 4px solid #f59e0b;
  padding: 24px 28px;
  border-radius: 28px;
  text-align: center;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
  max-width: 420px;
  width: 100%;
  animation: cardBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.celebration-icon {
  font-size: 3.2rem;
  margin-bottom: 8px;
}

.celebration-text {
  font-size: 1.25rem;
  font-weight: 800;
  color: #78350f;
  margin-bottom: 20px;
  line-height: 1.4;
}

@keyframes cardBounce {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------------------------------------------------------------------
   Mobile Responsive
   --------------------------------------------------------------------- */

@media (max-width: 480px) {
  .sudoku-cell {
    font-size: 1.8rem;
  }
  .animal-btn {
    max-width: 58px;
  }
  .animal-emoji {
    font-size: 1.8rem;
  }
  .action-btn {
    font-size: 0.95rem;
    padding: 8px 12px;
  }
}

@media (max-height: 540px) {
  .status-bar {
    margin-bottom: 2px;
  }
  .status-badge {
    padding: 2px 10px;
    font-size: 0.85rem;
  }
  .animal-palette {
    padding: 4px 8px;
    gap: 6px;
  }
  .animal-btn {
    max-width: 48px;
  }
  .animal-emoji {
    font-size: 1.6rem;
  }
  .action-btn {
    padding: 6px 10px;
    font-size: 0.9rem;
  }
}

/* ---------------------------------------------------------------------
   Reduced Motion
   --------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .sudoku-cell,
  .sudoku-cell.conflict-cell,
  .sudoku-cell.line-flash,
  .celebration-card {
    transition: none !important;
    animation: none !important;
  }
}
