/* Mini Sudoku Game Specific Styles */

/* Page Layout - Match main site */
.main {
  padding: 20px 0;
}

.game-header-section {
  text-align: left;
  margin-bottom: 15px;
  padding: 0 30px;
}

.heading-primary {
  font-size: 26px;
  font-weight: 600;
  color: #2b2d42;
  margin: 8px 0;
  line-height: 1.3;
}

.game-subtitle {
  font-size: 16px;
  color: #666;
  margin: 0 0 15px 0;
  line-height: 1.4;
}

/* Game Layout - Match main site width */
.game-container {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 30px;
  align-items: start;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 30px;
}

#game-screen {
  width: 100%;
  margin: 0 auto;
}

.game-area {
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  margin: 0 auto;
}

.screen {
  width: 100%;
}

.main-game {
  display: block;
}

.main-game.active {
  display: block;
}

/* Mini Sudoku Grid - 6x6 with moderate size for desktop */
body .main-sudoku-grid {
  display: grid !important;
  grid-template-columns: repeat(6, 70px) !important;
  grid-template-rows: repeat(6, 70px) !important;
  gap: 4px !important;
  margin: 20px auto !important;
  padding: 6px !important;
  background: #ffffff !important;
  border: 2px solid #2b2d42 !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
  border-radius: 4px !important;
  width: fit-content !important;
  max-width: none !important;
  height: auto !important;
}

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

/* No separators - clean grid */

/* Main site cell states */
body .main-grid-cell.filled {
  background: #e8f4f8 !important;
  color: #1a5f7a !important;
  font-weight: 600 !important;
}

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

body .main-grid-cell.selected {
  background: #fff9e6 !important;
  color: #4a7ba7 !important;
  border: 2px solid #ffc107 !important;
  box-shadow: 0 0 0 2px rgba(255,193,7,0.3) !important;
  transform: scale(1.02) !important;
}

body .main-grid-cell:hover:not(.filled):not(.selected) {
  background: #f0f7ff !important;
  border: 2px solid #4a7ba7 !important;
  transform: scale(1.02) !important;
}

body .main-grid-cell.hover:not(.selected) {
  background: #fff9e6 !important;
  border: 2px solid #ffc107 !important;
}

body .main-grid-cell.err {
  background: #ffe5e5 !important;
  color: #d32f2f !important;
  border: 2px solid #d32f2f !important;
  animation: shake 0.3s !important;
}

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

body .main-grid-cell.conflict {
  background: #ffe5e5 !important;
  border-color: #d32f2f !important;
  color: #d32f2f !important;
}

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

/* No separators - clean grid */

/* Numbers Section - Desktop: 2 rows (numbers + controls) */
.numbers-top {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 25px;
}

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

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

/* Notes toggle button active state */
#toggle-notes.active {
  background: #4a7ba7 !important;
  color: white !important;
  border-color: #4a7ba7 !important;
}

/* Control buttons in second row - evenly distributed */
.numbers-top .delete {
  grid-column: 1 / 3;
  grid-row: 2;
  height: 55px;
  font-size: 20px;
}

.numbers-top #toggle-notes {
  grid-column: 3 / 5;
  grid-row: 2;
  height: 55px;
  font-size: 16px;
}

.numbers-top #btn-hint {
  grid-column: 5 / 7;
  grid-row: 2;
  height: 55px;
  font-size: 16px;
}

.numbers-top .delete {
  width: 100%;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  background: #fff0f0;
  color: #e74c3c;
  border: 2px solid #ffcdd2;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.numbers-top #toggle-notes,
.numbers-top #btn-hint {
  width: 100%;
  height: 45px;
}

/* Control Cards */
.control-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 1px solid #e0e0e0;
}

.control-card h3 {
  margin: 0 0 15px 0;
  font-size: 16px;
  color: #2b2d42;
  font-weight: 600;
}

