/* =============================================
   SHARP MINDS — Game UI Styles
   ============================================= */

/* Game container */
.game-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* Game header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
}

.game-title .section-headline {
  font-size: 1.6rem;
  margin-bottom: 0;
}

.game-stats {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}

.stat {
  text-align: center;
  min-width: 48px;
}

.stat-value {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.2;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Countdown screen */
.countdown-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 24px 0;
}

.countdown-card-preview {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 480px;
}

.preview-card {
  aspect-ratio: 1;
  cursor: default;
}

.preview-card .card-front {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: 10px;
  border: 2px solid var(--border);
}

.preview-card .card-front svg {
  width: 55%;
  height: 55%;
}

.countdown-text {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

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

/* Game board */
.game-board {
  display: grid;
  gap: 8px;
  width: 100%;
}

.hidden {
  display: none !important;
}

/* Card — senior-friendly: large touch target, min 60px */
.card {
  position: relative; /* required: card-front/card-back use position:absolute */
  aspect-ratio: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.card.matched {
  cursor: default;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s ease;
  transform-style: preserve-3d;
}

.card-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  border-radius: 12px;
  border: 3px solid rgba(255,255,255,0.15);
  box-shadow: 0 4px 16px rgba(26,77,46,0.25);
  background-image: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.08) 2px, transparent 2px);
  background-size: 16px 16px;
}

.card-front {
  position: absolute;
  inset: 0;
  background: var(--surface);
  border-radius: 12px;
  border: 3px solid var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(26,77,46,0.15);
  backface-visibility: hidden;
}

.card-front svg {
  width: 55%;
  height: 55%;
  object-fit: contain;
}

.card-front.matched-face {
  border-color: #2A6B45;
  background: #f0f7f2;
}

.card.flipped .card-back,
.card.matched .card-back {
  display: none;
}

.card:not(.flipped):not(.matched) .card-back {
  display: flex;
}

/* Card press feedback for touch */
.card:not(.matched):active .card-back,
.card:not(.matched):active .card-front {
  transform: scale(0.95);
  transition: transform 0.1s;
}

/* Result modal */
.result-modal {
  position: fixed;
  inset: 0;
  background: rgba(45, 45, 45, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.result-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(26,77,46,0.2);
  text-align: center;
}

.result-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--accent);
  margin-bottom: 24px;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 20px;
}

.result-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.result-stat span {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--amber);
  line-height: 1.2;
}

.result-stat label {
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 4px;
}

.result-message {
  font-size: 0.95rem;
  color: var(--fg);
  margin-bottom: 28px;
  line-height: 1.5;
}

/* Buttons — senior-friendly: large tap targets */
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  transition: background 0.2s, transform 0.1s;
  min-height: 64px;
  line-height: 1;
}

.btn-primary:hover {
  background: var(--accent-light);
}

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

