/* Sudoku Solver Styles - Scoped to avoid conflicts */

/* Page header styling - matches other pages */
.sudoku-container .page-header {
  text-align: left;
  margin-bottom: 15px;
  padding: 0 30px;
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.sudoku-container .page-header h1 {
  font-size: 26px;
  font-weight: 600;
  color: #2b2d42;
  margin: 8px 0 8px 0;
  line-height: 1.3;
}

.sudoku-container .page-description {
  font-size: 15px;
  color: #666;
  line-height: 1.4;
  margin: 0 0 6px;
  width: 100%;
}

/* Game info card styling - scoped */
.sudoku-container .game-info-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid #e0e0e0;
}

.sudoku-container .game-info-card h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #2b2d42;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sudoku-container .game-info-card h3 i {
  color: #4a7ba7;
  font-size: 18px;
}

.sudoku-container .game-info-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #555;
}

/* Info card styling - scoped */
.sudoku-container .info-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid #e0e0e0;
}

.sudoku-container .info-card h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: #2b2d42;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sudoku-container .info-card h3 i {
  color: #4a7ba7;
  font-size: 18px;
}

.sudoku-container .info-content p {
  margin: 0 0 8px 0;
  font-size: 13px;
  line-height: 1.4;
  color: #555;
}

.sudoku-container .info-content p:last-child {
  margin-bottom: 0;
}

.sudoku-container .info-content strong {
  color: #2b2d42;
  font-weight: 600;
}

/* Control card styling - scoped */
.sudoku-container .control-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border: 1px solid #e0e0e0;
}

.sudoku-container .control-card h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: #2b2d42;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sudoku-container .control-card h3 i {
  color: #4a7ba7;
  font-size: 18px;
}

/* Sudoku grid styling to match homepage */
.main-sudoku-grid {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(9, 60px);
  grid-template-rows: repeat(9, 60px);
  box-shadow: inset 0 0 5px #ddd;
  padding: 0;
  background: #55555569;
  border: 2px solid #555;
  margin: 0 auto;
  width: fit-content;
}

.main-grid-cell {
  background: #fafafa !important;
  border: 0.5px solid #d0d0d0 !important;
  font-size: 24px !important;
  font-weight: 500 !important;
  color: #2b2d42 !important;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.main-grid-cell.filled {
  background: #e8f4f8 !important;
  color: #1a5f7a !important;
  font-weight: 600 !important;
}

.main-grid-cell:not(.filled) {
  color: #4a7ba7 !important;
  font-weight: 600 !important;
}

.main-grid-cell.selected {
  background: #e3f2fd !important;
  color: #1976d2 !important;
  border: 2px solid #1976d2 !important;
}

.main-grid-cell.solved {
  background: #e8f5e9 !important;
  color: #2e7d32 !important;
  font-weight: 600 !important;
}

.main-grid-cell.err {
  background: #ffebee !important;
  color: #d32f2f !important;
  border: 2px solid #f44336 !important;
}

/* Center the solver container like main game */
.sudoku-container {
  display: grid;
  place-items: center;
  padding: 40px 20px;
  min-height: calc(100vh - 200px);
}

/* Base game-container styling (missing from main app.css) */
.game-container {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.game-area {
  flex: 1;
  max-width: 600px;
}

.numbers-sidebar {
  width: 300px;
  flex-shrink: 0;
  box-sizing: border-box;
}

/* Base numbers-top styling for left side */
.game-info-card .numbers-top {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
  box-sizing: border-box;
}

.game-info-card .numbers-top .number {
  width: 100%;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  background: #fff;
  color: #2b2d42;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  box-sizing: border-box;
}

.game-info-card .numbers-top .number:hover {
  border-color: #4a7ba7;
  background: #f8f9fa;
}

.game-info-card .numbers-top .delete {
  grid-column: 1 / -1;
  width: 100%;
  height: 45px;
  box-sizing: border-box;
  margin-top: 8px;
}

/* Base numbers-top styling (missing from main app.css) */
.numbers-sidebar .numbers-top {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, 45px) auto;
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
  box-sizing: border-box;
}

.numbers-sidebar .numbers-top .number:nth-child(n+6) {
  grid-row: 2;
}

.numbers-sidebar .numbers-top .number:nth-child(6) { grid-column: 1; }
.numbers-sidebar .numbers-top .number:nth-child(7) { grid-column: 2; }
.numbers-sidebar .numbers-top .number:nth-child(8) { grid-column: 3; }
.numbers-sidebar .numbers-top .number:nth-child(9) { grid-column: 4; }