/* Numbers Sidebar */
.numbers-sidebar {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Action Buttons Row */
.action-buttons-row {
  display: flex;
  gap: 8px;
  margin-top: 15px;
}

.action-buttons-row > * {
  flex: 1;
  height: 45px;
  font-size: 14px;
  padding: 0 12px;
}

/* Button Styles - Match main site */
.compact-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.primary-btn {
  background: #4a7ba7;
  color: #fff;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.primary-btn:hover {
  background: #3d6a91;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(74,123,167,0.3);
}

.control-card .primary-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.control-card .primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102,126,234,0.4);
}

.control-card button i {
  font-size: 18px;
}

/* Difficulty Links - Override main site styles */
.difficulty-link {
  display: inline-block !important;
  padding: 6px 12px !important;
  font-size: 13px !important;
  background: #f0f0f0 !important;
  color: #666 !important;
  text-decoration: none !important;
  border-radius: 6px !important;
  margin: 2px !important;
  transition: all 0.2s !important;
  min-width: auto !important;
}

.difficulty-link:hover {
  background: #4a7ba7 !important;
  color: white !important;
}

/* Game Screens */
.start-screen,
.pause-screen,
.result-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(43, 45, 66, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  color: white;
  text-align: center;
  padding: 20px;
  box-sizing: border-box;
}

.start-screen h1 {
  font-size: 24px;
  margin: 12px 0 6px;
  font-weight: 600;
  line-height: 1.3;
  display: flex;
  flex-direction: column;
}

.start-screen h2 {
  font-size: 16px;
  margin: 6px 0 12px;
  font-weight: 500;
}

/* Tips and Benefits Sections - Match mistakes section format */
.tips-section,
.why-play-section {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
}

.tips-section h2,
.why-play-section h2 {
  font-size: 28px;
  font-weight: 600;
  color: #2b2d42;
  margin: 0 0 12px;
  line-height: 1.2;
  text-align: center;
}

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

.tip-card,
.benefit-card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.tip-card h3,
.benefit-card h3 {
  font-size: 18px;
  color: #2b2d42;
  margin: 15px 0 10px;
  font-weight: 600;
}

.tip-card p,
.benefit-card p {
  color: #666;
  line-height: 1.5;
  margin: 0;
}

/* Desktop Numbers Layout - Force full width like main site */
.numbers-top {
  display: grid !important;
  grid-template-columns: repeat(6, 1fr) !important;
  gap: 8px !important;
  row-gap: 15px !important;
  margin-bottom: 20px !important;
  width: 100% !important;
}

/* Control buttons in second row - spanning columns */
.numbers-top .delete {
  grid-row: 2 !important;
  grid-column: 1 / 3 !important;
}

#toggle-notes {
  grid-row: 2 !important;
  grid-column: 3 / 5 !important;
}

#btn-hint {
  grid-row: 2 !important;
  grid-column: 5 / 7 !important;
}

/* Clean 6x6 Mini-Sudoku Separators - Simple approach */
/* Override ALL main sudoku rules completely */
.main-sudoku-grid .main-grid-cell,
.main-sudoku-grid .main-grid-cell:nth-child(3n):not(:nth-child(9n)),
.main-sudoku-grid .main-grid-cell:nth-child(n+19):nth-child(-n+27),
.main-sudoku-grid .main-grid-cell:nth-child(n+46):nth-child(-n+54) {
  border: 0.5px solid #d0d0d0 !important;
}

/* Mini-sudoku separators: 1 vertical + 2 horizontal */
/* Vertical: cells 3,9,15,21,27,33 */
.main-sudoku-grid .main-grid-cell:nth-child(3),
.main-sudoku-grid .main-grid-cell:nth-child(9),
.main-sudoku-grid .main-grid-cell:nth-child(15),
.main-sudoku-grid .main-grid-cell:nth-child(21),
.main-sudoku-grid .main-grid-cell:nth-child(27),
.main-sudoku-grid .main-grid-cell:nth-child(33) {
  border-right: 1.5px solid #666 !important;
}

