.sudoku-game {
 display: flex !important;
 align-items: flex-start !important; /* Crucial for sticky sidebar */
 overflow: visible !important; /* Ensure parents don't clip sticky behavior */
 gap: 24px;
 max-width: 1100px;
 margin: 0 auto;
 padding: 20px;
 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
 box-sizing: border-box;
}

.sudoku-game *,
.sudoku-game *::before,
.sudoku-game *::after {
 box-sizing: border-box;
}

/* Sidebar */
.sudoku-sidebar {
 flex: 0 0 280px;
 background: #fff;
 border-radius: 12px;
 padding: 24px 20px;
 box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
 height: fit-content !important;
 position: -webkit-sticky !important;
 position: sticky !important;

 z-index: 100 !important;
}

.sudoku-sidebar-header {
 text-align: center;
 margin-bottom: 20px;
 padding-bottom: 16px;
 border-bottom: 2px solid #f0f0f0;
}

.sudoku-title {
 display: block;
 font-size: 26px;
 font-weight: 800;
 color: #1E9FFF;
 letter-spacing: 1px;
}

.sudoku-subtitle {
 display: block;
 font-size: 12px;
 color: #888;
 margin-top: 4px;
}

.sudoku-sidebar-section {
 margin-bottom: 18px;
}

.sudoku-sidebar-label {
 font-size: 11px;
 font-weight: 700;
 color: #888;
 text-transform: uppercase;
 letter-spacing: 1px;
 margin-bottom: 10px;
}

.sudoku-diff-bar {
 display: grid;
 grid-template-columns: repeat(3, 1fr);
 gap: 6px;
}

.sudoku-diff {
 padding: 8px 6px;
 border: 2px solid #e0e0e0;
 background: #fafafa;
 border-radius: 8px;
 font-size: 13px;
 font-weight: 600;
 cursor: pointer;
 transition: all 0.2s ease;
 color: #777;
}

.sudoku-game.loading .sudoku-diff,
.sudoku-game.loading .sudoku-btn {
 pointer-events: none;
 opacity: 0.6;
 cursor: not-allowed;
}

.sudoku-diff:hover {
 background: #f0f0f0;
 border-color: #ccc;
}

.sudoku-diff.active[data-diff="easy"] {
 background: #5FB878;
 color: #fff;
 border-color: #5FB878;
}

.sudoku-diff.active[data-diff="medium"] {
 background: #1E9FFF;
 color: #fff;
 border-color: #1E9FFF;
}

.sudoku-diff.active[data-diff="hard"] {
 background: #FF5722;
 color: #fff;
 border-color: #FF5722;
}

.sudoku-diff.active[data-diff="expert"] {
 background: #673AB7;
 color: #fff;
 border-color: #673AB7;
}

.sudoku-diff.active[data-diff="master"] {
 background: #FF9800;
 color: #fff;
 border-color: #FF9800;
}

/* Number input controls */
.sudoku-number-input {
 display: flex;
 align-items: center;
 gap: 0;
 border: 1px solid #ddd;
 border-radius: 8px;
 overflow: hidden;
 background: #fff;
}

.sudoku-num-btn {
 width: 36px;
 height: 36px;
 border: none;
 background: #f8f8f8;
 color: #555;
 font-size: 18px;
 font-weight: 600;
 cursor: pointer;
 transition: background 0.2s;
 display: flex;
 align-items: center;
 justify-content: center;
 user-select: none;
}

.sudoku-num-btn:hover {
 background: #e8e8e8;
}

.sudoku-num-btn:active {
 background: #ddd;
}

.sudoku-pages-input,
.sudoku-perpage-input {
 width: 100%;
 height: 36px;
 border: none;
 text-align: center;
 font-size: 15px;
 font-weight: 600;
 color: #333;
 background: #fff;
 -moz-appearance: textfield;
}

.sudoku-pages-input::-webkit-outer-spin-button,
.sudoku-pages-input::-webkit-inner-spin-button {
 -webkit-appearance: none;
 margin: 0;
}

.sudoku-sidebar-summary {
 background: #f0f7ff;
 border: 1px solid #d0e8ff;
 border-radius: 8px;
 padding: 10px 14px;
 margin-bottom: 16px;
 text-align: center;
 font-size: 13px;
 font-weight: 600;
 color: #1E9FFF;
}

.sudoku-game.loading .sudoku-num-btn,
.sudoku-game.loading .sudoku-pages-input,
.sudoku-game.loading .sudoku-perpage-input {
 pointer-events: none;
 opacity: 0.6;
 cursor: not-allowed;
}

.sudoku-option {
 display: flex;
 align-items: center;
 gap: 8px;
 font-size: 14px;
 color: #555;
 cursor: pointer;
}

.sudoku-option input[type="checkbox"] {
 width: 18px;
 height: 18px;
 accent-color: #1E9FFF;
 cursor: pointer;
}

