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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 100%;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

#puzzle-title {
  color: #333;
  font-size: 1.5rem;
}

.help-btn {
  background: none;
  border: 1px solid #9ca3af;
  border-radius: 6px;
  color: #6b7280;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 4px 8px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.help-btn:hover {
  border-color: #6366f1;
  color: #6366f1;
}

.help-text {
  background: #f0f4ff;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  color: #4338ca;
  font-size: 0.85rem;
  line-height: 1.6;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.help-text p + p {
  margin-top: 4px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 8px;
  /* aspect-ratio keeps the grid square; padding-bottom adds buffer below cells
     so that subpixel rounding never causes cells to exceed the grid bounding box */
  aspect-ratio: 1;
  padding-bottom: 4px;
  margin-bottom: 20px;
}

.cell {
  min-height: 0;
  min-width: 0;
  background: #f5f5f5;
  border: 2px solid #ddd;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.cell:hover:not(.clue-cell) {
  background: #e8e8e8;
  border-color: #bbb;
}

.cell.clue-cell {
  background: #e0e7ff;
  border-color: #6366f1;
  border-style: dashed;
  cursor: not-allowed;
  position: relative;
}

.cell.clue-cell::before {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px dotted #6366f1;
  border-radius: 4px;
  pointer-events: none;
}

.grid.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.message {
  text-align: center;
  min-height: 24px;
  margin-bottom: 16px;
  font-weight: 600;
  color: #333;
}

.message.success {
  color: #059669;
  font-size: 1.1rem;
}

.message.error {
  color: #dc2626;
}

.controls {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.btn {
  flex: 1;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: #6366f1;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #4f46e5;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-secondary {
  background: #e5e7eb;
  color: #374151;
}

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

.attempts {
  text-align: center;
  color: #6b7280;
  font-size: 0.9rem;
}

@media (max-width: 320px) {
  .container {
    padding: 16px;
  }

  .cell {
    font-size: 1.5rem;
  }

  .btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }
}