.numbers-sidebar .numbers-top .delete {
  grid-row: 2;
  grid-column: 5;
  width: 100%;
  height: 45px;
  box-sizing: border-box;
}

.numbers-sidebar .numbers-top .number {
  width: 100%;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  background: #fff;
  color: #2b2d42;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  box-sizing: border-box;
}

.numbers-sidebar .numbers-top .number:hover {
  border-color: #4a7ba7;
  background: #f8f9fa;
}

/* Mobile responsive improvements */
@media (max-width: 768px) {
  .sudoku-container {
    padding: 20px 8px;
  }
  
  .page-header {
    margin-bottom: 15px;
    padding: 0 8px;
  }
  
  .page-header h1 {
    font-size: 20px;
    margin: 5px 0 4px 0;
    line-height: 1.2;
  }
  
  .page-description {
    font-size: 14px;
  }
  
  .game-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 0;
    align-items: center;
  }
  
  .game-area {
    order: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 400px;
  }
  
  .numbers-sidebar {
    order: 2;
    width: 100%;
    display: flex;
    flex-direction: column;
  }
  
  /* Move Solver Actions above Getting Started on mobile */
  .numbers-sidebar .control-card {
    order: 1; /* Solver Actions first */
  }
  
  .numbers-sidebar .info-card {
    order: 2; /* Getting Started second */
  }
  
  /* Center align game info card */
  .game-info-card {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
  }
  
  /* Numbers grid mobile layout */
  .game-info-card .numbers-top {
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
    justify-content: center;
  }
  
  /* Center align sudoku grid */
  .main-sudoku-grid {
    margin: 0 auto !important;
    justify-self: center;
  }
  
  .game-info-card .numbers-top .number {
    height: 40px;
    font-size: 14px;
  }
  
  .game-info-card .numbers-top .delete {
    height: 40px;
    font-size: 14px;
    margin-top: 6px;
  }
  
  /* Control buttons mobile layout */
  .control-card, .info-card {
    margin-bottom: 12px;
  }
}

/* iPhone 14 Pro Max and similar 430px width devices */
@media (max-width: 430px) {
  .sudoku-container {
    padding: 8px 0;
    width: 100%;
  }
  
  .game-container {
    padding: 0 4px;
    max-width: 430px;
    margin: 0 auto;
  }
  
  .game-area {
    max-width: 100%;
    width: 100%;
  }
  
  .game-info-card {
    max-width: 100%;
    margin: 0 auto;
  }
  
  /* Revert sudoku grid to proper size and center it */
  .main-sudoku-grid {
    grid-template-columns: repeat(9, 42px) !important;
    grid-template-rows: repeat(9, 42px) !important;
    gap: 2px !important;
    margin: 0 auto !important;
    padding: 4px !important;
    width: fit-content !important;
    max-width: none !important;
  }
  
  .main-grid-cell {
    font-size: 20px !important;
  }
  
  /* Adjust numbers for 430px */
  .game-info-card .numbers-top .number {
    height: 38px;
    font-size: 14px;
  }
  
  .game-info-card .numbers-top .delete {
    height: 38px;
    font-size: 13px;
  }
}