/* Horizontal: cells 7-12 and 19-24 */
.main-sudoku-grid .main-grid-cell:nth-child(7),
.main-sudoku-grid .main-grid-cell:nth-child(8),
.main-sudoku-grid .main-grid-cell:nth-child(9),
.main-sudoku-grid .main-grid-cell:nth-child(10),
.main-sudoku-grid .main-grid-cell:nth-child(11),
.main-sudoku-grid .main-grid-cell:nth-child(12),
.main-sudoku-grid .main-grid-cell:nth-child(19),
.main-sudoku-grid .main-grid-cell:nth-child(20),
.main-sudoku-grid .main-grid-cell:nth-child(21),
.main-sudoku-grid .main-grid-cell:nth-child(22),
.main-sudoku-grid .main-grid-cell:nth-child(23),
.main-sudoku-grid .main-grid-cell:nth-child(24) {
  border-bottom: 1.5px solid #666 !important;
}

/* 2 horizontal lines - after rows 2 and 4 (cells 7-12 and 19-24) */
body .main-grid-cell:nth-child(n+7):nth-child(-n+12),
body .main-grid-cell:nth-child(n+19):nth-child(-n+24) {
  border-bottom: 1.5px solid #666 !important;
}

/* Mobile Responsive - Match main site */
@media (max-width: 768px) {
  .main {
    padding: 10px 0;
  }
  
  .game-header-section {
    margin-bottom: 20px;
    padding: 0 8px;
  }
  
  .game-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 0 8px;
  }

  .numbers-top {
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    row-gap: 15px;
    margin-bottom: 15px;
  }

  .numbers-top .number {
    height: 48px;
    font-size: 20px;
  }

  /* Control buttons in second row - red eraser */
  .numbers-top .delete {
    grid-column: 1 / 3;
    grid-row: 2;
    height: 48px;
    font-size: 18px;
    background: #fff0f0;
    color: #e74c3c;
    border: 2px solid #ffcdd2;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .numbers-top #toggle-notes {
    grid-column: 3 / 5;
    grid-row: 2;
  }

  .numbers-top #btn-hint {
    grid-column: 5 / 7;
    grid-row: 2;
  }

  body .main-sudoku-grid {
    grid-template-columns: repeat(6, 65px) !important;
    grid-template-rows: repeat(6, 65px) !important;
    gap: 5px !important;
    width: fit-content !important;
    height: fit-content !important;
    max-width: none !important;
    border: 2px solid #2b2d42 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    border-radius: 4px !important;
    padding: 5px !important;
    background: #ffffff !important;
  }

  /* OVERRIDE: Reset all borders first */
  body .main-grid-cell {
    width: 65px !important;
    height: 65px !important;
    font-size: 24px !important;
    background: #fafafa !important;
    border: 0.5px solid #d0d0d0 !important;
    border-right: 0.5px solid #d0d0d0 !important;
    border-bottom: 0.5px solid #d0d0d0 !important;
  }
  
  /* 6x6 Mini-Sudoku Separators */
  /* 1 vertical line in middle - after column 3 (cells 3,9,15,21,27,33) */
  body .main-grid-cell:nth-child(6n+3) {
    border-right: 1.5px solid #666 !important;
  }

  /* 2 horizontal lines - after rows 2 and 4 (cells 7-12 and 19-24) */
  body .main-grid-cell:nth-child(n+7):nth-child(-n+12),
  body .main-grid-cell:nth-child(n+19):nth-child(-n+24) {
    border-bottom: 1.5px solid #666 !important;
  }

  .tips-grid,
  .benefits-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
}

