/* Homepage player. Kept out of style.css so the page never pairs new markup with a cached old stylesheet. */

.hero.hero-compact {
  padding: 1.75rem 0 1.5rem;
}

.hero.hero-compact .container {
  padding-top: 0;
  padding-bottom: 0;
}

.hero.hero-compact h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin-bottom: 0.4rem;
}

.hero.hero-compact p {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  max-width: 640px;
}

#home-play {
  --hp-accent: #4f46e5;
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.5rem 1rem 0.5rem;
}

.hp-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.9rem;
}

.hp-head h2 {
  font-size: clamp(1.15rem, 2.6vw, 1.5rem);
  margin: 0;
}

.hp-head h2 span {
  font-weight: 500;
  color: var(--text-secondary);
}

/* Level tabs */
.hp-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.hp-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-height: 3.1rem;
  padding: 0.45rem 0.25rem;
  border: 2px solid var(--border);
  border-radius: 0.6rem;
  background: var(--bg-secondary);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.hp-tab small {
  min-height: 1em;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1;
  color: var(--text-secondary);
}

.hp-tab[aria-selected="true"] {
  border-color: var(--hp-accent);
  background: var(--hp-accent);
  color: #fff;
}

.hp-tab[aria-selected="true"] small { color: rgba(255, 255, 255, 0.85); }
.hp-tab.solved:not([aria-selected="true"]) small { color: #15803d; font-weight: 700; }
.hp-tab:disabled { opacity: 0.45; cursor: default; }
.hp-tab:focus-visible, .hp-key:focus-visible, .hp-act:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }

/* Board + side panel */
.hp-body {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(0, 1fr);
  gap: 1.75rem;
  align-items: start;
}

.hp-board { min-width: 0; }

.hp-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

#home-play #sudoku-grid {
  margin: 0;
  max-width: 520px;
  width: 100%;
  border-radius: 4px;
}

#home-play .cell {
  touch-action: manipulation;
  font-size: clamp(1.15rem, 4.4vw, 1.9rem);
}

#home-play .cell:not(.given) { color: var(--primary); }
#home-play .cell.given { font-weight: 700; }

#home-play .cell.hinted {
  box-shadow: inset 0 0 0 3px #f59e0b;
  animation: hp-pulse 1s ease-in-out 2;
}

@keyframes hp-pulse {
  50% { background: #fde68a; }
}

.hp-progress {
  height: 4px;
  margin-top: 0.5rem;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}

#hp-progress-bar {
  width: 0;
  height: 100%;
  background: var(--hp-accent);
  transition: width 0.25s;
}

#home-play #game-message {
  min-height: 3rem;
  margin: 0.6rem 0 0;
  font-size: 0.95rem;
  color: var(--text);
}

/* Number pad */
.hp-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.hp-key {
  position: relative;
  aspect-ratio: 1.35;
  border: 2px solid var(--border);
  border-radius: 0.6rem;
  background: var(--bg-secondary);
  color: var(--primary);
  font: inherit;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.hp-key small {
  position: absolute;
  top: 0.25rem;
  right: 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.hp-key:hover, .hp-act:hover { border-color: var(--hp-accent); }
.hp-key:active, .hp-act:active { transform: scale(0.97); }
.hp-key.done { opacity: 0.3; }

.hp-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.hp-act {
  min-height: 2.75rem;
  padding: 0.4rem 0.3rem;
  border: 2px solid var(--border);
  border-radius: 0.6rem;
  background: var(--bg-secondary);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.hp-act.active {
  background: var(--hp-accent);
  border-color: var(--hp-accent);
  color: #fff;
}

.hp-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.85rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.hp-toggle input { width: 1.05rem; height: 1.05rem; accent-color: var(--hp-accent); }

.hp-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  text-align: center;
}

.hp-stats b {
  display: block;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.hp-stats span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.hp-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-top: 0.9rem;
  font-size: 0.9rem;
}

.hp-keys {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.hp-keys kbd {
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: var(--bg-secondary);
  font: inherit;
  font-size: 0.75rem;
}

/* Solved panel: shown in place, never a pop-up over the board */
#home-play #completion-modal {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding: 1rem;
  border: 2px solid #16a34a;
  border-radius: 0.6rem;
  background: #f0fdf4;
  color: #14532d;
  text-align: center;
}

#home-play #completion-modal strong { font-size: 1.15rem; }
#home-play #completion-modal #completion-time { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }

.hp-done-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.hp-done-actions button {
  padding: 0.55rem 0.9rem;
  border: 2px solid #16a34a;
  border-radius: 0.5rem;
  background: #16a34a;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.hp-done-actions button.plain { background: transparent; color: #166534; }

.hp-celebrate #sudoku-grid { animation: hp-win 0.8s ease-out 2; }

@keyframes hp-win {
  50% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0.45); }
}

/* Dark mode */
.dark-mode #home-play { --hp-accent: #6366f1; }
.dark-mode #home-play #completion-modal { background: #052e16; color: #bbf7d0; }
.dark-mode .hp-done-actions button.plain { color: #bbf7d0; }
.dark-mode .hp-tab.solved:not([aria-selected="true"]) small { color: #4ade80; }
.dark-mode #home-play .cell:not(.given) { color: #93c5fd; }
.dark-mode .hp-key { color: #93c5fd; }
.dark-mode .hp-key.done { opacity: 0.25; }

/* Narrow screens: board first, then a one-row number pad within thumb reach */
@media (max-width: 860px) {
  .hp-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
    max-width: 520px;
    margin: 0 auto;
  }

  .hp-tabs { max-width: 520px; margin-left: auto; margin-right: auto; }
  .hp-head { max-width: 520px; margin-left: auto; margin-right: auto; }

  .hp-pad {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 0.25rem;
  }

  .hp-key {
    aspect-ratio: auto;
    min-height: 3.25rem;
    padding-top: 0.6rem;
    font-size: 1.35rem;
    border-radius: 0.45rem;
  }

  .hp-key small { top: 0.1rem; right: 0.2rem; font-size: 0.65rem; }
  .hp-keys { display: none; }
  #home-play #game-message { min-height: 2.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  #home-play .cell.hinted, .hp-celebrate #sudoku-grid { animation: none; }
}

@media print {
  #home-play { display: none; }
}
