:root {
  --bg-color: #f5f5f5;
  --board-bg: #FFFFFF;
  --text-color: #333333;
  --border-thick: 2px solid #333333; /* Thick border for cages */
  --border-thin: 1px dotted #ccc;    /* Thin border for inner cells */
  --highlight-cell: #bbdefb;         /* Active cell color */
  --highlight-same-num: #e3f2fd;     /* Same number highlight */
  --highlight-cage: #f0f9ff;         /* Active cage highlight */
  --error-color: #ffcdd2;            /* Error background */
  --hint-color: #2196f3;             /* Hint text color */
}

/* Ensure body takes full height for the layout */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    font-family: system-ui, sans-serif;
}

.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Grid Container */
.board-container {
  background: var(--board-bg);
  padding: 4px; 
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  margin: 0 auto;
  width: 100%;
  max-width: 540px; /* Match Sudoku max width */
  aspect-ratio: 1;
  overflow: hidden;
  box-sizing: border-box;
}

.grid {
  display: grid;
  /* grid-template-columns set via JS */
  border: 2px solid #333; /* Outer border */
  user-select: none;
  touch-action: manipulation;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

/* Cell Styles */
.cell {
  position: relative;
  border: var(--border-thin); /* Default thin dotted border */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: white;
  transition: background-color 0.1s;
  box-sizing: border-box;
  /* To ensure borders don't mess up sizing, use negative margins or overlaps? 
     Actually standard CSS grid handles borders fine if box-sizing is border-box.
     But we want thick borders to override thin ones.
  */
}

/* Cage Borders - override basic border */
/* We use !important to ensure cage borders override the default thin dotted border */
.cell.b-top { border-top: var(--border-thick) !important; }
.cell.b-bottom { border-bottom: var(--border-thick) !important; }
.cell.b-left { border-left: var(--border-thick) !important; }
.cell.b-right { border-right: var(--border-thick) !important; }

/* States */
.cell.active {
  background-color: var(--highlight-cell);
}

.cell.cage-active {
  background-color: var(--highlight-cage);
}

.cell.num-highlight {
  background-color: var(--highlight-same-num);
}

.cell.error {
  background-color: var(--error-color) !important;
  color: #b71c1c;
}

.cell.hinted {
  color: var(--hint-color);
  font-weight: bold;
}

/* Cell Content */
.target-label {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.75rem; /* Will be scaled relative to cell font size if em used, but rem is safer */
  line-height: 1;
  font-weight: bold;
  pointer-events: none;
  z-index: 2;
}

/* Adjust label size for small grids */
@media (max-width: 600px) {
    .target-label { font-size: 0.6rem; left: 2px; top: 1px; }
}

.cell-value {
  font-weight: 500;
  pointer-events: none;
  z-index: 1;
}

/* Side Panel */
/* .game-side inherits styles from index.css */

/* Virtual Keypad Grid */
.virtual-keypad {
  margin-top: 0;
  width: 100%;
  max-width: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0;
  box-sizing: border-box;
}

.keypad-btn {
  height: 48px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  color: #374151;
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: manipulation;
}

.keypad-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
  color: #3b82f6;
}

.keypad-btn:active {
  background: #e5e7eb;
  transform: translateY(1px);
}

/* Menu Screen */
#menu-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  padding: 24px 20px;
  box-sizing: border-box;
}

.menu-title {
  color: #333;
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 24px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 800px;
  width: 100%;
}

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.2s;
  background: white;
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  border: 1px solid #eee;
}

.menu-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px rgba(0,0,0,0.1);
}

.menu-item-label {
  color: #333;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
}

.menu-item-sublabel {
  color: #666;
  font-size: 0.9rem;
  margin-top: -8px;
}

.menu-icon {
  background: white;
  border-radius: 4px;
  padding: 2px;
  display: grid;
  gap: 1px;
  width: 80px;
  height: 80px;
  box-sizing: border-box;
  border: 2px solid #333;
  background-color: #333;
}

.menu-icon div {
  background: white;
  border: none;
}

@media (max-width: 700px) {
  .menu-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