.sudoku-sidebar-actions {
 display: flex;
 flex-direction: column;
 gap: 10px;
}

.sudoku-btn {
 padding: 10px 16px;
 border: 1px solid #ddd;
 background: #fff;
 border-radius: 8px;
 font-size: 14px;
 font-weight: 600;
 cursor: pointer;
 color: #555;
 transition: all 0.2s;
 text-align: center;
}

.sudoku-btn:hover {
 background: #f5f5f5;
 border-color: #bbb;
}

.sudoku-btn.sudoku-btn-primary {
 background: #1E9FFF;
 color: #fff;
 border-color: #1E9FFF;
}

.sudoku-btn.sudoku-btn-primary:hover {
 background: #1890e0;
 border-color: #1890e0;
}

.sudoku-btn.sudoku-btn-secondary {
 background: #5FB878;
 color: #fff;
 border-color: #5FB878;
}

.sudoku-btn.sudoku-btn-secondary:hover {
 background: #52a86a;
 border-color: #52a86a;
}

.sudoku-sidebar-footer {
 margin-top: 20px;
 padding-top: 16px;
 border-top: 1px solid #f0f0f0;
 font-size: 12px;
 color: #999;
 line-height: 1.6;
}

.sudoku-sidebar-footer p {
 margin: 0 0 4px;
}

/* Paper area (A4 simulation) */
.sudoku-paper-area {
 flex: 1;
 min-width: 0;
}

.sudoku-paper-shadow {
 position: relative;
 background: transparent;
 border-radius: 8px;
}

.sudoku-paper {
 background: transparent;
 width: 100%;
 max-width: none;
 min-height: auto;
 margin: 0 auto;
 padding: 0;
 position: relative;
}

/* Loading state */
.sudoku-game.loading .sudoku-print-puzzles {
 opacity: 0.6;
 pointer-events: none;
}

.sudoku-game.loading::after {
 content: '';
 position: absolute;
 top: 50%;
 left: 50%;
 transform: translate(-50%, -50%);
 width: 40px;
 height: 40px;
 border: 4px solid #e0e0e0;
 border-top-color: #1E9FFF;
 border-radius: 50%;
 animation: sudoku-spin 0.8s linear infinite;
 z-index: 100;
}

@keyframes sudoku-spin {
 to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Print puzzles */
.sudoku-print-puzzles {
 width: 100%;
 display: flex;
 flex-direction: column;
 gap: 30px;
}

.sudoku-print-page {
 background: #fff;
 width: 100%;
 min-height: 842px;
 margin: 0 auto;
 padding: 30px 25px;
 box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12),
    0 1px 3px rgba(0, 0, 0, 0.08);
 border-radius: 2px;
 position: relative;
 page-break-after: always;
}

.sudoku-print-page:last-child {
 page-break-after: auto;
}

.sudoku-print-header {
 text-align: center;
 margin-bottom: 12px;
 padding-bottom: 8px;
 border-bottom: 2px solid #333;
}

.sudoku-print-title {
 font-size: 16px;
 font-weight: 700;
 color: #222;
}

.sudoku-print-subtitle {
 font-size: 11px;
 color: #888;
 margin-top: 3px;
}

.sudoku-print-items {
 display: flex;
 flex-direction: column;
 gap: 16px;
}

.sudoku-print-item {
 background: #fff;
 padding: 8px;
}

.sudoku-print-item-title {
 text-align: center;
 font-size: 14px;
 font-weight: 700;
 color: #333;
 margin-bottom: 6px;
 padding-bottom: 4px;
 border-bottom: none;
}

/* Grid-based Sudoku Board Styles */
.sudoku-print-board {
 display: grid;
 grid-template-columns: repeat(9, 1fr);
 grid-template-rows: repeat(9, 1fr);
 aspect-ratio: 1;
 width: 100%;
 max-width: 380px;
 margin: 0 auto;
 border: 2px solid #333;
 background: #fff;
 box-sizing: border-box;
}

.sudoku-print-cell {
 display: flex;
 align-items: center;
 justify-content: center;
 font-size: 18px;
 font-weight: 700;
 border-right: 1px solid #999;
 border-bottom: 1px solid #999;
 background: #fff;
 color: #000;
 position: relative;
 z-index: 1;
}

.sudoku-print-cell:nth-child(9n) {
 border-right: none;
}

.sudoku-print-cell:nth-child(n+73) {
 border-bottom: none;
}

.sudoku-print-cell.col-border-right {
 border-right: 2.5px solid #000 !important;
 z-index: 2;
}

.sudoku-print-cell.row-border-bottom {
 border-bottom: 2.5px solid #000 !important;
 z-index: 2;
}

.sudoku-print-cell.fixed {
 color: #222;
}

.sudoku-print-footer {
 text-align: center;
 margin-top: 12px;
 padding-top: 8px;
 border-top: 1px dashed #ccc;
 font-size: 10px;
 color: #aaa;
}