.btn-ghost {
  display: block;
  width: 100%;
  padding: 14px 24px;
  background: transparent;
  color: var(--fg-muted);
  border: 2px solid var(--border);
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  min-height: 60px;
  line-height: 1;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Nav back link */
.nav-back {
  font-size: 0.9rem;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.nav-back:hover {
  color: var(--accent);
}

/* =============================================
   Mobile Responsiveness (320px – 428px)
   ============================================= */

@media (max-width: 480px) {
  .game-container {
    padding: 16px 12px 40px;
  }

  .game-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .game-title .section-headline {
    font-size: 1.4rem;
  }

  .game-title .section-label {
    font-size: 0.75rem;
  }

  .game-stats {
    gap: 12px;
    width: 100%;
  }

  .stat {
    min-width: 0;
    flex: 1;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  .stat-label {
    font-size: 0.65rem;
  }
}

@media (max-width: 380px) {
  .game-header {
    flex-direction: column;
    gap: 10px;
  }

  .game-stats {
    gap: 8px;
  }

  .stat-value {
    font-size: 1rem;
  }

  .result-stats {
    gap: 16px;
  }

  .result-stat span {
    font-size: 1.3rem;
  }
}

/* Grid columns: scale down on small screens */
@media (max-width: 480px) {
  .game-board {
    gap: 6px;
  }

  .countdown-card-preview {
    gap: 5px;
    max-width: 100%;
  }
}

@media (max-width: 360px) {
  .game-board {
    gap: 5px;
  }

  .countdown-card-preview {
    gap: 4px;
  }
}

/* =============================================
   Sudoku Grid & Cell Styles
   ============================================= */

.sudoku-grid {
  display: grid;
  gap: 2px;
  width: 100%;
  max-width: 480px;
  background: var(--border);
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 2px;
}

.sudoku-cell {
  aspect-ratio: 1;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  position: relative;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
  min-width: 64px;
  min-height: 64px;
}

.sudoku-cell:active {
  background: var(--bg-alt);
}

.sudoku-cell.given {
  background: var(--bg-alt);
  font-weight: 700;
  color: var(--accent);
  cursor: default;
}

.sudoku-cell.selected {
  border: 3px solid var(--accent);
}

.sudoku-cell.hint-cell {
  background: rgba(212,136,58,0.15);
  animation: hintPulse 1s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { border-color: transparent; }
  50% { border-color: #D4883A; }
}

.sudoku-cell.error-cell {
  background: rgba(200,50,50,0.08);
}

/* 9x9 grid: 3x3 box borders */
.sudoku-grid.grid-9x9 .sudoku-cell:nth-child(3n) {
  border-right: 3px solid var(--accent);
}

.sudoku-grid.grid-9x9 .sudoku-cell:nth-child(n+19):nth-child(-n+27),
.sudoku-grid.grid-9x9 .sudoku-cell:nth-child(n+46):nth-child(-n+54) {
  border-bottom: 3px solid var(--accent);
}

/* Pencil marks */
.pencil-marks {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px;
  pointer-events: none;
}

.pencil-mark {
  font-size: 9px;
  color: var(--fg-muted);
  line-height: 1;
  width: 25%;
  text-align: center;
}

/* Number pad */
.number-pad {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
  max-width: 480px;
}

.num-btn {
  min-width: 56px;
  min-height: 56px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 20px;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.num-btn:hover {
  border-color: var(--accent);
  background: rgba(26,77,46,0.05);
}

.num-btn:active {
  transform: scale(0.95);
  background: var(--bg-alt);
}

/* Controls */
.sudoku-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.ctrl-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-height: 48px;
}

.ctrl-btn:hover {
  border-color: var(--accent);
  background: rgba(26,77,46,0.05);
}

.ctrl-btn.pencil-mode {
  background: rgba(26,77,46,0.08);
  border-color: var(--accent);
  color: var(--accent);
}

.ctrl-btn.hint-used {
  opacity: 0.5;
  pointer-events: none;
}

/* Difficulty selector */
.sudoku-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 32px 0;
}

.selector-label {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--fg-muted);
}

.selector-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  max-width: 440px;
}

.pill-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 12px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.pill-btn:hover {
  border-color: var(--accent);
  background: rgba(26,77,46,0.04);
  transform: translateY(-2px);
}

.pill-btn:active {
  transform: translateY(0);
}

.pill-name {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--fg);
}

.pill-desc {
  font-size: 0.78rem;
  color: var(--fg-muted);
}
/* =============================================
   DEMO PAGE
   ============================================= */

.demo-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.demo-topbar {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.demo-topbar .nav-logo {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.demo-hero {
  padding: 48px 24px 32px;
  text-align: center;
  background: var(--bg);
}

.demo-hero .section-headline {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin-bottom: 12px;
}

.demo-hero .section-lede {
  font-size: 1rem;
  color: var(--fg-muted);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
}

.demo-games {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  padding: 0 24px 48px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.demo-game-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px 20px 28px;
  box-shadow: var(--shadow);
}

.demo-game-section .section-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 6px;
}

.demo-game-section .section-headline {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0;
}

.demo-cta-footer {
  padding: 0 24px 64px;
  text-align: center;
}

.demo-cta-footer p {
  font-size: 1rem;
  color: var(--fg-muted);
  margin-bottom: 16px;
}

.demo-cta-footer .btn-signup {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 16px 36px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  text-decoration: none;
  min-height: 64px;
  box-shadow: 0 4px 20px rgba(26,77,46,0.25);
  transition: background 0.2s ease, transform 0.15s ease;
}

.demo-cta-footer .btn-signup:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

@media (max-width: 720px) {
  .demo-games {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 0 16px 40px;
  }
}

@media (max-width: 480px) {
  .demo-hero {
    padding: 36px 16px 24px;
  }
  .demo-game-section {
    padding: 20px 16px 24px;
  }
  .demo-cta-footer {
    padding: 0 16px 48px;
  }
}

/* Onboarding tooltip — shown once per browser session on first game load */
.game-tooltip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(26,77,46,0.07);
  border: 1.5px solid rgba(26,77,46,0.18);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
}

.game-tooltip-text {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--accent);
  line-height: 1.4;
}

.game-tooltip-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.game-tooltip-close:hover {
  background: rgba(26,77,46,0.1);
  color: var(--accent);
}

/* Leaderboard on result modal */
.result-leaderboard {
  text-align: left;
  margin: 16px 0 24px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.result-leaderboard h3 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--accent);
  margin-bottom: 10px;
  text-align: center;
}
.leaderboard-list { list-style: none; padding: 0; margin: 0; }
.leaderboard-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 0.95rem;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
}
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-row .rank {
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.leaderboard-row .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.leaderboard-row .score {
  color: var(--amber);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.leaderboard-row--me {
  background: rgba(212, 136, 58, 0.12);
  border-radius: 6px;
  font-weight: 600;
}
.leaderboard-empty, .leaderboard-signin, .leaderboard-rank {
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-align: center;
  padding: 8px 0;
}
.leaderboard-signin a { color: var(--accent); }