@media (max-width: 480px) {
  .numbers-top {
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    row-gap: 12px;
    margin-bottom: 12px;
  }

  .numbers-top .number {
    height: 42px;
    font-size: 18px;
  }

  /* Control buttons in second row - red eraser */
  .numbers-top .delete {
    grid-column: 1 / 3;
    grid-row: 2;
    height: 42px;
    font-size: 16px;
    background: #fff0f0;
    color: #e74c3c;
    border: 2px solid #ffcdd2;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .numbers-top #toggle-notes {
    grid-column: 3 / 5;
    grid-row: 2;
  }

  .numbers-top #btn-hint {
    grid-column: 5 / 7;
    grid-row: 2;
  }

  body .main-sudoku-grid {
    grid-template-columns: repeat(6, 60px) !important;
    grid-template-rows: repeat(6, 60px) !important;
    gap: 5px !important;
    width: fit-content !important;
    height: fit-content !important;
    max-width: none !important;
    border: 2px solid #2b2d42 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    border-radius: 4px !important;
    padding: 5px !important;
    background: #ffffff !important;
  }

  body .main-grid-cell {
    width: 60px !important;
    height: 60px !important;
    font-size: 22px !important;
    background: #fafafa !important;
    border: 0.5px solid #d0d0d0 !important;
    border-right: 0.5px solid #d0d0d0 !important;
    border-bottom: 0.5px solid #d0d0d0 !important;
  }

  /* 6x6 Mini-Sudoku Separators - Override main sudoku rules */
  /* Reset main sudoku borders for mini-sudoku */
  body .main-grid-cell:nth-child(3n):not(:nth-child(9n)),
  body .main-grid-cell:nth-child(n+19):nth-child(-n+27),
  body .main-grid-cell:nth-child(n+46):nth-child(-n+54) {
    border-right: 0.5px solid #d0d0d0 !important;
    border-bottom: 0.5px solid #d0d0d0 !important;
  }

  /* Apply mini-sudoku specific separators */
  body .main-grid-cell:nth-child(6n+3) {
    border-right: 1.5px solid #666 !important;
  }

  body .main-grid-cell:nth-child(n+7):nth-child(-n+12),
  body .main-grid-cell:nth-child(n+19):nth-child(-n+24) {
    border-bottom: 1.5px solid #666 !important;
  }

  /* Numbers section for 6x6 */
  .numbers-top {
    gap: 2px !important;
    margin-bottom: 8px !important;
    justify-content: center !important;
    grid-template-columns: repeat(6, 1fr) !important;
  }
  
  .numbers-top .number,
  .numbers-top .delete {
    height: 34px !important;
    font-size: 13px !important;
    min-width: 34px !important;
    padding: 0 !important;
  }
  
  /* Control buttons span 2 columns each in second row for 6x6 */
  #toggle-notes,
  #btn-hint,
  .numbers-top .delete {
    height: 34px !important;
    font-size: 13px !important;
    grid-column: span 2 !important;
  }
}

@media (max-width: 390px) {
  .main {
    padding: 8px 0;
  }
  
  .game-header-section {
    padding: 0 6px;
    margin-bottom: 15px;
  }
  
  .game-container {
    padding: 0 6px;
    gap: 10px;
    display: flex;
    flex-direction: column;
  }

  .control-card {
    padding: 10px;
    margin-bottom: 6px;
    width: 100%;
    box-sizing: border-box;
  }

  .numbers-sidebar {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  .numbers-top {
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 2px !important;
    row-gap: 10px !important;
    margin-bottom: 8px !important;
  }
  
  .numbers-top .number {
    height: 38px !important;
    font-size: 15px !important;
    min-width: 38px !important;
    padding: 0 !important;
  }

  /* Control buttons in second row - red eraser */
  .numbers-top .delete {
    grid-column: 1 / 3 !important;
    grid-row: 2 !important;
    height: 38px !important;
    font-size: 15px !important;
    background: #fff0f0 !important;
    color: #e74c3c !important;
    border: 2px solid #ffcdd2 !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
  }

  .numbers-top #toggle-notes {
    grid-column: 3 / 5 !important;
    grid-row: 2 !important;
  }

  .numbers-top #btn-hint {
    grid-column: 5 / 7 !important;
    grid-row: 2 !important;
  }
  
  .control-card h3 {
    font-size: 12px !important;
    margin-bottom: 6px !important;
  }
  
  /* Ensure right sidebar (3rd block) is fully visible */
  .numbers-sidebar .control-card:last-child {
    margin-bottom: 15px !important;
  }
  
  /* Adjust difficulty links for narrow screens */
  .difficulty-link {
    padding: 4px 6px !important;
    font-size: 11px !important;
    min-width: 45px !important;
  }
  
  /* Mini sudoku specific adjustments */
  .main-sudoku-grid {
    grid-template-columns: repeat(6, 46px) !important;
    grid-template-rows: repeat(6, 46px) !important;
    margin: 0 auto !important;
    max-width: 280px !important;
    padding: 1px !important;
    border: 1px solid #bbb !important;
    background: #ffffff !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08) !important;
    border-radius: 3px !important;
    gap: 1px !important;
    width: 280px !important;
  }
  
  .main-grid-cell {
    border: 0.5px solid #ddd !important;
    background: #fafafa !important;
    width: 46px !important;
    height: 46px !important;
    font-size: 18px !important;
  }
  
  /* 2x3 box separators - vertical (after column 3) */
  .main-grid-cell:nth-child(3n):not(:nth-child(6n)) {
    border-right: 2px solid #777 !important;
  }
  
  /* 2x3 box separators - horizontal (bottom border on rows 2 and 4) */
  .main-grid-cell:nth-child(7), .main-grid-cell:nth-child(8), .main-grid-cell:nth-child(9),
  .main-grid-cell:nth-child(10), .main-grid-cell:nth-child(11), .main-grid-cell:nth-child(12),
  .main-grid-cell:nth-child(19), .main-grid-cell:nth-child(20), .main-grid-cell:nth-child(21),
  .main-grid-cell:nth-child(22), .main-grid-cell:nth-child(23), .main-grid-cell:nth-child(24) {
    border-bottom: 2px solid #777 !important;
  }
  
  .action-buttons-row {
    gap: 4px !important;
  }
  
  .action-buttons-row > * {
    height: 38px !important;
    font-size: 12px !important;
    padding: 0 8px !important;
  }
  
  /* Force container to not overflow */
  .container,
  .main,
  .game-container,
  .numbers-sidebar {
    max-width: 390px !important;
    overflow-x: hidden !important;
  }
  
  /* Ensure all elements fit within viewport */
  * {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Control buttons span 2 columns each in second row for 6x6 */
  #toggle-notes,
  #btn-hint,
  .numbers-top .delete {
    height: 34px !important;
    font-size: 13px !important;
    grid-column: span 2 !important;
  }
}

