:root {
  --bg: #f5f0e8;
  --surface: #fff;
  --text: #2d2d2d;
  --text-dim: #777;
  --star-on: #f4b400;
  --star-off: #ddd;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

/* Header */
#header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

#header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: background 0.15s;
  flex-shrink: 0;
}

.back-btn:hover {
  background: #eee;
}

.hidden {
  display: none !important;
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.puzzle-card {
  display: block;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: var(--text);
  border-left: 4px solid #ccc;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s, box-shadow 0.15s;
}

.puzzle-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.puzzle-card:active {
  transform: translateY(0);
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.card-desc {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.card-stars {
  font-size: 1rem;
  letter-spacing: 0.1em;
}

.star-on {
  color: var(--star-on);
}

.star-off {
  color: var(--star-off);
}

/* Puzzle container */
.puzzle-container {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Shared puzzle classes */
.puzzle-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.puzzle-instructions {
  color: var(--text-dim);
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-align: center;
}

.btn-primary {
  background: var(--text);
  color: var(--surface);
}

.btn-primary:hover {
  background: #444;
}

.btn-secondary {
  background: #eee;
  color: var(--text);
}

.btn-secondary:hover {
  background: #ddd;
}

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* Reveal puzzles */
.reveal-text {
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.reveal-answer {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  font-weight: 600;
}

/* Game puzzles */
.game-grid {
  display: inline-grid;
  gap: 2px;
  margin: 1rem 0;
}

.game-cell {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1.2rem;
  cursor: pointer;
  background: var(--surface);
  transition: background 0.1s;
}

.game-status {
  font-size: 1rem;
  font-weight: 600;
  margin: 0.75rem 0;
  min-height: 1.5em;
}

/* Mobile */
@media (max-width: 600px) {
  #app {
    padding: 0.75rem;
  }

  #header h1 {
    font-size: 1.25rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .puzzle-container {
    padding: 1rem;
  }

  .game-cell {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
}
