/* ===========================
   CSS VARIABLES & RESET
   =========================== */
:root {
  --color-bg: #FFF8E7;
  --color-primary: #4ECDC4;
  --color-easy: #7BC74D;
  --color-medium: #F9A825;
  --color-hard: #F94144;
  --color-cell-bg: #FFFFFF;
  --color-cell-select: #FFFACD;
  --color-cell-given-bg: #F0F0F0;
  --color-error: #FF6B6B;
  --color-text: #2D3436;
  --color-given-text: #000000;
  --color-player-text: #1565C0;
  --color-reveal-text: #2E7D32;
  --color-player-correct-bg: #E3F2FD;
  --color-auto-revealed-bg: #E8F5E9;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
}

.hidden {
  display: none !important;
}

/* ===========================
   MENU SCREEN
   =========================== */
#menu-screen {
  text-align: center;
  max-width: 500px;
  width: 100%;
}

#menu-screen h1 {
  font-size: 2.8rem;
  color: var(--color-primary);
  margin-bottom: 8px;
}

.subtitle {
  font-size: 1.3rem;
  color: #666;
  margin-bottom: 32px;
}

/* Difficulty button container */
.difficulty-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.btn-difficulty {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 320px;
  padding: 18px 24px;
  border: none;
  border-radius: 16px;
  font-size: 1.1rem;
  font-weight: bold;
  color: white;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-difficulty:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}

.btn-difficulty:active {
  transform: scale(0.98);
}

.btn-easy { background: var(--color-easy); }
.btn-medium { background: var(--color-medium); }
.btn-hard { background: var(--color-hard); }

.btn-difficulty .emoji {
  font-size: 2rem;
}

.btn-difficulty .label {
  font-size: 1.3rem;
  flex: 1;
  text-align: left;
}

.btn-difficulty .desc {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* ===========================
   GAME SCREEN
   =========================== */
#game-screen {
  text-align: center;
  max-width: 500px;
  width: 100%;
}

/* Top bar: difficulty badge + timer */
#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 4px;
}

#difficulty-badge {
  font-size: 1rem;
  font-weight: bold;
  padding: 6px 14px;
  border-radius: 20px;
  color: white;
}

#difficulty-badge.easy { background: var(--color-easy); }
#difficulty-badge.medium { background: var(--color-medium); }
#difficulty-badge.hard { background: var(--color-hard); }

#timer-display {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--color-primary);
  transition: color 0.3s;
}

#timer-display.urgent {
  color: var(--color-hard);
  animation: pulse 0.8s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Message area for friendly feedback */
#message-area {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 10px;
  padding: 6px 12px;
  border-radius: 12px;
  transition: background-color 0.3s, color 0.3s;
}

#message-area.error-msg {
  background: #FFE0E0;
  color: #C62828;
}

#message-area.success-msg {
  background: #E8F5E9;
  color: #2E7D32;
}

#message-area.info-msg {
  background: #E3F2FD;
  color: #1565C0;
}

/* ===========================
   SUDOKU BOARD
   =========================== */
#board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  width: min(90vw, 450px);
  aspect-ratio: 1;
  margin: 0 auto 16px auto;
  border: 3px solid var(--color-primary);
  border-radius: 12px;
  overflow: hidden;
  background-color: var(--color-primary);
  gap: 1px;
}

.cell {
  background: var(--color-cell-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(1rem, 4.5vw, 1.8rem);
  font-weight: bold;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.1s;
  position: relative;
}

.cell:hover {
  background: #F5F5F5;
}

/* Given cells (pre-filled, locked) */
.cell.given {
  background: var(--color-cell-given-bg);
  color: var(--color-given-text);
  cursor: default;
}

.cell.given:hover {
  background: var(--color-cell-given-bg);
}

/* Selected cell */
.cell.selected {
  background: var(--color-cell-select);
}

/* Error highlight */
.cell.error {
  background: var(--color-error);
  color: white;
}

/* Player-entered numbers */
.cell.player {
  color: var(--color-player-text);
}

/* Solution reveal: player got it right */
.cell.player-correct {
  color: var(--color-player-text);
  background: var(--color-player-correct-bg);
}

/* Solution reveal: auto-filled answer */
.cell.auto-revealed {
  color: var(--color-reveal-text);
  background: var(--color-auto-revealed-bg);
}

/* 3x3 box borders — thicker lines at box boundaries */
.cell.box-border-right {
  border-right: 2px solid var(--color-primary);
}

.cell.box-border-bottom {
  border-bottom: 2px solid var(--color-primary);
}

/* ===========================
   NUMBER PAD
   =========================== */
#number-pad {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-number {
  width: clamp(38px, 8.5vw, 52px);
  height: clamp(38px, 8.5vw, 52px);
  border: none;
  border-radius: 12px;
  background: var(--color-primary);
  color: white;
  font-size: clamp(1rem, 4vw, 1.4rem);
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s, background-color 0.15s;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

.btn-number:hover {
  transform: scale(1.1);
  background: #3db8b0;
}

.btn-number:active {
  transform: scale(0.95);
}

.btn-number.btn-erase {
  background: #E0E0E0;
  color: #555;
}

.btn-number.btn-erase:hover {
  background: #BDBDBD;
}

.btn-number:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

/* ===========================
   ACTION BUTTONS
   =========================== */
#action-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-action {
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

.btn-action:hover {
  transform: scale(1.05);
}

.btn-action:active {
  transform: scale(0.97);
}

#btn-giveup {
  background: #FFCDD2;
  color: #C62828;
}

#btn-newgame {
  background: var(--color-primary);
  color: white;
}

/* ===========================
   WIN CELEBRATION
   =========================== */
@keyframes celebrate {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

#board.celebrate {
  animation: celebrate 0.6s ease 3;
}