/* Additional breakpoint for 430px and similar widths */
@media (max-width: 430px) {
  .numbers-top {
    row-gap: 10px !important;
  }

  body .main-sudoku-grid {
    grid-template-columns: repeat(6, 55px) !important;
    grid-template-rows: repeat(6, 55px) !important;
    gap: 4px !important;
    width: fit-content !important;
    height: fit-content !important;
    border: 2px solid #2b2d42 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    border-radius: 4px !important;
    padding: 4px !important;
    background: #ffffff !important;
  }

  body .main-grid-cell {
    width: 55px !important;
    height: 55px !important;
    font-size: 20px !important;
    background: #fafafa !important;
    border: 0.5px solid #d0d0d0 !important;
  }

}

@media (max-width: 430px) {
  body .main-grid-cell {
    width: 55px !important;
    height: 55px !important;
    font-size: 20px !important;
    background: #fafafa !important;
    border: 0.5px solid #d0d0d0 !important;
    border-right: 0.5px solid #d0d0d0 !important;
    border-bottom: 0.5px solid #d0d0d0 !important;
  }

  /* 6x6 Mini-Sudoku Separators */
  body .main-grid-cell:nth-child(6n+3) {
    border-right: 1.5px solid #666 !important;
  }

  body .main-grid-cell:nth-child(n+7):nth-child(-n+12),
  body .main-grid-cell:nth-child(n+19):nth-child(-n+24) {
    border-bottom: 1.5px solid #666 !important;
  }
}

@media (max-width: 390px) {
  body .main-grid-cell {
    width: 50px !important;
    height: 50px !important;
    font-size: 18px !important;
    background: #fafafa !important;
    border: 0.5px solid #d0d0d0 !important;
    border-right: 0.5px solid #d0d0d0 !important;
    border-bottom: 0.5px solid #d0d0d0 !important;
  }

  /* 6x6 Mini-Sudoku Separators */
  body .main-grid-cell:nth-child(6n+3) {
    border-right: 1.5px solid #666 !important;
  }

  body .main-grid-cell:nth-child(n+7):nth-child(-n+12),
  body .main-grid-cell:nth-child(n+19):nth-child(-n+24) {
    border-bottom: 1.5px solid #666 !important;
  }
}
