:root {
  --bg-color: #f4f7f6;
  --primary: #2c3e50;
  --accent: #3498db;
  --error-bg: #fadbd8;
  --header-h: 60px;
  --ad-h: 50px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', sans-serif;
  background-color: var(--bg-color);
  margin: 0;
  height: 100vh; /* Strict height limit */
  width: 100vw;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* No scrolling allowed */
}

/* --- SCREEN 1: MENU --- */
#menu-screen {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: white; z-index: 100;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 20px;
}

.game-title {
  font-size: 3rem; font-weight: 800; color: var(--primary);
  margin-bottom: 50px; text-transform: uppercase; letter-spacing: 2px;
  text-align: center;
}

.menu-btn {
  width: 100%; max-width: 250px;
  padding: 15px; margin: 10px 0;
  font-size: 1.2rem; font-weight: bold;
  border: none; border-radius: 50px;
  cursor: pointer; color: white;
  transition: transform 0.2s;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.menu-btn:active { transform: scale(0.95); }

.btn-easy { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.btn-medium { background: linear-gradient(135deg, #f1c40f, #f39c12); }
.btn-hard { background: linear-gradient(135deg, #e74c3c, #c0392b); }

/* --- SCREEN 2: GAME --- */
#game-screen {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

/* HEADER */
header {
  height: var(--header-h);
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 15px; background: white;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  flex-shrink: 0;
}

.header-title { font-weight: 700; color: var(--primary); font-size: 1.2rem; }
.timer-display { font-family: monospace; font-size: 1.1rem; color: #555; }

.icon-group { display: flex; gap: 15px; }
.icon-btn {
  background: none; border: none; font-size: 1.5rem;
  cursor: pointer; padding: 0;
  transition: opacity 0.2s;
}
.icon-btn:hover { opacity: 0.7; }

/* MAIN BOARD AREA */
main {
  flex-grow: 1;
  display: flex; justify-content: center; align-items: center;
  overflow: hidden;
  width: 100%;
}


#sudoku-board{
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: min(95vw, calc(100dvh - var(--header-h) - var(--ad-h) - 20px));
  aspect-ratio: 1 / 1;  
  height: auto;          
  border: 2px solid var(--primary);
  background: white;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}


/* REPLACE THIS BLOCK IN style.css */
.cell {
  border: 1px solid #ddd;
  
  aspect-ratio: 1 / 1;
  width: 100%;
  height: 100%;
  
  font-size: clamp(14px, 3.5vmin, 28px);
  
  /* --- FIX STARTS HERE --- */
  text-align: center; /* Horizontally center the number */
  line-height: normal; /* Allow browser to center text vertically */
  display: block;      /* Input must be block or inline-block, NOT grid */
  /* --- FIX ENDS HERE --- */
  
  color: var(--primary);
  
  padding: 0;
  margin: 0;
  outline: none;
  border-radius: 0;
  
  /* Remove default mobile styling */
  -webkit-appearance: none;
  -moz-appearance: textfield;
  appearance: none;
  background: transparent;
}

/* Grid Lines */
.cell:nth-child(3n) { border-right: 2px solid var(--primary); }
.cell:nth-child(9n) { border-right: 1px solid #ddd; } /* Reset right edge */
.border-bottom-thick { border-bottom: 2px solid var(--primary) !important; }

/* Cell States */
.cell.fixed { background-color: #f0f2f5; font-weight: 700; pointer-events: none; }
.cell.user { background-color: white; color: var(--accent); font-weight: 600; }

/* Error Colors (Only at end) */
.error-row { background-color: var(--error-bg) !important; }
.error-col { background-color: var(--error-bg) !important; }

/* BOTTOM AD */
.banner-ad {
  height: var(--ad-h); background: #333; color: #777;
  display: flex; justify-content: center; align-items: center;
  font-size: 0.8rem; letter-spacing: 1px;
  flex-shrink: 0;
}

/* POPUPS */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); display: none;
  justify-content: center; align-items: center; z-index: 200;
}
.modal-content {
  background: white; padding: 30px; border-radius: 15px;
  text-align: center; width: 85%; max-width: 320px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}
.modal h2 { margin-top: 0; color: var(--primary); }

.close-btn {
  margin-top: 15px; padding: 10px 25px;
  background: var(--accent); color: white;
  border: none; border-radius: 5px; font-size: 1rem;
}

.fail-title { color: #e74c3c; }

/* Ad Overlay special style moved from inline */
.ad-content {
  border: 2px solid gold;
  background: #222;
  color: white;
}
.ad-timer {
  color: gold;
  font-weight: bold;
}