/* Samsung Galaxy A53 and similar 390px width devices */
@media (max-width: 390px) {
  .sudoku-container {
    padding: 8px 0;
    width: 100%;
  }
  
  .game-container {
    padding: 0 8px;
    max-width: 390px;
    margin: 0 auto;
  }
  
  .page-header h1 {
    font-size: 20px;
    margin: 5px 0 4px 0;
    line-height: 1.2;
  }
  
  .page-description {
    font-size: 13px;
  }
  
  .game-area {
    max-width: 100%;
    width: 100%;
  }
  
  .game-info-card {
    max-width: 100%;
    margin: 0 auto;
  }
  
  /* Expand container for sudoku grid instead of shrinking grid */
  .main-sudoku-grid {
    grid-template-columns: repeat(9, 34px) !important;
    grid-template-rows: repeat(9, 34px) !important;
    gap: 1px !important;
    margin: 0 auto !important;
    padding: 2px !important;
    width: fit-content !important;
    height: fit-content !important;
    max-width: 320px !important;
    max-height: 320px !important;
    box-sizing: border-box !important;
  }
  
  /* Ensure grid stays within screen and main-game container */
  .screen {
    overflow: hidden;
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
    box-sizing: border-box;
  }
  
  .main-game {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 5px;
    min-height: auto;
    height: fit-content;
  }
  
  .main-grid-cell {
    font-size: 16px !important;
    box-sizing: border-box;
    width: 34px !important;
    height: 34px !important;
  }
  
  /* Compact control buttons */
  .control-btn {
    padding: 8px !important;
    font-size: 13px !important;
  }
  
  .info-content p {
    font-size: 12px !important;
    line-height: 1.3 !important;
    margin-bottom: 6px !important;
  }
  
  /* Optimize all sections for compact 390px layout */
  .page-header {
    margin-bottom: 15px;
    padding: 0 8px;
  }
  
  .game-info-card {
    padding: 12px;
    margin: 0 4px 10px 4px;
  }
  
  .game-info-card h3 {
    font-size: 14px;
    margin-bottom: 8px;
  }
  
  .game-info-card h3 i {
    font-size: 16px;
  }
  
  /* Compact numbers grid */
  .game-info-card .numbers-top {
    gap: 3px;
    margin-bottom: 8px;
  }
  
  .game-info-card .numbers-top .number {
    height: 32px;
    font-size: 13px;
  }
  
  .game-info-card .numbers-top .delete {
    height: 32px;
    font-size: 12px;
    margin-top: 4px;
  }
  
  /* Compact sidebar sections */
  .control-card, .info-card {
    margin: 0 4px 8px 4px;
    padding: 12px;
  }
  
  .control-card h3, .info-card h3 {
    font-size: 14px;
    margin-bottom: 8px;
  }
  
  .control-card h3 i, .info-card h3 i {
    font-size: 16px;
  }
  
  /* Reduce gaps in control sections */
  .game-container {
    gap: 10px;
  }
}

/* Ad slot styling */
#ad-slot-sidebar {
  display: block;
  margin-top: 20px;
}

@media (max-width: 768px) {
  #ad-slot-sidebar {
    display: none;
  }
}
  cursor: pointer;
  transition: all 0.2s;
}

.numbers-top .number:hover,
.numbers-top .delete:hover,
.numbers-top #candidates-btn:hover {
  border-color: #4a7ba7;
  background: #f8f9fa;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Solver-specific grid adjustments */
.main-grid-cell {
  cursor: pointer !important;
}

.main-grid-cell.user-input {
  color: #4a7ba7 !important;
  font-weight: 600 !important;
}

.main-grid-cell.solved {
  color: #28a745 !important;
  background: #d4edda !important;
}

/* Hint message error state */
#hint-message.error {
  background: #f8d7da !important;
  border-left-color: #dc3545 !important;
  color: #721c24 !important;
}

/* Technique Panel */
.technique-panel {
  margin: 20px 0;
  padding: 20px;
  background: #e8f5e8;
  border: 1px solid #28a745;
  border-radius: 8px;
}

.technique-panel h3 {
  margin: 0 0 10px 0;
  color: #155724;
  font-size: 16px;
}

.technique-panel p {
  margin: 0 0 10px 0;
  color: #155724;
  line-height: 1.5;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h3 {
  margin: 0 0 15px 0;
  color: #2b2d42;
}

.modal-content textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
  margin-bottom: 15px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-buttons .control-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 80px;
}

.modal-buttons .control-btn.primary {
  background: #4a7ba7;
  color: white;
}

.modal-buttons .control-btn.secondary {
  background: #6c757d;
  color: white;
}

/* Instructions */
.instructions-section {
  margin-top: 40px;
  padding: 30px 0;
  border-top: 1px solid #e9ecef;
}

.instructions-section h2 {
  text-align: center;
  margin-bottom: 30px;
  color: #2b2d42;
}

.instructions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 25px;
  margin-top: 20px;
}

.instruction-item {
  text-align: center;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 12px;
  border: 1px solid #e9ecef;
}

.instruction-icon {
  font-size: 32px;
  margin-bottom: 15px;
}

.instruction-item h3 {
  margin: 0 0 10px 0;
  color: #2b2d42;
  font-size: 16px;
}

.instruction-item p {
  margin: 0;
  color: #666;
  font-size: 14px;
  line-height: 1.5;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .instructions-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .modal-content {
    padding: 20px;
    margin: 20px;
  }
}

@media (max-width: 480px) {
  .modal-buttons {
    flex-direction: column;
  }
  
  .modal-buttons .control-btn {
    width: 100%;
  }
}
