/* Custom styles & safety margins for High-Yield H5 Web Game */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  margin: 0;
  padding: 0;
  background-color: #0b0f19;
  color: #f1f5f9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  touch-action: manipulation;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* Ad Placement Safe Zones - Prevents Cumulative Layout Shift (CLS) */
.ad-slot-container {
  min-height: 50px;
  width: 100%;
  max-width: 468px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  background: rgba(15, 23, 42, 0.6);
  border: 1px dashed rgba(99, 102, 241, 0.25);
  border-radius: 8px;
}

.ad-slot-badge {
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #64748b;
  position: absolute;
  top: 2px;
  right: 6px;
  pointer-events: none;
}

/* Sudoku 9x9 Grid Styles */
.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1 / 1;
  border: 2.5px solid #6366f1;
  border-radius: 12px;
  overflow: hidden;
  background-color: #1e1b4b;
  margin: 0 auto;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.sudoku-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(99, 102, 241, 0.25);
  border-bottom: 1px solid rgba(99, 102, 241, 0.25);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

/* 3x3 Subgrid Divider Lines */
.sudoku-cell:nth-child(3n) {
  border-right: 2px solid #818cf8;
}
.sudoku-cell:nth-child(9n) {
  border-right: none;
}
.sudoku-row-divider {
  border-bottom: 2px solid #818cf8 !important;
}

/* Cell States */
.sudoku-cell.clue {
  color: #f8fafc;
  font-weight: 700;
  background-color: rgba(30, 41, 59, 0.7);
}

.sudoku-cell.user-value {
  color: #38bdf8;
  font-weight: 600;
}

.sudoku-cell.selected {
  background-color: #4338ca !important;
  color: #ffffff;
}

.sudoku-cell.highlight-peer {
  background-color: rgba(99, 102, 241, 0.18);
}

.sudoku-cell.highlight-number {
  background-color: rgba(234, 179, 8, 0.22);
}

.sudoku-cell.error {
  background-color: rgba(239, 68, 68, 0.35) !important;
  color: #f87171 !important;
  animation: shake 0.3s ease-in-out;
}

/* Mini Notes Grid within cell */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 1px;
  pointer-events: none;
}

.note-item {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: #94a3b8;
  font-weight: 500;
  line-height: 1;
}

/* Animations */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

@keyframes popIn {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.animate-pop {
  animation: popIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Custom Scrollbar for Jigsaw Tray */
#jigsaw-tray::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}
#jigsaw-tray::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
}
#jigsaw-tray::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}
#jigsaw-tray::-webkit-scrollbar-thumb:hover {
  background: #475569;
}