/* Empty state */
.sudoku-print-puzzles:empty::before,
.sudoku-print-puzzles > p:only-child {
 content: 'Generating puzzles...';
 display: block;
 text-align: center;
 color: #999;
 padding: 40px 20px;
 font-size: 14px;
}

/* Responsive Styles for Mobile */
@media screen and (max-width: 768px) {
 .sudoku-game {
  flex-direction: column !important;
  padding: 10px;
  gap: 20px;
 }

 .sudoku-sidebar {
  flex: 1 1 100%;
  width: 100%;
  position: relative !important;
  top: 0 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  margin-bottom: 10px;
 }

 .sudoku-paper-area {
  width: 100%;
 }

 .sudoku-print-page {
  padding: 20px 15px;
  min-height: auto;
 }

 .sudoku-print-board {
  max-width: 100%;
 }

 .sudoku-diff-bar {
  grid-template-columns: repeat(3, 1fr);
 }

 .sudoku-num-btn {
  width: 44px;
  height: 44px;
 }

 .sudoku-pages-input {
  height: 44px;
 }

 .sudoku-btn {
  padding: 12px 16px;
  font-size: 16px;
 }
}

/* Print styles - optimized for A4 height */
@media print {
 @page { size: A4; margin: 0; }

 body {
  background: #fff !important;
 }

 #adminmenuback, #adminmenuwrap, #wpadminbar, #footer, .sudoku-sidebar {
  display: none !important;
 }

 .sudoku-game {
  display: block !important;
  padding: 0 !important;
  margin: 0 !important;
  width: 100% !important;
 }

 .sudoku-print-page {
  display: block !important;
  box-shadow: none !important;
  border: none !important;
  margin: 0 !important;
  padding: 8mm 15mm !important;
  width: 210mm !important;
  height: 297mm !important;
  page-break-after: always !important;
  box-sizing: border-box !important;
  position: relative !important;
 }

 .sudoku-print-header {
  margin: 0 !important;
  margin-bottom: 3mm !important;
  padding-bottom: 2mm !important;
  line-height: 1 !important;
 }
 
 .sudoku-print-items {
  display: block !important;
 }

 .sudoku-print-item + .sudoku-print-item {
  margin-top: 5mm !important;
 }

 .sudoku-print-board {
  width: 100mm !important;
  height: 100mm !important;
  max-width: 100mm !important;
 }

 .sudoku-print-item {
  padding: 0 !important;
 }

 .sudoku-print-footer {
  position: absolute !important;
  bottom: 6mm !important;
  left: 15mm !important;
  right: 15mm !important;
  text-align: center !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  font-size: 10px !important;
  color: #000 !important;
  line-height: 1 !important;
 }

 .sudoku-print-page:last-child {
  page-break-after: avoid !important;
 }
}

/* SEO Content Section Styles */
.sudoku-container {
 max-width: 1100px;
 margin: 0 auto;
 padding: 0 20px 40px;
}

.sudoku-seo-content {
 margin-top: 60px;
 padding-top: 40px;
 border-top: 1px solid #eee;
 color: #444;
 line-height: 1.8;
}

.sudoku-seo-title {
 font-size: 28px;
 font-weight: 800;
 color: #333;
 margin-bottom: 24px;
 text-align: center;
}

.sudoku-seo-text p {
 margin-bottom: 20px;
 font-size: 16px;
}

.sudoku-seo-subtitle {
 font-size: 22px;
 font-weight: 700;
 color: #333;
 margin: 40px 0 20px;
}

.sudoku-static-links {
 display: grid;
 grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
 gap: 16px;
 margin: 30px 0;
}

.sudoku-static-link {
 display: flex;
 align-items: center;
 gap: 12px;
 padding: 16px 20px;
 background: #f9f9f9;
 border: 1px solid #eee;
 border-radius: 10px;
 text-decoration: none;
 color: #1E9FFF;
 font-weight: 600;
 transition: all 0.2s;
}

.sudoku-static-link:hover {
 background: #fff;
 border-color: #1E9FFF;
 box-shadow: 0 4px 12px rgba(30, 159, 255, 0.1);
 transform: translateY(-2px);
}

.sudoku-static-link .icon {
 font-size: 20px;
}

.sudoku-seo-faq {
 margin-top: 50px;
 background: #fff;
 padding: 30px;
 border-radius: 12px;
 box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.sudoku-seo-faq h3 {
 margin-top: 0;
 margin-bottom: 24px;
 color: #333;
}

.faq-item {
 margin-bottom: 24px;
}

.faq-item h4 {
 font-size: 17px;
 color: #333;
 margin-bottom: 10px;
}

.faq-item p {
 font-size: 15px;
 color: #666;
 margin: 0;
}

@media screen and (max-width: 768px) {
 .sudoku-static-links {
  grid-template-columns: 1fr;
 }
 .sudoku-seo-title {
  font-size: 22px;
 }
}